[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 <redacted@gmail.com>
This commit is contained in:
R.K 2024-05-27 14:57:19 -07:00 committed by GitHub
parent b90a59badb
commit a3d8bf590d
5 changed files with 27 additions and 18 deletions

View File

@ -1,7 +1,10 @@
#include "backend/command.hpp" #include "backend/command.hpp"
#include "backend/looped_command.hpp"
#include "backend/looped/looped.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 namespace big
{ {
@ -34,7 +37,15 @@ namespace big
virtual void on_tick() override 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<PINT>(), 7))
return;
}
// Clear current wanted level // 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_wanted_level = 0;
g_local_player->m_player_info->m_is_wanted = false; g_local_player->m_player_info->m_is_wanted = false;
@ -42,9 +53,15 @@ namespace big
g.self.wanted_level = 0; g.self.wanted_level = 0;
g.self.force_wanted_level = false; 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() void looped::self_wanted()
{ {

View File

@ -96,6 +96,11 @@ namespace big::scr_locals
constexpr static auto broadcast_idx = 12327; constexpr static auto broadcast_idx = 12327;
} }
namespace fm_mission_controller
{
constexpr static auto mission_controller_wanted_state_flags = 60051;
}
namespace freemode namespace freemode
{ {
// first uLocal_ in this function call // first uLocal_ in this function call

View File

@ -45,8 +45,6 @@ namespace big
#pragma pack(push, 1) #pragma pack(push, 1)
struct gta_pointers struct gta_pointers
{ {
memory::handle m_max_wanted_level;
PVOID m_world_model_spawn_bypass; PVOID m_world_model_spawn_bypass;
memory::handle m_blame_explode; memory::handle m_blame_explode;

View File

@ -1418,15 +1418,6 @@ namespace big
g_pointers->m_gta.m_delete_object = ptr.as<functions::delete_object>(); g_pointers->m_gta.m_delete_object = ptr.as<functions::delete_object>();
} }
}, },
// 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 // World Model Spawn Bypass
{ {
"WMSB", "WMSB",

View File

@ -210,9 +210,7 @@ namespace big
ImGui::SeparatorText("WANTED_LEVEL"_T.data()); ImGui::SeparatorText("WANTED_LEVEL"_T.data());
ImGui::Checkbox("NEVER_WANTED"_T.data(), &g.self.never_wanted); components::command_checkbox<"neverwanted">();
if (ImGui::IsItemHovered())
ImGui::SetTooltip("NEVER_WANTED_DESC"_T.data());
// 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 // 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) if (!g.self.never_wanted)