This commit is contained in:
parent
c8a3f3c9fc
commit
404975b407
@ -99,11 +99,11 @@ void CNpc::processGenericGetUserDist( int _frames, s32 *distX, s32 *distY )
|
|||||||
*distY = playerPos.vy - this->Pos.vy;
|
*distY = playerPos.vy - this->Pos.vy;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CNpc::processGenericFixedPathWalk( int _frames, s32 *moveX, s32 *moveY )
|
void CNpc::processGenericFixedPathWalk( int _frames, s32 *moveX, s32 *moveY, s32 *heading )
|
||||||
{
|
{
|
||||||
s32 maxHeight = 10;
|
s32 maxHeight = 10;
|
||||||
s32 distX, distY;
|
s32 distX, distY;
|
||||||
s32 fallSpeed = 5;
|
s32 fallSpeed = 2;
|
||||||
s8 yMovement = fallSpeed * _frames;
|
s8 yMovement = fallSpeed * _frames;
|
||||||
s32 groundHeight;
|
s32 groundHeight;
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ void CNpc::processGenericFixedPathWalk( int _frames, s32 *moveX, s32 *moveY )
|
|||||||
|
|
||||||
// ignore y component of waypoint, since we are stuck to the ground
|
// ignore y component of waypoint, since we are stuck to the ground
|
||||||
|
|
||||||
if ( m_npcPath.think2D( Pos, &distX, &distY ) )
|
if ( m_npcPath.think2D( Pos, &distX, &distY, heading ) )
|
||||||
{
|
{
|
||||||
// path has finished, waypoint has changed, or there are no waypoints - do not move horizontally
|
// path has finished, waypoint has changed, or there are no waypoints - do not move horizontally
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ class CLayerCollision *CNpc::m_layerCollision;
|
|||||||
|
|
||||||
void CNpc::init()
|
void CNpc::init()
|
||||||
{
|
{
|
||||||
m_type = NPC_FISH_FOLK;
|
m_type = NPC_SHARK_MAN;
|
||||||
|
|
||||||
m_heading = m_fireHeading = 0;
|
m_heading = m_fireHeading = 0;
|
||||||
m_movementTimer = 0;
|
m_movementTimer = 0;
|
||||||
@ -723,7 +723,7 @@ void CNpc::processMovement(int _frames)
|
|||||||
|
|
||||||
case NPC_MOVEMENT_FIXED_PATH_WALK:
|
case NPC_MOVEMENT_FIXED_PATH_WALK:
|
||||||
{
|
{
|
||||||
processGenericFixedPathWalk( _frames, &moveX, &moveY );
|
processGenericFixedPathWalk( _frames, &moveX, &moveY, &m_heading );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -271,7 +271,7 @@ protected:
|
|||||||
|
|
||||||
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 );
|
||||||
void processGenericFixedPathWalk( int _frames, s32 *moveX, s32 *moveY );
|
void processGenericFixedPathWalk( int _frames, s32 *moveX, s32 *moveY, s32 *heading );
|
||||||
|
|
||||||
// small jellyfish functions
|
// small jellyfish functions
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
|
|||||||
{ // NPC_PRICKLY_BUG
|
{ // NPC_PRICKLY_BUG
|
||||||
NPC_INIT_DEFAULT,
|
NPC_INIT_DEFAULT,
|
||||||
NPC_SENSOR_NONE,
|
NPC_SENSOR_NONE,
|
||||||
NPC_MOVEMENT_FIXED_PATH,
|
NPC_MOVEMENT_FIXED_PATH_WALK,
|
||||||
NPC_MOVEMENT_MODIFIER_NONE,
|
NPC_MOVEMENT_MODIFIER_NONE,
|
||||||
NPC_CLOSE_NONE,
|
NPC_CLOSE_NONE,
|
||||||
NPC_TIMER_NONE,
|
NPC_TIMER_NONE,
|
||||||
@ -346,7 +346,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
|
|||||||
{ // NPC_HERMIT_CRAB
|
{ // NPC_HERMIT_CRAB
|
||||||
NPC_INIT_DEFAULT,
|
NPC_INIT_DEFAULT,
|
||||||
NPC_SENSOR_NONE,
|
NPC_SENSOR_NONE,
|
||||||
NPC_MOVEMENT_FIXED_PATH,
|
NPC_MOVEMENT_FIXED_PATH_WALK,
|
||||||
NPC_MOVEMENT_MODIFIER_NONE,
|
NPC_MOVEMENT_MODIFIER_NONE,
|
||||||
NPC_CLOSE_NONE,
|
NPC_CLOSE_NONE,
|
||||||
NPC_TIMER_NONE,
|
NPC_TIMER_NONE,
|
||||||
@ -388,7 +388,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
|
|||||||
{ // NPC_SPIDER_CRAB
|
{ // NPC_SPIDER_CRAB
|
||||||
NPC_INIT_DEFAULT,
|
NPC_INIT_DEFAULT,
|
||||||
NPC_SENSOR_SPIDER_CRAB_USER_CLOSE,
|
NPC_SENSOR_SPIDER_CRAB_USER_CLOSE,
|
||||||
NPC_MOVEMENT_FIXED_PATH,
|
NPC_MOVEMENT_FIXED_PATH_WALK,
|
||||||
NPC_MOVEMENT_MODIFIER_NONE,
|
NPC_MOVEMENT_MODIFIER_NONE,
|
||||||
NPC_CLOSE_SPIDER_CRAB_ATTACK,
|
NPC_CLOSE_SPIDER_CRAB_ATTACK,
|
||||||
NPC_TIMER_NONE,
|
NPC_TIMER_NONE,
|
||||||
@ -430,7 +430,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
|
|||||||
{ // NPC_ZOMBIE_FISH_FOLK
|
{ // NPC_ZOMBIE_FISH_FOLK
|
||||||
NPC_INIT_FISH_FOLK,
|
NPC_INIT_FISH_FOLK,
|
||||||
NPC_SENSOR_NONE,
|
NPC_SENSOR_NONE,
|
||||||
NPC_MOVEMENT_FIXED_PATH,
|
NPC_MOVEMENT_FIXED_PATH_WALK,
|
||||||
NPC_MOVEMENT_MODIFIER_FISH_FOLK,
|
NPC_MOVEMENT_MODIFIER_FISH_FOLK,
|
||||||
NPC_CLOSE_NONE,
|
NPC_CLOSE_NONE,
|
||||||
NPC_TIMER_NONE,
|
NPC_TIMER_NONE,
|
||||||
@ -500,7 +500,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
|
|||||||
{ // NPC_SHARK_MAN
|
{ // NPC_SHARK_MAN
|
||||||
NPC_INIT_DEFAULT,
|
NPC_INIT_DEFAULT,
|
||||||
NPC_SENSOR_GENERIC_USER_VISIBLE,
|
NPC_SENSOR_GENERIC_USER_VISIBLE,
|
||||||
NPC_MOVEMENT_FIXED_PATH,
|
NPC_MOVEMENT_FIXED_PATH_WALK,
|
||||||
NPC_MOVEMENT_MODIFIER_NONE,
|
NPC_MOVEMENT_MODIFIER_NONE,
|
||||||
NPC_CLOSE_SHARK_MAN_ATTACK,
|
NPC_CLOSE_SHARK_MAN_ATTACK,
|
||||||
NPC_TIMER_NONE,
|
NPC_TIMER_NONE,
|
||||||
|
@ -231,7 +231,7 @@ s32 CNpcPath::think( DVECTOR currentPos, bool *pathComplete, bool *waypointChang
|
|||||||
return( headingToTarget );
|
return( headingToTarget );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CNpcPath::think2D( DVECTOR currentPos, s32 *distX, s32 *distY )
|
bool CNpcPath::think2D( DVECTOR currentPos, s32 *distX, s32 *distY, s32 *heading )
|
||||||
{
|
{
|
||||||
bool pointChange = false;
|
bool pointChange = false;
|
||||||
|
|
||||||
@ -256,5 +256,14 @@ bool CNpcPath::think2D( DVECTOR currentPos, s32 *distX, s32 *distY )
|
|||||||
incPath();
|
incPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( *distX > 0 )
|
||||||
|
{
|
||||||
|
*heading = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*heading = 2048;
|
||||||
|
}
|
||||||
|
|
||||||
return( pointChange );
|
return( pointChange );
|
||||||
}
|
}
|
@ -52,7 +52,7 @@ public:
|
|||||||
void resetPath();
|
void resetPath();
|
||||||
void reversePathDir();
|
void reversePathDir();
|
||||||
s32 think( DVECTOR currentPos, bool *pathComplete, bool *waypointChange );
|
s32 think( DVECTOR currentPos, bool *pathComplete, bool *waypointChange );
|
||||||
bool think2D( DVECTOR currentPos, s32 *distX, s32 *distY );
|
bool think2D( DVECTOR currentPos, s32 *distX, s32 *distY, s32 *heading );
|
||||||
bool getDistToNextWaypoint( DVECTOR currentPos, s32 *distX, s32 *distY );
|
bool getDistToNextWaypoint( DVECTOR currentPos, s32 *distX, s32 *distY );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -27,34 +27,35 @@
|
|||||||
void CNpc::processCloseSpiderCrabAttack( int _frames )
|
void CNpc::processCloseSpiderCrabAttack( int _frames )
|
||||||
{
|
{
|
||||||
s32 velocity;
|
s32 velocity;
|
||||||
|
DVECTOR newPos = Pos;
|
||||||
|
|
||||||
velocity = m_velocity * _frames;
|
velocity = m_velocity * _frames;
|
||||||
|
|
||||||
if ( m_extendDir == EXTEND_RIGHT )
|
if ( m_extendDir == EXTEND_RIGHT )
|
||||||
{
|
{
|
||||||
Pos.vx += velocity;
|
newPos.vx += velocity;
|
||||||
m_heading = 0;
|
m_heading = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Pos.vx -= velocity;
|
newPos.vx -= velocity;
|
||||||
m_heading = 2048;
|
m_heading = 2048;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 horizontalExtension = abs( Pos.vx - m_base.vx );
|
s32 horizontalExtension = abs( newPos.vx - m_base.vx );
|
||||||
|
|
||||||
if ( horizontalExtension > 128 )
|
if ( horizontalExtension > 128 )
|
||||||
{
|
{
|
||||||
if ( m_extendDir == EXTEND_RIGHT )
|
if ( m_extendDir == EXTEND_RIGHT )
|
||||||
{
|
{
|
||||||
Pos.vx = m_base.vx + 128;
|
newPos.vx = m_base.vx + 128;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Pos.vx = m_base.vx - 128;
|
newPos.vx = m_base.vx - 128;
|
||||||
}
|
}
|
||||||
|
|
||||||
Pos.vy = m_base.vy;
|
newPos.vy = m_base.vy;
|
||||||
|
|
||||||
m_controlFunc = NPC_CONTROL_MOVEMENT;
|
m_controlFunc = NPC_CONTROL_MOVEMENT;
|
||||||
m_timerFunc = NPC_TIMER_ATTACK_DONE;
|
m_timerFunc = NPC_TIMER_ATTACK_DONE;
|
||||||
@ -63,6 +64,22 @@ void CNpc::processCloseSpiderCrabAttack( int _frames )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Pos.vy = m_base.vy - ( ( 20 * rsin( horizontalExtension << 4 ) ) >> 12 );
|
newPos.vy = m_base.vy - ( ( 20 * rsin( horizontalExtension << 4 ) ) >> 12 );
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for collision with ground
|
||||||
|
|
||||||
|
if ( m_layerCollision->getHeightFromGround( newPos.vx, newPos.vy ) < 0 )
|
||||||
|
{
|
||||||
|
// abort jump
|
||||||
|
|
||||||
|
m_controlFunc = NPC_CONTROL_MOVEMENT;
|
||||||
|
m_timerFunc = NPC_TIMER_ATTACK_DONE;
|
||||||
|
m_timerTimer = GameState::getOneSecondInFrames();
|
||||||
|
m_sensorFunc = NPC_SENSOR_NONE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Pos = newPos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,13 @@
|
|||||||
|
|
||||||
void CNpc::processCloseSharkManAttack( int _frames )
|
void CNpc::processCloseSharkManAttack( int _frames )
|
||||||
{
|
{
|
||||||
s32 moveX, moveY;
|
s32 moveX = 0, moveY = 0;
|
||||||
|
s32 groundHeight;
|
||||||
s16 decDir, incDir, moveDist;
|
s16 decDir, incDir, moveDist;
|
||||||
|
s32 direction;
|
||||||
|
s32 maxHeight = 10;
|
||||||
|
s32 fallSpeed = 2;
|
||||||
|
s8 yMovement = fallSpeed * _frames;
|
||||||
|
|
||||||
s16 headingToPlayer = ratan2( playerYDist, playerXDist );
|
s16 headingToPlayer = ratan2( playerYDist, playerXDist );
|
||||||
|
|
||||||
@ -62,32 +67,47 @@ void CNpc::processCloseSharkManAttack( int _frames )
|
|||||||
{
|
{
|
||||||
// continue charge
|
// continue charge
|
||||||
|
|
||||||
if ( playerXDist < 0 )
|
if ( playerXDist != 0 )
|
||||||
{
|
{
|
||||||
m_heading = 2048;
|
direction = playerXDist / abs( playerXDist );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_heading = 0;
|
direction = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 preShiftX = _frames * m_velocity * rcos( m_heading );
|
if ( m_layerCollision->getHeightFromGround( Pos.vx + ( _frames * m_velocity * direction ), Pos.vy ) < -maxHeight )
|
||||||
s32 preShiftY = _frames * m_velocity * rsin( m_heading );
|
|
||||||
|
|
||||||
moveX = preShiftX >> 12;
|
|
||||||
if ( !moveX && preShiftX )
|
|
||||||
{
|
{
|
||||||
moveX = preShiftX / abs( preShiftX );
|
// there is an obstacle in the way, abort
|
||||||
}
|
|
||||||
|
|
||||||
moveY = preShiftY >> 12;
|
m_controlFunc = NPC_CONTROL_MOVEMENT;
|
||||||
if ( !moveY && preShiftY )
|
m_timerFunc = NPC_TIMER_ATTACK_DONE;
|
||||||
|
m_timerTimer = GameState::getOneSecondInFrames();
|
||||||
|
m_sensorFunc = NPC_SENSOR_NONE;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
moveY = preShiftY / abs( preShiftY );
|
// check for vertical movement
|
||||||
}
|
|
||||||
|
|
||||||
Pos.vx += moveX;
|
groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 );
|
||||||
Pos.vy += moveY;
|
|
||||||
|
if ( groundHeight <= yMovement )
|
||||||
|
{
|
||||||
|
// groundHeight <= yMovement indicates either just above ground or on or below ground
|
||||||
|
|
||||||
|
moveX = _frames * m_velocity * direction;
|
||||||
|
moveY = groundHeight;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// fall
|
||||||
|
|
||||||
|
moveY = yMovement;
|
||||||
|
}
|
||||||
|
|
||||||
|
Pos.vx += moveX;
|
||||||
|
Pos.vy += moveY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user