diff --git a/src/Components/Modules/Movement.cpp b/src/Components/Modules/Movement.cpp index fe782c4b..6197387f 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,17 @@ 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()) + if (ent->client != nullptr && BGRocketJump.get() && + wp->weapDef->inventoryType != Game::WEAPINVENTORY_EXCLUSIVE) { - 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 +220,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 +268,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 +296,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);