From db3724775d6f8a2046680dc994221a2441f3def8 Mon Sep 17 00:00:00 2001 From: ifBars <114284668+ifBars@users.noreply.github.com> Date: Tue, 10 Oct 2023 22:25:02 -0600 Subject: [PATCH] Update hack.hpp - Made armor toggleable - Added toggleable player distance --- memory-external/hacks/hack.hpp | 66 +++++++++++++++++++++++++++------- 1 file changed, 54 insertions(+), 12 deletions(-) diff --git a/memory-external/hacks/hack.hpp b/memory-external/hacks/hack.hpp index e9c1005..7f83f0d 100644 --- a/memory-external/hacks/hack.hpp +++ b/memory-external/hacks/hack.hpp @@ -9,6 +9,14 @@ namespace hack { std::shared_ptr process; ProcessModule base_module; + float CalculateDistance(const Vector3& point1, const Vector3& point2) { + float dx = point2.x - point1.x; + float dy = point2.y - point1.y; + float dz = point2.z - point1.z; + + return std::sqrt(dx * dx + dy * dy + dz * dz); + } + void loop() { const uintptr_t localPlayer = process->read(base_module.base + updater::offsets::dwLocalPlayer); if (!localPlayer) @@ -87,6 +95,7 @@ namespace hack { const Vector3 origin = process->read(pCSPlayerPawn + updater::offsets::m_vecOrigin); const Vector3 head = { origin.x, origin.y, origin.z + 75.f }; + const Vector3 localOrigin = process->read(localPlayer + updater::offsets::m_vecOrigin); if (config::render_distance != -1 && (localOrigin - origin).length2d() > config::render_distance) { playerIndex++; @@ -187,18 +196,51 @@ namespace hack { 10 ); - render::RenderText( - g::hdcBuffer, - screenHead.x + (width / 2 + 5), - screenHead.y + 22, - (std::to_string(playerArmor) + "armor").c_str(), - RGB( - (255 - playerArmor), - (55 + playerArmor * 2), - 75 - ), - 10 - ); + if (config::show_armor) + { + render::RenderText( + g::hdcBuffer, + screenHead.x + (width / 2 + 5), + screenHead.y + 21, + (std::to_string(playerArmor) + "armor").c_str(), + RGB( + (255 - playerArmor), + (55 + playerArmor * 2), + 75 + ), + 10 + ); + } + + if (config::show_distance) + { + float distance = CalculateDistance(localOrigin, origin); + // Round the distance to the nearest integer + int roundedDistance = std::round(distance / 10); + + if (config::rainbow) + { + render::RenderText( + g::hdcBuffer, + screenHead.x + (width / 2 + 5), + screenHead.y + 32, + (std::to_string(roundedDistance) + "m away").c_str(), + rainbowColor, + 10 + ); + } + else + { + render::RenderText( + g::hdcBuffer, + screenHead.x + (width / 2 + 5), + screenHead.y + 32, + (std::to_string(roundedDistance) + "m away").c_str(), + RGB(75, 75, 175), + 10 + ); + } + } } playerIndex++; }