-
Notifications
You must be signed in to change notification settings - Fork 333
Add Rainbow Paint and Vehicle Jump #617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Ethereal-Business
wants to merge
4
commits into
YimMenu:enhanced
Choose a base branch
from
Ethereal-Business:enhanced
base: enhanced
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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."}; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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.