Checking rendering items out of bounds when looking at the ground & removed handle hijack because of not working properly

This commit is contained in:
IMXNOOBX
2025-01-14 18:12:42 +01:00
parent 58ec1dc3f2
commit 93c831084b
5 changed files with 136 additions and 127 deletions
+5
View File
@@ -11,4 +11,9 @@ void Utils::update_console_title() {
config::show_extra_flags ? title += " | Flags: [O]" : title += " | Flags: [X]";
SetConsoleTitle(title.c_str());
}
bool Utils::is_in_bounds(const Vector3& pos, int width, int heigh) {
return pos.x >= 0 && pos.x <= width && pos.y >= 0 && pos.y <= heigh;
}
+2
View File
@@ -3,11 +3,13 @@
#include <string>
#include "config.hpp"
#include "vector.hpp"
class Utils {
private:
public:
void update_console_title();
bool is_in_bounds(const Vector3& pos, int width, int heigh);
};
inline Utils utils;
+126 -123
View File
@@ -6,7 +6,6 @@
#include "../classes/globals.hpp"
namespace hack {
std::vector<std::pair<std::string, std::string>> boneConnections = {
{"neck_0", "spine_1"},
{"spine_1", "spine_2"},
@@ -27,7 +26,7 @@ namespace hack {
void loop() {
std::lock_guard<std::mutex> lock(dataMutex);
std::lock_guard<std::mutex> lock(reader_mutex);
if (g_game.isC4Planted)
{
@@ -73,165 +72,169 @@ namespace hack {
const Vector3 screenPos = g_game.world_to_screen(&player->origin);
const Vector3 screenHead = g_game.world_to_screen(&player->head);
if (screenPos.z >= 0.01f) {
const float height = screenPos.y - screenHead.y;
const float width = height / 2.4f;
if (
screenPos.z < 0.01f ||
!utils.is_in_bounds(screenPos, g_game.game_bounds.right, g_game.game_bounds.bottom)
)
continue;
float distance = g_game.localOrigin.calculate_distance(player->origin);
int roundedDistance = std::round(distance / 10.f);
const float height = screenPos.y - screenHead.y;
const float width = height / 2.4f;
if (config::show_head_tracker) {
render::DrawCircle(
float distance = g_game.localOrigin.calculate_distance(player->origin);
int roundedDistance = std::round(distance / 10.f);
if (config::show_head_tracker) {
render::DrawCircle(
g::hdcBuffer,
player->bones.bonePositions["head"].x,
player->bones.bonePositions["head"].y - width / 12,
width / 5,
(g_game.localTeam == player->team ? config::esp_skeleton_color_team : config::esp_skeleton_color_enemy)
);
}
if (config::show_skeleton_esp) {
for (const auto& connection : boneConnections) {
const std::string& boneFrom = connection.first;
const std::string& boneTo = connection.second;
render::DrawLine(
g::hdcBuffer,
player->bones.bonePositions["head"].x,
player->bones.bonePositions["head"].y - width / 12,
width / 5,
(g_game.localTeam == player->team ? config::esp_skeleton_color_team : config::esp_skeleton_color_enemy)
);
}
if (config::show_skeleton_esp) {
for (const auto& connection : boneConnections) {
const std::string& boneFrom = connection.first;
const std::string& boneTo = connection.second;
render::DrawLine(
g::hdcBuffer,
player->bones.bonePositions[boneFrom].x, player->bones.bonePositions[boneFrom].y,
player->bones.bonePositions[boneTo].x, player->bones.bonePositions[boneTo].y,
g_game.localTeam == player->team ? config::esp_skeleton_color_team : config::esp_skeleton_color_enemy
);
}
}
if (config::show_box_esp)
{
render::DrawBorderBox(
g::hdcBuffer,
screenHead.x - width / 2,
screenHead.y,
width,
height,
(g_game.localTeam == player->team ? config::esp_box_color_team : config::esp_box_color_enemy)
player->bones.bonePositions[boneFrom].x, player->bones.bonePositions[boneFrom].y,
player->bones.bonePositions[boneTo].x, player->bones.bonePositions[boneTo].y,
g_game.localTeam == player->team ? config::esp_skeleton_color_team : config::esp_skeleton_color_enemy
);
}
}
if (config::show_box_esp)
{
render::DrawBorderBox(
g::hdcBuffer,
screenHead.x - (width / 2 + 10),
screenHead.y + (height * (100 - player->armor) / 100),
2,
height - (height * (100 - player->armor) / 100),
RGB(0, 185, 255)
);
render::DrawBorderBox(
g::hdcBuffer,
screenHead.x - (width / 2 + 5),
screenHead.y + (height * (100 - player->health) / 100),
2,
height - (height * (100 - player->health) / 100),
RGB(
(255 - player->health),
(55 + player->health * 2),
75
)
);
render::RenderText(
g::hdcBuffer,
screenHead.x + (width / 2 + 5),
screenHead.x - width / 2,
screenHead.y,
player->name.c_str(),
config::esp_name_color,
10
width,
height,
(g_game.localTeam == player->team ? config::esp_box_color_team : config::esp_box_color_enemy)
);
}
/**
* I know is not the best way but a simple way to not saturate the screen with a ton of information
*/
if (roundedDistance > config::flag_render_distance)
continue;
render::DrawBorderBox(
g::hdcBuffer,
screenHead.x - (width / 2 + 10),
screenHead.y + (height * (100 - player->armor) / 100),
2,
height - (height * (100 - player->armor) / 100),
RGB(0, 185, 255)
);
render::DrawBorderBox(
g::hdcBuffer,
screenHead.x - (width / 2 + 5),
screenHead.y + (height * (100 - player->health) / 100),
2,
height - (height * (100 - player->health) / 100),
RGB(
(255 - player->health),
(55 + player->health * 2),
75
)
);
render::RenderText(
g::hdcBuffer,
screenHead.x + (width / 2 + 5),
screenHead.y,
player->name.c_str(),
config::esp_name_color,
10
);
/**
* I know is not the best way but a simple way to not saturate the screen with a ton of information
*/
if (roundedDistance > config::flag_render_distance)
continue;
render::RenderText(
g::hdcBuffer,
screenHead.x + (width / 2 + 5),
screenHead.y + 10,
(std::to_string(player->health) + "hp").c_str(),
RGB(
(255 - player->health),
(55 + player->health * 2),
75
),
10
);
render::RenderText(
g::hdcBuffer,
screenHead.x + (width / 2 + 5),
screenHead.y + 20,
(std::to_string(player->armor) + "armor").c_str(),
RGB(
(255 - player->armor),
(55 + player->armor * 2),
75
),
10
);
if (config::show_extra_flags)
{
render::RenderText(
g::hdcBuffer,
screenHead.x + (width / 2 + 5),
screenHead.y + 10,
(std::to_string(player->health) + "hp").c_str(),
RGB(
(255 - player->health),
(55 + player->health * 2),
75
),
screenHead.y + 30,
player->weapon.c_str(),
config::esp_distance_color,
10
);
render::RenderText(
g::hdcBuffer,
screenHead.x + (width / 2 + 5),
screenHead.y + 20,
(std::to_string(player->armor) + "armor").c_str(),
RGB(
(255 - player->armor),
(55 + player->armor * 2),
75
),
screenHead.y + 40,
(std::to_string(roundedDistance) + "m away").c_str(),
config::esp_distance_color,
10
);
if (config::show_extra_flags)
render::RenderText(
g::hdcBuffer,
screenHead.x + (width / 2 + 5),
screenHead.y + 50,
("$" + std::to_string(player->money)).c_str(),
RGB(0, 125, 0),
10
);
if (player->flashAlpha > 100)
{
render::RenderText(
g::hdcBuffer,
screenHead.x + (width / 2 + 5),
screenHead.y + 30,
player->weapon.c_str(),
screenHead.y + 60,
"Player is flashed",
config::esp_distance_color,
10
);
}
if (player->is_defusing)
{
const std::string defuText = "Player is defusing";
render::RenderText(
g::hdcBuffer,
screenHead.x + (width / 2 + 5),
screenHead.y + 40,
(std::to_string(roundedDistance) + "m away").c_str(),
screenHead.y + 60,
defuText.c_str(),
config::esp_distance_color,
10
);
render::RenderText(
g::hdcBuffer,
screenHead.x + (width / 2 + 5),
screenHead.y + 50,
("$" + std::to_string(player->money)).c_str(),
RGB(0, 125, 0),
10
);
if (player->flashAlpha > 100)
{
render::RenderText(
g::hdcBuffer,
screenHead.x + (width / 2 + 5),
screenHead.y + 60,
"Player is flashed",
config::esp_distance_color,
10
);
}
if (player->is_defusing)
{
const std::string defuText = "Player is defusing";
render::RenderText(
g::hdcBuffer,
screenHead.x + (width / 2 + 5),
screenHead.y + 60,
defuText.c_str(),
config::esp_distance_color,
10
);
}
}
}
}
+2 -3
View File
@@ -43,7 +43,7 @@ void CGame::init() {
std::cout << "[cs2] Waiting for cs2.exe..." << std::endl;
process = std::make_shared<pProcess>();
while (!process->AttachProcessHj("cs2.exe"))
while (!process->AttachProcess("cs2.exe"))
std::this_thread::sleep_for(std::chrono::seconds(1));
std::cout << "[cs2] Attached to cs2.exe\n" << std::endl;
@@ -68,8 +68,7 @@ void CGame::close() {
}
void CGame::loop() {
std::lock_guard<std::mutex> lock(dataMutex);
std::lock_guard<std::mutex> lock(reader_mutex);
if (updater::offsets::dwLocalPlayerController == 0x0)
throw std::runtime_error("Offsets have not been corretly set, cannot proceed.");
+1 -1
View File
@@ -77,4 +77,4 @@ private:
inline CGame g_game;
inline std::mutex dataMutex;
inline std::mutex reader_mutex;