diff --git a/src/game/features/vehicle/RainbowPaint.cpp b/src/game/features/vehicle/RainbowPaint.cpp new file mode 100644 index 00000000..287b7f82 --- /dev/null +++ b/src/game/features/vehicle/RainbowPaint.cpp @@ -0,0 +1,129 @@ +#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)", 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}; // 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..8983a2c9 --- /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" +// This can literally be recycled almost word +namespace YimMenu::Features +{ + class VehicleJump : public LoopedCommand + { + using LoopedCommand::LoopedCommand; + + virtual void OnTick() override + { + 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 + 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, // X Y Z - modifies the Z force (responsible for up or down) - strong upwards force + 0.0f, + 0.0f, + 0.0f, + 0, + 0, + 1, + 1, + 0, + 1); + } + } + }; + + 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 63fda329..b67bb552 100644 --- a/src/game/frontend/submenus/Vehicle.cpp +++ b/src/game/frontend/submenus/Vehicle.cpp @@ -32,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));