feat(Vehicle): Added rainbow options (#141)

This commit is contained in:
Maddy 2022-05-02 15:32:23 -04:00 committed by GitHub
parent d1749da34a
commit c56d9194f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 184 additions and 3 deletions

View File

@ -28,6 +28,12 @@ namespace big
looped::hud_transition_state();
}QUEUE_JOB_END_CLAUSE
QUEUE_JOB_BEGIN_CLAUSE()
{
looped::rgb_synced_fade();
looped::rgb_synced_spasm();
}QUEUE_JOB_END_CLAUSE
QUEUE_JOB_BEGIN_CLAUSE()
{
looped::tunables_disable_phone();
@ -86,6 +92,7 @@ namespace big
looped::vehicle_god_mode();
looped::vehicle_horn_boost();
looped::vehicle_is_targetable();
looped::vehicle_rainbow_paint();
looped::vehicle_speedo_meter();
}QUEUE_JOB_END_CLAUSE

View File

@ -9,6 +9,9 @@ namespace big
static void hud_transition_state();
static void rgb_synced_fade();
static void rgb_synced_spasm();
static void tunables_disable_phone();
static void tunables_no_idle_kick();
@ -37,6 +40,7 @@ namespace big
static void vehicle_horn_boost();
static void vehicle_is_targetable();
static void vehicle_ls_customs();
static void vehicle_rainbow_paint();
static void vehicle_speedo_meter();
static void weapons_ammo_special_type();

View File

@ -0,0 +1,83 @@
#include "backend/looped/looped.hpp"
#include "script.hpp"
namespace big
{
enum rgb_controller_t
{
rgb_controller_green_up,
rgb_controller_red_down,
rgb_controller_blue_up,
rgb_controller_green_down,
rgb_controller_red_up,
rgb_controller_blue_down,
};
void looped::rgb_synced_fade()
{
if (g->rgb.fade)
{
static int rgb_controller_v = rgb_controller_green_up;
switch (rgb_controller_v)
{
case rgb_controller_green_up:
g->rgb.g += g->rgb.speed;
if (g->rgb.g >= 255)
{
g->rgb.g = 255;
rgb_controller_v = rgb_controller_red_down;
}
break;
case rgb_controller_red_down:
g->rgb.r -= g->rgb.speed;
if (g->rgb.r < 0)
{
g->rgb.r = 0;
rgb_controller_v = rgb_controller_blue_up;
}
break;
case rgb_controller_blue_up:
g->rgb.b += g->rgb.speed;
if (g->rgb.b >= 255)
{
g->rgb.b = 255;
rgb_controller_v = rgb_controller_green_down;
}
break;
case rgb_controller_green_down:
g->rgb.g -= g->rgb.speed;
if (g->rgb.g < 0)
{
g->rgb.g = 0;
rgb_controller_v = rgb_controller_red_up;
}
break;
case rgb_controller_red_up:
g->rgb.r += g->rgb.speed;
if (g->rgb.r >= 255)
{
g->rgb.r = 255;
rgb_controller_v = rgb_controller_blue_down;
}
break;
case rgb_controller_blue_down:
g->rgb.b -= g->rgb.speed;
if (g->rgb.b < 0)
{
g->rgb.b = 0;
rgb_controller_v = rgb_controller_green_up;
}
break;
default:
throw std::runtime_error("Invalid case provided to RGB controller!");
}
}
}
}

View File

@ -0,0 +1,18 @@
#include "backend/looped/looped.hpp"
#include "script.hpp"
namespace big
{
void looped::rgb_synced_spasm()
{
auto delay = std::chrono::milliseconds(1000 - (g->rgb.speed * 100));
if (g->rgb.spasm)
{
g->rgb.r = rand()%256;
g->rgb.g = rand() % 256;
g->rgb.b = rand() % 256;
}
script::get_current()->yield(delay);
}
}

View File

@ -0,0 +1,27 @@
#include "backend/looped/looped.hpp"
#include "natives.hpp"
namespace big
{
void looped::vehicle_rainbow_paint()
{
const Vehicle veh = PED::GET_VEHICLE_PED_IS_IN(PLAYER::PLAYER_PED_ID(), false);
if (veh != 0 && g->vehicle.rainbow_paint != 0)
{
if (g->vehicle.rainbow_paint == 1)
{
g->rgb.fade = true;
g->rgb.spasm = false;
}
else if (g->vehicle.rainbow_paint == 2)
{
g->rgb.spasm = true;
g->rgb.fade = false;
}
VEHICLE::SET_VEHICLE_CUSTOM_PRIMARY_COLOUR(veh, g->rgb.r, g->rgb.g, g->rgb.b);
VEHICLE::SET_VEHICLE_CUSTOM_PRIMARY_COLOUR(veh, g->rgb.r, g->rgb.g, g->rgb.b);
}
}
}

