This commit is contained in:
Charles 2001-04-24 19:03:06 +00:00
parent b4c67ab838
commit 395a740e59
15 changed files with 133 additions and 0 deletions

View File

@ -44,6 +44,11 @@
#endif
void CNpcAnemoneEnemy::processEnemyCollision( CThing *thisThing )
{
// do nothing
}
bool CNpcAnemoneEnemy::processSensor()
{
switch( m_sensorFunc )

View File

@ -21,6 +21,7 @@
class CNpcAnemoneEnemy : public CNpcEnemy
{
protected:
virtual void processEnemyCollision( CThing *thisThing );
virtual bool processSensor();
};

View File

@ -36,6 +36,11 @@
#endif
void CNpcClamEnemy::processEnemyCollision( CThing *thisThing )
{
// do nothing
}
bool CNpcClamEnemy::processSensor()
{
switch( m_sensorFunc )

View File

@ -17,6 +17,7 @@
class CNpcClamEnemy : public CNpcEnemy
{
protected:
virtual void processEnemyCollision( CThing *thisThing );
virtual bool processSensor();
};

View File

@ -32,6 +32,11 @@
#endif
void CNpcEyeballEnemy::processEnemyCollision( CThing *thisThing )
{
// do nothing
}
void CNpcEyeballEnemy::postInit()
{
CProjectile *projectile;

View File

@ -18,6 +18,7 @@ class CNpcEyeballEnemy : public CNpcEnemy
{
virtual void postInit();
protected:
virtual void processEnemyCollision( CThing *thisThing );
virtual bool processSensor();
virtual void processClose( int _frames );
};

View File

@ -28,6 +28,11 @@
#endif
void CNpcFlamingSkullEnemy::processEnemyCollision( CThing *thisThing )
{
// do nothing
}
void CNpcFlamingSkullEnemy::postInit()
{
m_state = FLAMING_SKULL_ATTACK;

View File

@ -18,6 +18,7 @@ class CNpcFlamingSkullEnemy : public CNpcEnemy
{
virtual void postInit();
protected:
virtual void processEnemyCollision( CThing *thisThing );
virtual bool processSensor();
virtual void processClose( int _frames );

View File

@ -80,3 +80,10 @@ void CNpcEnemyGenerator::render()
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcEnemyGenerator::processEnemyCollision( CThing *thisThing )
{
// do nothing
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -21,6 +21,7 @@
class CNpcEnemyGenerator : public CNpcEnemy
{
public:
virtual void processEnemyCollision( CThing *thisThing );
void render();
void think(int _frames);
};

View File

@ -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();
}
}

View File

@ -180,6 +180,8 @@ public:
static CNpcEnemy *Create(sThingActor *ThisActor);
void setupWaypoints( sThingActor *ThisActor );
virtual int canCollide();
protected:
class CLayerCollision *m_layerCollision;
@ -302,6 +304,7 @@ protected:
void processGenericFixedPathMove( int _frames, s32 *moveX, s32 *moveY, s32 *moveVel, s32 *moveDist );
void processGenericFixedPathWalk( int _frames, s32 *moveX, s32 *moveY );
bool processGroundCollisionReverse( s32 *moveX, s32 *moveY );
virtual void processEnemyCollision( CThing *thisThing );
void reinit();
@ -329,6 +332,7 @@ protected:
s32 m_velocity;
bool m_evadeClockwise;
s32 m_movementTimer;
s32 m_collisionTimer;
s32 m_timerTimer;
s32 m_extension;
bool m_extendDir;

View File

@ -32,6 +32,11 @@
#endif
void CNpcSkullStomperEnemy::processEnemyCollision( CThing *thisThing )
{
// do nothing
}
void CNpcSkullStomperEnemy::postInit()
{
m_extendDir = EXTEND_DOWN;

View File

@ -19,6 +19,7 @@ class CNpcSkullStomperEnemy : public CNpcEnemy
public:
virtual void postInit();
protected:
virtual void processEnemyCollision( CThing *thisThing );
virtual bool processSensor();
virtual void processClose( int _frames );
};

View File

@ -229,6 +229,31 @@ void CThingManager::thinkAllThings(int _frames)
thing1=thing1->m_nextThing;
}
// Enemy -> Enemy collision
thing1=s_thingLists[CThing::TYPE_ENEMY];
while(thing1)
{
thing2=s_thingLists[CThing::TYPE_ENEMY];
while(thing2)
{
if ( thing1 != thing2 )
{
if ( thing1->canCollide() &&
thing2->canCollide() &&
thing1->checkCollisionAgainst( thing2, _frames ) )
{
thing1->collidedWith( thing2 );
//thing2->collidedWith( thing1 );
}
}
thing2 = thing2->m_nextThing;
}
thing1 = thing1->m_nextThing;
}
}
/*----------------------------------------------------------------------