Fix for a crash which occurs when NPCs pick up a weapon the player is already holding

This commit is contained in:
Blixibon 2021-09-25 14:27:11 -05:00
parent 85097e119e
commit f61b933ed3

View File

@ -11495,6 +11495,14 @@ bool CAI_BaseNPC::ChooseEnemy( void )
//=========================================================
void CAI_BaseNPC::PickupWeapon( CBaseCombatWeapon *pWeapon )
{
#ifdef MAPBASE
if ( pWeapon->VPhysicsGetObject() && pWeapon->VPhysicsGetObject()->GetGameFlags() & FVPHYSICS_PLAYER_HELD )
{
CBasePlayer *pPlayer = UTIL_GetLocalPlayer();
pPlayer->ForceDropOfCarriedPhysObjects( pWeapon );
}
#endif
pWeapon->OnPickedUp( this );
Weapon_Equip( pWeapon );
m_iszPendingWeapon = NULL_STRING;