From 2c59d8a6466856f419a41a8d349e5eb281b0e1c5 Mon Sep 17 00:00:00 2001 From: Skull Merlin <86374920+skkuull@users.noreply.github.com> Date: Mon, 9 May 2022 02:04:45 +0300 Subject: [PATCH] elevators but not yet --- src/client/component/gameplay.cpp | 50 ++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/src/client/component/gameplay.cpp b/src/client/component/gameplay.cpp index 9a7c4f83..f506ee13 100644 --- a/src/client/component/gameplay.cpp +++ b/src/client/component/gameplay.cpp @@ -117,6 +117,46 @@ namespace gameplay a.jmp(0x140322F82); }); + + void pm_player_trace_stub(game::pmove_t* pm, game::trace_t* trace, const float* f3, + const float* f4, const game::Bounds* bounds, int a6, int a7) + { + pm_player_trace_hook.invoke(pm, trace, f3, f4, bounds, a6, a7); + + // By setting startsolid to false we allow the player to clip through solid objects above their head + if (dvars::g_enableElevators->current.enabled) + { + trace->startsolid = false; + } + } + + void pm_trace_stub(utils::hook::assembler& a) + { + const auto stand = a.newLabel(); + const auto allsolid = a.newLabel(); + + a.call(qword_ptr(r10, r15)); // Game code + + a.push(rax); + + a.mov(rax, qword_ptr(reinterpret_cast(&dvars::g_enableElevators))); + a.mov(al, byte_ptr(rax, 0x10)); + a.cmp(al, 1); + + a.pop(rax); + + a.jz(stand); // Always stand up + + a.cmp(byte_ptr(rsp, 0x89), 0); // Game code trace[0].allsolid == false + a.jnz(allsolid); + + a.bind(stand); + a.and_(dword_ptr(rbx, 0x54), 0xFFFFFFFD); + a.jmp(0x1401E1CDF); + + a.bind(allsolid); + a.jmp(0x1401E1CE1); + } } class component final : public component_interface @@ -133,6 +173,15 @@ namespace gameplay return; } +#ifdef DEBUG + // Influence PM_JitterPoint code flow so the trace->startsolid checks are 'ignored' + pm_player_trace_hook.create(0x1401E8BE0, &pm_player_trace_stub); + + // If g_enableElevators is 1 the 'ducked' flag will always be removed from the player state + utils::hook::jump(0x1401E1CD1, utils::hook::assemble(pm_trace_stub), true); + dvars::g_enableElevators = dvars::register_bool("g_enableElevators", false, game::DvarFlags::DVAR_FLAG_NONE, ""); +#endif + auto* timescale = dvars::register_float("timescale", 1.0f, 0.1f, 50.0f, game::DVAR_FLAG_REPLICATED, "Changes Timescale of the game"); utils::hook::inject(0x1400D89A4, ×cale->current.value); utils::hook::inject(0x1400DA9D1, ×cale->current.value); @@ -144,7 +193,6 @@ namespace gameplay utils::hook::inject(0x1400DBE72, ×cale->current.value); utils::hook::inject(0x1400DBE9C, ×cale->current.value); - utils::hook::call(0x1401E8830, jump_apply_slowdown_stub); jump_slowDownEnable = dvars::register_bool("jump_slowDownEnable", true, game::DVAR_FLAG_REPLICATED, "Slow player movement after jumping");