Skip to content

all games: Add sv_infinite_ammo ConVar #1211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

copperpixel
Copy link
Contributor

This PR implements the sv_infinite_ammo cheat-protected ConVar from Left 4 Dead/Alien Swarm. When enabled, it prevents the player's active weapon from depleting ammo.
Furthermore, added functionality from Counter-Strike : GO where setting the ConVar to 2 or higher will only replenish the weapon's reserve (so the player still has to reload).

In Team Fortress 2, it also refills metal and weapon/item charges.

brokenparts

This comment was marked as resolved.

@copperpixel
Copy link
Contributor Author

This doesn't seem to work with energy weapons in TF2

Should be fixed now

@copperpixel copperpixel requested a review from brokenparts April 23, 2025 05:24
Copy link
Contributor

@brokenparts brokenparts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to work perfectly for guns.

If you want to refill Soldier banners and rage meters (Soda Popper, Phog, Hitman's Heatmaker, etc) the simpler way to do it would be by calling CTFPlayerShared::SetItemChargeMeter on every weapon slot. This is what impulse 101 does:

m_Shared.m_flRageMeter = 100.f;
m_Shared.SetDemomanChargeMeter( 100.f );
for( int i = FIRST_LOADOUT_SLOT_WITH_CHARGE_METER; i <= LAST_LOADOUT_SLOT_WITH_CHARGE_METER; ++i )
{
m_Shared.SetItemChargeMeter( (loadout_positions_t)i, 100.f );
}

@copperpixel
Copy link
Contributor Author

Added your suggested changes, thanks! Although the SetScoutHypeMeter call is still needed as the Soda Popper charge doesn't seem to be affected by SetRageMeter and SetItemChargeMeter (impulse 101 doesn't affect it either).

@brokenparts
Copy link
Contributor

That may have just been an issue with my testing setup, then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants