From 2ffa0261e30a4b90082965bb2539b767c5686a5f Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Thu, 24 Feb 2022 16:40:10 +0300 Subject: [PATCH] Fix sniperrifle dropping when massn is gibbed (#244) --- dlls/gearbox/massn.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/dlls/gearbox/massn.cpp b/dlls/gearbox/massn.cpp index 5ca5981e..4e9d0631 100644 --- a/dlls/gearbox/massn.cpp +++ b/dlls/gearbox/massn.cpp @@ -72,6 +72,7 @@ class CMassn : public CHGrunt public: int Classify(void); void HandleAnimEvent(MonsterEvent_t *pEvent); + void GibMonster(void); void Sniperrifle(void); BOOL FOkToSpeak(void); @@ -229,6 +230,47 @@ void CMassn::HandleAnimEvent(MonsterEvent_t *pEvent) } } +void CMassn::GibMonster() +{ + Vector vecGunPos; + Vector vecGunAngles; + + if( GetBodygroup( GUN_GROUP ) != GUN_NONE ) + { + // throw a gun if the grunt has one + GetAttachment( 0, vecGunPos, vecGunAngles ); + + CBaseEntity *pGun; + + if( FBitSet( pev->weapons, MASSN_SNIPERRIFLE ) ) + { + pGun = DropItem( "weapon_sniperrifle", vecGunPos, vecGunAngles ); + } + else + { + pGun = DropItem( "weapon_9mmAR", vecGunPos, vecGunAngles ); + } + + if( pGun ) + { + pGun->pev->velocity = Vector( RANDOM_FLOAT( -100, 100 ), RANDOM_FLOAT( -100, 100 ), RANDOM_FLOAT( 200, 300 ) ); + pGun->pev->avelocity = Vector( 0, RANDOM_FLOAT( 200, 400 ), 0 ); + } + + if( FBitSet( pev->weapons, MASSN_GRENADELAUNCHER ) ) + { + pGun = DropItem( "ammo_ARgrenades", vecGunPos, vecGunAngles ); + if ( pGun ) + { + pGun->pev->velocity = Vector( RANDOM_FLOAT( -100, 100 ), RANDOM_FLOAT( -100, 100 ), RANDOM_FLOAT( 200, 300 ) ); + pGun->pev->avelocity = Vector( 0, RANDOM_FLOAT( 200, 400 ), 0 ); + } + } + } + + CBaseMonster::GibMonster(); +} + //========================================================= // Spawn //=========================================================