Cleaned up rainbow paint. (#414)

This commit is contained in:
aa15032261 2022-08-14 18:19:33 +08:00 committed by GitHub
parent 84ba76b7a5
commit d200526c64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 163 additions and 191 deletions

View File

@ -83,7 +83,6 @@ namespace big
looped::vehicle_jump(); looped::vehicle_jump();
looped::vehicle_instant_brake(); looped::vehicle_instant_brake();
looped::vehicle_is_targetable(); looped::vehicle_is_targetable();
looped::vehicle_rainbow_paint();
looped::vehicle_seatbelt(); looped::vehicle_seatbelt();
looped::vehicle_speedo_meter(); looped::vehicle_speedo_meter();
@ -103,19 +102,6 @@ namespace big
} }
} }
void backend::rgbrandomizer_loop()
{
LOG(INFO) << "Starting script: rgbrandomizer";
while (g_running)
{
looped::rgb_synced_fade();
looped::rgb_synced_spasm();
script::get_current()->yield();
}
}
void backend::misc_loop() void backend::misc_loop()
{ {
LOG(INFO) << "Starting script: Miscellaneous"; LOG(INFO) << "Starting script: Miscellaneous";
@ -172,6 +158,18 @@ namespace big
} }
} }
void backend::rainbowpaint_loop()
{
LOG(INFO) << "Starting script: Rainbow paint";
while (g_running)
{
looped::vehicle_rainbow_paint();
script::get_current()->yield();
}
}
void backend::vehiclefly_loop() void backend::vehiclefly_loop()
{ {
LOG(INFO) << "Starting script: Vehicle fly"; LOG(INFO) << "Starting script: Vehicle fly";

View File

@ -11,11 +11,11 @@ namespace big
static void weapons_loop(); static void weapons_loop();
static void vehicles_loop(); static void vehicles_loop();
static void turnsignal_loop(); static void turnsignal_loop();
static void rgbrandomizer_loop();
static void misc_loop(); static void misc_loop();
static void remote_loop(); static void remote_loop();
static void noclip_loop(); static void noclip_loop();
static void lscustoms_loop(); static void lscustoms_loop();
static void rainbowpaint_loop();
static void vehiclefly_loop(); static void vehiclefly_loop();
static void disable_control_action_loop(); static void disable_control_action_loop();
}; };

View File

@ -13,9 +13,6 @@ namespace big
static void context_menu(); static void context_menu();
static void hud_transition_state(); static void hud_transition_state();
static void rgb_synced_fade();
static void rgb_synced_spasm();
static void tunables_disable_phone(); static void tunables_disable_phone();
static void tunables_no_idle_kick(); static void tunables_no_idle_kick();

View File

@ -1,83 +0,0 @@
#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

@ -1,18 +0,0 @@
#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

