From b9f380e49cec795ff731a38c6414aae8ec10d0d0 Mon Sep 17 00:00:00 2001 From: Aure7138 <100095051+Aure7138@users.noreply.github.com> Date: Sat, 11 Feb 2023 05:33:47 +0800 Subject: [PATCH] refactor: c4 limit and some general fixes (#970) --- scripts/gtav-classes.cmake | 2 +- src/backend/backend.cpp | 1 + src/backend/looped/looped.hpp | 1 + src/backend/looped/weapons/c4_limit.cpp | 15 +++++++++++++++ src/core/globals.hpp | 5 +++-- src/pointers.cpp | 8 -------- src/pointers.hpp | 2 -- src/util/entity.hpp | 2 +- src/views/self/view_weapons.cpp | 10 +++------- 9 files changed, 25 insertions(+), 21 deletions(-) create mode 100644 src/backend/looped/weapons/c4_limit.cpp diff --git a/scripts/gtav-classes.cmake b/scripts/gtav-classes.cmake index a15ebe83..8856518f 100644 --- a/scripts/gtav-classes.cmake +++ b/scripts/gtav-classes.cmake @@ -3,7 +3,7 @@ include(FetchContent) FetchContent_Declare( gtav_classes GIT_REPOSITORY https://github.com/Yimura/GTAV-Classes.git - GIT_TAG 4f93aec221704c74daefab2362b88429ac2dc6bc + GIT_TAG 2862a02e24ebfedc60432887e735efef56d83635 GIT_PROGRESS TRUE CONFIGURE_COMMAND "" BUILD_COMMAND "" diff --git a/src/backend/backend.cpp b/src/backend/backend.cpp index 6b051ea6..28ce385e 100644 --- a/src/backend/backend.cpp +++ b/src/backend/backend.cpp @@ -60,6 +60,7 @@ namespace big looped::weapons_repair_gun(); looped::weapons_steal_vehicle_gun(); looped::weapons_vehicle_gun(); + looped::weapons_c4_limit(); script::get_current()->yield(); } diff --git a/src/backend/looped/looped.hpp b/src/backend/looped/looped.hpp index 753bebb6..179fa4fa 100644 --- a/src/backend/looped/looped.hpp +++ b/src/backend/looped/looped.hpp @@ -60,6 +60,7 @@ namespace big static void weapons_repair_gun(); static void weapons_steal_vehicle_gun(); static void weapons_vehicle_gun(); + static void weapons_c4_limit(); static void drive_train(); static void derail_train(); diff --git a/src/backend/looped/weapons/c4_limit.cpp b/src/backend/looped/weapons/c4_limit.cpp new file mode 100644 index 00000000..33ae6473 --- /dev/null +++ b/src/backend/looped/weapons/c4_limit.cpp @@ -0,0 +1,15 @@ +#include "backend/looped/looped.hpp" + +namespace big +{ + void looped::weapons_c4_limit() + { + if (g_local_player) + { + if (g.weapons.increased_c4_limit) + g_local_player->fired_sticky_bombs = 0; + if (g.weapons.increased_flare_limit) + g_local_player->fired_flares = 0; + } + } +} diff --git a/src/core/globals.hpp b/src/core/globals.hpp index 45dd6b79..29d5612e 100644 --- a/src/core/globals.hpp +++ b/src/core/globals.hpp @@ -611,12 +611,13 @@ namespace big bool no_recoil = false; bool no_spread = false; std::string vehicle_gun_model = "bus"; - bool bypass_c4_limit = false; + bool increased_c4_limit = false; + bool increased_flare_limit = false; bool rapid_fire = false; NLOHMANN_DEFINE_TYPE_INTRUSIVE(weapons, ammo_special, custom_weapon, force_crosshairs, infinite_ammo, infinite_mag, increased_damage, no_recoil, - no_spread, vehicle_gun_model, bypass_c4_limit, rapid_fire, gravity_gun) + no_spread, vehicle_gun_model, increased_c4_limit, increased_flare_limit, rapid_fire, gravity_gun) } weapons{}; struct window diff --git a/src/pointers.cpp b/src/pointers.cpp index 06be9e70..f1fe4cfd 100644 --- a/src/pointers.cpp +++ b/src/pointers.cpp @@ -847,14 +847,6 @@ namespace big } else LOG(WARNING) << "socialclub.dll module was not loaded within the time limit."; - if (auto pat = mem_region.scan("41 80 78 28 ? 0F 85 ? ? ? ? 49 8B 80")) - { - m_bypass_max_count_of_active_sticky_bombs = memory::byte_patch::make(pat.add(4).as(), { 99 }).get(); - - if (g.weapons.bypass_c4_limit) - m_bypass_max_count_of_active_sticky_bombs->apply(); - } - /** * Freemode thread restorer through VM patch */ diff --git a/src/pointers.hpp b/src/pointers.hpp index d12730bb..ba5f9128 100644 --- a/src/pointers.hpp +++ b/src/pointers.hpp @@ -134,8 +134,6 @@ namespace big functions::start_get_presence_attributes m_start_get_presence_attributes; functions::join_session_by_info m_join_session_by_info; - memory::byte_patch* m_bypass_max_count_of_active_sticky_bombs; - functions::reset_network_complaints m_reset_network_complaints{}; functions::fidevice_get_device m_fidevice_get_device{}; diff --git a/src/util/entity.hpp b/src/util/entity.hpp index 11241f24..e23ecfcc 100644 --- a/src/util/entity.hpp +++ b/src/util/entity.hpp @@ -58,7 +58,7 @@ namespace big::entity inline bool network_has_control_of_entity(rage::netObject* net_object) { - return net_object && !net_object->m_next_owner_id && (net_object->m_control_id == -1); + return !net_object || !net_object->m_next_owner_id && (net_object->m_control_id == -1); } inline bool take_control_of(Entity ent, int timeout = 300) diff --git a/src/views/self/view_weapons.cpp b/src/views/self/view_weapons.cpp index a0b71152..6eccdc6a 100644 --- a/src/views/self/view_weapons.cpp +++ b/src/views/self/view_weapons.cpp @@ -22,13 +22,9 @@ namespace big ImGui::SameLine(); ImGui::BeginGroup(); - if (ImGui::Checkbox("BYPASS_C4_LIM"_T.data(), &g.weapons.bypass_c4_limit)) - { - if (g.weapons.bypass_c4_limit) - g_pointers->m_bypass_max_count_of_active_sticky_bombs->apply(); - else - g_pointers->m_bypass_max_count_of_active_sticky_bombs->restore(); - } + ImGui::Checkbox("Increased C4 Limit (Max = 50)", &g.weapons.increased_c4_limit); + ImGui::Checkbox("Increased Flare Limit (Max = 50)", &g.weapons.increased_flare_limit); + components::command_checkbox<"rapidfire">(); ImGui::EndGroup();