2001-01-16 22:56:29 +01:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
npc.cpp
|
|
|
|
|
|
|
|
Author: CRB
|
2001-01-22 23:24:53 +01:00
|
|
|
Created:
|
2001-01-16 22:56:29 +01:00
|
|
|
Project: Spongebob
|
2001-01-22 23:24:53 +01:00
|
|
|
Purpose:
|
2001-01-16 22:56:29 +01:00
|
|
|
|
|
|
|
Copyright (c) 2000 Climax Development Ltd
|
|
|
|
|
|
|
|
===========================================================================*/
|
|
|
|
|
2001-01-16 20:35:34 +01:00
|
|
|
#include "enemy\npc.h"
|
|
|
|
|
|
|
|
#ifndef __LEVEL_LEVEL_H__
|
|
|
|
#include "level\level.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __FILE_EQUATES_H__
|
|
|
|
#include <biglump.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __GAME_GAME_H__
|
|
|
|
#include "game\game.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PLAYER_PLAYER_H__
|
|
|
|
#include "player\player.h"
|
|
|
|
#endif
|
|
|
|
|
2001-01-18 20:18:39 +01:00
|
|
|
#ifndef __ENEMY_NPCPATH_H__
|
|
|
|
#include "enemy\npcpath.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __UTILS_HEADER__
|
|
|
|
#include "utils\utils.h"
|
|
|
|
#endif
|
|
|
|
|
2001-01-22 21:57:39 +01:00
|
|
|
#ifndef __GAME_CONVO_H__
|
|
|
|
#include "game\convo.h"
|
|
|
|
#endif
|
|
|
|
|
2001-04-01 22:22:49 +02:00
|
|
|
|
|
|
|
#include "Gfx\actor.h"
|
2001-01-16 20:35:34 +01:00
|
|
|
|
2001-02-27 22:25:22 +01:00
|
|
|
#ifndef __VID_HEADER_
|
|
|
|
#include "system\vid.h"
|
|
|
|
#endif
|
|
|
|
|
2001-04-04 00:01:52 +02:00
|
|
|
#ifndef __PROJECTL_PROJECTL_H__
|
|
|
|
#include "projectl\projectl.h"
|
|
|
|
#endif
|
|
|
|
|
2001-02-27 22:25:22 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Friend NPCs
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcFriend::init()
|
|
|
|
{
|
|
|
|
CNpcThing::init();
|
|
|
|
|
|
|
|
Pos.vx = 100;
|
|
|
|
Pos.vy = 100;
|
|
|
|
|
|
|
|
m_extension = EXTEND_RIGHT;
|
|
|
|
|
|
|
|
// temporary
|
2001-04-02 17:52:09 +02:00
|
|
|
m_actorGfx=CActorPool::GetActor(ACTORS_CLAM_SBK);
|
|
|
|
|
|
|
|
//m_animPlaying = true;
|
2001-02-27 22:25:22 +01:00
|
|
|
m_animNo = 0;
|
|
|
|
m_frame = 0;
|
2001-04-04 18:51:04 +02:00
|
|
|
m_reversed = false;
|
2001-02-27 22:25:22 +01:00
|
|
|
|
2001-03-22 20:10:19 +01:00
|
|
|
DVECTOR ofs = getCollisionSize();
|
|
|
|
|
|
|
|
m_drawOffset.vx = 0;
|
|
|
|
m_drawOffset.vy = -( ofs.vy >> 1 );
|
|
|
|
|
|
|
|
setCollisionCentreOffset( 0, -( ofs.vy >> 1 ) );
|
|
|
|
|
2001-02-27 22:25:22 +01:00
|
|
|
//m_spriteBank=new ("enemy sprites") SpriteBank();
|
|
|
|
//m_spriteBank->load(UI_UIGFX_SPR);
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcFriend::shutdown()
|
|
|
|
{
|
|
|
|
//m_spriteBank->dump(); delete m_spriteBank;
|
|
|
|
|
|
|
|
CNpcThing::shutdown();
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcFriend::think(int _frames)
|
|
|
|
{
|
|
|
|
CNpcThing::think(_frames);
|
|
|
|
|
|
|
|
switch( m_data[m_type].movementFunc )
|
|
|
|
{
|
|
|
|
case NPC_FRIEND_MOVEMENT_GARY:
|
|
|
|
processGaryMovement( _frames );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NPC_FRIEND_MOVEMENT_STATIC:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcFriend::render()
|
|
|
|
{
|
|
|
|
CNpcThing::render();
|
|
|
|
|
|
|
|
// Render
|
|
|
|
DVECTOR renderPos;
|
|
|
|
DVECTOR offset = CLevel::getCameraPos();
|
|
|
|
|
2001-04-04 18:51:04 +02:00
|
|
|
renderPos.vx = Pos.vx - offset.vx;
|
|
|
|
renderPos.vy = Pos.vy - offset.vy;
|
2001-02-27 22:25:22 +01:00
|
|
|
|
2001-04-04 18:51:04 +02:00
|
|
|
if ( renderPos.vx >= 0 && renderPos.vx <= VidGetScrW() )
|
|
|
|
{
|
|
|
|
if ( renderPos.vy >= 0 && renderPos.vy <= VidGetScrH() )
|
|
|
|
{
|
|
|
|
m_actorGfx->Render(renderPos,m_animNo,m_frame,m_reversed);
|
|
|
|
}
|
|
|
|
}
|
2001-02-27 22:25:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcFriend::processEvent( GAME_EVENT evt, CThing *sourceThing )
|
|
|
|
{
|
|
|
|
switch( evt )
|
|
|
|
{
|
|
|
|
case USER_REQUEST_TALK_EVENT:
|
|
|
|
{
|
|
|
|
if ( m_data[this->m_type].canTalk )
|
|
|
|
{
|
|
|
|
DVECTOR sourcePos;
|
|
|
|
s32 xDiffSqr, yDiffSqr;
|
|
|
|
|
|
|
|
// check talk distance
|
|
|
|
|
|
|
|
sourcePos = sourceThing->getPos();
|
|
|
|
|
|
|
|
xDiffSqr = this->Pos.vx - sourcePos.vx;
|
|
|
|
xDiffSqr *= xDiffSqr;
|
|
|
|
|
|
|
|
yDiffSqr = this->Pos.vy - sourcePos.vy;
|
|
|
|
yDiffSqr *= yDiffSqr;
|
|
|
|
|
|
|
|
if ( xDiffSqr + yDiffSqr < 10000 )
|
|
|
|
{
|
|
|
|
if( !CConversation::isActive() )
|
|
|
|
{
|
|
|
|
CConversation::trigger( SCRIPTS_SPEECHTEST_DAT );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
// ignore
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Enemy NPCs
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
s32 CNpcEnemy::playerXDist;
|
|
|
|
s32 CNpcEnemy::playerYDist;
|
|
|
|
s32 CNpcEnemy::playerXDistSqr;
|
|
|
|
s32 CNpcEnemy::playerYDistSqr;
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2001-04-02 21:21:46 +02:00
|
|
|
void CNpcEnemy::setTypeFromMapEdit( u16 newType )
|
|
|
|
{
|
|
|
|
m_type = mapEditConvertTable[newType - NPC_ENEMY_MAPEDIT_OFFSET];
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcEnemy::addWaypoint( s32 xPos, s32 yPos )
|
|
|
|
{
|
|
|
|
DVECTOR newPos;
|
|
|
|
|
|
|
|
newPos.vx = xPos << 4;
|
|
|
|
newPos.vy = yPos << 4;
|
|
|
|
|
|
|
|
m_npcPath.addWaypoint( newPos );
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcEnemy::setStartPos( s32 xPos, s32 yPos )
|
|
|
|
{
|
|
|
|
Pos.vx = xPos << 4;
|
|
|
|
Pos.vy = yPos << 4;
|
2001-04-03 17:36:31 +02:00
|
|
|
|
|
|
|
m_base = Pos;
|
2001-04-02 21:21:46 +02:00
|
|
|
}
|
|
|
|
|
2001-04-03 22:03:16 +02:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Static function to initialise the actor pool with levels nasty folk
|
|
|
|
void CNpcEnemy::CacheActor(int Type)
|
|
|
|
{
|
|
|
|
int m_type = mapEditConvertTable[Type - NPC_ENEMY_MAPEDIT_OFFSET];
|
|
|
|
|
|
|
|
CActorPool::GetActor(m_data[m_type].skelType);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2001-04-02 21:21:46 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2001-02-27 22:25:22 +01:00
|
|
|
void CNpcEnemy::init()
|
2001-01-16 20:35:34 +01:00
|
|
|
{
|
2001-02-27 17:59:50 +01:00
|
|
|
CEnemyThing::init();
|
|
|
|
|
2001-04-01 22:22:49 +02:00
|
|
|
m_actorGfx=CActorPool::GetActor(m_data[m_type].skelType);
|
2001-02-27 22:25:22 +01:00
|
|
|
|
2001-02-28 22:05:39 +01:00
|
|
|
m_animPlaying = true;
|
|
|
|
m_animNo = m_data[m_type].initAnim;
|
2001-02-27 22:25:22 +01:00
|
|
|
m_frame = 0;
|
|
|
|
|
2001-04-04 17:53:44 +02:00
|
|
|
m_heading = m_fireHeading = 0;
|
2001-01-18 20:18:39 +01:00
|
|
|
m_movementTimer = 0;
|
|
|
|
m_timerTimer = 0;
|
|
|
|
m_velocity = 0;
|
2001-01-18 22:19:43 +01:00
|
|
|
m_extension = 0;
|
2001-02-23 22:35:11 +01:00
|
|
|
m_rotation = 0;
|
2001-02-28 22:05:39 +01:00
|
|
|
m_reversed = false;
|
2001-03-13 18:01:35 +01:00
|
|
|
m_salvoCount = 0;
|
2001-01-18 20:18:39 +01:00
|
|
|
|
2001-03-05 22:29:44 +01:00
|
|
|
m_health = m_data[this->m_type].initHealth;
|
|
|
|
|
2001-03-13 21:45:51 +01:00
|
|
|
m_extendDir = EXTEND_RIGHT;
|
2001-02-12 21:03:44 +01:00
|
|
|
|
2001-01-18 20:18:39 +01:00
|
|
|
m_timerFunc = m_data[this->m_type].timerFunc;
|
|
|
|
m_sensorFunc = m_data[this->m_type].sensorFunc;
|
2001-01-16 20:35:34 +01:00
|
|
|
|
2001-01-22 20:48:57 +01:00
|
|
|
m_controlFunc = NPC_CONTROL_MOVEMENT;
|
|
|
|
|
2001-03-01 20:32:05 +01:00
|
|
|
m_npcPath.initPath();
|
|
|
|
|
2001-03-22 20:10:19 +01:00
|
|
|
DVECTOR ofs = getCollisionSize();
|
|
|
|
|
|
|
|
m_drawOffset.vx = 0;
|
2001-04-04 17:53:44 +02:00
|
|
|
m_drawOffset.vy = 0;
|
2001-03-22 20:10:19 +01:00
|
|
|
|
2001-04-04 17:53:44 +02:00
|
|
|
setCollisionCentreOffset( 0, -( ofs.vy >> 1 ) );
|
2001-03-22 20:10:19 +01:00
|
|
|
|
2001-03-30 19:26:29 +02:00
|
|
|
m_positionHistory = NULL;
|
2001-04-04 00:01:52 +02:00
|
|
|
}
|
2001-03-30 19:26:29 +02:00
|
|
|
|
2001-04-04 00:01:52 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcEnemy::postInit()
|
|
|
|
{
|
2001-01-16 20:35:34 +01:00
|
|
|
switch ( m_data[this->m_type].initFunc )
|
|
|
|
{
|
|
|
|
case NPC_INIT_DEFAULT:
|
2001-01-23 18:03:27 +01:00
|
|
|
{
|
2001-04-02 21:21:46 +02:00
|
|
|
m_npcPath.setPathType( CNpcPath::PONG_PATH );
|
2001-01-18 20:18:39 +01:00
|
|
|
|
2001-01-16 20:35:34 +01:00
|
|
|
break;
|
2001-01-23 18:03:27 +01:00
|
|
|
}
|
2001-01-16 20:35:34 +01:00
|
|
|
|
2001-04-04 17:53:44 +02:00
|
|
|
case NPC_INIT_BALL_BLOB:
|
|
|
|
{
|
|
|
|
m_heading = m_fireHeading = 128;
|
|
|
|
|
|
|
|
m_npcPath.setPathType( CNpcPath::PONG_PATH );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-04-02 17:52:09 +02:00
|
|
|
case NPC_INIT_HERMIT_CRAB:
|
|
|
|
{
|
2001-04-02 21:21:46 +02:00
|
|
|
m_npcPath.setPathType( CNpcPath::PONG_PATH );
|
2001-04-02 17:52:09 +02:00
|
|
|
|
|
|
|
m_state = HERMIT_CRAB_NO_ATTACK;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-01-22 20:48:57 +01:00
|
|
|
case NPC_INIT_GHOST_PIRATE:
|
|
|
|
m_heading = m_fireHeading = 3072;
|
|
|
|
|
2001-01-23 18:03:27 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NPC_INIT_SKULL_STOMPER:
|
|
|
|
{
|
2001-02-14 17:04:41 +01:00
|
|
|
m_extendDir = EXTEND_DOWN;
|
2001-01-23 18:03:27 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-01-25 16:45:15 +01:00
|
|
|
case NPC_INIT_MOTHER_JELLYFISH:
|
|
|
|
{
|
2001-03-12 20:14:38 +01:00
|
|
|
m_state = MOTHER_JELLYFISH_RETURN_TO_START_1;
|
2001-01-25 16:45:15 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-01-25 18:20:08 +01:00
|
|
|
case NPC_INIT_FLYING_DUTCHMAN:
|
2001-01-25 16:45:15 +01:00
|
|
|
{
|
|
|
|
m_state = FLYING_DUTCHMAN_ATTACK_PLAYER_1;
|
|
|
|
m_extendDir = EXTEND_UP;
|
2001-03-13 21:45:51 +01:00
|
|
|
m_extension = 100;
|
2001-01-25 16:45:15 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-01-25 18:20:08 +01:00
|
|
|
case NPC_INIT_SUB_SHARK:
|
|
|
|
{
|
2001-03-13 18:01:35 +01:00
|
|
|
m_state = SUB_SHARK_MINE_1;
|
2001-01-25 18:20:08 +01:00
|
|
|
m_extendDir = EXTEND_RIGHT;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-01-25 20:57:29 +01:00
|
|
|
case NPC_INIT_IRON_DOGFISH:
|
|
|
|
{
|
|
|
|
m_state = IRON_DOGFISH_THUMP_1;
|
|
|
|
m_extendDir = EXTEND_RIGHT;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-01-29 21:11:05 +01:00
|
|
|
case NPC_INIT_FISH_HOOK:
|
|
|
|
{
|
|
|
|
m_heading = m_fireHeading = 3072;
|
|
|
|
|
|
|
|
DVECTOR newPos;
|
|
|
|
|
2001-01-29 17:55:11 +01:00
|
|
|
newPos.vx = 100;
|
|
|
|
newPos.vy = -100;
|
|
|
|
|
|
|
|
m_npcPath.addWaypoint( newPos );
|
|
|
|
|
2001-04-02 21:21:46 +02:00
|
|
|
m_npcPath.setPathType( CNpcPath::SINGLE_USE_PATH );
|
2001-01-29 17:55:11 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-01-29 22:46:54 +01:00
|
|
|
case NPC_INIT_PENDULUM:
|
|
|
|
{
|
|
|
|
m_extendDir = EXTEND_LEFT;
|
|
|
|
m_extension = 0;
|
|
|
|
m_heading = 1024;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-01-30 21:30:52 +01:00
|
|
|
case NPC_INIT_FIREBALL:
|
|
|
|
{
|
|
|
|
DVECTOR newPos;
|
|
|
|
|
2001-01-30 23:58:25 +01:00
|
|
|
newPos.vx = 300;
|
2001-01-30 21:30:52 +01:00
|
|
|
newPos.vy = 100;
|
|
|
|
|
|
|
|
m_npcPath.addWaypoint( newPos );
|
2001-04-02 21:21:46 +02:00
|
|
|
m_npcPath.setPathType( CNpcPath::SINGLE_USE_PATH );
|
2001-01-30 21:30:52 +01:00
|
|
|
|
2001-01-30 23:58:25 +01:00
|
|
|
m_extension = 0;
|
2001-01-30 21:30:52 +01:00
|
|
|
m_velocity = m_data[m_type].speed;
|
|
|
|
m_timerTimer = GameState::getOneSecondInFrames() * 4;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-01-31 17:26:40 +01:00
|
|
|
case NPC_INIT_RETURNING_HAZARD:
|
2001-01-31 17:14:12 +01:00
|
|
|
{
|
|
|
|
DVECTOR newPos;
|
|
|
|
|
|
|
|
newPos.vx = 100;
|
|
|
|
newPos.vy = 10;
|
|
|
|
|
|
|
|
m_npcPath.addWaypoint( newPos );
|
|
|
|
|
|
|
|
newPos.vx = 500;
|
|
|
|
newPos.vy = 10;
|
|
|
|
|
|
|
|
m_npcPath.addWaypoint( newPos );
|
|
|
|
|
2001-04-02 21:21:46 +02:00
|
|
|
m_npcPath.setPathType( CNpcPath::SINGLE_USE_PATH );
|
2001-01-31 17:14:12 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-02-05 15:55:11 +01:00
|
|
|
case NPC_INIT_FISH_FOLK:
|
|
|
|
{
|
|
|
|
m_heading = m_fireHeading = 0;
|
|
|
|
|
|
|
|
DVECTOR newPos;
|
|
|
|
|
2001-02-22 16:39:38 +01:00
|
|
|
newPos.vx = 200;
|
|
|
|
newPos.vy = 400;
|
2001-02-05 15:55:11 +01:00
|
|
|
|
|
|
|
m_npcPath.addWaypoint( newPos );
|
|
|
|
|
|
|
|
newPos.vx = 500;
|
2001-02-22 16:39:38 +01:00
|
|
|
newPos.vy = 400;
|
2001-02-05 15:55:11 +01:00
|
|
|
|
|
|
|
m_npcPath.addWaypoint( newPos );
|
|
|
|
|
2001-04-02 21:21:46 +02:00
|
|
|
m_npcPath.setPathType( CNpcPath::PONG_PATH );
|
2001-02-05 15:55:11 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-02-23 22:35:11 +01:00
|
|
|
case NPC_INIT_FLAMING_SKULL:
|
2001-02-06 20:29:35 +01:00
|
|
|
{
|
|
|
|
m_state = FLAMING_SKULL_ATTACK;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-04-04 00:01:52 +02:00
|
|
|
case NPC_INIT_EYEBALL:
|
|
|
|
{
|
|
|
|
CProjectile *projectile;
|
|
|
|
projectile = new ( "eyeball projectile" ) CProjectile;
|
|
|
|
projectile->init( Pos, m_fireHeading, CProjectile::PROJECTILE_FIXED, CProjectile::PROJECTILE_INFINITE_LIFE );
|
|
|
|
|
|
|
|
addChild( projectile );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-04-04 17:53:44 +02:00
|
|
|
case NPC_INIT_ANEMONE_2:
|
|
|
|
{
|
|
|
|
CProjectile *projectile;
|
|
|
|
s16 heading;
|
|
|
|
|
|
|
|
for ( int fireLoop = 0 ; fireLoop < 5 ; fireLoop++ )
|
|
|
|
{
|
|
|
|
DVECTOR spikePos;
|
|
|
|
|
|
|
|
heading = m_heading - 1024 + ( fireLoop * 512 );
|
|
|
|
heading %= 4096;
|
|
|
|
|
|
|
|
spikePos = Pos;
|
|
|
|
spikePos.vx += ( 10 * rcos( heading ) ) >> 12;
|
|
|
|
spikePos.vy += ( 10 * rsin( heading ) ) >> 12;
|
|
|
|
|
|
|
|
projectile = new( "anemone lev2 projectile" ) CProjectile;
|
|
|
|
projectile->init( spikePos, heading, CProjectile::PROJECTILE_FIXED, CProjectile::PROJECTILE_INFINITE_LIFE );
|
|
|
|
|
|
|
|
addChild( projectile );
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-02-23 22:35:11 +01:00
|
|
|
case NPC_INIT_CIRCULAR_PLATFORM:
|
|
|
|
{
|
|
|
|
Pos.vx = 300;
|
|
|
|
Pos.vy = 300;
|
|
|
|
|
|
|
|
m_base = Pos;
|
|
|
|
|
|
|
|
m_extendDir = EXTEND_CLOCKWISE;
|
|
|
|
m_extension = 100;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-03-26 18:44:45 +02:00
|
|
|
case NPC_INIT_PARASITIC_WORM:
|
|
|
|
{
|
|
|
|
DVECTOR newPos;
|
|
|
|
|
|
|
|
newPos.vx = 100;
|
|
|
|
//newPos.vy = 10;
|
|
|
|
newPos.vy = 100;
|
|
|
|
|
|
|
|
m_npcPath.addWaypoint( newPos );
|
|
|
|
|
|
|
|
newPos.vx = 500;
|
|
|
|
//newPos.vy = 10;
|
|
|
|
newPos.vy = 100;
|
|
|
|
|
|
|
|
m_npcPath.addWaypoint( newPos );
|
|
|
|
|
|
|
|
newPos.vx = 500;
|
|
|
|
//newPos.vy = 100;
|
|
|
|
newPos.vy = 300;
|
|
|
|
|
|
|
|
m_npcPath.addWaypoint( newPos );
|
|
|
|
|
|
|
|
newPos.vx = 100;
|
|
|
|
//newPos.vy = 100;
|
|
|
|
newPos.vy = 300;
|
|
|
|
|
|
|
|
m_npcPath.addWaypoint( newPos );
|
|
|
|
|
2001-04-02 21:21:46 +02:00
|
|
|
m_npcPath.setPathType( CNpcPath::PONG_PATH );
|
2001-03-26 18:44:45 +02:00
|
|
|
|
|
|
|
// create head of list
|
|
|
|
CNpcPositionHistory *newPosition;
|
|
|
|
newPosition = new ("position history") CNpcPositionHistory;
|
|
|
|
newPosition->pos = Pos;
|
|
|
|
m_positionHistory = newPosition;
|
|
|
|
|
|
|
|
CNpcPositionHistory *currentPosition = m_positionHistory;
|
|
|
|
|
|
|
|
// create rest of list
|
|
|
|
|
|
|
|
for ( int histLength = 1 ; histLength < ( 10 * NPC_PARASITIC_WORM_SPACING ) ; histLength++ )
|
|
|
|
{
|
|
|
|
newPosition = new ("position history") CNpcPositionHistory;
|
|
|
|
newPosition->pos = Pos;
|
|
|
|
newPosition->next = NULL;
|
|
|
|
|
|
|
|
currentPosition->next = newPosition;
|
|
|
|
currentPosition = newPosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( int segCount = 0 ; segCount < 10 ; segCount++ )
|
|
|
|
{
|
|
|
|
CNpcEnemy *segment;
|
|
|
|
segment = new ("segment") CNpcEnemy;
|
|
|
|
segment->setType( CNpcEnemy::NPC_PARASITIC_WORM_SEGMENT );
|
|
|
|
segment->init();
|
|
|
|
segment->setLayerCollision( m_layerCollision );
|
|
|
|
|
|
|
|
this->addChild( segment );
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NPC_INIT_PARASITIC_WORM_SEGMENT:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-01-16 20:35:34 +01:00
|
|
|
default:
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-27 22:25:22 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
2001-01-16 20:35:34 +01:00
|
|
|
|
2001-02-27 22:25:22 +01:00
|
|
|
void CNpcEnemy::shutdown()
|
2001-01-16 20:35:34 +01:00
|
|
|
{
|
2001-03-30 19:26:29 +02:00
|
|
|
// remove waypoints
|
|
|
|
|
2001-01-26 16:16:07 +01:00
|
|
|
m_npcPath.removeAllWaypoints();
|
2001-02-27 17:59:50 +01:00
|
|
|
|
2001-03-30 19:26:29 +02:00
|
|
|
// remove position history
|
|
|
|
|
|
|
|
CNpcPositionHistory *currentPosition;
|
|
|
|
CNpcPositionHistory *oldPosition;
|
|
|
|
|
|
|
|
currentPosition = m_positionHistory;
|
|
|
|
|
|
|
|
while( currentPosition )
|
|
|
|
{
|
|
|
|
oldPosition = currentPosition;
|
|
|
|
currentPosition = currentPosition->next;
|
|
|
|
|
|
|
|
delete oldPosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_positionHistory = NULL;
|
|
|
|
|
2001-03-01 20:08:18 +01:00
|
|
|
// temporary
|
2001-02-27 17:59:50 +01:00
|
|
|
CEnemyThing::shutdown();
|
2001-01-16 20:35:34 +01:00
|
|
|
}
|
|
|
|
|
2001-02-27 22:25:22 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
2001-01-16 20:35:34 +01:00
|
|
|
|
2001-02-27 22:25:22 +01:00
|
|
|
void CNpcEnemy::think(int _frames)
|
2001-01-16 20:35:34 +01:00
|
|
|
{
|
2001-02-27 17:59:50 +01:00
|
|
|
CEnemyThing::think(_frames);
|
|
|
|
|
2001-02-07 17:42:13 +01:00
|
|
|
processGenericGetUserDist( _frames, &playerXDist, &playerYDist );
|
|
|
|
playerXDistSqr = playerXDist * playerXDist;
|
|
|
|
playerYDistSqr = playerYDist * playerYDist;
|
|
|
|
|
2001-02-28 22:05:39 +01:00
|
|
|
if ( m_animPlaying )
|
|
|
|
{
|
2001-04-01 22:22:49 +02:00
|
|
|
int frameCount = m_actorGfx->getFrameCount(m_animNo);
|
2001-02-28 22:05:39 +01:00
|
|
|
|
2001-04-04 00:01:52 +02:00
|
|
|
if ( frameCount - m_frame > _frames >> 1 )
|
2001-02-28 22:05:39 +01:00
|
|
|
{
|
2001-04-04 00:01:52 +02:00
|
|
|
m_frame += _frames >> 1;
|
2001-02-28 22:05:39 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-04-02 17:52:09 +02:00
|
|
|
m_frame = frameCount - 1;
|
2001-02-28 22:05:39 +01:00
|
|
|
m_animPlaying = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-16 20:35:34 +01:00
|
|
|
switch ( this->m_controlFunc )
|
|
|
|
{
|
2001-01-29 17:55:11 +01:00
|
|
|
case NPC_CONTROL_NONE:
|
|
|
|
return;
|
|
|
|
|
2001-01-16 20:35:34 +01:00
|
|
|
case NPC_CONTROL_MOVEMENT:
|
|
|
|
if ( !processSensor() )
|
|
|
|
{
|
2001-01-18 20:18:39 +01:00
|
|
|
processMovement(_frames);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
processClose(_frames);
|
2001-01-16 20:35:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NPC_CONTROL_SHOT:
|
|
|
|
processShot();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NPC_CONTROL_CLOSE:
|
2001-01-18 20:18:39 +01:00
|
|
|
processClose(_frames);
|
2001-01-16 20:35:34 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NPC_CONTROL_COLLISION:
|
|
|
|
processCollision();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-01-18 20:18:39 +01:00
|
|
|
processTimer(_frames);
|
2001-04-02 21:25:37 +02:00
|
|
|
|
|
|
|
if ( m_heading > 1024 && m_heading < 3072 )
|
|
|
|
{
|
|
|
|
m_reversed = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_reversed = false;
|
|
|
|
}
|
2001-01-16 20:35:34 +01:00
|
|
|
}
|
|
|
|
|
2001-02-27 22:25:22 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
2001-01-16 20:35:34 +01:00
|
|
|
|
2001-03-05 22:11:51 +01:00
|
|
|
void CNpcEnemy::collidedWith( CThing *_thisThing )
|
2001-02-07 17:42:13 +01:00
|
|
|
{
|
2001-03-05 22:11:51 +01:00
|
|
|
switch(_thisThing->getThingType())
|
2001-02-07 17:42:13 +01:00
|
|
|
{
|
2001-03-05 22:11:51 +01:00
|
|
|
case TYPE_PLAYER:
|
|
|
|
{
|
|
|
|
if ( m_data[m_type].detectCollision )
|
|
|
|
{
|
2001-03-06 21:13:16 +01:00
|
|
|
if ( m_data[m_type].damageToUserType == DAMAGE__NONE )
|
|
|
|
{
|
|
|
|
// if we can detect a collision, but the collision does no damage, this must be a platform
|
|
|
|
|
|
|
|
CPlayer *player = (CPlayer *) _thisThing;
|
|
|
|
|
|
|
|
player->setPlatform( this );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_oldControlFunc = m_controlFunc;
|
|
|
|
m_controlFunc = NPC_CONTROL_COLLISION;
|
|
|
|
}
|
2001-03-05 22:11:51 +01:00
|
|
|
}
|
2001-02-07 17:42:13 +01:00
|
|
|
|
2001-03-05 22:11:51 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
ASSERT(0);
|
|
|
|
break;
|
2001-02-07 17:42:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-27 22:25:22 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
2001-02-07 17:42:13 +01:00
|
|
|
|
2001-02-27 22:25:22 +01:00
|
|
|
bool CNpcEnemy::processSensor()
|
2001-01-16 20:35:34 +01:00
|
|
|
{
|
2001-01-18 20:18:39 +01:00
|
|
|
switch( m_sensorFunc )
|
2001-01-16 20:35:34 +01:00
|
|
|
{
|
|
|
|
case NPC_SENSOR_NONE:
|
|
|
|
return( false );
|
|
|
|
|
2001-01-18 22:19:43 +01:00
|
|
|
default:
|
|
|
|
{
|
|
|
|
switch( m_sensorFunc )
|
|
|
|
{
|
|
|
|
case NPC_SENSOR_JELLYFISH_USER_CLOSE:
|
|
|
|
{
|
2001-02-22 22:00:56 +01:00
|
|
|
if ( playerXDistSqr + playerYDistSqr < 5625 )
|
2001-01-18 22:19:43 +01:00
|
|
|
{
|
2001-01-19 22:46:30 +01:00
|
|
|
m_controlFunc = NPC_CONTROL_CLOSE;
|
2001-02-21 22:53:06 +01:00
|
|
|
m_evadeClockwise = getRnd() % 2;
|
2001-01-18 22:19:43 +01:00
|
|
|
|
|
|
|
return( true );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
}
|
2001-01-18 20:18:39 +01:00
|
|
|
|
2001-01-18 22:19:43 +01:00
|
|
|
case NPC_SENSOR_CLAM_USER_CLOSE:
|
|
|
|
{
|
2001-02-07 17:42:13 +01:00
|
|
|
if ( playerXDistSqr + playerYDistSqr < 10000 )
|
2001-01-18 22:19:43 +01:00
|
|
|
{
|
2001-01-19 22:46:30 +01:00
|
|
|
m_controlFunc = NPC_CONTROL_CLOSE;
|
|
|
|
m_extendDir = EXTEND_UP;
|
|
|
|
m_extension = 0;
|
|
|
|
m_movementTimer = GameState::getOneSecondInFrames() >> 3;
|
|
|
|
m_velocity = ( getRnd() % 6 ) + 1;
|
|
|
|
|
|
|
|
return( true );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case NPC_SENSOR_SPIDER_CRAB_USER_CLOSE:
|
|
|
|
{
|
2001-02-07 17:42:13 +01:00
|
|
|
if ( playerXDistSqr + playerYDistSqr < 10000 )
|
2001-01-19 22:46:30 +01:00
|
|
|
{
|
2001-04-04 22:10:29 +02:00
|
|
|
// only attack if within path extents
|
|
|
|
|
|
|
|
s32 minX, maxX;
|
|
|
|
m_npcPath.getPathXExtents( &minX, &maxX );
|
2001-01-19 22:46:30 +01:00
|
|
|
|
2001-02-07 17:42:13 +01:00
|
|
|
if ( playerXDist < 0 )
|
2001-01-19 22:46:30 +01:00
|
|
|
{
|
|
|
|
m_extendDir = EXTEND_LEFT;
|
2001-04-04 22:10:29 +02:00
|
|
|
|
|
|
|
if ( ( Pos.vx + playerXDist - 128 ) < minX )
|
|
|
|
{
|
|
|
|
return( false );
|
|
|
|
}
|
2001-01-19 22:46:30 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_extendDir = EXTEND_RIGHT;
|
2001-04-04 22:10:29 +02:00
|
|
|
|
|
|
|
if ( ( Pos.vx + playerXDist + 128 ) > maxX )
|
|
|
|
{
|
|
|
|
return( false );
|
|
|
|
}
|
2001-01-19 22:46:30 +01:00
|
|
|
}
|
|
|
|
|
2001-04-04 22:10:29 +02:00
|
|
|
m_controlFunc = NPC_CONTROL_CLOSE;
|
|
|
|
m_extension = 0;
|
|
|
|
m_velocity = 5;
|
|
|
|
m_base = Pos;
|
|
|
|
|
2001-01-19 22:46:30 +01:00
|
|
|
return( true );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-22 15:23:11 +01:00
|
|
|
case NPC_SENSOR_OIL_BLOB_USER_CLOSE:
|
2001-01-19 22:46:30 +01:00
|
|
|
case NPC_SENSOR_NINJA_STARFISH_USER_CLOSE:
|
|
|
|
{
|
2001-02-07 17:42:13 +01:00
|
|
|
if ( playerXDistSqr + playerYDistSqr < 10000 )
|
2001-01-19 22:46:30 +01:00
|
|
|
{
|
|
|
|
m_controlFunc = NPC_CONTROL_CLOSE;
|
|
|
|
m_velocity = m_data[m_type].speed;
|
2001-01-16 20:35:34 +01:00
|
|
|
|
2001-01-18 22:19:43 +01:00
|
|
|
return( true );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-19 22:46:30 +01:00
|
|
|
case NPC_SENSOR_GHOST_PIRATE_USER_CLOSE:
|
|
|
|
{
|
2001-02-07 17:42:13 +01:00
|
|
|
if ( playerXDistSqr + playerYDistSqr < 10000 )
|
2001-01-19 22:46:30 +01:00
|
|
|
{
|
|
|
|
m_controlFunc = NPC_CONTROL_CLOSE;
|
|
|
|
m_extendDir = EXTEND_UP;
|
|
|
|
m_extension = 0;
|
|
|
|
m_movementTimer = GameState::getOneSecondInFrames() >> 1;
|
|
|
|
m_velocity = 4;
|
|
|
|
|
|
|
|
return( true );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-12 16:37:31 +01:00
|
|
|
case NPC_SENSOR_GENERIC_USER_VISIBLE:
|
2001-01-19 22:46:30 +01:00
|
|
|
{
|
|
|
|
s32 xDistWaypoint, yDistWaypoint;
|
|
|
|
|
2001-02-07 17:42:13 +01:00
|
|
|
if ( abs( playerXDist ) < 500 )
|
2001-01-19 22:46:30 +01:00
|
|
|
{
|
|
|
|
// within range
|
|
|
|
|
2001-02-12 16:37:31 +01:00
|
|
|
// make sure user is closer to npc than next waypoint
|
2001-01-19 22:46:30 +01:00
|
|
|
|
|
|
|
s32 xDistWaypoint, yDistWaypoint;
|
|
|
|
|
|
|
|
m_npcPath.getDistToNextWaypoint( Pos, &xDistWaypoint, &yDistWaypoint );
|
|
|
|
|
2001-02-07 17:42:13 +01:00
|
|
|
if ( abs( playerXDist ) < abs( xDistWaypoint ) )
|
2001-01-19 22:46:30 +01:00
|
|
|
{
|
2001-02-07 17:42:13 +01:00
|
|
|
s16 headingToPlayer = ratan2( playerYDist, playerXDist );
|
2001-01-19 22:46:30 +01:00
|
|
|
|
|
|
|
s16 decDir, incDir, moveDist;
|
|
|
|
|
|
|
|
s32 headingToWaypoint = ratan2( yDistWaypoint, xDistWaypoint );
|
|
|
|
|
|
|
|
// check waypoint is in the same direction as the user
|
|
|
|
|
|
|
|
decDir = headingToPlayer - headingToWaypoint;
|
|
|
|
|
|
|
|
if ( decDir < 0 )
|
|
|
|
{
|
|
|
|
decDir += ONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
incDir = headingToWaypoint - headingToPlayer;
|
|
|
|
|
|
|
|
if ( incDir < 0 )
|
|
|
|
{
|
|
|
|
incDir += ONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( decDir < incDir )
|
|
|
|
{
|
|
|
|
moveDist = decDir;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
moveDist = incDir;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( moveDist > 512 )
|
|
|
|
{
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-02-12 16:37:31 +01:00
|
|
|
// check if npc is facing user
|
2001-01-19 22:46:30 +01:00
|
|
|
|
|
|
|
decDir = m_heading - headingToPlayer;
|
|
|
|
|
|
|
|
if ( decDir < 0 )
|
|
|
|
{
|
|
|
|
decDir += ONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
incDir = headingToPlayer - m_heading;
|
|
|
|
|
|
|
|
if ( incDir < 0 )
|
|
|
|
{
|
|
|
|
incDir += ONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( decDir < incDir )
|
|
|
|
{
|
|
|
|
moveDist = decDir;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
moveDist = incDir;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( moveDist < 1024 )
|
|
|
|
{
|
|
|
|
m_controlFunc = NPC_CONTROL_CLOSE;
|
|
|
|
m_velocity = 8;
|
|
|
|
|
|
|
|
return( true );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-22 17:02:38 +01:00
|
|
|
case NPC_SENSOR_ANEMONE_USER_CLOSE:
|
2001-01-25 20:57:29 +01:00
|
|
|
case NPC_SENSOR_EYEBALL_USER_CLOSE:
|
2001-02-06 20:29:35 +01:00
|
|
|
case NPC_SENSOR_FLAMING_SKULL_USER_CLOSE:
|
2001-01-22 17:02:38 +01:00
|
|
|
{
|
2001-02-07 17:42:13 +01:00
|
|
|
if ( playerXDistSqr + playerYDistSqr < 40000 )
|
2001-01-22 17:02:38 +01:00
|
|
|
{
|
|
|
|
m_controlFunc = NPC_CONTROL_CLOSE;
|
|
|
|
|
|
|
|
return( true );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-25 20:57:29 +01:00
|
|
|
case NPC_SENSOR_SKULL_STOMPER_USER_CLOSE:
|
2001-01-22 23:24:53 +01:00
|
|
|
{
|
2001-02-07 17:42:13 +01:00
|
|
|
if ( playerXDistSqr + playerYDistSqr < 40000 )
|
2001-01-22 23:24:53 +01:00
|
|
|
{
|
|
|
|
m_controlFunc = NPC_CONTROL_CLOSE;
|
2001-01-26 16:16:07 +01:00
|
|
|
m_extendDir = EXTEND_DOWN;
|
2001-01-22 23:24:53 +01:00
|
|
|
|
|
|
|
return( true );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-04-02 17:52:09 +02:00
|
|
|
case NPC_SENSOR_HERMIT_CRAB_USER_CLOSE:
|
|
|
|
{
|
|
|
|
if ( playerXDistSqr + playerYDistSqr < 400 )
|
|
|
|
{
|
|
|
|
m_controlFunc = NPC_CONTROL_CLOSE;
|
|
|
|
|
|
|
|
return( true );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-25 20:57:29 +01:00
|
|
|
case NPC_SENSOR_BOOGER_MONSTER_USER_CLOSE:
|
2001-01-23 18:03:27 +01:00
|
|
|
{
|
2001-02-07 17:42:13 +01:00
|
|
|
if ( playerXDistSqr + playerYDistSqr < 400 )
|
2001-01-23 18:03:27 +01:00
|
|
|
{
|
|
|
|
m_controlFunc = NPC_CONTROL_CLOSE;
|
2001-01-25 20:57:29 +01:00
|
|
|
m_extendDir = EXTEND_UP;
|
2001-01-23 18:03:27 +01:00
|
|
|
|
|
|
|
return( true );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-25 20:57:29 +01:00
|
|
|
case NPC_SENSOR_IRON_DOGFISH_USER_CLOSE:
|
2001-01-23 20:58:19 +01:00
|
|
|
{
|
2001-02-07 17:42:13 +01:00
|
|
|
if ( playerXDistSqr + playerYDistSqr < 10000 )
|
2001-01-23 20:58:19 +01:00
|
|
|
{
|
|
|
|
m_controlFunc = NPC_CONTROL_CLOSE;
|
|
|
|
|
|
|
|
return( true );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-29 17:55:11 +01:00
|
|
|
case NPC_SENSOR_FISH_HOOK_USER_CLOSE:
|
|
|
|
{
|
2001-02-07 17:42:13 +01:00
|
|
|
if ( playerXDistSqr + playerYDistSqr < 400 )
|
2001-01-29 17:55:11 +01:00
|
|
|
{
|
|
|
|
m_controlFunc = NPC_CONTROL_CLOSE;
|
|
|
|
|
|
|
|
return( true );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-29 21:11:05 +01:00
|
|
|
case NPC_SENSOR_FALLING_ITEM_USER_CLOSE:
|
|
|
|
{
|
2001-02-07 17:42:13 +01:00
|
|
|
if ( playerXDistSqr + playerYDistSqr < 40000 )
|
2001-01-29 21:11:05 +01:00
|
|
|
{
|
|
|
|
m_controlFunc = NPC_CONTROL_CLOSE;
|
|
|
|
m_movementTimer = GameState::getOneSecondInFrames() * 3;
|
|
|
|
|
|
|
|
return( true );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-04-03 17:14:53 +02:00
|
|
|
case NPC_SENSOR_OCTOPUS_USER_CLOSE:
|
|
|
|
{
|
|
|
|
if ( playerXDistSqr + playerYDistSqr < 400 )
|
|
|
|
{
|
|
|
|
m_controlFunc = NPC_CONTROL_CLOSE;
|
|
|
|
|
|
|
|
return( true );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-18 22:19:43 +01:00
|
|
|
default:
|
|
|
|
return( false );
|
|
|
|
}
|
2001-01-16 20:35:34 +01:00
|
|
|
}
|
|
|
|
|
2001-01-18 22:19:43 +01:00
|
|
|
break;
|
2001-01-18 20:18:39 +01:00
|
|
|
}
|
2001-01-16 20:35:34 +01:00
|
|
|
}
|
|
|
|
|
2001-02-27 22:25:22 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcEnemy::processMovement(int _frames)
|
2001-01-16 20:35:34 +01:00
|
|
|
{
|
2001-01-18 20:18:39 +01:00
|
|
|
if ( _frames > 2 )
|
2001-01-16 20:35:34 +01:00
|
|
|
{
|
2001-01-18 20:18:39 +01:00
|
|
|
_frames = 2;
|
|
|
|
}
|
2001-01-16 20:35:34 +01:00
|
|
|
|
2001-01-18 20:18:39 +01:00
|
|
|
s32 moveX = 0, moveY = 0;
|
|
|
|
s32 moveVel = 0;
|
2001-02-22 22:00:56 +01:00
|
|
|
s32 moveDist = 0;
|
2001-01-16 20:35:34 +01:00
|
|
|
|
2001-01-18 20:18:39 +01:00
|
|
|
switch( m_data[this->m_type].movementFunc )
|
|
|
|
{
|
|
|
|
case NPC_MOVEMENT_STATIC:
|
|
|
|
{
|
2001-01-16 20:35:34 +01:00
|
|
|
break;
|
2001-01-18 20:18:39 +01:00
|
|
|
}
|
2001-01-16 20:35:34 +01:00
|
|
|
|
2001-04-02 17:52:09 +02:00
|
|
|
case NPC_MOVEMENT_STATIC_CYCLE_ANIM:
|
|
|
|
{
|
|
|
|
if ( !m_animPlaying )
|
|
|
|
{
|
|
|
|
m_animPlaying = true;
|
|
|
|
m_animNo = m_data[m_type].initAnim;
|
|
|
|
m_frame = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-01-16 20:35:34 +01:00
|
|
|
case NPC_MOVEMENT_FIXED_PATH:
|
2001-01-18 20:18:39 +01:00
|
|
|
{
|
2001-02-22 22:00:56 +01:00
|
|
|
processGenericFixedPathMove( _frames, &moveX, &moveY, &moveVel, &moveDist );
|
2001-01-16 20:35:34 +01:00
|
|
|
|
2001-04-02 17:52:09 +02:00
|
|
|
if ( !m_animPlaying )
|
|
|
|
{
|
|
|
|
m_animPlaying = true;
|
|
|
|
m_animNo = m_data[m_type].moveAnim;
|
|
|
|
m_frame = 0;
|
|
|
|
}
|
|
|
|
|
2001-01-16 20:35:34 +01:00
|
|
|
break;
|
2001-01-18 20:18:39 +01:00
|
|
|
}
|
2001-01-16 20:35:34 +01:00
|
|
|
|
2001-02-22 16:39:38 +01:00
|
|
|
case NPC_MOVEMENT_FIXED_PATH_WALK:
|
|
|
|
{
|
2001-02-22 22:00:56 +01:00
|
|
|
processGenericFixedPathWalk( _frames, &moveX, &moveY );
|
2001-02-22 16:39:38 +01:00
|
|
|
|
2001-04-02 17:52:09 +02:00
|
|
|
if ( !m_animPlaying )
|
|
|
|
{
|
|
|
|
m_animPlaying = true;
|
|
|
|
m_animNo = m_data[m_type].moveAnim;
|
|
|
|
m_frame = 0;
|
|
|
|
}
|
|
|
|
|
2001-02-22 16:39:38 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-01-25 16:45:15 +01:00
|
|
|
case NPC_MOVEMENT_MOTHER_JELLYFISH:
|
|
|
|
{
|
|
|
|
processMotherJellyfishMovement( _frames );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NPC_MOVEMENT_FLYING_DUTCHMAN:
|
|
|
|
{
|
|
|
|
processFlyingDutchmanMovement( _frames );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-03-26 18:44:45 +02:00
|
|
|
case NPC_MOVEMENT_PARASITIC_WORM:
|
|
|
|
{
|
|
|
|
processParasiticWormMovement( _frames );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-01-25 18:20:08 +01:00
|
|
|
case NPC_MOVEMENT_SUB_SHARK:
|
|
|
|
{
|
|
|
|
processSubSharkMovement( _frames );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-01-25 20:57:29 +01:00
|
|
|
case NPC_MOVEMENT_IRON_DOGFISH:
|
|
|
|
{
|
|
|
|
processIronDogfishMovement( _frames );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-01-29 22:46:54 +01:00
|
|
|
case NPC_MOVEMENT_PENDULUM:
|
|
|
|
{
|
|
|
|
processPendulumMovement( _frames );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-01-30 21:30:52 +01:00
|
|
|
case NPC_MOVEMENT_FIREBALL:
|
|
|
|
{
|
|
|
|
processFireballMovement( _frames );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-01-31 17:26:40 +01:00
|
|
|
case NPC_MOVEMENT_RETURNING_HAZARD:
|
2001-01-31 17:14:12 +01:00
|
|
|
{
|
2001-01-31 17:26:40 +01:00
|
|
|
processReturningHazardMovement( _frames );
|
2001-01-31 17:14:12 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-04-02 22:35:43 +02:00
|
|
|
case NPC_MOVEMENT_SHARK_MAN:
|
|
|
|
{
|
|
|
|
processSharkManMovement( _frames, &moveX, &moveY );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-04-03 20:32:24 +02:00
|
|
|
case NPC_MOVEMENT_BALL_BLOB:
|
|
|
|
{
|
|
|
|
processBallBlobMovement( _frames, &moveX, &moveY );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-01-16 20:35:34 +01:00
|
|
|
default:
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2001-01-18 20:18:39 +01:00
|
|
|
|
2001-02-22 22:00:56 +01:00
|
|
|
processMovementModifier( _frames, moveX, moveY, moveVel, moveDist );
|
2001-01-18 20:18:39 +01:00
|
|
|
}
|
|
|
|
|
2001-02-27 22:25:22 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcEnemy::processMovementModifier(int _frames, s32 distX, s32 distY, s32 dist, s16 headingChange)
|
2001-01-18 20:18:39 +01:00
|
|
|
{
|
|
|
|
switch( m_data[m_type].movementModifierFunc )
|
|
|
|
{
|
|
|
|
case NPC_MOVEMENT_MODIFIER_NONE:
|
|
|
|
{
|
|
|
|
Pos.vx += distX;
|
|
|
|
Pos.vy += distY;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NPC_MOVEMENT_MODIFIER_BOB:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NPC_MOVEMENT_MODIFIER_JELLYFISH:
|
|
|
|
{
|
2001-01-18 22:19:43 +01:00
|
|
|
processSmallJellyfishMovementModifier( _frames, distX, distY, dist, headingChange );
|
2001-01-18 20:18:39 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2001-02-05 15:55:11 +01:00
|
|
|
|
|
|
|
case NPC_MOVEMENT_MODIFIER_FISH_FOLK:
|
|
|
|
{
|
|
|
|
processFishFolkMovementModifier( _frames, distX, distY );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2001-02-06 17:14:16 +01:00
|
|
|
|
|
|
|
case NPC_MOVEMENT_MODIFIER_OCTOPUS:
|
|
|
|
{
|
|
|
|
processBabyOctopusMovementModifier( _frames, dist, headingChange );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2001-01-18 20:18:39 +01:00
|
|
|
}
|
2001-01-16 20:35:34 +01:00
|
|
|
}
|
|
|
|
|
2001-02-27 22:25:22 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcEnemy::processShot()
|
2001-01-16 20:35:34 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-02-27 22:25:22 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcEnemy::processClose(int _frames)
|
2001-01-16 20:35:34 +01:00
|
|
|
{
|
2001-01-18 20:18:39 +01:00
|
|
|
switch( m_data[this->m_type].closeFunc )
|
|
|
|
{
|
2001-01-18 22:19:43 +01:00
|
|
|
case NPC_CLOSE_JELLYFISH_EVADE:
|
|
|
|
processCloseSmallJellyfishEvade( _frames );
|
2001-01-18 20:18:39 +01:00
|
|
|
|
2001-01-18 22:19:43 +01:00
|
|
|
break;
|
2001-01-18 20:18:39 +01:00
|
|
|
|
2001-03-01 17:48:45 +01:00
|
|
|
case NPC_CLOSE_CLAM_JUMP_ATTACK:
|
|
|
|
processCloseClamJumpAttack( _frames );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NPC_CLOSE_CLAM_SNAP_ATTACK:
|
|
|
|
processCloseClamSnapAttack( _frames );
|
2001-01-18 20:18:39 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
2001-01-19 22:46:30 +01:00
|
|
|
case NPC_CLOSE_SPIDER_CRAB_ATTACK:
|
|
|
|
processCloseSpiderCrabAttack( _frames );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2001-01-22 15:23:11 +01:00
|
|
|
case NPC_CLOSE_GENERIC_USER_SEEK:
|
2001-02-06 20:29:35 +01:00
|
|
|
{
|
2001-02-07 17:42:13 +01:00
|
|
|
processGenericGotoTarget( _frames, playerXDist, playerYDist, m_data[m_type].speed );
|
2001-01-19 22:46:30 +01:00
|
|
|
|
|
|
|
break;
|
2001-02-06 20:29:35 +01:00
|
|
|
}
|
2001-01-19 22:46:30 +01:00
|
|
|
|
|
|
|
case NPC_CLOSE_GHOST_PIRATE_ATTACK:
|
|
|
|
processCloseGhostPirateAttack( _frames );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NPC_CLOSE_SHARK_MAN_ATTACK:
|
|
|
|
processCloseSharkManAttack( _frames );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2001-01-22 18:44:58 +01:00
|
|
|
case NPC_CLOSE_ANEMONE_1_ATTACK:
|
|
|
|
processCloseAnemone1Attack( _frames );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2001-01-22 17:02:38 +01:00
|
|
|
case NPC_CLOSE_ANEMONE_2_ATTACK:
|
|
|
|
processCloseAnemone2Attack( _frames );
|
|
|
|
|
2001-01-22 18:44:58 +01:00
|
|
|
break;
|
|
|
|
|
2001-02-08 16:34:18 +01:00
|
|
|
case NPC_CLOSE_ANEMONE_3_ATTACK:
|
|
|
|
processCloseAnemone3Attack( _frames );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2001-01-22 23:24:53 +01:00
|
|
|
case NPC_CLOSE_EYEBALL_ATTACK:
|
|
|
|
processCloseEyeballAttack( _frames );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2001-01-23 18:03:27 +01:00
|
|
|
case NPC_CLOSE_SKULL_STOMPER_ATTACK:
|
|
|
|
processCloseSkullStomperAttack( _frames );
|
|
|
|
|
2001-01-23 20:58:19 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NPC_CLOSE_BOOGER_MONSTER_ATTACK:
|
|
|
|
processCloseBoogerMonsterAttack( _frames );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2001-01-25 16:45:15 +01:00
|
|
|
case NPC_CLOSE_MOTHER_JELLYFISH_ATTACK:
|
|
|
|
processCloseMotherJellyfishAttack( _frames );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NPC_CLOSE_FLYING_DUTCHMAN_ATTACK:
|
|
|
|
processCloseFlyingDutchmanAttack( _frames );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2001-01-25 18:20:08 +01:00
|
|
|
case NPC_CLOSE_SUB_SHARK_ATTACK:
|
|
|
|
processCloseSubSharkAttack( _frames );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2001-01-25 20:57:29 +01:00
|
|
|
case NPC_CLOSE_IRON_DOGFISH_ATTACK:
|
|
|
|
processCloseIronDogfishAttack( _frames );
|
|
|
|
|
2001-01-29 17:55:11 +01:00
|
|
|
break;
|
|
|
|
|
2001-01-29 21:00:30 +01:00
|
|
|
case NPC_CLOSE_FALLING_ITEM_FALL:
|
|
|
|
processCloseFallingItemFall( _frames );
|
2001-01-29 17:55:11 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NPC_CLOSE_FISH_HOOK_RISE:
|
|
|
|
processCloseFishHookRise( _frames );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2001-02-06 20:29:35 +01:00
|
|
|
case NPC_CLOSE_FLAMING_SKULL_ATTACK:
|
|
|
|
processCloseFlamingSkullAttack( _frames );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2001-02-12 16:37:31 +01:00
|
|
|
case NPC_CLOSE_SKELETAL_FISH_ATTACK:
|
|
|
|
processCloseSkeletalFishAttack( _frames );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2001-04-02 17:52:09 +02:00
|
|
|
case NPC_CLOSE_HERMIT_CRAB_ATTACK:
|
|
|
|
processCloseHermitCrabAttack( _frames );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2001-04-03 17:14:53 +02:00
|
|
|
case NPC_CLOSE_OCTOPUS_ATTACK:
|
|
|
|
processCloseOctopusAttack( _frames );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2001-01-18 20:18:39 +01:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2001-01-16 20:35:34 +01:00
|
|
|
}
|
|
|
|
|
2001-02-27 22:25:22 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcEnemy::processCollision()
|
2001-01-16 20:35:34 +01:00
|
|
|
{
|
2001-02-07 17:42:13 +01:00
|
|
|
CPlayer *player = GameScene.getPlayer();
|
|
|
|
|
|
|
|
//player->takeDamage( m_data[m_type].damageToUserType );
|
2001-02-07 18:40:56 +01:00
|
|
|
|
|
|
|
m_controlFunc = m_oldControlFunc;
|
2001-01-16 20:35:34 +01:00
|
|
|
}
|
|
|
|
|
2001-02-27 22:25:22 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcEnemy::processTimer(int _frames)
|
2001-01-16 20:35:34 +01:00
|
|
|
{
|
2001-01-22 18:44:58 +01:00
|
|
|
if ( m_timerTimer > 0 )
|
|
|
|
{
|
|
|
|
this->m_timerTimer -= _frames;
|
|
|
|
}
|
|
|
|
|
2001-01-18 20:18:39 +01:00
|
|
|
switch( m_timerFunc )
|
|
|
|
{
|
|
|
|
case NPC_TIMER_NONE:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NPC_TIMER_EVADE_DONE:
|
2001-01-18 22:19:43 +01:00
|
|
|
case NPC_TIMER_ATTACK_DONE:
|
2001-01-18 20:18:39 +01:00
|
|
|
{
|
|
|
|
if ( m_timerTimer <= 0 )
|
|
|
|
{
|
|
|
|
this->m_timerFunc = NPC_TIMER_NONE;
|
2001-01-18 22:19:43 +01:00
|
|
|
this->m_sensorFunc = m_data[this->m_type].sensorFunc;
|
2001-01-18 20:18:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2001-01-16 20:35:34 +01:00
|
|
|
}
|
|
|
|
|
2001-02-27 22:25:22 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcEnemy::render()
|
2001-01-16 20:35:34 +01:00
|
|
|
{
|
2001-02-27 17:59:50 +01:00
|
|
|
CEnemyThing::render();
|
2001-02-27 22:25:22 +01:00
|
|
|
|
|
|
|
// Render
|
|
|
|
DVECTOR renderPos;
|
|
|
|
DVECTOR offset = CLevel::getCameraPos();
|
|
|
|
|
2001-04-04 17:53:44 +02:00
|
|
|
renderPos.vx = Pos.vx - offset.vx;
|
|
|
|
renderPos.vy = Pos.vy - offset.vy;
|
2001-02-27 22:25:22 +01:00
|
|
|
|
2001-04-04 18:51:04 +02:00
|
|
|
if ( renderPos.vx >= 0 && renderPos.vx <= VidGetScrW() )
|
|
|
|
{
|
|
|
|
if ( renderPos.vy >= 0 && renderPos.vy <= VidGetScrH() )
|
|
|
|
{
|
|
|
|
m_actorGfx->Render(renderPos,m_animNo,m_frame,m_reversed);
|
|
|
|
}
|
|
|
|
}
|
2001-01-16 20:35:34 +01:00
|
|
|
}
|
2001-01-16 21:55:44 +01:00
|
|
|
|
2001-02-27 22:25:22 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcEnemy::processEvent( GAME_EVENT evt, CThing *sourceThing )
|
2001-01-16 21:55:44 +01:00
|
|
|
{
|
2001-01-22 23:24:53 +01:00
|
|
|
switch( evt )
|
2001-01-16 21:55:44 +01:00
|
|
|
{
|
2001-01-22 23:24:53 +01:00
|
|
|
case USER_REQUEST_TALK_EVENT:
|
|
|
|
{
|
|
|
|
if ( m_data[this->m_type].canTalk )
|
|
|
|
{
|
|
|
|
DVECTOR sourcePos;
|
|
|
|
s32 xDiffSqr, yDiffSqr;
|
2001-01-16 21:55:44 +01:00
|
|
|
|
2001-01-22 23:24:53 +01:00
|
|
|
// check talk distance
|
2001-01-16 21:55:44 +01:00
|
|
|
|
2001-01-22 23:24:53 +01:00
|
|
|
sourcePos = sourceThing->getPos();
|
2001-01-16 21:55:44 +01:00
|
|
|
|
2001-01-22 23:24:53 +01:00
|
|
|
xDiffSqr = this->Pos.vx - sourcePos.vx;
|
|
|
|
xDiffSqr *= xDiffSqr;
|
2001-01-16 21:55:44 +01:00
|
|
|
|
2001-01-22 23:24:53 +01:00
|
|
|
yDiffSqr = this->Pos.vy - sourcePos.vy;
|
|
|
|
yDiffSqr *= yDiffSqr;
|
2001-01-16 21:55:44 +01:00
|
|
|
|
2001-01-30 16:02:01 +01:00
|
|
|
if ( xDiffSqr + yDiffSqr < 10000 )
|
2001-01-22 23:24:53 +01:00
|
|
|
{
|
|
|
|
if( !CConversation::isActive() )
|
|
|
|
{
|
|
|
|
CConversation::trigger( SCRIPTS_SPEECHTEST_DAT );
|
|
|
|
}
|
|
|
|
}
|
2001-01-16 21:55:44 +01:00
|
|
|
}
|
2001-01-22 23:24:53 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PROJECTILE_RETURNED_TO_SOURCE_EVENT:
|
|
|
|
{
|
|
|
|
m_controlFunc = NPC_CONTROL_MOVEMENT;
|
|
|
|
m_timerFunc = NPC_TIMER_ATTACK_DONE;
|
|
|
|
m_timerTimer = GameState::getOneSecondInFrames();
|
|
|
|
m_sensorFunc = NPC_SENSOR_NONE;
|
|
|
|
|
2001-04-04 00:01:52 +02:00
|
|
|
//removeChild( sourceThing );
|
|
|
|
//sourceThing->shutdown();
|
|
|
|
//delete sourceThing;
|
|
|
|
|
|
|
|
CProjectile *projectile;
|
|
|
|
projectile = (CProjectile *) sourceThing;
|
|
|
|
projectile->setMovementType( CProjectile::PROJECTILE_FIXED );
|
|
|
|
projectile->setPosition( Pos );
|
2001-01-22 23:24:53 +01:00
|
|
|
|
|
|
|
break;
|
2001-01-16 21:55:44 +01:00
|
|
|
}
|
|
|
|
}
|
2001-01-22 23:24:53 +01:00
|
|
|
}
|