This commit is contained in:
Charles 2001-04-11 14:52:28 +00:00
parent fea6cc1922
commit 02c1d9eb41
3 changed files with 70 additions and 5 deletions

View File

@ -511,7 +511,7 @@ void CNpcEnemy::postInit()
m_npcPath.setPathType( CNpcPath::PONG_PATH ); m_npcPath.setPathType( CNpcPath::PONG_PATH );
// create head of list // create start of list
CNpcPositionHistory *newPosition; CNpcPositionHistory *newPosition;
newPosition = new ("position history") CNpcPositionHistory; newPosition = new ("position history") CNpcPositionHistory;
newPosition->pos = Pos; newPosition->pos = Pos;
@ -521,17 +521,23 @@ void CNpcEnemy::postInit()
// create rest of list // create rest of list
for ( int histLength = 1 ; histLength < ( 10 * NPC_PARASITIC_WORM_SPACING ) ; histLength++ ) for ( int histLength = 1 ; histLength < ( NPC_PARASITIC_WORM_LENGTH * NPC_PARASITIC_WORM_SPACING ) ; histLength++ )
{ {
newPosition = new ("position history") CNpcPositionHistory; newPosition = new ("position history") CNpcPositionHistory;
newPosition->pos = Pos; newPosition->pos = Pos;
newPosition->next = NULL; newPosition->next = NULL;
newPosition->prev = currentPosition;
currentPosition->next = newPosition; currentPosition->next = newPosition;
currentPosition = newPosition; currentPosition = newPosition;
} }
for ( int segCount = 0 ; segCount < 10 ; segCount++ ) // link ends together for circular list
currentPosition->next = m_positionHistory;
m_positionHistory->prev = currentPosition;
for ( int segCount = 0 ; segCount < NPC_PARASITIC_WORM_LENGTH ; segCount++ )
{ {
CNpcEnemy *segment; CNpcEnemy *segment;
segment = new ("segment") CNpcEnemy; segment = new ("segment") CNpcEnemy;

View File

@ -391,6 +391,7 @@ protected:
NPC_BOOGER_MONSTER_MAX_EXTENSION = 20, NPC_BOOGER_MONSTER_MAX_EXTENSION = 20,
NPC_SUB_SHARK_HIGH_SPEED = 6, NPC_SUB_SHARK_HIGH_SPEED = 6,
NPC_PARASITIC_WORM_SPACING = 6, NPC_PARASITIC_WORM_SPACING = 6,
NPC_PARASITIC_WORM_LENGTH = 10,
EXTEND_UP = true, EXTEND_UP = true,
EXTEND_DOWN = false, EXTEND_DOWN = false,
EXTEND_RIGHT = true, EXTEND_RIGHT = true,
@ -611,6 +612,7 @@ protected:
public: public:
DVECTOR pos; DVECTOR pos;
CNpcPositionHistory *next; CNpcPositionHistory *next;
CNpcPositionHistory *prev;
}; };
CNpcPositionHistory *m_positionHistory; CNpcPositionHistory *m_positionHistory;

View File

@ -39,7 +39,64 @@ void CNpcEnemy::processParasiticWormMovement( int _frames )
m_extension += 256; m_extension += 256;
m_extension &= 4095; m_extension &= 4095;
// add new (old) position onto list head m_positionHistory = m_positionHistory->prev;
m_positionHistory->pos = oldPos;
CNpcPositionHistory *newPos;
newPos = m_positionHistory;
for ( skipCounter = 1 ; skipCounter < NPC_PARASITIC_WORM_SPACING ; skipCounter++ )
{
newPos = newPos->next;
}
CThing *List=Next;
oldPos = Pos;
s32 extension = m_extension;
u8 downShift = 2;
while( List )
{
CNpcEnemy *segment = (CNpcEnemy *) List;
s32 xDist = oldPos.vx - newPos->pos.vx;
s32 yDist = oldPos.vy - newPos->pos.vy;
s16 headingToTarget = ratan2( yDist, xDist );
segment->setHeading( headingToTarget );
DVECTOR sinPos;
sinPos = newPos->pos;
s32 diff = ( ( 10 >> downShift ) * rsin( extension ) ) >> 12;
sinPos.vx += ( diff * rcos( headingToTarget + 1024 ) ) >> 12;
sinPos.vy += ( diff * rsin( headingToTarget + 1024 ) ) >> 12;
List->setPos( sinPos );
oldPos = newPos->pos;
List = List->getNext();
if ( List )
{
for ( skipCounter = 0 ; skipCounter < NPC_PARASITIC_WORM_SPACING ; skipCounter++ )
{
newPos = newPos->next;
}
}
extension += 1024;
extension &= 4095;
if ( downShift > 0 )
{
downShift--;
}
}
/*// add new (old) position onto list head
CNpcPositionHistory *newPos; CNpcPositionHistory *newPos;
newPos = new ("position history") CNpcPositionHistory; newPos = new ("position history") CNpcPositionHistory;
newPos->pos = oldPos; newPos->pos = oldPos;
@ -111,5 +168,5 @@ void CNpcEnemy::processParasiticWormMovement( int _frames )
{ {
downShift--; downShift--;
} }
} }*/
} }