player_sustainammo

oops i missed this one
This commit is contained in:
Skull Merlin 2022-05-05 18:28:54 +03:00
parent 54185c8464
commit def158432b
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;

View File

@ -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;

View File

@ -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;

View File

@ -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