From b82f524819b71b1bd4b12a20ab008052a6126a03 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Mon, 24 Apr 2023 01:55:43 +0300 Subject: [PATCH] Fix Human Grunts dropping weapons again if the game is saved and loaded while the grunt is dying Same as https://github.com/SamVanheer/halflife-updated/commit/bc7d6e3c0782f94553dd692351e7659903c0fa05 --- dlls/hgrunt.cpp | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/dlls/hgrunt.cpp b/dlls/hgrunt.cpp index 7f7e39e5..2f1dffbd 100644 --- a/dlls/hgrunt.cpp +++ b/dlls/hgrunt.cpp @@ -849,27 +849,30 @@ void CHGrunt::HandleAnimEvent( MonsterEvent_t *pEvent ) { case HGRUNT_AE_DROP_GUN: { - Vector vecGunPos; - Vector vecGunAngles; + if ( GetBodygroup( GUN_GROUP ) != GUN_NONE ) + { + Vector vecGunPos; + Vector vecGunAngles; - GetAttachment( 0, vecGunPos, vecGunAngles ); + GetAttachment( 0, vecGunPos, vecGunAngles ); - // switch to body group with no gun. - SetBodygroup( GUN_GROUP, GUN_NONE ); + // switch to body group with no gun. + SetBodygroup( GUN_GROUP, GUN_NONE ); - // now spawn a gun. - if( FBitSet( pev->weapons, HGRUNT_SHOTGUN ) ) - { - DropItem( "weapon_shotgun", vecGunPos, vecGunAngles ); - } - else - { - DropItem( "weapon_9mmAR", vecGunPos, vecGunAngles ); - } + // now spawn a gun. + if( FBitSet( pev->weapons, HGRUNT_SHOTGUN ) ) + { + DropItem( "weapon_shotgun", vecGunPos, vecGunAngles ); + } + else + { + DropItem( "weapon_9mmAR", vecGunPos, vecGunAngles ); + } - if( FBitSet( pev->weapons, HGRUNT_GRENADELAUNCHER ) ) - { - DropItem( "ammo_ARgrenades", BodyTarget( pev->origin ), vecGunAngles ); + if( FBitSet( pev->weapons, HGRUNT_GRENADELAUNCHER ) ) + { + DropItem( "ammo_ARgrenades", BodyTarget( pev->origin ), vecGunAngles ); + } } } break;