mirror of
https://github.com/XLabsProject/s1x-client.git
synced 2023-08-02 15:02:12 +02:00
Add g_gravity dvar
This commit is contained in:
parent
6d18534a6d
commit
0f22c5b77d
@ -11,12 +11,14 @@ namespace gameplay
|
||||
{
|
||||
utils::hook::detour pm_weapon_use_ammo_hook;
|
||||
|
||||
void stuck_in_client_stub(void* entity)
|
||||
int stuck_in_client_stub(void* entity)
|
||||
{
|
||||
if (dvars::g_playerEjection->current.enabled)
|
||||
{
|
||||
reinterpret_cast<void(*)(void*)>(0x1402DA310)(entity); // StuckInClient
|
||||
return utils::hook::invoke<int>(0x1402DA310, entity); // StuckInClient
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cm_transformed_capsule_trace_stub(game::trace_t* results, const float* start, const float* end,
|
||||
@ -24,11 +26,8 @@ namespace gameplay
|
||||
{
|
||||
if (dvars::g_playerCollision->current.enabled)
|
||||
{
|
||||
reinterpret_cast<void(*)
|
||||
(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
|
||||
utils::hook::invoke<void>(0x1403AB1C0,
|
||||
results, start, end, bounds, capsule, contents, origin, angles); // CM_TransformedCapsuleTrace
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,6 +63,23 @@ namespace gameplay
|
||||
pm_weapon_use_ammo_hook.invoke<void>(ps, weapon, is_alternate, amount, hand);
|
||||
}
|
||||
}
|
||||
|
||||
const auto client_end_frame_stub = utils::hook::assemble([](utils::hook::assembler& a)
|
||||
{
|
||||
a.push(rax);
|
||||
|
||||
a.mov(rax, qword_ptr(reinterpret_cast<int64_t>(&dvars::g_gravity)));
|
||||
a.mov(eax, dword_ptr(rax, 0x10));
|
||||
a.mov(word_ptr(rbx, 0x36), ax);
|
||||
|
||||
a.pop(rax);
|
||||
|
||||
// Game code hook skipped
|
||||
a.mov(eax, dword_ptr(rbx, 0x5084));
|
||||
a.mov(rdi, rcx);
|
||||
|
||||
a.jmp(0x1402D5A6A);
|
||||
});
|
||||
}
|
||||
|
||||
class component final : public component_interface
|
||||
@ -95,6 +111,12 @@ namespace gameplay
|
||||
|
||||
// Change jump_slowdownEnable dvar flags to just "replicated"
|
||||
utils::hook::set<uint8_t>(0x140135992, game::DVAR_FLAG_REPLICATED);
|
||||
|
||||
// Choosing the following min/max because the game would truncate larger values
|
||||
dvars::g_gravity = game::Dvar_RegisterInt("g_gravity", 800, std::numeric_limits<short>::min(),
|
||||
std::numeric_limits<short>::max(), game::DVAR_FLAG_REPLICATED, "Gravity in inches per second per second");
|
||||
utils::hook::jump(0x1402D5A5D, client_end_frame_stub, true);
|
||||
utils::hook::nop(0x1402D5A69, 1); // Nop skipped opcode
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ namespace dvars
|
||||
game::dvar_t* g_playerCollision = nullptr;
|
||||
|
||||
game::dvar_t* pm_bouncing = nullptr;
|
||||
game::dvar_t* g_gravity = nullptr;
|
||||
|
||||
game::dvar_t* player_sustainAmmo = nullptr;
|
||||
|
||||
|
@ -20,6 +20,7 @@ namespace dvars
|
||||
extern game::dvar_t* g_playerEjection;
|
||||
|
||||
extern game::dvar_t* pm_bouncing;
|
||||
extern game::dvar_t* g_gravity;
|
||||
|
||||
extern game::dvar_t* player_sustainAmmo;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user