From b19db66ed5ad2d203075a36d92d6194c4cb13264 Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 28 Jun 2001 20:29:14 +0000 Subject: [PATCH] --- source/enemy/nanemone.cpp | 127 +++++----------------------------- source/enemy/nanemone.h | 3 +- source/enemy/ndogfish.cpp | 117 ++------------------------------ source/enemy/ndogfish.h | 2 +- source/enemy/neyeball.cpp | 139 +++++++++++--------------------------- source/enemy/neyeball.h | 3 +- source/enemy/nfdutch.cpp | 128 ++++------------------------------- source/enemy/nfdutch.h | 3 +- source/enemy/npc.cpp | 127 +++++++++++++++++++--------------- source/enemy/npc.h | 3 + source/enemy/nsshark.cpp | 50 ++------------ source/enemy/nworm.cpp | 122 +++------------------------------ source/enemy/nworm.h | 2 +- 13 files changed, 177 insertions(+), 649 deletions(-) diff --git a/source/enemy/nanemone.cpp b/source/enemy/nanemone.cpp index e6a037f0a..8e9cfc50e 100644 --- a/source/enemy/nanemone.cpp +++ b/source/enemy/nanemone.cpp @@ -285,123 +285,30 @@ void CNpcAnemone2Enemy::shutdown() //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void CNpcAnemone2Enemy::processShot( int _frames ) +void CNpcAnemone2Enemy::processShotDeathStart( int _frames ) { - switch( m_data[m_type].shotFunc ) + CNpcEnemy::processShotDeathStart( _frames ); + + deleteAllChild(); + + if (m_data[m_type].skelType) { - case NPC_SHOT_NONE: - { - // do nothing - - break; - } - - case NPC_SHOT_GENERIC: - { - switch ( m_state ) - { - case NPC_GENERIC_HIT_CHECK_HEALTH: - { - m_health -= 5; - - if ( m_health < 0 ) - { - m_state = NPC_GENERIC_HIT_DEATH_START; - } - else - { - m_state = NPC_GENERIC_HIT_RECOIL; - - m_animPlaying = true; - m_animNo = m_data[m_type].recoilAnim; - m_frame = 0; - } - - break; - } - - case NPC_GENERIC_HIT_RECOIL: - { - if ( !m_animPlaying ) - { - m_state = 0; - m_controlFunc = NPC_CONTROL_MOVEMENT; - } - - break; - } - - case NPC_GENERIC_HIT_DEATH_START: - { - m_animPlaying = true; - m_animNo = m_data[m_type].dieAnim; - m_frame = 0; - m_state = NPC_GENERIC_HIT_DEATH_END; - - if ( m_data[m_type].deathSfx < CSoundMediator::NUM_SFXIDS ) - { - if( m_soundId != NOT_PLAYING ) - { - CSoundMediator::stopAndUnlockSfx( (xmPlayingId) m_soundId ); - } - - m_soundId = (int) CSoundMediator::playSfx( m_data[m_type].deathSfx, true ); - } - - deleteAllChild(); - m_isDying = true; - m_speed = -5; - - if (m_data[m_type].skelType) - { - m_actorGfx->SetOtPos( 0 ); - } - - break; - } - - case NPC_GENERIC_HIT_DEATH_END: - { - m_heading += 64 * _frames; - m_heading &= 4095; - - m_drawRotation = ( m_heading + 1024 ) & 4095; - - Pos.vy += m_speed * _frames; - - if ( m_speed < 5 ) - { - m_speed++; - } - - DVECTOR offset = CLevel::getCameraPos(); - - if ( Pos.vy - offset.vy > VidGetScrH() ) - { - if ( m_data[m_type].respawning ) - { - m_isActive = false; - - m_timerFunc = NPC_TIMER_RESPAWN; - m_timerTimer = 4 * GameState::getOneSecondInFrames(); - } - else - { - setToShutdown(); - } - } - - break; - } - } - - break; - } + m_actorGfx->SetOtPos( 0 ); } } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void CNpcAnemone2Enemy::processShotDeathEnd( int _frames ) +{ + m_heading += 64 * _frames; + m_heading &= 4095; + + CNpcEnemy::processShotDeathEnd( _frames ); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcAnemone2Enemy::processClose( int _frames ) { int fireLoop; diff --git a/source/enemy/nanemone.h b/source/enemy/nanemone.h index 0f0789297..a7a3e2f98 100644 --- a/source/enemy/nanemone.h +++ b/source/enemy/nanemone.h @@ -42,10 +42,11 @@ public: virtual void postInit(); virtual void shutdown(); virtual void render(); - virtual void processShot( int _frames ); protected: virtual void processClose( int _frames ); virtual void processMovementModifier( int _frames, s32 distX, s32 distY, s32 dist, s16 headingChange ); + virtual void processShotDeathStart( int _frames ); + virtual void processShotDeathEnd( int _frames ); u16 m_scaleX, m_scaleY; diff --git a/source/enemy/ndogfish.cpp b/source/enemy/ndogfish.cpp index 9c209bfa3..9229b08d3 100644 --- a/source/enemy/ndogfish.cpp +++ b/source/enemy/ndogfish.cpp @@ -428,6 +428,7 @@ void CNpcIronDogfishEnemy::hasBeenSteamed( DVECTOR &steamPos ) //hasBeenAttacked(); m_steamTimer = 4 * GameState::getOneSecondInFrames(); + m_effect->killFX(); } } @@ -445,119 +446,15 @@ void CNpcIronDogfishEnemy::processTimer(int _frames) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void CNpcIronDogfishEnemy::processShot( int _frames ) +void CNpcIronDogfishEnemy::processShotDeathEnd( int _frames ) { - switch( m_data[m_type].shotFunc ) + if ( !m_animPlaying ) { - case NPC_SHOT_NONE: + CNpcEnemy::processShotDeathEnd( _frames ); + + if ( isSetToShutdown() ) { - // do nothing - - break; - } - - case NPC_SHOT_GENERIC: - { - switch ( m_state ) - { - case NPC_GENERIC_HIT_CHECK_HEALTH: - { - m_health -= 5; - - if ( m_health < 0 ) - { - m_state = NPC_GENERIC_HIT_DEATH_START; - m_isDying = true; - } - else - { - m_state = NPC_GENERIC_HIT_RECOIL; - - m_animPlaying = true; - m_animNo = m_data[m_type].recoilAnim; - m_frame = 0; - } - - break; - } - - case NPC_GENERIC_HIT_RECOIL: - { - if ( !m_animPlaying ) - { - m_state = 0; - m_controlFunc = NPC_CONTROL_MOVEMENT; - } - - break; - } - - case NPC_GENERIC_HIT_DEATH_START: - { - m_animPlaying = true; - m_animNo = m_data[m_type].dieAnim; - m_frame = 0; - m_state = NPC_GENERIC_HIT_DEATH_END; - m_isDying = true; - - if ( m_data[m_type].deathSfx < CSoundMediator::NUM_SFXIDS ) - { - if( m_soundId != NOT_PLAYING ) - { - CSoundMediator::stopAndUnlockSfx( (xmPlayingId) m_soundId ); - } - - m_soundId = (int) CSoundMediator::playSfx( m_data[m_type].deathSfx, true ); - } - - m_speed = -5; - - if (m_data[m_type].skelType) - { - m_actorGfx->SetOtPos( 0 ); - } - - break; - } - - case NPC_GENERIC_HIT_DEATH_END: - { - if ( !m_animPlaying ) - { - m_drawRotation += 64 * _frames; - m_drawRotation &= 4095; - - Pos.vy += m_speed * _frames; - - if ( m_speed < 5 ) - { - m_speed++; - } - - DVECTOR offset = CLevel::getCameraPos(); - - if ( Pos.vy - offset.vy > VidGetScrH() ) - { - if ( m_data[m_type].respawning ) - { - m_isActive = false; - - m_timerFunc = NPC_TIMER_RESPAWN; - m_timerTimer = 4 * GameState::getOneSecondInFrames(); - } - else - { - setToShutdown(); - CGameScene::setBossHasBeenKilled(); - } - } - } - - break; - } - } - - break; + CGameScene::setBossHasBeenKilled(); } } } diff --git a/source/enemy/ndogfish.h b/source/enemy/ndogfish.h index 48a3dc4d7..5ff924f69 100644 --- a/source/enemy/ndogfish.h +++ b/source/enemy/ndogfish.h @@ -35,7 +35,7 @@ protected: virtual void processCollision(); virtual void processAttackCollision(); virtual void hasBeenSteamed( DVECTOR &steamPos ); - virtual void processShot( int _frames ); + virtual void processShotDeathEnd( int _frames ); virtual void collidedWith(CThing *_thisThing); enum NPC_IRON_DOGFISH_STATE diff --git a/source/enemy/neyeball.cpp b/source/enemy/neyeball.cpp index 18c034dbc..c7e761fd4 100644 --- a/source/enemy/neyeball.cpp +++ b/source/enemy/neyeball.cpp @@ -236,110 +236,49 @@ void CNpcEyeballEnemy::processEvent( GAME_EVENT evt, CThing *sourceThing ) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void CNpcEyeballEnemy::processShot( int _frames ) +void CNpcEyeballEnemy::processShotDeathStart( int _frames ) { - switch ( m_state ) + CNpcEnemy::processShotDeathStart( _frames ); + + CThing *Next=getNext(); + if ( Next ) { - case NPC_GENERIC_HIT_CHECK_HEALTH: + CProjectile *projectile; + + projectile = (CProjectile *) Next; + + if ( projectile->getMovementType() != CProjectile::PROJECTILE_FIXED ) { - m_health -= 5; + projectile->setMovementType( CProjectile::PROJECTILE_DUMBFIRE ); + projectile->setLifeTime( CProjectile::PROJECTILE_FINITE_LIFE ); - if ( m_health < 0 ) - { - m_state = NPC_GENERIC_HIT_DEATH_START; - } - else - { - m_state = 0; - m_controlFunc = NPC_CONTROL_MOVEMENT; - } - - break; - } - - case NPC_GENERIC_HIT_DEATH_START: - { - m_animPlaying = true; - m_animNo = m_data[m_type].dieAnim; - m_frame = 0; - m_state = NPC_GENERIC_HIT_DEATH_END; - - m_isDying = true; - m_speed = -5; - - if (m_data[m_type].skelType) - { - m_actorGfx->SetOtPos( 0 ); - } - - CThing *Next=getNext(); - if ( Next ) - { - CProjectile *projectile; - - projectile = (CProjectile *) Next; - - if ( projectile->getMovementType() != CProjectile::PROJECTILE_FIXED ) - { - projectile->setMovementType( CProjectile::PROJECTILE_DUMBFIRE ); - projectile->setLifeTime( CProjectile::PROJECTILE_FINITE_LIFE ); - - removeChild( Next ); - } - } - - break; - } - - case NPC_GENERIC_HIT_DEATH_END: - { - m_drawRotation += 64 * _frames; - m_drawRotation &= 4095; - - m_heading = m_drawRotation - 1024; - m_heading &= 4095; - - Pos.vy += m_speed * _frames; - - if ( m_speed < 5 ) - { - m_speed++; - } - - CThing *Next=getNext(); - if ( Next ) - { - CProjectile *projectile; - - projectile = (CProjectile *) Next; - - DVECTOR eyeballPos = Pos; - - eyeballPos.vx += ( EYEBALL_DIST * rcos( m_heading ) ) >> 12; - eyeballPos.vy += ( EYEBALL_DIST * rsin( m_heading ) ) >> 12; - - projectile->setPosition( eyeballPos ); - projectile->setHeading( m_heading ); - } - - DVECTOR offset = CLevel::getCameraPos(); - - if ( Pos.vy - offset.vy > VidGetScrH() ) - { - if ( m_data[m_type].respawning ) - { - m_isActive = false; - - m_timerFunc = NPC_TIMER_RESPAWN; - m_timerTimer = 4 * GameState::getOneSecondInFrames(); - } - else - { - setToShutdown(); - } - } - - break; + removeChild( Next ); } } } + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcEyeballEnemy::processShotDeathEnd( int _frames ) +{ + CNpcEnemy::processShotDeathEnd( _frames ); + + m_heading = m_drawRotation - 1024; + m_heading &= 4095; + + CThing *Next=getNext(); + if ( Next ) + { + CProjectile *projectile; + + projectile = (CProjectile *) Next; + + DVECTOR eyeballPos = Pos; + + eyeballPos.vx += ( EYEBALL_DIST * rcos( m_heading ) ) >> 12; + eyeballPos.vy += ( EYEBALL_DIST * rsin( m_heading ) ) >> 12; + + projectile->setPosition( eyeballPos ); + projectile->setHeading( m_heading ); + } +} diff --git a/source/enemy/neyeball.h b/source/enemy/neyeball.h index edaa8b0e9..54165adf0 100644 --- a/source/enemy/neyeball.h +++ b/source/enemy/neyeball.h @@ -26,7 +26,8 @@ protected: virtual void processEnemyCollision( CThing *thisThing ); virtual bool processSensor(); virtual void processClose( int _frames ); - virtual void processShot( int _frames ); + virtual void processShotDeathStart( int _frames ); + virtual void processShotDeathEnd( int _frames ); s32 m_fireHeading; diff --git a/source/enemy/nfdutch.cpp b/source/enemy/nfdutch.cpp index 578d4f009..057b34941 100644 --- a/source/enemy/nfdutch.cpp +++ b/source/enemy/nfdutch.cpp @@ -313,122 +313,22 @@ void CNpcFlyingDutchmanEnemy::processClose( int _frames ) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void CNpcFlyingDutchmanEnemy::processShot( int _frames ) +void CNpcFlyingDutchmanEnemy::processShotRecoil( int _frames ) { - switch( m_data[m_type].shotFunc ) + m_invulnerableTimer = 2 * GameState::getOneSecondInFrames(); + + CNpcEnemy::processShotRecoil( _frames ); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcFlyingDutchmanEnemy::processShotDeathEnd( int _frames ) +{ + CNpcEnemy::processShotDeathEnd( _frames ); + + if ( isSetToShutdown() ) { - case NPC_SHOT_NONE: - { - // do nothing - - break; - } - - case NPC_SHOT_GENERIC: - { - switch ( m_state ) - { - case NPC_GENERIC_HIT_CHECK_HEALTH: - { - m_health -= 5; - - if ( m_health < 0 ) - { - m_state = NPC_GENERIC_HIT_DEATH_START; - m_isDying = true; - } - else - { - m_state = NPC_GENERIC_HIT_RECOIL; - - m_animPlaying = true; - m_animNo = m_data[m_type].recoilAnim; - m_frame = 0; - } - - break; - } - - case NPC_GENERIC_HIT_RECOIL: - { - m_invulnerableTimer = 2 * GameState::getOneSecondInFrames(); - - if ( !m_animPlaying ) - { - m_state = 0; - m_controlFunc = NPC_CONTROL_MOVEMENT; - } - - break; - } - - case NPC_GENERIC_HIT_DEATH_START: - { - //m_animPlaying = true; - m_animNo = m_data[m_type].dieAnim; - m_frame = 0; - m_state = NPC_GENERIC_HIT_DEATH_END; - m_isDying = true; - - if ( m_data[m_type].deathSfx < CSoundMediator::NUM_SFXIDS ) - { - if( m_soundId != NOT_PLAYING ) - { - CSoundMediator::stopAndUnlockSfx( (xmPlayingId) m_soundId ); - } - - m_soundId = (int) CSoundMediator::playSfx( m_data[m_type].deathSfx, true ); - } - - m_speed = -5; - - if (m_data[m_type].skelType) - { - m_actorGfx->SetOtPos( 0 ); - } - - break; - } - - case NPC_GENERIC_HIT_DEATH_END: - { - //if ( !m_animPlaying ) - { - m_drawRotation += 64 * _frames; - m_drawRotation &= 4095; - - Pos.vy += m_speed * _frames; - - if ( m_speed < 5 ) - { - m_speed++; - } - - DVECTOR offset = CLevel::getCameraPos(); - - if ( Pos.vy - offset.vy > VidGetScrH() ) - { - if ( m_data[m_type].respawning ) - { - m_isActive = false; - - m_timerFunc = NPC_TIMER_RESPAWN; - m_timerTimer = 4 * GameState::getOneSecondInFrames(); - } - else - { - setToShutdown(); - CGameScene::setBossHasBeenKilled(); - } - } - } - - break; - } - } - - break; - } + CGameScene::setBossHasBeenKilled(); } } diff --git a/source/enemy/nfdutch.h b/source/enemy/nfdutch.h index 63958539e..ab313cb92 100644 --- a/source/enemy/nfdutch.h +++ b/source/enemy/nfdutch.h @@ -28,7 +28,8 @@ public: protected: virtual void processClose( int _frames ); virtual void processMovement( int _frames ); - virtual void processShot( int _frames ); + virtual void processShotRecoil( int _frames ); + virtual void processShotDeathEnd( int _frames ); virtual void collidedWith(CThing *_thisThing); enum NPC_FLYING_DUTCHMAN_STATE diff --git a/source/enemy/npc.cpp b/source/enemy/npc.cpp index 854355db3..e591c212d 100644 --- a/source/enemy/npc.cpp +++ b/source/enemy/npc.cpp @@ -1243,71 +1243,21 @@ void CNpcEnemy::processShot( int _frames ) case NPC_GENERIC_HIT_RECOIL: { - if ( !m_animPlaying ) - { - m_state = 0; - m_controlFunc = NPC_CONTROL_MOVEMENT; - } + processShotRecoil( _frames ); break; } case NPC_GENERIC_HIT_DEATH_START: { - m_animPlaying = true; - m_animNo = m_data[m_type].dieAnim; - m_frame = 0; - m_state = NPC_GENERIC_HIT_DEATH_END; - m_isDying = true; - - if ( m_data[m_type].deathSfx < CSoundMediator::NUM_SFXIDS ) - { - if( m_soundId != NOT_PLAYING ) - { - CSoundMediator::stopAndUnlockSfx( (xmPlayingId) m_soundId ); - } - - m_soundId = (int) CSoundMediator::playSfx( m_data[m_type].deathSfx, true ); - } - - m_speed = -5; - - if (m_data[m_type].skelType) - { - m_actorGfx->SetOtPos( 0 ); - } + processShotDeathStart( _frames ); break; } case NPC_GENERIC_HIT_DEATH_END: { - m_drawRotation += 64 * _frames; - m_drawRotation &= 4095; - - Pos.vy += m_speed * _frames; - - if ( m_speed < 5 ) - { - m_speed++; - } - - DVECTOR offset = CLevel::getCameraPos(); - - if ( Pos.vy - offset.vy > VidGetScrH() ) - { - if ( m_data[m_type].respawning ) - { - m_isActive = false; - - m_timerFunc = NPC_TIMER_RESPAWN; - m_timerTimer = 4 * GameState::getOneSecondInFrames(); - } - else - { - setToShutdown(); - } - } + processShotDeathEnd( _frames ); break; } @@ -1320,6 +1270,77 @@ void CNpcEnemy::processShot( int _frames ) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void CNpcEnemy::processShotRecoil( int _frames ) +{ + if ( !m_animPlaying ) + { + m_state = 0; + m_controlFunc = NPC_CONTROL_MOVEMENT; + } +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcEnemy::processShotDeathStart( int _frames ) +{ + m_animPlaying = true; + m_animNo = m_data[m_type].dieAnim; + m_frame = 0; + m_state = NPC_GENERIC_HIT_DEATH_END; + m_isDying = true; + + if ( m_data[m_type].deathSfx < CSoundMediator::NUM_SFXIDS ) + { + if( m_soundId != NOT_PLAYING ) + { + CSoundMediator::stopAndUnlockSfx( (xmPlayingId) m_soundId ); + } + + m_soundId = (int) CSoundMediator::playSfx( m_data[m_type].deathSfx, true ); + } + + m_speed = -5; + + if (m_data[m_type].skelType) + { + m_actorGfx->SetOtPos( 0 ); + } +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcEnemy::processShotDeathEnd( int _frames ) +{ + m_drawRotation += 64 * _frames; + m_drawRotation &= 4095; + + Pos.vy += m_speed * _frames; + + if ( m_speed < 5 ) + { + m_speed++; + } + + DVECTOR offset = CLevel::getCameraPos(); + + if ( Pos.vy - offset.vy > VidGetScrH() ) + { + if ( m_data[m_type].respawning ) + { + m_isActive = false; + + m_timerFunc = NPC_TIMER_RESPAWN; + m_timerTimer = 4 * GameState::getOneSecondInFrames(); + } + else + { + setToShutdown(); + } + } +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcEnemy::processClose(int _frames) { switch( m_data[this->m_type].closeFunc ) diff --git a/source/enemy/npc.h b/source/enemy/npc.h index 5661a3d85..82efcf94d 100644 --- a/source/enemy/npc.h +++ b/source/enemy/npc.h @@ -252,6 +252,9 @@ protected: virtual void processMovement( int _frames ); virtual void processMovementModifier( int _frames, s32 distX, s32 distY, s32 dist, s16 headingChange ); virtual void processShot( int _frames ); + virtual void processShotRecoil( int _frames ); + virtual void processShotDeathStart( int _frames ); + virtual void processShotDeathEnd( int _frames ); virtual void processClose( int _frames ); virtual void processCollision(); virtual void processAttackCollision(); diff --git a/source/enemy/nsshark.cpp b/source/enemy/nsshark.cpp index 4f805e3fa..3082d3279 100644 --- a/source/enemy/nsshark.cpp +++ b/source/enemy/nsshark.cpp @@ -627,28 +627,7 @@ void CNpcSubSharkEnemy::processShot( int _frames ) case NPC_GENERIC_HIT_DEATH_START: { - m_animPlaying = true; - m_animNo = m_data[m_type].dieAnim; - m_frame = 0; - m_state = NPC_GENERIC_HIT_DEATH_END; - m_isDying = true; - - if ( m_data[m_type].deathSfx < CSoundMediator::NUM_SFXIDS ) - { - if( m_soundId != NOT_PLAYING ) - { - CSoundMediator::stopAndUnlockSfx( (xmPlayingId) m_soundId ); - } - - m_soundId = (int) CSoundMediator::playSfx( m_data[m_type].deathSfx, true ); - } - - m_speed = -5; - - if (m_data[m_type].skelType) - { - m_actorGfx->SetOtPos( 0 ); - } + CNpcEnemy::processShotDeathStart( _frames ); break; } @@ -657,32 +636,11 @@ void CNpcSubSharkEnemy::processShot( int _frames ) { if ( !m_animPlaying ) { - m_drawRotation += 64 * _frames; - m_drawRotation &= 4095; + CNpcEnemy::processShotDeathEnd( _frames ); - Pos.vy += m_speed * _frames; - - if ( m_speed < 5 ) + if ( isSetToShutdown() ) { - m_speed++; - } - - DVECTOR offset = CLevel::getCameraPos(); - - if ( Pos.vy - offset.vy > VidGetScrH() ) - { - if ( m_data[m_type].respawning ) - { - m_isActive = false; - - m_timerFunc = NPC_TIMER_RESPAWN; - m_timerTimer = 4 * GameState::getOneSecondInFrames(); - } - else - { - setToShutdown(); - CGameScene::setBossHasBeenKilled(); - } + CGameScene::setBossHasBeenKilled(); } } diff --git a/source/enemy/nworm.cpp b/source/enemy/nworm.cpp index 3a6541360..61b55456d 100644 --- a/source/enemy/nworm.cpp +++ b/source/enemy/nworm.cpp @@ -595,118 +595,18 @@ int CNpcParasiticWormSegment::checkCollisionAgainst( CThing *_thisThing, int _fr //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void CNpcParasiticWormEnemy::processShot( int _frames ) +void CNpcParasiticWormEnemy::processShotDeathEnd( int _frames ) { - switch( m_data[m_type].shotFunc ) + CNpcEnemy::processShotDeathEnd( _frames ); + + // go through segments + + for ( int segCount = 0 ; segCount < NPC_PARASITIC_WORM_LENGTH ; segCount++ ) { - case NPC_SHOT_NONE: - { - // do nothing - - break; - } - - case NPC_SHOT_GENERIC: - { - switch ( m_state ) - { - case NPC_GENERIC_HIT_CHECK_HEALTH: - { - m_health -= 5; - - if ( m_health < 0 ) - { - m_state = NPC_GENERIC_HIT_DEATH_START; - } - else - { - m_state = NPC_GENERIC_HIT_RECOIL; - - m_animPlaying = true; - m_animNo = m_data[m_type].recoilAnim; - m_frame = 0; - } - - break; - } - - case NPC_GENERIC_HIT_RECOIL: - { - if ( !m_animPlaying ) - { - m_state = 0; - m_controlFunc = NPC_CONTROL_MOVEMENT; - } - - break; - } - - case NPC_GENERIC_HIT_DEATH_START: - { - m_state = NPC_GENERIC_HIT_DEATH_END; - - if ( m_data[m_type].deathSfx < CSoundMediator::NUM_SFXIDS ) - { - if( m_soundId != NOT_PLAYING ) - { - CSoundMediator::stopAndUnlockSfx( (xmPlayingId) m_soundId ); - } - - m_soundId = CSoundMediator::playSfx( m_data[m_type].deathSfx, true ); - } - - m_isDying = true; - m_speed = -5; - - if (m_data[m_type].skelType) - { - m_actorGfx->SetOtPos( 0 ); - } - - break; - } - - case NPC_GENERIC_HIT_DEATH_END: - { - Pos.vy += m_speed * _frames; - - // go through segments - - for ( int segCount = 0 ; segCount < NPC_PARASITIC_WORM_LENGTH ; segCount++ ) - { - DVECTOR segPos = m_segmentArray[segCount].getPos(); - segPos.vy += m_speed * _frames; - m_segmentArray[segCount].setPos( segPos ); - m_segmentArray[segCount].updateCollisionArea(); - } - - if ( m_speed < 5 ) - { - m_speed++; - } - - DVECTOR offset = CLevel::getCameraPos(); - - if ( Pos.vy - offset.vy > VidGetScrH() ) - { - if ( m_data[m_type].respawning ) - { - m_isActive = false; - - m_timerFunc = NPC_TIMER_RESPAWN; - m_timerTimer = 4 * GameState::getOneSecondInFrames(); - } - else - { - setToShutdown(); - } - } - - break; - } - } - - break; - } + DVECTOR segPos = m_segmentArray[segCount].getPos(); + segPos.vy += m_speed * _frames; + m_segmentArray[segCount].setPos( segPos ); + m_segmentArray[segCount].updateCollisionArea(); } } + diff --git a/source/enemy/nworm.h b/source/enemy/nworm.h index c447f8b07..6c9314139 100644 --- a/source/enemy/nworm.h +++ b/source/enemy/nworm.h @@ -59,7 +59,7 @@ protected: virtual bool processSensor(); virtual void processClose( int _frames ); virtual void processMovement( int _frames ); - virtual void processShot( int _frames ); + virtual void processShotDeathEnd( int _frames ); //void resetParasiticWormHeadToTail(); virtual void processEnemyCollision( CThing *thisThing );