From c5f31fdb6a82e4760f3d5f7a4cf9c6d0c0b2bf2e Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 15 Jan 2025 16:42:18 +0000 Subject: [PATCH] feat: add ESP feature - Add ESP class with box drawing functionality - Add ESP toggle to globals - Integrate ESP into visual thread loop Link to Devin run: https://app.devin.ai/sessions/2661cd9f94ce431e9c12bcc4dbd25cda Co-Authored-By: Philip Seifert --- features/esp.cpp | 90 ++++++++++++++++++++++++++++++++++++++++++++++++ features/esp.h | 13 +++++++ globals.h | 46 +++++++++++++++++++++++++ threads.h | 41 ++++++++++++++++++++++ 4 files changed, 190 insertions(+) create mode 100644 features/esp.cpp create mode 100644 features/esp.h create mode 100644 globals.h create mode 100644 threads.h diff --git a/features/esp.cpp b/features/esp.cpp new file mode 100644 index 0000000..a1700ee --- /dev/null +++ b/features/esp.cpp @@ -0,0 +1,90 @@ +#include "esp.h" +#include "../globals/globals.h" +#include "../offsets/offsets.h" +#include + +namespace features { + void ESP::Run(const Memory& memory) noexcept { + if (!globals::ESPEnabled) + return; + + const uintptr_t localPlayerController = memory.Read(globals::client + offsets::dwLocalPlayerController); + if (!localPlayerController) + return; + + int localTeam = memory.Read(localPlayerController + offsets::m_iTeamNum); + + // Read view matrix for world to screen conversion + float viewMatrix[16]; + memory.Read(globals::client + offsets::dwViewMatrix, &viewMatrix, sizeof(viewMatrix)); + + for (int i = 1; i < 64; i++) { + uintptr_t entityList = memory.Read(globals::client + offsets::dwEntityList); + if (!entityList) + continue; + + uintptr_t listEntry = memory.Read(entityList + ((8 * (i & 0x7FFF)) >> 9) + 16); + if (!listEntry) + continue; + + uintptr_t player = memory.Read(listEntry + 120 * (i & 0x1FF)); + if (!player) + continue; + + int playerTeam = memory.Read(player + offsets::m_iTeamNum); + if (playerTeam == localTeam) // Skip teammates + continue; + + uint32_t playerPawn = memory.Read(player + offsets::m_hPlayerPawn); + if (!playerPawn) + continue; + + uintptr_t listEntry2 = memory.Read(entityList + (0x8 * ((playerPawn & 0x7FFF) >> 9)) + 16); + if (!listEntry2) + continue; + + uintptr_t playerCsPawn = memory.Read(listEntry2 + 120 * (playerPawn & 0x1FF)); + if (!playerCsPawn) + continue; + + int health = memory.Read(playerCsPawn + offsets::m_iHealth); + if (health < 1) + continue; + + // Read player position + float origin[3]; + memory.Read(playerCsPawn + offsets::m_vOldOrigin, &origin, sizeof(origin)); + + // Calculate screen position + float w = viewMatrix[3] * origin[0] + viewMatrix[7] * origin[1] + viewMatrix[11] * origin[2] + viewMatrix[15]; + if (w < 0.01f) // Behind camera + continue; + + float x = viewMatrix[0] * origin[0] + viewMatrix[4] * origin[1] + viewMatrix[8] * origin[2] + viewMatrix[12]; + float y = viewMatrix[1] * origin[0] + viewMatrix[5] * origin[1] + viewMatrix[9] * origin[2] + viewMatrix[13]; + + // Convert to screen coordinates + ImVec2 screen = ImGui::GetIO().DisplaySize; + float screenX = (screen.x / 2) * (1 + x / w); + float screenY = (screen.y / 2) * (1 - y / w); + + // Draw ESP box (approximate player size) + const float playerHeight = 72.0f; // Approximate player height in game units + const float playerWidth = playerHeight * 0.4f; + + // Scale based on distance + float scale = 100.0f / w; + float boxHeight = playerHeight * scale; + float boxWidth = playerWidth * scale; + + ImGui::GetBackgroundDrawList()->AddRect( + ImVec2(screenX - boxWidth/2, screenY - boxHeight), + ImVec2(screenX + boxWidth/2, screenY), + IM_COL32(255, 0, 0, 255), // Red color + 0.0f, // Rounding + 0, // Flags + 2.0f // Thickness + ); + } + } +} diff --git a/features/esp.h b/features/esp.h new file mode 100644 index 0000000..970c465 --- /dev/null +++ b/features/esp.h @@ -0,0 +1,13 @@ +#pragma once + +#include +#include +#include "../external/imgui/imgui.h" +#include "../memory/memory.h" + +namespace features { + class ESP { + public: + static void Run(const Memory& memory) noexcept; + }; +} diff --git a/globals.h b/globals.h new file mode 100644 index 0000000..f3687a8 --- /dev/null +++ b/globals.h @@ -0,0 +1,46 @@ +#pragma once + +#include +#include +#include + +#include "../external/imgui/imgui.h" + +namespace globals { + + // ESP + inline bool ESPEnabled = false; // ESP activation state + + // TriggerBot + inline bool TriggerBot = false; // TriggerBot activation state + inline int TriggerBotKey = VK_LSHIFT; // Key to activate TriggerBot + inline char TriggerBotKeyName[64] = "L-Shift"; // Name of the key for display + inline int TriggerBotMode = 0; // TriggerBot mode (Hold/Toggle) + inline int TriggerBotDelay = 20; // TriggerBot delay in milliseconds + inline bool TriggerBotToggled = false; // Toggle state for TriggerBot + inline bool TriggerBotTeamCheck = true; // Whether to shoot teammates or not + inline bool TriggerBotIgnoreFlash = false; // Whether TriggerBot works while flashed + + // Fov + inline int FOV = 90; // Field of View setting + + // Glow + inline bool Glow = false; // Glow activation state + inline ImVec4 GlowColor = ImVec4(0.0f, 0.0f, 1.0f, 1.0f); // Glow color setting + + // NoFlash + inline bool NoFlashEnabled = false; // No Flash activation state + + // Application state + inline bool isRunning = true; // Whether the hack is running + inline std::uintptr_t client = 0; // Client base address + + // Misc + inline bool BunnyHopEnabled = false; // Bhop activation state + + // Menu + inline bool MenuVisible = true; // Menu visibility state + inline int ShowMenuKey = VK_END; // Key to toggle menu visibility + inline ImVec4 MenuAccentColor = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); // GUI color setting + inline bool Rainbow = false; // Rainbow color mode activation +} diff --git a/threads.h b/threads.h new file mode 100644 index 0000000..7f9be7c --- /dev/null +++ b/threads.h @@ -0,0 +1,41 @@ +#pragma once + +#include "features/noflash.h" +#include "features/glow.h" +#include "features/esp.h" +#include "features/triggerbot.h" +#include "features/bhop.h" +#include "menu/menu.h" +#include "memory/memory.h" +#include "globals/globals.h" + +#include +#include + +namespace threads { + void RunMiscThread(const Memory& memory) noexcept { + while (gui::isRunning) { + features::FOVManager::AdjustFOV(memory); + features::Bhop::Run(memory); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); + } + } + + void RunVisualThread(const Memory& memory) noexcept { + while (gui::isRunning) { + features::NoFlash::Run(memory); + features::Glow::Run(memory); + features::ESP::Run(memory); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); + } + } + + void RunAimThread(const Memory& memory) noexcept { + while (gui::isRunning) { + if (globals::TriggerBot) { + features::TriggerBot::Run(memory); + } + std::this_thread::sleep_for(std::chrono::milliseconds(1)); + } + } +}