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:
void Precache( void ); void Precache( void );
void SetYawSpeed( void ); void SetYawSpeed( void );
int ISoundMask( void ); int ISoundMask( void );
virtual void BarneyFirePistol( void ); void BarneyFirePistol( void );
void AlertSound( void ); void AlertSound( void );
int Classify( void ); int Classify( void );
void HandleAnimEvent( MonsterEvent_t *pEvent ); void HandleAnimEvent( MonsterEvent_t *pEvent );

27
dlls/redempt/roy.cpp

@ -32,18 +32,19 @@
//========================================================= //=========================================================
// Monster's Anim Events Go Here // 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 class CRoy : public CBarney
{ {
public: public:
void Spawn( void ); void Spawn( void );
void Precache( void ); void Precache( void );
void BarneyFirePistol( void ); void RoyFirePistol( void );
void AlertSound( void ); void AlertSound( void );
void HandleAnimEvent( MonsterEvent_t *pEvent );
int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType );
void DeclineFollowing( void ); void DeclineFollowing( void );
// Override these to set behavior // Override these to set behavior
@ -75,7 +76,7 @@ void CRoy::AlertSound( void )
// BarneyFirePistol - shoots one round from the pistol at // BarneyFirePistol - shoots one round from the pistol at
// the enemy barney is facing. // the enemy barney is facing.
//========================================================= //=========================================================
void CRoy::BarneyFirePistol( void ) void CRoy::RoyFirePistol( void )
{ {
Vector vecShootOrigin; Vector vecShootOrigin;
@ -104,6 +105,24 @@ void CRoy::BarneyFirePistol( void )
m_cAmmoLoaded--;// take away a bullet! 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 // Spawn
//========================================================= //=========================================================

Loading…
Cancel
Save