From b626140916ce0b84e2d0456e963b79cface1b104 Mon Sep 17 00:00:00 2001 From: maybegreat48 <96936658+maybegreat48@users.noreply.github.com> Date: Mon, 13 May 2024 15:21:34 +0000 Subject: [PATCH] Hide vehicle godmode (#3103) --- src/core/settings.hpp | 3 +- src/gta_pointers.hpp | 6 ++++ src/hooking/hooking.cpp | 1 + src/hooking/hooking.hpp | 3 ++ ...e_physical_script_game_state_data_node.cpp | 29 +++++++++++++++++++ src/pointers.cpp | 9 ++++++ src/views/network/view_spoofing.cpp | 1 + 7 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 src/hooks/spoofing/write_physical_script_game_state_data_node.cpp diff --git a/src/core/settings.hpp b/src/core/settings.hpp index 17a06d67..15b9bcad 100644 --- a/src/core/settings.hpp +++ b/src/core/settings.hpp @@ -689,6 +689,7 @@ namespace big bool spoof_cheater = false; bool spoof_hide_god = true; + bool spoof_hide_veh_god = true; bool spoof_hide_spectate = true; bool spoof_crew_data = false; @@ -707,7 +708,7 @@ namespace big bool voice_chat_audio = false; - NLOHMANN_DEFINE_TYPE_INTRUSIVE(spoofing, hide_from_player_list, spoof_blip, blip_type, spoof_rank, rank, spoof_job_points, job_points, spoof_kd_ratio, kd_ratio, spoof_bad_sport, badsport_type, spoof_player_model, player_model, spoof_cheater, spoof_hide_god, spoof_hide_spectate, spoof_crew_data, crew_tag, rockstar_crew, square_crew_tag, spoof_session_region_type, session_region_type, spoof_session_language, session_language, spoof_session_player_count, session_player_count, spoof_session_bad_sport_status, session_bad_sport, voice_chat_audio) + NLOHMANN_DEFINE_TYPE_INTRUSIVE(spoofing, hide_from_player_list, spoof_blip, blip_type, spoof_rank, rank, spoof_job_points, job_points, spoof_kd_ratio, kd_ratio, spoof_bad_sport, badsport_type, spoof_player_model, player_model, spoof_cheater, spoof_hide_god, spoof_hide_veh_god, spoof_hide_spectate, spoof_crew_data, crew_tag, rockstar_crew, square_crew_tag, spoof_session_region_type, session_region_type, spoof_session_language, session_language, spoof_session_player_count, session_player_count, spoof_session_bad_sport_status, session_bad_sport, voice_chat_audio) } spoofing{}; struct vehicle diff --git a/src/gta_pointers.hpp b/src/gta_pointers.hpp index c4a3e516..1ad4d43c 100644 --- a/src/gta_pointers.hpp +++ b/src/gta_pointers.hpp @@ -17,6 +17,9 @@ class CBlipList; class TimecycleKeyframeData; class CTrainConfig; class CWeaponInfoManager; +class CGameScriptHandlerMgr; +class CPedFactory; +class GtaThread; namespace rage { @@ -30,6 +33,7 @@ namespace rage class netTime; class rlGamerInfo; struct game_skeleton; + class scrProgramTable; } template @@ -368,6 +372,8 @@ namespace big functions::can_create_vehicle m_can_create_vehicle; PVOID m_format_int; + + PVOID m_write_physical_script_game_state_data_node; }; #pragma pack(pop) static_assert(sizeof(gta_pointers) % 8 == 0, "Pointers are not properly aligned"); diff --git a/src/hooking/hooking.cpp b/src/hooking/hooking.cpp index 4c930632..073f08be 100644 --- a/src/hooking/hooking.cpp +++ b/src/hooking/hooking.cpp @@ -144,6 +144,7 @@ namespace big detour_hook_helper::add("FI", g_pointers->m_gta.m_format_int); + detour_hook_helper::add("WPSGSDN", g_pointers->m_gta.m_write_physical_script_game_state_data_node); g_hooking = this; } diff --git a/src/hooking/hooking.hpp b/src/hooking/hooking.hpp index 54c82854..c0b29c8b 100644 --- a/src/hooking/hooking.hpp +++ b/src/hooking/hooking.hpp @@ -38,6 +38,7 @@ class Network; class GtaThread; class CNetworkPlayerMgr; class CNetworkObjectMgr; +class CPhysicalScriptGameStateDataNode; enum class eAckCode : uint32_t; @@ -195,6 +196,8 @@ namespace big static bool can_create_vehicle(); static void format_int(int64_t integer_to_format, char* format_string, size_t size_always_64, bool use_commas); + + static void write_physical_script_game_state_data_node(rage::CPhysical* this_ptr, CPhysicalScriptGameStateDataNode* node); }; class minhook_keepalive diff --git a/src/hooks/spoofing/write_physical_script_game_state_data_node.cpp b/src/hooks/spoofing/write_physical_script_game_state_data_node.cpp new file mode 100644 index 00000000..111da230 --- /dev/null +++ b/src/hooks/spoofing/write_physical_script_game_state_data_node.cpp @@ -0,0 +1,29 @@ +#include "hooking/hooking.hpp" +#include "util/model_info.hpp" + +#include + +namespace big +{ + void hooks::write_physical_script_game_state_data_node(rage::CPhysical* this_ptr, CPhysicalScriptGameStateDataNode* node) + { + g_hooking->get_original()(this_ptr, node); + + auto this_vehicle = (*(CVehicle*(__fastcall**)(char*))(*((DWORD64*)this_ptr - 38) + 0xC0))((char*)this_ptr - 304); + + if (g.spoofing.spoof_hide_veh_god && g_local_player && self::veh) + { + if (g_local_player->m_vehicle && g_local_player->m_vehicle == this_vehicle) + { + node->m_godmode = false; + node->m_bullet_proof = false; + node->m_fire_proof = false; + node->m_smoke_proof = false; + node->m_steam_proof = false; + node->m_collision_proof = false; + node->m_explosion_proof = false; + node->m_melee_proof = false; + } + } + } +} diff --git a/src/pointers.cpp b/src/pointers.cpp index d428d9ad..8e09f6e1 100644 --- a/src/pointers.cpp +++ b/src/pointers.cpp @@ -1773,6 +1773,15 @@ namespace big { g_pointers->m_gta.m_format_int = ptr.as(); } + }, + // Write Physical Script Game State Data Node + { + "WPSGSDN", + "48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 41 56 41 57 48 83 EC 20 4C 8D B1 D0 FE", + [](memory::handle ptr) + { + g_pointers->m_gta.m_write_physical_script_game_state_data_node = ptr.as(); + } } >(); // don't leave a trailing comma at the end diff --git a/src/views/network/view_spoofing.cpp b/src/views/network/view_spoofing.cpp index 79e2e996..f81be846 100644 --- a/src/views/network/view_spoofing.cpp +++ b/src/views/network/view_spoofing.cpp @@ -85,6 +85,7 @@ namespace big ImGui::SeparatorText("SPOOFING_HIDE_FEATURES"_T.data()); ImGui::Checkbox("SPOOFING_HIDE_GOD_MODE"_T.data(), &g.spoofing.spoof_hide_god); + ImGui::Checkbox("SPOOFING_HIDE_VEH_GOD_MODE"_T.data(), &g.spoofing.spoof_hide_veh_god); ImGui::Checkbox("SPOOFING_HIDE_SPECTATE"_T.data(), &g.spoofing.spoof_hide_spectate); ImGui::SeparatorText("CREW"_T.data());