Reviewed #30 pull request

- Added customizable colors in the configuration
- Cleaned code just a bit
- Updated offsets to the latest game version

Thnaks @ifBars for great ideas in with his pull request
This commit is contained in:
IMXNOOBX
2023-10-12 12:50:49 +02:00
parent 61940cb6cc
commit 889cee1aa0
7 changed files with 283 additions and 275 deletions
-2
View File
@@ -19,8 +19,6 @@ namespace updater {
std::tm commit_date = {}; std::tm commit_date = {};
std::istringstream(last_commit_date) >> std::get_time(&commit_date, "%Y-%m-%dT%H:%M:%SZ"); std::istringstream(last_commit_date) >> std::get_time(&commit_date, "%Y-%m-%dT%H:%M:%SZ");
auto currentTime = std::chrono::system_clock::now();
std::chrono::system_clock::time_point commitTimePoint = std::chrono::system_clock::from_time_t(std::mktime(&commit_date)); std::chrono::system_clock::time_point commitTimePoint = std::chrono::system_clock::from_time_t(std::mktime(&commit_date));
if (file_good("offsets.json")) { if (file_good("offsets.json")) {
+5 -5
View File
@@ -27,13 +27,13 @@ namespace updater {
extern bool read(); extern bool read();
extern void save(); extern void save();
inline std::string github_repo_api = "https://api.github.com/repos/IMXNOOBX/cs2-external-esp/commits"; const inline std::string github_repo_api = "https://api.github.com/repos/IMXNOOBX/cs2-external-esp/commits";
inline std::string raw_updated_offets = "https://github.com/IMXNOOBX/cs2-external-esp/raw/main/offsets/offsets.json"; const inline std::string raw_updated_offets = "https://github.com/IMXNOOBX/cs2-external-esp/raw/main/offsets/offsets.json";
namespace offsets { namespace offsets {
inline std::ptrdiff_t dwLocalPlayer = 0x187AC48; inline std::ptrdiff_t dwLocalPlayer = 0x1877CF8;
inline std::ptrdiff_t dwEntityList = 0x178D8E8; inline std::ptrdiff_t dwEntityList = 0x178A808;
inline std::ptrdiff_t dwViewMatrix = 0x187B730; inline std::ptrdiff_t dwViewMatrix = 0x18787E0;
inline std::ptrdiff_t m_iPawnArmor = 0x80c; inline std::ptrdiff_t m_iPawnArmor = 0x80c;
inline std::ptrdiff_t dwPawnHealth = 0x808; inline std::ptrdiff_t dwPawnHealth = 0x808;
+60 -15
View File
@@ -26,16 +26,53 @@ namespace config {
automatic_update = data["automatic_update"]; automatic_update = data["automatic_update"];
if (data["render_distance"].is_number()) if (data["render_distance"].is_number())
render_distance = data["render_distance"]; render_distance = data["render_distance"];
if (data["show_distance"].is_boolean()) if (data["flag_render_distance"].is_number())
show_distance = data["show_distance"]; flag_render_distance = data["flag_render_distance"];
if (data["show_armor"].is_boolean()) if (data["show_extra_flags"].is_boolean())
show_armor = data["show_armor"]; show_extra_flags = data["show_extra_flags"];
if (data["rainbow"].is_boolean())
rainbow = data["rainbow"]; if (data.find("esp_box_color_team") != data.end()) {
if (data["rainbow_speed"].is_number()) esp_box_color_team = {
rainbow_speed = data["rainbow_speed"]; data["esp_box_color_team"][0].get<int>(),
if (data["head_tracker"].is_boolean()) data["esp_box_color_team"][1].get<int>(),
head_tracker = data["head_tracker"]; data["esp_box_color_team"][2].get<int>()
};
}
if (data.find("esp_box_color_enemy") != data.end()) {
esp_box_color_enemy = {
data["esp_box_color_enemy"][0].get<int>(),
data["esp_box_color_enemy"][1].get<int>(),
data["esp_box_color_enemy"][2].get<int>()
};
}
if (data.find("esp_name_color") != data.end()) {
esp_name_color = {
data["esp_name_color"][0].get<int>(),
data["esp_name_color"][1].get<int>(),
data["esp_name_color"][2].get<int>()
};
}
if (data.find("esp_distance_color") != data.end()) {
esp_distance_color = {
data["esp_distance_color"][0].get<int>(),
data["esp_distance_color"][1].get<int>(),
data["esp_distance_color"][2].get<int>()
};
}
//if (data["show_distance"].is_boolean())
// show_distance = data["show_distance"];
//if (data["show_armor"].is_boolean())
// show_armor = data["show_armor"];
//if (data["rainbow"].is_boolean())
// rainbow = data["rainbow"];
//if (data["rainbow_speed"].is_number())
// rainbow_speed = data["rainbow_speed"];
//if (data["head_tracker"].is_boolean())
// head_tracker = data["head_tracker"];
return true; return true;
} }
@@ -46,11 +83,19 @@ namespace config {
data["team_esp"] = team_esp; data["team_esp"] = team_esp;
data["automatic_update"] = automatic_update; data["automatic_update"] = automatic_update;
data["render_distance"] = render_distance; data["render_distance"] = render_distance;
data["show_distance"] = show_distance; data["flag_render_distance"] = flag_render_distance;
data["show_armor"] = show_armor; data["show_extra_flags"] = show_extra_flags;
data["rainbow"] = rainbow;
data["rainbow_speed"] = rainbow_speed; data["esp_box_color_team"] = { esp_box_color_team.r, esp_box_color_team.g, esp_box_color_team.b };
data["head_tracker"] = head_tracker; data["esp_box_color_enemy"] = { esp_box_color_enemy.r, esp_box_color_enemy.g, esp_box_color_enemy.b };
data["esp_name_color"] = { esp_name_color.r, esp_name_color.g, esp_name_color.b };
data["esp_distance_color"] = { esp_distance_color.r, esp_distance_color.g, esp_distance_color.b };
//data["show_distance"] = show_distance;
//data["show_armor"] = show_armor;
//data["rainbow"] = rainbow;
//data["rainbow_speed"] = rainbow_speed;
//data["head_tracker"] = head_tracker;
std::ofstream output(file_path); std::ofstream output(file_path);
output << std::setw(4) << data << std::endl; output << std::setw(4) << data << std::endl;
+25 -5
View File
@@ -5,6 +5,18 @@
using json = nlohmann::json; using json = nlohmann::json;
struct RGB {
int r;
int g;
int b;
// Conversion function from RGB to COLORREF
operator COLORREF() const {
return RGB(r, g, b);
}
};
namespace config { namespace config {
const std::string file_path = "config.json"; const std::string file_path = "config.json";
@@ -14,9 +26,17 @@ namespace config {
inline bool automatic_update = false; inline bool automatic_update = false;
inline bool team_esp = false; inline bool team_esp = false;
inline float render_distance = -1.f; inline float render_distance = -1.f;
inline bool show_distance = false; inline int flag_render_distance = 200;
inline bool show_armor = false; inline bool show_extra_flags = false;
inline bool head_tracker = false;
inline bool rainbow = false; //inline bool show_distance = false;
inline float rainbow_speed = 0.001f; //inline bool show_armor = false;
//inline bool head_tracker = false;
//inline bool rainbow = false;
//inline float rainbow_speed = 0.001f;
inline RGB esp_box_color_team = { 75, 175, 75 };
inline RGB esp_box_color_enemy = { 175, 75, 75 };
inline RGB esp_name_color = { 75, 75, 175 };
inline RGB esp_distance_color = { 75, 75, 175 };
} }
+8
View File
@@ -99,6 +99,14 @@ struct Vector3
return { x, y, w }; return { x, y, w };
} }
float calculate_distance(const Vector3& point) const {
float dx = point.x - x;
float dy = point.y - y;
float dz = point.z - z;
return std::sqrt(dx * dx + dy * dy + dz * dz);
}
// struct data // struct data
float x, y, z; float x, y, z;
}; };
+67 -125
View File
@@ -5,17 +5,13 @@
#include "../classes/render.hpp" #include "../classes/render.hpp"
#include "../classes/config.hpp" #include "../classes/config.hpp"
namespace hack { namespace hack {
std::shared_ptr<pProcess> process; std::shared_ptr<pProcess> process;
ProcessModule base_module; ProcessModule base_module;
float CalculateDistance(const Vector3& point1, const Vector3& point2) { //const float pi = 3.14159265358979323846f;
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() { void loop() {
const uintptr_t localPlayer = process->read<uintptr_t>(base_module.base + updater::offsets::dwLocalPlayer); const uintptr_t localPlayer = process->read<uintptr_t>(base_module.base + updater::offsets::dwLocalPlayer);
@@ -27,7 +23,7 @@ namespace hack {
const Vector3 localOrigin = process->read<Vector3>(localPlayer + updater::offsets::m_vecOrigin); const Vector3 localOrigin = process->read<Vector3>(localPlayer + updater::offsets::m_vecOrigin);
const uintptr_t entity_list = process->read<uintptr_t>(base_module.base + updater::offsets::dwEntityList); const uintptr_t entity_list = process->read<uintptr_t>(base_module.base + updater::offsets::dwEntityList);
int playerIndex = 1; int playerIndex = 0;
uintptr_t list_entry; uintptr_t list_entry;
/** /**
@@ -36,22 +32,21 @@ namespace hack {
* (This could have been done by getting a entity list count from the engine, but I'm too lazy to do that) * (This could have been done by getting a entity list count from the engine, but I'm too lazy to do that)
**/ **/
while (true) { while (true) {
playerIndex++;
list_entry = process->read<uintptr_t>(entity_list + (8 * (playerIndex & 0x7FFF) >> 9) + 16); list_entry = process->read<uintptr_t>(entity_list + (8 * (playerIndex & 0x7FFF) >> 9) + 16);
if (!list_entry) if (!list_entry)
break; break;
const uintptr_t player = process->read<uintptr_t>(list_entry + 120 * (playerIndex & 0x1FF)); const uintptr_t player = process->read<uintptr_t>(list_entry + 120 * (playerIndex & 0x1FF));
if (!player) { if (!player)
playerIndex++;
continue; continue;
}
const int playerHealth = process->read<int>(player + updater::offsets::dwPawnHealth); const int playerHealth = process->read<int>(player + updater::offsets::dwPawnHealth);
const int playerArmor = process->read<int>(player + updater::offsets::m_iPawnArmor); const int playerArmor = process->read<int>(player + updater::offsets::m_iPawnArmor);
if (playerHealth <= 0 || playerHealth > 100) { if (playerHealth <= 0 || playerHealth > 100)
playerIndex++;
continue; continue;
}
/** /**
* Skip rendering your own character and teammates * Skip rendering your own character and teammates
@@ -60,29 +55,24 @@ namespace hack {
* since you are in the same team as yourself it will be excluded anyway * since you are in the same team as yourself it will be excluded anyway
**/ **/
const int playerTeam = process->read<int>(player + updater::offsets::m_iTeamNum); const int playerTeam = process->read<int>(player + updater::offsets::m_iTeamNum);
if (config::team_esp && (playerTeam == localTeam)) { if (config::team_esp && (playerTeam == localTeam))
playerIndex++;
continue; continue;
}
const std::uint32_t playerPawn = process->read<std::uint32_t>(player + updater::offsets::dwPlayerPawn); const std::uint32_t playerPawn = process->read<std::uint32_t>(player + updater::offsets::dwPlayerPawn);
const uintptr_t list_entry2 = process->read<uintptr_t>(entity_list + 0x8 * ((playerPawn & 0x7FFF) >> 9) + 16); const uintptr_t list_entry2 = process->read<uintptr_t>(entity_list + 0x8 * ((playerPawn & 0x7FFF) >> 9) + 16);
if (!list_entry2) { if (!list_entry2)
playerIndex++;
continue; continue;
}
const uintptr_t pCSPlayerPawn = process->read<uintptr_t>(list_entry2 + 120 * (playerPawn & 0x1FF)); const uintptr_t pCSPlayerPawn = process->read<uintptr_t>(list_entry2 + 120 * (playerPawn & 0x1FF));
if (!pCSPlayerPawn) { if (!pCSPlayerPawn)
playerIndex++;
continue; continue;
}
if (config::team_esp && (pCSPlayerPawn == localPlayer)) { if (config::team_esp && (pCSPlayerPawn == localPlayer))
playerIndex++;
continue; continue;
}
std::string playerName = "Invalid Name"; std::string playerName = "Invalid Name";
const DWORD64 playerNameAddress = process->read<DWORD64>(player + updater::offsets::dwSanitizedName); const DWORD64 playerNameAddress = process->read<DWORD64>(player + updater::offsets::dwSanitizedName);
@@ -98,10 +88,13 @@ namespace hack {
const Vector3 head2 = { origin.x + 10, origin.y + 10, origin.z + 75.f }; const Vector3 head2 = { origin.x + 10, origin.y + 10, origin.z + 75.f };
const Vector3 localOrigin = process->read<Vector3>(localPlayer + updater::offsets::m_vecOrigin); const Vector3 localOrigin = process->read<Vector3>(localPlayer + updater::offsets::m_vecOrigin);
if (config::render_distance != -1 && (localOrigin - origin).length2d() > config::render_distance) { if (config::render_distance != -1 && (localOrigin - origin).length2d() > config::render_distance)
playerIndex++;
continue; continue;
}
if ((localOrigin - origin).length2d() < 5)
continue;
const Vector3 screenPos = origin.world_to_screen(view_matrix); const Vector3 screenPos = origin.world_to_screen(view_matrix);
const Vector3 screenHead = head.world_to_screen(view_matrix); const Vector3 screenHead = head.world_to_screen(view_matrix);
@@ -109,51 +102,21 @@ namespace hack {
const float height = screenPos.y - screenHead.y; const float height = screenPos.y - screenHead.y;
const float width = height / 2.4f; const float width = height / 2.4f;
const float height2 = (screenPos.y - screenHead.y) / 8; const float head_height = (screenPos.y - screenHead.y) / 8;
const float width2 = (height / 2.4f) / 4; const float head_width = (height / 2.4f) / 4;
if (screenPos.z >= 0.01f) { if (screenPos.z >= 0.01f) {
const COLORREF boxColor = RGB(175, 75, 75); float distance = localOrigin.calculate_distance(origin);
const COLORREF healthBarColor = RGB(255 - playerHealth, 55 + playerHealth * 2, 75);
const float pi = 3.14159265358979323846f;
// Get the current time
DWORD currentTime = GetTickCount();
// Calculate the sinusoidal values for RGB colors
float red = (sin(config::rainbow_speed * currentTime + 0) * 127.5f + 127.5f); // 0 phase shift
float green = (sin(config::rainbow_speed * currentTime + 2 * pi / 3) * 127.5f + 127.5f); // 2*pi/3 phase shift
float blue = (sin(config::rainbow_speed * currentTime + 4 * pi / 3) * 127.5f + 127.5f); // 4*pi/3 phase shift
// Convert the floating point values to integers for RGB color creation
COLORREF rainbowColor = RGB(static_cast<int>(red), static_cast<int>(green), static_cast<int>(blue));
float distance = CalculateDistance(localOrigin, origin);
// Round the distance to the nearest integer
int roundedDistance = std::round(distance / 10); int roundedDistance = std::round(distance / 10);
if (config::rainbow) {
render::DrawBorderBox( render::DrawBorderBox(
g::hdcBuffer, g::hdcBuffer,
screenHead.x - width / 2, screenHead.x - width / 2,
screenHead.y, screenHead.y,
width, width,
height, height,
(localTeam == playerTeam ? rainbowColor : rainbowColor) (localTeam == playerTeam ? config::esp_box_color_team : config::esp_box_color_enemy)
); );
}
else
{
render::DrawBorderBox(
g::hdcBuffer,
screenHead.x - width / 2,
screenHead.y,
width,
height,
(localTeam == playerTeam ? RGB(75, 175, 75) : RGB(175, 75, 75))
);
}
render::DrawBorderBox( render::DrawBorderBox(
g::hdcBuffer, g::hdcBuffer,
@@ -168,54 +131,20 @@ namespace hack {
) )
); );
if (config::head_tracker) render::RenderText(
{
if (roundedDistance > 35)
{
render::DrawFilledBox(
g::hdcBuffer, g::hdcBuffer,
screenHead.x - (width2 / 2), screenHead.x + (width / 2 + 5),
(screenHead.y + 10 - (roundedDistance / 80)) - (height2 / 2), screenHead.y,
width2, playerName.c_str(),
height2, config::esp_name_color,
rainbowColor 10
); );
}
else if (roundedDistance > 5)
{
render::DrawFilledBox(
g::hdcBuffer,
screenHead.x - (width2 / 2),
screenHead.y + 25 - (height2 / 2),
width2,
height2,
rainbowColor
);
}
}
if (config::rainbow) /**
{ * I know is not the best way but a simple way to not saturate the screen with a ton of information
render::RenderText( */
g::hdcBuffer, if (roundedDistance > config::flag_render_distance)
screenHead.x + (width / 2 + 5), continue;
screenHead.y,
playerName.c_str(),
rainbowColor,
10
);
}
else
{
render::RenderText(
g::hdcBuffer,
screenHead.x + (width / 2 + 5),
screenHead.y,
playerName.c_str(),
RGB(75, 75, 175),
10
);
}
render::RenderText( render::RenderText(
g::hdcBuffer, g::hdcBuffer,
@@ -230,7 +159,7 @@ namespace hack {
10 10
); );
if (config::show_armor) if (config::show_extra_flags)
{ {
render::RenderText( render::RenderText(
g::hdcBuffer, g::hdcBuffer,
@@ -244,35 +173,48 @@ namespace hack {
), ),
10 10
); );
render::RenderText(
g::hdcBuffer,
screenHead.x + (width / 2 + 5),
screenHead.y + 32,
(std::to_string(roundedDistance) + "m away").c_str(),
config::esp_distance_color,
10
);
} }
if (config::show_distance) /**
* Great idea by @ifBars that will be implemented later on
*/
/*
if (config::head_tracker)
{ {
if (config::rainbow) if (roundedDistance > 35)
{ {
render::RenderText( render::DrawFilledBox(
g::hdcBuffer, g::hdcBuffer,
screenHead.x + (width / 2 + 5), screenHead.x - (head_width / 2),
screenHead.y + 32, (screenHead.y + 10 - (roundedDistance / 80)) - (head_height / 2),
(std::to_string(roundedDistance) + "m away").c_str(), head_width,
rainbowColor, head_height,
10 (localTeam == playerTeam ? RGB(75, 175, 75) : RGB(175, 75, 75))
); );
} }
else else if (roundedDistance > 5)
{ {
render::RenderText( render::DrawFilledBox(
g::hdcBuffer, g::hdcBuffer,
screenHead.x + (width / 2 + 5), screenHead.x - (head_width / 2),
screenHead.y + 32, screenHead.y + 25 - (head_height / 2),
(std::to_string(roundedDistance) + "m away").c_str(), head_width,
RGB(75, 75, 175), head_height,
10 (localTeam == playerTeam ? RGB(75, 175, 75) : RGB(175, 75, 75))
); );
} }
} }
*/
} }
playerIndex++;
} }
std::this_thread::sleep_for(std::chrono::milliseconds(1)); std::this_thread::sleep_for(std::chrono::milliseconds(1));
} }
+4 -9
View File
@@ -137,10 +137,11 @@ int main() {
//SetActiveWindow(hack::process->hwnd_); //SetActiveWindow(hack::process->hwnd_);
#ifndef _UC #ifndef _UC
std::cout << "\n[settings] In Game keybinds:\n\t[F5] enable/disable Team ESP\n\t[F6] enable/disable automatic updates\n\t[F7] enable/disable rainbow boxes & names\n\t[F8] enable/disable player distances\n\t[F9] enable/disable player armor\n\t[F10] enable/disable player head tracker\n\t[fin] Unload esp.\n" << std::endl; std::cout << "\n[settings] In Game keybinds:\n\t[F5] enable/disable Team ESP\n\t[F6] enable/disable automatic updates\n\t[F7] enable/disable extra flags\n\t[end] Unload esp.\n" << std::endl;
#else #else
std::cout << "\n[settings] In Game keybinds:\n\t[F5] enable/disable Team ESP\n\t[fin] Unload esp\n" << std::endl; std::cout << "\n[settings] In Game keybinds:\n\t[F5] enable/disable Team ESP\n\t[F7] enable/disable extra flags\n\t[end] Unload esp\n" << std::endl;
#endif #endif
std::cout << "[settings] Make sure you check the config for additional settings!" << std::endl;
// Message loop // Message loop
MSG msg; MSG msg;
@@ -152,13 +153,7 @@ int main() {
#ifndef _UC #ifndef _UC
if (GetAsyncKeyState(VK_F6) & 0x8000) { config::automatic_update = !config::automatic_update; config::save(); Beep(700, 100); } if (GetAsyncKeyState(VK_F6) & 0x8000) { config::automatic_update = !config::automatic_update; config::save(); Beep(700, 100); }
#endif #endif
if (GetAsyncKeyState(VK_F7) & 0x8000) { config::rainbow = !config::rainbow; config::save(); Beep(700, 100); }; if (GetAsyncKeyState(VK_F7) & 0x8000) { config::show_extra_flags = !config::show_extra_flags; config::save(); Beep(700, 100); };
if (GetAsyncKeyState(VK_F8) & 0x8000) { config::show_distance = !config::show_distance; config::save(); Beep(700, 100); };
if (GetAsyncKeyState(VK_F9) & 0x8000) { config::show_armor = !config::show_armor; config::save(); Beep(700, 100); };
if (GetAsyncKeyState(VK_F10) & 0x8000) { config::head_tracker = !config::head_tracker; config::save(); Beep(700, 100); };
TranslateMessage(&msg); TranslateMessage(&msg);
DispatchMessage(&msg); DispatchMessage(&msg);