-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesp.cpp
More file actions
115 lines (91 loc) · 3.09 KB
/
Copy pathesp.cpp
File metadata and controls
115 lines (91 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include "esp.h"
int screenheight = GetSystemMetrics(SM_CYSCREEN);
int screenwidth = GetSystemMetrics(SM_CXSCREEN);
bool ESP::IsTeamGame()
{
if ((*gameMode == 0 || *gameMode == 4 || *gameMode == 5 || *gameMode == 7 || *gameMode == 11 || *gameMode == 13 ||
*gameMode == 14 || *gameMode == 16 || *gameMode == 17 || *gameMode == 20 || *gameMode == 21))
return true;
else return false;
}
bool ESP::IsEnemy(ent* e)
{
if (localPlayer->team == e->team)
return false;
else return true;
}
bool ESP::IsValidEnt(ent* ent)
{
if (ent)
{
if (ent->vTable == 0x4E4A98 || ent->vTable == 0x4E4AC0)
return true;
}
return false;
}
void ESP::DrawESPBox(ent* e, vec3 screen, GL::Font& font)
{
const GLubyte* color = nullptr;
if (IsTeamGame() && !IsEnemy(e))
color = rgb::green;
else color = rgb::red;
float dist = localPlayer->pos.Distance(e->pos);
float scale = (GAME_UNIT_MAGIC / dist) * (viewport[2] / VIRTUAL_SCREEN_WIDTH);
float x = screen.x - scale;
float y = screen.y - scale * PLAYER_ASPECT_RATIO;
float width = scale * 2;
float height = scale * PLAYER_ASPECT_RATIO * 2;
GL::DrawOutline(x, y, width, height, 2.0f, color);
float textX = font.centerText(x, width, strlen(e->name) * ESP_FONT_WIDTH);
float textY = y - ESP_FONT_HEIGHT / 2;
font.Print(textX, textY, color, "%s", e->name);
}
void ESP::Drawline(ent* e, vec3 screen)
{
const GLubyte* color = nullptr; // color
if (IsTeamGame() && !IsEnemy(e)) // team colors and enemy color
color = rgb::green;
else color = rgb::red;
float dist = localPlayer->pos.Distance(e->pos); // gets the distance from us to the entity
float x1 = screen.x;
float y1 = screen.y;
float x2 = 512; // screen width line x postion
float y2 = screenheight / 2.0f; // lin y position
GL::DrawLine(x1, y1, x2, y2, color);
}
void ESP::Draw(GL::Font& font)
{
glGetIntegerv(GL_VIEWPORT, viewport);
for (int i = 0; i < (*numOfPlayers); i++)
{
if (entlist && entlist->ents && IsValidEnt(entlist->ents[i]))
{
ent* e = entlist->ents[i];
vec3 center = e->head;
center.z = center.z - EYE_HEIGHT + PLAYER_HEIGHT / 2;
vec3 screenCoords;
if (WorldToScreen(center, screenCoords, matrix, viewport[2], viewport[3]))
{
DrawESPBox(e, screenCoords, font);
}
}
}
}
void ESP::DrawL(GL::Font& font)
{
glGetIntegerv(GL_VIEWPORT, viewport);
for (int i = 0; i < (*numOfPlayers); i++)
{
if (entlist && entlist->ents && IsValidEnt(entlist->ents[i]))
{
ent* e = entlist->ents[i];
vec3 center = e->head;
center.z = center.z - EYE_HEIGHT; // where the line goes
vec3 screenCoords;
if (WorldToScreen(center, screenCoords, matrix, viewport[2], viewport[3]))
{
Drawline(e, screenCoords);
}
}
}
}