This commit is contained in:
Charles 2001-03-26 16:44:45 +00:00
parent 5c8fb556a0
commit eea7d02e97
8 changed files with 222 additions and 23 deletions

View File

@ -74,7 +74,8 @@ enemy_src := npc \
nfskull \
nsklfish \
ngary \
nplatfrm
nplatfrm \
nworm
projectl_src := projectl

View File

@ -216,8 +216,6 @@ void CNpcEnemy::init()
{
CEnemyThing::init();
m_type = NPC_FLYING_DUTCHMAN;
// sActorHdr *Hdr = m_skel.Load( m_data[m_type].skelType );
// m_skel.Init( Hdr );
m_skel.Init(m_data[m_type].skelType);
@ -444,6 +442,75 @@ void CNpcEnemy::init()
break;
}
case NPC_INIT_PARASITIC_WORM:
{
DVECTOR newPos;
newPos.vx = 100;
//newPos.vy = 10;
newPos.vy = 100;
m_npcPath.addWaypoint( newPos );
newPos.vx = 500;
//newPos.vy = 10;
newPos.vy = 100;
m_npcPath.addWaypoint( newPos );
newPos.vx = 500;
//newPos.vy = 100;
newPos.vy = 300;
m_npcPath.addWaypoint( newPos );
newPos.vx = 100;
//newPos.vy = 100;
newPos.vy = 300;
m_npcPath.addWaypoint( newPos );
m_npcPath.setPathType( PONG_PATH );
// create head of list
CNpcPositionHistory *newPosition;
newPosition = new ("position history") CNpcPositionHistory;
newPosition->pos = Pos;
m_positionHistory = newPosition;
CNpcPositionHistory *currentPosition = m_positionHistory;
// create rest of list
for ( int histLength = 1 ; histLength < ( 10 * NPC_PARASITIC_WORM_SPACING ) ; histLength++ )
{
newPosition = new ("position history") CNpcPositionHistory;
newPosition->pos = Pos;
newPosition->next = NULL;
currentPosition->next = newPosition;
currentPosition = newPosition;
}
for ( int segCount = 0 ; segCount < 10 ; segCount++ )
{
CNpcEnemy *segment;
segment = new ("segment") CNpcEnemy;
segment->setType( CNpcEnemy::NPC_PARASITIC_WORM_SEGMENT );
segment->init();
segment->setLayerCollision( m_layerCollision );
this->addChild( segment );
}
break;
}
case NPC_INIT_PARASITIC_WORM_SEGMENT:
{
break;
}
default:
break;
@ -921,6 +988,13 @@ void CNpcEnemy::processMovement(int _frames)
break;
}
case NPC_MOVEMENT_PARASITIC_WORM:
{
processParasiticWormMovement( _frames );
break;
}
case NPC_MOVEMENT_SUB_SHARK:
{
processSubSharkMovement( _frames );

View File

@ -128,8 +128,7 @@ public:
NPC_SQUID_DART,
NPC_FISH_FOLK,
NPC_PRICKLY_BUG,
NPC_SEA_SNAKE_1,
NPC_SEA_SNAKE_2,
NPC_SEA_SNAKE,
NPC_PUFFA_FISH,
NPC_ANGLER_FISH,
NPC_HERMIT_CRAB,
@ -148,8 +147,10 @@ public:
NPC_SKULL_STOMPER,
NPC_MOTHER_JELLYFISH,
NPC_SUB_SHARK,
NPC_PARASITIC_WORM,
NPC_FLYING_DUTCHMAN,
NPC_IRON_DOGFISH,
NPC_PARASITIC_WORM_SEGMENT,
NPC_UNIT_TYPE_MAX,
};
@ -159,6 +160,8 @@ public:
void render();
void processEvent( GAME_EVENT evt, CThing *sourceThing );
void setLayerCollision( class CLayerCollision *_layer ) {m_layerCollision=_layer;}
void setType( NPC_UNIT_TYPE newType ) {m_type = newType;}
void setHeading( s32 newHeading ) {m_heading = newHeading;}
protected:
@ -183,6 +186,8 @@ protected:
NPC_INIT_FISH_FOLK,
NPC_INIT_FLAMING_SKULL,
NPC_INIT_CIRCULAR_PLATFORM,
NPC_INIT_PARASITIC_WORM,
NPC_INIT_PARASITIC_WORM_SEGMENT,
};
enum NPC_CONTROL_FUNC
@ -253,6 +258,7 @@ protected:
NPC_MOVEMENT_FIREBALL,
NPC_MOVEMENT_RETURNING_HAZARD,
NPC_MOVEMENT_CLAM_RETRACT,
NPC_MOVEMENT_PARASITIC_WORM,
};
enum NPC_MOVEMENT_MODIFIER_FUNC
@ -319,6 +325,7 @@ protected:
NPC_JELLYFISH_RESISTANCE = 64,
NPC_BOOGER_MONSTER_MAX_EXTENSION = 20,
NPC_SUB_SHARK_HIGH_SPEED = 6,
NPC_PARASITIC_WORM_SPACING = 6,
EXTEND_UP = true,
EXTEND_DOWN = false,
EXTEND_RIGHT = true,
@ -432,6 +439,10 @@ protected:
void processSubSharkMovement( int _frames );
void processCloseSubSharkAttack( int _frames );
// parasitic worm functions
void processParasiticWormMovement( int _frames );
// flying dutchman functions
void processFlyingDutchmanMovement( int _frames );
@ -494,6 +505,17 @@ protected:
DVECTOR m_drawOffset;
virtual void collidedWith(CThing *_thisThing);
// position history stuff
class CNpcPositionHistory
{
public:
DVECTOR pos;
CNpcPositionHistory *next;
};
CNpcPositionHistory *m_positionHistory;
};

