diff --git a/makefile.gaz b/makefile.gaz index 8f9c2fb25..c3c666000 100644 --- a/makefile.gaz +++ b/makefile.gaz @@ -74,7 +74,8 @@ enemy_src := npc \ nfskull \ nsklfish \ ngary \ - nplatfrm + nplatfrm \ + nworm projectl_src := projectl diff --git a/source/enemy/npc.cpp b/source/enemy/npc.cpp index 76feb6a34..5acd9a683 100644 --- a/source/enemy/npc.cpp +++ b/source/enemy/npc.cpp @@ -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 ); diff --git a/source/enemy/npc.h b/source/enemy/npc.h index 7f6e4b95a..5b844a7e6 100644 --- a/source/enemy/npc.h +++ b/source/enemy/npc.h @@ -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; }; diff --git a/source/enemy/npcdata.cpp b/source/enemy/npcdata.cpp index 4216a8850..a1a4a56f6 100644 --- a/source/enemy/npcdata.cpp +++ b/source/enemy/npcdata.cpp @@ -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, + }, }; \ No newline at end of file diff --git a/source/enemy/nworm.cpp b/source/enemy/nworm.cpp index 76ffa0066..10be16906 100644 --- a/source/enemy/nworm.cpp +++ b/source/enemy/nworm.cpp @@ -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--; + } + } } \ No newline at end of file diff --git a/source/game/game.cpp b/source/game/game.cpp index b90f3ee8f..c83852800 100644 --- a/source/game/game.cpp +++ b/source/game/game.cpp @@ -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 diff --git a/source/thing/thing.h b/source/thing/thing.h index a47aa489d..29f1d61b3 100644 --- a/source/thing/thing.h +++ b/source/thing/thing.h @@ -99,6 +99,7 @@ public: DVECTOR getPos() {return Pos;} + void setPos(DVECTOR newPos) {Pos=newPos;} virtual void shove(DVECTOR move); CThing *getNext() {return Next;} diff --git a/users/paul/spongebob project/spongebob project.dsp b/users/paul/spongebob project/spongebob project.dsp index 89f54d3cf..4003b6aca 100644 --- a/users/paul/spongebob project/spongebob project.dsp +++ b/users/paul/spongebob project/spongebob project.dsp @@ -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"