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,15 +718,23 @@ void CNpcEnemy::think(int _frames)
void CNpcEnemy::collidedWith( CThing *_thisThing ) void CNpcEnemy::collidedWith( CThing *_thisThing )
{ {
if ( m_isActive )
{
switch(_thisThing->getThingType()) switch(_thisThing->getThingType())
{ {
case TYPE_PLAYER: case TYPE_PLAYER:
{ {
if ( m_controlFunc != NPC_CONTROL_COLLISION && m_attackTimer == 0 ) CPlayer *player = (CPlayer *) _thisThing;
{
// only detect collision if one isn't already happening
switch( m_data[m_type].detectCollision && m_isActive ) ATTACK_STATE playerState = player->getAttackState();
switch( playerState )
{
case ATTACK_STATE__NONE:
{
if ( !player->isRecoveringFromHit() )
{
switch( m_data[m_type].detectCollision )
{ {
case DETECT_NO_COLLISION: case DETECT_NO_COLLISION:
{ {
@ -747,6 +753,7 @@ void CNpcEnemy::collidedWith( CThing *_thisThing )
case DETECT_ATTACK_COLLISION_GENERIC: 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 ) if ( m_controlFunc == NPC_CONTROL_CLOSE )
{ {
// only detect collision if in attack mode // only detect collision if in attack mode
@ -763,10 +770,28 @@ void CNpcEnemy::collidedWith( CThing *_thisThing )
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;
}
default: default:
ASSERT(0); ASSERT(0);
break; 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;