Checking rendering items out of bounds when looking at the ground & removed handle hijack because of not working properly
This commit is contained in:
@@ -11,4 +11,9 @@ void Utils::update_console_title() {
|
|||||||
config::show_extra_flags ? title += " | Flags: [O]" : title += " | Flags: [X]";
|
config::show_extra_flags ? title += " | Flags: [O]" : title += " | Flags: [X]";
|
||||||
|
|
||||||
SetConsoleTitle(title.c_str());
|
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;
|
||||||
}
|
}
|
||||||
@@ -3,11 +3,13 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
|
#include "vector.hpp"
|
||||||
|
|
||||||
class Utils {
|
class Utils {
|
||||||
private:
|
private:
|
||||||
public:
|
public:
|
||||||
void update_console_title();
|
void update_console_title();
|
||||||
|
bool is_in_bounds(const Vector3& pos, int width, int heigh);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline Utils utils;
|
inline Utils utils;
|
||||||
+126
-123
@@ -6,7 +6,6 @@
|
|||||||
#include "../classes/globals.hpp"
|
#include "../classes/globals.hpp"
|
||||||
|
|
||||||
namespace hack {
|
namespace hack {
|
||||||
|
|
||||||
std::vector<std::pair<std::string, std::string>> boneConnections = {
|
std::vector<std::pair<std::string, std::string>> boneConnections = {
|
||||||
{"neck_0", "spine_1"},
|
{"neck_0", "spine_1"},
|
||||||
{"spine_1", "spine_2"},
|
{"spine_1", "spine_2"},
|
||||||
@@ -27,7 +26,7 @@ namespace hack {
|
|||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(dataMutex);
|
std::lock_guard<std::mutex> lock(reader_mutex);
|
||||||
|
|
||||||
if (g_game.isC4Planted)
|
if (g_game.isC4Planted)
|
||||||
{
|
{
|
||||||
@@ -73,165 +72,169 @@ namespace hack {
|
|||||||
const Vector3 screenPos = g_game.world_to_screen(&player->origin);
|
const Vector3 screenPos = g_game.world_to_screen(&player->origin);
|
||||||
const Vector3 screenHead = g_game.world_to_screen(&player->head);
|
const Vector3 screenHead = g_game.world_to_screen(&player->head);
|
||||||
|
|
||||||
if (screenPos.z >= 0.01f) {
|
if (
|
||||||
const float height = screenPos.y - screenHead.y;
|
screenPos.z < 0.01f ||
|
||||||
const float width = height / 2.4f;
|
!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);
|
const float height = screenPos.y - screenHead.y;
|
||||||
int roundedDistance = std::round(distance / 10.f);
|
const float width = height / 2.4f;
|
||||||
|
|
||||||
if (config::show_head_tracker) {
|
float distance = g_game.localOrigin.calculate_distance(player->origin);
|
||||||
render::DrawCircle(
|
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,
|
g::hdcBuffer,
|
||||||
player->bones.bonePositions["head"].x,
|
player->bones.bonePositions[boneFrom].x, player->bones.bonePositions[boneFrom].y,
|
||||||
player->bones.bonePositions["head"].y - width / 12,
|
player->bones.bonePositions[boneTo].x, player->bones.bonePositions[boneTo].y,
|
||||||
width / 5,
|
g_game.localTeam == player->team ? config::esp_skeleton_color_team : config::esp_skeleton_color_enemy
|
||||||
(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)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config::show_box_esp)
|
||||||
|
{
|
||||||
render::DrawBorderBox(
|
render::DrawBorderBox(
|
||||||
g::hdcBuffer,
|
g::hdcBuffer,
|
||||||
screenHead.x - (width / 2 + 10),
|
screenHead.x - width / 2,
|
||||||
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,
|
screenHead.y,
|
||||||
player->name.c_str(),
|
width,
|
||||||
config::esp_name_color,
|
height,
|
||||||
10
|
(g_game.localTeam == player->team ? config::esp_box_color_team : config::esp_box_color_enemy)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
render::DrawBorderBox(
|
||||||
* I know is not the best way but a simple way to not saturate the screen with a ton of information
|
g::hdcBuffer,
|
||||||
*/
|
screenHead.x - (width / 2 + 10),
|
||||||
if (roundedDistance > config::flag_render_distance)
|
screenHead.y + (height * (100 - player->armor) / 100),
|
||||||
continue;
|
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(
|
render::RenderText(
|
||||||
g::hdcBuffer,
|
g::hdcBuffer,
|
||||||
screenHead.x + (width / 2 + 5),
|
screenHead.x + (width / 2 + 5),
|
||||||
screenHead.y + 10,
|
screenHead.y + 30,
|
||||||
(std::to_string(player->health) + "hp").c_str(),
|
player->weapon.c_str(),
|
||||||
RGB(
|
config::esp_distance_color,
|
||||||
(255 - player->health),
|
|
||||||
(55 + player->health * 2),
|
|
||||||
75
|
|
||||||
),
|
|
||||||
10
|
10
|
||||||
);
|
);
|
||||||
|
|
||||||
render::RenderText(
|
render::RenderText(
|
||||||
g::hdcBuffer,
|
g::hdcBuffer,
|
||||||
screenHead.x + (width / 2 + 5),
|
screenHead.x + (width / 2 + 5),
|
||||||
screenHead.y + 20,
|
screenHead.y + 40,
|
||||||
(std::to_string(player->armor) + "armor").c_str(),
|
(std::to_string(roundedDistance) + "m away").c_str(),
|
||||||
RGB(
|
config::esp_distance_color,
|
||||||
(255 - player->armor),
|
|
||||||
(55 + player->armor * 2),
|
|
||||||
75
|
|
||||||
),
|
|
||||||
10
|
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(
|
render::RenderText(
|
||||||
g::hdcBuffer,
|
g::hdcBuffer,
|
||||||
screenHead.x + (width / 2 + 5),
|
screenHead.x + (width / 2 + 5),
|
||||||
screenHead.y + 30,
|
screenHead.y + 60,
|
||||||
player->weapon.c_str(),
|
"Player is flashed",
|
||||||
config::esp_distance_color,
|
config::esp_distance_color,
|
||||||
10
|
10
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player->is_defusing)
|
||||||
|
{
|
||||||
|
const std::string defuText = "Player is defusing";
|
||||||
render::RenderText(
|
render::RenderText(
|
||||||
g::hdcBuffer,
|
g::hdcBuffer,
|
||||||
screenHead.x + (width / 2 + 5),
|
screenHead.x + (width / 2 + 5),
|
||||||
screenHead.y + 40,
|
screenHead.y + 60,
|
||||||
(std::to_string(roundedDistance) + "m away").c_str(),
|
defuText.c_str(),
|
||||||
config::esp_distance_color,
|
config::esp_distance_color,
|
||||||
10
|
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
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ void CGame::init() {
|
|||||||
std::cout << "[cs2] Waiting for cs2.exe..." << std::endl;
|
std::cout << "[cs2] Waiting for cs2.exe..." << std::endl;
|
||||||
|
|
||||||
process = std::make_shared<pProcess>();
|
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::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
|
|
||||||
std::cout << "[cs2] Attached to cs2.exe\n" << std::endl;
|
std::cout << "[cs2] Attached to cs2.exe\n" << std::endl;
|
||||||
@@ -68,8 +68,7 @@ void CGame::close() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CGame::loop() {
|
void CGame::loop() {
|
||||||
|
std::lock_guard<std::mutex> lock(reader_mutex);
|
||||||
std::lock_guard<std::mutex> lock(dataMutex);
|
|
||||||
|
|
||||||
if (updater::offsets::dwLocalPlayerController == 0x0)
|
if (updater::offsets::dwLocalPlayerController == 0x0)
|
||||||
throw std::runtime_error("Offsets have not been corretly set, cannot proceed.");
|
throw std::runtime_error("Offsets have not been corretly set, cannot proceed.");
|
||||||
|
|||||||
@@ -77,4 +77,4 @@ private:
|
|||||||
|
|
||||||
inline CGame g_game;
|
inline CGame g_game;
|
||||||
|
|
||||||
inline std::mutex dataMutex;
|
inline std::mutex reader_mutex;
|
||||||
Reference in New Issue
Block a user