From a3d8bf590dfcc772aa09fb3789eadcee8eef4e06 Mon Sep 17 00:00:00 2001 From: "R.K" Date: Mon, 27 May 2024 14:57:19 -0700 Subject: [PATCH] [Bug Fix]: Fixes for Never Wanted "Flickering" in Zancudo/Bolingbroke (#3152) * replace REPORT_CRIME with SET_MAX_WANTED_LEVEL --------- Co-authored-by: gir489 <100792176+gir489returns@users.noreply.github.com> Co-authored-by: Arthur --- src/backend/looped/self/wanted_level.cpp | 25 ++++++++++++++++++++---- src/core/scr_globals.hpp | 5 +++++ src/gta_pointers.hpp | 2 -- src/pointers.cpp | 9 --------- src/views/self/view_self.cpp | 4 +--- 5 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/backend/looped/self/wanted_level.cpp b/src/backend/looped/self/wanted_level.cpp index ab4bbf11..c948200a 100644 --- a/src/backend/looped/self/wanted_level.cpp +++ b/src/backend/looped/self/wanted_level.cpp @@ -1,7 +1,10 @@ #include "backend/command.hpp" -#include "backend/looped_command.hpp" #include "backend/looped/looped.hpp" -#include "pointers.hpp" +#include "backend/looped_command.hpp" +#include "core/scr_globals.hpp" +#include "util/misc.hpp" +#include "gta_util.hpp" +#include "natives.hpp" namespace big { @@ -19,7 +22,7 @@ namespace big // Clear current wanted level g_local_player->m_player_info->m_wanted_level = 0; - g_local_player->m_player_info->m_is_wanted = false; + g_local_player->m_player_info->m_is_wanted = false; // Keep the lock if it's on, but reset the wanted level g.self.wanted_level = 0; @@ -34,7 +37,15 @@ namespace big virtual void on_tick() override { + // Disable never wanted if the script needs to force-modify the wanted level in heists + if (auto script = gta_util::find_script_thread("fm_mission_controller"_J)) + { + if (!misc::has_bit_set(script_local(script, scr_locals::fm_mission_controller::mission_controller_wanted_state_flags).as(), 7)) + return; + } + // Clear current wanted level + PLAYER::SET_MAX_WANTED_LEVEL(0); g_local_player->m_player_info->m_wanted_level = 0; g_local_player->m_player_info->m_is_wanted = false; @@ -42,9 +53,15 @@ namespace big g.self.wanted_level = 0; g.self.force_wanted_level = false; } + + virtual void on_disable() override + { + // There are cases where it is set to 6 in the scripts, but the native automatically reverts it back to 5 anyway + PLAYER::SET_MAX_WANTED_LEVEL(5); + } }; - never_wanted g_never_wanted("neverwanted", "NEVER_WANTED", "NEVER_WANTED", g.self.never_wanted); + never_wanted g_never_wanted("neverwanted", "NEVER_WANTED", "NEVER_WANTED_DESC", g.self.never_wanted); void looped::self_wanted() { diff --git a/src/core/scr_globals.hpp b/src/core/scr_globals.hpp index 98d7d017..13722eea 100644 --- a/src/core/scr_globals.hpp +++ b/src/core/scr_globals.hpp @@ -96,6 +96,11 @@ namespace big::scr_locals constexpr static auto broadcast_idx = 12327; } + namespace fm_mission_controller + { + constexpr static auto mission_controller_wanted_state_flags = 60051; + } + namespace freemode { // first uLocal_ in this function call diff --git a/src/gta_pointers.hpp b/src/gta_pointers.hpp index 43ab495a..9ebb44f2 100644 --- a/src/gta_pointers.hpp +++ b/src/gta_pointers.hpp @@ -45,8 +45,6 @@ namespace big #pragma pack(push, 1) struct gta_pointers { - memory::handle m_max_wanted_level; - PVOID m_world_model_spawn_bypass; memory::handle m_blame_explode; diff --git a/src/pointers.cpp b/src/pointers.cpp index cc323057..e9259d1f 100644 --- a/src/pointers.cpp +++ b/src/pointers.cpp @@ -1418,15 +1418,6 @@ namespace big g_pointers->m_gta.m_delete_object = ptr.as(); } }, - // Max Wanted Level - { - "MWL", - "8B 43 6C 89 05", - [](memory::handle ptr) - { - g_pointers->m_gta.m_max_wanted_level = ptr; - } - }, // World Model Spawn Bypass { "WMSB", diff --git a/src/views/self/view_self.cpp b/src/views/self/view_self.cpp index 6d5266a8..777c7c63 100644 --- a/src/views/self/view_self.cpp +++ b/src/views/self/view_self.cpp @@ -210,9 +210,7 @@ namespace big ImGui::SeparatorText("WANTED_LEVEL"_T.data()); - ImGui::Checkbox("NEVER_WANTED"_T.data(), &g.self.never_wanted); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("NEVER_WANTED_DESC"_T.data()); + components::command_checkbox<"neverwanted">(); // Only show all the other stuff like clear wanted, force wanted, and the slider if we don't have never_wanted enabled, since never_wanted overrides all of that if (!g.self.never_wanted)