From ace470e1c4a14426cd873a9c45870d8a77f9671a Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 5 Apr 2001 19:36:04 +0000 Subject: [PATCH] --- source/enemy/npc.cpp | 47 ++++++++++++--- source/enemy/npc.h | 11 ++-- source/enemy/npcdata.cpp | 127 ++++++++++++++++++++++++++------------- 3 files changed, 130 insertions(+), 55 deletions(-) diff --git a/source/enemy/npc.cpp b/source/enemy/npc.cpp index c7b638cd4..0ffd14422 100644 --- a/source/enemy/npc.cpp +++ b/source/enemy/npc.cpp @@ -685,7 +685,7 @@ bool CNpcEnemy::processSensor() if ( playerXDistSqr + playerYDistSqr < 10000 ) { m_controlFunc = NPC_CONTROL_SHOT; - m_state = NPC_GENERIC_DEATH_START; + m_state = NPC_GENERIC_HIT_CHECK_HEALTH; return( true ); } @@ -1225,21 +1225,52 @@ void CNpcEnemy::processShot() break; } - case NPC_SHOT_GENERIC_DIE: + case NPC_SHOT_GENERIC: { switch ( m_state ) { - case NPC_GENERIC_DEATH_START: + case NPC_GENERIC_HIT_CHECK_HEALTH: { - m_animPlaying = true; - m_animNo = m_data[m_type].dieAnim; - m_frame = 0; - m_state = NPC_GENERIC_DEATH_END; + 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_DEATH_END: + 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; + + break; + } + + case NPC_GENERIC_HIT_DEATH_END: { if ( !m_animPlaying ) { diff --git a/source/enemy/npc.h b/source/enemy/npc.h index 68a64ff25..66c668029 100644 --- a/source/enemy/npc.h +++ b/source/enemy/npc.h @@ -307,7 +307,7 @@ protected: enum NPC_SHOT_FUNC { NPC_SHOT_NONE = 0, - NPC_SHOT_GENERIC_DIE = 1, + NPC_SHOT_GENERIC = 1, }; enum NPC_MOTHER_JELLYFISH_STATE @@ -367,10 +367,12 @@ protected: PUFFA_FISH_INFLATE, }; - enum NPC_GENERIC_DEATH_STATE + enum NPC_GENERIC_HIT_STATE { - NPC_GENERIC_DEATH_START = 100, - NPC_GENERIC_DEATH_END = 101, + NPC_GENERIC_HIT_CHECK_HEALTH = 100, + NPC_GENERIC_HIT_RECOIL = 101, + NPC_GENERIC_HIT_DEATH_START, + NPC_GENERIC_HIT_DEATH_END, }; enum @@ -410,6 +412,7 @@ protected: u16 moveAnim; NPC_SHOT_FUNC shotFunc; u16 dieAnim; + u16 recoilAnim; } NPC_DATA; diff --git a/source/enemy/npcdata.cpp b/source/enemy/npcdata.cpp index 0aa24a842..91f9aa173 100644 --- a/source/enemy/npcdata.cpp +++ b/source/enemy/npcdata.cpp @@ -202,7 +202,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__SQUASH_ENEMY, 0, 0, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -222,7 +223,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__NONE, 0, 0, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -242,7 +244,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__NONE, 0, ANIM_DUSTDEVIL_TWIST, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -262,7 +265,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__HIT_ENEMY, 0, 0, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -282,7 +286,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__BURN_ENEMY, 0, 0, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -302,7 +307,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__HIT_ENEMY, 0, 0, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -322,8 +328,9 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__SHOCK_ENEMY, 16, ANIM_JELLYFISH1_SWIM, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, 0, + ANIM_JELLYFISH1_SWIM, }, { // NPC_SMALL_JELLYFISH_2 @@ -342,7 +349,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__SHOCK_ENEMY, 32, 0, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -362,7 +370,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__NONE, 16, 0, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -382,7 +391,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__NONE, 32, 0, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -402,7 +412,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__NONE, 48, 0, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -422,8 +433,9 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__BITE_ENEMY, 0, ANIM_SKELETALFISH_SWIM, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, ANIM_SKELETALFISH_DIE, + ANIM_SKELETALFISH_GETHIT, }, { // NPC_CLAM_JUMP @@ -442,7 +454,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__HIT_ENEMY, 0, 0, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -462,7 +475,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__HIT_ENEMY, 0, 0, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -482,7 +496,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__HIT_ENEMY, 16, ANIM_SQUIDDART_SWIM, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -502,7 +517,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__NONE, 0, 0, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -522,8 +538,9 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__POISON_ENEMY, 48, ANIM_CATERPILLAR_CRAWL, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, ANIM_CATERPILLAR_DIE, + ANIM_CATERPILLAR_GETHIT, }, { // NPC_SEA_SNAKE @@ -542,7 +559,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__SHOCK_ENEMY, 56, 0, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -562,7 +580,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__HIT_ENEMY, 64, ANIM_PUFFAFISH_SWIM, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -582,7 +601,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__NONE, 0, 0, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -600,10 +620,11 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 128, false, DAMAGE__HIT_ENEMY, - 0, + 32, ANIM_HERMITCRAB_SCUTTLE, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, ANIM_HERMITCRAB_DIE, + ANIM_HERMITCRAB_GETHIT, }, { // NPC_MINE @@ -622,7 +643,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__HIT_ENEMY, 0, 0, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -642,7 +664,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__BITE_ENEMY, 0, 0, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -662,8 +685,9 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__PINCH_ENEMY, 0, ANIM_SPIDERCRAB_RUN, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, ANIM_SPIDERCRAB_DIE, + ANIM_SPIDERCRAB_HIT, }, { // NPC_EYEBALL @@ -682,7 +706,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__HIT_ENEMY, 32, 0, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -700,10 +725,11 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 512, false, DAMAGE__HIT_ENEMY, - 0, + 32, ANIM_BABYOCTOPUS_SWIM, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, ANIM_BABYOCTOPUS_DIE, + ANIM_BABYOCTOPUS_HIT, }, { // NPC_ZOMBIE_FISH_FOLK @@ -722,7 +748,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__HIT_ENEMY, 16, 0, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -742,7 +769,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__HIT_ENEMY, 16, 0, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -762,7 +790,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__HIT_ENEMY, 0, ANIM_GHOST_MOVE, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -782,7 +811,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__HIT_ENEMY, 160, 0, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -802,7 +832,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__BURN_ENEMY, 16, ANIM_FLAMINGSKULL_MOVE, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -822,8 +853,9 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__BITE_ENEMY, 16, ANIM_SHARKMAN_RUN, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, ANIM_SHARKMAN_DIE, + ANIM_SHARKMAN_BLOCK, }, { // NPC_OIL_BLOB @@ -842,7 +874,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__HIT_ENEMY, 0, 0, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -862,7 +895,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__SQUASH_ENEMY, 0, ANIM_STOMPER_CRUSH, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -882,7 +916,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__SHOCK_ENEMY, 256, 0, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -902,7 +937,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__HIT_ENEMY, 256, 0, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -922,7 +958,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__HIT_ENEMY, 256, 0, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -942,8 +979,9 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__HIT_ENEMY, 256, ANIM_FLYINGDUTCHMAN_FLY, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, 0, + ANIM_FLYINGDUTCHMAN_GETHIT, }, { // NPC_IRON_DOGFISH @@ -962,8 +1000,9 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__HIT_ENEMY, 256, ANIM_IRONDOGFISH_WALK, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, 0, + ANIM_IRONDOGFISH_GETHIT, }, { // NPC_PARASITIC_WORM_SEGMENT @@ -982,7 +1021,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__HIT_ENEMY, 256, 0, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, @@ -1002,7 +1042,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = DAMAGE__BURN_ENEMY, 16, ANIM_BALLBLOB_WOBBLE, - NPC_SHOT_GENERIC_DIE, + NPC_SHOT_GENERIC, + 0, 0, }, };