diff --git a/src/byte_patch_manager.cpp b/src/byte_patch_manager.cpp index 4837a271..9d1a7140 100644 --- a/src/byte_patch_manager.cpp +++ b/src/byte_patch_manager.cpp @@ -4,8 +4,8 @@ #include "hooking.hpp" #include "memory/byte_patch.hpp" #include "pointers.hpp" +#include "util/explosion_anti_cheat_bypass.hpp" #include "util/police.hpp" -#include "util/toxic.hpp" #include "util/vehicle.hpp" extern "C" void sound_overload_detour(); @@ -22,9 +22,9 @@ namespace big memory::byte_patch::make(g_pointers->m_gta.m_max_wanted_level.add(14).rip().as(), 0).get(); // Patch blocked explosions - toxic::explosion_anti_cheat_bypass::m_can_blame_others = + explosion_anti_cheat_bypass::m_can_blame_others = memory::byte_patch::make(g_pointers->m_gta.m_blame_explode.as(), 0xE990).get(); - toxic::explosion_anti_cheat_bypass::m_can_use_blocked_explosions = + explosion_anti_cheat_bypass::m_can_use_blocked_explosions = memory::byte_patch::make(g_pointers->m_gta.m_explosion_patch.sub(12).as(), 0x9090).get(); // Skip matchmaking session validity checks diff --git a/src/lua/natives/lua_native_binding_FIRE.cpp b/src/lua/natives/lua_native_binding_FIRE.cpp index 9f0021f8..41ab2aa7 100644 --- a/src/lua/natives/lua_native_binding_FIRE.cpp +++ b/src/lua/natives/lua_native_binding_FIRE.cpp @@ -1,5 +1,6 @@ #include "lua_native_binding.hpp" #include "natives.hpp" +#include "util/explosion_anti_cheat_bypass.hpp" namespace lua::native { @@ -63,7 +64,11 @@ namespace lua::native static void LUA_NATIVE_FIRE_ADD_OWNED_EXPLOSION(Ped ped, float x, float y, float z, int explosionType, float damageScale, bool isAudible, bool isInvisible, float cameraShake) { + big::explosion_anti_cheat_bypass::apply(); + FIRE::ADD_OWNED_EXPLOSION(ped, x, y, z, explosionType, damageScale, isAudible, isInvisible, cameraShake); + + big::explosion_anti_cheat_bypass::restore(); } static void LUA_NATIVE_FIRE_ADD_EXPLOSION_WITH_USER_VFX(float x, float y, float z, int explosionType, Hash explosionFx, float damageScale, bool isAudible, bool isInvisible, float cameraShake) diff --git a/src/lua/natives/natives_gen.py b/src/lua/natives/natives_gen.py index 8ff5af3a..944d914a 100644 --- a/src/lua/natives/natives_gen.py +++ b/src/lua/natives/natives_gen.py @@ -95,6 +95,9 @@ class NativeFunc: s += "\n" s += "\t{\n" + if self.cpp_name == "ADD_OWNED_EXPLOSION": + s+= "\t\tbig::explosion_anti_cheat_bypass::apply();\n\n" + call_native = "\t\t" if len(self.out_params) > 0: if returning_multiple_values: @@ -127,6 +130,9 @@ class NativeFunc: s += call_native + if self.cpp_name == "ADD_OWNED_EXPLOSION": + s+= "\n\n\t\tbig::explosion_anti_cheat_bypass::restore();" + if returning_multiple_values: assign_return_values = "\n" if self.return_type != "void": @@ -262,6 +268,8 @@ def generate_native_binding_cpp_and_hpp_files(functions_per_namespaces): file_buffer += '#include "lua_native_binding.hpp"\n' file_buffer += '#include "natives.hpp"\n' + if namespace_name == "FIRE": + file_buffer += '#include "util/explosion_anti_cheat_bypass.hpp"\n' file_buffer += "\n" file_buffer += "namespace lua::native\n" file_buffer += "{\n" diff --git a/src/util/explosion_anti_cheat_bypass.hpp b/src/util/explosion_anti_cheat_bypass.hpp new file mode 100644 index 00000000..2a08a70f --- /dev/null +++ b/src/util/explosion_anti_cheat_bypass.hpp @@ -0,0 +1,23 @@ +#pragma once +#include "memory/byte_patch.hpp" + +namespace big +{ + struct explosion_anti_cheat_bypass + { + inline static memory::byte_patch* m_can_blame_others; + inline static memory::byte_patch* m_can_use_blocked_explosions; + + inline static void apply() + { + explosion_anti_cheat_bypass::m_can_blame_others->apply(); + explosion_anti_cheat_bypass::m_can_use_blocked_explosions->apply(); + } + + inline static void restore() + { + explosion_anti_cheat_bypass::m_can_use_blocked_explosions->restore(); + explosion_anti_cheat_bypass::m_can_blame_others->restore(); + } + }; +} \ No newline at end of file diff --git a/src/util/toxic.hpp b/src/util/toxic.hpp index d247645d..3cbce82c 100644 --- a/src/util/toxic.hpp +++ b/src/util/toxic.hpp @@ -5,6 +5,7 @@ #include "gta/pickup_rewards.hpp" #include "pointers.hpp" #include "services/gta_data/gta_data_service.hpp" +#include "util/explosion_anti_cheat_bypass.hpp" #include "util/scripts.hpp" #include "util/session.hpp" #include "util/system.hpp" @@ -18,16 +19,9 @@ namespace big::toxic { - struct explosion_anti_cheat_bypass - { - inline static memory::byte_patch* m_can_blame_others; - inline static memory::byte_patch* m_can_use_blocked_explosions; - }; - inline void blame_explode_coord(player_ptr to_blame, Vector3 pos, eExplosionTag explosion_type, float damage, bool is_audible, bool is_invisible, float camera_shake) { - explosion_anti_cheat_bypass::m_can_blame_others->apply(); - explosion_anti_cheat_bypass::m_can_use_blocked_explosions->apply(); + explosion_anti_cheat_bypass::apply(); FIRE::ADD_OWNED_EXPLOSION( (*g_pointers->m_gta.m_is_session_started && to_blame) ? PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(to_blame->id()) : 0, @@ -40,8 +34,7 @@ namespace big::toxic is_invisible, camera_shake); - explosion_anti_cheat_bypass::m_can_use_blocked_explosions->restore(); - explosion_anti_cheat_bypass::m_can_blame_others->restore(); + explosion_anti_cheat_bypass::restore(); } inline void blame_explode_player(player_ptr to_blame, player_ptr target, eExplosionTag explosion_type, float damage, bool is_audible, bool is_invisible, float camera_shake)