forked from OneshotGH/supremacy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
entity.h
1523 lines (1260 loc) · 45.1 KB
/
entity.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
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#pragma once
#define MAX_WEAPONS 48
enum Hitboxes_t : int {
HITBOX_HEAD = 0,
HITBOX_NECK,
HITBOX_LOWER_NECK,
HITBOX_PELVIS,
HITBOX_BODY,
HITBOX_THORAX,
HITBOX_CHEST,
HITBOX_UPPER_CHEST,
HITBOX_R_THIGH,
HITBOX_L_THIGH,
HITBOX_R_CALF,
HITBOX_L_CALF,
HITBOX_R_FOOT,
HITBOX_L_FOOT,
HITBOX_R_HAND,
HITBOX_L_HAND,
HITBOX_R_UPPER_ARM,
HITBOX_R_FOREARM,
HITBOX_L_UPPER_ARM,
HITBOX_L_FOREARM,
HITBOX_MAX
};
enum RenderFlags_t : uint32_t {
STUDIO_NONE = 0x00000000,
STUDIO_RENDER = 0x00000001,
STUDIO_VIEWXFORMATTACHMENTS = 0x00000002,
STUDIO_DRAWTRANSLUCENTSUBMODELS = 0x00000004,
STUDIO_TWOPASS = 0x00000008,
STUDIO_STATIC_LIGHTING = 0x00000010,
STUDIO_WIREFRAME = 0x00000020,
STUDIO_ITEM_BLINK = 0x00000040,
STUDIO_NOSHADOWS = 0x00000080,
STUDIO_WIREFRAME_VCOLLIDE = 0x00000100,
STUDIO_NOLIGHTING_OR_CUBEMAP = 0x00000200,
STUDIO_SKIP_FLEXES = 0x00000400,
STUDIO_DONOTMODIFYSTENCILSTATE = 0x00000800,
STUDIO_TRANSPARENCY = 0x80000000,
STUDIO_SHADOWDEPTHTEXTURE = 0x40000000,
STUDIO_SHADOWTEXTURE = 0x20000000,
STUDIO_SKIP_DECALS = 0x10000000
};
enum BoneFlags_t : int {
BONE_USED_BY_ANYTHING = 0x0007FF00,
BONE_USED_BY_HITBOX = 0x00000100, // bone (or child) is used by a hit box
BONE_USED_BY_ATTACHMENT = 0x00000200, // bone (or child) is used by an attachment point
BONE_USED_BY_VERTEX_MASK = 0x0003FC00,
BONE_USED_BY_VERTEX_LOD0 = 0x00000400, // bone (or child) is used by the toplevel model via skinned vertex
BONE_USED_BY_VERTEX_LOD1 = 0x00000800,
BONE_USED_BY_VERTEX_LOD2 = 0x00001000,
BONE_USED_BY_VERTEX_LOD3 = 0x00002000,
BONE_USED_BY_VERTEX_LOD4 = 0x00004000,
BONE_USED_BY_VERTEX_LOD5 = 0x00008000,
BONE_USED_BY_VERTEX_LOD6 = 0x00010000,
BONE_USED_BY_VERTEX_LOD7 = 0x00020000,
BONE_USED_BY_BONE_MERGE = 0x00040000
};
enum CSWeaponType : int {
WEAPONTYPE_UNKNOWN = -1,
WEAPONTYPE_KNIFE,
WEAPONTYPE_PISTOL,
WEAPONTYPE_SUBMACHINEGUN,
WEAPONTYPE_RIFLE,
WEAPONTYPE_SHOTGUN,
WEAPONTYPE_SNIPER_RIFLE,
WEAPONTYPE_MACHINEGUN,
WEAPONTYPE_C4,
WEAPONTYPE_TASER,
WEAPONTYPE_GRENADE,
WEAPONTYPE_HEALTHSHOT = 11
};
enum teams_t : int {
TEAM_NOTEAM = 0,
TEAM_SPECTATOR,
TEAM_TERRORISTS,
TEAM_COUNTERTERRORISTS
};
enum effects_t : int {
EF_BONEMERGE = 0x001, // Performs bone merge on client side
EF_BRIGHTLIGHT = 0x002, // DLIGHT centered at entity origin
EF_DIMLIGHT = 0x004, // player flashlight
EF_NOINTERP = 0x008, // don't interpolate the next frame
EF_NOSHADOW = 0x010, // Don't cast no shadow
EF_NODRAW = 0x020, // don't draw entity
EF_NORECEIVESHADOW = 0x040, // Don't receive no shadow
EF_BONEMERGE_FASTCULL = 0x080, // For use with EF_BONEMERGE. If this is set, then it places this ent's origin at its
EF_ITEM_BLINK = 0x100, // blink an item so that the user notices it.
EF_PARENT_ANIMATES = 0x200, // always assume that the parent entity is animating
EF_MAX_BITS = 10
};
enum InvalidatePhysicsBits_t : int {
POSITION_CHANGED = 0x1,
ANGLES_CHANGED = 0x2,
VELOCITY_CHANGED = 0x4,
ANIMATION_CHANGED = 0x8,
};
enum DataUpdateType_t : int {
DATA_UPDATE_CREATED = 0,
DATA_UPDATE_DATATABLE_CHANGED,
};
enum LifeStates_t : int {
LIFE_ALIVE = 0,
LIFE_DYING,
LIFE_DEAD,
LIFE_RESPAWNABLE,
LIFE_DISCARDBODY,
};
enum PlayerFlags_t : int {
FL_ONGROUND = (1 << 0),
FL_DUCKING = (1 << 1),
FL_WATERJUMP = (1 << 3),
FL_ONTRAIN = (1 << 4),
FL_INRAIN = (1 << 5),
FL_FROZEN = (1 << 6),
FL_ATCONTROLS = (1 << 7),
FL_CLIENT = (1 << 8),
FL_FAKECLIENT = (1 << 9),
FL_INWATER = (1 << 10),
};
enum MoveType_t : int {
MOVETYPE_NONE = 0,
MOVETYPE_ISOMETRIC,
MOVETYPE_WALK,
MOVETYPE_STEP,
MOVETYPE_FLY,
MOVETYPE_FLYGRAVITY,
MOVETYPE_VPHYSICS,
MOVETYPE_PUSH,
MOVETYPE_NOCLIP,
MOVETYPE_LADDER,
MOVETYPE_OBSERVER,
MOVETYPE_CUSTOM,
MOVETYPE_LAST = MOVETYPE_CUSTOM,
MOVETYPE_MAX_BITS = 4,
};
enum Weapons_t : int {
DEAGLE = 1,
ELITE = 2,
FIVESEVEN = 3,
GLOCK = 4,
AK47 = 7,
AUG = 8,
AWP = 9,
FAMAS = 10,
G3SG1 = 11,
GALIL = 13,
M249 = 14,
M4A4 = 16,
MAC10 = 17,
P90 = 19,
UMP45 = 24,
XM1014 = 25,
BIZON = 26,
MAG7 = 27,
NEGEV = 28,
SAWEDOFF = 29,
TEC9 = 30,
ZEUS = 31,
P2000 = 32,
MP7 = 33,
MP9 = 34,
NOVA = 35,
P250 = 36,
SCAR20 = 38,
SG553 = 39,
SSG08 = 40,
KNIFE_T = 42,
FLASHBANG = 43,
HEGRENADE = 44,
SMOKE = 45,
MOLOTOV = 46,
DECOY = 47,
FIREBOMB = 48,
C4 = 49,
MUSICKIT = 58,
KNIFE_CT = 59,
M4A1S = 60,
USPS = 61,
TRADEUPCONTRACT = 62,
CZ75A = 63,
REVOLVER = 64,
KNIFE_BAYONET = 500,
KNIFE_FLIP = 505,
KNIFE_GUT = 506,
KNIFE_KARAMBIT = 507,
KNIFE_M9_BAYONET = 508,
KNIFE_HUNTSMAN = 509,
KNIFE_FALCHION = 512,
KNIFE_BOWIE = 514,
KNIFE_BUTTERFLY = 515,
KNIFE_SHADOW_DAGGERS = 516,
};
struct RenderableInstance_t {
uint8_t m_alpha;
__forceinline RenderableInstance_t() : m_alpha{ 255ui8 } {}
};
class Entity {
public:
// helper methods.
template< typename t >
__forceinline t &get(size_t offset) {
return *(t *)((uintptr_t)this + offset);
}
template< typename t >
__forceinline void set(size_t offset, const t &val) {
*(t *)((uintptr_t)this + offset) = val;
}
template< typename t >
__forceinline t as() {
return (t)this;
}
public:
// netvars / etc.
__forceinline vec3_t &m_vecOrigin() {
return get< vec3_t >(g_entoffsets.m_vecOrigin);
}
__forceinline vec3_t &m_vecOldOrigin() {
return get< vec3_t >(g_entoffsets.m_vecOldOrigin);
}
__forceinline vec3_t &m_vecVelocity() {
return get< vec3_t >(g_entoffsets.m_vecVelocity);
}
__forceinline vec3_t &m_vecMins() {
return get< vec3_t >(g_entoffsets.m_vecMins);
}
__forceinline vec3_t &m_vecMaxs() {
return get< vec3_t >(g_entoffsets.m_vecMaxs);
}
__forceinline int &m_iTeamNum() {
return get< int >(g_entoffsets.m_iTeamNum);
}
__forceinline int &m_nSequence() {
return get< int >(g_entoffsets.m_nSequence);
}
__forceinline float &m_flCycle() {
return get< float >(g_entoffsets.m_flCycle);
}
__forceinline float &m_flC4Blow() {
return get< float >(g_entoffsets.m_flC4Blow);
}
__forceinline bool &m_bBombTicking() {
return get< bool >(g_entoffsets.m_bBombTicking);
}
__forceinline int &m_fEffects() {
// todo; netvar.
return get< int >(g_entoffsets.m_fEffects);
}
__forceinline int &m_nModelIndex() {
return get< int >(g_entoffsets.m_nModelIndex);
}
__forceinline bool &m_bReadyToDraw() {
return get< bool >(g_entoffsets.m_bReadyToDraw);
}
public:
// virtual indices
enum indices : size_t {
WORLDSPACECENTER = 78,
GETMAXHEALTH = 122,
ISPLAYER = 152,
ISBASECOMBATWEAPON = 160,
};
public:
// virtuals.
// renderable table.
__forceinline void *renderable() {
return (void *)((uintptr_t)this + 0x4);
}
__forceinline vec3_t &GetRenderOrigin() {
return util::get_method< vec3_t &(__thiscall *)(void *) >(renderable(), 1)(renderable());
}
__forceinline ang_t &GetRenderAngles() {
return util::get_method< ang_t &(__thiscall *)(void *) >(renderable(), 2)(renderable());
}
__forceinline const model_t *GetModel() {
return util::get_method< const model_t *(__thiscall *)(void *) >(renderable(), 8)(renderable());
}
__forceinline void DrawModel(int flags = STUDIO_RENDER, const RenderableInstance_t &instance = {}) {
return util::get_method< void(__thiscall *)(void *, int, const RenderableInstance_t &)>(renderable(), 9)(renderable(), flags, instance);
}
__forceinline bool SetupBones(matrix3x4_t *out, int max, int mask, float time) {
return util::get_method< bool(__thiscall *)(void *, matrix3x4_t *, int, int, float)>(renderable(), 13)(renderable(), out, max, mask, time);
}
// networkable table.
__forceinline void *networkable() {
return (void *)((uintptr_t)this + 0x8);
}
__forceinline void Release() {
return util::get_method< void(__thiscall *)(void *) >(networkable(), 1)(networkable());
}
__forceinline ClientClass *GetClientClass() {
return util::get_method< ClientClass *(__thiscall *)(void *) >(networkable(), 2)(networkable());
}
__forceinline void OnDataChanged(DataUpdateType_t type) {
return util::get_method< void(__thiscall *)(void *, DataUpdateType_t) >(networkable(), 5)(networkable(), type);
}
__forceinline void PreDataUpdate(DataUpdateType_t type) {
return util::get_method< void(__thiscall *)(void *, DataUpdateType_t) >(networkable(), 6)(networkable(), type);
}
__forceinline void PostDataUpdate(DataUpdateType_t type) {
return util::get_method< void(__thiscall *)(void *, DataUpdateType_t) >(networkable(), 7)(networkable(), type);
}
__forceinline bool dormant() {
return util::get_method< bool(__thiscall *)(void *) >(networkable(), 9)(networkable());
}
__forceinline int index() {
return util::get_method< int(__thiscall *)(void *) >(networkable(), 10)(networkable());
}
__forceinline void SetDestroyedOnRecreateEntities() {
return util::get_method< void(__thiscall *)(void *) >(networkable(), 13)(networkable());
}
// normal table.
__forceinline const vec3_t &GetAbsOrigin() {
return util::get_method< const vec3_t &(__thiscall *)(void *) >(this, 10)(this);
}
__forceinline const ang_t &GetAbsAngles() {
return util::get_method< const ang_t &(__thiscall *)(void *) >(this, 11)(this);
}
__forceinline bool IsPlayer() {
return util::get_method< bool(__thiscall *)(void *) >(this, ISPLAYER)(this);
}
__forceinline bool IsBaseCombatWeapon() {
return util::get_method< bool(__thiscall *)(void *) >(this, ISBASECOMBATWEAPON)(this);
}
__forceinline std::string GetBombsiteName() {
std::string out;
// note - dex; bomb_target + 0x150 has a char array for site name... not sure how much memory gets allocated for it.
out.resize(32u);
std::memcpy(&out[0], (const void *)((uintptr_t)this + 0x150), 32u);
return out;
}
__forceinline void InvalidatePhysicsRecursive(InvalidatePhysicsBits_t bits) {
using InvalidatePhysicsRecursive_t = void(__thiscall *)(decltype(this), InvalidatePhysicsBits_t);
g_csgo.InvalidatePhysicsRecursive.as< InvalidatePhysicsRecursive_t >()(this, bits);
}
__forceinline void SetAbsAngles(const ang_t &angles) {
using SetAbsAngles_t = void(__thiscall *)(decltype(this), const ang_t &);
g_csgo.SetAbsAngles.as< SetAbsAngles_t >()(this, angles);
}
__forceinline void SetAbsOrigin(const vec3_t &origin) {
using SetAbsOrigin_t = void(__thiscall *)(decltype(this), const vec3_t &);
g_csgo.SetAbsOrigin.as< SetAbsOrigin_t >()(this, origin);
}
__forceinline void SetAbsVelocity(const vec3_t &velocity) {
using SetAbsVelocity_t = void(__thiscall *)(decltype(this), const vec3_t &);
g_csgo.SetAbsVelocity.as< SetAbsVelocity_t >()(this, velocity);
}
__forceinline void AddEffect(int effects) {
m_fEffects() |= effects;
}
__forceinline int get_class_id() {
ClientClass *cc{ GetClientClass() };
return (cc) ? cc->m_ClassID : -1;
}
__forceinline bool is(hash32_t hash) {
return g_netvars.GetClientID(hash) == get_class_id();
}
};
class CCSGOPlayerAnimState {
public:
PAD(0x1C); // 0x0000
Player *m_outer; // 0x001C
PAD(0x40); // 0x0020
Player *m_player; // 0x0060
PAD(0x8); // 0x0064
float m_time; // 0x006C
int m_frame; // 0x0070
float m_update_delta; // 0x0074
float m_eye_yaw; // 0x0078
float m_eye_pitch; // 0x007C
float m_goal_feet_yaw; // 0x0080
float m_cur_feet_yaw; // 0x0084
PAD(0x1C); // 0x0088
float m_dip_cycle; // 0x00A4
float m_dip_adj; // 0x00A8
PAD(0x40); // 0x00A8
float m_speed; // 0x00EC
float m_fall_velocity; // 0x00F0
PAD(0x14); // 0x00F0
bool m_ground; // 0x0108
bool m_land; // 0x0109
PAD(0x2); // 0x010A
PAD(0x21C); // 0x010C
bool m_dip_air; // 0x0328
PAD(0x12); // 0x0329
float m_min_pitch; // 0x033C
PAD(0x4); // 0x0340
}; // size: 0x344
class CStudioHdr {
public:
class mstudioposeparamdesc_t {
public:
int sznameindex;
__forceinline char *const name(void) const { return ((char *)this) + sznameindex; }
int flags; // ????
float start; // starting value
float end; // ending value
float loop; // looping range, 0 for no looping, 360 for rotations, etc.
};
studiohdr_t *m_pStudioHdr;
void *m_pVModel;
};
class C_AnimationLayer {
public:
float m_anim_time; // 0x0000
float m_fade_out_time; // 0x0004
int m_flags; // 0x0008
int m_activty; // 0x000C
int m_priority; // 0x0010
int m_order; // 0x0014
int m_sequence; // 0x0018
float m_prev_cycle; // 0x001C
float m_weight; // 0x0020
float m_weight_delta_rate; // 0x0024
float m_playback_rate; // 0x0028
float m_cycle; // 0x002C
Entity *m_owner; // 0x0030
int m_bits; // 0x0034
}; // size: 0x0038
class CBoneAccessor {
public:
void *m_pAnimating;
BoneArray *m_pBones;
int m_ReadableBones;
int m_WritableBones;
};
class CBoneCache {
public:
BoneArray *m_pCachedBones;
PAD(0x8);
int m_CachedBoneCount;
};
class Ragdoll : public Entity {
public:
__forceinline Player *GetPlayer() {
return g_csgo.m_entlist->GetClientEntityFromHandle< Player * >(m_hPlayer());
}
__forceinline EHANDLE &m_hPlayer() {
return get< EHANDLE >(g_entoffsets.m_hPlayer);
}
__forceinline float &m_flDeathYaw() {
return get< float >(g_entoffsets.m_flDeathYaw);
}
__forceinline float &m_flAbsYaw() {
return get< float >(g_entoffsets.m_flAbsYaw);
}
};
class Player : public Entity {
public:
// netvars / etc.
__forceinline vec3_t &m_vecAbsVelocity() {
return get< vec3_t >(g_entoffsets.m_vecAbsVelocity);
}
__forceinline int &m_lifeState() {
return get< int >(g_entoffsets.m_lifeState);
}
__forceinline int &m_fFlags() {
return get< int >(g_entoffsets.m_fFlags);
}
__forceinline int &m_MoveType() {
return get< int >(g_entoffsets.m_MoveType);
}
__forceinline int &m_iHealth() {
return get< int >(g_entoffsets.m_iHealth);
}
__forceinline int &m_iAccount() {
return get< int >(g_entoffsets.m_iAccount);
}
__forceinline bool &m_bHasDefuser() {
return get< bool >(g_entoffsets.m_bHasDefuser);
}
__forceinline int &m_nHitboxSet() {
return get< int >(g_entoffsets.m_nHitboxSet);
}
__forceinline ang_t &m_angAbsRotation() {
return get< ang_t >(g_entoffsets.m_angAbsRotation);
}
__forceinline ang_t &m_angRotation() {
return get< ang_t >(g_entoffsets.m_angRotation);
}
__forceinline ang_t &m_angNetworkAngles() {
return get< ang_t >(g_entoffsets.m_angNetworkAngles);
}
__forceinline bool m_bIsLocalPlayer() {
// .text:101E0078 674 84 C0 test al, al ; Logical Compare
// .text:101E007A 674 74 17 jz short loc_101E0093; Jump if Zero( ZF = 1 )
// .text:101E007C 674 8A 83 F8 35 00 00 mov al, [ ebx + 35F8h ]
return get< bool >(g_csgo.IsLocalPlayer);
}
__forceinline CCSGOPlayerAnimState *m_PlayerAnimState() {
// .text:1037A5B8 00C E8 E3 40 E6 FF call C_BasePlayer__Spawn ; Call Procedure
// .text:1037A5BD 00C 80 BE E1 39 00 00 00 cmp byte ptr[ esi + 39E1h ], 0; Compare Two Operands
// .text:1037A5C4 00C 74 48 jz short loc_1037A60E; Jump if Zero( ZF = 1 )
// .text:1037A5C6 00C 8B 8E 74 38 00 00 mov ecx, [ esi + 3874h ]; this
// .text:1037A5CC 00C 85 C9 test ecx, ecx; Logical Compare
// .text:1037A5CE 00C 74 3E jz short loc_1037A60E; Jump if Zero( ZF = 1 )
return get< CCSGOPlayerAnimState * >(g_csgo.PlayerAnimState);
}
__forceinline CStudioHdr *m_studioHdr() {
// .text:1017E902 08C 8B 86 3C 29 00 00 mov eax, [ esi + 293Ch ]
// .text:1017E908 08C 89 44 24 10 mov[ esp + 88h + var_78 ], eax
return get< CStudioHdr * >(g_csgo.studioHdr);
}
__forceinline ulong_t &m_iMostRecentModelBoneCounter() {
// .text:101AC9A9 000 89 81 80 26 00 00 mov[ ecx + 2680h ], eax
return get< ulong_t >(g_csgo.MostRecentModelBoneCounter);
}
__forceinline float &m_flLastBoneSetupTime() {
// .text:101AC99F 000 C7 81 14 29 00 00 FF FF+ mov dword ptr [ecx+2914h], 0FF7FFFFFh;
return get< float >(g_csgo.LastBoneSetupTime);
}
__forceinline int &m_nTickBase() {
return get< int >(g_entoffsets.m_nTickBase);
}
__forceinline float &m_flNextAttack() {
return get< float >(g_entoffsets.m_flNextAttack);
}
__forceinline float &m_flDuckAmount() {
return get< float >(g_entoffsets.m_flDuckAmount);
}
__forceinline float &m_flSimulationTime() {
return get< float >(g_entoffsets.m_flSimulationTime);
}
__forceinline float &m_flOldSimulationTime() {
return get< float >(g_entoffsets.m_flOldSimulationTime);
}
__forceinline float &m_flLowerBodyYawTarget() {
return get< float >(g_entoffsets.m_flLowerBodyYawTarget);
}
__forceinline float &m_fImmuneToGunGameDamageTime() {
return get< float >(g_entoffsets.m_fImmuneToGunGameDamageTime);
}
__forceinline bool &m_bHasHelmet() {
return get< bool >(g_entoffsets.m_bHasHelmet);
}
__forceinline bool &m_bClientSideAnimation() {
return get< bool >(g_entoffsets.m_bClientSideAnimation);
}
__forceinline bool &m_bHasHeavyArmor() {
return get< bool >(g_entoffsets.m_bHasHeavyArmor);
}
__forceinline bool &m_bIsScoped() {
return get< bool >(g_entoffsets.m_bIsScoped);
}
__forceinline bool &m_bDucking() {
return get< bool >(g_entoffsets.m_bDucking);
}
__forceinline bool &m_bSpotted() {
return get< bool >(g_entoffsets.m_bSpotted);
}
__forceinline int &m_iObserverMode() {
return get< int >(g_entoffsets.m_iObserverMode);
}
__forceinline int &m_ArmorValue() {
return get< int >(g_entoffsets.m_ArmorValue);
}
__forceinline float &m_flMaxspeed() {
return get< float >(g_entoffsets.m_flMaxspeed);
}
__forceinline float &m_surfaceFriction() {
return get< float >(g_entoffsets.m_surfaceFriction);
}
__forceinline float &m_flFlashBangTime() {
return get< float >(g_entoffsets.m_flFlashBangTime);
}
__forceinline ang_t &m_angEyeAngles() {
return get< ang_t >(g_entoffsets.m_angEyeAngles);
}
__forceinline ang_t &m_aimPunchAngle() {
return get< ang_t >(g_entoffsets.m_aimPunchAngle);
}
__forceinline ang_t &m_viewPunchAngle() {
return get< ang_t >(g_entoffsets.m_viewPunchAngle);
}
__forceinline ang_t &m_aimPunchAngleVel() {
return get< ang_t >(g_entoffsets.m_aimPunchAngleVel);
}
__forceinline vec3_t &m_vecViewOffset() {
return get< vec3_t >(g_entoffsets.m_vecViewOffset);
}
__forceinline CUserCmd &m_PlayerCommand() {
return get< CUserCmd >(g_entoffsets.m_PlayerCommand);
}
__forceinline CUserCmd *&m_pCurrentCommand() {
return get< CUserCmd * >(g_entoffsets.m_pCurrentCommand);
}
__forceinline int &m_iEFlags() {
return get< int >(g_entoffsets.m_iEFlags);
}
__forceinline float *m_flPoseParameter() {
return (float *)((uintptr_t)this + g_entoffsets.m_flPoseParameter);
}
__forceinline CBaseHandle *m_hMyWearables() {
return (CBaseHandle *)((uintptr_t)this + g_entoffsets.m_hMyWearables);
}
__forceinline CBoneCache &m_BoneCache() {
// TODO; sig
return get< CBoneCache >(g_entoffsets.m_BoneCache);
}
__forceinline EHANDLE &m_hObserverTarget() {
return get< EHANDLE >(g_entoffsets.m_hObserverTarget);
}
__forceinline EHANDLE &m_hActiveWeapon() {
return get< EHANDLE >(g_entoffsets.m_hActiveWeapon);
}
__forceinline EHANDLE &m_hGroundEntity() {
return get< EHANDLE >(g_entoffsets.m_hGroundEntity);
}
__forceinline CBaseHandle *m_hMyWeapons() {
return (CBaseHandle *)((uintptr_t)this + g_entoffsets.m_hMyWeapons);
}
__forceinline C_AnimationLayer *m_AnimOverlay() {
// .text:1017EAB1 08C 8B 47 1C mov eax, [edi+1Ch]
// .text:1017EAB4 08C 8D 0C D5 00 00 00 00 lea ecx, ds:0[ edx * 8 ]; Load Effective Address
// .text:1017EABB 08C 2B CA sub ecx, edx; Integer Subtraction
// .text:1017EABD 08C 8B 80 70 29 00 00 mov eax, [ eax + 2970h ]
// .text:1017EAC3 08C 8D 34 C8 lea esi, [ eax + ecx * 8 ]; Load Effective Address
// .text:1017EAC6
return get< C_AnimationLayer * >(g_csgo.AnimOverlay);
}
__forceinline float &m_flSpawnTime() {
// .text:10381AB3 00C F3 0F 10 49 10 movss xmm1, dword ptr [ecx+10h] ; Move Scalar Single-FP
// .text:10381AB8 00C F3 0F 5C 88 90 A2 00 00 subss xmm1, dword ptr[ eax + 0A290h ]; Scalar Single - FP Subtract
return get< float >(g_csgo.SpawnTime);
}
__forceinline CBoneAccessor &m_BoneAccessor() {
// .text:101A9253 1C4 C7 81 A0 26 00 00 00 FF 0F 00 mov dword ptr[ ecx + 26A0h ], 0FFF00h
// .text:101A925D 1C4 C7 81 9C 26 00 00 00 FF 0F 00 mov dword ptr[ ecx + 269Ch ], 0FFF00h
// .text:101A9267 1C4 8B 10 mov edx, [ eax ]
// .text:101A9269 1C4 8D 81 94 26 00 00 lea eax, [ ecx + 2694h ]; Load Effective Address
// .text:101A926F 1C4 50 push eax
return get< CBoneAccessor >(g_csgo.BoneAccessor);
}
public:
enum indices : size_t {
GETREFEHANDLE = 2,
TESTHITBOXES = 52,
BUILDTRANSFORMATIONS = 184,
DOEXTRABONEPROCESSING = 192,
STANDARDBLENDINGRULES = 200,
UPDATECLIENTSIDEANIMATION = 218, // 55 8B EC 51 56 8B F1 80 BE ? ? ? ? ? 74 36
GETACTIVEWEAPON = 262,
GETEYEPOS = 163,
GETFOV = 321,
UPDATECOLLISIONBOUNDS = 329 // 56 57 8B F9 8B 0D ? ? ? ? F6 87 ? ? ? ? ?
};
public:
// virtuals.
__forceinline ulong_t GetRefEHandle() {
using GetRefEHandle_t = ulong_t(__thiscall *)(decltype(this));
return util::get_method< GetRefEHandle_t >(this, GETREFEHANDLE)(this);
}
__forceinline void BuildTransformations(CStudioHdr *hdr, vec3_t *pos, quaternion_t *q, const matrix3x4_t &transform, int mask, uint8_t *computed) {
using BuildTransformations_t = void(__thiscall *)(decltype(this), CStudioHdr *, vec3_t *, quaternion_t *, matrix3x4_t const &, int, uint8_t *);
return util::get_method< BuildTransformations_t >(this, BUILDTRANSFORMATIONS)(this, hdr, pos, q, transform, mask, computed);
}
__forceinline void StandardBlendingRules(CStudioHdr *hdr, vec3_t *pos, quaternion_t *q, float time, int mask) {
using StandardBlendingRules_t = void(__thiscall *)(decltype(this), CStudioHdr *, vec3_t *, quaternion_t *, float, int);
return util::get_method< StandardBlendingRules_t >(this, STANDARDBLENDINGRULES)(this, hdr, pos, q, time, mask);
}
__forceinline float GetFOV() {
return util::get_method< float(__thiscall *)(decltype(this)) >(this, GETFOV)(this);
}
__forceinline const vec3_t &WorldSpaceCenter() {
return util::get_method< const vec3_t &(__thiscall *)(void *) >(this, WORLDSPACECENTER)(this);
}
__forceinline void GetEyePos(vec3_t *pos) {
util::get_method< void(__thiscall *)(decltype(this), vec3_t *) >(this, GETEYEPOS)(this, pos);
}
__forceinline void ModifyEyePosition(CCSGOPlayerAnimState *state, vec3_t *pos) {
if (!state) {
return;
}
// if ( *(this + 0x50) && (*(this + 0x100) || *(this + 0x94) != 0.0 || !sub_102C9480(*(this + 0x50))) )
if (state->m_player &&
(state->m_land || state->m_player->m_flDuckAmount() != 0.f || !state->m_player->GetGroundEntity())) {
auto v5 = 8;
if (v5 != -1 && state->m_player->m_BoneCache().m_pCachedBones) {
vec3_t head_pos(
state->m_player->m_BoneCache().m_pCachedBones[8][0][3],
state->m_player->m_BoneCache().m_pCachedBones[8][1][3],
state->m_player->m_BoneCache().m_pCachedBones[8][2][3]);
auto v12 = head_pos;
auto v7 = v12.z + 1.7;
auto v8 = pos->z;
if (v8 > v7) // if (v8 > (v12 + 1.7))
{
float v13 = 0.f;
float v3 = (*pos).z - v7;
float v4 = (v3 - 4.f) * 0.16666667;
if (v4 >= 0.f)
v13 = std::fminf(v4, 1.f);
(*pos).z = (((v7 - (*pos).z)) * (((v13 * v13) * 3.0) - (((v13 * v13) * 2.0) * v13))) + (*pos).z;
}
}
}
}
__forceinline vec3_t GetShootPosition() {
/*
float *__thiscall sub_103A4A60(_DWORD *this, float *a2)
{
int v2; // edi
_DWORD *v3; // ecx
v2 = this;
(*(*this + 652))(a2);
if ( *(v2 + 0x39E1) )
{
v3 = *(v2 + 0x3874);
if ( v3 )
sub_103B4130(v3, a2);
}
return a2;
}
*/
vec3_t pos;
GetEyePos(&pos);
if (*reinterpret_cast <int32_t *> (uintptr_t(this) + 0x39E1)) {
auto v3 = m_PlayerAnimState();
if (v3) {
ModifyEyePosition(v3, &pos);
}
}
return pos;
}
__forceinline void UpdateClientSideAnimation() {
return util::get_method< void(__thiscall *)(decltype(this)) >(this, UPDATECLIENTSIDEANIMATION)(this);
}
__forceinline void UpdateCollisionBounds() {
return util::get_method< void(__thiscall *)(decltype(this)) >(this, UPDATECOLLISIONBOUNDS)(this);
}
// misc funcs.
__forceinline CStudioHdr *GetModelPtr() {
using LockStudioHdr_t = void(__thiscall *)(decltype(this));
if (!m_studioHdr())
g_csgo.LockStudioHdr.as< LockStudioHdr_t >()(this);
return m_studioHdr();
}
__forceinline Weapon *GetActiveWeapon() {
return g_csgo.m_entlist->GetClientEntityFromHandle< Weapon * >(m_hActiveWeapon());
}
__forceinline Entity *GetObserverTarget() {
return g_csgo.m_entlist->GetClientEntityFromHandle(m_hObserverTarget());
}
__forceinline Entity *GetGroundEntity() {
return g_csgo.m_entlist->GetClientEntityFromHandle(m_hGroundEntity());
}
__forceinline void SetAnimLayers(C_AnimationLayer *layers) {
std::memcpy(m_AnimOverlay(), layers, sizeof(C_AnimationLayer) * 13);
}
__forceinline void GetAnimLayers(C_AnimationLayer *layers) {
std::memcpy(layers, m_AnimOverlay(), sizeof(C_AnimationLayer) * 13);
}
__forceinline void SetPoseParameters(float *poses) {
std::memcpy(m_flPoseParameter(), poses, sizeof(float) * 24);
}
__forceinline void GetPoseParameters(float *poses) {
std::memcpy(poses, m_flPoseParameter(), sizeof(float) * 24);
}
__forceinline bool ComputeHitboxSurroundingBox(vec3_t *mins, vec3_t *maxs) {
using ComputeHitboxSurroundingBox_t = bool(__thiscall *)(void *, vec3_t *, vec3_t *);
return g_csgo.ComputeHitboxSurroundingBox.as< ComputeHitboxSurroundingBox_t >()(this, mins, maxs);
}
__forceinline int GetSequenceActivity(int sequence) {
using GetSequenceActivity_t = int(__fastcall *)(CStudioHdr *, int);
return g_csgo.GetSequenceActivity.as< GetSequenceActivity_t >()(GetModelPtr(), sequence);
}
__forceinline bool HasC4() {
using HasC4_t = bool(__thiscall *)(decltype(this));
return g_csgo.HasC4.as< HasC4_t >()(this);
}
__forceinline void InvalidateBoneCache() {
CBoneAccessor *accessor = &m_BoneAccessor();
if (!accessor)
return;
accessor->m_WritableBones = 0;
accessor->m_ReadableBones = 0;
m_iMostRecentModelBoneCounter() = 0;
m_flLastBoneSetupTime() = std::numeric_limits< float >::lowest();
}
__forceinline bool alive() {
return m_lifeState() == LIFE_ALIVE;
}
__forceinline bool enemy(Player *from) {
if (m_iTeamNum() != from->m_iTeamNum())
return true;
else if (g_csgo.mp_teammates_are_enemies->GetInt())
return true;
return false;
}
};
class WeaponInfo {
private:
PAD(0x4); // 0x0000
public:
const char *m_weapon_name; // 0x0004 -- actual weapon name, even for usp-s and revolver. ex: "weapon_revolver"
PAD(0xC); // 0x0008
int m_max_clip1; // 0x0014
int m_max_clip2; // 0x0018
int m_default_clip1; // 0x001C
int m_default_clip2; // 0x0020
int m_max_reserve; // 0x0024
PAD(0x4); // 0x0028
const char *m_world_model; // 0x002C
const char *m_view_model; // 0x0030
const char *m_world_dropped_model; // 0x0034
PAD(0x48); // 0x0038
const char *m_ammo_type; // 0x0080
uint8_t pad_0084[4]; // 0x0084
const char *m_sfui_name; // 0x0088
const char *m_deprecated_weapon_name; // 0x008C -- shitty weapon name, shows "weapon_deagle" for revolver / etc.
uint8_t pad_0090[56]; // 0x0090
CSWeaponType m_weapon_type; // 0x00C8
int m_in_game_price; // 0x00CC
int m_kill_award; // 0x00D0
const char *m_animation_prefix; // 0x00D4
float m_cycletime; // 0x00D8
float m_cycletime_alt; // 0x00DC
float m_time_to_idle; // 0x00E0
float m_idle_interval; // 0x00E4
bool m_is_full_auto; // 0x00E5
PAD(0x3); // 0x00E8
int m_damage; // 0x00EC
float m_armor_ratio; // 0x00F0
int m_bullets; // 0x00F4
float m_penetration; // 0x00F8
float m_flinch_velocity_modifier_large; // 0x00FC
float m_flinch_velocity_modifier_small; // 0x0100
float m_range; // 0x0104
float m_range_modifier; // 0x0108