diff --git a/BigBaseV2/src/common.hpp b/BigBaseV2/src/common.hpp index 3ebdf09e..5a6afe81 100644 --- a/BigBaseV2/src/common.hpp +++ b/BigBaseV2/src/common.hpp @@ -66,7 +66,7 @@ namespace big inline HMODULE g_hmodule{}; inline HANDLE g_main_thread{}; inline DWORD g_main_thread_id{}; - inline std::atomic_bool g_running{ true }; + inline std::atomic_bool g_running{ false }; inline CPed* g_local_player; } diff --git a/BigBaseV2/src/core/globals.hpp b/BigBaseV2/src/core/globals.hpp index 24158532..89b15ac8 100644 --- a/BigBaseV2/src/core/globals.hpp +++ b/BigBaseV2/src/core/globals.hpp @@ -149,6 +149,21 @@ namespace big int y; }; + struct esp + { + bool enabled = true; + float global_render_distance[2] = {0.f, 600.f}; + float tracer_render_distance[2] = {200.f, 600.f}; + float box_render_distance[2] = {0.f, 150.f}; + bool tracer = true; + bool box = true; + bool health = true; + bool god = true; + bool distance = true; + bool name = true; + ImU32 color = 3359983061; + }; + public: int friend_count = 0; int player_count = 0; @@ -163,6 +178,7 @@ namespace big vehicle vehicle{}; weapons weapons{}; window window{}; + esp esp{}; menu_settings(file save_file) : m_save_file(std::move(save_file)) @@ -249,6 +265,21 @@ namespace big this->window.log = j["window"]["log"]; this->window.main = j["window"]["main"]; this->window.users = j["window"]["users"]; + + this->esp.enabled = j["esp"]["enabled"]; + this->esp.color = j["esp"]["color"]; + this->esp.box = j["esp"]["box"]; + this->esp.distance = j["esp"]["distance"]; + this->esp.god = j["esp"]["god"]; + this->esp.health = j["esp"]["health"]; + this->esp.name = j["esp"]["name"]; + for (int i = 0; i < 2; i++) + this->esp.global_render_distance[i] = j["esp"]["global_render_distance"].at(i); + for (int i = 0; i < 2; i++) + this->esp.tracer_render_distance[i] = j["esp"]["tracer_render_distance"].at(i); + for (int i = 0; i < 2; i++) + this->esp.box_render_distance[i] = j["esp"]["box_render_distance"].at(i); + this->esp.tracer = j["esp"]["tracer"]; } nlohmann::json to_json() @@ -372,6 +403,30 @@ namespace big { "main", this->window.main }, { "users", this->window.users } } + }, + { + "esp", { + { "enabled", this->esp.enabled }, + { "global_render_distance", nlohmann::json::array({ + this->esp.global_render_distance[0], + this->esp.global_render_distance[1] }) + }, + { "tracer_render_distance", nlohmann::json::array({ + this->esp.tracer_render_distance[0], + this->esp.tracer_render_distance[1] }) + }, + { "box_render_distance", nlohmann::json::array({ + this->esp.box_render_distance[0], + this->esp.box_render_distance[1] }) + }, + { "color", this->esp.color }, + { "distance", this->esp.distance }, + { "box", this->esp.box }, + { "god", this->esp.god }, + { "health", this->esp.health }, + { "name", this->esp.name }, + { "tracer", this->esp.tracer } + } } }; } diff --git a/BigBaseV2/src/function_types.hpp b/BigBaseV2/src/function_types.hpp index 61db9b63..a5b987b1 100644 --- a/BigBaseV2/src/function_types.hpp +++ b/BigBaseV2/src/function_types.hpp @@ -19,6 +19,10 @@ namespace big::functions using ptr_to_handle = Object(rage::CObject* object); + using get_screen_coords_for_world_coords = bool(float* world_coords, float* out_x, float* out_y); + + using get_gameplay_cam_coords = Vector3(); + // Received Event Signatures START using read_bitbuf_array = bool(rage::datBitBuffer* buffer, PVOID read, int bits, int); using read_bitbuf_dword = bool(rage::datBitBuffer* buffer, PVOID read, int bits); diff --git a/BigBaseV2/src/main.cpp b/BigBaseV2/src/main.cpp index 041957db..a2f9f731 100644 --- a/BigBaseV2/src/main.cpp +++ b/BigBaseV2/src/main.cpp @@ -80,6 +80,8 @@ BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID) g_hooking->enable(); LOG(INFO) << "Hooking enabled."; + g_running = true; + while (g_running) std::this_thread::sleep_for(500ms); diff --git a/BigBaseV2/src/pointers.cpp b/BigBaseV2/src/pointers.cpp index d4658a79..874a3947 100644 --- a/BigBaseV2/src/pointers.cpp +++ b/BigBaseV2/src/pointers.cpp @@ -237,6 +237,18 @@ namespace big { m_friend_registry = ptr.add(2).rip().as(); }); + + main_batch.add("GET_SCREEN_COORDS_FROM_WORLD_COORDS", "E8 ? ? ? ? 84 C0 74 19 F3 0F 10 44 24", [this](memory::handle ptr) + { + m_get_screen_coords_for_world_coords = ptr.add(1).rip().as(); + }); + + // Get Gameplay Cam Coords + main_batch.add("GGCC", "40 53 48 83 EC 20 48 8B D9 E8 ? ? ? ? 8B 90 ? ? ? ? 89 13 8B 90 ? ? ? ? 8B 80 ? ? ? ? 89 43 10 89 53 08 48 8B C3 48 83 C4 20 5B C3", [this](memory::handle ptr) + { + m_get_gamplay_cam_coords = ptr.as(); + }); + main_batch.run(memory::module(nullptr)); diff --git a/BigBaseV2/src/pointers.hpp b/BigBaseV2/src/pointers.hpp index bc63ce52..7512ff96 100644 --- a/BigBaseV2/src/pointers.hpp +++ b/BigBaseV2/src/pointers.hpp @@ -50,6 +50,8 @@ namespace big FriendRegistry* m_friend_registry{}; + functions::get_screen_coords_for_world_coords* m_get_screen_coords_for_world_coords{}; + functions::get_net_game_player* m_get_net_game_player{}; PVOID m_gta_thread_start{}; @@ -61,6 +63,8 @@ namespace big PVOID m_player_has_joined{}; PVOID m_player_has_left{}; + functions::get_gameplay_cam_coords* m_get_gamplay_cam_coords; + functions::increment_stat_event* m_increment_stat_event{}; PVOID m_scripted_game_event{}; diff --git a/BigBaseV2/src/services/player_service.hpp b/BigBaseV2/src/services/player_service.hpp index 8d26bebe..c8380301 100644 --- a/BigBaseV2/src/services/player_service.hpp +++ b/BigBaseV2/src/services/player_service.hpp @@ -15,6 +15,9 @@ namespace big player(CNetGamePlayer* net_game_player); virtual ~player() = default; + float screen_position_x = -1.f; + float screen_position_y = -1.f; + CAutomobile* get_current_vehicle(); const char* get_name(); rage::netPlayerData* get_net_data(); diff --git a/BigBaseV2/src/views/esp/view_esp.cpp b/BigBaseV2/src/views/esp/view_esp.cpp new file mode 100644 index 00000000..beb51b12 --- /dev/null +++ b/BigBaseV2/src/views/esp/view_esp.cpp @@ -0,0 +1,92 @@ +#include "view_esp.hpp" +#include "pointers.hpp" +#include "services/player_service.hpp" +#include "util/math.hpp" +#include "gta_util.hpp" +#include "util/misc.hpp" + +namespace big +{ + float esp::calculate_distance(rage::fvector3 player_position) + { + const Vector3 plyr_coords = { player_position.x, player_position.y, player_position.z }; + const Vector3 cam_coords = g_pointers->m_get_gamplay_cam_coords(); + + return (float)math::distance_between_vectors(plyr_coords, cam_coords); + } + + void esp::draw() { + if (!g->esp.enabled) return; + + static ImColor death_bg = ImColor(0.117f, 0.113f, 0.172f, .75f); + static ImColor health_green_bg = ImColor(0.29f, 0.69f, 0.34f, 0.5f); + 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, 0.5f); + 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, 0.5f); + static ImColor health_red = ImColor(0.69f, 0.29f, 0.29f, 1.f); + + ImGui::SetNextWindowSize({ (float)g->window.x, (float)g->window.y }); + if (ImGui::Begin("draw_window", nullptr, ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoFocusOnAppearing)) + { + ImDrawList* draw_list = ImGui::GetWindowDrawList(); + for (auto& item : g_player_service->m_players) + { + const std::unique_ptr& plyr = item.second; + + if (plyr->id() == gta_util::get_network_player_mgr()->m_local_net_player->m_player_id || !plyr->is_valid() || plyr->get_ped() == nullptr) continue; + + rage::fvector3& player_pos = plyr->get_ped()->m_navigation->m_position; + + float screen_x; + float screen_y; + + const float distance = calculate_distance(player_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) continue; + + bool god = misc::has_bit_set((int*)&plyr->get_ped()->m_damage_bits, 8); + + if (g_pointers->m_get_screen_coords_for_world_coords(player_pos.data, &screen_x, &screen_y)) + { + const float esp_x = (float)g->window.x * screen_x; + const float esp_y = (float)g->window.y * screen_y; + + const float esp_side_x = esp_x + (67.5f * multplr); + + ImVec2 name_pos = { esp_side_x, esp_y - (175.f * multplr) }; + + if (g->esp.distance) + name_pos = { esp_x - (62.5f * multplr), esp_y - (175.f * multplr) - 25.f }; + + float health_perc = (plyr->get_ped()->m_health - 100) / (plyr->get_ped()->m_maxhealth - 100); + health_perc = health_perc < 0.f ? 0.f : health_perc; + + if (distance < g->esp.tracer_render_distance[1] && distance > g->esp.tracer_render_distance[0] && g->esp.tracer) + draw_list->AddLine({ (float)g->window.x * 0.5f, (float)g->window.y }, { esp_x, esp_y }, g->esp.color); + + if (distance < g->esp.box_render_distance[1] && distance > g->esp.box_render_distance[0] && g->esp.box) + draw_list->AddRect({ esp_x - (62.5f * multplr), esp_y - (175.f * multplr) }, { esp_x - (62.5f * multplr) + (125.f * multplr), esp_y - (175.f * multplr) + (350.f * multplr) }, g->esp.color); + + if (g->esp.name) + draw_list->AddText(name_pos, g->esp.color, plyr->get_name()); + + if (g->esp.distance) + draw_list->AddText({ esp_side_x, esp_y - (175.f * multplr) }, g->esp.color, fmt::format("{}m", (int)distance).c_str()); + + if (god && g->esp.god) + draw_list->AddText({ esp_side_x, esp_y - (175.f * multplr) + 20.f }, health_red, "GOD"); + else if (g->esp.health) + { + draw_list->AddLine({ esp_side_x, esp_y - (175.f * multplr) + 25.f }, { esp_side_x + (100.f), esp_y - (175.f * multplr) + 25.f }, health_perc == 0.f ? death_bg : health_perc < 0.25f ? health_red_bg : health_perc < 0.65f ? health_yellow_bg : health_green_bg, 4); + draw_list->AddLine({ esp_side_x, esp_y - (175.f * multplr) + 25.f }, { esp_side_x + (100.f * health_perc), esp_y - (175.f * multplr) + 25.f }, health_perc < 0.25f ? health_red : health_perc < 0.65f ? health_yellow : health_green, 4); + } + } + + } + + ImGui::End(); + } + } +} \ No newline at end of file diff --git a/BigBaseV2/src/views/esp/view_esp.hpp b/BigBaseV2/src/views/esp/view_esp.hpp new file mode 100644 index 00000000..eacbfb64 --- /dev/null +++ b/BigBaseV2/src/views/esp/view_esp.hpp @@ -0,0 +1,13 @@ +#pragma once + +namespace big +{ + class player; + + class esp + { + static float calculate_distance(rage::fvector3); + public: + static void draw(); + }; +} \ No newline at end of file diff --git a/BigBaseV2/src/views/view.hpp b/BigBaseV2/src/views/view.hpp index a8bd6be3..563b0df3 100644 --- a/BigBaseV2/src/views/view.hpp +++ b/BigBaseV2/src/views/view.hpp @@ -1,8 +1,13 @@ #pragma once #include "imgui.h" #include "natives.hpp" +#include "pointers.hpp" #include "util/animator.hpp" #include "gui/components/components.hpp" +#include "script.hpp" +#include "services/player_service.hpp" +#include "views/esp/view_esp.hpp" + namespace big { @@ -74,6 +79,7 @@ namespace big static void always() { + esp::draw(); notifications(); } }; diff --git a/BigBaseV2/src/views/view_notifications.cpp b/BigBaseV2/src/views/view_notifications.cpp index fa3b6acb..0577a0cf 100644 --- a/BigBaseV2/src/views/view_notifications.cpp +++ b/BigBaseV2/src/views/view_notifications.cpp @@ -27,6 +27,7 @@ namespace big ImGui::PopStyleColor(2); ImGui::PopStyleVar(); } + ImGui::End(); } } } \ No newline at end of file diff --git a/BigBaseV2/src/views/view_session.cpp b/BigBaseV2/src/views/view_session.cpp index fcf16760..61586fd2 100644 --- a/BigBaseV2/src/views/view_session.cpp +++ b/BigBaseV2/src/views/view_session.cpp @@ -17,5 +17,35 @@ namespace big ImGui::TreePop(); } + + if (ImGui::TreeNode("ESP Settings")) + { + ImGui::Checkbox("ESP Enabled", &g->esp.enabled); + + if (g->esp.enabled) + { + ImGui::SliderFloat2("Global Render Distance", g->esp.global_render_distance, 0.f, 1500.f); + + ImGui::Checkbox("Tracer", &g->esp.tracer); + if (g->esp.tracer) + ImGui::SliderFloat2("Tracer Render Distance", g->esp.tracer_render_distance, g->esp.global_render_distance[0], g->esp.global_render_distance[1]); + + ImGui::Checkbox("Box ESP", &g->esp.box); + if (g->esp.box) + ImGui::SliderFloat2("Box Render Distance", g->esp.box_render_distance, g->esp.global_render_distance[0], g->esp.global_render_distance[1]); + + ImGui::Checkbox("Show Player Distance", &g->esp.distance); + ImGui::Checkbox("Show Player Godmode", &g->esp.god); + ImGui::Checkbox("Show Player Health", &g->esp.health); + ImGui::Checkbox("Show Player Name", &g->esp.name); + static ImVec4 col = ImVec4(114.0f / 255.0f, 144.0f / 255.0f, 154.0f / 255.0f, 200.0f / 255.0f); + if (ImGui::ColorPicker4("##picker", (float*)&col, ImGuiColorEditFlags_InputRGB | ImGuiColorEditFlags_NoSidePreview | ImGuiColorEditFlags_NoSmallPreview)) + { + g->esp.color = ImGui::ColorConvertFloat4ToU32(col); + } + } + + ImGui::TreePop(); + } } } \ No newline at end of file