From afd0efd6216ebfd1783273ae25837c76f82840c3 Mon Sep 17 00:00:00 2001 From: gir489 <100792176+gir489returns@users.noreply.github.com> Date: Sat, 2 Dec 2023 05:48:28 -0500 Subject: [PATCH] Added G's Cache to ESP. (#2461) * Redesigned G's Cache to use Globals that are more reliable (and actually work). Refactored START_NEW_SCRIPT_WITH_ARGS to use a static unordered_set so that it's not constantly constructing it each call, and potentially closes #2462 Added Pickup Pool. --- src/core/scr_globals.hpp | 2 + src/core/settings.hpp | 4 +- src/gta_pointers.hpp | 1 + src/native_hooks/am_launcher.hpp | 19 +++---- src/pointers.cpp | 3 +- src/util/pools.hpp | 10 ++++ src/views/esp/view_esp.cpp | 65 ++++++++++++++++++++---- src/views/esp/view_esp.hpp | 2 + src/views/settings/view_esp_settings.cpp | 5 ++ 9 files changed, 91 insertions(+), 20 deletions(-) diff --git a/src/core/scr_globals.hpp b/src/core/scr_globals.hpp index 90ae2175..77df6d0f 100644 --- a/src/core/scr_globals.hpp +++ b/src/core/scr_globals.hpp @@ -62,6 +62,8 @@ namespace big::scr_globals static inline const script_global property_garage(1945123); static inline const script_global property_names(1312228); + + static inline const script_global pickups(2765084); } namespace big::scr_locals diff --git a/src/core/settings.hpp b/src/core/settings.hpp index 701246f3..37c8d0f8 100644 --- a/src/core/settings.hpp +++ b/src/core/settings.hpp @@ -953,13 +953,15 @@ namespace big bool change_esp_color_from_dist = false; bool scale_health_from_dist = false; bool scale_armor_from_dist = false; + bool object_esp = false; + bool show_gs_cache_boxes = false; float distance_threshold[2] = {100.f, 200.f}; ImU32 enemy_color = 4281479904; ImU32 enemy_near_color = 4283794943; ImU32 default_color = 4285713522; ImU32 friend_color = 4293244509; - NLOHMANN_DEFINE_TYPE_INTRUSIVE(esp, enabled, global_render_distance, tracer_render_distance, box_render_distance, tracer, tracer_draw_position, box, health, armor, god, distance, name, change_esp_color_from_dist, scale_health_from_dist, scale_armor_from_dist, distance_threshold, enemy_color, enemy_near_color, default_color, friend_color) + NLOHMANN_DEFINE_TYPE_INTRUSIVE(esp, enabled, global_render_distance, tracer_render_distance, box_render_distance, tracer, tracer_draw_position, box, health, armor, god, distance, name, change_esp_color_from_dist, scale_health_from_dist, scale_armor_from_dist, object_esp, show_gs_cache_boxes, distance_threshold, enemy_color, enemy_near_color, default_color, friend_color) } esp{}; struct session_browser diff --git a/src/gta_pointers.hpp b/src/gta_pointers.hpp index ae7a0896..0c53b7fa 100644 --- a/src/gta_pointers.hpp +++ b/src/gta_pointers.hpp @@ -286,6 +286,7 @@ namespace big GenericPool** m_ped_pool; GenericPool** m_prop_pool; + GenericPool** m_pickup_pool; VehiclePool*** m_vehicle_pool; PVOID m_netfilter_handle_message; diff --git a/src/native_hooks/am_launcher.hpp b/src/native_hooks/am_launcher.hpp index 73e9e777..a1450383 100644 --- a/src/native_hooks/am_launcher.hpp +++ b/src/native_hooks/am_launcher.hpp @@ -4,14 +4,11 @@ namespace big { namespace am_launcher { - inline void START_NEW_SCRIPT_WITH_ARGS(rage::scrNativeCallContext* src) - { - const char* name = src->get_arg(0); - uint64_t* args = src->get_arg(1); - int argc = src->get_arg(2); - int stackSize = src->get_arg(3); + static const std::unordered_set bad_script_hashes = {RAGE_JOAAT("ggsm_arcade"), RAGE_JOAAT("camhedz_arcade"), RAGE_JOAAT("wizard_arcade"), RAGE_JOAAT("puzzle"), RAGE_JOAAT("fm_intro"), RAGE_JOAAT("pilot_school_mp"), RAGE_JOAAT("golf_mp"), RAGE_JOAAT("tennis_network_mp"), RAGE_JOAAT("fm_race_controler"), RAGE_JOAAT("fm_horde_controler"), RAGE_JOAAT("fm_mission_controller"), RAGE_JOAAT("fm_mission_controller_2020"), RAGE_JOAAT("fm_impromptu_dm_controler"), RAGE_JOAAT("fm_deathmatch_controler"), RAGE_JOAAT("fm_bj_race_controler"), RAGE_JOAAT("fm_survival_controller"), RAGE_JOAAT("sctv"), RAGE_JOAAT("am_pi_menu"), RAGE_JOAAT("scroll_arcade_cabinet"), RAGE_JOAAT("grid_arcade_cabinet"), RAGE_JOAAT("degenatron_games"), RAGE_JOAAT("gunslinger_arcade"), RAGE_JOAAT("road_arcade"), RAGE_JOAAT("AM_MP_DRONE")}; - const std::unordered_set bad_script_hashes = {RAGE_JOAAT("ggsm_arcade"), RAGE_JOAAT("camhedz_arcade"), RAGE_JOAAT("wizard_arcade"), RAGE_JOAAT("puzzle"), RAGE_JOAAT("fm_intro"), RAGE_JOAAT("pilot_school_mp"), RAGE_JOAAT("golf_mp"), RAGE_JOAAT("tennis_network_mp"), RAGE_JOAAT("fm_race_controler"), RAGE_JOAAT("fm_horde_controler"), RAGE_JOAAT("fm_mission_controller"), RAGE_JOAAT("fm_mission_controller_2020"), RAGE_JOAAT("fm_impromptu_dm_controler"), RAGE_JOAAT("fm_deathmatch_controler"), RAGE_JOAAT("fm_bj_race_controler"), RAGE_JOAAT("fm_survival_controller"), RAGE_JOAAT("sctv"), RAGE_JOAAT("am_pi_menu"), RAGE_JOAAT("scroll_arcade_cabinet"), RAGE_JOAAT("grid_arcade_cabinet"), RAGE_JOAAT("degenatron_games"), RAGE_JOAAT("gunslinger_arcade"), RAGE_JOAAT("road_arcade"), RAGE_JOAAT("AM_MP_DRONE")}; + static void START_NEW_SCRIPT_WITH_ARGS(rage::scrNativeCallContext* src) + { + const char* const name = src->get_arg(0); if (bad_script_hashes.contains(rage::joaat(name))) { @@ -19,7 +16,11 @@ namespace big return; } - src->set_return_value(SYSTEM::START_NEW_SCRIPT_WITH_ARGS(name, (Any*)args, argc, stackSize)); - }; + Any* args = src->get_arg(1); + const int argc = src->get_arg(2); + const int stackSize = src->get_arg(3); + + src->set_return_value(SYSTEM::START_NEW_SCRIPT_WITH_ARGS(name, args, argc, stackSize)); + } } } \ No newline at end of file diff --git a/src/pointers.cpp b/src/pointers.cpp index e1dc6a80..fb1a8bbd 100644 --- a/src/pointers.cpp +++ b/src/pointers.cpp @@ -1246,10 +1246,11 @@ namespace big // Prop Pool { "PRP", - "48 8B 0D ? ? ? ? 49 8B D0 E8 ? ? ? ? 39 03 EB 19 41 80 78 ? ? 75 15 48 8B 0D ? ? ? ? 49 8B D0 E8 ? ? ? ? 39 43 04", + "48 8B 05 ? ? ? ? 0F B7 50 10 48 8B 05", [](memory::handle ptr) { g_pointers->m_gta.m_prop_pool = ptr.add(3).rip().as(); + g_pointers->m_gta.m_pickup_pool = ptr.add(0xE).rip().as(); } }, // Vehicle Pool diff --git a/src/util/pools.hpp b/src/util/pools.hpp index ad30fe2f..d1283994 100644 --- a/src/util/pools.hpp +++ b/src/util/pools.hpp @@ -18,6 +18,11 @@ namespace big::pools return **g_pointers->m_gta.m_prop_pool; } + inline auto& get_all_pickups() + { + return **g_pointers->m_gta.m_pickup_pool; + } + inline auto get_all_peds_array() { return get_all_peds().to_array(); @@ -32,4 +37,9 @@ namespace big::pools { return get_all_props().to_array(); } + + inline auto get_all_pickups_array() + { + return get_all_pickups().to_array(); + } }; \ No newline at end of file diff --git a/src/views/esp/view_esp.cpp b/src/views/esp/view_esp.cpp index df70044e..15ea54fd 100644 --- a/src/views/esp/view_esp.cpp +++ b/src/views/esp/view_esp.cpp @@ -6,18 +6,19 @@ #include "util/math.hpp" #include "util/misc.hpp" #include "gta/enums.hpp" +#include "core/scr_globals.hpp" namespace big { - static ImColor death_bg = ImColor(0.117f, 0.113f, 0.172f, .75f); - static ImColor armor_blue_bg = ImColor(0.36f, 0.71f, 0.89f, .75f); - static ImColor armor_blue = ImColor(0.36f, 0.71f, 0.89f, 1.f); - static ImColor health_green_bg = ImColor(0.29f, 0.69f, 0.34f, .75f); - static ImColor health_green = ImColor(0.29f, 0.69f, 0.34f, 1.f); - static ImColor health_yellow_bg = ImColor(0.69f, 0.49f, 0.29f, .75f); - static ImColor health_yellow = ImColor(0.69f, 0.49f, 0.29f, 1.f); - static ImColor health_red_bg = ImColor(0.69f, 0.29f, 0.29f, .75f); - static ImColor health_red = ImColor(0.69f, 0.29f, 0.29f, 1.f); + static const ImColor death_bg = ImColor(0.117f, 0.113f, 0.172f, .75f); + static const ImColor armor_blue_bg = ImColor(0.36f, 0.71f, 0.89f, .75f); + static const ImColor armor_blue = ImColor(0.36f, 0.71f, 0.89f, 1.f); + static const ImColor health_green_bg = ImColor(0.29f, 0.69f, 0.34f, .75f); + static const ImColor health_green = ImColor(0.29f, 0.69f, 0.34f, 1.f); + static const ImColor health_yellow_bg = ImColor(0.69f, 0.49f, 0.29f, .75f); + static const ImColor health_yellow = ImColor(0.69f, 0.49f, 0.29f, 1.f); + static const ImColor health_red_bg = ImColor(0.69f, 0.29f, 0.29f, .75f); + static const ImColor health_red = ImColor(0.69f, 0.29f, 0.29f, 1.f); void esp::draw_player(const player_ptr& plyr, ImDrawList* const draw_list) { @@ -172,6 +173,40 @@ namespace big } } + void esp::draw_object(const rage::CDynamicEntity* object, ImDrawList* const draw_list, std::string name) + { + if (!object || !object->m_navigation) + return; + + auto& object_pos = *object->m_navigation->get_position(); + + float screen_x, screen_y; + + const float distance = math::calculate_distance_from_game_cam(object_pos); + const float multplr = distance > g.esp.global_render_distance[1] ? -1.f : 6.17757f / distance; + + if (multplr == -1.f || g.esp.global_render_distance[0] > distance) + return; + + ImVec2 name_pos; + + if (g_pointers->m_gta.m_get_screen_coords_for_world_coords(object_pos.data, &screen_x, &screen_y)) + { + const auto esp_x = (float)*g_pointers->m_gta.m_resolution_x * screen_x; + const auto esp_y = (float)*g_pointers->m_gta.m_resolution_y * screen_y; + name_pos = {esp_x, esp_y}; + } + else + { + return; + } + + ImU32 esp_color = g.esp.default_color; + + draw_list->AddText(name_pos, esp_color, name.c_str()); + } + + void esp::draw() { if (!g.esp.enabled) @@ -182,6 +217,18 @@ namespace big g_player_service->iterate([draw_list](const player_entry& entry) { draw_player(entry.second, draw_list); }); + + if (g.esp.object_esp) + { + if (g.esp.show_gs_cache_boxes && *g_pointers->m_gta.m_script_globals && **g_pointers->m_gta.m_script_globals) + { + auto gs_cache_box_entity = *scr_globals::pickups.at(605).as(); + if (gs_cache_box_entity != 0) + { + draw_object(g_pointers->m_gta.m_handle_to_ptr(gs_cache_box_entity), draw_list, "G's Cache"); + } + } + } } } } \ No newline at end of file diff --git a/src/views/esp/view_esp.hpp b/src/views/esp/view_esp.hpp index 1111d191..f9f23ad1 100644 --- a/src/views/esp/view_esp.hpp +++ b/src/views/esp/view_esp.hpp @@ -1,5 +1,6 @@ #pragma once #include "services/players/player_service.hpp" +#include "entities/CDynamicEntity.hpp" namespace big { @@ -8,5 +9,6 @@ namespace big public: static void draw(); static void draw_player(const player_ptr& plyr, ImDrawList* const draw_list); + static void draw_object(const rage::CDynamicEntity* object, ImDrawList* const draw_list, std::string name); }; } \ No newline at end of file diff --git a/src/views/settings/view_esp_settings.cpp b/src/views/settings/view_esp_settings.cpp index fbe23940..ed6a45f6 100644 --- a/src/views/settings/view_esp_settings.cpp +++ b/src/views/settings/view_esp_settings.cpp @@ -38,6 +38,11 @@ namespace big ImGui::Checkbox("SETTINGS_ESP_PLAYER_GOD_MODE"_T.data(), &g.esp.god); ImGui::Checkbox("SETTINGS_ESP_PLAYER_HEALTH"_T.data(), &g.esp.health); ImGui::Checkbox("SETTINGS_ESP_PLAYER_ARMOR"_T.data(), &g.esp.armor); + ImGui::Checkbox("SETTINGS_ESP_OBJECT_ESP"_T.data(), &g.esp.object_esp); + if (g.esp.object_esp) + { + ImGui::Checkbox("SETTINGS_ESP_OBJECT_ESP_GS_CACHE"_T.data(), &g.esp.show_gs_cache_boxes); + } ImGui::Checkbox("SETTINGS_ESP_COLOR_W_DISTANCE"_T.data(), &g.esp.change_esp_color_from_dist); if (g.esp.health)