diff --git a/Graphics/characters/Caterpillar/AnimList.Txt b/Graphics/characters/Caterpillar/AnimList.Txt index d1d344511..0e3d91734 100644 --- a/Graphics/characters/Caterpillar/AnimList.Txt +++ b/Graphics/characters/Caterpillar/AnimList.Txt @@ -1 +1,2 @@ crawl +die diff --git a/source/enemy/nhcrab.cpp b/source/enemy/nhcrab.cpp index 4f2533d27..092d17f83 100644 --- a/source/enemy/nhcrab.cpp +++ b/source/enemy/nhcrab.cpp @@ -31,6 +31,13 @@ #include #endif +#ifndef __VID_HEADER_ +#include "system\vid.h" +#endif + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcHermitCrabEnemy::postInit() { m_npcPath.setPathType( CNpcPath::PONG_PATH ); @@ -38,6 +45,8 @@ void CNpcHermitCrabEnemy::postInit() m_state = HERMIT_CRAB_NO_ATTACK; } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + bool CNpcHermitCrabEnemy::processSensor() { switch( m_sensorFunc ) @@ -61,6 +70,8 @@ bool CNpcHermitCrabEnemy::processSensor() } } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcHermitCrabEnemy::processClose( int _frames ) { if ( m_state == HERMIT_CRAB_NO_ATTACK ) @@ -234,6 +245,8 @@ void CNpcHermitCrabEnemy::processClose( int _frames ) } } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcHermitCrabEnemy::processMovementModifier( int _frames, s32 distX, s32 distY, s32 dist, s16 headingChange ) { Pos.vx += distX; @@ -261,3 +274,108 @@ void CNpcHermitCrabEnemy::processMovementModifier( int _frames, s32 distX, s32 d CSoundMediator::playSfx( CSoundMediator::SFX_HERMIT_CRAB_MOVE ); } + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcHermitCrabEnemy::processShot( int _frames ) +{ + switch ( m_state ) + { + case NPC_GENERIC_HIT_CHECK_HEALTH: + { + if ( CLevel::getCurrentChapter() == 1 && CLevel::getCurrentChapterLevel() == 1 ) + { + m_state = NPC_GENERIC_HIT_DEATH_START; + } + else + { + m_health -= 5; + + if ( m_health < 0 ) + { + m_state = NPC_GENERIC_HIT_DEATH_START; + + m_animPlaying = true; + m_animNo = m_data[m_type].dieAnim; + m_frame = 0; + } + 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: + { + if ( !m_animPlaying ) + { + m_state = NPC_GENERIC_HIT_DEATH_END; + + if ( m_data[m_type].deathSfx < CSoundMediator::NUM_SFXIDS ) + { + CSoundMediator::playSfx( m_data[m_type].deathSfx ); + } + + m_isDying = true; + m_speed = -5; + + if (m_data[m_type].skelType) + { + m_actorGfx->SetOtPos( 0 ); + } + } + + 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(); + } + } + + break; + } + } +} diff --git a/source/enemy/nhcrab.h b/source/enemy/nhcrab.h index 771648cb9..ac73e74d7 100644 --- a/source/enemy/nhcrab.h +++ b/source/enemy/nhcrab.h @@ -25,6 +25,7 @@ public: protected: virtual void processMovementModifier( int _frames, s32 distX, s32 distY, s32 dist, s16 headingChange ); virtual bool processSensor(); + virtual void processShot( int _frames ); virtual void processClose( int _frames ); s32 m_jumpBase; diff --git a/source/enemy/npbug.cpp b/source/enemy/npbug.cpp index 3503c42b1..8dd45db2d 100644 --- a/source/enemy/npbug.cpp +++ b/source/enemy/npbug.cpp @@ -19,8 +19,15 @@ #include "level\layercollision.h" #endif +#ifndef __VID_HEADER_ +#include "system\vid.h" +#endif + #include "game/game.h" + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcPricklyBugEnemy::processMovementModifier( int _frames, s32 distX, s32 distY, s32 dist, s16 headingChange ) { Pos.vx += distX; @@ -48,3 +55,108 @@ void CNpcPricklyBugEnemy::processMovementModifier( int _frames, s32 distX, s32 d CSoundMediator::playSfx( CSoundMediator::SFX_PRICKLY_BUG_MOVE ); } + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcPricklyBugEnemy::processShot( int _frames ) +{ + switch ( m_state ) + { + case NPC_GENERIC_HIT_CHECK_HEALTH: + { + if ( CLevel::getCurrentChapter() == 1 && CLevel::getCurrentChapterLevel() == 1 ) + { + m_state = NPC_GENERIC_HIT_DEATH_START; + } + else + { + m_health -= 5; + + if ( m_health < 0 ) + { + m_state = NPC_GENERIC_HIT_DEATH_START; + + m_animPlaying = true; + m_animNo = m_data[m_type].dieAnim; + m_frame = 0; + } + 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: + { + if ( !m_animPlaying ) + { + m_state = NPC_GENERIC_HIT_DEATH_END; + + if ( m_data[m_type].deathSfx < CSoundMediator::NUM_SFXIDS ) + { + CSoundMediator::playSfx( m_data[m_type].deathSfx ); + } + + m_isDying = true; + m_speed = -5; + + if (m_data[m_type].skelType) + { + m_actorGfx->SetOtPos( 0 ); + } + } + + 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(); + } + } + + break; + } + } +} diff --git a/source/enemy/npbug.h b/source/enemy/npbug.h index fbf93d277..20b15921f 100644 --- a/source/enemy/npbug.h +++ b/source/enemy/npbug.h @@ -22,6 +22,7 @@ class CNpcPricklyBugEnemy : public CNpcEnemy { protected: virtual void processMovementModifier( int _frames, s32 distX, s32 distY, s32 dist, s16 headingChange ); + virtual void processShot( int _frames ); }; #endif diff --git a/source/enemy/npc.cpp b/source/enemy/npc.cpp index c15498ce4..347ce8a2c 100644 --- a/source/enemy/npc.cpp +++ b/source/enemy/npc.cpp @@ -368,36 +368,6 @@ CNpcEnemy *CNpcEnemy::Create(int enemyType) break; } - /*case CNpcEnemy::NPC_FALLING_ITEM: - { - enemy = new ("falling item") CNpcFallingItemHazard; - break; - }*/ - - /*case CNpcEnemy::NPC_FISH_HOOK: - { - enemy = new ("fish hook") CNpcFishHookHazard; - break; - }*/ - - /*case CNpcEnemy::NPC_PENDULUM: - { - enemy = new ("pendulum") CNpcPendulumHazard; - break; - }*/ - - /*case CNpcEnemy::NPC_FIREBALL: - { - enemy = new ("fireball") CNpcFireballHazard; - break; - }*/ - - /*case CNpcEnemy::NPC_SAW_BLADE: - { - enemy = new ("saw blade") CNpcReturningHazard; - break; - }*/ - case CNpcEnemy::NPC_DUST_DEVIL: { enemy = new ("dust devil") CNpcDustDevilEnemy; diff --git a/source/enemy/npcdata.cpp b/source/enemy/npcdata.cpp index 61a824534..5c1b2f4eb 100644 --- a/source/enemy/npcdata.cpp +++ b/source/enemy/npcdata.cpp @@ -403,7 +403,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 9, ANIM_CATERPILLAR_CRAWL, NPC_SHOT_GENERIC, - 0, + ANIM_CATERPILLAR_DIE, 0, false, false,