@ -1,40 +1,124 @@
#include "backend/looped/looped.hpp" #include "backend/looped/looped.hpp"
#include "natives.hpp" #include "natives.hpp"
#include "script.hpp"
namespace big 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::vehicle_rainbow_paint() void looped::vehicle_rainbow_paint()
{ {
if (g->vehicle.rainbow_paint) static int rgb_controller_v = rgb_controller_green_up;
static int red = 255;
static int green = 0;
static int blue = 0;
if (self::veh && g->vehicle.rainbow_paint.type != RainbowPaintType::Off)
{ {
int delay_step = 100;
if (g->vehicle.rainbow_paint.type == RainbowPaintType::Spasm)
{
red = rand() % 256;
green = rand() % 256;
blue = rand() % 256;
}
else if (g->vehicle.rainbow_paint.type == RainbowPaintType::Fade)
{
delay_step = 10;
switch (rgb_controller_v)
{
case rgb_controller_green_up:
green += 5;
if (green >= 255)
{
green = 255;
rgb_controller_v = rgb_controller_red_down;
}
break;
case rgb_controller_red_down:
red -= 5;
if (red < 0)
{
red = 0;
rgb_controller_v = rgb_controller_blue_up;
}
break;
case rgb_controller_blue_up:
blue += 5;
if (blue >= 255)
{
blue = 255;
rgb_controller_v = rgb_controller_green_down;
}
break;
case rgb_controller_green_down:
green -= 5;
if (green < 0)
{
green = 0;
rgb_controller_v = rgb_controller_red_up;
}
break;
case rgb_controller_red_up:
red += 5;
if (red >= 255)
{
red = 255;
rgb_controller_v = rgb_controller_blue_down;
}
break;
case rgb_controller_blue_down:
blue -= 5;
if (blue < 0)
{
blue = 0;
rgb_controller_v = rgb_controller_green_up;
}
break;
default:
break;
}
}
Vehicle vehicle = self::veh; Vehicle vehicle = self::veh;
if (g->vehicle.rainbow_paint == 1) if (g->vehicle.rainbow_paint.primary) {
{ VEHICLE::SET_VEHICLE_CUSTOM_PRIMARY_COLOUR(vehicle, red, green, blue);
g->rgb.fade = true;
g->rgb.spasm = false;
} }
else if (g->vehicle.rainbow_paint == 2) if (g->vehicle.rainbow_paint.secondary) {
{ VEHICLE::SET_VEHICLE_CUSTOM_SECONDARY_COLOUR(vehicle, red, green, blue);
g->rgb.spasm = true;
g->rgb.fade = false;
} }
if (g->vehicle.rainbow_primary) { if (g->vehicle.rainbow_paint.neon) {
VEHICLE::SET_VEHICLE_CUSTOM_PRIMARY_COLOUR(vehicle, g->rgb.r, g->rgb.g, g->rgb.b);
}
if (g->vehicle.rainbow_secondary) {
VEHICLE::SET_VEHICLE_CUSTOM_SECONDARY_COLOUR(vehicle, g->rgb.r, g->rgb.g, g->rgb.b);
}
if (g->vehicle.rainbow_neon) {
VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(vehicle, 0, 1); VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(vehicle, 0, 1);
VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(vehicle, 1, 1); VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(vehicle, 1, 1);
VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(vehicle, 2, 1); VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(vehicle, 2, 1);
VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(vehicle, 3, 1); VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(vehicle, 3, 1);
VEHICLE::SET_VEHICLE_NEON_LIGHTS_COLOUR_(vehicle, g->rgb.r, g->rgb.g, g->rgb.b); VEHICLE::SET_VEHICLE_NEON_LIGHTS_COLOUR_(vehicle, red, green, blue);
} }
if (g->vehicle.rainbow_smoke) { if (g->vehicle.rainbow_paint.smoke) {
VEHICLE::SET_VEHICLE_TYRE_SMOKE_COLOR(vehicle, g->rgb.r, g->rgb.g, g->rgb.b); VEHICLE::SET_VEHICLE_TYRE_SMOKE_COLOR(vehicle, red, green, blue);
} }
auto delay = std::chrono::milliseconds(((delay_step * 10) + 10) - (g->vehicle.rainbow_paint.speed * delay_step));
script::get_current()->yield(delay);
} }
} }
} }

View File

