From 2d282b1477d0e179580f057be67c1d927630be6a Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin Date: Sat, 30 Nov 2019 13:33:58 +0500 Subject: [PATCH] Override HandleAnimEvent function instead of BarneyFirePistol to avoid fields offsets changing. --- dlls/barney.h | 2 +- dlls/redempt/roy.cpp | 27 +++++++++++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/dlls/barney.h b/dlls/barney.h index 755c465a..8328d9d3 100644 --- a/dlls/barney.h +++ b/dlls/barney.h @@ -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 ); diff --git a/dlls/redempt/roy.cpp b/dlls/redempt/roy.cpp index 786037e0..72d554bf 100644 --- a/dlls/redempt/roy.cpp +++ b/dlls/redempt/roy.cpp @@ -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 //=========================================================