From 3b714f5c67d57c75de532ee17df17d01633cf83a Mon Sep 17 00:00:00 2001 From: gir489 <100792176+gir489returns@users.noreply.github.com> Date: Thu, 9 Nov 2023 04:34:00 -0500 Subject: [PATCH] fix: Health decuction while in god mode (#2398) Closes #2164 Closes #2397 Closes #2399 --- src/backend/looped/world/groundsnow.cpp | 25 ----------------------- src/native_hooks/all_scripts.hpp | 15 +++++++++++++- src/native_hooks/native_hooks.cpp | 1 + src/views/world/view_time_and_weather.cpp | 2 -- src/views/world/view_world.cpp | 2 +- 5 files changed, 16 insertions(+), 29 deletions(-) delete mode 100644 src/backend/looped/world/groundsnow.cpp diff --git a/src/backend/looped/world/groundsnow.cpp b/src/backend/looped/world/groundsnow.cpp deleted file mode 100644 index 2fb3004e..00000000 --- a/src/backend/looped/world/groundsnow.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "backend/looped_command.hpp" -#include "fiber_pool.hpp" -#include "gta_util.hpp" -#include "script.hpp" -#include "services/tunables/tunables_service.hpp" - -namespace big -{ - class ground_snow : looped_command - { - using looped_command::looped_command; - - virtual void on_tick() override - { - g_tunables_service->set_tunable(RAGE_JOAAT("TURN_SNOW_ON_OFF"), true); - } - - virtual void on_disable() override - { - g_tunables_service->set_tunable(RAGE_JOAAT("TURN_SNOW_ON_OFF"), false); - } - }; - - ground_snow g_ground_snow("groundsnow", "BACKEND_LOOPED_WORLD_GROUND_SNOW", "BACKEND_LOOPED_WORLD_GROUND_SNOW_DESC", g.world.ground_snow); -} \ No newline at end of file diff --git a/src/native_hooks/all_scripts.hpp b/src/native_hooks/all_scripts.hpp index c83d7eb8..b6f3f779 100644 --- a/src/native_hooks/all_scripts.hpp +++ b/src/native_hooks/all_scripts.hpp @@ -146,7 +146,7 @@ namespace big void SET_ENTITY_HEALTH(rage::scrNativeCallContext* src) { - Entity entity = src->get_arg(0); + Entity entity = src->get_arg(0); int health = src->get_arg(1); int p2 = src->get_arg(2); @@ -156,6 +156,19 @@ namespace big ENTITY::SET_ENTITY_HEALTH(entity, health, p2); } + void APPLY_DAMAGE_TO_PED(rage::scrNativeCallContext* src) + { + Ped ped = src->get_arg(0); + int damage = src->get_arg(1); + BOOL damage_armor_first = src->get_arg(2); + Any p3 = src->get_arg(3); + + if (g.self.god_mode && ped == self::ped) + return; + + PED::APPLY_DAMAGE_TO_PED(ped, damage, damage_armor_first, p3); + } + void RETURN_TRUE(rage::scrNativeCallContext* src) { src->set_return_value(TRUE); diff --git a/src/native_hooks/native_hooks.cpp b/src/native_hooks/native_hooks.cpp index 63a313fc..9c497d99 100644 --- a/src/native_hooks/native_hooks.cpp +++ b/src/native_hooks/native_hooks.cpp @@ -115,6 +115,7 @@ namespace big add_native_detour(0x158C16F5E4CF41F8, all_scripts::RETURN_TRUE); // bypass casino country restrictions add_native_detour(0xE679E3E06E363892, all_scripts::NETWORK_OVERRIDE_CLOCK_TIME); add_native_detour(0x6B76DC1F3AE6E6A3, all_scripts::SET_ENTITY_HEALTH); + add_native_detour(0x697157CED63F18D4, all_scripts::APPLY_DAMAGE_TO_PED); add_native_detour(0x40EB1EFD921822BC, all_scripts::DO_NOTHING); // SECURITY::REGISTER_SCRIPT_VARIABLE add_native_detour(0x340A36A700E99699, all_scripts::DO_NOTHING); // SECURITY::UNREGISTER_SCRIPT_VARIABLE add_native_detour(0x8E580AB902917360, all_scripts::DO_NOTHING); // SECURITY::FORCE_CHECK_SCRIPT_VARIABLES diff --git a/src/views/world/view_time_and_weather.cpp b/src/views/world/view_time_and_weather.cpp index 2282dfd2..ba505d98 100644 --- a/src/views/world/view_time_and_weather.cpp +++ b/src/views/world/view_time_and_weather.cpp @@ -40,7 +40,5 @@ namespace big } components::command_checkbox<"blackout">(); - - components::command_checkbox<"groundsnow">(); } } diff --git a/src/views/world/view_world.cpp b/src/views/world/view_world.cpp index 83a22b16..b678a6a6 100644 --- a/src/views/world/view_world.cpp +++ b/src/views/world/view_world.cpp @@ -46,7 +46,7 @@ namespace big if (!PED::IS_PED_A_PLAYER(ped)) { auto relation = PED::GET_RELATIONSHIP_BETWEEN_PEDS(ped, self::ped); - if (relation == 4 || relation == 5) + if (relation == 4 || relation == 5 || relation == 3) ped::kill_ped(ped); } }