View File

@ -116,6 +116,15 @@ namespace big
script_events script_events{};
};
struct rgb {
bool fade = false;
bool spasm = false;
int r = 255;
int g = 0;
int b = 0;
int speed = 0;
};
struct self {
bool clean_player = false;
bool force_wanted_level = false;
@ -158,7 +167,7 @@ namespace big
bool preview_vehicle = false;
bool spawn_inside = false;
bool spawn_maxed = false;
};
};
struct spoofing
{
@ -188,6 +197,7 @@ namespace big
bool is_targetable = true;
bool ls_customs = false; // don't save this to disk
bool pv_teleport_into = false;
int rainbow_paint = 0;
speedo_meter speedo_meter{};
};
@ -248,6 +258,7 @@ namespace big
notifications notifications{};
player player{};
protections protections{};
rgb rgb{};
self self{};
session session{};
settings settings{};
@ -378,6 +389,13 @@ namespace big
script_handler.vehicle_kick = script_handler_j["vehicle_kick"];
}
this->rgb.fade = j["rgb"]["fade"];
this->rgb.spasm = j["rgb"]["spasm"];
this->rgb.r = j["rgb"]["r"];
this->rgb.g = j["rgb"]["g"];
this->rgb.b = j["rgb"]["b"];
this->rgb.speed = j["rgb"]["speed"];
this->tunables.disable_phone = j["tunables"]["disable_phone"];
this->tunables.no_idle_kick = j["tunables"]["no_idle_kick"];
@ -410,6 +428,7 @@ namespace big
this->vehicle.horn_boost = j["vehicle"]["horn_boost"];
this->vehicle.is_targetable = j["vehicle"]["is_targetable"];
this->vehicle.pv_teleport_into = j["vehicle"]["pv_teleport_into"];
this->vehicle.rainbow_paint = j["vehicle"]["rainbow_paint"];
this->vehicle.speedo_meter.type = (SpeedoMeter)j["vehicle"]["speedo_meter"]["type"];
this->vehicle.speedo_meter.left_side = j["vehicle"]["speedo_meter"]["left_side"];
@ -546,6 +565,16 @@ namespace big
}
}
},
{
"rgb", {
{ "fade", this->rgb.fade },
{ "spasm", this->rgb.spasm },
{ "r", this->rgb.r },
{ "g", this->rgb.g },
{ "b", this->rgb.b },
{ "speed", this->rgb.speed }
}
},
{
"tunables", {
{ "disable_phone", this->tunables.disable_phone },
@ -601,6 +630,7 @@ namespace big
{ "horn_boost", this->vehicle.horn_boost },
{ "is_targetable", this->vehicle.is_targetable },
{ "pv_teleport_into", this->vehicle.pv_teleport_into },
{ "rainbow_paint", this->vehicle.rainbow_paint },
{
"speedo_meter", {
{ "type", (int)this->vehicle.speedo_meter.type },

View File

@ -104,4 +104,6 @@ namespace big::vehicle
}
}
static constexpr char const* rgb_types[] = { "Off", "Fade", "Spasm" };
}

View File

@ -23,7 +23,7 @@ namespace big
Vehicle veh = PED::GET_VEHICLE_PED_IS_IN(PLAYER::PLAYER_PED_ID(), false);
vehicle::repair(veh);
});
});
if (components::button("Handling")) {
ImGui::OpenPopup("Handling Popup");
@ -52,7 +52,17 @@ namespace big
ImGui::EndPopup();
}
ImGui::EndGroup();
ImGui::TreePop();
}
if (ImGui::TreeNode("Paint"))
{
ImGui::ListBox("RGB Type", &g->vehicle.rainbow_paint, vehicle::rgb_types, 3);
if (g->vehicle.rainbow_paint != 0)
{
ImGui::SliderInt("RGB Speed", &g->rgb.speed, 1, 10);
}
ImGui::TreePop();
}