From 37e79f7c3acce22bc4f8e5caca4ef4a9f1f36dd0 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Thu, 11 Nov 2021 13:38:51 +0000 Subject: [PATCH] Hook dvar register func --- src/Components/Modules/Dvar.cpp | 3 --- src/Components/Modules/Movement.cpp | 18 ++++++++++++++---- src/Components/Modules/Movement.hpp | 2 ++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/Components/Modules/Dvar.cpp b/src/Components/Modules/Dvar.cpp index 0d7f8f9f..d0892d2e 100644 --- a/src/Components/Modules/Dvar.cpp +++ b/src/Components/Modules/Dvar.cpp @@ -299,9 +299,6 @@ namespace Components // Uncheat ui_debugMode Utils::Hook::Xor(0x6312DE, Game::dvar_flag::DVAR_FLAG_CHEAT); - // Remove unknown flag from player_lastStandCrawlSpeedScale (prevent unknown behaviour) - Utils::Hook::Xor(0x448B42, Game::dvar_flag::DVAR_FLAG_UNKNOWN80); - // Hook dvar 'name' registration Utils::Hook(0x40531C, Dvar::RegisterName, HOOK_CALL).install()->quick(); diff --git a/src/Components/Modules/Movement.cpp b/src/Components/Modules/Movement.cpp index 10a1377a..3c04b232 100644 --- a/src/Components/Modules/Movement.cpp +++ b/src/Components/Modules/Movement.cpp @@ -124,6 +124,14 @@ namespace Components } } + Game::dvar_t* Movement::Dvar_RegisterLastStandSpeedScale(const char* name, float defaultVal, float min, float max, int, const char*) + { + Movement::PlayerLastStandCrawlSpeedScale = Dvar::Register(name, defaultVal, + min, max, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, "TEST DESC"); + + return Movement::PlayerLastStandCrawlSpeedScale.get(); + } + Movement::Movement() { Dvar::OnInit([] @@ -132,17 +140,19 @@ namespace Components 0.65f, 0.0f, 5.0f, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, "The scale applied to the player speed when ducking"); - Movement::PlayerLastStandCrawlSpeedScale = Dvar::Register("player_lastStandCrawlSpeedScale", - 0.2f, 0.0f, 5.0f, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, - "The scale applied to the player speed when crawling in last stand"); - Movement::PlayerProneSpeedScale = Dvar::Register("player_proneSpeedScale", 0.15f, 0.0f, 5.0f, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, "The scale applied to the player speed when crawling"); }); + // Hook PM_CmdScaleForStance in PM_CmdScale_Walk Utils::Hook(0x572F34, Movement::PMCmdScaleForStanceStub, HOOK_CALL).install()->quick(); + + //Hook PM_CmdScaleForStance in PM_GetMaxSpeed Utils::Hook(0x57395F, Movement::PMCmdScaleForStanceStub, HOOK_CALL).install()->quick(); + + // Hook Dvar_RegisterFloat. Only thing that's changed is that the 0x80 flag is not used. + Utils::Hook(0x448B66, Movement::Dvar_RegisterLastStandSpeedScale, HOOK_CALL).install()->quick(); } Movement::~Movement() diff --git a/src/Components/Modules/Movement.hpp b/src/Components/Modules/Movement.hpp index 4c8104a2..07ad6894 100644 --- a/src/Components/Modules/Movement.hpp +++ b/src/Components/Modules/Movement.hpp @@ -16,5 +16,7 @@ namespace Components static int PMGetEffectiveStance(Game::playerState_s* ps); static float PMCmdScaleForStance(Game::pmove_s* move); static void PMCmdScaleForStanceStub(); + + static Game::dvar_t* Dvar_RegisterLastStandSpeedScale(const char* name, float defaultVal, float min, float max, int flags, const char* desc); }; }