This commit is contained in:
parent
3681159ed4
commit
a57387d57f
2 changed files with 56 additions and 5 deletions
|
@ -54,7 +54,7 @@ class CLayerCollision *CNpc::m_layerCollision;
|
||||||
|
|
||||||
void CNpc::init()
|
void CNpc::init()
|
||||||
{
|
{
|
||||||
m_type = NPC_GARY;
|
m_type = NPC_SMALL_JELLYFISH_1;
|
||||||
|
|
||||||
m_heading = m_fireHeading = 0;
|
m_heading = m_fireHeading = 0;
|
||||||
m_movementTimer = 0;
|
m_movementTimer = 0;
|
||||||
|
@ -85,22 +85,26 @@ void CNpc::init()
|
||||||
DVECTOR newPos;
|
DVECTOR newPos;
|
||||||
|
|
||||||
newPos.vx = 100;
|
newPos.vx = 100;
|
||||||
newPos.vy = 10;
|
//newPos.vy = 10;
|
||||||
|
newPos.vy = 400;
|
||||||
|
|
||||||
m_npcPath.addWaypoint( newPos );
|
m_npcPath.addWaypoint( newPos );
|
||||||
|
|
||||||
newPos.vx = 500;
|
newPos.vx = 500;
|
||||||
newPos.vy = 10;
|
//newPos.vy = 10;
|
||||||
|
newPos.vy = 400;
|
||||||
|
|
||||||
m_npcPath.addWaypoint( newPos );
|
m_npcPath.addWaypoint( newPos );
|
||||||
|
|
||||||
newPos.vx = 500;
|
newPos.vx = 500;
|
||||||
newPos.vy = 100;
|
//newPos.vy = 100;
|
||||||
|
newPos.vy = 350;
|
||||||
|
|
||||||
m_npcPath.addWaypoint( newPos );
|
m_npcPath.addWaypoint( newPos );
|
||||||
|
|
||||||
newPos.vx = 100;
|
newPos.vx = 100;
|
||||||
newPos.vy = 100;
|
//newPos.vy = 100;
|
||||||
|
newPos.vy = 350;
|
||||||
|
|
||||||
m_npcPath.addWaypoint( newPos );
|
m_npcPath.addWaypoint( newPos );
|
||||||
|
|
||||||
|
|
|
@ -214,6 +214,53 @@ void CNpc::processCloseSmallJellyfishEvade( int _frames )
|
||||||
moveY = ( _frames * 3 * rsin( m_heading ) ) >> 12;
|
moveY = ( _frames * 3 * rsin( m_heading ) ) >> 12;
|
||||||
moveVel = ( _frames * 3 ) << 8;
|
moveVel = ( _frames * 3 ) << 8;
|
||||||
|
|
||||||
|
// check for collision with ground
|
||||||
|
|
||||||
|
if ( m_layerCollision->Get( ( Pos.vx + moveX ) >> 4, ( Pos.vy + moveY ) >> 4 ) )
|
||||||
|
{
|
||||||
|
bool xBlocked = false;
|
||||||
|
bool yBlocked = false;
|
||||||
|
|
||||||
|
// destination point is below ground, check in individual directions
|
||||||
|
|
||||||
|
if ( m_layerCollision->Get( ( Pos.vx + moveX ) >> 4, Pos.vy >> 4 ) )
|
||||||
|
{
|
||||||
|
// X direction is blocked
|
||||||
|
|
||||||
|
xBlocked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( m_layerCollision->Get( Pos.vx >> 4, ( Pos.vy + moveY ) >> 4 ) )
|
||||||
|
{
|
||||||
|
yBlocked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( xBlocked && !yBlocked )
|
||||||
|
{
|
||||||
|
// invert X
|
||||||
|
|
||||||
|
moveX = -moveX;
|
||||||
|
|
||||||
|
m_heading = ratan2( moveY, moveX );
|
||||||
|
}
|
||||||
|
else if ( !xBlocked && yBlocked )
|
||||||
|
{
|
||||||
|
// invert Y
|
||||||
|
|
||||||
|
moveY = -moveY;
|
||||||
|
|
||||||
|
m_heading = ratan2( moveY, moveX );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
moveX = -moveX;
|
||||||
|
moveY = -moveY;
|
||||||
|
|
||||||
|
m_heading += 2048;
|
||||||
|
m_heading &= 4096;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
processMovementModifier(_frames, moveX, moveY, moveVel, moveDist);
|
processMovementModifier(_frames, moveX, moveY, moveVel, moveDist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue