From 01bdc8e683f2430a90b77add0731ca7b782db5a4 Mon Sep 17 00:00:00 2001 From: ALittlePatate Date: Tue, 28 May 2024 10:22:01 +0200 Subject: [PATCH] add: player esp and snaplines for now the esp will show "Player" instead of the real player name //TOFIX --- IL2CppDLL.vcxproj | 2 ++ IL2CppDLL.vcxproj.filters | 9 +++++ user/features/esp/esp.cpp | 72 +++++++++++++++++++++++++++++++++++++++ user/features/esp/esp.hpp | 7 ++++ user/features/menu.cpp | 3 ++ user/hooks/hooks.cpp | 3 ++ 6 files changed, 96 insertions(+) create mode 100644 user/features/esp/esp.cpp create mode 100644 user/features/esp/esp.hpp diff --git a/IL2CppDLL.vcxproj b/IL2CppDLL.vcxproj index 8de3674..52838f1 100644 --- a/IL2CppDLL.vcxproj +++ b/IL2CppDLL.vcxproj @@ -53,6 +53,7 @@ + @@ -93,6 +94,7 @@ + diff --git a/IL2CppDLL.vcxproj.filters b/IL2CppDLL.vcxproj.filters index 0c412ac..9bebe60 100644 --- a/IL2CppDLL.vcxproj.filters +++ b/IL2CppDLL.vcxproj.filters @@ -79,6 +79,9 @@ user\players + + user\features\esp + @@ -195,6 +198,9 @@ user\players + + user\features\esp + @@ -236,5 +242,8 @@ {54f72ffe-f8ca-4732-bd14-62d1a7a68267} + + {8f74b1c2-1d3c-4a14-8a6f-7bf00e07d57e} + \ No newline at end of file diff --git a/user/features/esp/esp.cpp b/user/features/esp/esp.cpp new file mode 100644 index 0000000..609285a --- /dev/null +++ b/user/features/esp/esp.cpp @@ -0,0 +1,72 @@ +#include "pch-il2cpp.h" + +#include +#include "ClientHelper.h" +#include "UnityCore.h" +#include "players/players.h" +#include "helpers.h" +#include "esp.hpp" + +static void DrawBox(float x, float y, float w, float h, ImColor color, float thickness) +{ + auto drawlist = ImGui::GetBackgroundDrawList(); + + drawlist->AddLine(ImVec2{ x, y }, ImVec2{ x + w, y }, color, thickness); + drawlist->AddLine(ImVec2{ x, y }, ImVec2{ x, y + h }, color, thickness); + drawlist->AddLine(ImVec2{ x + w, y }, ImVec2{ x + w, y + h }, color, thickness); + drawlist->AddLine(ImVec2{ x, y + h }, ImVec2{ x + w, y + h}, color, thickness); +} + +static void DrawString(ImVec2 pos, ImColor color, std::string label) +{ + auto drawlist = ImGui::GetBackgroundDrawList(); + + drawlist->AddText(pos, color, label.c_str()); +} + +static void DrawBoxESP(app::GameObject *it, float footOffset, float headOffset, std::string name, ImColor color, bool snapline = false, bool esp = false, float nameOffset = -0.5f, float widthOffset = 2.0f) +{ + ImGuiIO& io = ImGui::GetIO(); + app::Camera* cam = app::Camera_get_main(nullptr); + if (!it || cam == nullptr) + return; + + app::Transform* _transform = Unity::Transform::Get(it); + if (_transform == nullptr) + return; + + app::Vector3 pos = Unity::Transform::Position(_transform); + + app::Vector3 footpos = app::Camera_WorldToScreenPoint_1(cam, app::Vector3{pos.x, pos.y + footOffset, pos.z}, NULL); + app::Vector3 headpos = app::Camera_WorldToScreenPoint_1(cam, app::Vector3{pos.x, pos.y + headOffset, pos.z}, NULL); + app::Vector3 namepos = app::Camera_WorldToScreenPoint_1(cam, app::Vector3{pos.x, pos.y + nameOffset, pos.z}, NULL); + + if (esp && footpos.z > 0.0f) { + float height = (headpos.y - footpos.y); + float width = height / widthOffset; + + DrawBox(footpos.x - (width / 2), (float)io.DisplaySize.y - footpos.y - height, width, height, color, 2.0f); + DrawString(ImVec2(namepos.x, (float)io.DisplaySize.y - namepos.y), color, name); + } + + if (snapline && footpos.z > 0.f) { + auto drawlist = ImGui::GetBackgroundDrawList(); + drawlist->AddLine(ImVec2(io.DisplaySize.x / 2, io.DisplaySize.y / 2), ImVec2(footpos.x, io.DisplaySize.y - footpos.y), color, 2.f); + } +} + +void ESP::RunPlayersESP() { + app::GameObject__Array* players = Players::GetAllPlayers(); + + if (players == NULL) + return; + + for (int i = 0; i < players->max_length; i++) { + app::GameObject* ent = players->vector[i]; + + if (ent == nullptr || ent == Player::GetLocalPlayer()) + continue; + + DrawBoxESP(ent, -0.25, 1.75, "Player", ImColor{settings::player_esp_color[0], settings::player_esp_color[1], settings::player_esp_color[2], settings::player_esp_color[3]}, settings::player_snaplines, settings::player_esp); + } +} \ No newline at end of file diff --git a/user/features/esp/esp.hpp b/user/features/esp/esp.hpp new file mode 100644 index 0000000..247dca4 --- /dev/null +++ b/user/features/esp/esp.hpp @@ -0,0 +1,7 @@ +#pragma once + +#include "settings/settings.hpp" + +namespace ESP { + void RunPlayersESP(); +} diff --git a/user/features/menu.cpp b/user/features/menu.cpp index 0da85fa..d338e7a 100644 --- a/user/features/menu.cpp +++ b/user/features/menu.cpp @@ -52,6 +52,8 @@ void DrawVisualsTab() { } ImGui::SameLine(); ImGui::Text("Flashlight color"); + */ + ImGui::Checkbox("Player ESP", &settings::player_esp); ImGui::SameLine(); @@ -77,6 +79,7 @@ void DrawVisualsTab() { ImGui::EndPopup(); } + /* ImGui::Checkbox("Azazel ESP", &settings::azazel_esp); ImGui::SameLine(); bool open_azacolor_popup = ImGui::ColorButton("azaespcolor", ImVec4(settings::azazel_esp_color[0], settings::azazel_esp_color[1], settings::azazel_esp_color[2], settings::azazel_esp_color[3])); diff --git a/user/hooks/hooks.cpp b/user/hooks/hooks.cpp index 6f18b78..a3c62d1 100644 --- a/user/hooks/hooks.cpp +++ b/user/hooks/hooks.cpp @@ -2,6 +2,7 @@ #include "Hooks.hpp" #include "features/menu.hpp" #include "settings/settings.hpp" +#include "../features/esp/esp.hpp" #include "main.h" #include "utils/utils.hpp" @@ -630,6 +631,8 @@ HRESULT __stdcall hookD3D11Present(IDXGISwapChain* pSwapChain, UINT SyncInterval DrawMenu(open_menu); } + if (settings::player_esp) + ESP::RunPlayersESP(); ImGui::GetIO().MouseDrawCursor = open_menu;