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

View File

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

View File

@ -164,6 +164,8 @@ void CNpcSeaSnakeEnemy::postInit()
m_collTimer = 0;
m_turnDir = 0;
m_waitTimer = 0;
m_collCount = 0;
m_sign = 1;
CNpcBossEnemy::postInit();
}
@ -555,20 +557,34 @@ void CNpcSeaSnakeEnemy::processMovement( int _frames )
case COLLISION_TYPE_FLAG_SOLID:
{
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_npcPath.decPath();
bool dec = m_npcPath.decPath();
DVECTOR waypointPos;
m_npcPath.getCurrentWaypointPos( &waypointPos );
waypointPos.vy -= 8;
if ( CGameScene::getCollision()->getHeightFromGround( waypointPos.vx, waypointPos.vy ) < 0 )
if ( dec )
{
// 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;
@ -892,20 +908,34 @@ void CNpcSeaSnakeEnemy::processClose( int _frames )
m_sensorFunc = NPC_SENSOR_NONE;
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_npcPath.decPath();
bool dec = m_npcPath.decPath();
DVECTOR waypointPos;
m_npcPath.getCurrentWaypointPos( &waypointPos );
waypointPos.vy -= 8;
if ( CGameScene::getCollision()->getHeightFromGround( waypointPos.vx, waypointPos.vy ) < 0 )
if ( dec )
{
// 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;

View File

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