diff --git a/src/Components/Modules/PlayerMovement.cpp b/src/Components/Modules/PlayerMovement.cpp index f1173c51..aef7cff2 100644 --- a/src/Components/Modules/PlayerMovement.cpp +++ b/src/Components/Modules/PlayerMovement.cpp @@ -15,6 +15,8 @@ namespace Components const Game::dvar_t* PlayerMovement::PlayerSpectateSpeedScale; const Game::dvar_t* PlayerMovement::BGBounces; const Game::dvar_t* PlayerMovement::BGBouncesAllAngles; + const Game::dvar_t* PlayerMovement::BGBunnyHopSlowdown; + const Game::dvar_t* PlayerMovement::BGBunnyHopAuto; const Game::dvar_t* PlayerMovement::PlayerDuckedSpeedScale; const Game::dvar_t* PlayerMovement::PlayerProneSpeedScale; @@ -217,6 +219,38 @@ namespace Components } } + void PlayerMovement::PM_CrashLand_Stub(const float* v, float scale, const float* result) + { + if (!BGBunnyHopSlowdown->current.enabled) + { + Utils::Hook::Call(0x4C12B0)(v, scale, result); + } + } + + __declspec(naked) void PlayerMovement::Jump_Check_Stub() + { + using namespace Game; + + __asm + { + push eax + mov eax, BGBunnyHopAuto + cmp byte ptr [eax + 0x10], 1 + pop eax + + je autoHop + + // Game's code + test dword ptr [ebp + 0x30], CMD_BUTTON_UP + push 0x4E9890 + ret + + autoHop: + push 0x4E989F + ret + } + } + void PlayerMovement::GScr_IsSprinting(const Game::scr_entref_t entref) { const auto* client = Game::GetEntity(entref)->client; @@ -257,6 +291,12 @@ namespace Components 3.0f, 0.001f, 1000.0f, Game::DVAR_CHEAT | Game::DVAR_CODINFO, "The speed at which noclip camera moves"); + BGBunnyHopSlowdown = Game::Dvar_RegisterBool("bg_bunnyHopSlowdown", + false, Game::DVAR_CODINFO, "Toggle landing slowdown"); + + BGBunnyHopAuto = Game::Dvar_RegisterBool("bg_bunnyHopAuto", + false, Game::DVAR_CODINFO, "Constantly jump when holding space"); + BGRocketJump = Dvar::Register("bg_rocketJump", false, Game::DVAR_CODINFO, "Enable CoD4 rocket jumps"); @@ -330,6 +370,9 @@ namespace Components Utils::Hook(0x573F39, PM_PlayerTraceStub, HOOK_CALL).install()->quick(); Utils::Hook(0x573E93, PM_PlayerTraceStub, HOOK_CALL).install()->quick(); + Utils::Hook(0x570020, PM_CrashLand_Stub, HOOK_CALL).install()->quick(); // Vec3Scale + Utils::Hook(0x4E9889, Jump_Check_Stub, HOOK_JUMP).install()->quick(); + GSC::Script::AddMethod("IsSprinting", GScr_IsSprinting); RegisterMovementDvars(); diff --git a/src/Components/Modules/PlayerMovement.hpp b/src/Components/Modules/PlayerMovement.hpp index c4dc8fe6..64f2328e 100644 --- a/src/Components/Modules/PlayerMovement.hpp +++ b/src/Components/Modules/PlayerMovement.hpp @@ -23,6 +23,8 @@ namespace Components static const Game::dvar_t* PlayerSpectateSpeedScale; static const Game::dvar_t* BGBounces; static const Game::dvar_t* BGBouncesAllAngles; + static const Game::dvar_t* BGBunnyHopSlowdown; + static const Game::dvar_t* BGBunnyHopAuto; static const Game::dvar_t* PlayerDuckedSpeedScale; static const Game::dvar_t* PlayerProneSpeedScale; @@ -45,6 +47,9 @@ namespace Components static int StuckInClient_Hk(Game::gentity_s* self); static void CM_TransformedCapsuleTrace_Hk(Game::trace_t* results, const float* start, const float* end, const Game::Bounds* bounds, const Game::Bounds* capsule, int contents, const float* origin, const float* angles); + static void PM_CrashLand_Stub(const float* v, float scale, const float* result); + static void Jump_Check_Stub(); + static void GScr_IsSprinting(Game::scr_entref_t entref); static const Game::dvar_t* Dvar_RegisterSpectateSpeedScale(const char* dvarName, float value, float min, float max, unsigned __int16 flags, const char* description);