This commit is contained in:
Charles 2001-02-07 16:42:13 +00:00
parent 179b2a6231
commit e77ef80771
12 changed files with 126 additions and 141 deletions

View File

@ -32,17 +32,10 @@ void CNpc::processCloseAnemone1Attack( int _frames )
{ {
s32 moveX, moveY; s32 moveX, moveY;
s16 decDir, incDir, moveDist; s16 decDir, incDir, moveDist;
CPlayer *player = GameScene.getPlayer();
DVECTOR playerPos = player->getPos();
s32 xDist, yDist;
s16 maxTurnRate = m_data[m_type].turnSpeed; s16 maxTurnRate = m_data[m_type].turnSpeed;
bool withinRange = false; bool withinRange = false;
xDist = playerPos.vx - this->Pos.vx; s16 headingToPlayer = ratan2( playerYDist, playerXDist );
yDist = playerPos.vy - this->Pos.vy;
s16 headingToPlayer = ratan2( yDist, xDist );
decDir = m_fireHeading - headingToPlayer; decDir = m_fireHeading - headingToPlayer;

View File

@ -26,18 +26,9 @@
void CNpc::processCloseBoogerMonsterAttack( int _frames ) void CNpc::processCloseBoogerMonsterAttack( int _frames )
{ {
CPlayer *player = GameScene.getPlayer();
DVECTOR playerPos = player->getPos();
s32 xDist, yDist;
s32 xDistSqr, yDistSqr;
s32 velocity; s32 velocity;
xDist = playerPos.vx - this->Pos.vx; if ( playerXDistSqr + playerYDistSqr > 10000 )
xDistSqr = xDist * xDist;
yDist = playerPos.vy - this->Pos.vy;
yDistSqr = yDist * yDist;
if ( xDistSqr + yDistSqr > 10000 )
{ {
// user out of range, retract // user out of range, retract

View File

@ -70,13 +70,7 @@ void CNpc::processIronDogfishMovement( int _frames )
void CNpc::processStandardIronDogfishAttack( int _frames ) void CNpc::processStandardIronDogfishAttack( int _frames )
{ {
CPlayer *player = GameScene.getPlayer(); if ( playerXDist > 0 )
DVECTOR playerPos = player->getPos();
s32 xDist = playerPos.vx - Pos.vx;
s32 xDistSqr = xDist * xDist;
if ( xDist > 0 )
{ {
m_extendDir = EXTEND_RIGHT; m_extendDir = EXTEND_RIGHT;
} }
@ -90,9 +84,9 @@ void CNpc::processStandardIronDogfishAttack( int _frames )
case IRON_DOGFISH_THUMP_1: case IRON_DOGFISH_THUMP_1:
case IRON_DOGFISH_THUMP_2: case IRON_DOGFISH_THUMP_2:
{ {
if ( xDistSqr > 100 ) if ( playerXDistSqr > 100 )
{ {
processGenericGotoTarget( _frames, xDist, 0, m_data[m_type].speed ); processGenericGotoTarget( _frames, playerXDist, 0, m_data[m_type].speed );
} }
else else
{ {
@ -110,9 +104,7 @@ void CNpc::processStandardIronDogfishAttack( int _frames )
{ {
// fire at user // fire at user
s32 yDist = playerPos.vy - Pos.vy; s16 headingToPlayer = ratan2( playerYDist, playerXDist );
s16 headingToPlayer = ratan2( yDist, xDist );
CProjectile *projectile; CProjectile *projectile;
projectile = new( "test projectile" ) CProjectile; projectile = new( "test projectile" ) CProjectile;
@ -134,9 +126,9 @@ void CNpc::processStandardIronDogfishAttack( int _frames )
{ {
// charge user // charge user
if ( xDistSqr > 100 ) if ( playerXDistSqr > 100 )
{ {
processGenericGotoTarget( _frames, xDist, 0, 6 ); processGenericGotoTarget( _frames, playerXDist, 0, 6 );
} }
else else
{ {

View File

@ -71,13 +71,7 @@ void CNpc::processFlyingDutchmanMovement( int _frames )
void CNpc::processCloseFlyingDutchmanAttack( int _frames ) void CNpc::processCloseFlyingDutchmanAttack( int _frames )
{ {
CPlayer *player = GameScene.getPlayer(); if ( playerYDist > 0 )
DVECTOR playerPos = player->getPos();
s32 yDist = playerPos.vy - Pos.vy;
s32 yDistSqr = yDist * yDist;
if ( yDist > 0 )
{ {
m_extendDir = EXTEND_DOWN; m_extendDir = EXTEND_DOWN;
} }
@ -86,9 +80,9 @@ void CNpc::processCloseFlyingDutchmanAttack( int _frames )
m_extendDir = EXTEND_UP; m_extendDir = EXTEND_UP;
} }
if ( yDistSqr > 100 ) if ( playerYDistSqr > 100 )
{ {
processGenericGotoTarget( _frames, 0, yDist, m_data[m_type].speed ); processGenericGotoTarget( _frames, 0, playerYDist, m_data[m_type].speed );
} }
else else
{ {
@ -101,7 +95,7 @@ void CNpc::processCloseFlyingDutchmanAttack( int _frames )
s16 heading; s16 heading;
if ( playerPos.vx - Pos.vx > 0 ) if ( playerXDist > 0 )
{ {
heading = 0; heading = 0;
} }
@ -126,12 +120,9 @@ void CNpc::processCloseFlyingDutchmanAttack( int _frames )
{ {
// charge player // charge player
s32 xDist = playerPos.vx - Pos.vx; if ( playerXDistSqr + playerYDistSqr > 100 )
s32 xDistSqr = xDist * xDist;
if ( xDistSqr + yDistSqr > 100 )
{ {
processGenericGotoTarget( _frames, xDist, yDist, 6 ); processGenericGotoTarget( _frames, playerXDist, playerYDist, 6 );
} }
else else
{ {

View File

@ -55,10 +55,7 @@ void CNpc::processCloseGhostPirateAttack( int _frames )
s16 heading; s16 heading;
CPlayer *player = GameScene.getPlayer(); if ( playerXDist > 0 )
DVECTOR playerPos = player->getPos();
if ( playerPos.vx > Pos.vx )
{ {
heading = 0; heading = 0;
} }

View File

@ -32,20 +32,7 @@ void CNpc::processCloseNinjaStarfishAttack( int _frames )
s32 moveVel = 0; s32 moveVel = 0;
CPlayer *player = GameScene.getPlayer(); //if ( playerXDistSqr + playerYDistSqr > 22500 )
DVECTOR playerPos = player->getPos();
s32 xDist, yDist;
s32 xDistSqr, yDistSqr;
xDist = playerPos.vx - this->Pos.vx;
xDistSqr = xDist * xDist;
yDist = playerPos.vy - this->Pos.vy;
yDistSqr = yDist * yDist;
//if ( xDistSqr + yDistSqr > 22500 )
//{ //{
//this->m_controlFunc = NPC_CONTROL_MOVEMENT; //this->m_controlFunc = NPC_CONTROL_MOVEMENT;
//} //}
@ -53,7 +40,7 @@ void CNpc::processCloseNinjaStarfishAttack( int _frames )
{ {
bool pathComplete; bool pathComplete;
s16 headingToPlayer = ratan2( yDist, xDist ); s16 headingToPlayer = ratan2( playerYDist, playerXDist );
s16 maxTurnRate = m_data[m_type].turnSpeed; s16 maxTurnRate = m_data[m_type].turnSpeed;
s16 decDir, incDir; s16 decDir, incDir;

View File

@ -46,9 +46,15 @@
#endif #endif
s32 CNpc::playerXDist;
s32 CNpc::playerYDist;
s32 CNpc::playerXDistSqr;
s32 CNpc::playerYDistSqr;
void CNpc::init() void CNpc::init()
{ {
m_type = NPC_CLAM; m_type = NPC_ANEMONE_1;
m_heading = m_fireHeading = 0; m_heading = m_fireHeading = 0;
m_movementTimer = 0; m_movementTimer = 0;
@ -288,6 +294,12 @@ void CNpc::shutdown()
void CNpc::think(int _frames) void CNpc::think(int _frames)
{ {
processGenericGetUserDist( _frames, &playerXDist, &playerYDist );
playerXDistSqr = playerXDist * playerXDist;
playerYDistSqr = playerYDist * playerYDist;
detectCollisionWithPlayer();
switch ( this->m_controlFunc ) switch ( this->m_controlFunc )
{ {
case NPC_CONTROL_NONE: case NPC_CONTROL_NONE:
@ -325,6 +337,17 @@ void CNpc::think(int _frames)
} }
void CNpc::detectCollisionWithPlayer()
{
if ( playerXDistSqr + playerYDistSqr < 400 )
{
// close enough for collision
m_controlFunc = NPC_CONTROL_COLLISION;
}
}
bool CNpc::processSensor() bool CNpc::processSensor()
{ {
switch( m_sensorFunc ) switch( m_sensorFunc )
@ -334,24 +357,11 @@ bool CNpc::processSensor()
default: default:
{ {
CPlayer *player = GameScene.getPlayer();
DVECTOR playerPos = player->getPos();
s32 xDist, yDist;
s32 xDistSqr, yDistSqr;
xDist = playerPos.vx - this->Pos.vx;
xDistSqr = xDist * xDist;
yDist = playerPos.vy - this->Pos.vy;
yDistSqr = yDist * yDist;
switch( m_sensorFunc ) switch( m_sensorFunc )
{ {
case NPC_SENSOR_JELLYFISH_USER_CLOSE: case NPC_SENSOR_JELLYFISH_USER_CLOSE:
{ {
if ( xDistSqr + yDistSqr < 10000 ) if ( playerXDistSqr + playerYDistSqr < 10000 )
{ {
m_controlFunc = NPC_CONTROL_CLOSE; m_controlFunc = NPC_CONTROL_CLOSE;
m_evadeClockwise = ( getRnd() % 2 ) - 1; m_evadeClockwise = ( getRnd() % 2 ) - 1;
@ -366,7 +376,7 @@ bool CNpc::processSensor()
case NPC_SENSOR_CLAM_USER_CLOSE: case NPC_SENSOR_CLAM_USER_CLOSE:
{ {
if ( xDistSqr + yDistSqr < 10000 ) if ( playerXDistSqr + playerYDistSqr < 10000 )
{ {
m_controlFunc = NPC_CONTROL_CLOSE; m_controlFunc = NPC_CONTROL_CLOSE;
m_extendDir = EXTEND_UP; m_extendDir = EXTEND_UP;
@ -384,14 +394,14 @@ bool CNpc::processSensor()
case NPC_SENSOR_SPIDER_CRAB_USER_CLOSE: case NPC_SENSOR_SPIDER_CRAB_USER_CLOSE:
{ {
if ( xDistSqr + yDistSqr < 10000 ) if ( playerXDistSqr + playerYDistSqr < 10000 )
{ {
m_controlFunc = NPC_CONTROL_CLOSE; m_controlFunc = NPC_CONTROL_CLOSE;
m_extension = 0; m_extension = 0;
m_velocity = 5; m_velocity = 5;
m_base = Pos; m_base = Pos;
if ( playerPos.vx < Pos.vx ) if ( playerXDist < 0 )
{ {
m_extendDir = EXTEND_LEFT; m_extendDir = EXTEND_LEFT;
} }
@ -411,7 +421,7 @@ bool CNpc::processSensor()
case NPC_SENSOR_OIL_BLOB_USER_CLOSE: case NPC_SENSOR_OIL_BLOB_USER_CLOSE:
case NPC_SENSOR_NINJA_STARFISH_USER_CLOSE: case NPC_SENSOR_NINJA_STARFISH_USER_CLOSE:
{ {
if ( xDistSqr + yDistSqr < 10000 ) if ( playerXDistSqr + playerYDistSqr < 10000 )
{ {
m_controlFunc = NPC_CONTROL_CLOSE; m_controlFunc = NPC_CONTROL_CLOSE;
m_velocity = m_data[m_type].speed; m_velocity = m_data[m_type].speed;
@ -426,7 +436,7 @@ bool CNpc::processSensor()
case NPC_SENSOR_GHOST_PIRATE_USER_CLOSE: case NPC_SENSOR_GHOST_PIRATE_USER_CLOSE:
{ {
if ( xDistSqr + yDistSqr < 10000 ) if ( playerXDistSqr + playerYDistSqr < 10000 )
{ {
m_controlFunc = NPC_CONTROL_CLOSE; m_controlFunc = NPC_CONTROL_CLOSE;
m_extendDir = EXTEND_UP; m_extendDir = EXTEND_UP;
@ -446,7 +456,7 @@ bool CNpc::processSensor()
{ {
s32 xDistWaypoint, yDistWaypoint; s32 xDistWaypoint, yDistWaypoint;
if ( abs( xDist ) < 500 ) if ( abs( playerXDist ) < 500 )
{ {
// within range // within range
@ -456,9 +466,9 @@ bool CNpc::processSensor()
m_npcPath.getDistToNextWaypoint( Pos, &xDistWaypoint, &yDistWaypoint ); m_npcPath.getDistToNextWaypoint( Pos, &xDistWaypoint, &yDistWaypoint );
if ( abs( xDist ) < abs( xDistWaypoint ) ) if ( abs( playerXDist ) < abs( xDistWaypoint ) )
{ {
s16 headingToPlayer = ratan2( yDist, xDist ); s16 headingToPlayer = ratan2( playerYDist, playerXDist );
s16 decDir, incDir, moveDist; s16 decDir, incDir, moveDist;
@ -548,7 +558,7 @@ bool CNpc::processSensor()
case NPC_SENSOR_EYEBALL_USER_CLOSE: case NPC_SENSOR_EYEBALL_USER_CLOSE:
case NPC_SENSOR_FLAMING_SKULL_USER_CLOSE: case NPC_SENSOR_FLAMING_SKULL_USER_CLOSE:
{ {
if ( xDistSqr + yDistSqr < 40000 ) if ( playerXDistSqr + playerYDistSqr < 40000 )
{ {
m_controlFunc = NPC_CONTROL_CLOSE; m_controlFunc = NPC_CONTROL_CLOSE;
@ -562,7 +572,7 @@ bool CNpc::processSensor()
case NPC_SENSOR_SKULL_STOMPER_USER_CLOSE: case NPC_SENSOR_SKULL_STOMPER_USER_CLOSE:
{ {
if ( xDistSqr + yDistSqr < 40000 ) if ( playerXDistSqr + playerYDistSqr < 40000 )
{ {
m_controlFunc = NPC_CONTROL_CLOSE; m_controlFunc = NPC_CONTROL_CLOSE;
m_extendDir = EXTEND_DOWN; m_extendDir = EXTEND_DOWN;
@ -577,7 +587,7 @@ bool CNpc::processSensor()
case NPC_SENSOR_BOOGER_MONSTER_USER_CLOSE: case NPC_SENSOR_BOOGER_MONSTER_USER_CLOSE:
{ {
if ( xDistSqr + yDistSqr < 400 ) if ( playerXDistSqr + playerYDistSqr < 400 )
{ {
m_controlFunc = NPC_CONTROL_CLOSE; m_controlFunc = NPC_CONTROL_CLOSE;
m_extendDir = EXTEND_UP; m_extendDir = EXTEND_UP;
@ -592,7 +602,7 @@ bool CNpc::processSensor()
case NPC_SENSOR_IRON_DOGFISH_USER_CLOSE: case NPC_SENSOR_IRON_DOGFISH_USER_CLOSE:
{ {
if ( xDistSqr + yDistSqr < 10000 ) if ( playerXDistSqr + playerYDistSqr < 10000 )
{ {
m_controlFunc = NPC_CONTROL_CLOSE; m_controlFunc = NPC_CONTROL_CLOSE;
@ -606,7 +616,7 @@ bool CNpc::processSensor()
case NPC_SENSOR_FISH_HOOK_USER_CLOSE: case NPC_SENSOR_FISH_HOOK_USER_CLOSE:
{ {
if ( xDistSqr + yDistSqr < 400 ) if ( playerXDistSqr + playerYDistSqr < 400 )
{ {
m_controlFunc = NPC_CONTROL_CLOSE; m_controlFunc = NPC_CONTROL_CLOSE;
@ -620,7 +630,7 @@ bool CNpc::processSensor()
case NPC_SENSOR_FALLING_ITEM_USER_CLOSE: case NPC_SENSOR_FALLING_ITEM_USER_CLOSE:
{ {
if ( xDistSqr + yDistSqr < 40000 ) if ( playerXDistSqr + playerYDistSqr < 40000 )
{ {
m_controlFunc = NPC_CONTROL_CLOSE; m_controlFunc = NPC_CONTROL_CLOSE;
m_movementTimer = GameState::getOneSecondInFrames() * 3; m_movementTimer = GameState::getOneSecondInFrames() * 3;
@ -858,10 +868,7 @@ void CNpc::processClose(int _frames)
case NPC_CLOSE_GENERIC_USER_SEEK: case NPC_CLOSE_GENERIC_USER_SEEK:
{ {
s32 distX, distY; processGenericGotoTarget( _frames, playerXDist, playerYDist, m_data[m_type].speed );
processGenericGetUserDist( _frames, &distX, &distY );
processGenericGotoTarget( _frames, distX, distY, m_data[m_type].speed );
break; break;
} }
@ -943,6 +950,9 @@ void CNpc::processClose(int _frames)
void CNpc::processCollision() void CNpc::processCollision()
{ {
CPlayer *player = GameScene.getPlayer();
//player->takeDamage( m_data[m_type].damageToUserType );
} }
void CNpc::processTimer(int _frames) void CNpc::processTimer(int _frames)

View File

@ -22,6 +22,10 @@
#include "enemy\npcpath.h" #include "enemy\npcpath.h"
#endif #endif
#ifndef __PLAYER_PLAYER_H__
#include "player\player.h"
#endif
/*****************************************************************************/ /*****************************************************************************/
class CNpc : public CThing class CNpc : public CThing
@ -240,6 +244,7 @@ protected:
bool canTalk; bool canTalk;
u8 speed; u8 speed;
u16 turnSpeed; u16 turnSpeed;
DAMAGE_TYPE damageToUserType;
} }
NPC_DATA; NPC_DATA;
@ -252,6 +257,7 @@ protected:
void processClose( int _frames ); void processClose( int _frames );
void processCollision(); void processCollision();
void processTimer( int _frames ); void processTimer( int _frames );
void detectCollisionWithPlayer();
void processGenericGotoTarget( int _frames, s32 xDist, s32 yDist, s32 speed ); void processGenericGotoTarget( int _frames, s32 xDist, s32 yDist, s32 speed );
void processGenericGetUserDist( int _frames, s32 *distX, s32 *distY ); void processGenericGetUserDist( int _frames, s32 *distX, s32 *distY );
@ -341,6 +347,12 @@ protected:
static NPC_DATA m_data[NPC_UNIT_TYPE_MAX]; static NPC_DATA m_data[NPC_UNIT_TYPE_MAX];
static s32 playerXDist;
static s32 playerYDist;
static s32 playerXDistSqr;
static s32 playerYDistSqr;
// internal variables // internal variables
NPC_UNIT_TYPE m_type; NPC_UNIT_TYPE m_type;

View File

@ -15,6 +15,10 @@
#include "enemy\npc.h" #include "enemy\npc.h"
#endif #endif
#ifndef __PLAYER_PLAYER_H__
#include "player\player.h"
#endif
CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] = CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
{ {
@ -28,6 +32,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
true, true,
3, 3,
128, 128,
DAMAGE__LAVA,
}, },
{ // NPC_FALLING_ITEM { // NPC_FALLING_ITEM
@ -40,6 +45,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
3, 3,
128, 128,
DAMAGE__LAVA,
}, },
{ // NPC_FISH_HOOK { // NPC_FISH_HOOK
@ -52,6 +58,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
3, 3,
128, 128,
DAMAGE__LAVA,
}, },
{ // NPC_DUST_DEVIL { // NPC_DUST_DEVIL
@ -64,6 +71,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
3, 3,
2048, 2048,
DAMAGE__LAVA,
}, },
{ // NPC_PENDULUM { // NPC_PENDULUM
@ -76,6 +84,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
3, 3,
2048, 2048,
DAMAGE__LAVA,
}, },
{ // NPC_FIREBALL { // NPC_FIREBALL
@ -88,6 +97,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
40, 40,
2048, 2048,
DAMAGE__LAVA,
}, },
{ // NPC_SAW_BLADE { // NPC_SAW_BLADE
@ -100,6 +110,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
3, 3,
2048, 2048,
DAMAGE__LAVA,
}, },
{ // NPC_SMALL_JELLYFISH_1 { // NPC_SMALL_JELLYFISH_1
@ -112,6 +123,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
3, 3,
128, 128,
DAMAGE__LAVA,
}, },
{ // NPC_SMALL_JELLYFISH_2 { // NPC_SMALL_JELLYFISH_2
@ -124,6 +136,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
3, 3,
128, 128,
DAMAGE__LAVA,
}, },
{ // NPC_LARGE_JELLYFISH { // NPC_LARGE_JELLYFISH
@ -136,6 +149,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
3, 3,
128, 128,
DAMAGE__LAVA,
}, },
{ // NPC_ANEMONE_1 { // NPC_ANEMONE_1
@ -148,6 +162,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
0, 0,
128, 128,
DAMAGE__LAVA,
}, },
{ // NPC_ANEMONE_2 { // NPC_ANEMONE_2
@ -160,6 +175,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
0, 0,
128, 128,
DAMAGE__LAVA,
}, },
{ // NPC_CLAM { // NPC_CLAM
@ -171,6 +187,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
NPC_TIMER_NONE, NPC_TIMER_NONE,
0, 0,
128, 128,
DAMAGE__LAVA,
}, },
{ // NPC_SQUID_DART { // NPC_SQUID_DART
@ -183,6 +200,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
5, 5,
256, 256,
DAMAGE__LAVA,
}, },
{ // NPC_FISH_FOLK { // NPC_FISH_FOLK
@ -195,6 +213,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
2, 2,
2048, 2048,
DAMAGE__LAVA,
}, },
{ // NPC_PRICKLY_BUG { // NPC_PRICKLY_BUG
@ -207,6 +226,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
1, 1,
128, 128,
DAMAGE__LAVA,
}, },
{ // NPC_SEA_SNAKE_1 { // NPC_SEA_SNAKE_1
@ -219,6 +239,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
3, 3,
256, 256,
DAMAGE__LAVA,
}, },
{ // NPC_SEA_SNAKE_2 { // NPC_SEA_SNAKE_2
@ -231,6 +252,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
3, 3,
256, 256,
DAMAGE__LAVA,
}, },
{ // NPC_PUFFA_FISH { // NPC_PUFFA_FISH
@ -243,6 +265,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
2, 2,
128, 128,
DAMAGE__LAVA,
}, },
{ // NPC_ANGLER_FISH { // NPC_ANGLER_FISH
@ -255,6 +278,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
1, 1,
128, 128,
DAMAGE__LAVA,
}, },
{ // NPC_HERMIT_CRAB { // NPC_HERMIT_CRAB
@ -267,6 +291,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
2, 2,
128, 128,
DAMAGE__LAVA,
}, },
{ // NPC_MINE { // NPC_MINE
@ -279,6 +304,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
0, 0,
128, 128,
DAMAGE__LAVA,
}, },
{ // NPC_BOOGER_MONSTER { // NPC_BOOGER_MONSTER
@ -291,6 +317,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
0, 0,
128, 128,
DAMAGE__LAVA,
}, },
{ // NPC_SPIDER_CRAB { // NPC_SPIDER_CRAB
@ -303,6 +330,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
3, 3,
2048, 2048,
DAMAGE__LAVA,
}, },
{ // NPC_EYEBALL { // NPC_EYEBALL
@ -315,6 +343,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
0, 0,
128, 128,
DAMAGE__LAVA,
}, },
{ // NPC_BABY_OCTOPUS { // NPC_BABY_OCTOPUS
@ -327,6 +356,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
2, 2,
512, 512,
DAMAGE__LAVA,
}, },
{ // NPC_ZOMBIE_FISH_FOLK { // NPC_ZOMBIE_FISH_FOLK
@ -339,6 +369,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
2, 2,
2048, 2048,
DAMAGE__LAVA,
}, },
{ // NPC_NINJA_STARFISH { // NPC_NINJA_STARFISH
@ -351,6 +382,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
3, 3,
64, 64,
DAMAGE__LAVA,
}, },
{ // NPC_GHOST { // NPC_GHOST
@ -363,6 +395,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
2, 2,
128, 128,
DAMAGE__LAVA,
}, },
{ // NPC_GHOST_PIRATE { // NPC_GHOST_PIRATE
@ -375,6 +408,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
0, 0,
128, 128,
DAMAGE__LAVA,
}, },
{ // NPC_FLAMING_SKULL { // NPC_FLAMING_SKULL
@ -387,6 +421,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
3, 3,
128, 128,
DAMAGE__LAVA,
}, },
{ // NPC_SHARK_MAN { // NPC_SHARK_MAN
@ -399,6 +434,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
3, 3,
2048, 2048,
DAMAGE__LAVA,
}, },
{ // NPC_OIL_BLOB { // NPC_OIL_BLOB
@ -411,6 +447,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
3, 3,
64, 64,
DAMAGE__LAVA,
}, },
{ // NPC_SKULL_STOMPER { // NPC_SKULL_STOMPER
@ -423,6 +460,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
3, 3,
2048, 2048,
DAMAGE__LAVA,
}, },
{ // NPC_MOTHER_JELLYFISH { // NPC_MOTHER_JELLYFISH
@ -435,6 +473,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
3, 3,
256, 256,
DAMAGE__LAVA,
}, },
{ // NPC_SUB_SHARK { // NPC_SUB_SHARK
@ -447,6 +486,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
3, 3,
256, 256,
DAMAGE__LAVA,
}, },
{ // NPC_FLYING_DUTCHMAN { // NPC_FLYING_DUTCHMAN
@ -459,6 +499,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
3, 3,
256, 256,
DAMAGE__LAVA,
}, },
{ // NPC_IRON_DOGFISH { // NPC_IRON_DOGFISH
@ -471,5 +512,6 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
false, false,
3, 3,
2048, 2048,
DAMAGE__LAVA,
}, },
}; };

View File

@ -28,15 +28,8 @@ void CNpc::processCloseSharkManAttack( int _frames )
{ {
s32 moveX, moveY; s32 moveX, moveY;
s16 decDir, incDir, moveDist; s16 decDir, incDir, moveDist;
CPlayer *player = GameScene.getPlayer();
DVECTOR playerPos = player->getPos();
s32 xDist, yDist;
xDist = playerPos.vx - this->Pos.vx; s16 headingToPlayer = ratan2( playerYDist, playerXDist );
yDist = playerPos.vy - this->Pos.vy;
s16 headingToPlayer = ratan2( yDist, xDist );
decDir = m_heading - headingToPlayer; decDir = m_heading - headingToPlayer;
@ -65,11 +58,11 @@ void CNpc::processCloseSharkManAttack( int _frames )
m_npcPath.getDistToNextWaypoint( Pos, &xDistWaypoint, &yDistWaypoint ); m_npcPath.getDistToNextWaypoint( Pos, &xDistWaypoint, &yDistWaypoint );
if ( abs( moveDist ) < 1024 && abs( xDistWaypoint ) >= abs( xDist ) ) if ( abs( moveDist ) < 1024 && abs( xDistWaypoint ) >= abs( playerXDist ) )
{ {
// continue charge // continue charge
if ( playerPos.vx < Pos.vx ) if ( playerXDist < 0 )
{ {
m_heading = 2048; m_heading = 2048;
} }

View File

@ -108,20 +108,7 @@ void CNpc::processCloseSmallJellyfishEvade( int _frames )
s32 moveVel = 0; s32 moveVel = 0;
CPlayer *player = GameScene.getPlayer(); if ( playerXDistSqr + playerYDistSqr > 22500 )
DVECTOR playerPos = player->getPos();
s32 xDist, yDist;
s32 xDistSqr, yDistSqr;
xDist = playerPos.vx - this->Pos.vx;
xDistSqr = xDist * xDist;
yDist = playerPos.vy - this->Pos.vy;
yDistSqr = yDist * yDist;
if ( xDistSqr + yDistSqr > 22500 )
{ {
this->m_controlFunc = NPC_CONTROL_MOVEMENT; this->m_controlFunc = NPC_CONTROL_MOVEMENT;
} }
@ -138,7 +125,7 @@ void CNpc::processCloseSmallJellyfishEvade( int _frames )
} }
else else
{ {
s16 headingToPlayer = ratan2( yDist, xDist ); s16 headingToPlayer = ratan2( playerYDist, playerXDist );
if ( m_evadeClockwise ) if ( m_evadeClockwise )
{ {

View File

@ -86,13 +86,7 @@ void CNpc::processSubSharkMovement( int _frames )
void CNpc::processCloseSubSharkAttack( int _frames ) void CNpc::processCloseSubSharkAttack( int _frames )
{ {
CPlayer *player = GameScene.getPlayer(); if ( playerXDist > 0 )
DVECTOR playerPos = player->getPos();
s32 xDist = playerPos.vx - Pos.vx;
s32 xDistSqr = xDist * xDist;
if ( xDist > 0 )
{ {
m_extendDir = EXTEND_RIGHT; m_extendDir = EXTEND_RIGHT;
} }
@ -105,9 +99,9 @@ void CNpc::processCloseSubSharkAttack( int _frames )
{ {
case SUB_SHARK_MINE_1: case SUB_SHARK_MINE_1:
{ {
if ( xDistSqr > 100 ) if ( playerXDistSqr > 100 )
{ {
processGenericGotoTarget( _frames, xDist, 0, m_data[m_type].speed ); processGenericGotoTarget( _frames, playerXDist, 0, m_data[m_type].speed );
} }
else else
{ {
@ -124,9 +118,9 @@ void CNpc::processCloseSubSharkAttack( int _frames )
case SUB_SHARK_MINE_2: case SUB_SHARK_MINE_2:
{ {
if ( xDistSqr > 100 ) if ( playerXDistSqr > 100 )
{ {
processGenericGotoTarget( _frames, xDist, 0, m_data[m_type].speed ); processGenericGotoTarget( _frames, playerXDist, 0, m_data[m_type].speed );
} }
else else
{ {
@ -145,13 +139,9 @@ void CNpc::processCloseSubSharkAttack( int _frames )
{ {
// charge player // charge player
//s32 yDist = playerPos.vy - Pos.vy; if ( playerXDistSqr > 100 )
//s32 yDistSqr = yDist * yDist;
//if ( xDistSqr + yDistSqr > 100 )
if ( xDistSqr > 100 )
{ {
processGenericGotoTarget( _frames, xDist, 0, 6 ); processGenericGotoTarget( _frames, playerXDist, 0, 6 );
} }
else else
{ {