From 93c3ae5e34a23d025e359debd73c3e3ff0bb5716 Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 5 Mar 2001 21:11:51 +0000 Subject: [PATCH] --- source/enemy/npc.cpp | 22 +++++++++++++------ source/enemy/npc.h | 3 ++- source/enemy/npcdata.cpp | 46 ++++++++++++++++++++-------------------- source/player/player.cpp | 11 ++++++++++ source/player/player.h | 9 ++++++++ 5 files changed, 60 insertions(+), 31 deletions(-) diff --git a/source/enemy/npc.cpp b/source/enemy/npc.cpp index c7ae58fb5..a107a9a9e 100644 --- a/source/enemy/npc.cpp +++ b/source/enemy/npc.cpp @@ -453,8 +453,6 @@ void CNpcEnemy::think(int _frames) playerXDistSqr = playerXDist * playerXDist; playerYDistSqr = playerYDist * playerYDist; - detectCollisionWithPlayer(); - if ( m_animPlaying ) { int frameCount = m_skel.getFrameCount(); @@ -519,14 +517,24 @@ void CNpcEnemy::think(int _frames) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void CNpcEnemy::detectCollisionWithPlayer() +void CNpcEnemy::collidedWith( CThing *_thisThing ) { - if ( m_data[m_type].detectCollision && playerXDistSqr + playerYDistSqr < 400 ) + switch(_thisThing->getThingType()) { - // close enough for collision + case TYPE_PLAYER: + { + if ( m_data[m_type].detectCollision ) + { + m_oldControlFunc = m_controlFunc; + m_controlFunc = NPC_CONTROL_COLLISION; + } - m_oldControlFunc = m_controlFunc; - m_controlFunc = NPC_CONTROL_COLLISION; + break; + } + + default: + ASSERT(0); + break; } } diff --git a/source/enemy/npc.h b/source/enemy/npc.h index b1d628c29..1b410e721 100644 --- a/source/enemy/npc.h +++ b/source/enemy/npc.h @@ -350,7 +350,6 @@ protected: void processClose( int _frames ); void processCollision(); void processTimer( int _frames ); - void detectCollisionWithPlayer(); bool isCollisionWithGround(); void processGenericGotoTarget( int _frames, s32 xDist, s32 yDist, s32 speed ); @@ -485,6 +484,8 @@ protected: int m_animNo; CSkel m_skel; TPAGE_DESC m_actorTPage; + + virtual void collidedWith(CThing *_thisThing); }; diff --git a/source/enemy/npcdata.cpp b/source/enemy/npcdata.cpp index 34e20a394..7fae9ef56 100644 --- a/source/enemy/npcdata.cpp +++ b/source/enemy/npcdata.cpp @@ -74,7 +74,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 8, 128, false, - DAMAGE__HIT_ENEMY, + DAMAGE__SQUASH_ENEMY, }, { // NPC_FISH_HOOK @@ -90,7 +90,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 3, 128, false, - DAMAGE__HIT_ENEMY, + DAMAGE__NONE, }, { // NPC_DUST_DEVIL @@ -106,7 +106,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 3, 2048, false, - DAMAGE__HIT_ENEMY, + DAMAGE__NONE, }, { // NPC_PENDULUM @@ -138,7 +138,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 40, 2048, false, - DAMAGE__HIT_ENEMY, + DAMAGE__BURN_ENEMY, }, { // NPC_SAW_BLADE @@ -170,7 +170,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 3, 128, false, - DAMAGE__HIT_ENEMY, + DAMAGE__NONE, }, { // NPC_CIRCULAR_PLATFORM @@ -186,7 +186,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 3, 128, false, - DAMAGE__HIT_ENEMY, + DAMAGE__NONE, }, { // NPC_SMALL_JELLYFISH_1 @@ -202,7 +202,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 3, 128, false, - DAMAGE__HIT_ENEMY, + DAMAGE__SHOCK_ENEMY, }, { // NPC_SMALL_JELLYFISH_2 @@ -218,7 +218,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 3, 128, false, - DAMAGE__HIT_ENEMY, + DAMAGE__SHOCK_ENEMY, }, { // NPC_ANEMONE_1 @@ -234,7 +234,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 0, 128, false, - DAMAGE__HIT_ENEMY, + DAMAGE__NONE, }, { // NPC_ANEMONE_2 @@ -250,7 +250,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 0, 128, false, - DAMAGE__HIT_ENEMY, + DAMAGE__NONE, }, { // NPC_ANEMONE_3 @@ -266,7 +266,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 0, 128, false, - DAMAGE__HIT_ENEMY, + DAMAGE__NONE, }, { // NPC_SKELETAL_FISH @@ -282,7 +282,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 3, 2048, false, - DAMAGE__HIT_ENEMY, + DAMAGE__BITE_ENEMY, }, { // NPC_CLAM_JUMP @@ -346,7 +346,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 2, 2048, false, - DAMAGE__HIT_ENEMY, + DAMAGE__NONE, }, { // NPC_PRICKLY_BUG @@ -362,7 +362,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 1, 128, false, - DAMAGE__HIT_ENEMY, + DAMAGE__POISON_ENEMY, }, { // NPC_SEA_SNAKE_1 @@ -378,7 +378,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 3, 256, false, - DAMAGE__HIT_ENEMY, + DAMAGE__SHOCK_ENEMY, }, { // NPC_SEA_SNAKE_2 @@ -394,7 +394,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 3, 256, false, - DAMAGE__HIT_ENEMY, + DAMAGE__SHOCK_ENEMY, }, { // NPC_PUFFA_FISH @@ -426,7 +426,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 1, 128, false, - DAMAGE__HIT_ENEMY, + DAMAGE__NONE, }, { // NPC_HERMIT_CRAB @@ -474,7 +474,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 0, 128, false, - DAMAGE__HIT_ENEMY, + DAMAGE__BITE_ENEMY, }, { // NPC_SPIDER_CRAB @@ -490,7 +490,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 3, 2048, false, - DAMAGE__HIT_ENEMY, + DAMAGE__PINCH_ENEMY, }, { // NPC_EYEBALL @@ -602,7 +602,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 3, 128, false, - DAMAGE__HIT_ENEMY, + DAMAGE__BURN_ENEMY, }, { // NPC_SHARK_MAN @@ -618,7 +618,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 3, 2048, false, - DAMAGE__HIT_ENEMY, + DAMAGE__BITE_ENEMY, }, { // NPC_OIL_BLOB @@ -650,7 +650,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 5, 2048, false, - DAMAGE__HIT_ENEMY, + DAMAGE__SQUASH_ENEMY, }, { // NPC_MOTHER_JELLYFISH @@ -666,7 +666,7 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] = 3, 256, false, - DAMAGE__HIT_ENEMY, + DAMAGE__SHOCK_ENEMY, }, { // NPC_SUB_SHARK diff --git a/source/player/player.cpp b/source/player/player.cpp index 528afacf8..bc516d0a1 100644 --- a/source/player/player.cpp +++ b/source/player/player.cpp @@ -1173,9 +1173,20 @@ void CPlayer::takeDamage(DAMAGE_TYPE _damage) // Check if we are currently immune to this damage type switch(_damage) { + case DAMAGE__NONE: + break; + case DAMAGE__FALL: case DAMAGE__LAVA: case DAMAGE__HIT_ENEMY: + case DAMAGE__SHOCK_ENEMY: + case DAMAGE__GAS_ENEMY: + case DAMAGE__POISON_ENEMY: + case DAMAGE__SWALLOW_ENEMY: + case DAMAGE__PINCH_ENEMY: + case DAMAGE__SQUASH_ENEMY: + case DAMAGE__BURN_ENEMY: + case DAMAGE__BITE_ENEMY: break; case DAMAGE__ELECTROCUTION: diff --git a/source/player/player.h b/source/player/player.h index 458e70ad8..6e0d7d625 100644 --- a/source/player/player.h +++ b/source/player/player.h @@ -106,10 +106,19 @@ typedef enum typedef enum { + DAMAGE__NONE, // put in so that an item can push the user but not damage them DAMAGE__FALL, DAMAGE__ELECTROCUTION, DAMAGE__LAVA, DAMAGE__HIT_ENEMY, + DAMAGE__SHOCK_ENEMY, + DAMAGE__GAS_ENEMY, + DAMAGE__POISON_ENEMY, + DAMAGE__SWALLOW_ENEMY, + DAMAGE__PINCH_ENEMY, + DAMAGE__SQUASH_ENEMY, + DAMAGE__BURN_ENEMY, + DAMAGE__BITE_ENEMY, }DAMAGE_TYPE;