View File

@ -380,24 +380,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
48,
},
{ // NPC_SEA_SNAKE_1
ACTORS_CLAM_A3D,
ANIM_CLAM_CLAMSHUT,
NPC_INIT_DEFAULT,
NPC_SENSOR_NONE,
NPC_MOVEMENT_FIXED_PATH,
NPC_MOVEMENT_MODIFIER_NONE,
NPC_CLOSE_NONE,
NPC_TIMER_NONE,
false,
3,
256,
false,
DAMAGE__SHOCK_ENEMY,
56,
},
{ // NPC_SEA_SNAKE_2
{ // NPC_SEA_SNAKE
ACTORS_CLAM_A3D,
ANIM_CLAM_CLAMSHUT,
NPC_INIT_DEFAULT,
@ -720,6 +703,23 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
256,
},
{ // NPC_PARASITIC_WORM
ACTORS_CLAM_A3D,
ANIM_CLAM_CLAMSHUT,
NPC_INIT_PARASITIC_WORM,
NPC_SENSOR_NONE,
NPC_MOVEMENT_PARASITIC_WORM,
NPC_MOVEMENT_MODIFIER_NONE,
NPC_CLOSE_NONE,
NPC_TIMER_NONE,
false,
3,
128,
false,
DAMAGE__HIT_ENEMY,
256,
},
{ // NPC_FLYING_DUTCHMAN
ACTORS_CLAM_A3D,
ANIM_CLAM_CLAMSHUT,
@ -753,4 +753,21 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
DAMAGE__HIT_ENEMY,
256,
},
{ // NPC_PARASITIC_WORM_SEGMENT
ACTORS_CLAM_A3D,
ANIM_CLAM_CLAMSHUT,
NPC_INIT_PARASITIC_WORM_SEGMENT,
NPC_SENSOR_NONE,
NPC_MOVEMENT_STATIC,
NPC_MOVEMENT_MODIFIER_NONE,
NPC_CLOSE_NONE,
NPC_TIMER_NONE,
false,
3,
2048,
false,
DAMAGE__HIT_ENEMY,
256,
},
};

View File

@ -28,9 +28,88 @@ void CNpcEnemy::processParasiticWormMovement( int _frames )
s32 moveX = 0, moveY = 0;
s32 moveVel = 0;
s32 moveDist = 0;
DVECTOR oldPos = Pos;
u8 skipCounter;
processGenericFixedPathMove( _frames, &moveX, &moveY, &moveVel, &moveDist );
Pos.vx += moveX;
Pos.vy += moveY;
m_extension += 256;
m_extension &= 4095;
// add new (old) position onto list head
CNpcPositionHistory *newPos;
newPos = new ("position history") CNpcPositionHistory;
newPos->pos = oldPos;
newPos->next = m_positionHistory;
m_positionHistory = newPos;
// remove list end
CNpcPositionHistory *last;
last = newPos;
while( newPos->next )
{
last = newPos;
newPos = newPos->next;
}
delete newPos;
last->next = NULL;
// assign positions
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--;
}
}
}

View File

@ -236,6 +236,7 @@ void CGameScene::initLevel()
#ifdef __USER_charles__
CNpcEnemy *enemy;
enemy=new ("test enemy") CNpcEnemy;
enemy->setType( CNpcEnemy::NPC_PARASITIC_WORM );
enemy->init();
enemy->setLayerCollision( Level.getCollisionLayer() );
#endif

View File

@ -99,6 +99,7 @@ public:
DVECTOR getPos() {return Pos;}
void setPos(DVECTOR newPos) {Pos=newPos;}
virtual void shove(DVECTOR move);
CThing *getNext() {return Next;}

View File

@ -215,6 +215,10 @@ SOURCE=..\..\..\source\enemy\nsshark.cpp
SOURCE=..\..\..\source\enemy\nsstomp.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\source\enemy\nworm.cpp
# End Source File
# End Group
# Begin Group "fileio"