This commit is contained in:
Charles 2001-04-11 16:39:31 +00:00
parent f677614d5e
commit 276a169b6b
5 changed files with 75 additions and 39 deletions

View File

@ -161,10 +161,10 @@ void CNpcEnemy::processGenericFixedPathMove( int _frames, s32 *moveX, s32 *moveY
s16 headingToTarget = m_npcPath.think( Pos, &pathComplete, &waypointChange ); s16 headingToTarget = m_npcPath.think( Pos, &pathComplete, &waypointChange );
if ( waypointChange ) /*if ( waypointChange )
{ {
m_movementTimer = 0; m_movementTimer = 0;
} }*/
if ( !pathComplete ) if ( !pathComplete )
{ {

View File

@ -548,6 +548,8 @@ void CNpcEnemy::postInit()
this->addChild( segment ); this->addChild( segment );
} }
m_movementTimer = 2 * GameState::getOneSecondInFrames();
break; break;
} }
@ -986,6 +988,7 @@ bool CNpcEnemy::processSensor()
case NPC_SENSOR_ANEMONE_USER_CLOSE: case NPC_SENSOR_ANEMONE_USER_CLOSE:
case NPC_SENSOR_EYEBALL_USER_CLOSE: case NPC_SENSOR_EYEBALL_USER_CLOSE:
case NPC_SENSOR_FLAMING_SKULL_USER_CLOSE: case NPC_SENSOR_FLAMING_SKULL_USER_CLOSE:
case NPC_SENSOR_PARASITIC_WORM_USER_CLOSE:
{ {
if ( playerXDistSqr + playerYDistSqr < 40000 ) if ( playerXDistSqr + playerYDistSqr < 40000 )
{ {
@ -1487,6 +1490,11 @@ void CNpcEnemy::processClose(int _frames)
break; break;
case NPC_CLOSE_PARASITIC_WORM_ATTACK:
processCloseParasiticWormAttack( _frames );
break;
default: default:
break; break;
} }

View File

@ -241,6 +241,7 @@ protected:
NPC_SENSOR_HERMIT_CRAB_USER_CLOSE, NPC_SENSOR_HERMIT_CRAB_USER_CLOSE,
NPC_SENSOR_OCTOPUS_USER_CLOSE, NPC_SENSOR_OCTOPUS_USER_CLOSE,
NPC_SENSOR_PUFFA_FISH_USER_CLOSE, NPC_SENSOR_PUFFA_FISH_USER_CLOSE,
NPC_SENSOR_PARASITIC_WORM_USER_CLOSE,
}; };
enum NPC_CLOSE_FUNC enum NPC_CLOSE_FUNC
@ -270,6 +271,7 @@ protected:
NPC_CLOSE_HERMIT_CRAB_ATTACK, NPC_CLOSE_HERMIT_CRAB_ATTACK,
NPC_CLOSE_OCTOPUS_ATTACK, NPC_CLOSE_OCTOPUS_ATTACK,
NPC_CLOSE_PUFFA_FISH_INFLATE, NPC_CLOSE_PUFFA_FISH_INFLATE,
NPC_CLOSE_PARASITIC_WORM_ATTACK,
}; };
enum NPC_MOVEMENT_FUNC enum NPC_MOVEMENT_FUNC
@ -542,6 +544,8 @@ protected:
// parasitic worm functions // parasitic worm functions
void processParasiticWormMovement( int _frames ); void processParasiticWormMovement( int _frames );
void resetParasiticWormHeadToTail();
void processCloseParasiticWormAttack( int _frames );
// flying dutchman functions // flying dutchman functions

View File

@ -1147,10 +1147,10 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
ACTORS_CLAM_SBK, ACTORS_CLAM_SBK,
ANIM_CLAM_SIDESNAP, ANIM_CLAM_SIDESNAP,
NPC_INIT_PARASITIC_WORM, NPC_INIT_PARASITIC_WORM,
NPC_SENSOR_NONE, NPC_SENSOR_PARASITIC_WORM_USER_CLOSE,
NPC_MOVEMENT_PARASITIC_WORM, NPC_MOVEMENT_PARASITIC_WORM,
NPC_MOVEMENT_MODIFIER_NONE, NPC_MOVEMENT_MODIFIER_NONE,
NPC_CLOSE_NONE, NPC_CLOSE_PARASITIC_WORM_ATTACK,
NPC_TIMER_NONE, NPC_TIMER_NONE,
false, false,
3, 3,

View File

