From ac6e363375720bf4ef48dfa83f47ecf1912131cb Mon Sep 17 00:00:00 2001 From: maybegreat48 <96936658+maybegreat48@users.noreply.github.com> Date: Thu, 10 Apr 2025 10:53:03 -0400 Subject: [PATCH] feat: improve play all missions solo --- src/core/memory/Pattern.cpp | 5 +- .../features/recovery/PlayAllMissionsSolo.cpp | 88 ++++++++++++++++++- .../submenus/network/RandomEvents.cpp | 1 + src/types/script/scrProgram.hpp | 10 +-- 4 files changed, 94 insertions(+), 10 deletions(-) diff --git a/src/core/memory/Pattern.cpp b/src/core/memory/Pattern.cpp index 7926e4e..b98aa76 100644 --- a/src/core/memory/Pattern.cpp +++ b/src/core/memory/Pattern.cpp @@ -36,7 +36,7 @@ namespace YimMenu { const auto size_minus_one = ida_sig.size() - 1; m_Bytes.reserve(size_minus_one / 2); - for (size_t i = 0; i != size_minus_one; ++i) + for (size_t i = 0; i < size_minus_one; ++i) { if (ida_sig[i] == ' ') continue; @@ -47,11 +47,14 @@ namespace YimMenu if (c1 && c2) { m_Bytes.emplace_back(static_cast((*c1 * 0x10) + *c2)); + i++; } } else { m_Bytes.push_back({}); + if (ida_sig[i + 1] == '?') + i++; } } } diff --git a/src/game/features/recovery/PlayAllMissionsSolo.cpp b/src/game/features/recovery/PlayAllMissionsSolo.cpp index 742fe60..0cd4f37 100644 --- a/src/game/features/recovery/PlayAllMissionsSolo.cpp +++ b/src/game/features/recovery/PlayAllMissionsSolo.cpp @@ -12,6 +12,13 @@ namespace YimMenu::Features ScriptPatch m_MissionRequestPatch2{}; ScriptPatch m_MissionRequestPatch3{}; ScriptPatch m_MissionRequestPatch4{}; + ScriptPatch m_PlayerCountWatchdogPatch1{}; + ScriptPatch m_PlayerCountWatchdogPatch2{}; + ScriptPatch m_HeistTeamsPatch{}; + ScriptPatch m_ShouldFailMissionPatch1{}; // god I hate this function + std::vector m_ShouldFailMissionPatches{}; + ScriptPatch m_ShouldFailMissionPatch2{}; + ScriptPatch m_EnsureMissionPassedPatch{}; virtual void OnEnable() override { @@ -29,7 +36,7 @@ namespace YimMenu::Features if (!m_MissionRequestPatch2) { - m_MissionRequestPatch2 = ScriptPatches::AddPatch("freemode"_J, "25 ? 37 07 33 37 07 5D ? ? ? 39 11", 20, {0x48}); + m_MissionRequestPatch2 = ScriptPatches::AddPatch("freemode"_J, "25 ? 37 07 33 37 07 5D ? ? ? 39 11", 20, {0x72}); } m_MissionRequestPatch2->Enable(); @@ -44,6 +51,52 @@ namespace YimMenu::Features m_MissionRequestPatch4 = ScriptPatches::AddPatch("freemode"_J, "5D ? ? ? 39 06 38 01 5D ? ? ? 25", 0, {0x72, 0x2E, 0x04, 0x01}); } m_MissionRequestPatch4->Enable(); + + if (!m_PlayerCountWatchdogPatch1) + { + m_PlayerCountWatchdogPatch1 = ScriptPatches::AddPatch("fmmc_launcher"_J, "2D 02 09 00 00 25 A4", 5, {0x71, 0x2E, 0x02, 0x01}); + } + m_PlayerCountWatchdogPatch1->Enable(); + + if (!m_PlayerCountWatchdogPatch2) + { + m_PlayerCountWatchdogPatch2 = ScriptPatches::AddPatch("fmmc_launcher"_J, "2D 04 0B 00 00 2C ? ? ? 71 5D", 5, {0x71, 0x2E, 0x04, 0x01}); + } + m_PlayerCountWatchdogPatch2->Enable(); + + if (!m_HeistTeamsPatch) + { + m_HeistTeamsPatch = ScriptPatches::AddPatch("fmmc_launcher"_J, "47 ? ? 5B 7B 00 38 04", 0, {0x2B, 0x2B, 0x00, 0x55}); + } + m_HeistTeamsPatch->Enable(); + + if (!m_ShouldFailMissionPatch1) + { + m_ShouldFailMissionPatch1 = ScriptPatches::AddPatch("fm_mission_controller"_J, "50 ? ? 78 82 06 1F 56 ? ? 38 02", 0, {0x00, 0x00, 0x00, 0x72, 0x00}); + } + m_ShouldFailMissionPatch1->Enable(); + + if (m_ShouldFailMissionPatches.empty()) + { + // TODO: this is a very bad idea that can break anytime + for (int i = 0; i < 4; i++) + m_ShouldFailMissionPatches.push_back(ScriptPatches::AddPatch("fm_mission_controller"_J, "38 02 5D ? ? ? 71 09 2A 56 07 00 71 5D ? ? ? 06 1F 56", 0, {0x71, 0x00, 0x00, 0x00, 0x00, 0x00})); + } + + for (auto& patch : m_ShouldFailMissionPatches) + patch->Enable(); + + if (!m_ShouldFailMissionPatch2) + { + m_ShouldFailMissionPatch2 = ScriptPatches::AddPatch("fm_mission_controller"_J, "56 07 00 38 02 5D ? ? ? 20 56 BC 01", 0, {0x2B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2B, 0x71}); + } + m_ShouldFailMissionPatch2->Enable(); + + if (!m_EnsureMissionPassedPatch) + { + m_EnsureMissionPassedPatch = ScriptPatches::AddPatch("fm_mission_controller"_J, "55 C8 FF 61", 3, {0x2E, 0x00, 0x00}); + } + m_EnsureMissionPassedPatch->Enable(); } virtual void OnDisable() override @@ -72,6 +125,39 @@ namespace YimMenu::Features { m_MissionRequestPatch4->Disable(); } + + if (m_PlayerCountWatchdogPatch2) + { + m_PlayerCountWatchdogPatch2->Disable(); + } + + if (m_PlayerCountWatchdogPatch2) + { + m_PlayerCountWatchdogPatch2->Disable(); + } + + if (m_HeistTeamsPatch) + { + m_HeistTeamsPatch->Disable(); + } + + if (m_ShouldFailMissionPatch1) + { + m_ShouldFailMissionPatch1->Disable(); + } + + for (auto& patch : m_ShouldFailMissionPatches) + patch->Disable(); + + if (m_ShouldFailMissionPatch2) + { + m_ShouldFailMissionPatch2->Disable(); + } + + if (m_EnsureMissionPassedPatch) + { + m_EnsureMissionPassedPatch->Disable(); + } } }; diff --git a/src/game/frontend/submenus/network/RandomEvents.cpp b/src/game/frontend/submenus/network/RandomEvents.cpp index f4e65be..aafa7f1 100644 --- a/src/game/frontend/submenus/network/RandomEvents.cpp +++ b/src/game/frontend/submenus/network/RandomEvents.cpp @@ -162,6 +162,7 @@ namespace YimMenu::Submenus switch (GSBDRandomEvents->EventData[event].State) { case eRandomEventState::INACTIVE: + case eRandomEventState::CLEANUP: ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 0.0f, 0.0f, 1.0f)); break; case eRandomEventState::AVAILABLE: diff --git a/src/types/script/scrProgram.hpp b/src/types/script/scrProgram.hpp index 037ef79..c1c38fd 100644 --- a/src/types/script/scrProgram.hpp +++ b/src/types/script/scrProgram.hpp @@ -45,7 +45,7 @@ namespace rage if (page < num) { if (page == num - 1) - return m_CodeSize & 0x3FFF; + return (m_CodeSize & 0x3FFF); return 0x4000; } @@ -54,13 +54,7 @@ namespace rage std::uint32_t GetFullCodeSize() const { - auto numPages = GetNumCodePages(); - if (!numPages) - return 0; - if (numPages == 1) - --numPages; - - return (numPages * 0x4000) + (m_CodeSize & 0x3FFF); + return m_CodeSize; } std::uint8_t* GetCodePage(std::uint32_t page) const