-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathESP.cpp
130 lines (106 loc) · 4.55 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
124
125
126
127
128
129
130
#include "Render.h"
#include "Entity.h"
#include "ESP.h"
#include "Camera.h"
#include "Global.h"
#include "Utlilites.h"
#include "Settings.h"
#define MAX_PARTY 3
using GetDecryptedPos_t = void(__stdcall*)(uintptr_t, Vector*);
static GetDecryptedPos_t GetDecryptedPos_fn = nullptr;
bool bInplane = false;
cl_entity* pTeamArray[3];
void ESP::Draw()
{
auto CG_Entitys = Entity::GetCGEntitys();
if (!CG_Entitys)
return;
Globals::pRefDef = Globals::GetRefDef();
if (!Globals::pRefDef)
return;
//if (CG_Entitys)
//{
// // Plane Team check
// if (Globals::GetLocalPlayerPos().z < 0)
// {
// std::vector<cl_entity*> vEntity;
// for (int i = 0; i < 5; i++) // 200 to only get players
// {
// cl_entity* pEntity = (cl_entity*)(CG_Entitys + 0x318 * i);
// if (!pEntity)
// continue;
// // more than 3 therefore not in plane
// if (i > 3 && pEntity->type == 1)
// {
// vEntity.clear();
// break;
// }
// if (i < 3 && pEntity->type == 1)
// vEntity.push_back(pEntity);
// }
// for (int i = 0; i < vEntity.size(); i++) // 600
// pTeamArray[i] = vEntity[i];
//
// Utils::Log("", vEntity[0]);
// Utils::Log("", vEntity[1]);
// Utils::Log("", vEntity[2]);
// vEntity.clear();
// bInplane = true;
// }
// else
// bInplane = false;
// if (bInplane)
// return;
for (int i = 0; i < 800; i++) // 600
{
cl_entity* pEntity = (cl_entity*)(CG_Entitys + 0x318 * i);
if (!pEntity)
continue;
int type = pEntity->type;
if ((type == 1 && pEntity->valid & 1) && (Settings::bSnapLinesToggle || Settings::bTextToggle)) // player
{
auto pFnc = (*(uint32_t*)(Globals::pGameBase + 0x53389FC) ^ ((uintptr_t)pEntity + 0x38) ^ *(uint64_t*)((uintptr_t)pEntity + 0x40));
GetDecryptedPos_fn = (GetDecryptedPos_t)(pFnc);
if (!pFnc || !GetDecryptedPos_fn)
continue;
Vector validLocation;
GetDecryptedPos_fn((uintptr_t)pEntity + 0x48, &validLocation);
Vector vLocalPos = Globals::GetLocalPlayerPos();
if ((vLocalPos - validLocation).x <= 1.f && (vLocalPos - validLocation).x >= 0.f)
continue;
Vector2D screenPos;
if (WorldToScreen(validLocation, Globals::pRefDef, &screenPos))
{
int fdistance = sqrt(pow(vLocalPos.x - validLocation.x, 2) + pow(vLocalPos.y - validLocation.y, 2) + pow(vLocalPos.z - validLocation.z, 2)) * 0.0254f;
if (fdistance > 300)
continue;
ImColor color{ 20, 200, 30, 255 };
if (fdistance <= 100)
color = { 80, 127, 255, 255 };
std::string sdistance = "[" + std::to_string(fdistance); sdistance.append("m]");
std::string text = "Player " + sdistance;
if (Settings::bTextToggle)
g_Renderer->RenderText(text, ImVec2(screenPos.x-15, screenPos.y), 18, color);
if (Settings::bSnapLinesToggle)
g_Renderer->RenderLine(ImVec2(960, 1080), ImVec2(screenPos.x, screenPos.y), color);
}
}
else if (type == 14 && Settings::bTextToggle) // vehicle
{
Vector entpos = pEntity->location;
if (entpos.x < 2.f)
continue;
Vector2D screenPos;
if (WorldToScreen(entpos, Globals::pRefDef, &screenPos))
{
Vector vLocalPos = Globals::GetLocalPlayerPos();
int fdistance = sqrt(pow(vLocalPos.x - entpos.x, 2) + pow(vLocalPos.y - entpos.y, 2) + pow(vLocalPos.z - entpos.z, 2)) * 0.0254f;
if (fdistance > 600)
continue;
std::string sdistance = "[" + std::to_string(fdistance); sdistance.append("m]");
std::string text = "Vehicle " + sdistance;
g_Renderer->RenderText(text, ImVec2(screenPos.x-15, screenPos.y), 18, ImColor(80, 70, 200, 255));
}
}
}
}