-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsdk.cpp
More file actions
331 lines (246 loc) · 6.6 KB
/
sdk.cpp
File metadata and controls
331 lines (246 loc) · 6.6 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
#include "sdk.h"
#include "util.h"
#include "pipe.h"
bool EInterface::Init(unsigned long** base)
{
if (m_vmt = base)
{
m_hook = new VMT(m_vmt);
m_size = m_hook->szVMT;
return 1;
}
return 0;
}
bool EInterface::Init(const char* dll, const char* name, int v)
{
CreateInterfaceFn CreateInterface = (CreateInterfaceFn)IMPORT(dll, "CreateInterface");
if (!v)
{
for (int i = 99; i && !v; i--)
if (CreateInterface(format("%s%03i", name, i), 0))
v = i;
}
return Init((unsigned long**)CreateInterface(format("%s%03i", name, v), 0));
}
void EInterface::HookMethod(int m, void* hook, void* original)
{
unsigned long org = m_hook->HookMethod((unsigned long)hook, m);
if (original)
*(unsigned long*)original = org;
}
unsigned long EInterface::GetMethod(int m)
{
return m_hook->GetMethodAddress(m);
}
unsigned long long
CBaseEntity::GetSteamID()
{
extern IEngine* engine;
player_info info;
engine->GetPlayerInfo(EntIndex(), &info);
return 76561197960265728ull + info.friendsid;
}
bool CBaseEntity::IsSteamFriend()
{
static unsigned pipe = ((unsigned (*)())IMPORT("steamclient", "Steam_CreateSteamPipe"))();
static unsigned user = ((unsigned (*)(int))IMPORT("steamclient", "Steam_ConnectToGlobalUser"))(pipe);
/*
static void* cl = ((CreateInterfaceFn)IMPORT("steamclient", "CreateInterface"))("SteamClient007", 0);
static void* fl = GetVFunc<void* (__thiscall*)(void*, unsigned, unsigned, const char*)>(cl, 8)(cl, user, pipe, "SteamFriends003");
static int e_fs[128];
int uid = (EntIndex() ^ GetTickBase()) & 0x7FFFFFFF;
int idx = EntIndex() % 128;
if ((e_fs[idx] & 0x7FFFFFFF) != uid)
{
e_fs[idx] = uid;
if (GetVFunc<char (__thiscall*)(void*, unsigned long long, int)>(fl, 5)(fl, GetSteamID(), 4) == 3)
e_fs[idx] |= 0x80000000;
}
if (e_fs[idx] & 0x80000000)
return 1;
*/
return 0;
}
const char* CBaseEntity::GetClassname()
{
typedef const char* (__thiscall* GetClassnameFn)(void*);
static GetClassnameFn f = (GetClassnameFn)util::CalcAbsAddress(util::FindPattern("client", "\xE8????\x50\x68????\xFF\x15????\x83\xC4\x0C\x5F\x5E\x8B\xE5") + 1);
return f(this);
}
WeaponInfo* CBaseEntity::GetWeaponInfo()
{
if (css())
{
typedef unsigned short (*LookupWeaponInfoSlotFn)(const char*);
typedef WeaponInfo* (*GetFileWeaponInfoFromHandleFn)(unsigned short);
static LookupWeaponInfoSlotFn LookupWeaponInfoSlot =
(LookupWeaponInfoSlotFn)util::FindPattern("client", "\x55\x8B\xEC\x8B\x45\x08\x83\xEC\x08\x85\xC0\x74\x18");
static GetFileWeaponInfoFromHandleFn GetFileWeaponInfoFromHandle =
(GetFileWeaponInfoFromHandleFn)util::FindPattern("client", "\x55\x8B\xEC\x66\x8B\x45\x08\x66\x3B\x05");
return GetFileWeaponInfoFromHandle(LookupWeaponInfoSlot(GetClassname()));
}
return 0;
}
studiohitboxset* CBaseEntity::hboxset = 0;
matrix3x4 CBaseEntity::matrix[BONE_ARRAY];
bool CBaseEntity::UpdateBones()
{
extern IModelInfo* mdlinfo;
void* mdl = GetModel(), *stdhdr = 0;
if (!mdl)
return 0;
stdhdr = mdlinfo->GetStudiomodel(mdl);
if (!stdhdr)
return 0;
typedef bool (__thiscall* SetupBonesFn)(void*, matrix3x4*, int, int, float);
static SetupBonesFn SetupBones =
(SetupBonesFn)util::FunctionStart(
util::FindRefString("client", "*** ERROR: Bone access not allowed (entity %i:%s)")
);
if (SetupBones((void**)this + 1, matrix, BONE_ARRAY, 0x100, ReadPtr<float>(this, m_flSimulationTime)))
if (hboxset = MakePtr<studiohitboxset>(stdhdr, ReadPtr<int>(stdhdr, 0xB0)))
return 1;
return 0;
}
CBaseEntity* CBaseEntity::GetActiveWeapon()
{
extern IEntities* ents;
extern IEngine* engine;
return ents->GetClientEntityHandle(ReadPtr<unsigned long>(this, m_hActiveWeapon));
}
Vector CBaseEntity::GetAbsOrigin()
{
static unsigned long m_vecAbsOrigin = *(unsigned long*)(util::FindPattern((unsigned long)GetVFunc<void*>(this, 9), 0x20, "\xE8????\x8D\x86?????\xC3") + 7);
//util::Message("m_vecAbsOrigin + %X", m_vecAbsOrigin);
// m_vecAbsOrigin = m_vecOrigin - 0xD8 // get rekt
return ReadPtr<Vector>(this, m_vecAbsOrigin);
}
Vector CBaseEntity::GetAbsAngles()
{
static unsigned long m_vecAbsAngles = *(unsigned long*)(util::FindPattern((unsigned long)GetVFunc<void*>(this, 10), 0x20, "\xE8????\x8D\x86?????\xC3") + 7);
//util::Message("m_vecAbsAngles + %X", m_vecAbsAngles);
// m_vecAbsAngles = m_vecOrigin - 0xD8 + 12 // get rekt
return ReadPtr<Vector>(this, m_vecAbsAngles);
}
int CBaseEntity::GetMaxHealth()
{
if (tf2())
{
switch (TF2_GetClassNum())
{
case Class_Scout:
return 125;
case Class_Soldier:
return 200;
case Class_Pyro:
return 175;
case Class_Demoman:
return 175;
case Class_Heavy:
return 300;
case Class_Engineer:
return 125;
case Class_Medic:
return 150;
case Class_Sniper:
return 125;
case Class_Spy:
return 125;
}
}
return 100;
}
unsigned CBaseEntity::GetHPColor()
{
float p = GetHealthPercentage();
if (p < 0.33f)
return CC_RED;
if (p < 0.66f)
return CC_YELLOW;
return CC_GREEN;
}
unsigned CBaseEntity::GetESPColor()
{
unsigned retc = CC_LIGHTYELLOW;
extern IEntities* ents;
extern IEngine* engine;
if (gmod())
retc = aimbot::Ignore(this) ? CC_LIGHTBLUE : CC_LIGHTRED;
else
{
int team = GetTeam();
if (tf2() && team != LocalPlayer()->GetTeam() && TF2_IsCloaked())
return CC_WHITE;
if (team == TEAM_RED)
{
retc = CC_LIGHTRED;
if (dod()) retc = CC_LIGHTGREEN;
}
if (team == TEAM_BLU)
{
retc = CC_LIGHTBLUE;
if (dod()) retc = CC_LIGHTRED;
}
}
if (ragebot == EntIndex())
retc = CC_PURPLE;
if (IsSteamFriend())
retc = COLOR((RED(retc) > 127) ? 255 : 0, (GREEN(retc) > 127) ? 255 : 0, (BLUE(retc) > 127) ? 255 : 0);
return retc;
}
const char* CBaseEntity::GetNick()
{
extern IEngine* engine;
static player_info info;
if (!engine->GetPlayerInfo(EntIndex(), &info))
return 0;
return info.name;
}
const char* CBaseEntity::GetNickSafe()
{
extern IEngine* engine;
static player_info info;
if (!engine->GetPlayerInfo(EntIndex(), &info))
return 0;
util::SafeFormat(info.name);
return info.name;
}
bool CBaseEntity::IsMelee()
{
int ammo = ReadPtr<int>(this, m_iPrimaryAmmoType);
return
(ammo == -1 ||
(tf2() && (ammo == 4)) ||
(
(css() && (ammo == 11)) ||
(css() && (ammo == 12)) ||
(css() && (ammo == 13))
)
);
}
const char* CBaseEntity::TF2_GetClass()
{
static char* num2alias[] =
{
"",
"Scout",
"Sniper",
"Soldier",
"Demoman",
"Medic",
"Heavy",
"Pyro",
"Spy",
"Engineer",
""
};
return num2alias[clamp(TF2_GetClassNum(), 0, sizeof(num2alias) / sizeof(char*) - 1)];
}
bool FilterGeneric::ShouldHitEntity(CBaseEntity* handle, int)
{
return handle != hIgnore;
}
int FilterGeneric::GetTraceType() const
{
return 0;
}