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 #endif
void CNpcAnemoneEnemy::processEnemyCollision( CThing *thisThing )
{
// do nothing
}
bool CNpcAnemoneEnemy::processSensor() bool CNpcAnemoneEnemy::processSensor()
{ {
switch( m_sensorFunc ) switch( m_sensorFunc )

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -18,6 +18,7 @@ class CNpcFlamingSkullEnemy : public CNpcEnemy
{ {
virtual void postInit(); virtual void postInit();
protected: protected:
virtual void processEnemyCollision( CThing *thisThing );
virtual bool processSensor(); virtual bool processSensor();
virtual void processClose( int _frames ); 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 class CNpcEnemyGenerator : public CNpcEnemy
{ {
public: public:
virtual void processEnemyCollision( CThing *thisThing );
void render(); void render();
void think(int _frames); void think(int _frames);
}; };

View file

@ -704,6 +704,7 @@ void CNpcEnemy::init()
m_heading = m_fireHeading = 0; m_heading = m_fireHeading = 0;
m_movementTimer = 0; m_movementTimer = 0;
m_timerTimer = 0; m_timerTimer = 0;
m_collisionTimer = 0;
m_velocity = 0; m_velocity = 0;
m_extension = 0; m_extension = 0;
m_rotation = 0; m_rotation = 0;
@ -751,6 +752,7 @@ void CNpcEnemy::reinit()
m_heading = m_fireHeading = 0; m_heading = m_fireHeading = 0;
m_movementTimer = 0; m_movementTimer = 0;
m_timerTimer = 0; m_timerTimer = 0;
m_collisionTimer = 0;
m_velocity = 0; m_velocity = 0;
m_extension = 0; m_extension = 0;
m_rotation = 0; m_rotation = 0;
@ -963,6 +965,13 @@ void CNpcEnemy::collidedWith( CThing *_thisThing )
break; break;
} }
case TYPE_ENEMY:
{
processEnemyCollision( _thisThing );
break;
}
default: default:
ASSERT(0); ASSERT(0);
break; break;
@ -1310,6 +1319,11 @@ void CNpcEnemy::processCollision()
void CNpcEnemy::processTimer(int _frames) void CNpcEnemy::processTimer(int _frames)
{ {
if ( m_collisionTimer > 0 )
{
m_collisionTimer -= _frames;
}
if ( m_timerTimer > 0 ) if ( m_timerTimer > 0 )
{ {
m_timerTimer -= _frames; m_timerTimer -= _frames;
@ -1458,3 +1472,55 @@ void CNpcEnemy::caughtWithNet()
shutdown(); 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); static CNpcEnemy *Create(sThingActor *ThisActor);
void setupWaypoints( sThingActor *ThisActor ); void setupWaypoints( sThingActor *ThisActor );
virtual int canCollide();
protected: protected:
class CLayerCollision *m_layerCollision; class CLayerCollision *m_layerCollision;
@ -302,6 +304,7 @@ protected:
void processGenericFixedPathMove( int _frames, s32 *moveX, s32 *moveY, s32 *moveVel, s32 *moveDist ); void processGenericFixedPathMove( int _frames, s32 *moveX, s32 *moveY, s32 *moveVel, s32 *moveDist );
void processGenericFixedPathWalk( int _frames, s32 *moveX, s32 *moveY ); void processGenericFixedPathWalk( int _frames, s32 *moveX, s32 *moveY );
bool processGroundCollisionReverse( s32 *moveX, s32 *moveY ); bool processGroundCollisionReverse( s32 *moveX, s32 *moveY );
virtual void processEnemyCollision( CThing *thisThing );
void reinit(); void reinit();
@ -329,6 +332,7 @@ protected:
s32 m_velocity; s32 m_velocity;
bool m_evadeClockwise; bool m_evadeClockwise;
s32 m_movementTimer; s32 m_movementTimer;
s32 m_collisionTimer;
s32 m_timerTimer; s32 m_timerTimer;
s32 m_extension; s32 m_extension;
bool m_extendDir; bool m_extendDir;

View file

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

View file

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

View file

@ -229,6 +229,31 @@ void CThingManager::thinkAllThings(int _frames)
thing1=thing1->m_nextThing; 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;
}
} }
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------