From 2d9d2c95a8ba6a94ac507df0596779d6e027532e Mon Sep 17 00:00:00 2001 From: ALittlePatate Date: Tue, 4 Oct 2022 11:39:46 +0200 Subject: [PATCH] add: item esp base, fix: esp stuff --- DevourClient/Features/ESP/ESP.cpp | 54 +++++++++++++++++++++++++++++-- DevourClient/Features/ESP/ESP.hpp | 1 + DevourClient/Features/Menu.cpp | 2 +- DevourClient/Hooks/Hooks.cpp | 1 + 4 files changed, 55 insertions(+), 3 deletions(-) diff --git a/DevourClient/Features/ESP/ESP.cpp b/DevourClient/Features/ESP/ESP.cpp index a8c1107..39b8784 100644 --- a/DevourClient/Features/ESP/ESP.cpp +++ b/DevourClient/Features/ESP/ESP.cpp @@ -1,6 +1,7 @@ #include "ESP.hpp" #include "../../Utils/Settings/Settings.hpp" #include "../../Utils/Players/Players.hpp" +#include "../../Utils/Objects/Objects.hpp" #include "../../Dependencies/IL2CPP_Resolver/il2cpp_resolver.hpp" #include "../../Utils/Output/Output.hpp" @@ -34,8 +35,8 @@ void ESP::PlayerESP() { continue; } - Unity::Vector2 w2s_footpos = CameraMain->CallMethodSafe("WorldToScreenPoint"); - Unity::Vector2 w2s_headpos = CameraMain->CallMethodSafe("WorldToScreenPoint"); + Unity::Vector3 w2s_footpos = CameraMain->CallMethodSafe("WorldToScreenPoint", playerFootPos); + Unity::Vector3 w2s_headpos = CameraMain->CallMethodSafe("WorldToScreenPoint", playerHeadPos); auto draw = ImGui::GetBackgroundDrawList(); @@ -46,4 +47,53 @@ void ESP::PlayerESP() { draw->AddRect(ImVec2(w2s_headpos.x, settings::width - w2s_headpos.y), ImVec2(w2s_footpos.x, settings::width - w2s_footpos.y), box); } } +} + +void ESP::ItemESP() { + if (settings::item_esp) { + IL2CPP::Thread::Attach(IL2CPP::Domain::Get()); + for (Unity::CGameObject* object : Objects::ObjectList) { + if (!object || !object->m_CachedPtr) { + continue; + } + + Unity::Vector3 pivotPos = object->GetComponent("Transform")->GetMemberValue("position"); + + Unity::Vector3 playerFootPos; + playerFootPos.x = pivotPos.x; + playerFootPos.z = pivotPos.z; + playerFootPos.y = pivotPos.y - 2.f; //At the feet + + Unity::Vector3 playerHeadPos; + playerHeadPos.x = pivotPos.x; + playerHeadPos.z = pivotPos.z; + playerHeadPos.y = pivotPos.y + 2.f; //At the head + + Unity::CGameObject* Camera = Unity::GameObject::Find("Main Camera"); + if (!Camera) { + continue; + } + + Unity::CComponent* CameraMain = Camera->GetComponent("Camera"); + if (!CameraMain) { + continue; + } + + Unity::Vector3 w2s_footpos = CameraMain->CallMethodSafe("WorldToScreenPoint", playerFootPos); + Unity::Vector3 w2s_headpos = CameraMain->CallMethodSafe("WorldToScreenPoint", playerHeadPos); + + //imgui (thanks to that 1 dude in pinned for math, not the math id use but idk im debugging lol) + float h = w2s_headpos.y - w2s_footpos.y; + float w = h / 4.f; + float l = w2s_footpos.x - w; + float r = w2s_footpos.x + w; + + auto draw = ImGui::GetBackgroundDrawList(); + + ImColor box(settings::item_esp_color[0], settings::item_esp_color[1], + settings::item_esp_color[2], settings::item_esp_color[3]); + + draw->AddRect(ImVec2(l, w2s_headpos.y), ImVec2(r, w2s_footpos.y), box); + } + } } \ No newline at end of file diff --git a/DevourClient/Features/ESP/ESP.hpp b/DevourClient/Features/ESP/ESP.hpp index 12690dc..ca572c9 100644 --- a/DevourClient/Features/ESP/ESP.hpp +++ b/DevourClient/Features/ESP/ESP.hpp @@ -2,4 +2,5 @@ namespace ESP { void PlayerESP(); + void ItemESP(); } \ No newline at end of file diff --git a/DevourClient/Features/Menu.cpp b/DevourClient/Features/Menu.cpp index 88cc8da..321e08c 100644 --- a/DevourClient/Features/Menu.cpp +++ b/DevourClient/Features/Menu.cpp @@ -111,7 +111,7 @@ void DrawVisualsTab() { ImGui::EndPopup(); } - ImGui::Checkbox("Demon ESP", &settings::item_esp); + ImGui::Checkbox("Demon ESP", &settings::demon_esp); ImGui::SameLine(); bool open_dcolor_popup = ImGui::ColorButton("despcolor", ImVec4(settings::demon_esp_color[0], settings::demon_esp_color[1], settings::demon_esp_color[2], settings::demon_esp_color[3])); if (open_dcolor_popup) diff --git a/DevourClient/Hooks/Hooks.cpp b/DevourClient/Hooks/Hooks.cpp index 1b00f74..5c8b411 100644 --- a/DevourClient/Hooks/Hooks.cpp +++ b/DevourClient/Hooks/Hooks.cpp @@ -142,6 +142,7 @@ HRESULT __stdcall hookD3D11Present(IDXGISwapChain* pSwapChain, UINT SyncInterval ImGui::GetIO().MouseDrawCursor = open_menu; ESP::PlayerESP(); + ESP::ItemESP(); ImGui::EndFrame(); ImGui::Render();