player_sustainammo

oops i missed this one
This commit is contained in:
Skull Merlin
2022-05-05 18:28:54 +03:00
parent 667a0005e0
commit 1cd666a1e8
4 changed files with 30 additions and 0 deletions

View File

@ -14,6 +14,8 @@ namespace gameplay
{
namespace
{
utils::hook::detour pm_weapon_use_ammo_hook;
game::dvar_t* jump_slowDownEnable;
game::dvar_t* jump_enableFallDamage;
@ -53,6 +55,15 @@ namespace gameplay
}
}
void pm_weapon_use_ammo_stub(game::playerState_s* ps, game::Weapon weapon,
bool is_alternate, int amount, game::PlayerHandIndex hand)
{
if (!dvars::player_sustainAmmo->current.enabled)
{
pm_weapon_use_ammo_hook.invoke<void>(ps, weapon, is_alternate, amount, hand);
}
}
const auto pm_bouncing_stub_mp = utils::hook::assemble([](utils::hook::assembler& a)
{
const auto no_bounce = a.newLabel();
@ -100,6 +111,10 @@ namespace gameplay
public:
void post_unpack() override
{
dvars::player_sustainAmmo = dvars::register_bool("player_sustainAmmo", false,
game::DVAR_FLAG_REPLICATED, "Firing weapon will not decrease clip ammo");
pm_weapon_use_ammo_hook.create(SELECT_VALUE(0x14042E380, 0x1401F6B90), &pm_weapon_use_ammo_stub);
if (game::environment::is_sp())
{
return;