From 48f53fb221c500ab3d1a7ebf9994be8c5e0e5d64 Mon Sep 17 00:00:00 2001 From: Ethereal Date: Sun, 6 Jul 2025 16:46:25 +0200 Subject: [PATCH 1/3] Prepare for fork --- src/game/features/vehicle/RainbowPaint.cpp | 135 +++++++++++++++++++++ src/game/features/vehicle/VehicleJump.cpp | 43 +++++++ src/game/frontend/submenus/Vehicle.cpp | 9 ++ 3 files changed, 187 insertions(+) create mode 100644 src/game/features/vehicle/RainbowPaint.cpp create mode 100644 src/game/features/vehicle/VehicleJump.cpp diff --git a/src/game/features/vehicle/RainbowPaint.cpp b/src/game/features/vehicle/RainbowPaint.cpp new file mode 100644 index 00000000..9426c60b --- /dev/null +++ b/src/game/features/vehicle/RainbowPaint.cpp @@ -0,0 +1,135 @@ +#include "core/commands/BoolCommand.hpp" +#include "core/commands/IntCommand.hpp" +#include "core/commands/LoopedCommand.hpp" +#include "core/commands/ListCommand.hpp" +#include "game/gta/Natives.hpp" +#include "game/backend/Self.hpp" +#include + +namespace YimMenu::Features +{ + static float red = 255.f, green = 0.f, blue = 0.f; + + enum class RainbowPaintType + { + Spasm = 0, + Fade, + }; + + static std::vector> g_RainbowPaintTypeList = { + {0, "Spasm"}, + {1, "Fade"}, + }; + + struct RainbowPaintSettings + { + bool primary = true; + bool secondary = false; + int speed = 1; + RainbowPaintType type = RainbowPaintType::Fade; // Default option is fade + }; + + static RainbowPaintSettings g_RainbowPaintSettings; + + static BoolCommand _RainbowPaintPrimary{ + "rainbowpri", + "Vehicle RGB Paint Primary", + "Enable RGB rainbow paint on vehicle primary color", + g_RainbowPaintSettings.primary}; + + static BoolCommand _RainbowPaintSecondary{ + "rainbowsec", + "Vehicle RGB Paint Secondary", + "Enable RGB rainbow paint on vehicle secondary color", + g_RainbowPaintSettings.secondary}; + + static IntCommand _RainbowPaintSpeed{ + "rainbowspeed", + "Vehicle RGB Paint Speed", + "Speed of the rainbow paint cycling (1-10)", + g_RainbowPaintSettings.speed, + 1, + 10}; + + static ListCommand _RainbowPaintType{ + "rainbowtype", + "Vehicle Rainbow Paint Type", + "Type of rainbow paint effect", + g_RainbowPaintTypeList, + 1}; // Default index changed to 1 ("Fade") + + class VehicleRainbowPaint : public LoopedCommand + { + using LoopedCommand::LoopedCommand; + + void OnTick() override + { + UpdateRainbowPaint(); + } + + void UpdateRainbowPaint() + { + auto veh = Self::GetVehicle().GetHandle(); + if (!ENTITY::DOES_ENTITY_EXIST(veh)) + return; + + RainbowPaintType type = static_cast(_RainbowPaintType.GetState()); + + static std::chrono::system_clock::time_point last_rgb_run_time; + static std::chrono::milliseconds delay = std::chrono::milliseconds(0); + static bool ran = false; + + auto now = std::chrono::system_clock::now(); + + if (type == RainbowPaintType::Spasm && last_rgb_run_time + delay < now) + { + red = static_cast(rand() % 256); + green = static_cast(rand() % 256); + blue = static_cast(rand() % 256); + + delay = std::chrono::milliseconds(110 - (_RainbowPaintSpeed.GetState() * 10)); + last_rgb_run_time = now; + ran = true; + } + else if (type == RainbowPaintType::Fade) + { + if (ran) + { + red = 255.f; + green = 0.f; + blue = 0.f; + ran = false; + } + + int speed = _RainbowPaintSpeed.GetState(); + + if (red > 0.f && blue == 0.f) + { + green += speed; + red -= speed; + } + else if (green > 0.f && red == 0.f) + { + blue += speed; + green -= speed; + } + else if (blue > 0.f && green == 0.f) + { + red += speed; + blue -= speed; + } + + red = std::clamp(red, 0.f, 255.f); + green = std::clamp(green, 0.f, 255.f); + blue = std::clamp(blue, 0.f, 255.f); + } + + if (_RainbowPaintPrimary.GetState()) + VEHICLE::SET_VEHICLE_CUSTOM_PRIMARY_COLOUR(veh, static_cast(red), static_cast(green), static_cast(blue)); + if (_RainbowPaintSecondary.GetState()) + VEHICLE::SET_VEHICLE_CUSTOM_SECONDARY_COLOUR(veh, static_cast(red), static_cast(green), static_cast(blue)); + } + }; + + static VehicleRainbowPaint _VehicleRainbowPaint{"rainbowpaint", "Vehicle Rainbow Paint", "Cycles vehicle colors through a rainbow effect."}; +} diff --git a/src/game/features/vehicle/VehicleJump.cpp b/src/game/features/vehicle/VehicleJump.cpp new file mode 100644 index 00000000..e7aabf8e --- /dev/null +++ b/src/game/features/vehicle/VehicleJump.cpp @@ -0,0 +1,43 @@ +#include "core/commands/LoopedCommand.hpp" +#include "game/backend/Self.hpp" +#include "game/gta/Natives.hpp" +#include "types/pad/ControllerInputs.hpp" + +namespace YimMenu::Features +{ + class VehicleJump : public LoopedCommand + { + using LoopedCommand::LoopedCommand; + + virtual void OnTick() override + { + auto veh = Self::GetVehicle(); + if (!veh) + return; + + // Disable default handbrake action to capture input manually + PAD::DISABLE_CONTROL_ACTION(0, (int)ControllerInputs::INPUT_VEH_HANDBRAKE, false); + + if (PAD::IS_DISABLED_CONTROL_JUST_PRESSED(0, (int)ControllerInputs::INPUT_VEH_HANDBRAKE)) + { + ENTITY::APPLY_FORCE_TO_ENTITY( + veh.GetHandle(), + 1, // force type + 0.0f, + 0.0f, + 20.0f, // force vector (x,y,z) - strong upwards force + 0.0f, + 0.0f, + 0.0f, // offset vector + 0, + 0, + 1, + 1, + 0, + 1); // other params: apply force to center, etc. + } + } + }; + + static VehicleJump _VehicleJump{"vehjump", "Vehicle Jump", "Allows the vehicle to jump when the handbrake is pressed"}; +} diff --git a/src/game/frontend/submenus/Vehicle.cpp b/src/game/frontend/submenus/Vehicle.cpp index 63fda329..4548c17f 100644 --- a/src/game/frontend/submenus/Vehicle.cpp +++ b/src/game/frontend/submenus/Vehicle.cpp @@ -21,6 +21,15 @@ namespace YimMenu::Submenus globals->AddItem(std::make_shared("hornboost"_J)); globals->AddItem(std::make_shared("modifyboostbehavior"_J)); globals->AddItem(std::make_shared("modifyboostbehavior"_J, std::make_shared("boostbehavior"_J))); + // Rainbow Paint feature with options + globals->AddItem(std::make_shared("rainbowpaint"_J, "Rainbow Paint")); + globals->AddItem(std::make_shared("rainbowpaint"_J, std::make_shared("rainbowtype"_J, "Paint Type"))); + globals->AddItem(std::make_shared("rainbowpaint"_J, std::make_shared("rainbowpri"_J, "Primary"))); + globals->AddItem(std::make_shared("rainbowpaint"_J, std::make_shared("rainbowsec"_J, "Secondary"))); +// globals->AddItem(std::make_shared("rainbowpaint"_J, std::make_shared("rainbowspeed"_J, "Speed"))); Don't know how to change the speed once it's been changed in the UI, so no speed, for now. + + // Vehicle Jump feature + globals->AddItem(std::make_shared("vehjump"_J, "Vehicle Jump")); tools->AddItem(std::make_shared("enterlastvehicle"_J)); tools->AddItem(std::make_shared("repairvehicle"_J)); From 928ffcc0d6de589014bccfd3f98fccc297b3d3e8 Mon Sep 17 00:00:00 2001 From: Ethereal Date: Sun, 6 Jul 2025 16:58:59 +0200 Subject: [PATCH 2/3] make descriptions clearer --- src/game/features/vehicle/RainbowPaint.cpp | 20 ++++++++++---------- src/game/features/vehicle/VehicleJump.cpp | 14 +++++++------- src/game/frontend/submenus/Vehicle.cpp | 4 ++-- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/game/features/vehicle/RainbowPaint.cpp b/src/game/features/vehicle/RainbowPaint.cpp index 9426c60b..023003e4 100644 --- a/src/game/features/vehicle/RainbowPaint.cpp +++ b/src/game/features/vehicle/RainbowPaint.cpp @@ -8,7 +8,7 @@ namespace YimMenu::Features { - static float red = 255.f, green = 0.f, blue = 0.f; + static float red = 255.f, green = 0.f, blue = 0.f; // start from full red enum class RainbowPaintType { @@ -23,8 +23,8 @@ namespace YimMenu::Features struct RainbowPaintSettings { - bool primary = true; - bool secondary = false; + bool primary = true; // affect primary color + bool secondary = false; // do not affect secondary paint int speed = 1; RainbowPaintType type = RainbowPaintType::Fade; // Default option is fade }; @@ -56,7 +56,7 @@ namespace YimMenu::Features "Vehicle Rainbow Paint Type", "Type of rainbow paint effect", g_RainbowPaintTypeList, - 1}; // Default index changed to 1 ("Fade") + 1}; // Uses fade by default class VehicleRainbowPaint : public LoopedCommand { @@ -64,14 +64,14 @@ namespace YimMenu::Features void OnTick() override { - UpdateRainbowPaint(); + UpdateRainbowPaint(); // activates function found below } void UpdateRainbowPaint() { auto veh = Self::GetVehicle().GetHandle(); - if (!ENTITY::DOES_ENTITY_EXIST(veh)) - return; + if (!ENTITY::DOES_ENTITY_EXIST(veh)) //if player isn't sitting in a vehicle + return; // do nothing RainbowPaintType type = static_cast(_RainbowPaintType.GetState()); @@ -87,11 +87,11 @@ namespace YimMenu::Features green = static_cast(rand() % 256); blue = static_cast(rand() % 256); - delay = std::chrono::milliseconds(110 - (_RainbowPaintSpeed.GetState() * 10)); + delay = std::chrono::milliseconds(110 - (_RainbowPaintSpeed.GetState() * 10)); // the paint spazzes out last_rgb_run_time = now; ran = true; } - else if (type == RainbowPaintType::Fade) + else if (type == RainbowPaintType::Fade) // a great fade { if (ran) { @@ -125,7 +125,7 @@ namespace YimMenu::Features } if (_RainbowPaintPrimary.GetState()) - VEHICLE::SET_VEHICLE_CUSTOM_PRIMARY_COLOUR(veh, static_cast(red), static_cast(green), static_cast(blue)); + VEHICLE::SET_VEHICLE_CUSTOM_PRIMARY_COLOUR(veh, static_cast(red), static_cast(green), static_cast(blue)); // checks state of settings toggled if (_RainbowPaintSecondary.GetState()) VEHICLE::SET_VEHICLE_CUSTOM_SECONDARY_COLOUR(veh, static_cast(red), static_cast(green), static_cast(blue)); } diff --git a/src/game/features/vehicle/VehicleJump.cpp b/src/game/features/vehicle/VehicleJump.cpp index e7aabf8e..8983a2c9 100644 --- a/src/game/features/vehicle/VehicleJump.cpp +++ b/src/game/features/vehicle/VehicleJump.cpp @@ -2,7 +2,7 @@ #include "game/backend/Self.hpp" #include "game/gta/Natives.hpp" #include "types/pad/ControllerInputs.hpp" - +// This can literally be recycled almost word namespace YimMenu::Features { class VehicleJump : public LoopedCommand @@ -11,8 +11,8 @@ namespace YimMenu::Features virtual void OnTick() override { - auto veh = Self::GetVehicle(); - if (!veh) + auto veh = Self::GetVehicle(); // Check if player is in the vehicle + if (!veh) // If not, then don't do anything. return; // Disable default handbrake action to capture input manually @@ -25,19 +25,19 @@ namespace YimMenu::Features 1, // force type 0.0f, 0.0f, - 20.0f, // force vector (x,y,z) - strong upwards force + 20.0f, // X Y Z - modifies the Z force (responsible for up or down) - strong upwards force + 0.0f, 0.0f, 0.0f, - 0.0f, // offset vector 0, 0, 1, 1, 0, - 1); // other params: apply force to center, etc. + 1); } } }; - static VehicleJump _VehicleJump{"vehjump", "Vehicle Jump", "Allows the vehicle to jump when the handbrake is pressed"}; + static VehicleJump _VehicleJump{"vehjump", "Vehicle Jump", "Allows the vehicle to jump when the handbrake is pressed"}; // this is literally almost a word-for-word recycle of the version found in the legacy version of YimMenu } diff --git a/src/game/frontend/submenus/Vehicle.cpp b/src/game/frontend/submenus/Vehicle.cpp index 4548c17f..0f0fbdbb 100644 --- a/src/game/frontend/submenus/Vehicle.cpp +++ b/src/game/frontend/submenus/Vehicle.cpp @@ -21,14 +21,14 @@ namespace YimMenu::Submenus globals->AddItem(std::make_shared("hornboost"_J)); globals->AddItem(std::make_shared("modifyboostbehavior"_J)); globals->AddItem(std::make_shared("modifyboostbehavior"_J, std::make_shared("boostbehavior"_J))); - // Rainbow Paint feature with options + // Legacy feature from YimMenu globals->AddItem(std::make_shared("rainbowpaint"_J, "Rainbow Paint")); globals->AddItem(std::make_shared("rainbowpaint"_J, std::make_shared("rainbowtype"_J, "Paint Type"))); globals->AddItem(std::make_shared("rainbowpaint"_J, std::make_shared("rainbowpri"_J, "Primary"))); globals->AddItem(std::make_shared("rainbowpaint"_J, std::make_shared("rainbowsec"_J, "Secondary"))); // globals->AddItem(std::make_shared("rainbowpaint"_J, std::make_shared("rainbowspeed"_J, "Speed"))); Don't know how to change the speed once it's been changed in the UI, so no speed, for now. - // Vehicle Jump feature + // Add vehicle jump feature from legacy YimMenu globals->AddItem(std::make_shared("vehjump"_J, "Vehicle Jump")); tools->AddItem(std::make_shared("enterlastvehicle"_J)); From b29015121c95384b84b5e209534b8ff144b30b8e Mon Sep 17 00:00:00 2001 From: Ethereal Date: Sun, 13 Jul 2025 14:25:51 +0200 Subject: [PATCH 3/3] Move vehicle settings to Misc + fix slider --- src/game/features/vehicle/RainbowPaint.cpp | 28 +++++++++------------- src/game/frontend/submenus/Vehicle.cpp | 20 +++++++++------- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/src/game/features/vehicle/RainbowPaint.cpp b/src/game/features/vehicle/RainbowPaint.cpp index 023003e4..287b7f82 100644 --- a/src/game/features/vehicle/RainbowPaint.cpp +++ b/src/game/features/vehicle/RainbowPaint.cpp @@ -8,7 +8,7 @@ namespace YimMenu::Features { - static float red = 255.f, green = 0.f, blue = 0.f; // start from full red + static float red = 255.f, green = 0.f, blue = 0.f; enum class RainbowPaintType { @@ -23,8 +23,8 @@ namespace YimMenu::Features struct RainbowPaintSettings { - bool primary = true; // affect primary color - bool secondary = false; // do not affect secondary paint + bool primary = true; + bool secondary = false; int speed = 1; RainbowPaintType type = RainbowPaintType::Fade; // Default option is fade }; @@ -43,20 +43,14 @@ namespace YimMenu::Features "Enable RGB rainbow paint on vehicle secondary color", g_RainbowPaintSettings.secondary}; - static IntCommand _RainbowPaintSpeed{ - "rainbowspeed", - "Vehicle RGB Paint Speed", - "Speed of the rainbow paint cycling (1-10)", - g_RainbowPaintSettings.speed, - 1, - 10}; + static IntCommand _RainbowPaintSpeed{"rainbowspeed", "Vehicle RGB Paint Speed", "Speed of the rainbow paint cycling (1-10)", 1, 10, 1}; // change the setting needed to fix into a one-liner to be more readable static ListCommand _RainbowPaintType{ "rainbowtype", "Vehicle Rainbow Paint Type", "Type of rainbow paint effect", g_RainbowPaintTypeList, - 1}; // Uses fade by default + 1}; // Default index changed to 1 ("Fade") class VehicleRainbowPaint : public LoopedCommand { @@ -64,14 +58,14 @@ namespace YimMenu::Features void OnTick() override { - UpdateRainbowPaint(); // activates function found below + UpdateRainbowPaint(); } void UpdateRainbowPaint() { auto veh = Self::GetVehicle().GetHandle(); - if (!ENTITY::DOES_ENTITY_EXIST(veh)) //if player isn't sitting in a vehicle - return; // do nothing + if (!ENTITY::DOES_ENTITY_EXIST(veh)) + return; RainbowPaintType type = static_cast(_RainbowPaintType.GetState()); @@ -87,11 +81,11 @@ namespace YimMenu::Features green = static_cast(rand() % 256); blue = static_cast(rand() % 256); - delay = std::chrono::milliseconds(110 - (_RainbowPaintSpeed.GetState() * 10)); // the paint spazzes out + delay = std::chrono::milliseconds(110 - (_RainbowPaintSpeed.GetState() * 10)); last_rgb_run_time = now; ran = true; } - else if (type == RainbowPaintType::Fade) // a great fade + else if (type == RainbowPaintType::Fade) { if (ran) { @@ -125,7 +119,7 @@ namespace YimMenu::Features } if (_RainbowPaintPrimary.GetState()) - VEHICLE::SET_VEHICLE_CUSTOM_PRIMARY_COLOUR(veh, static_cast(red), static_cast(green), static_cast(blue)); // checks state of settings toggled + VEHICLE::SET_VEHICLE_CUSTOM_PRIMARY_COLOUR(veh, static_cast(red), static_cast(green), static_cast(blue)); if (_RainbowPaintSecondary.GetState()) VEHICLE::SET_VEHICLE_CUSTOM_SECONDARY_COLOUR(veh, static_cast(red), static_cast(green), static_cast(blue)); } diff --git a/src/game/frontend/submenus/Vehicle.cpp b/src/game/frontend/submenus/Vehicle.cpp index 0f0fbdbb..b67bb552 100644 --- a/src/game/frontend/submenus/Vehicle.cpp +++ b/src/game/frontend/submenus/Vehicle.cpp @@ -21,15 +21,6 @@ namespace YimMenu::Submenus globals->AddItem(std::make_shared("hornboost"_J)); globals->AddItem(std::make_shared("modifyboostbehavior"_J)); globals->AddItem(std::make_shared("modifyboostbehavior"_J, std::make_shared("boostbehavior"_J))); - // Legacy feature from YimMenu - globals->AddItem(std::make_shared("rainbowpaint"_J, "Rainbow Paint")); - globals->AddItem(std::make_shared("rainbowpaint"_J, std::make_shared("rainbowtype"_J, "Paint Type"))); - globals->AddItem(std::make_shared("rainbowpaint"_J, std::make_shared("rainbowpri"_J, "Primary"))); - globals->AddItem(std::make_shared("rainbowpaint"_J, std::make_shared("rainbowsec"_J, "Secondary"))); -// globals->AddItem(std::make_shared("rainbowpaint"_J, std::make_shared("rainbowspeed"_J, "Speed"))); Don't know how to change the speed once it's been changed in the UI, so no speed, for now. - - // Add vehicle jump feature from legacy YimMenu - globals->AddItem(std::make_shared("vehjump"_J, "Vehicle Jump")); tools->AddItem(std::make_shared("enterlastvehicle"_J)); tools->AddItem(std::make_shared("repairvehicle"_J)); @@ -41,6 +32,17 @@ namespace YimMenu::Submenus misc->AddItem(std::make_shared("speedometer"_J)); misc->AddItem(std::make_shared("seatbelt"_J)); + + // Rainbow Paint feature with options + misc->AddItem(std::make_shared("rainbowpaint"_J, "Rainbow Paint")); + misc->AddItem(std::make_shared("rainbowpaint"_J, std::make_shared("rainbowtype"_J, "Paint Type"))); + misc->AddItem(std::make_shared("rainbowpaint"_J, std::make_shared("rainbowpri"_J, "Primary"))); // do we even need this? + misc->AddItem(std::make_shared("rainbowpaint"_J, std::make_shared("rainbowsec"_J, "Secondary"))); + misc->AddItem(std::make_shared("rainbowpaint"_J, std::make_shared("rainbowspeed"_J, "Speed"))); + + // Vehicle Jump feature + misc->AddItem(std::make_shared("vehjump"_J, "Vehicle Jump")); + misc->AddItem(std::make_shared("lowervehiclestance"_J, "Lower Stance")); misc->AddItem(std::make_shared("allowhatsinvehicles"_J)); misc->AddItem(std::make_shared("lsccustomsbypass"_J));