mirror of
https://github.com/XLabsProject/s1x-client.git
synced 2023-08-02 15:02:12 +02:00
Merge pull request #349 from diamante0018/develop
Add sustain ammo dvar
This commit is contained in:
commit
8680aa31c1
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -27,7 +27,7 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Check out files
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: 0
|
||||
|
@ -9,6 +9,8 @@ namespace gameplay
|
||||
{
|
||||
namespace
|
||||
{
|
||||
utils::hook::detour pm_weapon_use_ammo_hook;
|
||||
|
||||
void stuck_in_client_stub(void* entity)
|
||||
{
|
||||
if (dvars::g_playerEjection->current.enabled)
|
||||
@ -17,14 +19,13 @@ namespace gameplay
|
||||
}
|
||||
}
|
||||
|
||||
void cm_transformed_capsule_trace_stub(struct trace_t* results, const float* start, const float* end,
|
||||
struct Bounds* bounds, struct Bounds* capsule, int contents,
|
||||
const float* origin, const float* angles)
|
||||
void cm_transformed_capsule_trace_stub(game::trace_t* results, const float* start, const float* end,
|
||||
game::Bounds* bounds, game::Bounds* capsule, int contents, const float* origin, const float* angles)
|
||||
{
|
||||
if (dvars::g_playerCollision->current.enabled)
|
||||
{
|
||||
reinterpret_cast<void(*)
|
||||
(struct trace_t*, const float*, const float*, struct Bounds*, struct Bounds*, unsigned int,
|
||||
(game::trace_t*, const float*, const float*, game::Bounds*, game::Bounds*, unsigned int,
|
||||
const float*, const float*)>
|
||||
(0x1403AB1C0)
|
||||
(results, start, end, bounds, capsule, contents, origin, angles); // CM_TransformedCapsuleTrace
|
||||
@ -54,6 +55,15 @@ namespace gameplay
|
||||
a.bind(loc_14014DF48);
|
||||
a.jmp(0x14014DF48);
|
||||
});
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class component final : public component_interface
|
||||
@ -61,6 +71,10 @@ namespace gameplay
|
||||
public:
|
||||
void post_unpack() override
|
||||
{
|
||||
dvars::player_sustainAmmo = game::Dvar_RegisterBool("player_sustainAmmo", false,
|
||||
game::DVAR_FLAG_REPLICATED, "Firing weapon will not decrease clip ammo");
|
||||
pm_weapon_use_ammo_hook.create(SELECT_VALUE(0x1403DD050, 0x140162B20), &pm_weapon_use_ammo_stub);
|
||||
|
||||
if (game::environment::is_sp()) return;
|
||||
|
||||
// Implement player ejection dvar
|
||||
|
@ -22,6 +22,8 @@ namespace dvars
|
||||
|
||||
game::dvar_t* pm_bouncing = nullptr;
|
||||
|
||||
game::dvar_t* player_sustainAmmo = nullptr;
|
||||
|
||||
game::dvar_t* r_fullbright = nullptr;
|
||||
|
||||
game::dvar_t* cg_legacyCrashHandling = nullptr;
|
||||
|
@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "game.hpp"
|
||||
#include "structs.hpp"
|
||||
|
||||
namespace dvars
|
||||
@ -22,6 +21,8 @@ namespace dvars
|
||||
|
||||
extern game::dvar_t* pm_bouncing;
|
||||
|
||||
extern game::dvar_t* player_sustainAmmo;
|
||||
|
||||
extern game::dvar_t* r_fullbright;
|
||||
|
||||
extern game::dvar_t* cg_legacyCrashHandling;
|
||||
|
@ -1331,6 +1331,29 @@ namespace game
|
||||
SV_LIVE_DROP_DISCONNECT = 0x1,
|
||||
};
|
||||
|
||||
struct trace_t
|
||||
{
|
||||
};
|
||||
|
||||
struct Bounds
|
||||
{
|
||||
float midPoint[3];
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user