From b9ccd83f66de87b6eacb7ab9a65efee9f86061ca Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 5 Feb 2001 14:55:11 +0000 Subject: [PATCH] --- makefile.gaz | 1 + source/enemy/npc.cpp | 32 ++++++++++++++++++- source/enemy/npc.h | 6 ++++ source/enemy/npcdata.cpp | 6 ++-- source/enemy/npcpath.cpp | 24 ++++++++++++++ source/enemy/npcpath.h | 5 +-- .../spongebob project/spongebob project.dsp | 4 +++ 7 files changed, 72 insertions(+), 6 deletions(-) diff --git a/makefile.gaz b/makefile.gaz index ab47d58f0..ae7b9c2f8 100644 --- a/makefile.gaz +++ b/makefile.gaz @@ -70,6 +70,7 @@ enemy_src := 2denemy \ nsshark \ ndogfish \ nhazard \ + nffolk \ enemy projectl_src := projectl diff --git a/source/enemy/npc.cpp b/source/enemy/npc.cpp index 3e40c6149..8d1f1095b 100644 --- a/source/enemy/npc.cpp +++ b/source/enemy/npc.cpp @@ -48,7 +48,7 @@ void CNpc::init() { - m_type = NPC_SAW_BLADE; + m_type = NPC_FISH_FOLK; m_heading = m_fireHeading = 0; m_movementTimer = 0; @@ -243,6 +243,29 @@ void CNpc::init() break; } + case NPC_INIT_FISH_FOLK: + { + m_heading = m_fireHeading = 0; + + m_npcPath.initPath(); + + DVECTOR newPos; + + newPos.vx = 100; + newPos.vy = 100; + + m_npcPath.addWaypoint( newPos ); + + newPos.vx = 500; + newPos.vy = 100; + + m_npcPath.addWaypoint( newPos ); + + m_npcPath.setPathType( PONG_PATH ); + + break; + } + default: break; @@ -780,6 +803,13 @@ void CNpc::processMovementModifier(int _frames, s32 distX, s32 distY, s32 dist, break; } + + case NPC_MOVEMENT_MODIFIER_FISH_FOLK: + { + processFishFolkMovementModifier( _frames, distX, distY ); + + break; + } } } diff --git a/source/enemy/npc.h b/source/enemy/npc.h index 815d3e591..e75b14906 100644 --- a/source/enemy/npc.h +++ b/source/enemy/npc.h @@ -96,6 +96,7 @@ protected: NPC_INIT_PENDULUM, NPC_INIT_FIREBALL, NPC_INIT_RETURNING_HAZARD, + NPC_INIT_FISH_FOLK, }; enum NPC_CONTROL_FUNC @@ -166,6 +167,7 @@ protected: NPC_MOVEMENT_MODIFIER_NONE = 0, NPC_MOVEMENT_MODIFIER_BOB = 1, NPC_MOVEMENT_MODIFIER_JELLYFISH, + NPC_MOVEMENT_MODIFIER_FISH_FOLK, }; enum NPC_TIMER_FUNC @@ -249,6 +251,10 @@ protected: void processSmallJellyfishMovementModifier( int _frames, s32 distX, s32 distY, s32 dist, s16 headingChange ); void processCloseSmallJellyfishEvade( int _frames ); + // fish folk functions + + void processFishFolkMovementModifier( int _frames, s32 distX, s32 distY ); + // clam functions void processCloseClamAttack( int _frames ); diff --git a/source/enemy/npcdata.cpp b/source/enemy/npcdata.cpp index af40181c8..0cb73275e 100644 --- a/source/enemy/npcdata.cpp +++ b/source/enemy/npcdata.cpp @@ -186,15 +186,15 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] = }, { // NPC_FISH_FOLK - NPC_INIT_DEFAULT, + NPC_INIT_FISH_FOLK, NPC_SENSOR_NONE, NPC_MOVEMENT_FIXED_PATH, - NPC_MOVEMENT_MODIFIER_NONE, + NPC_MOVEMENT_MODIFIER_FISH_FOLK, NPC_CLOSE_NONE, NPC_TIMER_NONE, false, 2, - 128, + 2048, }, { // NPC_PRICKLY_BUG diff --git a/source/enemy/npcpath.cpp b/source/enemy/npcpath.cpp index 98f17b06e..fbbe0a684 100644 --- a/source/enemy/npcpath.cpp +++ b/source/enemy/npcpath.cpp @@ -40,6 +40,7 @@ void CNpcPath::initPath() waypoint = NULL; pathType = SINGLE_USE_PATH; currentWaypoint = NULL; + lastWaypoint = NULL; waypointCount = 0; reversePath = false; } @@ -47,6 +48,7 @@ void CNpcPath::initPath() void CNpcPath::resetPath() { currentWaypoint = waypoint; + lastWaypoint = NULL; } void CNpcPath::addWaypoint( DVECTOR newPos ) @@ -118,6 +120,7 @@ bool CNpcPath::incPath() { if ( currentWaypoint->nextWaypoint ) { + lastWaypoint = currentWaypoint; currentWaypoint = currentWaypoint->nextWaypoint; } else @@ -132,6 +135,7 @@ bool CNpcPath::incPath() case REPEATING_PATH: // go back to start + lastWaypoint = currentWaypoint; currentWaypoint = this->waypoint; break; @@ -143,6 +147,7 @@ bool CNpcPath::incPath() if ( currentWaypoint->prevWaypoint ) { + lastWaypoint = currentWaypoint; currentWaypoint = currentWaypoint->prevWaypoint; } @@ -156,6 +161,7 @@ bool CNpcPath::incPath() if ( currentWaypoint->prevWaypoint ) { + lastWaypoint = currentWaypoint; currentWaypoint = currentWaypoint->prevWaypoint; } else @@ -164,6 +170,7 @@ bool CNpcPath::incPath() if ( currentWaypoint->nextWaypoint ) { + lastWaypoint = currentWaypoint; currentWaypoint = currentWaypoint->nextWaypoint; } } @@ -172,6 +179,23 @@ bool CNpcPath::incPath() return( false ); } +void CNpcPath::reversePathDir() +{ + if ( lastWaypoint ) + { + CNpcWaypoint *tempWaypoint; + + tempWaypoint = currentWaypoint; + currentWaypoint = lastWaypoint; + lastWaypoint = tempWaypoint; + + if ( pathType == PONG_PATH ) + { + reversePath = !reversePath; + } + } +} + bool CNpcPath::getDistToNextWaypoint( DVECTOR currentPos, s32 *distX, s32 *distY ) { return( currentWaypoint->isPointNear( currentPos, distX, distY ) ); diff --git a/source/enemy/npcpath.h b/source/enemy/npcpath.h index 4c8ff9c55..aa2e4b5a9 100644 --- a/source/enemy/npcpath.h +++ b/source/enemy/npcpath.h @@ -40,16 +40,17 @@ private: NPC_PATH_TYPE pathType; u8 waypointCount; bool reversePath; + CNpcWaypoint *currentWaypoint; + CNpcWaypoint *lastWaypoint; public: - CNpcWaypoint *currentWaypoint; - void initPath(); void addWaypoint( DVECTOR newPos ); void removeAllWaypoints(); void setPathType( NPC_PATH_TYPE newPathType ); bool incPath(); void resetPath(); + void reversePathDir(); s32 think( DVECTOR currentPos, bool *pathComplete, bool *waypointChange ); bool getDistToNextWaypoint( DVECTOR currentPos, s32 *distX, s32 *distY ); }; diff --git a/users/paul/spongebob project/spongebob project.dsp b/users/paul/spongebob project/spongebob project.dsp index e33b8203c..5db7a8d78 100644 --- a/users/paul/spongebob project/spongebob project.dsp +++ b/users/paul/spongebob project/spongebob project.dsp @@ -149,6 +149,10 @@ SOURCE=..\..\..\source\enemy\nfdutch.cpp # End Source File # Begin Source File +SOURCE=..\..\..\source\enemy\nffolk.cpp +# End Source File +# Begin Source File + SOURCE=..\..\..\source\enemy\ngeneric.cpp # End Source File # Begin Source File