Override HandleAnimEvent function instead of BarneyFirePistol to avoid fields offsets changing.

This commit is contained in:
Andrey Akhmichin 2019-11-30 13:33:58 +05:00
parent 4bb977ea76
commit 2d282b1477
2 changed files with 24 additions and 5 deletions

View File

@ -32,7 +32,7 @@ public:
void Precache( void );
void SetYawSpeed( void );
int ISoundMask( void );
virtual void BarneyFirePistol( void );
void BarneyFirePistol( void );
void AlertSound( void );
int Classify( void );
void HandleAnimEvent( MonsterEvent_t *pEvent );

View File

@ -32,18 +32,19 @@
//=========================================================
// Monster's Anim Events Go Here
//=========================================================
// first flag is barney dying for scripted sequences?
// first flag is roy dying for scripted sequences?
#define ROY_AE_SHOOT ( 3 )
class CRoy : public CBarney
{
public:
void Spawn( void );
void Precache( void );
void BarneyFirePistol( void );
void RoyFirePistol( void );
void AlertSound( void );
void HandleAnimEvent( MonsterEvent_t *pEvent );
int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType );
void DeclineFollowing( void );
// Override these to set behavior
@ -75,7 +76,7 @@ void CRoy::AlertSound( void )
// BarneyFirePistol - shoots one round from the pistol at
// the enemy barney is facing.
//=========================================================
void CRoy::BarneyFirePistol( void )
void CRoy::RoyFirePistol( void )
{
Vector vecShootOrigin;
@ -104,6 +105,24 @@ void CRoy::BarneyFirePistol( void )
m_cAmmoLoaded--;// take away a bullet!
}
//=========================================================
// HandleAnimEvent - catches the monster-specific messages
// that occur when tagged animation frames are played.
//
// Returns number of events handled, 0 if none.
//=========================================================
void CRoy::HandleAnimEvent( MonsterEvent_t *pEvent )
{
switch( pEvent->event )
{
case ROY_AE_SHOOT:
RoyFirePistol();
break;
default:
CBarney::HandleAnimEvent( pEvent );
}
}
//=========================================================
// Spawn
//=========================================================