From a889a66554181323ff54757421d56476e8d6475f Mon Sep 17 00:00:00 2001 From: ifBars <114284668+ifBars@users.noreply.github.com> Date: Tue, 31 Oct 2023 02:17:10 -0600 Subject: [PATCH] Head Tracker - Adds in a more advanced head tracker that uses bone array to get the exact position of head - Currently the circle changes size based on distance from player as the radius is set to a constant 5, this needs to be based off distance --- memory-external/classes/render.hpp | 11 +++++++++++ memory-external/hacks/hack.hpp | 24 ++++++++++++++++++++---- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/memory-external/classes/render.hpp b/memory-external/classes/render.hpp index bab648d..ec5ce9e 100644 --- a/memory-external/classes/render.hpp +++ b/memory-external/classes/render.hpp @@ -3,6 +3,17 @@ namespace render { + void DrawCircle(HDC hdc, int x, int y, int radius, COLORREF color) + { + HBRUSH hBrush = CreateSolidBrush(color); + HBRUSH hOldBrush = (HBRUSH)SelectObject(hdc, hBrush); + + Ellipse(hdc, x - radius, y - radius, x + radius, y + radius); + + SelectObject(hdc, hOldBrush); + DeleteObject(hBrush); + } + void DrawBorderBox(HDC hdc, int x, int y, int w, int h, COLORREF borderColor) { HBRUSH hBorderBrush = CreateSolidBrush(borderColor); diff --git a/memory-external/hacks/hack.hpp b/memory-external/hacks/hack.hpp index 31252bd..988a924 100644 --- a/memory-external/hacks/hack.hpp +++ b/memory-external/hacks/hack.hpp @@ -125,24 +125,40 @@ namespace hack { const Vector3 origin = process->read(pCSPlayerPawn + updater::offsets::m_vecOrigin); const Vector3 head = { origin.x, origin.y, origin.z + 75.f }; + if (origin.x == localOrigin.x && origin.y == localOrigin.y && origin.z == localOrigin.z) + continue; + + const uintptr_t gamescene = process->read(pCSPlayerPawn + 0x310); + const uintptr_t bonearray = process->read(gamescene + 0x160 + 0x80); + const Vector3 headPos = process->read(bonearray + 6 * 32); + if (config::render_distance != -1 && (localOrigin - origin).length2d() > config::render_distance) continue; - if (origin.x == 0 && origin.y == 0 && origin.z == 0) + if (origin.x == 0 && origin.y == 0) continue; const Vector3 screenPos = origin.world_to_screen(view_matrix); const Vector3 screenHead = head.world_to_screen(view_matrix); + const Vector3 screenHeadPos = headPos.world_to_screen(view_matrix); if (screenPos.z >= 0.01f) { const float height = screenPos.y - screenHead.y; const float width = height / 2.4f; - const float head_height = (screenPos.y - screenHead.y) / 8; - const float head_width = (height / 2.4f) / 4; + const float head_height = (screenHeadPos.y - screenHeadPos.y) / 8; + const float head_width = (head_height / 2.4f) / 4; float distance = localOrigin.calculate_distance(origin); int roundedDistance = std::round(distance / 10.f); + render::DrawCircle( + g::hdcBuffer, + screenHeadPos.x, + screenHeadPos.y, + 5, + config::esp_box_color_enemy + ); + render::DrawBorderBox( g::hdcBuffer, screenHead.x - width / 2, @@ -296,7 +312,7 @@ namespace hack { } } } - std::this_thread::sleep_for(std::chrono::milliseconds(1)); + // std::this_thread::sleep_for(std::chrono::milliseconds(1)); } }