You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the Gauss gun's secondary attack, the player's uranium ammo can be set to -1 if the player has only 1 unit of ammo left and holds the secondary attack key down.
When using secondary attack the weapon first uses up one unit of ammo, then the next time it checks it uses up another unit of ammo before checking if the player is out of ammo.
If the player only has 1 unit of ammo left to begin with then the first time it thinks while charging it will go from 0 ammo to -1.
To fix this an additional check is needed to prevent the ammo consumption from occurring:
if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] > 0)
{
// during the charging process, eat one bit of ammo every once in a whileif (UTIL_WeaponTimeBase() >= m_pPlayer->m_flNextAmmoBurn && m_pPlayer->m_flNextAmmoBurn != 1000)
{
#ifdef CLIENT_DLL
if (bIsMultiplayer())
#elseif (g_pGameRules->IsMultiplayer())
#endif
{
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase() + 0.1;
}
else
{
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase() + 0.3;
}
}
}
The text was updated successfully, but these errors were encountered:
SamVanheer
added a commit
to twhl-community/halflife-updated
that referenced
this issue
Mar 31, 2023
When using the Gauss gun's secondary attack, the player's uranium ammo can be set to -1 if the player has only 1 unit of ammo left and holds the secondary attack key down.
The cause is here:
halflife/dlls/gauss.cpp
Lines 229 to 256 in c7240b9
When using secondary attack the weapon first uses up one unit of ammo, then the next time it checks it uses up another unit of ammo before checking if the player is out of ammo.
If the player only has 1 unit of ammo left to begin with then the first time it thinks while charging it will go from 0 ammo to -1.
To fix this an additional check is needed to prevent the ammo consumption from occurring:
The text was updated successfully, but these errors were encountered: