From ddcbcd2bb3df10beffa59f9fb0873fba689a67b2 Mon Sep 17 00:00:00 2001 From: Skull Merlin <86374920+skkuull@users.noreply.github.com> Date: Thu, 5 May 2022 21:59:50 +0300 Subject: [PATCH] g_speed implementation thx to fed for his help --- src/client/component/gameplay.cpp | 17 +++++++++++++++++ src/client/game/dvars.cpp | 2 ++ src/client/game/dvars.hpp | 2 ++ 3 files changed, 21 insertions(+) diff --git a/src/client/component/gameplay.cpp b/src/client/component/gameplay.cpp index 31635184..040fa30e 100644 --- a/src/client/component/gameplay.cpp +++ b/src/client/component/gameplay.cpp @@ -88,6 +88,18 @@ namespace gameplay a.jmp(0x1401EAF9D); }); + const auto g_speed_stub = utils::hook::assemble([](utils::hook::assembler& a) + { + a.mov(rax, qword_ptr(reinterpret_cast(&dvars::g_speed))); + a.mov(eax, dword_ptr(rax, 0x10)); + + // original code + a.mov(dword_ptr(r14, 0x36), ax); + a.movzx(eax, word_ptr(r14, 0x3A)); + + a.jmp(0x140323DBC); + }); + const auto client_end_frame_stub = utils::hook::assemble([](utils::hook::assembler& a) { a.push(rax); @@ -130,6 +142,11 @@ namespace gameplay "Flag whether player ejection is on or off"); utils::hook::call(0x140323333, stuck_in_client_stub); + utils::hook::nop(0x140323DAD, 15); + utils::hook::jump(0x140323DAD, g_speed_stub, true); + dvars::g_speed = dvars::register_int("g_speed", 190, std::numeric_limits::min(), std::numeric_limits::max(), + game::DVAR_FLAG_REPLICATED, "changes the speed of the player"); + // Implement player collision dvar dvars::g_playerCollision = dvars::register_bool("g_playerCollision", true, game::DVAR_FLAG_REPLICATED, "Flag whether player collision is on or off"); diff --git a/src/client/game/dvars.cpp b/src/client/game/dvars.cpp index f46d7d5b..9587788a 100644 --- a/src/client/game/dvars.cpp +++ b/src/client/game/dvars.cpp @@ -30,6 +30,8 @@ namespace dvars game::dvar_t* r_fullbright; game::dvar_t* r_chams; + game::dvar_t* g_speed = nullptr; + game::dvar_t* g_gravity = nullptr; game::dvar_t* pm_bouncing = nullptr; diff --git a/src/client/game/dvars.hpp b/src/client/game/dvars.hpp index 24c4afb5..2d3f85be 100644 --- a/src/client/game/dvars.hpp +++ b/src/client/game/dvars.hpp @@ -33,6 +33,8 @@ namespace dvars extern game::dvar_t* r_fullbright; extern game::dvar_t* r_chams; + extern game::dvar_t* g_speed; + extern game::dvar_t* g_gravity; extern game::dvar_t* pm_bouncing;