mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2025-04-14 13:40:02 +03:00
* fix bug when picking weaponbox grenades with ammo > 1 (#669)
* fix bug pickup sound (if the player has ammo > 0)
This commit is contained in:
parent
4a7a63533c
commit
c756bf89d1
@ -1595,7 +1595,17 @@ int CBasePlayerWeapon::ExtractClipAmmo(CBasePlayerWeapon *pWeapon)
|
|||||||
iAmmo = m_iClip;
|
iAmmo = m_iClip;
|
||||||
}
|
}
|
||||||
|
|
||||||
return pWeapon->m_pPlayer->GiveAmmo(iAmmo, pszAmmo1(), iMaxAmmo1());
|
int iIdAmmo = pWeapon->m_pPlayer->GiveAmmo(iAmmo, pszAmmo1(), iMaxAmmo1());
|
||||||
|
|
||||||
|
#ifdef REGAMEDLL_FIXES
|
||||||
|
if (iIdAmmo > 0 && IsGrenadeWeapon(m_iId))
|
||||||
|
{
|
||||||
|
// grenades have WEAPON_NOCLIP force play the "got ammo" sound.
|
||||||
|
EMIT_SOUND(pWeapon->m_pPlayer->edict(), CHAN_ITEM, "items/9mmclip1.wav", VOL_NORM, ATTN_NORM);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return iIdAmmo;
|
||||||
}
|
}
|
||||||
|
|
||||||
// RetireWeapon - no more ammo for this gun, put it away.
|
// RetireWeapon - no more ammo for this gun, put it away.
|
||||||
@ -1920,19 +1930,35 @@ void CWeaponBox::Touch(CBaseEntity *pOther)
|
|||||||
int playerGrenades = pPlayer->m_rgAmmo[pGrenade->m_iPrimaryAmmoType];
|
int playerGrenades = pPlayer->m_rgAmmo[pGrenade->m_iPrimaryAmmoType];
|
||||||
|
|
||||||
#ifdef REGAMEDLL_FIXES
|
#ifdef REGAMEDLL_FIXES
|
||||||
auto info = GetWeaponInfo(pGrenade->m_iId);
|
// sorry for hardcode :(
|
||||||
if (info && playerGrenades < info->maxRounds)
|
const int boxAmmoSlot = 1;
|
||||||
{
|
|
||||||
auto pNext = m_rgpPlayerItems[i]->m_pNext;
|
|
||||||
if (pPlayer->AddPlayerItem(pItem))
|
|
||||||
{
|
|
||||||
pItem->AttachToPlayer(pPlayer);
|
|
||||||
bEmitSound = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// unlink this weapon from the box
|
if (playerGrenades < pGrenade->iMaxAmmo1())
|
||||||
m_rgpPlayerItems[i] = pItem = pNext;
|
{
|
||||||
continue;
|
if (m_rgAmmo[boxAmmoSlot] > 1 && playerGrenades > 0)
|
||||||
|
{
|
||||||
|
if (!FStringNull(m_rgiszAmmo[boxAmmoSlot])
|
||||||
|
&& pPlayer->GiveAmmo(1, STRING(m_rgiszAmmo[boxAmmoSlot]), pGrenade->iMaxAmmo1()) != -1)
|
||||||
|
{
|
||||||
|
m_rgAmmo[boxAmmoSlot]--;
|
||||||
|
|
||||||
|
EMIT_SOUND(pPlayer->edict(), CHAN_ITEM, "items/9mmclip1.wav", VOL_NORM, ATTN_NORM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto pNext = m_rgpPlayerItems[i]->m_pNext;
|
||||||
|
|
||||||
|
if (pPlayer->AddPlayerItem(pItem))
|
||||||
|
{
|
||||||
|
pItem->AttachToPlayer(pPlayer);
|
||||||
|
bEmitSound = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// unlink this weapon from the box
|
||||||
|
m_rgpPlayerItems[i] = pItem = pNext;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user