Browse Source

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

redempt
Andrey Akhmichin 5 years ago
parent
commit
2d282b1477
  1. 2
      dlls/barney.h
  2. 27
      dlls/redempt/roy.cpp

2
dlls/barney.h

@ -32,7 +32,7 @@ public: @@ -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 );

27
dlls/redempt/roy.cpp

@ -32,18 +32,19 @@ @@ -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 ) @@ -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 ) @@ -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
//=========================================================

Loading…
Cancel
Save