This commit is contained in:
Charles 2001-08-07 19:45:40 +00:00
parent 91231221c5
commit 8407047a70
4 changed files with 74 additions and 29 deletions

View File

@ -69,7 +69,7 @@ void CNpcPath::initPath()
reversePath = false; reversePath = false;
minX = maxX = minY = maxY = 0; minX = maxX = minY = maxY = 0;
waypointPtr = NULL; waypointPtr = NULL;
decLockout = false;
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -77,6 +77,7 @@ void CNpcPath::initPath()
void CNpcPath::resetPath() void CNpcPath::resetPath()
{ {
lastWaypoint = currentWaypoint = 0; lastWaypoint = currentWaypoint = 0;
decLockout = false;
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -168,6 +169,8 @@ void CNpcPath::setPathExtents()
bool CNpcPath::incPath() bool CNpcPath::incPath()
{ {
decLockout = false;
if ( !reversePath ) if ( !reversePath )
{ {
if ( currentWaypoint < waypointCount ) if ( currentWaypoint < waypointCount )
@ -233,18 +236,27 @@ bool CNpcPath::incPath()
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcPath::decPath() bool CNpcPath::decPath()
{ {
if ( currentWaypoint > 0 ) if ( !decLockout )
{ {
lastWaypoint = currentWaypoint; if ( currentWaypoint > 0 )
currentWaypoint--; {
} lastWaypoint = currentWaypoint;
else currentWaypoint--;
{ }
lastWaypoint = currentWaypoint; else
currentWaypoint = waypointCount; {
lastWaypoint = currentWaypoint;
currentWaypoint = waypointCount;
}
decLockout = true;
return( true );
} }
return( false );
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -30,7 +30,7 @@ public:
void setPathType( u8 newPathType ); void setPathType( u8 newPathType );
u8 getPathType(); u8 getPathType();
bool incPath(); bool incPath();
void decPath(); bool decPath();
void resetPath(); void resetPath();
void reversePathDir(); void reversePathDir();
s32 think( DVECTOR const &currentPos, bool *pathComplete, bool *waypointChange, s32 *distX, s32 *distY ); s32 think( DVECTOR const &currentPos, bool *pathComplete, bool *waypointChange, s32 *distX, s32 *distY );
@ -55,6 +55,7 @@ private:
u8 lastWaypoint; u8 lastWaypoint;
s32 minX, maxX; s32 minX, maxX;
s32 minY, maxY; s32 minY, maxY;
bool decLockout;
u16 *waypointPtr; u16 *waypointPtr;
}; };

View File

@ -164,6 +164,8 @@ void CNpcSeaSnakeEnemy::postInit()
m_collTimer = 0; m_collTimer = 0;
m_turnDir = 0; m_turnDir = 0;
m_waitTimer = 0; m_waitTimer = 0;
m_collCount = 0;
m_sign = 1;
CNpcBossEnemy::postInit(); CNpcBossEnemy::postInit();
} }
@ -555,20 +557,34 @@ void CNpcSeaSnakeEnemy::processMovement( int _frames )
case COLLISION_TYPE_FLAG_SOLID: case COLLISION_TYPE_FLAG_SOLID:
{ {
Pos = oldPos; Pos = oldPos;
m_heading += 2048;
if ( m_collCount > 4 )
{
m_collCount = 0;
m_sign = -m_sign;
}
else
{
m_collCount++;
}
m_heading += m_sign * 1024;
m_heading &= 4095; m_heading &= 4095;
m_npcPath.decPath(); bool dec = m_npcPath.decPath();
DVECTOR waypointPos; if ( dec )
m_npcPath.getCurrentWaypointPos( &waypointPos );
waypointPos.vy -= 8;
if ( CGameScene::getCollision()->getHeightFromGround( waypointPos.vx, waypointPos.vy ) < 0 )
{ {
// one of the special 'teleport' waypoints DVECTOR waypointPos;
m_npcPath.getCurrentWaypointPos( &waypointPos );
waypointPos.vy -= 8;
m_npcPath.incPath(); if ( CGameScene::getCollision()->getHeightFromGround( waypointPos.vx, waypointPos.vy ) < 0 )
{
// one of the special 'teleport' waypoints
m_npcPath.incPath();
}
} }
break; break;
@ -892,20 +908,34 @@ void CNpcSeaSnakeEnemy::processClose( int _frames )
m_sensorFunc = NPC_SENSOR_NONE; m_sensorFunc = NPC_SENSOR_NONE;
Pos = oldPos; Pos = oldPos;
m_heading += 2048;
if ( m_collCount > 4 )
{
m_collCount = 0;
m_sign = -m_sign;
}
else
{
m_collCount++;
}
m_heading += m_sign * 1024;
m_heading &= 4095; m_heading &= 4095;
m_npcPath.decPath(); bool dec = m_npcPath.decPath();
DVECTOR waypointPos; if ( dec )
m_npcPath.getCurrentWaypointPos( &waypointPos );
waypointPos.vy -= 8;
if ( CGameScene::getCollision()->getHeightFromGround( waypointPos.vx, waypointPos.vy ) < 0 )
{ {
// one of the special 'teleport' waypoints DVECTOR waypointPos;
m_npcPath.getCurrentWaypointPos( &waypointPos );
waypointPos.vy -= 8;
m_npcPath.incPath(); if ( CGameScene::getCollision()->getHeightFromGround( waypointPos.vx, waypointPos.vy ) < 0 )
{
// one of the special 'teleport' waypoints
m_npcPath.incPath();
}
} }
break; break;

View File

@ -112,6 +112,8 @@ protected:
s16 m_circleHeading; s16 m_circleHeading;
s16 m_origHeading; s16 m_origHeading;
s32 m_waitTimer; s32 m_waitTimer;
u8 m_collCount;
s8 m_sign;
}; };
#endif #endif