-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMiscClasses.h
708 lines (583 loc) · 20.2 KB
/
MiscClasses.h
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
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
/*
Syn's AyyWare Framework 2015
*/
#pragma once
#include "MiscDefinitions.h"
#include "ClientRecvProps.h"
#include "offsets.h"
#include "Vector.h"
#include "bspflags.h"
// Entity List
class IClientEntityList
{
public:
virtual void Function0();
virtual void Function1();
virtual void Function2();
virtual IClientEntity * GetClientEntity(int entnum);
virtual IClientEntity * GetClientEntityFromHandle(HANDLE hEnt) = 0;
virtual int NumberOfEntities(bool bIncludeNonNetworkable) = 0;
virtual int GetHighestEntityIndex(void);
virtual void SetMaxEntities(int maxents);
virtual int GetMaxEntities();
};
// Panels
class IPanel
{
public:
const char *GetName(unsigned int vguiPanel)
{
typedef const char* (__thiscall* OriginalFn)(PVOID, unsigned int);
return call_vfunc<OriginalFn>(this, Offsets::VMT::Panel_GetName)(this, vguiPanel);
}
};
// Colors
class Color
{
public:
// constructors
Color()
{
*((int *)this) = 0;
}
Color(int r, int g, int b)
{
SetColor(r, g, b, 0);
}
Color(int r, int g, int b, int a)
{
SetColor(r, g, b, a);
}
void SetColor(int r, int g, int b, int a = 0)
{
_color[0] = (unsigned char)r;
_color[1] = (unsigned char)g;
_color[2] = (unsigned char)b;
_color[3] = (unsigned char)a;
}
void GetColor(int &r, int &g, int &b, int &a) const
{
r = _color[0];
g = _color[1];
b = _color[2];
a = _color[3];
}
void SetRawColor(int color32)
{
*((int *)this) = color32;
}
int GetRawColor() const
{
return *((int *)this);
}
inline int r() const { return _color[0]; }
inline int g() const { return _color[1]; }
inline int b() const { return _color[2]; }
inline int a() const { return _color[3]; }
void SetAlpha(int a) { _color[0] = (unsigned char)a; }
int GetAlpha() { return _color[0]; }
unsigned char &operator[](int index)
{
return _color[index];
}
const unsigned char &operator[](int index) const
{
return _color[index];
}
bool operator == (const Color &rhs) const
{
return (*((int *)this) == *((int *)&rhs));
}
bool operator != (const Color &rhs) const
{
return !(operator==(rhs));
}
Color &operator=(const Color &rhs)
{
SetRawColor(rhs.GetRawColor());
return *this;
}
private:
unsigned char _color[4];
};
// Debug Overlay
class IVDebugOverlay
{
public:
virtual void AddEntityTextOverlay(int ent_index, int line_offset, float duration, int r, int g, int b, int a, const char *format, ...) = 0;
virtual void AddBoxOverlay(const Vector& origin, const Vector& mins, const Vector& max, Vector const& orientation, int r, int g, int b, int a, float duration) = 0;
virtual void AddSphereOverlay(const Vector& vOrigin, float flRadius, int nTheta, int nPhi, int r, int g, int b, int a, float flDuration) = 0;
virtual void AddTriangleOverlay(const Vector& p1, const Vector& p2, const Vector& p3, int r, int g, int b, int a, bool noDepthTest, float duration) = 0;
virtual void AddLineOverlay(const Vector& origin, const Vector& dest, int r, int g, int b, bool noDepthTest, float duration) = 0;
virtual void AddTextOverlay(const Vector& origin, float duration, const char *format, ...) = 0;
virtual void AddTextOverlay(const Vector& origin, int line_offset, float duration, const char *format, ...) = 0;
virtual void AddScreenTextOverlay(float flXPos, float flYPos, float flDuration, int r, int g, int b, int a, const char *text) = 0;
virtual void AddSweptBoxOverlay(const Vector& start, const Vector& end, const Vector& mins, const Vector& max, const Vector & angles, int r, int g, int b, int a, float flDuration) = 0;
virtual void AddGridOverlay(const Vector& origin) = 0;
virtual void AddCoordFrameOverlay(const matrix3x4& frame, float flScale, int vColorTable[3][3] = NULL) = 0;
virtual int ScreenPosition(const Vector& point, Vector& screen) = 0;
virtual int ScreenPosition(float flXPos, float flYPos, Vector& screen) = 0;
virtual void *GetFirst(void) = 0;
virtual void *GetNext(void *current) = 0;
virtual void ClearDeadOverlays(void) = 0;
virtual void ClearAllOverlays() = 0;
virtual void AddTextOverlayRGB(const Vector& origin, int line_offset, float duration, float r, float g, float b, float alpha, const char *format, ...) = 0;
virtual void AddTextOverlayRGB(const Vector& origin, int line_offset, float duration, int r, int g, int b, int a, const char *format, ...) = 0;
virtual void AddLineOverlayAlpha(const Vector& origin, const Vector& dest, int r, int g, int b, int a, bool noDepthTest, float duration) = 0;
virtual void AddBoxOverlay2(const Vector& origin, const Vector& mins, const Vector& max, Vector const& orientation, const Color& faceColor, const Color& edgeColor, float duration) = 0;
virtual void PurgeTextOverlays() = 0;
};
// User Cmd's
class CUserCmd
{
public:
virtual ~CUserCmd() {}; //Destructor 0
CUserCmd()
{
Reset();
}
void Reset()
{
command_number = 0;
tick_count = 0;
viewangles.Init();
forwardmove = 0.0f;
sidemove = 0.0f;
upmove = 0.0f;
buttons = 0;
impulse = 0;
weaponselect = 0;
weaponsubtype = 0;
random_seed = 0;
mousedx = 0;
mousedy = 0;
headangles.Init();
headoffset.Init();
hasbeenpredicted = false;
}
CUserCmd& operator =(const CUserCmd& src)
{
if (this == &src)
return *this;
command_number = src.command_number;
tick_count = src.tick_count;
viewangles = src.viewangles;
forwardmove = src.forwardmove;
sidemove = src.sidemove;
upmove = src.upmove;
buttons = src.buttons;
impulse = src.impulse;
weaponselect = src.weaponselect;
weaponsubtype = src.weaponsubtype;
random_seed = src.random_seed;
mousedx = src.mousedx;
mousedy = src.mousedy;
hasbeenpredicted = src.hasbeenpredicted;
headangles = src.headangles;
headoffset = src.headoffset;
return *this;
}
CUserCmd(const CUserCmd& src)
{
*this = src;
}
int command_number;
int tick_count;
Vector viewangles;
Vector aimdirection;
float forwardmove;
float sidemove;
float upmove;
int buttons;
BYTE impulse;
int weaponselect;
int weaponsubtype;
int random_seed;
short mousedx;
short mousedy;
bool hasbeenpredicted;
Vector headangles;
Vector headoffset;
};
class CGlobalVarsBase
{
public:
float realtime;
int framecount;
float absoluteframetime;
float absoluteframestarttimestddev;
float curtime;
float frametime;
int maxClients;
int tickcount;
float interval_per_tick;
float interpolation_amount;
int simTicksThisFrame;
int network_protocol;
void* pSaveData;
bool m_bClient;
int nTimestampNetworkingBase;
int nTimestampRandomizeWindow;
};
struct Ray_t
{
__declspec(align(16)) Vector m_Start;
__declspec(align(16)) Vector m_Delta;
__declspec(align(16)) Vector m_StartOffset;
__declspec(align(16)) Vector m_Extents;
//without your matrix3x4
bool m_IsRay;
bool m_IsSwept;
void Init(Vector& vecStart, Vector& vecEnd)
{
m_Delta = vecEnd - vecStart;
m_IsSwept = (m_Delta.LengthSqr() != 0);
m_Extents.x = m_Extents.y = m_Extents.z = 0.0f;
m_IsRay = true;
m_StartOffset.x = m_StartOffset.y = m_StartOffset.z = 0.0f;
m_Start = vecStart;
}
};
struct cplane_t
{
Vector normal;
float dist;
BYTE type;
BYTE signbits;
BYTE pad[2];
};
class CBaseTrace
{
public:
Vector startpos;
Vector endpos;
cplane_t plane;
float fraction;
int contents;
unsigned short dispFlags;
bool allsolid;
bool startsolid;
};
struct csurface_t
{
const char* name;
short surfaceProps;
unsigned short flags;
};
class CGameTrace : public CBaseTrace
{
public:
bool DidHitWorld() const;
bool DidHitNonWorldEntity() const;
int GetEntityIndex() const;
bool DidHit() const;
public:
float fractionleftsolid;
csurface_t surface;
int hitgroup;
short physicsbone;
unsigned short worldSurfaceIndex;
IClientEntity* m_pEnt;
int hitbox;
char shit[0x24];
};
inline bool CGameTrace::DidHit() const
{
return fraction < 1.0f || allsolid || startsolid;
}
typedef CGameTrace trace_t;
enum TraceType_t
{
TRACE_EVERYTHING = 0,
TRACE_WORLD_ONLY,
TRACE_ENTITIES_ONLY,
TRACE_EVERYTHING_FILTER_PROPS,
};
class ITraceFilter
{
public:
virtual bool ShouldHitEntity(IClientEntity* pEntity, int contentsMask) = 0;
virtual TraceType_t GetTraceType() const = 0;
};
class CTraceFilter : public ITraceFilter
{
public:
bool ShouldHitEntity(IClientEntity* pEntityHandle, int contentsMask)
{
return !(pEntityHandle == pSkip);
}
TraceType_t GetTraceType() const
{
return TRACE_EVERYTHING;
}
void* pSkip;
};
class IEngineTrace
{
public:
int GetPointContents(const Vector &vecAbsPosition, int contentsMask = MASK_ALL, IClientEntity** ppEntity = NULL)
{
typedef int(__thiscall* fnGetPointContents)(void*, const Vector&, int, IClientEntity**);
return call_vfunc<fnGetPointContents>(this, 0)(this, vecAbsPosition, contentsMask, ppEntity);
}
void TraceRay(const Ray_t &ray, unsigned int fMask, ITraceFilter* pTraceFilter, trace_t* pTrace)
{
typedef void(__thiscall* fnTraceRay)(void*, const Ray_t&, unsigned int, ITraceFilter*, trace_t*);
call_vfunc<fnTraceRay>(this, 5)(this, ray, fMask, pTraceFilter, pTrace);
}
};
struct mstudiobbox_t
{
int bone;
int group;
Vector bbmin;
Vector bbmax;
int szhitboxnameindex;
int unused[8];
char* GetHitboxName(void)
{
if (szhitboxnameindex == 0)
return "";
return ((char*)this) + szhitboxnameindex;
}
};
struct mstudiohitboxset_t
{
int sznameindex;
inline char* const GetName(void) const { return ((char*)this) + sznameindex; }
int numhitboxes;
int hitboxindex;
inline mstudiobbox_t* GetHitbox(int i) const { return (mstudiobbox_t*)(((byte*)this) + hitboxindex) + i; };
};
struct mstudiobone_t
{
int sznameindex;
inline char * const GetName(void) const { return ((char *)this) + sznameindex; }
int parent;
int bonecontroller[6];
Vector pos;
float quat[4];
Vector rot;
Vector posscale;
Vector rotscale;
matrix3x4 poseToBone;
float qAlignment[4];
int flags;
int proctype;
int procindex; // procedural rule
mutable int physicsbone; // index into physically simulated bone
inline void * GetProcedure() const { if (procindex == 0) return NULL; else return (void *)(((byte *)this) + procindex); };
int surfacepropidx; // index into string tablefor property name
inline char * const GetSurfaceProps(void) const { return ((char *)this) + surfacepropidx; }
int contents; // See BSPFlags.h for the contents flags
int unused[8]; // remove as appropriate
};
struct studiohdr_t
{
int id;
int version;
int checksum;
char name[64];
int length;
Vector eyeposition;
Vector illumposition;
Vector hull_min;
Vector hull_max;
Vector view_bbmin;
Vector view_bbmax;
int flags;
int numbones;
int boneindex;
inline mstudiobone_t *GetBone(int i) const { return (mstudiobone_t *)(((byte *)this) + boneindex) + i; };
// inline mstudiobone_t *pBone(int i) const { Assert(i >= 0 && i < numbones); return (mstudiobone_t *)(((byte *)this) + boneindex) + i; };
int numbonecontrollers;
int bonecontrollerindex;
int numhitboxsets;
int hitboxsetindex;
mstudiohitboxset_t* GetHitboxSet(int i) const
{
return (mstudiohitboxset_t*)(((byte*)this) + hitboxsetindex) + i;
}
inline mstudiobbox_t* GetHitbox(int i, int set) const
{
mstudiohitboxset_t const* s = GetHitboxSet(set);
if (!s)
return NULL;
return s->GetHitbox(i);
}
inline int GetHitboxCount(int set) const
{
mstudiohitboxset_t const* s = GetHitboxSet(set);
if (!s)
return 0;
return s->numhitboxes;
}
int numlocalanim;
int localanimindex;
int numlocalseq;
int localseqindex;
mutable int activitylistversion;
mutable int eventsindexed;
int numtextures;
int textureindex;
int numcdtextures;
int cdtextureindex;
int numskinref;
int numskinfamilies;
int skinindex;
int numbodyparts;
int bodypartindex;
int numlocalattachments;
int localattachmentindex;
int numlocalnodes;
int localnodeindex;
int localnodenameindex;
int numflexdesc;
int flexdescindex;
int numflexcontrollers;
int flexcontrollerindex;
int numflexrules;
int flexruleindex;
int numikchains;
int ikchainindex;
int nummouths;
int mouthindex;
int numlocalposeparameters;
int localposeparamindex;
int surfacepropindex;
int keyvalueindex;
int keyvaluesize;
int numlocalikautoplaylocks;
int localikautoplaylockindex;
float mass;
int contents;
int numincludemodels;
int includemodelindex;
mutable void *virtualModel;
int szanimblocknameindex;
int numanimblocks;
int animblockindex;
mutable void *animblockModel;
int bonetablebynameindex;
void *pVertexBase;
void *pIndexBase;
byte constdirectionallightdot;
byte rootLOD;
byte numAllowedRootLODs;
byte unused[1];
int unused4;
int numflexcontrollerui;
int flexcontrolleruiindex;
float flVertAnimFixedPointScale;
int unused3[1];
int studiohdr2index;
int unused2[1];
};
struct surfacephysicsparams_t
{
float friction;
float elasticity; // collision elasticity - used to compute coefficient of restitution
float density; // physical density (in kg / m^3)
float thickness; // material thickness if not solid (sheet materials) in inches
float dampening;
};
struct surfaceaudioparams_t
{
float reflectivity; // like elasticity, but how much sound should be reflected by this surface
float hardnessFactor; // like elasticity, but only affects impact sound choices
float roughnessFactor; // like friction, but only affects scrape sound choices
float roughThreshold; // surface roughness > this causes "rough" scrapes, < this causes "smooth" scrapes
float hardThreshold; // surface hardness > this causes "hard" impacts, < this causes "soft" impacts
float hardVelocityThreshold; // collision velocity > this causes "hard" impacts, < this causes "soft" impacts
};
struct surfacesoundnames_t
{
unsigned short stepleft;
unsigned short stepright;
unsigned short impactSoft;
unsigned short impactHard;
unsigned short scrapeSmooth;
unsigned short scrapeRough;
unsigned short bulletImpact;
unsigned short rolling;
unsigned short breakSound;
unsigned short strainSound;
};
struct surfacegameprops_t
{
public:
float maxSpeedFactor; //0x0000
float jumpFactor; //0x0004
char pad00[0x4]; //0x0008
float flPenetrationModifier; //0x000C
float flDamageModifier; //0x0010
unsigned short material; //0x0014
char pad01[0x3];
};//Size=0x0019
struct surfacedata_t
{
surfacephysicsparams_t physics;
surfaceaudioparams_t audio;
surfacesoundnames_t sounds;
surfacegameprops_t game;
};
class IPhysicsSurfaceProps
{
public:
surfacedata_t *GetSurfaceData(int surfaceDataIndex)
{
typedef surfacedata_t*(__thiscall* fnGetSurfaceData)(void*, int);
return call_vfunc<fnGetSurfaceData>(this, 5)(this, surfaceDataIndex);
}
};
class ConVar
{
public:
//void SetString(const char *pValue)
//{
// typedef void(__thiscall* SetStringFn)(void*, const char *);
// call_vfunc<SetStringFn>(this, 17)(this, pValue);
//}
void SetString(const char* str)
{
typedef void(__thiscall* SetStringFn)(void*, const char*);
return call_vfunc<SetStringFn>(this, 13)(this, str);
}
void InternalSetString(const char* str)
{
typedef void(__thiscall* SetStringFn)(void*, const char*);
return call_vfunc<SetStringFn>(this, 17)(this, str);
}
char* GetBaseName()
{
typedef char*(__thiscall* SetStringFn)(void*);
return call_vfunc<SetStringFn>(this, 6)(this);
}
char pad_0x0000[0x4]; //0x0000
ConVar* pNext; //0x0004
__int32 bRegistered; //0x0008
char* pszName; //0x000C
char* pszHelpString; //0x0010
__int32 nFlags; //0x0014
char pad_0x0018[0x4]; //0x0018
ConVar* pParent; //0x001C
char* pszDefaultValue; //0x0020
char* strString; //0x0024
__int32 StringLength; //0x0028
float fValue; //0x002C
__int32 nValue; //0x0030
__int32 bHasMin; //0x0034
float fMinVal; //0x0038
__int32 bHasMax; //0x003C
float fMaxVal; //0x0040
void *fnChangeCallback; //0x0044
};//Size=0x0048
class ICVar
{
public:
ConVar *FindVar(const char *var_name)
{
typedef ConVar*(__thiscall* FindVarFn)(void*, const char *);
return call_vfunc<FindVarFn>(this, 15)(this, var_name);
}
};