Rework rgb for fun vehicle and paintgun (#1783)

Closes #1819
This commit is contained in:
TheGreenBandit 2023-07-23 12:51:57 -04:00 committed by GitHub
parent 09a189eb4d
commit ae486ca129
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 65 additions and 161 deletions

View File

@ -16,9 +16,8 @@ include(scripts/json.cmake)
include(scripts/cpr.cmake) include(scripts/cpr.cmake)
include(scripts/zydis.cmake) include(scripts/zydis.cmake)
include(scripts/lua.cmake) include(scripts/lua.cmake)
message("\nFetching custom modules")
include(scripts/imgui.cmake) include(scripts/imgui.cmake)
message("\nFetching custom modules")
include(scripts/gtav-classes.cmake) include(scripts/gtav-classes.cmake)

View File

@ -35,7 +35,6 @@ namespace big
looped::system_desync_kick_protection(); looped::system_desync_kick_protection();
looped::system_spoofing(); looped::system_spoofing();
looped::system_mission_creator(); looped::system_mission_creator();
looped::system_rainbow();
for (auto command : g_looped_commands) for (auto command : g_looped_commands)
if (command->is_enabled()) if (command->is_enabled())

View File

@ -40,7 +40,6 @@ namespace big
static void system_desync_kick_protection(); static void system_desync_kick_protection();
static void system_spoofing(); static void system_spoofing();
static void system_mission_creator(); static void system_mission_creator();
static void system_rainbow();
static void vehicle_auto_drive(); static void vehicle_auto_drive();
static void vehicle_allow_all_weapons(); static void vehicle_allow_all_weapons();

View File

@ -1,101 +0,0 @@
#include "backend/looped/looped.hpp"
#include "core/data/color.hpp"
namespace big
{
void looped::system_rainbow()
{
static std::chrono::system_clock::time_point last_rgb_run_time;
static std::chrono::milliseconds delay = 0s;
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,
};
if (last_rgb_run_time + delay < std::chrono::system_clock::now())
{
int delay_step = 100;
if (g.settings.rainbow.spasm)
{
rgb.red = rand() % 256;
rgb.green = rand() % 256;
rgb.blue = rand() % 256;
}
else if (g.settings.rainbow.fade)
{
int delay_step = 10;
static int rgb_controller_v = rgb_controller_green_up;
switch (rgb_controller_v)
{
case rgb_controller_green_up:
rgb.green += 5;
if (rgb.green >= 255)
{
rgb.green = 255;
rgb_controller_v = rgb_controller_red_down;
}
break;
case rgb_controller_red_down:
rgb.red -= 5;
if (rgb.red < 0)
{
rgb.red = 0;
rgb_controller_v = rgb_controller_blue_up;
}
break;
case rgb_controller_blue_up:
rgb.blue += 5;
if (rgb.blue >= 255)
{
rgb.blue = 255;
rgb_controller_v = rgb_controller_green_down;
}
break;
case rgb_controller_green_down:
rgb.green -= 5;
if (rgb.green < 0)
{
rgb.green = 0;
rgb_controller_v = rgb_controller_red_up;
}
break;
case rgb_controller_red_up:
rgb.red += 5;
if (rgb.red >= 255)
{
rgb.red = 255;
rgb_controller_v = rgb_controller_blue_down;
}
break;
case rgb_controller_blue_down:
rgb.blue -= 5;
if (rgb.blue < 0)
{
rgb.blue = 0;
rgb_controller_v = rgb_controller_green_up;
}
break;
default: break;
}
}
delay = std::chrono::milliseconds(((delay_step * 10) + 10) - (g.settings.rainbow.speed * delay_step));
last_rgb_run_time = std::chrono::system_clock::now();
}
}
}

View File

