mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2024-12-28 15:45:41 +03:00
Fix: Grenade weaponbox not deploying on unarmed player (#847)
This commit is contained in:
parent
728f1fcc67
commit
1aae57fd17
@ -1840,7 +1840,12 @@ void CWeaponBox::Touch(CBaseEntity *pOther)
|
||||
pPlayer->OnTouchingWeapon(this);
|
||||
|
||||
bool bRemove = true;
|
||||
bool bEmitSound = false;
|
||||
|
||||
#ifdef REGAMEDLL_FIXES
|
||||
CBasePlayerItem *givenItem = nullptr;
|
||||
#else
|
||||
bool givenItem = false;
|
||||
#endif
|
||||
|
||||
// go through my weapons and try to give the usable ones to the player.
|
||||
// it's important the the player be given ammo first, so the weapons code doesn't refuse
|
||||
@ -1974,7 +1979,7 @@ void CWeaponBox::Touch(CBaseEntity *pOther)
|
||||
if (pPlayer->AddPlayerItem(pItem))
|
||||
{
|
||||
pItem->AttachToPlayer(pPlayer);
|
||||
bEmitSound = true;
|
||||
givenItem = pItem;
|
||||
}
|
||||
|
||||
// unlink this weapon from the box
|
||||
@ -2011,7 +2016,7 @@ void CWeaponBox::Touch(CBaseEntity *pOther)
|
||||
// there we will see only get one grenade. Next step - pick it up, do check again `entity_dump`,
|
||||
// but this time we'll see them x2.
|
||||
|
||||
bEmitSound = true;
|
||||
givenItem = true;
|
||||
pPlayer->GiveNamedItem(grenadeName);
|
||||
|
||||
// unlink this weapon from the box
|
||||
@ -2033,7 +2038,11 @@ void CWeaponBox::Touch(CBaseEntity *pOther)
|
||||
if (pPlayer->AddPlayerItem(pItem))
|
||||
{
|
||||
pItem->AttachToPlayer(pPlayer);
|
||||
bEmitSound = true;
|
||||
#ifdef REGAMEDLL_FIXES
|
||||
givenItem = pItem;
|
||||
#else
|
||||
givenItem = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
// unlink this weapon from the box
|
||||
@ -2067,9 +2076,21 @@ void CWeaponBox::Touch(CBaseEntity *pOther)
|
||||
}
|
||||
}
|
||||
|
||||
if (bEmitSound)
|
||||
if (givenItem)
|
||||
{
|
||||
EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM);
|
||||
|
||||
#ifdef REGAMEDLL_FIXES
|
||||
// BUGBUG: weaponbox links gun to player, then ammo is given
|
||||
// so FShouldSwitchWeapon's CanHolster (which checks ammo) check inside AddPlayerItem
|
||||
// return FALSE, causing an unarmed player to not deploy any weaponbox grenade
|
||||
if (pPlayer->m_pActiveItem != givenItem && CSGameRules()->FShouldSwitchWeapon(pPlayer, givenItem))
|
||||
{
|
||||
// This re-check is done after ammo is given
|
||||
// so it ensures player properly deploys grenade from floor
|
||||
pPlayer->SwitchWeapon(givenItem);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (bRemove)
|
||||
|
Loading…
Reference in New Issue
Block a user