This commit is contained in:
Charles 2001-06-20 19:39:00 +00:00
parent 731ac49770
commit d5ca17cc3b
7 changed files with 300 additions and 2 deletions

View file

@ -62,6 +62,20 @@ void CNpcSubSharkEnemy::postInit()
m_health = CLevel::getBossHealth();
m_speed = m_data[m_type].speed + ( ( 3 * ( m_data[m_type].initHealth - m_health ) ) / m_data[m_type].initHealth );
}
m_invulnerableTimer = 0;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcSubSharkEnemy::think( int _frames )
{
if ( m_invulnerableTimer > 0 )
{
m_invulnerableTimer -= _frames;
}
CNpcEnemy::think( _frames );
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -344,6 +358,8 @@ void CNpcSubSharkEnemy::processShot( int _frames )
case NPC_GENERIC_HIT_RECOIL:
{
m_invulnerableTimer = 2 * GameState::getOneSecondInFrames();
if ( !m_animPlaying )
{
m_state = 0;
@ -466,3 +482,89 @@ void CNpcSubSharkEnemy::render()
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcSubSharkEnemy::collidedWith(CThing *_thisThing)
{
if ( m_isActive && !m_isCaught && !m_isDying )
{
switch(_thisThing->getThingType())
{
case TYPE_PLAYER:
{
CPlayer *player = (CPlayer *) _thisThing;
ATTACK_STATE playerState = player->getAttackState();
if(playerState==ATTACK_STATE__NONE)
{
if ( !player->isRecoveringFromHit() )
{
switch( m_data[m_type].detectCollision )
{
case DETECT_NO_COLLISION:
{
// ignore
break;
}
case DETECT_ALL_COLLISION:
{
m_oldControlFunc = m_controlFunc;
m_controlFunc = NPC_CONTROL_COLLISION;
processUserCollision( _thisThing );
break;
}
case DETECT_ATTACK_COLLISION_GENERIC:
{
processAttackCollision();
processUserCollision( _thisThing );
break;
}
}
}
}
else if ( m_invulnerableTimer <= 0 )
{
// player is attacking, respond appropriately
if ( m_controlFunc != NPC_CONTROL_SHOT )
{
if(playerState==ATTACK_STATE__BUTT_BOUNCE)
{
player->justButtBouncedABadGuy();
}
m_controlFunc = NPC_CONTROL_SHOT;
m_state = NPC_GENERIC_HIT_CHECK_HEALTH;
drawAttackEffect();
}
}
break;
}
case TYPE_ENEMY:
{
CNpcEnemy *enemy = (CNpcEnemy *) _thisThing;
if ( canCollideWithEnemy() && enemy->canCollideWithEnemy() )
{
processEnemyCollision( _thisThing );
}
break;
}
default:
ASSERT(0);
break;
}
}
}