From 15a74630f95a7ecc9abf05d7b3ea5d5cb4eb0b09 Mon Sep 17 00:00:00 2001 From: Felix Wehrfeld Date: Tue, 27 May 2025 16:54:50 +0200 Subject: [PATCH] added: Casino Rig Slot Machines Manipulation, RP Multiplier and MaxAmmo Feature (#299) * added nightclub * Add arcade * added rp multiplier * add arcade safe payout * added rp multiplier * added nightclub safe payout * add casino win * removed unnecessary code an debug logs * Removed debug code * Fixed casino rig slot machines * changed cmake autoRecon bool * removed unnecessary line * fix https://github.com/YimMenu/YimMenuV2/pull/299#discussion_r2094336529 * fix https://github.com/YimMenu/YimMenuV2/pull/299#discussion_r2094338633 and https://github.com/YimMenu/YimMenuV2/pull/299#discussion_r2094338444 * fixed https://github.com/YimMenu/YimMenuV2/pull/299#discussion_r2094339450, https://github.com/YimMenu/YimMenuV2/pull/299#discussion_r2094337391 and https://github.com/YimMenu/YimMenuV2/pull/299#discussion_r2094336813. Added Give Max Ammo-Feature. * changed format * fix format * fixed wrong path * removed Nightclub and arcade safe payout because of https://github.com/YimMenu/YimMenuV2/pull/299#discussion_r2094595284. Moved RPMultiplier to Recovery general. * fixed misspelling * cleanup for merge * removed unnecessary include * removed unnecessary import * added givemaxammo item to group --------- Co-authored-by: Felix Wehrfeld --- src/game/features/recovery/Casino.cpp | 83 +++++++++++++++++++++ src/game/features/recovery/RpMultiplier.cpp | 25 +++++++ src/game/features/self/GiveMaxAmmo.cpp | 21 ++++++ src/game/frontend/submenus/Recovery.cpp | 16 +++- src/game/frontend/submenus/Self.cpp | 3 +- src/game/gta/Ped.cpp | 7 ++ src/game/gta/Ped.hpp | 1 + 7 files changed, 152 insertions(+), 4 deletions(-) create mode 100644 src/game/features/recovery/Casino.cpp create mode 100644 src/game/features/recovery/RpMultiplier.cpp create mode 100644 src/game/features/self/GiveMaxAmmo.cpp diff --git a/src/game/features/recovery/Casino.cpp b/src/game/features/recovery/Casino.cpp new file mode 100644 index 0000000..ceb1cd9 --- /dev/null +++ b/src/game/features/recovery/Casino.cpp @@ -0,0 +1,83 @@ +#include "core/commands/LoopedCommand.hpp" +#include "game/backend/Self.hpp" +#include "game/gta/Natives.hpp" +#include "game/gta/ScriptLocal.hpp" + +#include + + +namespace YimMenu::Features +{ + class CasinoManipulateRigSlotMachines : public LoopedCommand + { + using LoopedCommand::LoopedCommand; + + int slots_random_results_table = 1348; + std::set slots_blacklist = {9, 21, 22, 87, 152}; + + virtual void OnTick() override + { + if (Scripts::SafeToModifyFreemodeBroadcastGlobals() && SCRIPT::GET_NUMBER_OF_THREADS_RUNNING_THE_SCRIPT_WITH_THIS_HASH("casino_slots"_J)) + { + Player casinoSlotsScriptHostPlayer = NETWORK::NETWORK_GET_HOST_OF_SCRIPT("casino_slots", -1, 0); + auto casinoSlotsScriptHostPlayerId = casinoSlotsScriptHostPlayer.GetId(); + auto selfPlayerId = Self::GetPlayer().GetId(); + if (casinoSlotsScriptHostPlayerId != selfPlayerId) + { + Scripts::ForceScriptHost(Scripts::FindScriptThread("casino_slots"_J)); + } + + bool needs_run = false; + for (int slots_iter = 3; slots_iter <= 196; ++slots_iter) + { + if (!slots_blacklist.contains(slots_iter)) + { + if (*ScriptLocal("casino_slots"_J, slots_random_results_table + slots_iter).As() != 6) + { + needs_run = true; + } + } + } + if (needs_run) + { + for (int slots_iter = 3; slots_iter <= 196; ++slots_iter) + { + if (!slots_blacklist.contains(slots_iter)) + { + int slot_result = 6; + *ScriptLocal("casino_slots"_J, slots_random_results_table + slots_iter).As() = slot_result; + } + } + } + } + } + + virtual void OnDisable() override + { + if (Scripts::SafeToModifyFreemodeBroadcastGlobals() && SCRIPT::GET_NUMBER_OF_THREADS_RUNNING_THE_SCRIPT_WITH_THIS_HASH("casino_slots"_J)) + { + Player casinoSlotsScriptHostPlayer = NETWORK::NETWORK_GET_HOST_OF_SCRIPT("casino_slots", -1, 0); + auto casinoSlotsScriptHostPlayerId = casinoSlotsScriptHostPlayer.GetId(); + auto selfPlayerId = Self::GetPlayer().GetId(); + if (casinoSlotsScriptHostPlayerId != selfPlayerId) + { + Scripts::ForceScriptHost(Scripts::FindScriptThread("casino_slots"_J)); + } + + for (int slots_iter = 3; slots_iter <= 196; ++slots_iter) + { + if (!slots_blacklist.contains(slots_iter)) + { + int slot_result = 6; + std::srand(static_cast(std::time(0)) + slots_iter); + slot_result = std::rand() % 7; // Generates a pseudo random number between 0 and 7 + *ScriptLocal("casino_slots"_J, slots_random_results_table + slots_iter).As() = slot_result; + } + } + } + } + }; + + static CasinoManipulateRigSlotMachines _CasinoManipulateRigSlotMachines{"casinomanipulaterigslotmachines", "Manipulate Rig Slot Machines", "Lets you win the Rig Slot Machines every time"}; + +} \ No newline at end of file diff --git a/src/game/features/recovery/RpMultiplier.cpp b/src/game/features/recovery/RpMultiplier.cpp new file mode 100644 index 0000000..1952190 --- /dev/null +++ b/src/game/features/recovery/RpMultiplier.cpp @@ -0,0 +1,25 @@ +#include "core/commands/Command.hpp" +#include "core/commands/IntCommand.hpp" +#include "game/backend/Tunables.hpp" + +namespace YimMenu::Features +{ + static IntCommand _RpMultiplierInput{"rpmultiplierinput", "RP Multiplier Input", "RP Mulitplier (< 0 = 0 -> No RP)", std::nullopt, std::nullopt, 1}; + + class RPMultiplier : public Command + { + using Command::Command; + + virtual void OnCall() override + { + int state = _RpMultiplierInput.GetState(); + if (state < 0) + { + state = 0; + } + *Tunables::GetTunable("XP_MULTIPLIER"_J).As() = state; + } + }; + + static RPMultiplier _RPMultiplier{"rpmultiplier", "Set RP Multiplier", "Multiplies RP by the given value"}; +} \ No newline at end of file diff --git a/src/game/features/self/GiveMaxAmmo.cpp b/src/game/features/self/GiveMaxAmmo.cpp new file mode 100644 index 0000000..7f9587f --- /dev/null +++ b/src/game/features/self/GiveMaxAmmo.cpp @@ -0,0 +1,21 @@ +#include "core/commands/Command.hpp" +#include "game/backend/Self.hpp" +#include "game/gta/data/Weapons.hpp" + +namespace YimMenu::Features +{ + class GiveMaxAmmo : public Command + { + using Command::Command; + + virtual void OnCall() override + { + for (auto weapon : Data::Weapons) + { + Self::GetPed().SetMaxAmmoForWeapon(weapon); + } + } + }; + + static GiveMaxAmmo _GiveMaxAmmo{"givemaxammo", "Give Max Ammo", "Refills your ammo to max."}; +} \ No newline at end of file diff --git a/src/game/frontend/submenus/Recovery.cpp b/src/game/frontend/submenus/Recovery.cpp index d9dcdb9..600ec02 100644 --- a/src/game/frontend/submenus/Recovery.cpp +++ b/src/game/frontend/submenus/Recovery.cpp @@ -1,8 +1,8 @@ #include "Recovery.hpp" -#include "game/frontend/items/Items.hpp" +#include "Recovery/HeistModifier.hpp" #include "Recovery/StatEditor.hpp" #include "Recovery/Transactions.hpp" -#include "Recovery/HeistModifier.hpp" +#include "game/frontend/items/Items.hpp" namespace YimMenu::Submenus { @@ -10,14 +10,24 @@ namespace YimMenu::Submenus Submenu::Submenu("Recovery") { auto missions = std::make_shared("Missions"); - auto vehiclesGroup = std::make_shared("Vehicles"); + auto casino = std::make_shared("Casino"); + auto generalGroup = std::make_shared("General"); + auto casinoGroup = std::make_shared("CasinoRigSlotMachines"); + generalGroup->AddItem(std::make_shared("playallmissionssolo"_J)); generalGroup->AddItem(std::make_shared("forcelaunchheist"_J)); + generalGroup->AddItem(std::make_shared("rpmultiplierinput"_J)); + generalGroup->AddItem(std::make_shared("rpmultiplier"_J)); + + casinoGroup->AddItem(std::make_shared("casinomanipulaterigslotmachines"_J)); missions->AddItem(generalGroup); + casino->AddItem(casinoGroup); + AddCategory(std::move(missions)); + AddCategory(std::move(casino)); AddCategory(BuildStatEditorMenu()); AddCategory(BuildTransactionsMenu()); AddCategory(BuildHeistModifierMenu()); diff --git a/src/game/frontend/submenus/Self.cpp b/src/game/frontend/submenus/Self.cpp index 3ef7ed8..c2fd0d9 100644 --- a/src/game/frontend/submenus/Self.cpp +++ b/src/game/frontend/submenus/Self.cpp @@ -71,6 +71,7 @@ namespace YimMenu::Submenus weaponsGlobalsGroup->AddItem(std::make_shared("infiniteparachutes"_J)); weaponsGlobalsGroup->AddItem(std::make_shared("ExplosiveAmmo"_J)); weaponsGlobalsGroup->AddItem(std::make_shared("giveallweapons"_J)); + weaponsGlobalsGroup->AddItem(std::make_shared("givemaxammo"_J)); weaponsAimbotGroup->AddItem(std::make_shared("aimbot"_J)); weaponsAimbotGroup->AddItem(std::make_shared("aimbot"_J, std::make_shared("aimbotaimforhead"_J))); @@ -83,4 +84,4 @@ namespace YimMenu::Submenus auto outfitEditorCategory = YimMenu::CreateOutfitsMenu(); AddCategory(std::move(outfitEditorCategory)); } -} +} \ No newline at end of file diff --git a/src/game/gta/Ped.cpp b/src/game/gta/Ped.cpp index 062617e..ed3562e 100644 --- a/src/game/gta/Ped.cpp +++ b/src/game/gta/Ped.cpp @@ -236,4 +236,11 @@ namespace YimMenu ENTITY_ASSERT_VALID(); PED::SET_PED_MAX_TIME_UNDERWATER(GetHandle(), time); } + + void Ped::SetMaxAmmoForWeapon(std::uint32_t hash) + { + int maxAmmo; + WEAPON::GET_MAX_AMMO(GetHandle(), hash, &maxAmmo); + WEAPON::SET_PED_AMMO(GetHandle(), hash, maxAmmo, 0); + } } diff --git a/src/game/gta/Ped.hpp b/src/game/gta/Ped.hpp index a4b3fd9..59098fa 100644 --- a/src/game/gta/Ped.hpp +++ b/src/game/gta/Ped.hpp @@ -48,6 +48,7 @@ namespace YimMenu bool HasWeapon(std::uint32_t hash); void SetInfiniteAmmo(bool infinite); void SetInfiniteClip(bool infinite); + void SetMaxAmmoForWeapon(std::uint32_t hash); // teleport void TeleportTo(const rage::fvector3& pos); // similar to SetPosition, but handles vehicles correctly