From 00a944cf5bee7274eb91f620482281da5e36533d Mon Sep 17 00:00:00 2001 From: Diavolo Date: Fri, 5 Aug 2022 23:39:25 +0200 Subject: [PATCH 1/2] [Movement] Add rocket jump scale --- src/Components/Modules/Movement.cpp | 79 ++++++++++++++++------------- src/Components/Modules/Movement.hpp | 3 ++ src/Game/Functions.hpp | 2 +- 3 files changed, 49 insertions(+), 35 deletions(-) diff --git a/src/Components/Modules/Movement.cpp b/src/Components/Modules/Movement.cpp index fe782c4b..ec243bd6 100644 --- a/src/Components/Modules/Movement.cpp +++ b/src/Components/Modules/Movement.cpp @@ -7,6 +7,7 @@ namespace Components Dvar::Var Movement::CGNoclipScaler; Dvar::Var Movement::BGBouncesAllAngles; Dvar::Var Movement::BGRocketJump; + Dvar::Var Movement::BGRocketJumpScale; Dvar::Var Movement::BGPlayerEjection; Dvar::Var Movement::BGPlayerCollision; Game::dvar_t* Movement::BGBounces; @@ -172,15 +173,16 @@ namespace Components } Game::gentity_s* Movement::Weapon_RocketLauncher_Fire_Hk(Game::gentity_s* ent, unsigned int weaponIndex, - float spread, Game::weaponParms* wp, const float* gunVel, Game::lockonFireParms* lockParms, bool a7) + float spread, Game::weaponParms* wp, const float* gunVel, Game::lockonFireParms* lockParms, bool magicBullet) { - auto* result = Game::Weapon_RocketLauncher_Fire(ent, weaponIndex, spread, wp, gunVel, lockParms, a7); + auto* result = Game::Weapon_RocketLauncher_Fire(ent, weaponIndex, spread, wp, gunVel, lockParms, magicBullet); if (ent->client != nullptr && BGRocketJump.get()) { - ent->client->ps.velocity[0] += (0.0f - wp->forward[0]) * 64.0f; - ent->client->ps.velocity[1] += (0.0f - wp->forward[1]) * 64.0f; - ent->client->ps.velocity[2] += (0.0f - wp->forward[2]) * 64.0f; + const auto scale = Movement::BGRocketJumpScale.get(); + ent->client->ps.velocity[0] += (0.0f - wp->forward[0]) * scale; + ent->client->ps.velocity[1] += (0.0f - wp->forward[1]) * scale; + ent->client->ps.velocity[2] += (0.0f - wp->forward[2]) * scale; } return result; @@ -217,6 +219,42 @@ namespace Components return Movement::PlayerSpectateSpeedScale.get(); } + void Movement::RegisterMovementDvars() + { + Movement::PlayerDuckedSpeedScale = Game::Dvar_RegisterFloat("player_duckedSpeedScale", + 0.65f, 0.0f, 5.0f, Game::DVAR_CHEAT | Game::DVAR_CODINFO, + "The scale applied to the player speed when ducking"); + + Movement::PlayerProneSpeedScale = Game::Dvar_RegisterFloat("player_proneSpeedScale", + 0.15f, 0.0f, 5.0f, Game::DVAR_CHEAT | Game::DVAR_CODINFO, + "The scale applied to the player speed when crawling"); + + // 3arc naming convention + Movement::CGUfoScaler = Dvar::Register("cg_ufo_scaler", + 6.0f, 0.001f, 1000.0f, Game::DVAR_CHEAT | Game::DVAR_CODINFO, + "The speed at which ufo camera moves"); + + Movement::CGNoclipScaler = Dvar::Register("cg_noclip_scaler", + 3.0f, 0.001f, 1000.0f, Game::DVAR_CHEAT | Game::DVAR_CODINFO, + "The speed at which noclip camera moves"); + + Movement::BGBouncesAllAngles = Dvar::Register("bg_bouncesAllAngles", + false, Game::DVAR_CODINFO, "Force bounce from all angles"); + + Movement::BGRocketJump = Dvar::Register("bg_rocketJump", + false, Game::DVAR_CODINFO, "Enable CoD4 rocket jumps"); + + Movement::BGRocketJumpScale = Dvar::Register("bg_rocketJumpScale", + 64.0f, 1.0f, std::numeric_limits::max(), Game::DVAR_CODINFO, + "The scale applied to the pushback force of a rocket"); + + Movement::BGPlayerEjection = Dvar::Register("bg_playerEjection", + true, Game::DVAR_CODINFO, "Push intersecting players away from each other"); + + Movement::BGPlayerCollision = Dvar::Register("bg_playerCollision", + true, Game::DVAR_CODINFO, "Push intersecting players away from each other"); + } + Movement::Movement() { Scheduler::Once([] @@ -229,37 +267,8 @@ namespace Components nullptr }; - Movement::PlayerDuckedSpeedScale = Game::Dvar_RegisterFloat("player_duckedSpeedScale", - 0.65f, 0.0f, 5.0f, Game::DVAR_CHEAT | Game::DVAR_CODINFO, - "The scale applied to the player speed when ducking"); - - Movement::PlayerProneSpeedScale = Game::Dvar_RegisterFloat("player_proneSpeedScale", - 0.15f, 0.0f, 5.0f, Game::DVAR_CHEAT | Game::DVAR_CODINFO, - "The scale applied to the player speed when crawling"); - - // 3arc naming convention - Movement::CGUfoScaler = Dvar::Register("cg_ufo_scaler", - 6.0f, 0.001f, 1000.0f, Game::DVAR_CHEAT | Game::DVAR_CODINFO, - "The speed at which ufo camera moves"); - - Movement::CGNoclipScaler = Dvar::Register("cg_noclip_scaler", - 3.0f, 0.001f, 1000.0f, Game::DVAR_CHEAT | Game::DVAR_CODINFO, - "The speed at which noclip camera moves"); - Movement::BGBounces = Game::Dvar_RegisterEnum("bg_bounces", bg_bouncesValues, Movement::DISABLED, Game::DVAR_CODINFO, "Bounce glitch settings"); - - Movement::BGBouncesAllAngles = Dvar::Register("bg_bouncesAllAngles", - false, Game::DVAR_CODINFO, "Force bounce from all angles"); - - Movement::BGRocketJump = Dvar::Register("bg_rocketJump", - false, Game::DVAR_CODINFO, "Enable CoD4 rocket jumps"); - - Movement::BGPlayerEjection = Dvar::Register("bg_playerEjection", - true, Game::DVAR_CODINFO, "Push intersecting players away from each other"); - - Movement::BGPlayerCollision = Dvar::Register("bg_playerCollision", - true, Game::DVAR_CODINFO, "Push intersecting players away from each other"); }, Scheduler::Pipeline::MAIN); // Hook Dvar_RegisterFloat. Only thing that's changed is that the 0x80 flag is not used. @@ -286,5 +295,7 @@ namespace Components Utils::Hook(0x5D8153, Movement::StuckInClient_Hk, HOOK_CALL).install()->quick(); Utils::Hook(0x45A5BF, Movement::CM_TransformedCapsuleTrace_Hk, HOOK_CALL).install()->quick(); // SV_ClipMoveToEntity Utils::Hook(0x5A0CAD, Movement::CM_TransformedCapsuleTrace_Hk, HOOK_CALL).install()->quick(); // CG_ClipMoveToEntity + + Movement::RegisterMovementDvars(); } } diff --git a/src/Components/Modules/Movement.hpp b/src/Components/Modules/Movement.hpp index 72aa3347..ddcd7bf2 100644 --- a/src/Components/Modules/Movement.hpp +++ b/src/Components/Modules/Movement.hpp @@ -15,6 +15,7 @@ namespace Components static Dvar::Var CGNoclipScaler; static Dvar::Var BGBouncesAllAngles; static Dvar::Var BGRocketJump; + static Dvar::Var BGRocketJumpScale; static Dvar::Var BGPlayerEjection; static Dvar::Var BGPlayerCollision; // Can't use Var class inside assembly stubs @@ -40,5 +41,7 @@ namespace Components 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 Game::dvar_t* Dvar_RegisterSpectateSpeedScale(const char* dvarName, float value, float min, float max, unsigned __int16 flags, const char* description); + + static void RegisterMovementDvars(); }; } diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 658fe3af..b42db6ac 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -1092,7 +1092,7 @@ namespace Game typedef void(__cdecl * AimAssist_ApplyAutoMelee_t)(const AimInput* input, AimOutput* output); extern AimAssist_ApplyAutoMelee_t AimAssist_ApplyAutoMelee; - typedef gentity_s*(__cdecl * Weapon_RocketLauncher_Fire_t)(gentity_s* ent, unsigned int weaponIndex, float spread, weaponParms* wp, const float* gunVel, lockonFireParms* lockParms, bool a7); + typedef gentity_s*(__cdecl * Weapon_RocketLauncher_Fire_t)(gentity_s* ent, unsigned int weaponIndex, float spread, weaponParms* wp, const float* gunVel, lockonFireParms* lockParms, bool magicBullet); extern Weapon_RocketLauncher_Fire_t Weapon_RocketLauncher_Fire; typedef void(__cdecl * Jump_ClearState_t)(playerState_s* ps); From d7290e18f0a61d90e48a5b24e6f8c7c914559977 Mon Sep 17 00:00:00 2001 From: Diavolo Date: Sat, 6 Aug 2022 00:00:58 +0200 Subject: [PATCH 2/2] fix for controlled killstreaks --- src/Components/Modules/Movement.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Components/Modules/Movement.cpp b/src/Components/Modules/Movement.cpp index ec243bd6..6197387f 100644 --- a/src/Components/Modules/Movement.cpp +++ b/src/Components/Modules/Movement.cpp @@ -177,7 +177,8 @@ namespace Components { auto* result = Game::Weapon_RocketLauncher_Fire(ent, weaponIndex, spread, wp, gunVel, lockParms, magicBullet); - if (ent->client != nullptr && BGRocketJump.get()) + if (ent->client != nullptr && BGRocketJump.get() && + wp->weapDef->inventoryType != Game::WEAPINVENTORY_EXCLUSIVE) { const auto scale = Movement::BGRocketJumpScale.get(); ent->client->ps.velocity[0] += (0.0f - wp->forward[0]) * scale;