diff --git a/src/client/component/gameplay.cpp b/src/client/component/gameplay.cpp index 061a9c19..31635184 100644 --- a/src/client/component/gameplay.cpp +++ b/src/client/component/gameplay.cpp @@ -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(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; diff --git a/src/client/game/dvars.cpp b/src/client/game/dvars.cpp index 8f0c5dba..f46d7d5b 100644 --- a/src/client/game/dvars.cpp +++ b/src/client/game/dvars.cpp @@ -23,6 +23,7 @@ namespace dvars game::dvar_t* con_inputCmdMatchColor = nullptr; game::dvar_t* g_playerEjection = nullptr; game::dvar_t* g_playerCollision = nullptr; + game::dvar_t* player_sustainAmmo = nullptr; game::dvar_t* jump_enableFallDamage; diff --git a/src/client/game/dvars.hpp b/src/client/game/dvars.hpp index 34f6d714..24c4afb5 100644 --- a/src/client/game/dvars.hpp +++ b/src/client/game/dvars.hpp @@ -26,6 +26,7 @@ namespace dvars extern game::dvar_t* con_inputCmdMatchColor; extern game::dvar_t* g_playerEjection; extern game::dvar_t* g_playerCollision; + extern game::dvar_t* player_sustainAmmo; extern game::dvar_t* jump_enableFallDamage; diff --git a/src/client/game/structs.hpp b/src/client/game/structs.hpp index 9d1907c8..6fa0cf2f 100644 --- a/src/client/game/structs.hpp +++ b/src/client/game/structs.hpp @@ -1438,6 +1438,19 @@ namespace game float halfSize[3]; }; + enum PlayerHandIndex + { + WEAPON_HAND_DEFAULT = 0x0, + WEAPON_HAND_RIGHT = 0x0, + WEAPON_HAND_LEFT = 0x1, + NUM_WEAPON_HANDS = 0x2, + }; + + union Weapon + { + unsigned int data; + }; + namespace mp { struct cachedSnapshot_t