This commit is contained in:
Charles 2001-04-05 20:44:30 +00:00
parent ace470e1c4
commit ef78241c95
6 changed files with 184 additions and 71 deletions

View File

@ -136,6 +136,8 @@ void CNpcEnemy::processCloseAnemone1Attack( int _frames )
m_controlFunc = NPC_CONTROL_MOVEMENT;
m_timerTimer = GameState::getOneSecondInFrames();
m_timerFunc = NPC_TIMER_ATTACK_DONE;
m_sensorFunc = NPC_SENSOR_NONE;
m_animPlaying = true;
m_animNo = ANIM_ANENOMELVL1_BEND;

View File

@ -42,19 +42,4 @@ void CNpcEnemy::processCloseEyeballAttack( int _frames )
projectile->setState( CProjectile::PROJECTILE_ATTACK );
}
}
/*if ( Next )
{
// already have child, ignore
}
else
{
// create child projectile which will be deleted when the projectile has returned
CProjectile *projectile;
projectile = new ( "test projectile" ) CProjectile;
projectile->init( Pos, m_fireHeading, CProjectile::PROJECTILE_FIXED, CProjectile::PROJECTILE_INFINITE_LIFE );
addChild( projectile );
}*/
}

View File

@ -651,20 +651,39 @@ void CNpcEnemy::collidedWith( CThing *_thisThing )
{
case TYPE_PLAYER:
{
if ( m_data[m_type].detectCollision )
if ( m_controlFunc != NPC_CONTROL_COLLISION )
{
if ( m_data[m_type].damageToUserType == DAMAGE__NONE )
// only detect collision if one isn't already happening
switch( m_data[m_type].detectCollision )
{
// if we can detect a collision, but the collision does no damage, this must be a platform
case DETECT_NO_COLLISION:
{
// ignore
CPlayer *player = (CPlayer *) _thisThing;
player->setPlatform( this );
break;
}
else
case DETECT_ALL_COLLISION:
{
m_oldControlFunc = m_controlFunc;
m_controlFunc = NPC_CONTROL_COLLISION;
break;
}
case DETECT_ATTACK_COLLISION_GENERIC:
{
if ( m_controlFunc == NPC_CONTROL_CLOSE )
{
// only detect collision if in attack mode
m_oldControlFunc = m_controlFunc;
m_controlFunc = NPC_CONTROL_COLLISION;
}
break;
}
}
}
@ -1422,12 +1441,27 @@ void CNpcEnemy::processClose(int _frames)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcEnemy::processCollision()
{
switch( m_data[m_type].collisionFunc )
{
case NPC_COLLISION_GENERIC:
{
CPlayer *player = GameScene.getPlayer();
//player->takeDamage( m_data[m_type].damageToUserType );
m_controlFunc = m_oldControlFunc;
break;
}
case NPC_COLLISION_SPIDER_CRAB_BITE:
{
processSpiderCrabCollision();
break;
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -310,6 +310,12 @@ protected:
NPC_SHOT_GENERIC = 1,
};
enum NPC_COLLISION_FUNC
{
NPC_COLLISION_GENERIC = 0,
NPC_COLLISION_SPIDER_CRAB_BITE = 1,
};
enum NPC_MOTHER_JELLYFISH_STATE
{
MOTHER_JELLYFISH_RETURN_TO_START_1 = 0,
@ -391,6 +397,13 @@ protected:
NPC_ENEMY_MAPEDIT_OFFSET = 10,
};
enum DETECT_TYPE
{
DETECT_NO_COLLISION = 0,
DETECT_ALL_COLLISION = 1,
DETECT_ATTACK_COLLISION_GENERIC,
};
typedef struct NPC_DATA_TYPE
{
@ -406,13 +419,14 @@ protected:
bool canTalk;
u8 speed;
u16 turnSpeed;
bool detectCollision;
DETECT_TYPE detectCollision;
DAMAGE_TYPE damageToUserType;
u16 initHealth;
u16 moveAnim;
NPC_SHOT_FUNC shotFunc;
u16 dieAnim;
u16 recoilAnim;
NPC_COLLISION_FUNC collisionFunc;
}
NPC_DATA;
@ -462,6 +476,7 @@ protected:
// spider crab functions
void processCloseSpiderCrabAttack( int _frames );
void processSpiderCrabCollision();
// hermit crab functions

View File

@ -198,13 +198,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
8,
128,
false,
DETECT_NO_COLLISION,
DAMAGE__SQUASH_ENEMY,
0,
0,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_FISH_HOOK
@ -219,13 +220,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
3,
128,
false,
DETECT_NO_COLLISION,
DAMAGE__NONE,
0,
0,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_DUST_DEVIL
@ -240,13 +242,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
3,
2048,
false,
DETECT_NO_COLLISION,
DAMAGE__NONE,
0,
ANIM_DUSTDEVIL_TWIST,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_PENDULUM
@ -261,13 +264,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
3,
2048,
false,
DETECT_NO_COLLISION,
DAMAGE__HIT_ENEMY,
0,
0,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_FIREBALL
@ -282,13 +286,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
40,
2048,
false,
DETECT_NO_COLLISION,
DAMAGE__BURN_ENEMY,
0,
0,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_SAW_BLADE
@ -303,13 +308,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
3,
2048,
false,
DETECT_NO_COLLISION,
DAMAGE__HIT_ENEMY,
0,
0,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_SMALL_JELLYFISH_1
@ -324,13 +330,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
3,
128,
false,
DETECT_NO_COLLISION,
DAMAGE__SHOCK_ENEMY,
16,
ANIM_JELLYFISH1_SWIM,
NPC_SHOT_GENERIC,
0,
ANIM_JELLYFISH1_SWIM,
NPC_COLLISION_GENERIC,
},
{ // NPC_SMALL_JELLYFISH_2
@ -345,13 +352,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
3,
128,
false,
DETECT_NO_COLLISION,
DAMAGE__SHOCK_ENEMY,
32,
0,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_ANEMONE_1
@ -366,13 +374,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
0,
128,
false,
DETECT_NO_COLLISION,
DAMAGE__NONE,
16,
0,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_ANEMONE_2
@ -387,13 +396,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
0,
128,
false,
DETECT_NO_COLLISION,
DAMAGE__NONE,
32,
0,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_ANEMONE_3
@ -408,13 +418,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
0,
128,
false,
DETECT_NO_COLLISION,
DAMAGE__NONE,
48,
0,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_SKELETAL_FISH
@ -429,13 +440,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
3,
2048,
false,
DETECT_NO_COLLISION,
DAMAGE__BITE_ENEMY,
0,
ANIM_SKELETALFISH_SWIM,
NPC_SHOT_GENERIC,
ANIM_SKELETALFISH_DIE,
ANIM_SKELETALFISH_GETHIT,
NPC_COLLISION_GENERIC,
},
{ // NPC_CLAM_JUMP
@ -450,13 +462,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
0,
128,
false,
DETECT_NO_COLLISION,
DAMAGE__HIT_ENEMY,
0,
0,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_CLAM_STATIC
@ -471,13 +484,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
0,
128,
false,
DETECT_NO_COLLISION,
DAMAGE__HIT_ENEMY,
0,
0,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_SQUID_DART
@ -492,13 +506,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
5,
256,
false,
DETECT_NO_COLLISION,
DAMAGE__HIT_ENEMY,
16,
ANIM_SQUIDDART_SWIM,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_FISH_FOLK
@ -513,13 +528,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
2,
2048,
false,
DETECT_NO_COLLISION,
DAMAGE__NONE,
0,
0,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_PRICKLY_BUG
@ -534,13 +550,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
1,
128,
false,
DETECT_NO_COLLISION,
DAMAGE__POISON_ENEMY,
48,
ANIM_CATERPILLAR_CRAWL,
NPC_SHOT_GENERIC,
ANIM_CATERPILLAR_DIE,
ANIM_CATERPILLAR_GETHIT,
NPC_COLLISION_GENERIC,
},
{ // NPC_SEA_SNAKE
@ -555,13 +572,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
3,
256,
false,
DETECT_NO_COLLISION,
DAMAGE__SHOCK_ENEMY,
56,
0,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_PUFFA_FISH
@ -576,13 +594,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
2,
128,
false,
DETECT_NO_COLLISION,
DAMAGE__HIT_ENEMY,
64,
ANIM_PUFFAFISH_SWIM,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_ANGLER_FISH
@ -597,13 +616,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
1,
128,
false,
DETECT_NO_COLLISION,
DAMAGE__NONE,
0,
0,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_HERMIT_CRAB
@ -618,13 +638,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
2,
128,
false,
DETECT_NO_COLLISION,
DAMAGE__HIT_ENEMY,
32,
ANIM_HERMITCRAB_SCUTTLE,
NPC_SHOT_GENERIC,
ANIM_HERMITCRAB_DIE,
ANIM_HERMITCRAB_GETHIT,
NPC_COLLISION_GENERIC,
},
{ // NPC_MINE
@ -639,13 +660,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
0,
128,
false,
DETECT_NO_COLLISION,
DAMAGE__HIT_ENEMY,
0,
0,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_BOOGER_MONSTER
@ -660,13 +682,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
0,
128,
false,
DETECT_NO_COLLISION,
DAMAGE__BITE_ENEMY,
0,
0,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_SPIDER_CRAB
@ -681,13 +704,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
3,
2048,
false,
DETECT_ATTACK_COLLISION_GENERIC,
DAMAGE__PINCH_ENEMY,
0,
ANIM_SPIDERCRAB_RUN,
NPC_SHOT_GENERIC,
ANIM_SPIDERCRAB_DIE,
ANIM_SPIDERCRAB_HIT,
NPC_COLLISION_SPIDER_CRAB_BITE,
},
{ // NPC_EYEBALL
@ -702,13 +726,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
0,
128,
false,
DETECT_NO_COLLISION,
DAMAGE__HIT_ENEMY,
32,
0,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_BABY_OCTOPUS
@ -723,13 +748,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
2,
512,
false,
DETECT_NO_COLLISION,
DAMAGE__HIT_ENEMY,
32,
ANIM_BABYOCTOPUS_SWIM,
NPC_SHOT_GENERIC,
ANIM_BABYOCTOPUS_DIE,
ANIM_BABYOCTOPUS_HIT,
NPC_COLLISION_GENERIC,
},
{ // NPC_ZOMBIE_FISH_FOLK
@ -744,13 +770,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
2,
2048,
false,
DETECT_NO_COLLISION,
DAMAGE__HIT_ENEMY,
16,
0,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_NINJA_STARFISH
@ -765,13 +792,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
3,
64,
false,
DETECT_NO_COLLISION,
DAMAGE__HIT_ENEMY,
16,
0,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_GHOST
@ -786,13 +814,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
2,
128,
false,
DETECT_NO_COLLISION,
DAMAGE__HIT_ENEMY,
0,
ANIM_GHOST_MOVE,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_GHOST_PIRATE
@ -807,13 +836,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
0,
128,
false,
DETECT_NO_COLLISION,
DAMAGE__HIT_ENEMY,
160,
0,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_FLAMING_SKULL
@ -828,13 +858,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
3,
128,
false,
DETECT_NO_COLLISION,
DAMAGE__BURN_ENEMY,
16,
ANIM_FLAMINGSKULL_MOVE,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_SHARK_MAN
@ -849,13 +880,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
3,
2048,
false,
DETECT_NO_COLLISION,
DAMAGE__BITE_ENEMY,
16,
ANIM_SHARKMAN_RUN,
NPC_SHOT_GENERIC,
ANIM_SHARKMAN_DIE,
ANIM_SHARKMAN_BLOCK,
NPC_COLLISION_GENERIC,
},
{ // NPC_OIL_BLOB
@ -870,13 +902,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
3,
64,
false,
DETECT_NO_COLLISION,
DAMAGE__HIT_ENEMY,
0,
0,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_SKULL_STOMPER
@ -891,13 +924,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
5,
2048,
false,
DETECT_NO_COLLISION,
DAMAGE__SQUASH_ENEMY,
0,
ANIM_STOMPER_CRUSH,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_MOTHER_JELLYFISH
@ -912,13 +946,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
3,
256,
false,
DETECT_NO_COLLISION,
DAMAGE__SHOCK_ENEMY,
256,
0,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_SUB_SHARK
@ -933,13 +968,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
3,
2048,
false,
DETECT_NO_COLLISION,
DAMAGE__HIT_ENEMY,
256,
0,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_PARASITIC_WORM
@ -954,13 +990,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
3,
128,
false,
DETECT_NO_COLLISION,
DAMAGE__HIT_ENEMY,
256,
0,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_FLYING_DUTCHMAN
@ -975,13 +1012,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
3,
2048,
false,
DETECT_NO_COLLISION,
DAMAGE__HIT_ENEMY,
256,
ANIM_FLYINGDUTCHMAN_FLY,
NPC_SHOT_GENERIC,
0,
ANIM_FLYINGDUTCHMAN_GETHIT,
NPC_COLLISION_GENERIC,
},
{ // NPC_IRON_DOGFISH
@ -996,13 +1034,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
3,
2048,
false,
DETECT_NO_COLLISION,
DAMAGE__HIT_ENEMY,
256,
ANIM_IRONDOGFISH_WALK,
NPC_SHOT_GENERIC,
0,
ANIM_IRONDOGFISH_GETHIT,
NPC_COLLISION_GENERIC,
},
{ // NPC_PARASITIC_WORM_SEGMENT
@ -1017,13 +1056,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
3,
2048,
false,
DETECT_NO_COLLISION,
DAMAGE__HIT_ENEMY,
256,
0,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
{ // NPC_BALL_BLOB
@ -1038,13 +1078,14 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
false,
3,
128,
false,
DETECT_NO_COLLISION,
DAMAGE__BURN_ENEMY,
16,
ANIM_BALLBLOB_WOBBLE,
NPC_SHOT_GENERIC,
0,
0,
NPC_COLLISION_GENERIC,
},
};

View File

@ -111,3 +111,39 @@ void CNpcEnemy::processCloseSpiderCrabAttack( int _frames )
m_extension = 0;
}
}
void CNpcEnemy::processSpiderCrabCollision()
{
if ( m_oldControlFunc == NPC_CONTROL_CLOSE )
{
// bite player
if ( m_animNo != ANIM_SPIDERCRAB_BITE )
{
CPlayer *player = GameScene.getPlayer();
//player->takeDamage( m_data[m_type].damageToUserType );
m_animNo = ANIM_SPIDERCRAB_BITE;
m_animPlaying = true;
m_frame = 0;
}
else if ( !m_animPlaying )
{
m_controlFunc = NPC_CONTROL_MOVEMENT;
m_timerFunc = NPC_TIMER_ATTACK_DONE;
m_timerTimer = GameState::getOneSecondInFrames();
m_sensorFunc = NPC_SENSOR_NONE;
m_extension = 0;
}
}
else
{
CPlayer *player = GameScene.getPlayer();
//player->takeDamage( m_data[m_type].damageToUserType );
m_controlFunc = m_oldControlFunc;
}
}