@ -190,6 +190,13 @@ namespace big
MPS MPS
}; };
enum class RainbowPaintType
{
Off,
Fade,
Spasm
};
enum class AutoDriveDestination enum class AutoDriveDestination
{ {
STOPPED, STOPPED,

View File

@ -121,15 +121,6 @@ namespace big
script_events script_events{}; 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 { struct self {
bool clean_player = false; bool clean_player = false;
bool force_wanted_level = false; bool force_wanted_level = false;
@ -229,6 +220,15 @@ namespace big
float speed = 1; float speed = 1;
}; };
struct rainbow_paint {
RainbowPaintType type = RainbowPaintType::Off;
bool neon = false;
bool primary = false;
bool secondary = false;
bool smoke = false;
int speed = 0;
};
SpeedUnit speed_unit = SpeedUnit::MIPH; SpeedUnit speed_unit = SpeedUnit::MIPH;
bool god_mode = false; bool god_mode = false;
@ -251,15 +251,11 @@ namespace big
bool instant_brake = false; bool instant_brake = false;
bool is_targetable = true; bool is_targetable = true;
bool ls_customs = false; // don't save this to disk bool ls_customs = false; // don't save this to disk
bool rainbow_neon = false;
int rainbow_paint = 0;
bool rainbow_primary = false;
bool rainbow_secondary = false;
bool rainbow_smoke = false;
bool seatbelt = false; bool seatbelt = false;
bool turn_signals = false; bool turn_signals = false;
bool vehicle_jump = false; bool vehicle_jump = false;
speedo_meter speedo_meter{}; speedo_meter speedo_meter{};
rainbow_paint rainbow_paint{};
fly fly{}; fly fly{};
}; };
@ -356,7 +352,6 @@ namespace big
notifications notifications{}; notifications notifications{};
player player{}; player player{};
protections protections{}; protections protections{};
rgb rgb{};
self self{}; self self{};
session session{}; session session{};
settings settings{}; settings settings{};
@ -504,13 +499,6 @@ namespace big
script_handler.vehicle_kick = script_handler_j["vehicle_kick"]; 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.disable_phone = j["tunables"]["disable_phone"];
this->tunables.no_idle_kick = j["tunables"]["no_idle_kick"]; this->tunables.no_idle_kick = j["tunables"]["no_idle_kick"];
@ -576,11 +564,6 @@ namespace big
this->vehicle.vehicle_jump = j["vehicle"]["vehicle_jump"]; this->vehicle.vehicle_jump = j["vehicle"]["vehicle_jump"];
this->vehicle.instant_brake = j["vehicle"]["instant_brake"]; this->vehicle.instant_brake = j["vehicle"]["instant_brake"];
this->vehicle.is_targetable = j["vehicle"]["is_targetable"]; this->vehicle.is_targetable = j["vehicle"]["is_targetable"];
this->vehicle.rainbow_paint = j["vehicle"]["rainbow_paint"];
this->vehicle.rainbow_primary = j["vehicle"]["rainbow_primary"];
this->vehicle.rainbow_secondary = j["vehicle"]["rainbow_secondary"];
this->vehicle.rainbow_neon = j["vehicle"]["rainbow_neon"];
this->vehicle.rainbow_smoke = j["vehicle"]["rainbow_smoke"];
this->vehicle.seatbelt = j["vehicle"]["seatbelt"]; this->vehicle.seatbelt = j["vehicle"]["seatbelt"];
this->vehicle.turn_signals = j["vehicle"]["turn_signals"]; this->vehicle.turn_signals = j["vehicle"]["turn_signals"];
@ -589,6 +572,13 @@ namespace big
this->vehicle.speedo_meter.x = j["vehicle"]["speedo_meter"]["position_x"]; this->vehicle.speedo_meter.x = j["vehicle"]["speedo_meter"]["position_x"];
this->vehicle.speedo_meter.y = j["vehicle"]["speedo_meter"]["position_y"]; this->vehicle.speedo_meter.y = j["vehicle"]["speedo_meter"]["position_y"];
this->vehicle.rainbow_paint.type = j["vehicle"]["rainbow_paint"]["type"];
this->vehicle.rainbow_paint.speed = j["vehicle"]["rainbow_paint"]["speed"];
this->vehicle.rainbow_paint.neon = j["vehicle"]["rainbow_paint"]["neon"];
this->vehicle.rainbow_paint.primary = j["vehicle"]["rainbow_paint"]["primary"];
this->vehicle.rainbow_paint.secondary = j["vehicle"]["rainbow_paint"]["secondary"];
this->vehicle.rainbow_paint.smoke = j["vehicle"]["rainbow_paint"]["smoke"];
this->vehicle.fly.dont_stop = j["vehicle"]["fly"]["dont_stop"]; this->vehicle.fly.dont_stop = j["vehicle"]["fly"]["dont_stop"];
this->vehicle.fly.enabled = j["vehicle"]["fly"]["enabled"]; this->vehicle.fly.enabled = j["vehicle"]["fly"]["enabled"];
this->vehicle.fly.no_collision = j["vehicle"]["fly"]["no_collision"]; this->vehicle.fly.no_collision = j["vehicle"]["fly"]["no_collision"];
@ -754,16 +744,6 @@ 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", { "tunables", {
{ "disable_phone", this->tunables.disable_phone }, { "disable_phone", this->tunables.disable_phone },
@ -858,21 +838,28 @@ namespace big
{ "vehicle_jump", this->vehicle.vehicle_jump }, { "vehicle_jump", this->vehicle.vehicle_jump },
{ "instant_brake", this->vehicle.instant_brake }, { "instant_brake", this->vehicle.instant_brake },
{ "is_targetable", this->vehicle.is_targetable }, { "is_targetable", this->vehicle.is_targetable },
{ "rainbow_paint", this->vehicle.rainbow_paint },
{ "rainbow_primary", this->vehicle.rainbow_primary },
{ "rainbow_secondary", this->vehicle.rainbow_secondary },
{ "rainbow_neon", this->vehicle.rainbow_neon },
{ "rainbow_smoke", this->vehicle.rainbow_smoke },
{ "turn_signals", this->vehicle.turn_signals }, { "turn_signals", this->vehicle.turn_signals },
{ "seatbelt", this->vehicle.seatbelt }, { "seatbelt", this->vehicle.seatbelt },
{ {
"speedo_meter", { "speedo_meter",
{
{ "enabled", this->vehicle.speedo_meter.enabled }, { "enabled", this->vehicle.speedo_meter.enabled },
{ "left_side", this->vehicle.speedo_meter.left_side }, { "left_side", this->vehicle.speedo_meter.left_side },
{ "position_x", this->vehicle.speedo_meter.x }, { "position_x", this->vehicle.speedo_meter.x },
{ "position_y", this->vehicle.speedo_meter.y }, { "position_y", this->vehicle.speedo_meter.y },
} }
}, },
{
"rainbow_paint",
{
{ "type", this->vehicle.rainbow_paint.type },
{ "speed", this->vehicle.rainbow_paint.speed },
{ "neon", this->vehicle.rainbow_paint.neon },
{ "primary", this->vehicle.rainbow_paint.primary },
{ "secondary", this->vehicle.rainbow_paint.secondary },
{ "smoke", this->vehicle.rainbow_paint.smoke }
}
},
{ {
"fly", "fly",
{ {

View File

@ -95,8 +95,8 @@ BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID)
g_script_mgr.add_script(std::make_unique<script>(&backend::remote_loop, "Remote")); g_script_mgr.add_script(std::make_unique<script>(&backend::remote_loop, "Remote"));
g_script_mgr.add_script(std::make_unique<script>(&backend::noclip_loop, "No Clip")); g_script_mgr.add_script(std::make_unique<script>(&backend::noclip_loop, "No Clip"));
g_script_mgr.add_script(std::make_unique<script>(&backend::lscustoms_loop, "LS Customs")); g_script_mgr.add_script(std::make_unique<script>(&backend::lscustoms_loop, "LS Customs"));
g_script_mgr.add_script(std::make_unique<script>(&backend::rainbowpaint_loop, "Rainbow Paint"));
g_script_mgr.add_script(std::make_unique<script>(&backend::vehiclefly_loop, "Vehicle Fly")); g_script_mgr.add_script(std::make_unique<script>(&backend::vehiclefly_loop, "Vehicle Fly"));
g_script_mgr.add_script(std::make_unique<script>(&backend::rgbrandomizer_loop, "RGB Randomizer"));
g_script_mgr.add_script(std::make_unique<script>(&backend::turnsignal_loop, "Turn Signals")); g_script_mgr.add_script(std::make_unique<script>(&backend::turnsignal_loop, "Turn Signals"));
g_script_mgr.add_script(std::make_unique<script>(&backend::disable_control_action_loop, "Disable Controls")); g_script_mgr.add_script(std::make_unique<script>(&backend::disable_control_action_loop, "Disable Controls"));
g_script_mgr.add_script(std::make_unique<script>(&context_menu_service::context_menu, "Context Menu")); g_script_mgr.add_script(std::make_unique<script>(&context_menu_service::context_menu, "Context Menu"));

View File

@ -141,26 +141,26 @@ namespace big
components::sub_title("Rainbow Paint"); components::sub_title("Rainbow Paint");
{ {
ImGui::Checkbox("Primary", &g->vehicle.rainbow_primary); ImGui::Checkbox("Primary", &g->vehicle.rainbow_paint.primary);
ImGui::SameLine(); ImGui::SameLine();
ImGui::Checkbox("Secondary", &g->vehicle.rainbow_secondary); ImGui::Checkbox("Secondary", &g->vehicle.rainbow_paint.secondary);
ImGui::SameLine(); ImGui::SameLine();
ImGui::Checkbox("Neon", &g->vehicle.rainbow_neon); ImGui::Checkbox("Neon", &g->vehicle.rainbow_paint.neon);
ImGui::SameLine(); ImGui::SameLine();
ImGui::Checkbox("Smoke", &g->vehicle.rainbow_smoke); ImGui::Checkbox("Smoke", &g->vehicle.rainbow_paint.smoke);
static constexpr char const* rgb_types[] = { "Off", "Fade", "Spasm" }; static constexpr char const* rgb_types[] = { "Off", "Fade", "Spasm" };
ImGui::SetNextItemWidth(120); ImGui::SetNextItemWidth(120);
if (ImGui::BeginCombo("RGB Type", rgb_types[g->vehicle.rainbow_paint])) if (ImGui::BeginCombo("RGB Type", rgb_types[(int)g->vehicle.rainbow_paint.type]))
{ {
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
{ {
bool itemSelected = g->vehicle.rainbow_paint == i; bool itemSelected = (int)g->vehicle.rainbow_paint.type == i;
if (ImGui::Selectable(rgb_types[i], itemSelected)) if (ImGui::Selectable(rgb_types[i], itemSelected))
{ {
g->vehicle.rainbow_paint = i; g->vehicle.rainbow_paint.type = (RainbowPaintType)i;
} }
if (itemSelected) if (itemSelected)
@ -171,11 +171,11 @@ namespace big
ImGui::EndCombo(); ImGui::EndCombo();
} }
if (g->vehicle.rainbow_paint != 0) if (g->vehicle.rainbow_paint.type != RainbowPaintType::Off)
{ {
ImGui::SameLine(); ImGui::SameLine();
ImGui::SetNextItemWidth(150); ImGui::SetNextItemWidth(150);
ImGui::SliderInt("RGB Speed", &g->rgb.speed, 1, 10); ImGui::SliderInt("RGB Speed", &g->vehicle.rainbow_paint.speed, 1, 10);
} }
} }
ImGui::Separator(); ImGui::Separator();