Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
129 changes: 129 additions & 0 deletions src/game/features/vehicle/RainbowPaint.cpp
Original file line number Diff line number Diff line change
@@ -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 <chrono>

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

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;
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>(_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));
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<int>(red), static_cast<int>(green), static_cast<int>(blue));
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
}
11 changes: 11 additions & 0 deletions src/game/frontend/submenus/Vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ namespace YimMenu::Submenus

misc->AddItem(std::make_shared<BoolCommandItem>("speedometer"_J));
misc->AddItem(std::make_shared<BoolCommandItem>("seatbelt"_J));

// Rainbow Paint feature with options
misc->AddItem(std::make_shared<BoolCommandItem>("rainbowpaint"_J, "Rainbow Paint"));
misc->AddItem(std::make_shared<ConditionalItem>("rainbowpaint"_J, std::make_shared<ListCommandItem>("rainbowtype"_J, "Paint Type")));
misc->AddItem(std::make_shared<ConditionalItem>("rainbowpaint"_J, std::make_shared<BoolCommandItem>("rainbowpri"_J, "Primary"))); // do we even need this?
misc->AddItem(std::make_shared<ConditionalItem>("rainbowpaint"_J, std::make_shared<BoolCommandItem>("rainbowsec"_J, "Secondary")));
misc->AddItem(std::make_shared<ConditionalItem>("rainbowpaint"_J, std::make_shared<IntCommandItem>("rainbowspeed"_J, "Speed")));

// Vehicle Jump feature
misc->AddItem(std::make_shared<BoolCommandItem>("vehjump"_J, "Vehicle Jump"));

misc->AddItem(std::make_shared<BoolCommandItem>("lowervehiclestance"_J, "Lower Stance"));
misc->AddItem(std::make_shared<BoolCommandItem>("allowhatsinvehicles"_J));
misc->AddItem(std::make_shared<BoolCommandItem>("lsccustomsbypass"_J));
Expand Down