This commit is contained in:
Charles 2001-04-12 19:42:10 +00:00
parent 612dc64226
commit ca95a6ded4
2 changed files with 57 additions and 45 deletions

View file

@ -248,7 +248,6 @@ void CNpcEnemy::init()
m_heading = m_fireHeading = 0; m_heading = m_fireHeading = 0;
m_movementTimer = 0; m_movementTimer = 0;
m_timerTimer = 0; m_timerTimer = 0;
m_attackTimer = 0;
m_velocity = 0; m_velocity = 0;
m_extension = 0; m_extension = 0;
m_rotation = 0; m_rotation = 0;
@ -578,7 +577,6 @@ void CNpcEnemy::reinit()
m_heading = m_fireHeading = 0; m_heading = m_fireHeading = 0;
m_movementTimer = 0; m_movementTimer = 0;
m_timerTimer = 0; m_timerTimer = 0;
m_attackTimer = 0;
m_velocity = 0; m_velocity = 0;
m_extension = 0; m_extension = 0;
m_rotation = 0; m_rotation = 0;
@ -720,52 +718,79 @@ void CNpcEnemy::think(int _frames)
void CNpcEnemy::collidedWith( CThing *_thisThing ) void CNpcEnemy::collidedWith( CThing *_thisThing )
{ {
switch(_thisThing->getThingType()) if ( m_isActive )
{ {
case TYPE_PLAYER: switch(_thisThing->getThingType())
{ {
if ( m_controlFunc != NPC_CONTROL_COLLISION && m_attackTimer == 0 ) case TYPE_PLAYER:
{ {
// only detect collision if one isn't already happening CPlayer *player = (CPlayer *) _thisThing;
switch( m_data[m_type].detectCollision && m_isActive ) ATTACK_STATE playerState = player->getAttackState();
switch( playerState )
{ {
case DETECT_NO_COLLISION: case ATTACK_STATE__NONE:
{ {
// ignore if ( !player->isRecoveringFromHit() )
break;
}
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 switch( m_data[m_type].detectCollision )
{
case DETECT_NO_COLLISION:
{
// ignore
m_oldControlFunc = m_controlFunc; break;
m_controlFunc = NPC_CONTROL_COLLISION; }
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 && m_data[m_type].closeFunc != NPC_CLOSE_NONE )
if ( m_controlFunc == NPC_CONTROL_CLOSE )
{
// only detect collision if in attack mode
m_oldControlFunc = m_controlFunc;
m_controlFunc = NPC_CONTROL_COLLISION;
}
break;
}
}
}
break;
}
default:
{
// player is attacking, respond appropriately
if ( m_controlFunc != NPC_CONTROL_SHOT )
{
m_controlFunc = NPC_CONTROL_SHOT;
m_state = NPC_GENERIC_HIT_CHECK_HEALTH;
} }
break; break;
} }
} }
break;
} }
break; default:
ASSERT(0);
break;
} }
default:
ASSERT(0);
break;
} }
} }
@ -1542,8 +1567,6 @@ void CNpcEnemy::processCollision()
m_controlFunc = m_oldControlFunc; m_controlFunc = m_oldControlFunc;
m_attackTimer = GameState::getOneSecondInFrames();
break; break;
} }
@ -1560,16 +1583,6 @@ void CNpcEnemy::processCollision()
void CNpcEnemy::processTimer(int _frames) void CNpcEnemy::processTimer(int _frames)
{ {
if ( m_attackTimer > 0 )
{
m_attackTimer -= _frames;
if ( m_attackTimer < 0 )
{
m_attackTimer = 0;
}
}
if ( m_timerTimer > 0 ) if ( m_timerTimer > 0 )
{ {
m_timerTimer -= _frames; m_timerTimer -= _frames;

View file

@ -602,7 +602,6 @@ protected:
bool m_reversed; bool m_reversed;
s32 m_health; s32 m_health;
bool m_isActive; bool m_isActive;
s32 m_attackTimer;
s32 m_frame; s32 m_frame;
int m_animNo; int m_animNo;