This commit is contained in:
Charles 2001-02-22 16:56:27 +00:00
parent c8a3f3c9fc
commit 404975b407
8 changed files with 83 additions and 37 deletions

View File

@ -99,11 +99,11 @@ void CNpc::processGenericGetUserDist( int _frames, s32 *distX, s32 *distY )
*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 distX, distY;
s32 fallSpeed = 5;
s32 fallSpeed = 2;
s8 yMovement = fallSpeed * _frames;
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
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

View File

@ -54,7 +54,7 @@ class CLayerCollision *CNpc::m_layerCollision;
void CNpc::init()
{
m_type = NPC_FISH_FOLK;
m_type = NPC_SHARK_MAN;
m_heading = m_fireHeading = 0;
m_movementTimer = 0;
@ -723,7 +723,7 @@ void CNpc::processMovement(int _frames)
case NPC_MOVEMENT_FIXED_PATH_WALK:
{
processGenericFixedPathWalk( _frames, &moveX, &moveY );
processGenericFixedPathWalk( _frames, &moveX, &moveY, &m_heading );
break;
}

View File

@ -271,7 +271,7 @@ protected:
void processGenericGotoTarget( int _frames, s32 xDist, s32 yDist, s32 speed );
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

View File

@ -276,7 +276,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
{ // NPC_PRICKLY_BUG
NPC_INIT_DEFAULT,
NPC_SENSOR_NONE,
NPC_MOVEMENT_FIXED_PATH,
NPC_MOVEMENT_FIXED_PATH_WALK,
NPC_MOVEMENT_MODIFIER_NONE,
NPC_CLOSE_NONE,
NPC_TIMER_NONE,
@ -346,7 +346,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
{ // NPC_HERMIT_CRAB
NPC_INIT_DEFAULT,
NPC_SENSOR_NONE,
NPC_MOVEMENT_FIXED_PATH,
NPC_MOVEMENT_FIXED_PATH_WALK,
NPC_MOVEMENT_MODIFIER_NONE,
NPC_CLOSE_NONE,
NPC_TIMER_NONE,
@ -388,7 +388,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
{ // NPC_SPIDER_CRAB
NPC_INIT_DEFAULT,
NPC_SENSOR_SPIDER_CRAB_USER_CLOSE,
NPC_MOVEMENT_FIXED_PATH,
NPC_MOVEMENT_FIXED_PATH_WALK,
NPC_MOVEMENT_MODIFIER_NONE,
NPC_CLOSE_SPIDER_CRAB_ATTACK,
NPC_TIMER_NONE,
@ -430,7 +430,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
{ // NPC_ZOMBIE_FISH_FOLK
NPC_INIT_FISH_FOLK,
NPC_SENSOR_NONE,
NPC_MOVEMENT_FIXED_PATH,
NPC_MOVEMENT_FIXED_PATH_WALK,
NPC_MOVEMENT_MODIFIER_FISH_FOLK,
NPC_CLOSE_NONE,
NPC_TIMER_NONE,
@ -500,7 +500,7 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
{ // NPC_SHARK_MAN
NPC_INIT_DEFAULT,
NPC_SENSOR_GENERIC_USER_VISIBLE,
NPC_MOVEMENT_FIXED_PATH,
NPC_MOVEMENT_FIXED_PATH_WALK,
NPC_MOVEMENT_MODIFIER_NONE,
NPC_CLOSE_SHARK_MAN_ATTACK,
NPC_TIMER_NONE,

View File

@ -231,7 +231,7 @@ s32 CNpcPath::think( DVECTOR currentPos, bool *pathComplete, bool *waypointChang
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;
@ -256,5 +256,14 @@ bool CNpcPath::think2D( DVECTOR currentPos, s32 *distX, s32 *distY )
incPath();
}
if ( *distX > 0 )
{
*heading = 0;
}
else
{
*heading = 2048;
}
return( pointChange );
}

View File

@ -52,7 +52,7 @@ public:
void resetPath();
void reversePathDir();
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 );
};

View File

@ -27,34 +27,35 @@
void CNpc::processCloseSpiderCrabAttack( int _frames )
{
s32 velocity;
DVECTOR newPos = Pos;
velocity = m_velocity * _frames;
if ( m_extendDir == EXTEND_RIGHT )
{
Pos.vx += velocity;
newPos.vx += velocity;
m_heading = 0;
}
else
{
Pos.vx -= velocity;
newPos.vx -= velocity;
m_heading = 2048;
}
s32 horizontalExtension = abs( Pos.vx - m_base.vx );
s32 horizontalExtension = abs( newPos.vx - m_base.vx );
if ( horizontalExtension > 128 )
{
if ( m_extendDir == EXTEND_RIGHT )
{
Pos.vx = m_base.vx + 128;
newPos.vx = m_base.vx + 128;
}
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_timerFunc = NPC_TIMER_ATTACK_DONE;
@ -63,6 +64,22 @@ void CNpc::processCloseSpiderCrabAttack( int _frames )
}
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;
}
}

View File

@ -26,8 +26,13 @@
void CNpc::processCloseSharkManAttack( int _frames )
{
s32 moveX, moveY;
s32 moveX = 0, moveY = 0;
s32 groundHeight;
s16 decDir, incDir, moveDist;
s32 direction;
s32 maxHeight = 10;
s32 fallSpeed = 2;
s8 yMovement = fallSpeed * _frames;
s16 headingToPlayer = ratan2( playerYDist, playerXDist );
@ -62,32 +67,47 @@ void CNpc::processCloseSharkManAttack( int _frames )
{
// continue charge
if ( playerXDist < 0 )
if ( playerXDist != 0 )
{
m_heading = 2048;
direction = playerXDist / abs( playerXDist );
}
else
{
m_heading = 0;
direction = 1;
}
s32 preShiftX = _frames * m_velocity * rcos( m_heading );
s32 preShiftY = _frames * m_velocity * rsin( m_heading );
moveX = preShiftX >> 12;
if ( !moveX && preShiftX )
if ( m_layerCollision->getHeightFromGround( Pos.vx + ( _frames * m_velocity * direction ), Pos.vy ) < -maxHeight )
{
moveX = preShiftX / abs( preShiftX );
}
// there is an obstacle in the way, abort
moveY = preShiftY >> 12;
if ( !moveY && preShiftY )
m_controlFunc = NPC_CONTROL_MOVEMENT;
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;
Pos.vy += moveY;
groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 );
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
{