fix: some small fixes

This commit is contained in:
maybegreat48 committed 2025-06-03 12:48:04 -04:00
1 parent 6ef3ef5898
commit 21841afe6b
13 files changed
+233 -71

No files matched your search

+11
View File
@@ -195,4 +195,15 @@ namespace YimMenu
LOG(INFO) << "Loaded " << m_Tunables.size() << " tunables from cache.";
}
bool Tunable::IsReady()
{
if (m_Global)
return true;
m_Global = Tunables::GetTunable(m_Hash);
if (m_Global)
return true;
}
}
+31 -2
View File
@@ -70,14 +70,43 @@ namespace YimMenu
return GetInstance().m_CurrentJunkVal++;
}
static ScriptGlobal GetTunable(joaat_t hash)
static std::optional<ScriptGlobal> GetTunable(joaat_t hash)
{
if (auto it = GetInstance().m_Tunables.find(hash); it != GetInstance().m_Tunables.end())
{
return ScriptGlobal(it->second);
}
return ScriptGlobal(TUNABLE_BASE_ADDRESS); // this is not good
return std::nullopt;
}
};
class Tunable
{
joaat_t m_Hash;
std::optional<ScriptGlobal> m_Global;
public:
constexpr Tunable(joaat_t hash) :
m_Hash(hash),
m_Global(std::nullopt)
{
}
bool IsReady();
// make sure to call IsReady before accessing tunables
template<typename T>
T Get()
{
return *m_Global->As<T*>();
}
// make sure to call IsReady before accessing tunables
template<typename T>
void Set(T new_value)
{
*m_Global->As<T*>() = new_value;
}
};
}
@@ -137,12 +137,48 @@ namespace YimMenu::Features
switch (primary_target)
{
case 0: *Tunables::GetTunable("IH_PRIMARY_TARGET_VALUE_TEQUILA"_J).As<int*>() = _CayoPericoHeistPrimaryTargetValue.GetState(); break;
case 1: *Tunables::GetTunable("IH_PRIMARY_TARGET_VALUE_PEARL_NECKLACE"_J).As<int*>() = _CayoPericoHeistPrimaryTargetValue.GetState(); break;
case 2: *Tunables::GetTunable("IH_PRIMARY_TARGET_VALUE_BEARER_BONDS"_J).As<int*>() = _CayoPericoHeistPrimaryTargetValue.GetState(); break;
case 3: *Tunables::GetTunable("IH_PRIMARY_TARGET_VALUE_PINK_DIAMOND"_J).As<int*>() = _CayoPericoHeistPrimaryTargetValue.GetState(); break;
case 4: *Tunables::GetTunable("IH_PRIMARY_TARGET_VALUE_MADRAZO_FILES"_J).As<int*>() = _CayoPericoHeistPrimaryTargetValue.GetState(); break;
case 5: *Tunables::GetTunable("IH_PRIMARY_TARGET_VALUE_SAPPHIRE_PANTHER_STATUE"_J).As<int*>() = _CayoPericoHeistPrimaryTargetValue.GetState(); break;
case 0:
{
static Tunable tunable{"IH_PRIMARY_TARGET_VALUE_TEQUILA"_J};
if (tunable.IsReady())
tunable.Set(_CayoPericoHeistPrimaryTargetValue.GetState());
break;
}
case 1:
{
static Tunable tunable{"IH_PRIMARY_TARGET_VALUE_PEARL_NECKLACE"_J};
if (tunable.IsReady())
tunable.Set(_CayoPericoHeistPrimaryTargetValue.GetState());
break;
}
case 2:
{
static Tunable tunable{"IH_PRIMARY_TARGET_VALUE_BEARER_BONDS"_J};
if (tunable.IsReady())
tunable.Set(_CayoPericoHeistPrimaryTargetValue.GetState());
break;
}
case 3:
{
static Tunable tunable{"IH_PRIMARY_TARGET_VALUE_PINK_DIAMOND"_J};
if (tunable.IsReady())
tunable.Set(_CayoPericoHeistPrimaryTargetValue.GetState());
break;
}
case 4:
{
static Tunable tunable{"IH_PRIMARY_TARGET_VALUE_MADRAZO_FILES"_J};
if (tunable.IsReady())
tunable.Set(_CayoPericoHeistPrimaryTargetValue.GetState());
break;
}
case 5:
{
static Tunable tunable{"IH_PRIMARY_TARGET_VALUE_SAPPHIRE_PANTHER_STATUE"_J};
if (tunable.IsReady())
tunable.Set(_CayoPericoHeistPrimaryTargetValue.GetState());
break;
}
default: break;
}
}
@@ -261,10 +261,34 @@ namespace YimMenu::Features
switch (primary_target)
{
case 0: *Tunables::GetTunable(static_cast<joaat_t>(-1638885821)).As<int*>() = _DiamondCasinoHeistPotentialTake.GetState(); break; // "Cash"
case 1: *Tunables::GetTunable(static_cast<joaat_t>(-582734553)).As<int*>() = _DiamondCasinoHeistPotentialTake.GetState(); break; // "Gold"
case 2: *Tunables::GetTunable(static_cast<joaat_t>(1934398910)).As<int*>() = _DiamondCasinoHeistPotentialTake.GetState(); break; // "Artwork"
case 3: *Tunables::GetTunable(static_cast<joaat_t>(1277889925)).As<int*>() = _DiamondCasinoHeistPotentialTake.GetState(); break; // "Diamond"
case 0:
{
static Tunable tunable{static_cast<joaat_t>(-1638885821)};
if (tunable.IsReady())
tunable.Set(_DiamondCasinoHeistPotentialTake.GetState());
break;
} // "Cash"
case 1:
{
static Tunable tunable{static_cast<joaat_t>(-582734553)};
if (tunable.IsReady())
tunable.Set(_DiamondCasinoHeistPotentialTake.GetState());
break;
} // "Gold"
case 2:
{
static Tunable tunable{1934398910};
if (tunable.IsReady())
tunable.Set(_DiamondCasinoHeistPotentialTake.GetState());
break;
} // "Artwork"
case 3:
{
static Tunable tunable{1277889925};
if (tunable.IsReady())
tunable.Set(_DiamondCasinoHeistPotentialTake.GetState());
break;
} // "Diamond"
default: break;
}
}
+19 -9
View File
@@ -1,25 +1,35 @@
#include "core/commands/Command.hpp"
#include "core/commands/IntCommand.hpp"
#include "core/commands/LoopedCommand.hpp"
#include "core/commands/FloatCommand.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};
static FloatCommand _RpMultiplierInput{"rpmultiplierinput", "RP Multiplier Input", "RP Mulitplier (< 0 = 0 -> No RP)", std::nullopt, std::nullopt, 1};
class RPMultiplier : public Command
class OverrideRPMultiplier : public LoopedCommand
{
using Command::Command;
using LoopedCommand::LoopedCommand;
virtual void OnCall() override
Tunable m_XPMultiplier{"XP_MULTIPLIER"_J};
virtual void OnTick() override
{
int state = _RpMultiplierInput.GetState();
auto state = _RpMultiplierInput.GetState();
if (state < 0)
{
state = 0;
}
*Tunables::GetTunable("XP_MULTIPLIER"_J).As<float*>() = state;
if (m_XPMultiplier.IsReady())
m_XPMultiplier.Set(state);
}
virtual void OnDisable() override
{
if (m_XPMultiplier.IsReady())
m_XPMultiplier.Set(1.0f);
}
};
static RPMultiplier _RPMultiplier{"rpmultiplier", "Set RP Multiplier", "Multiplies RP by the given value"};
static OverrideRPMultiplier _OverrideRPMultiplier{"overriderpmultiplier", "Override RP Multiplier", "Multiplies RP by the given value"};
}
@@ -0,0 +1,32 @@
#include "core/commands/LoopedCommand.hpp"
#include "game/pointers/Pointers.hpp"
#include "game/gta/ScriptGlobal.hpp"
namespace YimMenu::Features
{
class UnlockGTAPlus : public LoopedCommand
{
using LoopedCommand::LoopedCommand;
bool m_OldGTAPlus;
virtual void OnEnable() override
{
m_OldGTAPlus = *Pointers.HasGTAPlus;
}
virtual void OnTick() override
{
*Pointers.HasGTAPlus = true;
*ScriptGlobal(1963591).As<bool*>() = true;
*ScriptGlobal(1963591).At(3).As<int*>() = (1 << 3) | (1 << 1);
}
virtual void OnDisable() override
{
*Pointers.HasGTAPlus = m_OldGTAPlus;
}
};
static UnlockGTAPlus _UnlockGTAPlus{"unlockgtaplus", "Unlock GTA+", "Force-unlocks GTA+ content. Use with caution"};
}
+17 -12
View File
@@ -7,17 +7,25 @@ namespace YimMenu::Features
{
using LoopedCommand::LoopedCommand;
static constexpr std::array m_TunableHashes = {"IDLEKICK_WARNING1"_J, "IDLEKICK_WARNING2"_J, "IDLEKICK_WARNING3"_J, "IDLEKICK_KICK"_J, "ConstrainedKick_Warning1"_J, "ConstrainedKick_Warning2"_J, "ConstrainedKick_Warning3"_J, "ConstrainedKick_Kick"_J};
static constexpr std::array m_DefaultValues = {120000, 300000, 600000, 900000, 30000, 60000, 90000, 120000};
std::array<Tunable, 8> m_Tunables = std::to_array({
Tunable("IDLEKICK_WARNING1"_J),
Tunable("IDLEKICK_WARNING2"_J),
Tunable("IDLEKICK_WARNING3"_J),
Tunable("IDLEKICK_KICK"_J),
Tunable("ConstrainedKick_Warning1"_J),
Tunable("ConstrainedKick_Warning2"_J),
Tunable("ConstrainedKick_Warning3"_J),
Tunable("ConstrainedKick_Kick"_J),
});
static constexpr auto m_DefaultValues = std::to_array({120000, 300000, 600000, 900000, 30000, 60000, 90000, 120000});
virtual void OnTick() override
{
for (auto tunable : m_TunableHashes)
for (auto& tunable : m_Tunables)
{
if (auto tunablePtr = Tunables::GetTunable(tunable).As<int*>())
{
*tunablePtr = INT_MAX;
}
if (tunable.IsReady())
tunable.Set(INT_MAX);
}
}
@@ -25,11 +33,8 @@ namespace YimMenu::Features
{
for (int i = 0; i < m_DefaultValues.size(); i++)
{
if (auto tunablePtr = Tunables::GetTunable(m_TunableHashes[i]).As<int*>())
{
// TO-DO: Add methods for getting the default script value and cloud value to the Tunables class
*tunablePtr = m_DefaultValues[i];
}
if (m_Tunables[i].IsReady())
m_Tunables[i].Set(m_DefaultValues[i]);
}
}
};
+5 -5
View File
@@ -15,14 +15,14 @@ namespace YimMenu::Submenus
auto generalGroup = std::make_shared<Group>("General");
auto businessGroup = std::make_shared<Group>("General");
auto casinoGroup = std::make_shared<Group>("CasinoRigSlotMachines");
auto casinoGroup = std::make_shared<Group>("Slot Machines");
generalGroup->AddItem(std::make_shared<BoolCommandItem>("playallmissionssolo"_J));
generalGroup->AddItem(std::make_shared<CommandItem>("forcelaunchheist"_J));
generalGroup->AddItem(std::make_shared<IntCommandItem>("rpmultiplierinput"_J));
generalGroup->AddItem(std::make_shared<CommandItem>("rpmultiplier"_J));
generalGroup->AddItem(std::make_shared<BoolCommandItem>("unlockgtaplus"_J));
generalGroup->AddItem(std::make_shared<BoolCommandItem>("overriderpmultiplier"_J));
generalGroup->AddItem(std::make_shared<ConditionalItem>("overriderpmultiplier"_J, std::make_shared<FloatCommandItem>("rpmultiplierinput"_J)));
businessGroup->AddItem(std::make_shared<ListCommandItem>("businesssafe"_J));
businessGroup->AddItem(std::make_shared<CommandItem>("claimsafeearnings"_J));
@@ -96,8 +96,10 @@ namespace YimMenu::Submenus
else
{
// Phantom Car's cooldown is actually 2147483647ms if STANDARDTARGETTINGTIME is not enabled
setCooldown = *Tunables::GetTunable(randomEventCooldowns[event]).As<int*>();
setAvailability = *Tunables::GetTunable(randomEventAvailabilities[event]).As<int*>();
if (auto tunable = Tunables::GetTunable(randomEventCooldowns[event]))
setCooldown = *tunable->As<int*>();
if (auto tunable = Tunables::GetTunable(randomEventAvailabilities[event]))
setAvailability = *tunable->As<int*>();
}
}
@@ -213,7 +215,8 @@ namespace YimMenu::Submenus
}
int numActiveEvents = GetNumLocallyActiveEvents();
int maxActiveEvents = *Tunables::GetTunable("FMREMAXACTIVATEDEVENTS"_J).As<int*>();
static Tunable maxEventsTune{"FMREMAXACTIVATEDEVENTS"_J};
int maxActiveEvents = maxEventsTune.IsReady() ? maxEventsTune.Get<int>() : 0;
if (numActiveEvents >= maxActiveEvents)
ImGui::TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f), "Active Events: %d/%d", numActiveEvents, maxActiveEvents);
else
+5
View File
@@ -36,6 +36,11 @@ namespace YimMenu
return *static_cast<std::add_pointer_t<std::remove_reference_t<T>>>(Get());
}
constexpr bool operator==(const ScriptGlobal& other)
{
return m_Index == other.m_Index;
}
bool CanAccess() const;
private:
+30 -30
View File
@@ -3,7 +3,7 @@
namespace YimMenu
{
static constexpr std::array randomEventNames = {
static constexpr auto randomEventNames = std::to_array({
"Drug Vehicle",
"Movie Props",
"Sleeping Guard",
@@ -25,9 +25,9 @@ namespace YimMenu
"Ghosts Exposed",
"Happy Holidays Hauler",
"Community Outreach"
};
});
static constexpr std::array randomEventScripts = {
static constexpr auto randomEventScripts = std::to_array({
"fm_content_drug_vehicle"_J,
"fm_content_movie_props"_J,
"fm_content_golden_gun"_J,
@@ -49,9 +49,9 @@ namespace YimMenu
"fm_content_ghosthunt"_J,
"fm_content_xmas_truck"_J,
"fm_content_community_outreach"_J
};
});
static constexpr std::array randomEventCooldowns = {
static constexpr auto randomEventCooldowns = std::to_array({
"SUM22_RE_DRUG_VEHICLE_INACTIVE_TIME"_J,
"SUM22_RE_MOVIE_PROPS_INACTIVE_TIME"_J,
"SUM22_RE_GOLDEN_GUN_INACTIVE_TIME"_J,
@@ -72,30 +72,30 @@ namespace YimMenu
"STANDARDCONTROLLERVOLUME_COOLDOWN"_J,
"SUM23_RE_GHOSTHUNT_INACTIVE_TIME"_J,
"XMAS_TRUCK_INACTIVE_TIME"_J,
"RE_COMMUNITY_OUTREACH_INACTIVE_TIME"_J
};
"RE_COMMUNITY_OUTREACH_INACTIVE_TIME"_J,
});
static constexpr std::array randomEventAvailabilities = {
"SUM22_RE_DRUG_VEHICLE_AVAILABLE_TIME"_J,
"SUM22_RE_MOVIE_PROPS_AVAILABLE_TIME"_J,
"SUM22_RE_GOLDEN_GUN_AVAILABLE_TIME"_J,
"SUM22_RE_VEHICLE_LIST_AVAILABLE_TIME"_J,
"STANDARDCONTROLLERVOLUME_AVAILABILITY"_J,
"STANDARDTARGETTINGTIME_AVAILABILITY"_J,
"SSP2_AVAILABILITY"_J,
"SUM22_RE_SMUGGLER_TRAIL_AVAILABLE_TIME"_J,
"NC_SOURCE_TRUCK_AVAILABILITY"_J,
"SUM22_RE_SMUGGLER_PLANE_AVAILABLE_TIME"_J,
"SUM22_RE_CRIME_SCENE_AVAILABLE_TIME"_J,
"SUM22_RE_METAL_DETECTOR_AVAILABLE_TIME"_J,
"XM22_RE_GANG_CONVOY_AVAILABLE_TIME"_J,
"XM22_RE_ROBBERY_AVAILABLE_TIME"_J,
"STANDARD_KEYBIND_AVAILABILITY"_J,
"XM22_RE_BANK_SHOOTOUT_AVAILABLE_TIME"_J,
(joaat_t)NULL,
"STANDARDCONTROLLERVOLUME_AVAILABILITY"_J,
"SUM23_RE_GHOSTHUNT_AVAILABLE_TIME"_J,
"XMAS_TRUCK_AVAILABLE_TIME"_J,
"RE_COMMUNITY_OUTREACH_AVAILABLE_TIME"_J
};
static constexpr auto randomEventAvailabilities = std::to_array({
"SUM22_RE_DRUG_VEHICLE_AVAILABLE_TIME"_J,
"SUM22_RE_MOVIE_PROPS_AVAILABLE_TIME"_J,
"SUM22_RE_GOLDEN_GUN_AVAILABLE_TIME"_J,
"SUM22_RE_VEHICLE_LIST_AVAILABLE_TIME"_J,
"STANDARDCONTROLLERVOLUME_AVAILABILITY"_J,
"STANDARDTARGETTINGTIME_AVAILABILITY"_J,
"SSP2_AVAILABILITY"_J,
"SUM22_RE_SMUGGLER_TRAIL_AVAILABLE_TIME"_J,
"NC_SOURCE_TRUCK_AVAILABILITY"_J,
"SUM22_RE_SMUGGLER_PLANE_AVAILABLE_TIME"_J,
"SUM22_RE_CRIME_SCENE_AVAILABLE_TIME"_J,
"SUM22_RE_METAL_DETECTOR_AVAILABLE_TIME"_J,
"XM22_RE_GANG_CONVOY_AVAILABLE_TIME"_J,
"XM22_RE_ROBBERY_AVAILABLE_TIME"_J,
"STANDARD_KEYBIND_AVAILABILITY"_J,
"XM22_RE_BANK_SHOOTOUT_AVAILABLE_TIME"_J,
(joaat_t)NULL,
"STANDARDCONTROLLERVOLUME_AVAILABILITY"_J,
"SUM23_RE_GHOSTHUNT_AVAILABLE_TIME"_J,
"XMAS_TRUCK_AVAILABLE_TIME"_J,
"RE_COMMUNITY_OUTREACH_AVAILABLE_TIME"_J,
});
}
+6
View File
@@ -369,6 +369,12 @@ namespace YimMenu
StatsMpCharacterMappingData = ptr.Add(3).Rip().As<CStatsMpCharacterMappingData*>();
});
static constexpr auto scMembershipStuffPtrn = Pattern<"48 8D 15 ? ? ? ? 41 B8 18 02 00 00 E8">("ScMembershipStuff");
scanner.Add(scMembershipStuffPtrn, [this](PointerCalculator addr) {
HasGTAPlus = addr.Add(3).Rip().As<int*>();
});
if (!scanner.Scan())
{
LOG(FATAL) << "Some patterns could not be found, unloading.";
+1
View File
@@ -148,6 +148,7 @@ namespace YimMenu
BytePatch SetJoinRequestPoolTypePatch;
BytePatch HandleJoinRequestIgnorePoolPatch;
CStatsMpCharacterMappingData* StatsMpCharacterMappingData;
int* HasGTAPlus;
};
struct Pointers : PointerData