forked from sstokic-tgm/Gladiatorcheatz-Public
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEntity.cpp
646 lines (514 loc) · 14.9 KB
/
Entity.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
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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
#include "harCs.hpp"
#include "Entity.hpp"
int Entity::getTeam()
{
return *(int*)((DWORD)this + offs.entTeam);
}
bool Entity::isPlayer()
{
Entity *ent = NULL;
for (int i = 0; i < 64; i++)
{
ent = reinterpret_cast<Entity*>(csFuncs->getEntityById(i));
if (ent == this)
return true;
}
return false;
}
DWORD Entity::getGlowIndex()
{
return *(DWORD*)((DWORD)this + offs.entGlowIndex);
}
bool Entity::isStationary()
{
return *(bool*)((DWORD)this + offs.stationary);
}
bool Entity::isImmune()
{
return *(bool*)((DWORD)this + offs.immun);
}
bool Entity::getLifeState()
{
return *(bool*)((DWORD)this + offs.lifeSt);
}
int &Entity::getFlags()
{
return *(int*)((DWORD)this + offs.flags);
}
int Entity::getMoveTip()
{
return *(int*)((DWORD)this + 0x258);
}
int Entity::getFiredShots()
{
return *(int*)((DWORD)this + offs.metakFired);
}
int Entity::getTickBase()
{
return *(int*)((DWORD)this + offs.tickBase);
}
int Entity::getArmVal()
{
return *(int*)((DWORD)this + offs.armVal);
}
bool Entity::getHelm()
{
return *(bool*)((DWORD)this + offs.hHelm);
}
bool Entity::getHeavArm()
{
return *(bool*)((DWORD)this + offs.hHeavArmor);
}
Vector3 Entity::getVel()
{
return *(Vector3*)((DWORD)this + offs.vekVel);
}
Vector3 Entity::predict(Vector3 v0)
{
return (v0 + (this->getVel() * p_GlobVars->interval_per_tick));
}
Vector3 Entity::getVektPunch()
{
return *(Vector3*)((DWORD)this + offs.aimPunch);
}
Vector3 Entity::getVecAechse()
{
return *(Vector3*)((DWORD)this + offs.vecAechse);
}
Vector3 Entity::getViewOriginal()
{
return *(Vector3*)((DWORD)this + offs.viewOriginal);
}
int Entity::getCompRank(int idx)
{
DWORD tmp = *(DWORD*)(csFuncs->dClientDll + offs.gameRes);
return *(int*)((DWORD)tmp + offs.compRank + (int)idx * 4);
}
int Entity::getCompWins(int idx)
{
DWORD tmp = *(DWORD*)(csFuncs->dClientDll + offs.gameRes);
return *(int*)((DWORD)tmp + offs.compWins + (int)idx * 4);
}
bool Entity::getGameResConnected(int idx)
{
DWORD tmp = *(DWORD*)(csFuncs->dClientDll + offs.gameRes);
return *(bool*)((DWORD)tmp + offs.resConnected + idx);
}
int Entity::getGameResTeam(int idx)
{
DWORD tmp = *(DWORD*)(csFuncs->dClientDll + offs.gameRes);
return *(int*)((DWORD)tmp + offs.resTeam + (int)idx * 4);
}
std::wstring Entity::getName(int idx)
{
DWORD tmpBase = *(DWORD*)(csFuncs->dClientDll + offs.radar);
DWORD tmp = *(DWORD*)(tmpBase + 0x54);
wchar_t *wcName = (wchar_t*)(tmp + 0x1E0 * idx + 0x24);
std::wstring name(wcName);
return name;
}
int Entity::getLeben()
{
return *(int*)((DWORD)this + offs.leben);
}
Vector3 Entity::getSkeletById(int idx)
{
matrix3x4_t kostToWorldOut[128];
if (this->setupBones(kostToWorldOut, 128, 0x100, 0))
return Vector3(kostToWorldOut[idx][0][3], kostToWorldOut[idx][1][3], kostToWorldOut[idx][2][3]);
else
return Vector3(0, 0, 0);
}
int Entity::getSkeletByName(const char *imeKost)
{
studiohdr_t *studioHdr = p_ModelInfo->GetStudioModel(this->getModel());
if (!studioHdr)
return -1;
matrix3x4_t kostToWorldOut[128];
if (!this->setupBones(kostToWorldOut, 128, 256, 0))
return -1;
for (int i = 0; i < studioHdr->numbones; i++)
{
mstudiobone_t *studioKost = studioHdr->pBone(i);
if (!studioKost)
continue;
if (studioKost->pszName() && strcmp(studioKost->pszName(), imeKost) == 0)
return i;
}
return -1;
}
EntityWeapon *Entity::getWeapon()
{
DWORD weap = *(DWORD*)((DWORD)this + offs.activWeap);
auto plyrWeap = p_ClientEntList->GetClientEntityFromHandle(weap);
if (plyrWeap)
return reinterpret_cast<EntityWeapon*>(plyrWeap);
else
return NULL;
}
UINT *Entity::getWeapons()
{
return (UINT*)((DWORD)this + 0x2DE8);
}
int Entity::getWeaponId()
{
DWORD weap = *(DWORD*)((DWORD)this + offs.activWeap);
auto plyrWeap = p_ClientEntList->GetClientEntityFromHandle(weap);
if (plyrWeap)
return *(int*)(reinterpret_cast<EntityWeapon*>(plyrWeap) + offs.itmDI);
else
return 0;
}
int *Entity::getModelIdx()
{
return (int*)((DWORD)this + offs.modIdx);
}
DWORD Entity::getViewModel()
{
return *(DWORD*)((DWORD)this + offs.viewModel);
}
Client *Entity::getClientCls()
{
void *netwable = (void*)((DWORD)(this) + 0x8);
typedef Client*(__thiscall *o_GetClientCls)(void*);
return VT::vfunc<o_GetClientCls>(netwable, 2)(netwable);
}
int Entity::getIdx()
{
void *netwable = (void*)((DWORD)(this) + 0x8);
typedef int(__thiscall *o_GetIdx)(void*);
return VT::vfunc<o_GetIdx>(netwable, 10)(netwable);
}
model_t *Entity::getModel()
{
return *(model_t**)((DWORD)this + 0x6C);
}
bool Entity::setupBones(matrix3x4_t *kostToWorldOut, int maxKosti, int kostMaska, float curtime)
{
//*(int*)((DWORD)(this) + offs.iCheckForOccl) = p_GlobVars->framecount;
//*(int*)((DWORD)(this) + 0xA28) = 0;
//*(int*)((DWORD)(this) + offs.upisivaKost) = 0;
//*(int*)((DWORD)(this) + offs.iCheckForOccl) = p_GlobVars->framecount;
//reinterpret_cast<void(__fastcall*)(void*)>(offs.invalKostCache)(this);
void *rendable = (void*)((DWORD)(this) + 0x4);
typedef bool(__thiscall *o_setupBones)(void*, matrix3x4_t*, int, int, float);
return VT::vfunc<o_setupBones>(rendable, 13)(rendable, kostToWorldOut, maxKosti, kostMaska, curtime);
}
void AngleIMatrix(const QAngle& angles, matrix3x4_t& matrix)
{
Assert(s_bMathlibInitialized);
float sr, sp, sy, cr, cp, cy;
SinCos(DEG2RAD(angles[1]), &sy, &cy);
SinCos(DEG2RAD(angles[0]), &sp, &cp);
SinCos(DEG2RAD(angles[2]), &sr, &cr);
// matrix = (YAW * PITCH) * ROLL
matrix[0][0] = cp*cy;
matrix[0][1] = cp*sy;
matrix[0][2] = -sp;
matrix[1][0] = sr*sp*cy + cr*-sy;
matrix[1][1] = sr*sp*sy + cr*cy;
matrix[1][2] = sr*cp;
matrix[2][0] = (cr*sp*cy + -sr*-sy);
matrix[2][1] = (cr*sp*sy + -sr*cy);
matrix[2][2] = cr*cp;
matrix[0][3] = 0.f;
matrix[1][3] = 0.f;
matrix[2][3] = 0.f;
}
bool Entity::setupBonesEx(Entity *player, int kostMaska, matrix3x4_t *kostToWorldOut)
{
//void *rendable = (void*)((DWORD)player + 0x4);
//if (!rendable)
// return false;
//studiohdr_t *studiohdr = p_ModelInfo->GetStudioModel(player->getModel());
//if (!studiohdr)
// return false;
//// 9876 boneaccessor
//// 9884 oldWritableBones m_WritableBones
//// 9880 oldReadableBones m_ReadableBones
//matrix3x4_t *backup_matrix = *(matrix3x4_t**)((DWORD)rendable + 0x2694);
//if (!backup_matrix)
// return false;
//int oldReadableBones = *(int*)((DWORD)rendable + 9880);
//int bonesMaskNeedRecalc = kostMaska | oldReadableBones;
//// raw
//Vector3 origin = lagComp->m_LagRecord[player->getIdx()][mVars.historyIdx].m_vAbsOrigin;
//Vector3 angles = lagComp->m_LagRecord[player->getIdx()][mVars.historyIdx].m_vecAngles;
//// backup interpolated data
//Vector3 backup_absorigin = player->getAbsOriginal();
//Vector3 backup_absangles = player->getAbsAechse();
//float backup_poses[24];
//for (int i = 0; i < 24; i++)
// backup_poses[i] = player->getPoseParams(i);
//matrix3x4_t parentTransform;
//AngleIMatrix(angles, parentTransform);
//parentTransform[0][3] = origin.xAechse;
//parentTransform[1][3] = origin.yAechse;
//parentTransform[2][3] = origin.zAechse;
//player->setAbsOriginal(origin);
//player->setAbsAechse(angles);
//for (int i = 0; i < 24; i++)
// *(float*)((DWORD)player + offs.poseParams + sizeof(float) * i) = lagComp->m_LagRecord[player->getIdx()][mVars.historyIdx].m_flPoseParameter[i];
//*(int*)((DWORD)rendable + 224) |= 8;//AddFlag( EFL_SETTING_UP_BONES ); (1 << 3));
//Vector3 pos[128];
//Quaternion q[128];
//memset(pos, 0xFF, sizeof(pos));
//memset(q, 0xFF, sizeof(q));
//player->standardBlendingRules(studiohdr, pos, q, p_GlobVars->curtime, bonesMaskNeedRecalc);
//*(matrix3x4_t**)((DWORD)rendable + 0x2694) = kostToWorldOut;
//byte computed[0x100] = { 0 };
//player->buildTransformations(studiohdr, pos, q, parentTransform, bonesMaskNeedRecalc, computed);
//*(int*)((DWORD)rendable + 224) &= ~(8);//AddFlag( EFL_SETTING_UP_BONES ); (1 << 3));
//*(matrix3x4_t**)((DWORD)rendable + 0x2694) = backup_matrix;
//player->setAbsOriginal(backup_absorigin);
//player->setAbsAechse(backup_absangles);
//for (int i = 0; i < 24; i++)
// *(float*)((DWORD)player + offs.poseParams + sizeof(float) * i) = backup_poses[i];
return true;
}
Collideable *Entity::getCollideable()
{
return (Collideable*)((DWORD)this + offs.coll);
}
DWORD Entity::getRgflCoordinateFrame()
{
return offs.rgflCoordinateFrame;
}
Vector3 *Entity::getHeadRot()
{
return (Vector3*)((DWORD)this + offs.angRot);
}
float &Entity::getLowBodYtarg()
{
return *(float*)((DWORD)this + offs.lowBodYtarg);
}
int Entity::getHitboxSet()
{
return *(int*)((DWORD)this + offs.hitboxSet);
}
Vector3 &Entity::getEyeAechse()
{
return *(Vector3*)((DWORD)this + offs.angEyeAechse);
}
bool Entity::isAlive()
{
return (bool)(*(int*)((DWORD)this + offs.lifeSt) == 0);
}
bool Entity::isZum()
{
return *(bool*)((DWORD)this + offs.uZum);
}
int Entity::getOwner()
{
return *(int*)((DWORD)this + offs.owner);
}
float &Entity::getSimulTime()
{
return *(float*)((DWORD)this + offs.simulTime);
}
float &Entity::getCycle()
{
return *(float*)((DWORD)this + offs.cycle);
}
int &Entity::getSequence()
{
return *(int*)((DWORD)this + offs.sequence);
}
Vector3 &Entity::getAbsOriginal()
{
typedef Vector3&(__thiscall *o_getAbsOriginal)(void*);
return VT::vfunc<o_getAbsOriginal>(this, 10)(this);
}
Vector3 &Entity::getNetOriginal()
{
static int offset = netMngr->getOffs(XorStr("CCSPlayer"), XorStr("m_flFriction")) - sizeof(Vector3);
return *(Vector3*)((DWORD)this + offset);
}
Vector3 &Entity::getAbsAechse()
{
typedef Vector3&(__thiscall *o_getAbsAechse)(void*);
return VT::vfunc<o_getAbsAechse>(this, 11)(this);
}
void Entity::setAbsOriginal(Vector3 origin)
{
using SetAbsOriginFn = void(__thiscall*)(void*, const Vector3 &origin);
static SetAbsOriginFn SetAbsOrigin;
if (!SetAbsOrigin)
SetAbsOrigin = (SetAbsOriginFn)(csFuncs->findPattern(XorStr("\x55\x8B\xEC\x83\xE4\xF8\x51\x53\x56\x57\x8B\xF1\xE8\x00\x00"), XorStr("xxxxxxxxxxxxx??"), csFuncs->dClientDll, csFuncs->dClientDll + csFuncs->dClientDllSize, 0));
SetAbsOrigin(this, origin);
}
void Entity::setAbsAechse(Vector3 aechse)
{
using SetAbsAechseFn = void(__thiscall*)(void*, const Vector3 &aechse);
static SetAbsAechseFn SetAbsAechse;
if (!SetAbsAechse)
SetAbsAechse = (SetAbsAechseFn)(csFuncs->findPattern(XorStr("\x55\x8B\xEC\x83\xE4\xF8\x83\xEC\x64\x53\x56\x57\x8B\xF1\xE8"), XorStr("xxxxxxxxxxxxxxx"), csFuncs->dClientDll, csFuncs->dClientDll + csFuncs->dClientDllSize, 0));
SetAbsAechse(this, aechse);
}
Vector3 const &Entity::getRenderOrigin()
{
void *rendable = (void*)((DWORD)(this) + 0x4);
typedef Vector3&(__thiscall *o_GetRenderOrigin)(void*);
return VT::vfunc<o_GetRenderOrigin>(rendable, 1)(rendable);
}
QAngle const &Entity::getRenderAechse()
{
void *rendable = (void*)((DWORD)(this) + 0x4);
typedef QAngle&(__thiscall *o_GetRenderAechse)(void*);
return VT::vfunc<o_GetRenderAechse>(rendable, 2)(rendable);
}
float &Entity::getPoseParams(int idx)
{
return *reinterpret_cast<float*>(reinterpret_cast<uintptr_t>(this) + offs.poseParams + sizeof(float) * idx);
}
void *Entity::getObsTarget()
{
return (void*)((DWORD)this + offs.obsTrgt);
}
int Entity::getChockedPackets()
{
if (this->getSimulTime() > Global::oldSimulTime[this->getIdx()])
return TIME_TO_TICKS(fabs(this->getSimulTime() - Global::oldSimulTime[this->getIdx()]));
return 0;
}
int Entity::getChockedTicks()
{
if (this->getSimulTime() > this->getOldSimulTime())
return TIME_TO_TICKS(fabs(this->getSimulTime() - this->getOldSimulTime()));
return 0;
}
float &Entity::getSurfaceFriction()
{
static int offs = netMngr->getOffs(XorStr("CBaseEntity"), XorStr("m_surfaceFriction"));
return *(float*)((DWORD)this + offs);
}
float &Entity::getStepSize()
{
static int offs = netMngr->getOffs(XorStr("CBaseEntity"), XorStr("m_flStepSize"));
return *(float*)((DWORD)this + offs);
}
float &Entity::getMaxSpeed()
{
static int offs = netMngr->getOffs(XorStr("CBasePlayer"), XorStr("m_flMaxSpeed"));
return *(float*)((DWORD)this + offs);
}
float &Entity::getFallVel()
{
static int offs = netMngr->getOffs(XorStr("CBasePlayer"), XorStr("m_flFallVelocity"));
return *(float*)((DWORD)this + offs);
}
float &Entity::getAnimTime()
{
return *(float*)((DWORD)this + offs.animTime);
}
float &Entity::getOldSimulTime()
{
static int offs = netMngr->getOffs(XorStr("CBaseEntity"), XorStr("m_flSimulationTime")) + 0x4;
return *(float*)((DWORD)this + offs);
}
int &Entity::getDucked()
{
return *(int*)((DWORD)this + offs.ducked);
}
int &Entity::getDucking()
{
return *(int*)((DWORD)this + offs.ducking);
}
float &Entity::getDuckAmnt()
{
return *(float*)((DWORD)this + offs.duckAmnt);
}
float &Entity::getDuckSpeed()
{
return *(float*)((DWORD)this + offs.duckSpeed);
}
void Entity::standardBlendingRules(studiohdr_t *studiohdr, Vector3 *pos, Quaternion *q, float curtime, int kostMaska)
{
typedef void(__thiscall *o_standardBlendingRules)(void*, studiohdr_t*, Vector3*, Quaternion*, float, int);
VT::vfunc<o_standardBlendingRules>(this, 200)(this, studiohdr, pos, q, curtime, kostMaska);
}
void Entity::buildTransformations(studiohdr_t *studiohdr, Vector3 *pos, Quaternion *q, const matrix3x4_t &cameraTransform, int kostMaska, byte *computed)
{
typedef void(__thiscall *o_buildTransformations)(void*, studiohdr_t*, Vector3*, Quaternion*, const matrix3x4_t &, int, byte*);
VT::vfunc<o_buildTransformations>(this, 184)(this, studiohdr, pos, q, cameraTransform, kostMaska, computed);
}
void Entity::updateClientSideAnimation()
{
typedef void(__thiscall *o_updateClientSideAnimation)(void*);
VT::vfunc<o_updateClientSideAnimation>(this, 218)(this);
}
DWORD *Entity::getVarMap()
{
return nullptr;
}
float EntityWeapon::getAccurPen()
{
return *(float*)((DWORD)this + offs.accPen);
}
float EntityWeapon::getNextPrimAtt()
{
return *(float*)((DWORD)this + offs.nextPrimAtt);
}
float EntityWeapon::getInac()
{
typedef float(__thiscall *o_getInac)(void*);
return VT::vfunc<o_getInac>(this, 469)(this);
}
float EntityWeapon::getSir()
{
typedef float(__thiscall *o_getSir)(void*);
return VT::vfunc<o_getSir>(this, 439)(this);
}
void EntityWeapon::upAccurPen()
{
typedef void(__thiscall *o_upAccurPen)(void*);
VT::vfunc<o_upAccurPen>(this, 470)(this);
}
bool EntityWeapon::isEmpty()
{
int clip = *(int*)((DWORD)this + offs.clip);
return clip == 0;
}
bool EntityWeapon::isReload()
{
return *(bool*)((DWORD)this + 0x3235);
}
WeapInfo_t *EntityWeapon::getWeapInfo()
{
if (!this || this == NULL)
return NULL;
typedef WeapInfo_t *(__thiscall *o_getWeapInfo)(void*);
return VT::vfunc<o_getWeapInfo>(this, 446)(this);
}
int *EntityWeapon::getItemDefIdx()
{
return (int*)((DWORD)this + offs.itmDI);
}
int *EntityWeapon::getItemIdHigh()
{
return (int*)((DWORD)this + offs.itemIdHigh);
}
char *EntityWeapon::getCustName()
{
return (char*)((DWORD)this + offs.custName);
}
int *EntityWeapon::getFallbackPK()
{
return (int*)((DWORD)this + offs.fallbackPK);
}
int *EntityWeapon::getFallbackS()
{
return (int*)((DWORD)this + offs.fallbackS);
}
float *EntityWeapon::getFallbackW()
{
return (float*)((DWORD)this + offs.fallbackW);
}
int *EntityWeapon::getFallbackST()
{
return (int*)((DWORD)this + offs.fallbackST);
}
int *EntityWeapon::getAccId()
{
return (int*)((DWORD)this + offs.accId);
}