Skip to content

Commit

Permalink
Remove un-needed if statements in the Low Ammo Threshold
Browse files Browse the repository at this point in the history
Also, fix certain NOCLIP weapons constantly thinking they're low on ammo.
  • Loading branch information
sabianroberts committed Nov 17, 2024
1 parent 5a57d00 commit bc29653
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 6 additions & 10 deletions cl_dll/ammo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,10 +649,9 @@ void CHudAmmo::Warning()
{
static bool ammoWarningPlayed = false;
int ammoCount = m_iCurrentClipAmmo;
lowAmmoThreshold = WEAPON_NOCLIP;

if (m_iCurrentWeapon == WEAPON_CROWBAR || m_iCurrentWeapon == WEAPON_PIPEWRENCH || m_iCurrentWeapon == WEAPON_KNIFE || m_iCurrentWeapon == WEAPON_GRAPPLE || m_iCurrentWeapon == WEAPON_RPG || m_iCurrentWeapon == WEAPON_SATCHEL || m_iCurrentWeapon == WEAPON_SHOCKRIFLE || m_iCurrentWeapon == WEAPON_HORNETGUN)
lowAmmoThreshold = -1;
else if (m_iCurrentWeapon == WEAPON_GLOCK)
if (m_iCurrentWeapon == WEAPON_GLOCK)
lowAmmoThreshold = 3;
else if (m_iCurrentWeapon == WEAPON_EAGLE)
lowAmmoThreshold = 2;
Expand All @@ -664,17 +663,14 @@ void CHudAmmo::Warning()
lowAmmoThreshold = 2; // give space for a double shot on warning.
else if (m_iCurrentWeapon == WEAPON_CROSSBOW)
lowAmmoThreshold = 1;
else if (m_iCurrentWeapon == WEAPON_GAUSS || m_iCurrentWeapon == WEAPON_EGON)
lowAmmoThreshold = 40;
else if (m_iCurrentWeapon == WEAPON_DISPLACER)
lowAmmoThreshold = 60;
else if (m_iCurrentWeapon == WEAPON_HANDGRENADE || m_iCurrentWeapon == WEAPON_TRIPMINE || m_iCurrentWeapon == WEAPON_SPORELAUNCHER || m_iCurrentWeapon == WEAPON_SNARK || m_iCurrentWeapon == WEAPON_PENGUIN)
lowAmmoThreshold = 1; // most boobie traps.
else if (m_iCurrentWeapon == WEAPON_M249)
lowAmmoThreshold = 15;
else if (m_iCurrentWeapon == WEAPON_SNIPERRIFLE)
lowAmmoThreshold = 1;

if (lowAmmoThreshold == WEAPON_NOCLIP)
return;

if (ammoCount > lowAmmoThreshold)
ammoWarningPlayed = false;
else if (!ammoWarningPlayed)
Expand Down Expand Up @@ -940,7 +936,7 @@ int CHudAmmo::Draw(float flTime)
m_fFade -= (gHUD.m_flTimeDelta * 20);

UnpackRGB(r, g, b, RGB_DEFAULT);
if (m_iCurrentClipAmmo > lowAmmoThreshold)
if (m_iCurrentClipAmmo > lowAmmoThreshold || m_iCurrentClipAmmo == WEAPON_NOCLIP)
{
UnpackRGB(r, g, b, gHUD.m_iDefaultHUDColor);
if (Blinking)
Expand Down
2 changes: 2 additions & 0 deletions cl_dll/cl_weapons.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@
#define WEAPON_KNIFE 25
#define WEAPON_PENGUIN 26
#define WEAPON_ONE 27

#define WEAPON_NOCLIP -1

0 comments on commit bc29653

Please sign in to comment.