This commit is contained in:
parent
c8a3f3c9fc
commit
404975b407
8 changed files with 83 additions and 37 deletions
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue