From 8470b76ba13045c386d0bafcea057625d1c71136 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 23 Jan 2001 17:03:27 +0000 Subject: [PATCH] --- makefile.gaz | 1 + source/enemy/npc.cpp | 74 +++++++++++++++---- source/enemy/npc.h | 13 +++- source/enemy/npcpath.cpp | 6 +- source/enemy/npcpath.h | 6 +- source/enemy/nsjfish.cpp | 3 +- .../spongebob project/spongebob project.dsp | 4 + 7 files changed, 85 insertions(+), 22 deletions(-) diff --git a/makefile.gaz b/makefile.gaz index 7edf0aace..04cad2564 100644 --- a/makefile.gaz +++ b/makefile.gaz @@ -62,6 +62,7 @@ enemy_src := 2denemy \ ngeneric \ nanemone \ neyeball \ + nsstomp \ enemy projectl_src := projectl diff --git a/source/enemy/npc.cpp b/source/enemy/npc.cpp index 279d30307..4f399b626 100644 --- a/source/enemy/npc.cpp +++ b/source/enemy/npc.cpp @@ -48,18 +48,6 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] = { - { // NPC_TEST_TYPE - NPC_INIT_DEFAULT, - NPC_SENSOR_JELLYFISH_USER_CLOSE, - NPC_MOVEMENT_FIXED_PATH, - NPC_MOVEMENT_MODIFIER_JELLYFISH, - NPC_CLOSE_JELLYFISH_EVADE, - NPC_TIMER_NONE, - false, - 3, - 128, - }, - { // NPC_SANDY_CHEEKS NPC_INIT_DEFAULT, NPC_SENSOR_NONE, @@ -382,12 +370,24 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] = 3, 64, }, + + { // NPC_SKULL_STOMPER + NPC_INIT_SKULL_STOMPER, + NPC_SENSOR_SKULL_STOMPER_USER_CLOSE, + NPC_MOVEMENT_STATIC, + NPC_MOVEMENT_MODIFIER_NONE, + NPC_CLOSE_SKULL_STOMPER_ATTACK, + NPC_TIMER_NONE, + false, + 3, + 2048, + }, }; void CNpc::init() { - m_type = NPC_EYEBALL; + m_type = NPC_SKULL_STOMPER; m_heading = m_fireHeading = 0; m_movementTimer = 0; @@ -406,6 +406,7 @@ void CNpc::init() switch ( m_data[this->m_type].initFunc ) { case NPC_INIT_DEFAULT: + { m_npcPath.initPath(); DVECTOR newPos; @@ -433,10 +434,36 @@ void CNpc::init() m_npcPath.setPathType( REPEATING_PATH ); break; + } case NPC_INIT_GHOST_PIRATE: m_heading = m_fireHeading = 3072; + break; + + case NPC_INIT_SKULL_STOMPER: + { + m_heading = m_fireHeading = 1024; + + m_npcPath.initPath(); + + DVECTOR newPos; + + newPos.vx = 100; + newPos.vy = 100; + + m_npcPath.addWaypoint( newPos ); + + newPos.vx = 100; + newPos.vy = 10; + + m_npcPath.addWaypoint( newPos ); + + m_npcPath.setPathType( SINGLE_USE_PATH ); + + break; + } + default: break; @@ -732,6 +759,21 @@ bool CNpc::processSensor() } } + case NPC_SENSOR_SKULL_STOMPER_USER_CLOSE: + { + if ( xDistSqr + yDistSqr < 40000 ) + { + m_controlFunc = NPC_CONTROL_CLOSE; + m_npcPath.currentWaypoint = 0; + + return( true ); + } + else + { + return( false ); + } + } + default: return( false ); } @@ -764,8 +806,9 @@ void CNpc::processMovement(int _frames) case NPC_MOVEMENT_FIXED_PATH: { bool pathComplete; + bool waypointChange; - s16 headingToTarget = m_npcPath.think( Pos, &pathComplete ); + s16 headingToTarget = m_npcPath.think( Pos, &pathComplete, &waypointChange ); if ( !pathComplete ) { @@ -932,6 +975,9 @@ void CNpc::processClose(int _frames) break; + case NPC_CLOSE_SKULL_STOMPER_ATTACK: + processCloseSkullStomperAttack( _frames ); + default: break; } diff --git a/source/enemy/npc.h b/source/enemy/npc.h index d69017de6..b9e3c5bab 100644 --- a/source/enemy/npc.h +++ b/source/enemy/npc.h @@ -29,9 +29,8 @@ class CNpc : public CThing public: enum NPC_UNIT_TYPE { - NPC_TEST_TYPE = 0, - NPC_SANDY_CHEEKS = 1, - NPC_SMALL_JELLYFISH_1, + NPC_SANDY_CHEEKS = 0, + NPC_SMALL_JELLYFISH_1 = 1, NPC_SMALL_JELLYFISH_2, NPC_LARGE_JELLYFISH, NPC_ANEMONE_1, @@ -57,6 +56,7 @@ public: NPC_FLAMING_SKULL, NPC_SHARK_MAN, NPC_OIL_BLOB, + NPC_SKULL_STOMPER, NPC_UNIT_TYPE_MAX, }; @@ -76,6 +76,7 @@ protected: NPC_INIT_SNAKE = 1, NPC_INIT_ACID, NPC_INIT_GHOST_PIRATE, + NPC_INIT_SKULL_STOMPER, }; enum NPC_CONTROL_FUNC @@ -98,6 +99,7 @@ protected: NPC_SENSOR_OIL_BLOB_USER_CLOSE, NPC_SENSOR_ANEMONE_USER_CLOSE, NPC_SENSOR_EYEBALL_USER_CLOSE, + NPC_SENSOR_SKULL_STOMPER_USER_CLOSE, }; enum NPC_CLOSE_FUNC @@ -112,6 +114,7 @@ protected: NPC_CLOSE_ANEMONE_1_ATTACK, NPC_CLOSE_ANEMONE_2_ATTACK, NPC_CLOSE_EYEBALL_ATTACK, + NPC_CLOSE_SKULL_STOMPER_ATTACK, }; enum NPC_MOVEMENT_FUNC @@ -203,6 +206,10 @@ protected: void processCloseEyeballAttack( int _frames ); + // skull stomper functions + + void processCloseSkullStomperAttack( int _frames ); + // data static NPC_DATA m_data[NPC_UNIT_TYPE_MAX]; diff --git a/source/enemy/npcpath.cpp b/source/enemy/npcpath.cpp index dd18548a8..c744b4cd6 100644 --- a/source/enemy/npcpath.cpp +++ b/source/enemy/npcpath.cpp @@ -46,7 +46,7 @@ void CNpcPath::initPath() } pathType = SINGLE_USE_PATH; - currentWaypoint = 0; + currentWaypoint = lastWaypoint = 0; waypointCount = 0; reversePath = false; } @@ -122,15 +122,17 @@ bool CNpcPath::getDistToNextWaypoint( DVECTOR currentPos, s32 *distX, s32 *distY return( waypoint[currentWaypoint].isPointNear( currentPos, distX, distY ) ); } -s32 CNpcPath::think( DVECTOR currentPos, bool *pathComplete ) +s32 CNpcPath::think( DVECTOR currentPos, bool *pathComplete, bool *waypointChange ) { s32 xDist, yDist; *pathComplete = false; + *waypointChange = false; if ( waypoint[currentWaypoint].isPointNear( currentPos, &xDist, &yDist ) ) { *pathComplete = incPath(); + *waypointChange = true; } s32 headingToTarget = ratan2( yDist, xDist ); diff --git a/source/enemy/npcpath.h b/source/enemy/npcpath.h index a6c20794c..eba433b60 100644 --- a/source/enemy/npcpath.h +++ b/source/enemy/npcpath.h @@ -41,16 +41,18 @@ class CNpcPath private: CNpcWaypoint waypoint[NPC_MAX_WAYPOINTS]; NPC_PATH_TYPE pathType; - u8 currentWaypoint; u8 waypointCount; + u8 lastWaypoint; bool reversePath; public: + u8 currentWaypoint; + void initPath(); void addWaypoint( DVECTOR newPos ); void setPathType( NPC_PATH_TYPE newPathType ); bool incPath(); - s32 think( DVECTOR currentPos, bool *pathComplete ); + s32 think( DVECTOR currentPos, bool *pathComplete, bool *waypointChange ); bool getDistToNextWaypoint( DVECTOR currentPos, s32 *distX, s32 *distY ); }; diff --git a/source/enemy/nsjfish.cpp b/source/enemy/nsjfish.cpp index dac6e637c..3d76edfdc 100644 --- a/source/enemy/nsjfish.cpp +++ b/source/enemy/nsjfish.cpp @@ -128,8 +128,9 @@ void CNpc::processCloseSmallJellyfishEvade( int _frames ) else { bool pathComplete; + bool waypointChange; - s16 headingToTarget = m_npcPath.think( Pos, &pathComplete ); + s16 headingToTarget = m_npcPath.think( Pos, &pathComplete, &waypointChange ); if ( pathComplete ) { diff --git a/users/paul/spongebob project/spongebob project.dsp b/users/paul/spongebob project/spongebob project.dsp index 8af2e4d4a..de7158980 100644 --- a/users/paul/spongebob project/spongebob project.dsp +++ b/users/paul/spongebob project/spongebob project.dsp @@ -175,6 +175,10 @@ SOURCE=..\..\..\source\enemy\nshrkman.cpp SOURCE=..\..\..\source\enemy\nsjfish.cpp # End Source File +# Begin Source File + +SOURCE=..\..\..\source\enemy\nsstomp.cpp +# End Source File # End Group # Begin Group "fileio"