-
Notifications
You must be signed in to change notification settings - Fork 0
/
ESP.cpp
123 lines (90 loc) · 5.51 KB
/
ESP.cpp
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
116
117
118
119
120
121
122
123
#include "ESP.h"
ESP::ESP() : AbstractModule("ESP", Category::Render) {
EventManager::getInstance().reg(Event::EventRenderOverlay, MakeHandler(this, &ESP::onRenderOverlay));
}
ESP* ESP::getInstance() {
static ESP* inst = new ESP();
return inst;
}
void ESP::onEnabled() {
}
void ESP::onDisabled() {
}
void ESP::onRenderOverlay() {
ToggleCheck;
IngameCheck;
Vec3 ePos;
Vec2 view;
Vec4 camera;
for (SDK::ClientPlayer* p : Game::playerInWorld) {
ePos.x = p->actorBody->entity->posX;
ePos.y = p->actorBody->entity->posY;
ePos.z = p->actorBody->entity->posZ;
view = Game::getGameViewSize();
view.x *= 0.5f;
view.y *= 0.5f;
camera.w = Game::theUIRenderer->matrixLevel1->matrixLevel2->matrix[0][3] * p->actorBody->entity->posX + Game::theUIRenderer->matrixLevel1->matrixLevel2->matrix[1][3] * p->actorBody->entity->posY + Game::theUIRenderer->matrixLevel1->matrixLevel2->matrix[2][3] * p->actorBody->entity->posZ + Game::theUIRenderer->matrixLevel1->matrixLevel2->matrix[3][3];
if (camera.w < 0.01f) continue;
float scale = 1 / camera.w;
camera.x = view.x + (Game::theUIRenderer->matrixLevel1->matrixLevel2->matrix[0][0] * p->actorBody->entity->posX + Game::theUIRenderer->matrixLevel1->matrixLevel2->matrix[1][0] * p->actorBody->entity->posY + Game::theUIRenderer->matrixLevel1->matrixLevel2->matrix[2][0] * p->actorBody->entity->posZ + Game::theUIRenderer->matrixLevel1->matrixLevel2->matrix[3][0]) * scale * view.x;
camera.y = view.y - (Game::theUIRenderer->matrixLevel1->matrixLevel2->matrix[0][1] * p->actorBody->entity->posX + Game::theUIRenderer->matrixLevel1->matrixLevel2->matrix[1][1] * p->actorBody->entity->posY + Game::theUIRenderer->matrixLevel1->matrixLevel2->matrix[2][1] * p->actorBody->entity->posZ + Game::theUIRenderer->matrixLevel1->matrixLevel2->matrix[3][1]) * scale * view.y;
camera.z = view.y - (Game::theUIRenderer->matrixLevel1->matrixLevel2->matrix[0][1] * p->actorBody->entity->posX + Game::theUIRenderer->matrixLevel1->matrixLevel2->matrix[1][1] * (p->actorBody->entity->posY + 200) + Game::theUIRenderer->matrixLevel1->matrixLevel2->matrix[2][1] * p->actorBody->entity->posZ + Game::theUIRenderer->matrixLevel1->matrixLevel2->matrix[3][1]) * scale * view.y;
float rectHeight = camera.y - camera.z;
float rectWidth = rectHeight * 0.6015625f;
ImVec2 rectPos1 = { camera.x - rectWidth / 2, camera.z + 6 };
ImVec2 rectPos2 = { rectPos1.x + rectWidth, rectPos1.y + rectHeight + 6 };
float lineLength = 8;
ImVec2 rightTop(rectPos1.x + rectWidth, rectPos1.y);
ImVec2 leftBottom(rectPos2.x - rectWidth, rectPos2.y);
// Health rect
float curHealth = p->playerAttribuLua->currentHealth;
float maxHealth = p->playerAttribuLua->maxHealth;
ImVec2 healthPos1(rectPos1.x - 10, rectPos1.y);
ImVec2 healthPos2(rectPos1.x - 5, rectPos1.y + rectHeight);
float healthHeight = Utility::map(curHealth, 0, maxHealth, healthPos2.y, healthPos1.y);
ImVec2 curHealthPos(healthPos1.x + 1, healthHeight + 1);
// »æÖÆ
ImDrawList* dl = ImGui::GetForegroundDrawList();
if (TeamCheck && Game::thePlayer->isSameTeam(p->playerTeamComponent->team)) {
// Left Top
dl->AddLine(rectPos1, ImVec2(rectPos1.x + lineLength, rectPos1.y), IM_COL32(18, 255, 18, 245), 1.8f);
dl->AddLine(rectPos1, ImVec2(rectPos1.x, rectPos1.y + lineLength), IM_COL32(18, 255, 18, 245), 1.8f);
// Right Top
dl->AddLine(rightTop, ImVec2(rightTop.x - lineLength, rightTop.y), IM_COL32(18, 255, 18, 245), 1.8f);
dl->AddLine(rightTop, ImVec2(rightTop.x, rightTop.y + lineLength), IM_COL32(18, 255, 18, 245), 1.8f);
// Left Bottom
dl->AddLine(leftBottom, ImVec2(leftBottom.x + lineLength, leftBottom.y), IM_COL32(18, 255, 18, 245), 1.8f);
dl->AddLine(leftBottom, ImVec2(leftBottom.x, leftBottom.y - lineLength), IM_COL32(18, 255, 18, 245), 1.8f);
// Right Bottom
dl->AddLine(rectPos2, ImVec2(rectPos2.x - lineLength, rectPos2.y), IM_COL32(18, 255, 18, 245), 1.8f);
dl->AddLine(rectPos2, ImVec2(rectPos2.x, rectPos2.y - lineLength), IM_COL32(18, 255, 18, 245), 1.8f);
}
else {
// Left Top
dl->AddLine(rectPos1, ImVec2(rectPos1.x + lineLength, rectPos1.y), IM_COL32(255, 18, 18, 245), 1.8f);
dl->AddLine(rectPos1, ImVec2(rectPos1.x, rectPos1.y + lineLength), IM_COL32(255, 18, 18, 245), 1.8f);
// Right Top
dl->AddLine(rightTop, ImVec2(rightTop.x - lineLength, rightTop.y), IM_COL32(255, 18, 18, 245), 1.8f);
dl->AddLine(rightTop, ImVec2(rightTop.x, rightTop.y + lineLength), IM_COL32(255, 18, 18, 245), 1.8f);
// Left Bottom
dl->AddLine(leftBottom, ImVec2(leftBottom.x + lineLength, leftBottom.y), IM_COL32(255, 18, 18, 245), 1.8f);
dl->AddLine(leftBottom, ImVec2(leftBottom.x, leftBottom.y - lineLength), IM_COL32(255, 18, 18, 245), 1.8f);
// Right Bottom
dl->AddLine(rectPos2, ImVec2(rectPos2.x - lineLength, rectPos2.y), IM_COL32(255, 18, 18, 245), 1.8f);
dl->AddLine(rectPos2, ImVec2(rectPos2.x, rectPos2.y - lineLength), IM_COL32(255, 18, 18, 245), 1.8f);
}
// Health
if (curHealth <= (maxHealth / 3)) {
dl->AddRectFilled(curHealthPos, healthPos2, IM_COL32(255, 10, 10, 245));
dl->AddRect(healthPos1, healthPos2, IM_COL32(10, 10, 10, 255));
}
else if (curHealth <= (maxHealth / 2) && curHealth > (maxHealth / 3)) {
dl->AddRectFilled(curHealthPos, healthPos2, IM_COL32(255, 255, 10, 245));
dl->AddRect(healthPos1, healthPos2, IM_COL32(10, 10, 10, 255));
}
else if (curHealth <= maxHealth && curHealth > (maxHealth / 2)) {
dl->AddRectFilled(curHealthPos, healthPos2, IM_COL32(10, 255, 10, 245));
dl->AddRect(healthPos1, healthPos2, IM_COL32(10, 10, 10, 255));
}
}
}