From 9bf66ef92560e0099376159c1e4abe01980916fa Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 2 Aug 2001 16:26:54 +0000 Subject: [PATCH] --- source/enemy/nboss.cpp | 18 ++++++++ source/enemy/nboss.h | 2 + source/enemy/ndogfish.cpp | 2 +- source/enemy/nfdutch.cpp | 4 +- source/enemy/nmjfish.cpp | 6 --- source/enemy/nmjfish.h | 1 - source/enemy/nsshark.cpp | 14 ------ source/enemy/nsshark.h | 2 - source/enemy/nssnake.cpp | 91 +++++++++++++++++++++++++++++++++++++++ source/enemy/nssnake.h | 1 + 10 files changed, 115 insertions(+), 26 deletions(-) diff --git a/source/enemy/nboss.cpp b/source/enemy/nboss.cpp index eee5dd480..6130c9848 100644 --- a/source/enemy/nboss.cpp +++ b/source/enemy/nboss.cpp @@ -15,6 +15,10 @@ #include "enemy\nboss.h" #endif +#ifndef __GAME_GAME_H__ +#include "game\game.h" +#endif + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -22,6 +26,7 @@ void CNpcBossEnemy::postInit() { m_meterOn=false; m_energyBar = NULL; + m_invulnerableTimer = 0; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -38,6 +43,18 @@ void CNpcBossEnemy::shutdown() //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void CNpcBossEnemy::think( int _frames ) +{ + if ( m_invulnerableTimer > 0 ) + { + m_invulnerableTimer -= _frames; + } + + CNpcEnemy::think( _frames ); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcBossEnemy::addHealthMeter() { if (!m_meterOn) @@ -83,6 +100,7 @@ void CNpcBossEnemy::processShot( int _frames ) m_animPlaying = true; m_animNo = m_data[m_type].recoilAnim; m_frame = 0; + m_invulnerableTimer = 2 * GameState::getOneSecondInFrames(); } break; diff --git a/source/enemy/nboss.h b/source/enemy/nboss.h index 749d5040d..90e3a06cd 100644 --- a/source/enemy/nboss.h +++ b/source/enemy/nboss.h @@ -26,12 +26,14 @@ class CNpcBossEnemy : public CNpcEnemy public: virtual void postInit(); virtual void shutdown(); + void think( int _frames ); protected: void addHealthMeter(); virtual void processShot( int _frames ); bool m_meterOn; CFXNRGBar *m_energyBar; + s32 m_invulnerableTimer; }; #endif \ No newline at end of file diff --git a/source/enemy/ndogfish.cpp b/source/enemy/ndogfish.cpp index cd40ee351..f375dc4c3 100644 --- a/source/enemy/ndogfish.cpp +++ b/source/enemy/ndogfish.cpp @@ -535,7 +535,7 @@ void CNpcIronDogfishEnemy::collidedWith( CThing *_thisThing ) } } } - else if ( m_vulnerableTimer > 0 ) + else if ( m_vulnerableTimer > 0 && m_invulnerableTimer <= 0 ) { // player is attacking, respond appropriately diff --git a/source/enemy/nfdutch.cpp b/source/enemy/nfdutch.cpp index a0c67f708..7081a7ecc 100644 --- a/source/enemy/nfdutch.cpp +++ b/source/enemy/nfdutch.cpp @@ -103,7 +103,7 @@ void CNpcFlyingDutchmanEnemy::think( int _frames ) } } - CNpcEnemy::think( _frames ); + CNpcBossEnemy::think( _frames ); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -760,7 +760,7 @@ void CNpcFlyingDutchmanEnemy::collidedWith(CThing *_thisThing) } } } - else + else if ( m_invulnerableTimer <= 0 ) { // player is attacking, respond appropriately diff --git a/source/enemy/nmjfish.cpp b/source/enemy/nmjfish.cpp index 19d98d6ed..c57a33327 100644 --- a/source/enemy/nmjfish.cpp +++ b/source/enemy/nmjfish.cpp @@ -88,7 +88,6 @@ void CNpcMotherJellyfishEnemy::postInit() m_renderScale = 2048 + ( ( ( 4096 - 2048 ) * m_health ) / m_data[m_type].initHealth ); m_speed = m_data[m_type].speed + ( ( 2 * ( m_data[m_type].initHealth - m_health ) ) / m_data[m_type].initHealth ); m_pauseTimer = m_maxPauseTimer = ( GameState::getOneSecondInFrames() * m_health ) / m_data[m_type].initHealth; - m_invulnerableTimer = 0; m_attackCounter = 0; m_patternNum = 0; @@ -193,11 +192,6 @@ void CNpcMotherJellyfishEnemy::setupWaypoints( sThingActor *ThisActor ) void CNpcMotherJellyfishEnemy::processMovement( int _frames ) { - if ( m_invulnerableTimer > 0 ) - { - m_invulnerableTimer -= _frames; - } - switch( m_state ) { case MOTHER_JELLYFISH_CYCLE: diff --git a/source/enemy/nmjfish.h b/source/enemy/nmjfish.h index f67727621..c02614253 100644 --- a/source/enemy/nmjfish.h +++ b/source/enemy/nmjfish.h @@ -66,7 +66,6 @@ protected: s32 m_cycleWidth; s32 m_halfCycleWidth; s16 m_renderScale; - s32 m_invulnerableTimer; u8 m_attackCounter; u8 m_patternNum; u8 m_patternPoint; diff --git a/source/enemy/nsshark.cpp b/source/enemy/nsshark.cpp index dc0eff18a..690d119ec 100644 --- a/source/enemy/nsshark.cpp +++ b/source/enemy/nsshark.cpp @@ -63,8 +63,6 @@ void CNpcSubSharkEnemy::postInit() m_speed = m_data[m_type].speed + ( ( 3 * ( m_data[m_type].initHealth - m_health ) ) / m_data[m_type].initHealth ); } - m_invulnerableTimer = 0; - m_timerTimer = 0; m_salvoCount = 5; m_carryPlayer = false; @@ -75,18 +73,6 @@ void CNpcSubSharkEnemy::postInit() //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void CNpcSubSharkEnemy::think( int _frames ) -{ - if ( m_invulnerableTimer > 0 ) - { - m_invulnerableTimer -= _frames; - } - - CNpcEnemy::think( _frames ); -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void CNpcSubSharkEnemy::processMovement( int _frames ) { if ( m_movementTimer > 0 ) diff --git a/source/enemy/nsshark.h b/source/enemy/nsshark.h index 60c533ca1..47aee0190 100644 --- a/source/enemy/nsshark.h +++ b/source/enemy/nsshark.h @@ -26,7 +26,6 @@ class CNpcSubSharkEnemy : public CNpcBossEnemy { public: - void think( int _frames ); void postInit(); void render(); void shutdown(); @@ -54,7 +53,6 @@ protected: }; u8 m_salvoCount; - s32 m_invulnerableTimer; DVECTOR m_targetPos; u8 m_carryPlayer; PLAYER_MODE m_oldPlayerMode; diff --git a/source/enemy/nssnake.cpp b/source/enemy/nssnake.cpp index edae6b8a3..5476f9cb0 100644 --- a/source/enemy/nssnake.cpp +++ b/source/enemy/nssnake.cpp @@ -1168,6 +1168,8 @@ void CNpcSeaSnakeEnemy::processShot( int _frames ) m_collTimer = GameState::getOneSecondInFrames(); } + m_invulnerableTimer = 2 * GameState::getOneSecondInFrames(); + m_controlFunc = NPC_CONTROL_MOVEMENT; } } @@ -1239,3 +1241,92 @@ void CNpcSeaSnakeEnemy::addHealthMeter() m_meterOn=true; } } + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcSeaSnakeEnemy::collidedWith( CThing *_thisThing ) +{ + if ( m_isActive && !m_isCaught && !m_isDying ) + { + switch(_thisThing->getThingType()) + { + case TYPE_PLAYER: + { + CPlayer *player = (CPlayer *) _thisThing; + + ATTACK_STATE playerState = player->getAttackState(); + + if(playerState==ATTACK_STATE__NONE) + { + if ( !player->isRecoveringFromHit() ) + { + switch( m_data[m_type].detectCollision ) + { + case DETECT_NO_COLLISION: + { + // ignore + + break; + } + + case DETECT_ALL_COLLISION: + { + if ( m_controlFunc != NPC_CONTROL_COLLISION ) + { + m_oldControlFunc = m_controlFunc; + m_controlFunc = NPC_CONTROL_COLLISION; + } + + processUserCollision( _thisThing ); + + break; + } + + case DETECT_ATTACK_COLLISION_GENERIC: + { + processAttackCollision(); + processUserCollision( _thisThing ); + + break; + } + } + } + } + else if ( m_invulnerableTimer <= 0 ) + { + // player is attacking, respond appropriately + + if ( m_controlFunc != NPC_CONTROL_SHOT ) + { + if(playerState==ATTACK_STATE__BUTT_BOUNCE) + { + player->justButtBouncedABadGuy(); + } + m_controlFunc = NPC_CONTROL_SHOT; + m_state = NPC_GENERIC_HIT_CHECK_HEALTH; + + drawAttackEffect(); + } + } + + break; + } + + case TYPE_ENEMY: + { + CNpcEnemy *enemy = (CNpcEnemy *) _thisThing; + + if ( canCollideWithEnemy() && enemy->canCollideWithEnemy() ) + { + processEnemyCollision( _thisThing ); + } + + break; + } + + default: + ASSERT(0); + break; + } + } +} diff --git a/source/enemy/nssnake.h b/source/enemy/nssnake.h index 2a9012d80..ccd139cd0 100644 --- a/source/enemy/nssnake.h +++ b/source/enemy/nssnake.h @@ -73,6 +73,7 @@ protected: void moveEntireSnake( DVECTOR const &newPos ); void addHealthMeter(); void updateTail( DVECTOR &oldPos, int _frames ); + void collidedWith(CThing *_thisThing); enum {