@ -3,34 +3,50 @@
#include "backend/looped/looped.hpp" #include "backend/looped/looped.hpp"
#include "natives.hpp" #include "natives.hpp"
#include "script.hpp" #include "script.hpp"
#include "core/data/color.hpp"
namespace big namespace big
{ {
float red = 255.f, green = 0.f, blue = 0.f;
void looped::vehicle_rainbow_paint() void looped::vehicle_rainbow_paint()
{ {
static std::chrono::system_clock::time_point last_rgb_run_time; static std::chrono::system_clock::time_point last_rgb_run_time;
static std::chrono::milliseconds delay = 0s; static std::chrono::milliseconds delay = 0s;
static bool ran = false;
static int red = 255; if (self::veh && g.vehicle.rainbow_paint.type != RainbowPaintType::Off)
static int green = 0;
static int blue = 0;
if (self::veh && g.vehicle.rainbow_paint.type != RainbowPaintType::Off && last_rgb_run_time + delay < std::chrono::system_clock::now())
{ {
int delay_step = 100; if (g.vehicle.rainbow_paint.type == RainbowPaintType::Spasm && last_rgb_run_time + delay < std::chrono::system_clock::now())
if (g.vehicle.rainbow_paint.type == RainbowPaintType::Spasm)
{ {
red = rand() % 256; red = rand() % 255;
green = rand() % 256; green = rand() % 255;
blue = rand() % 256; blue = rand() % 255;
delay = std::chrono::milliseconds((110) - (g.vehicle.rainbow_paint.speed * 10));
last_rgb_run_time = std::chrono::system_clock::now();
ran = true;
} }
else if (g.vehicle.rainbow_paint.type == RainbowPaintType::Fade)
if (g.vehicle.rainbow_paint.type == RainbowPaintType::Fade) //messy but gets job done
{ {
red = rgb.red; if (ran) { red = 255; green = 0; blue = 0; ran = false; }
blue = rgb.blue;
green = rgb.green; if (red > 0 && blue == 0)
{
green += g.vehicle.rainbow_paint.speed;
red -= g.vehicle.rainbow_paint.speed;
}
if (green > 0 && red == 0)
{
blue += g.vehicle.rainbow_paint.speed;
green -= g.vehicle.rainbow_paint.speed;
}
if (blue > 0 && green == 0)
{
red += g.vehicle.rainbow_paint.speed;
blue -= g.vehicle.rainbow_paint.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 (g.vehicle.rainbow_paint.primary) if (g.vehicle.rainbow_paint.primary)
@ -43,19 +59,12 @@ namespace big
} }
if (g.vehicle.rainbow_paint.neon) if (g.vehicle.rainbow_paint.neon)
{ {
VEHICLE::SET_VEHICLE_NEON_ENABLED(self::veh, 0, 1);
VEHICLE::SET_VEHICLE_NEON_ENABLED(self::veh, 1, 1);
VEHICLE::SET_VEHICLE_NEON_ENABLED(self::veh, 2, 1);
VEHICLE::SET_VEHICLE_NEON_ENABLED(self::veh, 3, 1);
VEHICLE::SET_VEHICLE_NEON_COLOUR(self::veh, red, green, blue); VEHICLE::SET_VEHICLE_NEON_COLOUR(self::veh, red, green, blue);
} }
if (g.vehicle.rainbow_paint.smoke) if (g.vehicle.rainbow_paint.smoke)
{ {
VEHICLE::SET_VEHICLE_TYRE_SMOKE_COLOR(self::veh, red, green, blue); VEHICLE::SET_VEHICLE_TYRE_SMOKE_COLOR(self::veh, red, green, blue);
} }
delay = std::chrono::milliseconds(((delay_step * 10) + 10) - (g.vehicle.rainbow_paint.speed * delay_step));
last_rgb_run_time = std::chrono::system_clock::now();
} }
} }

View File

@ -2,19 +2,42 @@
#include "core/enums.hpp" #include "core/enums.hpp"
#include "gta/enums.hpp" #include "gta/enums.hpp"
#include "util/entity.hpp" #include "util/entity.hpp"
#include "core/data/color.hpp"
namespace big namespace big
{ {
void looped::weapons_paint_gun() void looped::weapons_paint_gun()
{ {
static Vector3 col = {0, 0, 0};
static float red = 255.f, green = 0.f, blue = 0.f;
if (g.weapons.paintgun.rainbow) if (g.weapons.paintgun.rainbow)
{ {
g.weapons.paintgun.col[0] = rgb.red; if (red > 0 && blue == 0)
g.weapons.paintgun.col[1] = rgb.green; {
g.weapons.paintgun.col[2] = rgb.blue; green += red;
red -= g.weapons.paintgun.speed;
}
if (green > 0 && red == 0)
{
blue += g.weapons.paintgun.speed;
green -= g.weapons.paintgun.speed;
}
if (blue > 0 && green == 0)
{
red += g.weapons.paintgun.speed;
blue -= g.weapons.paintgun.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 (g.weapons.paintgun.rainbow)
col = {red, green, blue};
else
col = {g.weapons.paintgun.col[0], g.weapons.paintgun.col[1], g.weapons.paintgun.col[2]};
if (g.weapons.custom_weapon == CustomWeapon::PAINT_GUN && (!g.self.custom_weapon_stop || WEAPON::IS_PED_ARMED(self::ped, 4 | 2))) if (g.weapons.custom_weapon == CustomWeapon::PAINT_GUN && (!g.self.custom_weapon_stop || WEAPON::IS_PED_ARMED(self::ped, 4 | 2)))
{ {
Vector3 c; entity::raycast(&c); Vector3 c; entity::raycast(&c);
@ -35,9 +58,9 @@ namespace big
0.f, // always 0 0.f, // always 0
0.5f, //size x 0.5f, //size x
0.4f, //size y 0.4f, //size y
g.weapons.paintgun.col[0], col.x,
g.weapons.paintgun.col[1], col.y,
g.weapons.paintgun.col[2], col.z,
g.weapons.paintgun.col[3], g.weapons.paintgun.col[3],
-1, -1,
true, true,

View File

@ -1,10 +0,0 @@
namespace big
{
inline class rgb
{
public:
float red = 255.f;
float green = 0;
float blue = 0;
} rgb{};
}

View File

@ -422,13 +422,6 @@ namespace big
{ {
bool dev_dlc = false; bool dev_dlc = false;
struct rainbow
{
bool fade = false;
bool spasm = false;
int speed = 1;
} rainbow{};
struct hotkeys struct hotkeys
{ {
bool editing_menu_toggle = false; bool editing_menu_toggle = false;
@ -732,6 +725,7 @@ namespace big
struct paintgun struct paintgun
{ {
bool rainbow = false; bool rainbow = false;
float speed = 1.f;
float col[4] = {0.f, 0.f, 1.f, 1.f}; float col[4] = {0.f, 0.f, 1.f, 1.f};
NLOHMANN_DEFINE_TYPE_INTRUSIVE(paintgun, rainbow, col) NLOHMANN_DEFINE_TYPE_INTRUSIVE(paintgun, rainbow, col)
} paintgun{}; } paintgun{};

View File

@ -1,5 +1,4 @@
#include "hooking.hpp" #include "hooking.hpp"
#include "core/data/color.hpp"
#include <misc/vfx/TimecycleKeyframeData.hpp> #include <misc/vfx/TimecycleKeyframeData.hpp>

View File

@ -150,6 +150,7 @@ namespace big
break; break;
case CustomWeapon::PAINT_GUN: case CustomWeapon::PAINT_GUN:
ImGui::Checkbox("Rainbow Color", &g.weapons.paintgun.rainbow); ImGui::Checkbox("Rainbow Color", &g.weapons.paintgun.rainbow);
ImGui::SliderFloat("Rainbow Speed", &g.weapons.paintgun.speed, 0.f, 10.f);
if (!g.weapons.paintgun.rainbow) { ImGui::ColorEdit4("Paint Gun Color", g.weapons.paintgun.col); } if (!g.weapons.paintgun.rainbow) { ImGui::ColorEdit4("Paint Gun Color", g.weapons.paintgun.col); }
} }

View File

@ -58,11 +58,6 @@ namespace big
}); });
} }
ImGui::SeparatorText("Rainbow");
ImGui::Checkbox("Spasm", &g.settings.rainbow.spasm);
ImGui::Checkbox("Fade", &g.settings.rainbow.fade);
ImGui::SliderInt("Speed", &g.settings.rainbow.speed, 0, 10); // TODO: THIS SPEED DOESNT MAKE SENSE
ImGui::SeparatorText("SETTINGS_MISC"_T.data()); ImGui::SeparatorText("SETTINGS_MISC"_T.data());
ImGui::Checkbox("SETTINGS_MISC_DEV_DLC"_T.data(), &g.settings.dev_dlc); ImGui::Checkbox("SETTINGS_MISC_DEV_DLC"_T.data(), &g.settings.dev_dlc);

View File

@ -1,8 +1,5 @@
#include "views/view.hpp" #include "views/view.hpp"
#include <imgui_internal.h>
namespace big namespace big
{ {
void view::vfx() void view::vfx()