This commit is contained in:
parent
b4c67ab838
commit
395a740e59
15 changed files with 133 additions and 0 deletions
|
@ -704,6 +704,7 @@ void CNpcEnemy::init()
|
|||
m_heading = m_fireHeading = 0;
|
||||
m_movementTimer = 0;
|
||||
m_timerTimer = 0;
|
||||
m_collisionTimer = 0;
|
||||
m_velocity = 0;
|
||||
m_extension = 0;
|
||||
m_rotation = 0;
|
||||
|
@ -751,6 +752,7 @@ void CNpcEnemy::reinit()
|
|||
m_heading = m_fireHeading = 0;
|
||||
m_movementTimer = 0;
|
||||
m_timerTimer = 0;
|
||||
m_collisionTimer = 0;
|
||||
m_velocity = 0;
|
||||
m_extension = 0;
|
||||
m_rotation = 0;
|
||||
|
@ -963,6 +965,13 @@ void CNpcEnemy::collidedWith( CThing *_thisThing )
|
|||
break;
|
||||
}
|
||||
|
||||
case TYPE_ENEMY:
|
||||
{
|
||||
processEnemyCollision( _thisThing );
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
ASSERT(0);
|
||||
break;
|
||||
|
@ -1310,6 +1319,11 @@ void CNpcEnemy::processCollision()
|
|||
|
||||
void CNpcEnemy::processTimer(int _frames)
|
||||
{
|
||||
if ( m_collisionTimer > 0 )
|
||||
{
|
||||
m_collisionTimer -= _frames;
|
||||
}
|
||||
|
||||
if ( m_timerTimer > 0 )
|
||||
{
|
||||
m_timerTimer -= _frames;
|
||||
|
@ -1458,3 +1472,55 @@ void CNpcEnemy::caughtWithNet()
|
|||
shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int CNpcEnemy::canCollide()
|
||||
{
|
||||
return( m_isActive );
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CNpcEnemy::processEnemyCollision( CThing *thisThing )
|
||||
{
|
||||
DVECTOR otherPos = thisThing->getPos();
|
||||
DVECTOR otherDelta = thisThing->getPosDelta();
|
||||
|
||||
s32 xDist = Pos.vx - otherPos.vx;
|
||||
s32 yDist = Pos.vy - otherPos.vy;
|
||||
|
||||
s16 headingFromTarget = ratan2( yDist, xDist );
|
||||
|
||||
if ( xDist > 0 )
|
||||
{
|
||||
Pos.vx += 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
Pos.vx -= 6;
|
||||
}
|
||||
|
||||
if ( yDist > 0 )
|
||||
{
|
||||
Pos.vy += 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
Pos.vy -= 6;
|
||||
}
|
||||
|
||||
Pos.vx += otherDelta.vx;
|
||||
Pos.vy += otherDelta.vy;
|
||||
|
||||
if ( m_collisionTimer <= 0 )
|
||||
{
|
||||
m_collisionTimer = GameState::getOneSecondInFrames();
|
||||
|
||||
m_heading = headingFromTarget;
|
||||
|
||||
// try next waypoint to get around other enemy
|
||||
|
||||
m_npcPath.incPath();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue