add: item esp base, fix: esp stuff

This commit is contained in:
ALittlePatate
2022-10-04 11:39:46 +02:00
parent b6e90e362a
commit 2d9d2c95a8
4 changed files with 55 additions and 3 deletions

View File

@@ -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<Unity::Vector2>("WorldToScreenPoint");
Unity::Vector2 w2s_headpos = CameraMain->CallMethodSafe<Unity::Vector2>("WorldToScreenPoint");
Unity::Vector3 w2s_footpos = CameraMain->CallMethodSafe<Unity::Vector3>("WorldToScreenPoint", playerFootPos);
Unity::Vector3 w2s_headpos = CameraMain->CallMethodSafe<Unity::Vector3>("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<Unity::Vector3>("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<Unity::Vector3>("WorldToScreenPoint", playerFootPos);
Unity::Vector3 w2s_headpos = CameraMain->CallMethodSafe<Unity::Vector3>("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);
}
}
}

View File

@@ -2,4 +2,5 @@
namespace ESP {
void PlayerESP();
void ItemESP();
}

View File

@@ -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)

View File

@@ -142,6 +142,7 @@ HRESULT __stdcall hookD3D11Present(IDXGISwapChain* pSwapChain, UINT SyncInterval
ImGui::GetIO().MouseDrawCursor = open_menu;
ESP::PlayerESP();
ESP::ItemESP();
ImGui::EndFrame();
ImGui::Render();