Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 135 additions & 0 deletions src/game/features/vehicle/RainbowPaint.cpp
Original file line number Diff line number Diff line change
@@ -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 <chrono>

namespace YimMenu::Features
{
static float red = 255.f, green = 0.f, blue = 0.f; // start from full red

enum class RainbowPaintType
{
Spasm = 0,
Fade,
};

static std::vector<std::pair<int, const char*>> g_RainbowPaintTypeList = {
{0, "Spasm"},
{1, "Fade"},
};

struct RainbowPaintSettings
{
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
};

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}; // Uses fade by default

class VehicleRainbowPaint : public LoopedCommand
{
using LoopedCommand::LoopedCommand;

void OnTick() override
{
UpdateRainbowPaint(); // activates function found below
}

void UpdateRainbowPaint()
{
auto veh = Self::GetVehicle().GetHandle();
if (!ENTITY::DOES_ENTITY_EXIST(veh)) //if player isn't sitting in a vehicle
return; // do nothing

RainbowPaintType type = static_cast<RainbowPaintType>(_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<float>(rand() % 256);
green = static_cast<float>(rand() % 256);
blue = static_cast<float>(rand() % 256);

delay = std::chrono::milliseconds(110 - (_RainbowPaintSpeed.GetState() * 10)); // the paint spazzes out
last_rgb_run_time = now;
ran = true;
}
else if (type == RainbowPaintType::Fade) // a great 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<int>(red), static_cast<int>(green), static_cast<int>(blue)); // checks state of settings toggled
if (_RainbowPaintSecondary.GetState())
VEHICLE::SET_VEHICLE_CUSTOM_SECONDARY_COLOUR(veh, static_cast<int>(red), static_cast<int>(green), static_cast<int>(blue));
}
};

static VehicleRainbowPaint _VehicleRainbowPaint{"rainbowpaint", "Vehicle Rainbow Paint", "Cycles vehicle colors through a rainbow effect."};
}
43 changes: 43 additions & 0 deletions src/game/features/vehicle/VehicleJump.cpp
Original file line number Diff line number Diff line change
@@ -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
}
9 changes: 9 additions & 0 deletions src/game/frontend/submenus/Vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ namespace YimMenu::Submenus
globals->AddItem(std::make_shared<BoolCommandItem>("hornboost"_J));
globals->AddItem(std::make_shared<BoolCommandItem>("modifyboostbehavior"_J));
globals->AddItem(std::make_shared<ConditionalItem>("modifyboostbehavior"_J, std::make_shared<ListCommandItem>("boostbehavior"_J)));
// Legacy feature from YimMenu
globals->AddItem(std::make_shared<BoolCommandItem>("rainbowpaint"_J, "Rainbow Paint"));
globals->AddItem(std::make_shared<ConditionalItem>("rainbowpaint"_J, std::make_shared<ListCommandItem>("rainbowtype"_J, "Paint Type")));
globals->AddItem(std::make_shared<ConditionalItem>("rainbowpaint"_J, std::make_shared<BoolCommandItem>("rainbowpri"_J, "Primary")));
globals->AddItem(std::make_shared<ConditionalItem>("rainbowpaint"_J, std::make_shared<BoolCommandItem>("rainbowsec"_J, "Secondary")));
// globals->AddItem(std::make_shared<ConditionalItem>("rainbowpaint"_J, std::make_shared<IntCommandItem>("rainbowspeed"_J, "Speed"))); Don't know how to change the speed once it's been changed in the UI, so no speed, for now.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The speed control should work, I can't see anything wrong with the code right now

@Ethereal-Business Ethereal-Business Jul 11, 2025

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does work, but I can't figure out how to change the number inside the UI. I click it and it goes from 10 to 1 and it gets stuck there for me. I have tried clicking it like a textbox, tried sliding it both ways, but it didn't budge in the UI.


// Add vehicle jump feature from legacy YimMenu
globals->AddItem(std::make_shared<BoolCommandItem>("vehjump"_J, "Vehicle Jump"));

tools->AddItem(std::make_shared<CommandItem>("enterlastvehicle"_J));
tools->AddItem(std::make_shared<CommandItem>("repairvehicle"_J));
Expand Down