mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2025-03-03 17:25:24 +03:00
RemovePlayerItemEx: Do not remove the grenade weapons until it runs out of ammo
This commit is contained in:
parent
4b4cd88feb
commit
94bf705196
@ -211,33 +211,38 @@ EXT_FUNC bool CCSPlayer::RemovePlayerItemEx(const char* pszItemName, bool bRemov
|
||||
auto pItem = GetItemByName(pszItemName);
|
||||
if (pItem)
|
||||
{
|
||||
if (FClassnameIs(pItem->pev, "weapon_c4")) {
|
||||
pPlayer->m_bHasC4 = false;
|
||||
pPlayer->pev->body = 0;
|
||||
pPlayer->SetBombIcon(FALSE);
|
||||
pPlayer->SetProgressBarTime(0);
|
||||
}
|
||||
|
||||
if (pItem->IsWeapon())
|
||||
{
|
||||
// These weapons have a unique type of ammo that is used only by them
|
||||
// If a weapon is removed, its ammo is also reduced, unless the ammo can be used by another weapon
|
||||
if (!bRemoveAmmo && (IsGrenadeWeapon(pItem->m_iId) || pItem->m_iId == WEAPON_C4))
|
||||
{
|
||||
if (pPlayer->m_rgAmmo[pItem->PrimaryAmmoIndex()] > 0)
|
||||
pPlayer->m_rgAmmo[pItem->PrimaryAmmoIndex()]--;
|
||||
|
||||
// Hold the weapon until it runs out of ammo
|
||||
if (pPlayer->m_rgAmmo[pItem->PrimaryAmmoIndex()] > 0)
|
||||
return true; // ammo was reduced, this will be considered a successful result
|
||||
}
|
||||
|
||||
if (pItem == pPlayer->m_pActiveItem) {
|
||||
((CBasePlayerWeapon *)pItem)->RetireWeapon();
|
||||
}
|
||||
|
||||
if (bRemoveAmmo) {
|
||||
pPlayer->m_rgAmmo[ pItem->PrimaryAmmoIndex() ] = 0;
|
||||
} else {
|
||||
// These weapons have a unique type of ammo that is used only by them
|
||||
// If a weapon is removed, its ammo is also reduced, unless the ammo can be used by another weapon
|
||||
if (IsGrenadeWeapon(pItem->m_iId) || pItem->m_iId == WEAPON_C4)
|
||||
{
|
||||
if (pPlayer->m_rgAmmo[pItem->PrimaryAmmoIndex()] > 0)
|
||||
pPlayer->m_rgAmmo[pItem->PrimaryAmmoIndex()]--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pPlayer->RemovePlayerItem(pItem)) {
|
||||
if (pPlayer->RemovePlayerItem(pItem))
|
||||
{
|
||||
if (FClassnameIs(pItem->pev, "weapon_c4")) {
|
||||
pPlayer->m_bHasC4 = false;
|
||||
pPlayer->pev->body = 0;
|
||||
pPlayer->SetBombIcon(FALSE);
|
||||
pPlayer->SetProgressBarTime(0);
|
||||
}
|
||||
|
||||
pPlayer->pev->weapons &= ~(1 << pItem->m_iId);
|
||||
// No more weapon
|
||||
if ((pPlayer->pev->weapons & ~(1 << WEAPON_SUIT)) == 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user