@ -15,9 +15,9 @@
#include "enemy\npc.h" #include "enemy\npc.h"
#endif #endif
//#ifndef __GAME_GAME_H__ #ifndef __GAME_GAME_H__
//#include "game\game.h" #include "game\game.h"
//#endif #endif
#ifndef __PLAYER_PLAYER_H__ #ifndef __PLAYER_PLAYER_H__
#include "player\player.h" #include "player\player.h"
@ -55,6 +55,19 @@ void CNpcEnemy::processParasiticWormMovement( int _frames )
s32 extension = m_extension; s32 extension = m_extension;
u8 downShift = 2; u8 downShift = 2;
u8 timeShift;
if ( m_movementTimer > 0 )
{
m_movementTimer -= _frames;
if ( m_movementTimer < 0 )
{
m_movementTimer = 0;
}
}
timeShift = m_movementTimer / GameState::getOneSecondInFrames();
while( List ) while( List )
{ {
@ -70,7 +83,7 @@ void CNpcEnemy::processParasiticWormMovement( int _frames )
DVECTOR sinPos; DVECTOR sinPos;
sinPos = newPos->pos; sinPos = newPos->pos;
s32 diff = ( ( 10 >> downShift ) * rsin( extension ) ) >> 12; s32 diff = ( ( ( 10 >> downShift ) * rsin( extension ) ) >> 12 ) >> timeShift;
sinPos.vx += ( diff * rcos( headingToTarget + 1024 ) ) >> 12; sinPos.vx += ( diff * rcos( headingToTarget + 1024 ) ) >> 12;
sinPos.vy += ( diff * rsin( headingToTarget + 1024 ) ) >> 12; sinPos.vy += ( diff * rsin( headingToTarget + 1024 ) ) >> 12;
@ -95,29 +108,40 @@ void CNpcEnemy::processParasiticWormMovement( int _frames )
downShift--; downShift--;
} }
} }
}
/*// add new (old) position onto list head void CNpcEnemy::resetParasiticWormHeadToTail()
CNpcPositionHistory *newPos; {
newPos = new ("position history") CNpcPositionHistory; DVECTOR startPos;
newPos->pos = oldPos; DVECTOR endPos;
newPos->next = m_positionHistory; int posCounter;
m_positionHistory = newPos; CNpcPositionHistory *currentPos;
// remove list end startPos = Pos;
CNpcPositionHistory *last;
last = newPos;
while( newPos->next ) currentPos = m_positionHistory;
for ( posCounter = 0 ; posCounter < ( NPC_PARASITIC_WORM_LENGTH * NPC_PARASITIC_WORM_SPACING ) - 1 ; posCounter++ )
{ {
last = newPos; currentPos = currentPos->next;
newPos = newPos->next;
} }
delete newPos; endPos = currentPos->pos;
last->next = NULL;
// assign positions currentPos = m_positionHistory;
for ( posCounter = 0 ; posCounter < NPC_PARASITIC_WORM_LENGTH * NPC_PARASITIC_WORM_SPACING ; posCounter++ )
{
currentPos->pos.vx = startPos.vx + ( posCounter * ( endPos.vx - startPos.vx ) ) / ( ( NPC_PARASITIC_WORM_LENGTH * NPC_PARASITIC_WORM_SPACING ) - 1 );
currentPos->pos.vy = startPos.vy + ( posCounter * ( endPos.vy - startPos.vy ) ) / ( ( NPC_PARASITIC_WORM_LENGTH * NPC_PARASITIC_WORM_SPACING ) - 1 );
currentPos = currentPos->next;
}
CNpcPositionHistory *newPos;
newPos = m_positionHistory; newPos = m_positionHistory;
u8 skipCounter;
for ( skipCounter = 1 ; skipCounter < NPC_PARASITIC_WORM_SPACING ; skipCounter++ ) for ( skipCounter = 1 ; skipCounter < NPC_PARASITIC_WORM_SPACING ; skipCounter++ )
{ {
newPos = newPos->next; newPos = newPos->next;
@ -125,10 +149,9 @@ void CNpcEnemy::processParasiticWormMovement( int _frames )
CThing *List=Next; CThing *List=Next;
oldPos = Pos; DVECTOR oldPos = Pos;
s32 extension = m_extension; s32 extension = m_extension;
u8 downShift = 2;
while( List ) while( List )
{ {
@ -141,14 +164,7 @@ void CNpcEnemy::processParasiticWormMovement( int _frames )
segment->setHeading( headingToTarget ); segment->setHeading( headingToTarget );
DVECTOR sinPos; List->setPos( newPos->pos );
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; oldPos = newPos->pos;
List = List->getNext(); List = List->getNext();
@ -163,10 +179,18 @@ void CNpcEnemy::processParasiticWormMovement( int _frames )
extension += 1024; extension += 1024;
extension &= 4095; extension &= 4095;
}
if ( downShift > 0 )
{
downShift--;
}
}*/
} }
void CNpcEnemy::processCloseParasiticWormAttack( int _frames )
{
resetParasiticWormHeadToTail();
m_movementTimer = 2 * GameState::getOneSecondInFrames();
m_controlFunc = NPC_CONTROL_MOVEMENT;
m_timerFunc = NPC_TIMER_ATTACK_DONE;
m_timerTimer = GameState::getOneSecondInFrames();
m_sensorFunc = NPC_SENSOR_NONE;
}