/
Menu.h
1765 lines (1455 loc) · 54.6 KB
/
Menu.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
#include "Draw.h"
#include <iostream>
#include <algorithm>
#include <intrin.h>
#include <vector>
#include <string>
using namespace std;
#define j_junk() UsefulFuntion(25415, 75242, 2451, 7897);
inline int UsefulFuntion(int x, int y, int z, int r)
{
for (int i = 2; i < 8; i++)
{
z += 456;
r -= 55;
x++;
y--;
}
for (int i = 0; i < 2; i++)
{
x++;
y += 234;
z -= 23;
r += 634;
}
return x + z + r + y;
}
bool SHOW = true;
LPDIRECT3D9 d3d; // the pointer to our Direct3D interface
LPDIRECT3DDEVICE9 d3ddev;
int Width = GetSystemMetrics(SM_CXSCREEN);
int Height = GetSystemMetrics(SM_CYSCREEN);
RECT GameRect = { NULL };
HWND GameWnd = NULL;
float ScreenCenterX;
float ScreenCenterY;
HWND MyWnd = NULL;
const MARGINS Margin = { -1 ,-1, -1, -1 };
MSG Message = { NULL };
#define M_PI 3.14159265358979323846f
#define M_PI_F ((float)(M_PI)) // Shouldn't collide with anything.
struct FVector
{
float X; // 0x0000(0x0004) (Edit, BlueprintVisible, ZeroConstructor, SaveGame, IsPlainOldData)
float Y; // 0x0004(0x0004) (Edit, BlueprintVisible, ZeroConstructor, SaveGame, IsPlainOldData)
float Z; // 0x0008(0x0004) (Edit, BlueprintVisible, ZeroConstructor, SaveGame, IsPlainOldData)
inline FVector()
: X(0), Y(0), Z(0) {
}
inline FVector(float x, float y, float z) : X(x), Y(y), Z(z) {}
__forceinline FVector operator-(const FVector& V) {
return FVector(X - V.X, Y - V.Y, Z - V.Z);
}
__forceinline FVector operator+(const FVector& V) {
return FVector(X + V.X, Y + V.Y, Z + V.Z);
}
__forceinline FVector operator*(float Scale) const {
return FVector(X * Scale, Y * Scale, Z * Scale);
}
__forceinline FVector operator/(float Scale) const {
const float RScale = 1.f / Scale;
return FVector(X * RScale, Y * RScale, Z * RScale);
}
__forceinline FVector operator+(float A) const {
return FVector(X + A, Y + A, Z + A);
}
__forceinline FVector operator-(float A) const {
return FVector(X - A, Y - A, Z - A);
}
__forceinline FVector operator*(const FVector& V) const {
return FVector(X * V.X, Y * V.Y, Z * V.Z);
}
__forceinline FVector operator/(const FVector& V) const {
return FVector(X / V.X, Y / V.Y, Z / V.Z);
}
__forceinline float operator|(const FVector& V) const {
return X * V.X + Y * V.Y + Z * V.Z;
}
__forceinline float operator^(const FVector& V) const {
return X * V.Y - Y * V.X - Z * V.Z;
}
__forceinline FVector& operator+=(const FVector& v) {
X += v.X;
Y += v.Y;
Z += v.Z;
return *this;
}
__forceinline FVector& operator-=(const FVector& v) {
X -= v.X;
Y -= v.Y;
Z -= v.Z;
return *this;
}
__forceinline FVector& operator*=(const FVector& v) {
X *= v.X;
Y *= v.Y;
Z *= v.Z;
return *this;
}
__forceinline FVector& operator/=(const FVector& v) {
X /= v.X;
Y /= v.Y;
Z /= v.Z;
return *this;
}
__forceinline bool operator==(const FVector& src) const {
return (src.X == X) && (src.Y == Y) && (src.Z == Z);
}
__forceinline bool operator!=(const FVector& src) const {
return (src.X != X) || (src.Y != Y) || (src.Z != Z);
}
__forceinline float Size() const {
return sqrt(X * X + Y * Y + Z * Z);
}
__forceinline float Distance(const FVector& v)
{
return float(sqrtf(powf(v.X - X, 2.0) + powf(v.Y - Y, 2.0) + powf(v.Z - Z, 2.0)));
}
__forceinline float Size2D() const {
return sqrt(X * X + Y * Y);
}
__forceinline float SizeSquared() const {
return X * X + Y * Y + Z * Z;
}
__forceinline float SizeSquared2D() const {
return X * X + Y * Y;
}
__forceinline float Dot(const FVector& vOther) const {
const FVector& a = *this;
return (a.X * vOther.X + a.Y * vOther.Y + a.Z * vOther.Z);
}
__forceinline FVector Normalize() {
FVector vector;
float length = this->Size();
if (length != 0) {
vector.X = X / length;
vector.Y = Y / length;
vector.Z = Z / length;
}
else
vector.X = vector.Y = 0.0f;
vector.Z = 1.0f;
return vector;
}
__forceinline FVector ToRotator() {
FVector rotator;
rotator.X = -(float)atan(Z / Size2D()) * (float)(180.0f / M_PI);
rotator.Y = (float)atan(Y / X) * (float)(180.0f / M_PI);
rotator.Z = (float)0.f;
if (X >= 0.f)
rotator.Y += 180.0f;
return rotator;
}
__forceinline FVector Clamp()
{
FVector clamped;
while (clamped.Y < -180.0f)
clamped.Y += 360.0f;
while (clamped.Y > 180.0f)
clamped.Y -= 360.0f;
if (clamped.X < -74.0f)
clamped.X = -74.0f;
if (clamped.X > 74.0f)
clamped.X = 74.0f;
return clamped;
}
};
struct color {
int a, r, g, b;
color() = default;
color(const int r, const int g, const int b, const int a = 255) : _color{ } {
this->r = r;
this->g = g;
this->b = b;
this->a = a;
}
explicit color(const uint32_t color) : _color{ } {
this->a = color >> 24 & 0xff;
this->r = color >> 16 & 0xff;
this->g = color >> 8 & 0xff;
this->b = color & 0xff;
}
static color from_uint(const uint32_t uint) {
return color(uint);
}
unsigned char& operator[ ](const int index) {
return _color[index];
}
template <typename T>
color hsv_to_rgb(T h, T s, T v, const float alpha) const {
int _r, _g, _b;
if (s != 0) {
h == 360 ? h = 0 : h = h / 60;
auto i = static_cast<int>(trunc(h));
int f = h - i;
const int p = v * (1 - s);
const int q = v * (1 - s * f);
const int t = v * (1 - s * (1 - f));
switch (i) {
case 0:
_r = v;
_g = t;
_b = p;
break;
case 1:
_r = q;
_g = v;
_b = p;
break;
case 2:
_r = p;
_g = v;
_b = t;
break;
case 3:
_r = p;
_g = q;
_b = v;
break;
case 4:
_r = t;
_g = p;
_b = v;
break;
default:
_r = v;
_g = p;
_b = q;
break;
}
}
else {
_r = v;
_g = v;
_b = v;
}
return color(static_cast<uint8_t>(_r * 255), static_cast<uint8_t>(_g * 255),
static_cast<uint8_t>(_b * 255), alpha);
}
unsigned char _color[4];
};
void DrawBorder(int x, int y, int w, int h, int px, D3DCOLOR BorderColor, IDirect3DDevice9* pDevice)
{
DrawBox(x, (y + h - px), w, px, BorderColor, pDevice);
DrawBox(x, y, px, h, BorderColor, pDevice);
DrawBox(x, y, w, px, BorderColor, pDevice);
DrawBox((x + w - px), y, px, h, BorderColor, pDevice);
}
void DrawESPBox(FVector Head, FVector Foot, DWORD dwColor, int rectAlpha, LPDIRECT3DDEVICE9 pDevice)
{
FVector Box = Head - Foot;
if (Box.Y < 0)
Box.Y *= -1;
int BoxWidth = (int)Box.Y / 2;
int BoxHeight = (int)Box.Y / 2;
int DrawX = (int)Head.X - (BoxWidth / 2);
int DrawY = (int)Head.Y;
DrawBorder(DrawX, DrawY, BoxWidth, (int)Box.Y, 1, dwColor, pDevice);
}
template <typename T>
T read(uintptr_t address)
{
T buffer{ };
ReadProcessMemory(GetCurrentProcess(), (LPVOID)address, &buffer, sizeof(T), 0);
return buffer;
}
template<typename T>
bool write(uintptr_t address, T* buffer, SIZE_T sizeh)
{
if (address > 0x7FFFFFFFFFFF || address < 1) return 0;
WriteProcessMemory(GetCurrentProcess(), (LPVOID)address, buffer, sizeh, 0);
}
__forceinline __int64 decrypt_uworld(const uint32_t key, const uintptr_t* state)
{
unsigned __int64 v19; // r11
unsigned __int64 v20; // r8
unsigned __int64 v21; // r9
unsigned int v22; // er10
unsigned __int64 v23; // rcx
unsigned __int64 v24; // rdx
unsigned __int64 v25; // rcx
int v26; // ebx
unsigned int v27; // ecx
__int64 v28; // rax
unsigned __int64 v29; // r8
unsigned __int64 v30; // r8
unsigned __int64 v31; // rcx
unsigned __int64 v32; // rdx
unsigned __int64 v33; // rcx
v19 = 2685821657736338717i64 * ((unsigned int)key ^ (unsigned int)(key << 25) ^ (((unsigned int)key ^ ((unsigned __int64)(unsigned int)key >> 15)) >> 12)) % 7 % 7;
v20 = state[v19];
v21 = (2685821657736338717i64 * ((unsigned int)key ^ (unsigned int)(key << 25) ^ (((unsigned int)key ^ ((unsigned __int64)(unsigned int)key >> 15)) >> 12))) >> 32;
v22 = (unsigned int)v19;
if (!v19)
{
v23 = (2 * (v20 - (unsigned int)(v21 - 1))) ^ ((2 * (v20 - (unsigned int)(v21 - 1))) ^ ((v20 - (unsigned int)(v21 - 1)) >> 1)) & 0x5555555555555555i64;
v24 = (4 * v23) ^ ((4 * v23) ^ (v23 >> 2)) & 0x3333333333333333i64;
v25 = (16 * v24) ^ ((16 * v24) ^ (v24 >> 4)) & 0xF0F0F0F0F0F0F0Fi64;
v20 = rol8((v25 << 8) ^ ((v25 << 8) ^ (v25 >> 8)) & 0xFF00FF00FF00FFi64, 32);
LABEL_26:
v26 = 2 * v19;
goto LABEL_27;
}
if (v22 != 1)
goto LABEL_26;
v26 = 2 * v19;
v20 = rol8(v20 - (unsigned int)(2 * v19 + v21), (unsigned __int8)(((int)v21 + (int)v19) % 0x3Fu) + 1);
LABEL_27:
v27 = v26 + v21;
if (v22 == 2)
v20 = ~(v20 - v27);
switch (v22)
{
case 3u:
v28 = 2 * ((2 * v20) ^ ((2 * v20) ^ (v20 >> 1)) & 0x5555555555555555i64);
v20 = v28 ^ (v28 ^ (((2 * v20) ^ ((2 * v20) ^ (v20 >> 1)) & 0x5555555555555555i64) >> 1)) & 0x5555555555555555i64;
break;
case 4u:
v29 = ror8(v20, (unsigned __int8)(v27 % 0x3F) + 1);
v20 = (2 * v29) ^ ((2 * v29) ^ (v29 >> 1)) & 0x5555555555555555i64;
break;
case 5u:
v30 = ror8(v20, (unsigned __int8)(v27 % 0x3F) + 1);
v31 = (2 * v30) ^ ((2 * v30) ^ (v30 >> 1)) & 0x5555555555555555i64;
v32 = (4 * v31) ^ ((4 * v31) ^ (v31 >> 2)) & 0x3333333333333333i64;
v33 = (16 * v32) ^ ((16 * v32) ^ (v32 >> 4)) & 0xF0F0F0F0F0F0F0Fi64;
v20 = rol8((v33 << 8) ^ ((v33 << 8) ^ (v33 >> 8)) & 0xFF00FF00FF00FFi64, 32);
break;
case 6u:
v20 = ~v20 - (unsigned int)(v21 + v19);
break;
}
return v20 ^ (unsigned int)key;
}
uint64_t valBase = (uintptr_t)GetModuleHandleA(0);
uint64_t UWorld = 0;
uint64_t ReadWorld()
{
uint64_t key = read<uint64_t>(valBase + 0x75CF2B8);
#pragma pack(push, 1)
struct State
{
uint64_t Keys[7];
};
#pragma pack(pop)
const auto state = read<State>(valBase + 0x75CF280);
return read<uint64_t>(decrypt_uworld(key, (uint64_t*)&state));
}
struct alignas(16) FQuat
{
float X; // 0x0000(0x0004) (Edit, BlueprintVisible, ZeroConstructor, SaveGame, IsPlainOldData)
float Y; // 0x0004(0x0004) (Edit, BlueprintVisible, ZeroConstructor, SaveGame, IsPlainOldData)
float Z; // 0x0008(0x0004) (Edit, BlueprintVisible, ZeroConstructor, SaveGame, IsPlainOldData)
float W; // 0x000C(0x0004) (Edit, BlueprintVisible, ZeroConstructor, SaveGame, IsPlainOldData)
};
struct alignas(16) FPlane : public FVector
{
float W; // 0x000C(0x0004) (Edit, BlueprintVisible, ZeroConstructor, SaveGame, IsPlainOldData)
};
struct FMatrix
{
struct FPlane XPlane; // 0x0000(0x0010) (Edit, BlueprintVisible, SaveGame, IsPlainOldData)
struct FPlane YPlane; // 0x0010(0x0010) (Edit, BlueprintVisible, SaveGame, IsPlainOldData)
struct FPlane ZPlane; // 0x0020(0x0010) (Edit, BlueprintVisible, SaveGame, IsPlainOldData)
struct FPlane WPlane; // 0x0030(0x0010) (Edit, BlueprintVisible, SaveGame, IsPlainOldData)
FMatrix operator*(const FMatrix& pM2)
{
FMatrix pOut;
pOut.XPlane.X = XPlane.X * pM2.XPlane.X + XPlane.Y * pM2.YPlane.X + XPlane.Z * pM2.ZPlane.X + XPlane.W * pM2.WPlane.X;
pOut.XPlane.Y = XPlane.X * pM2.XPlane.Y + XPlane.Y * pM2.YPlane.Y + XPlane.Z * pM2.ZPlane.Y + XPlane.W * pM2.WPlane.Y;
pOut.XPlane.Z = XPlane.X * pM2.XPlane.Z + XPlane.Y * pM2.YPlane.Z + XPlane.Z * pM2.ZPlane.Z + XPlane.W * pM2.WPlane.Z;
pOut.XPlane.W = XPlane.X * pM2.XPlane.W + XPlane.Y * pM2.YPlane.W + XPlane.Z * pM2.ZPlane.W + XPlane.W * pM2.WPlane.W;
pOut.YPlane.X = YPlane.X * pM2.XPlane.X + YPlane.Y * pM2.YPlane.X + YPlane.Z * pM2.ZPlane.X + YPlane.W * pM2.WPlane.X;
pOut.YPlane.Y = YPlane.X * pM2.XPlane.Y + YPlane.Y * pM2.YPlane.Y + YPlane.Z * pM2.ZPlane.Y + YPlane.W * pM2.WPlane.Y;
pOut.YPlane.Z = YPlane.X * pM2.XPlane.Z + YPlane.Y * pM2.YPlane.Z + YPlane.Z * pM2.ZPlane.Z + YPlane.W * pM2.WPlane.Z;
pOut.YPlane.W = YPlane.X * pM2.XPlane.W + YPlane.Y * pM2.YPlane.W + YPlane.Z * pM2.ZPlane.W + YPlane.W * pM2.WPlane.W;
pOut.ZPlane.X = ZPlane.X * pM2.XPlane.X + ZPlane.Y * pM2.YPlane.X + ZPlane.Z * pM2.ZPlane.X + ZPlane.W * pM2.WPlane.X;
pOut.ZPlane.Y = ZPlane.X * pM2.XPlane.Y + ZPlane.Y * pM2.YPlane.Y + ZPlane.Z * pM2.ZPlane.Y + ZPlane.W * pM2.WPlane.Y;
pOut.ZPlane.Z = ZPlane.X * pM2.XPlane.Z + ZPlane.Y * pM2.YPlane.Z + ZPlane.Z * pM2.ZPlane.Z + ZPlane.W * pM2.WPlane.Z;
pOut.ZPlane.W = ZPlane.X * pM2.XPlane.W + ZPlane.Y * pM2.YPlane.W + ZPlane.Z * pM2.ZPlane.W + ZPlane.W * pM2.WPlane.W;
pOut.WPlane.X = WPlane.X * pM2.XPlane.X + WPlane.Y * pM2.YPlane.X + WPlane.Z * pM2.ZPlane.X + WPlane.W * pM2.WPlane.X;
pOut.WPlane.Y = WPlane.X * pM2.XPlane.Y + WPlane.Y * pM2.YPlane.Y + WPlane.Z * pM2.ZPlane.Y + WPlane.W * pM2.WPlane.Y;
pOut.WPlane.Z = WPlane.X * pM2.XPlane.Z + WPlane.Y * pM2.YPlane.Z + WPlane.Z * pM2.ZPlane.Z + WPlane.W * pM2.WPlane.Z;
pOut.WPlane.W = WPlane.X * pM2.XPlane.W + WPlane.Y * pM2.YPlane.W + WPlane.Z * pM2.ZPlane.W + WPlane.W * pM2.WPlane.W;
return pOut;
}
};
struct alignas(16) FTransform
{
struct FQuat Rotation; // 0x0000(0x0010) (Edit, BlueprintVisible, SaveGame, IsPlainOldData)
struct FVector Translation; // 0x0010(0x000C) (Edit, BlueprintVisible, SaveGame, IsPlainOldData)
unsigned char UnknownData00[0x4]; // 0x001C(0x0004) MISSED OFFSET
struct FVector Scale3D; // 0x0020(0x000C) (Edit, BlueprintVisible, SaveGame, IsPlainOldData)
unsigned char UnknownData01[0x4]; // 0x002C(0x0004) MISSED OFFSET
FMatrix ToMatrixWithScale()
{
FMatrix m;
m.WPlane.X = Translation.X;
m.WPlane.Y = Translation.Y;
m.WPlane.Z = Translation.Z;
float x2 = Rotation.X + Rotation.X;
float y2 = Rotation.Y + Rotation.Y;
float z2 = Rotation.Z + Rotation.Z;
float xx2 = Rotation.X * x2;
float yy2 = Rotation.Y * y2;
float zz2 = Rotation.Z * z2;
m.XPlane.X = (1.0f - (yy2 + zz2)) * Scale3D.X;
m.YPlane.Y = (1.0f - (xx2 + zz2)) * Scale3D.Y;
m.ZPlane.Z = (1.0f - (xx2 + yy2)) * Scale3D.Z;
float yz2 = Rotation.Y * z2;
float wx2 = Rotation.W * x2;
m.ZPlane.Y = (yz2 - wx2) * Scale3D.Z;
m.YPlane.Z = (yz2 + wx2) * Scale3D.Y;
float xy2 = Rotation.X * y2;
float wz2 = Rotation.W * z2;
m.YPlane.X = (xy2 - wz2) * Scale3D.Y;
m.XPlane.Y = (xy2 + wz2) * Scale3D.X;
float xz2 = Rotation.X * z2;
float wy2 = Rotation.W * y2;
m.ZPlane.X = (xz2 + wy2) * Scale3D.Z;
m.XPlane.Z = (xz2 - wy2) * Scale3D.X;
m.XPlane.W = 0.0f;
m.YPlane.W = 0.0f;
m.ZPlane.W = 0.0f;
m.WPlane.W = 1.0f;
return m;
}
};
class CameraStruct
{
public:
FVector Position; //0x11B0
FVector Rotation; //0x11BC
float Fov; //0x11C8
}; //Size=0x11CC
namespace Offsets
{
uintptr_t oLevel = 0x38;
uintptr_t oGameInstance = 0x1A8;
uintptr_t oLocalPlayers = 0x40;
uintptr_t oPlayerController = 0x38;
uintptr_t oLocalPawn = 0x440;
uintptr_t RootComp = 0x210;
uintptr_t oCameraManager = 0x458;
uintptr_t oCameraCache = 0x1220;
uintptr_t ObjID = 0x18;
uintptr_t Dormant = 0xD8;
uintptr_t RelativeLocation = 0x15C;
uintptr_t RelativeRotation = 0x168;
uintptr_t PlayerState = 0x3C8;
uintptr_t Ping = 0x3B8;
uintptr_t TeamComponent = 0x598;
uintptr_t Team = 0xF8;
uintptr_t DamageHandler = 0x968;
uintptr_t Health = 0x188;
uintptr_t HealthMax = 0x198;
uintptr_t Mesh = 0x408;
uintptr_t StaticMesh = 0x518;
uintptr_t StaticMesh_Cached = 0x528;
uintptr_t ComponentToWorld = 0x250;
uintptr_t UniqueID = 0x38;
uintptr_t ControlRotation = 0x418;
uintptr_t PlayerName = 0x3A8;
};
uint64_t PlayerController = 0;
uint64_t CameraCache = 0;
CameraStruct GetCameraCache()
{
CameraStruct Camera = read<CameraStruct>(CameraCache + Offsets::oCameraCache);
return Camera;
}
D3DMATRIX to_matrix(const FVector& rotation, const FVector& origin) {
const auto pitch = rotation.X * float(3.14159265358979323846f) / 180.f;
const auto yaw = rotation.Y * float(3.14159265358979323846f) / 180.f;
const auto roll = rotation.Z * float(3.14159265358979323846f) / 180.f;
const auto SP = sinf(pitch);
const auto CP = cosf(pitch);
const auto SY = sinf(yaw);
const auto CY = cosf(yaw);
const auto SR = sinf(roll);
const auto CR = cosf(roll);
D3DMATRIX matrix;
matrix._11 = CP * CY;
matrix._12 = CP * SY;
matrix._13 = SP;
matrix._14 = 0.f;
matrix._21 = SR * SP * CY - CR * SY;
matrix._22 = SR * SP * SY + CR * CY;
matrix._23 = -SR * CP;
matrix._24 = 0.f;
matrix._31 = -(CR * SP * CY + SR * SY);
matrix._32 = CY * SR - CR * SP * SY;
matrix._33 = CR * CP;
matrix._34 = 0.f;
matrix._41 = origin.X;
matrix._42 = origin.Y;
matrix._43 = origin.Z;
matrix._44 = 1.f;
return matrix;
}
FVector WorldToScreen(FVector& world_loc) {
auto CamCache = GetCameraCache();
const auto matrix = to_matrix(CamCache.Rotation, FVector());
const auto axisx = FVector(matrix.m[0][0], matrix.m[0][1], matrix.m[0][2]);
const auto axisy = FVector(matrix.m[1][0], matrix.m[1][1], matrix.m[1][2]);
const auto axisz = FVector(matrix.m[2][0], matrix.m[2][1], matrix.m[2][2]);
const auto delta = world_loc - CamCache.Position;
auto transformed = FVector(delta.Dot(axisy), delta.Dot(axisz), delta.Dot(axisx));
if (transformed.Z < 0.001f)
transformed.Z = 0.001f;
const auto fov_angle = CamCache.Fov;
const float center = Width / 2.f;
const float centery = Height / 2.f;
return FVector(center + transformed.X * (center / static_cast<float>(tan(fov_angle * M_PI / 360))) / transformed.Z, centery - transformed.Y * (center / static_cast<float>(tan(fov_angle * M_PI / 360))) / transformed.Z, 0.f);
}
bool WorldToScreen2(FVector& world_loc, FVector& screenLoc) {
auto CamCache = GetCameraCache();
const auto matrix = to_matrix(CamCache.Rotation, FVector());
const auto axisx = FVector(matrix.m[0][0], matrix.m[0][1], matrix.m[0][2]);
const auto axisy = FVector(matrix.m[1][0], matrix.m[1][1], matrix.m[1][2]);
const auto axisz = FVector(matrix.m[2][0], matrix.m[2][1], matrix.m[2][2]);
const auto delta = world_loc - CamCache.Position;
auto transformed = FVector(delta.Dot(axisy), delta.Dot(axisz), delta.Dot(axisx));
if (transformed.Z < 0.001f)
transformed.Z = 0.001f;
const auto fov_angle = CamCache.Fov;
const float screenCenterX = Width / 2.f;
const float screenCenterY = Height / 2.f;
screenLoc.X = screenCenterX + transformed.X * (screenCenterX / (float)tan(fov_angle * M_PI / 360)) / transformed.Z;
screenLoc.Y = screenCenterY - transformed.Y * (screenCenterX / (float)tan(fov_angle * M_PI / 360)) / transformed.Z;
return ((screenLoc.X >= 0.0f) && (screenLoc.X <= Width) && (screenLoc.Y >= 0.0f) && (screenLoc.Y <= Height));
}
#define URotationToRadians(URotation) ((URotation)* (M_PI / 32768.0f))
#define URotationToDegree( URotation ) ( ( URotation ) * ( 360.0f / 65536.0f ) )
#define DegreeToURotation( Degree ) ( ( Degree ) * ( 65536.0f / 360.0f ) )
#define DegreeToRadian( Degree ) ( ( Degree ) * ( M_PI / 180.0f ) )
#define RadianToURotation( URotation ) ( ( URotation ) * ( 32768.0f / M_PI ) )
#define RadianToDegree( Radian ) ( ( Radian ) * ( 180.0f / M_PI ) )
#define RAD2DEG( x ) ( (float)(x) * (float)(180.f / M_PI_F) )
bool bumbum = true;
__forceinline void Clamp(FVector& Ang) {
if (Ang.X < 0.f)
Ang.X += 360.f;
if (Ang.X > 360.f)
Ang.X -= 360.f;
if (Ang.Y < 0.f) Ang.Y += 360.f;
if (Ang.Y > 360.f) Ang.Y -= 360.f;
Ang.Z = 0.f;
}
__forceinline FVector CalcAngle(FVector Src, FVector& Dst) {
FVector Delta = Src - Dst;
const auto sqrtss = [](float in) {
__m128 reg = _mm_load_ss(&in);
return _mm_mul_ss(reg, _mm_rsqrt_ss(reg)).m128_f32[0];
};
float hyp = sqrtss(Delta.X * Delta.X + Delta.Y * Delta.Y + Delta.Z * Delta.Z);
FVector Rotation{};
Rotation.X = RadianToDegree(acosf(Delta.Z / hyp));
Rotation.Y = RadianToDegree(atanf(Delta.Y / Delta.X));
Rotation.Z = 0;
if (Delta.X >= 0.0f) Rotation.Y += 180.0f;
Rotation.X += 270.f;
return Rotation;
}
//pcontroller + ProjectW2S = 0x828
void ClientSetRotation(FVector NewRotation)
{
auto ClientSetRotationAddr = read<uintptr_t>(PlayerController) + 0x658;
auto fClientSetRotation = *((void(__fastcall**)(uintptr_t AController, FVector NewRotation, bool bResetCamera))(ClientSetRotationAddr));
fClientSetRotation(PlayerController, NewRotation, true);
}
bool is_visible(uint64_t mesh)
{
bool bVisible;
float fLastSubmitTime = read<float>(mesh + 0x340);
float fLastRenderTimeOnScreen = read<float>(mesh + 0x340 + 8);
const float fVisionTick = 0.06f;
bVisible = fLastRenderTimeOnScreen + fVisionTick >= fLastSubmitTime;
return bVisible;
}
/*
48 8B C4 55 56 57 41 56 41 57 48 8D 68 C8 > LineOfSightTo
48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 48 81 EC ? ? ? ? 41 0F B6 E9 > WorldToScreen
48 89 5C 24 ?? 48 89 74 24 ?? 57 48 81 EC ?? ?? ?? ?? F6 81 > GetBoneMatrix
*/
#define line_of_sight 0x37A2210//0x357F248//0x357F250
#define get_bone_matrix 0x357DDD0
#define project_w2s 0x389FB40
FTransform GetBoneIndex(uintptr_t mesh, int index)
{
uintptr_t bonearray = read<uintptr_t>(mesh + Offsets::StaticMesh);
if (bonearray == 0)
bonearray = read<uintptr_t>(mesh + Offsets::StaticMesh_Cached);
return read<FTransform>(bonearray + (index * 0x30));
}
FVector GetBoneWithRotation(uintptr_t mesh, int id)
{
FTransform Bone = GetBoneIndex(mesh, id);
if (Bone.Scale3D.Z > 0.f && Bone.Scale3D.Y > 0.f && Bone.Scale3D.Z > 0.f)
{
FTransform ComponentToWorld = read<FTransform>(mesh + Offsets::ComponentToWorld);
FMatrix Matrix = Bone.ToMatrixWithScale() * ComponentToWorld.ToMatrixWithScale();
return FVector{ Matrix.WPlane.X, Matrix.WPlane.Y, Matrix.WPlane.Z };
}
}
void DrawSkeleton(uintptr_t Mesh, bool IsMale, DWORD col)
{
__try
{
int skeleton[][4] = {
{ 7, 8, 0, 0},
{ 7, IsMale ? 47 : 46, IsMale ? 48 : 47, IsMale ? 49 : 48 },
{ 7, 21, 22, 23 },
{ 7, 5, 4, 3 },
{ 3, IsMale ? 82 : 80, IsMale ? 83 : 81, IsMale ? 85 : 83 },
{ 3, IsMale ? 75 : 73, IsMale ? 76 : 74, IsMale ? 78 : 76 }
};
for (auto part : skeleton)
{
FVector previous{};
for (int i = 0; i < 4; i++)
{
if (!part[i]) break;
FVector current = GetBoneWithRotation(Mesh, part[i]);
if (previous.X == 0.f)
{
previous = current;
continue;
}
FVector p1{}, c1{};
p1 = WorldToScreen(previous);
c1 = WorldToScreen(current);
DrawLine(p1.X, p1.Y, c1.X, c1.Y, col, 1.0f);
previous = current;
}
}
}
__except (1) {}
}
bool isaimbotting;
//#define BIT_CHECK(a,b) (!!((a) & (1ULL<<(b))))
/*
bool isVisible(uintptr_t de_mesh)
{
bool bVisible;
float fLastSubmitTime = read<float>(de_mesh + 0x0340);
float fLastRenderTimeOnScreen = read<float>(de_mesh + 0x0344);
const float fVisionTick = 0.04f;
bVisible = fLastRenderTimeOnScreen + fVisionTick >= fLastSubmitTime;
return bVisible;
}*/
uintptr_t ULevel;
uintptr_t GameInstance;
uintptr_t LocalPlayer;
uintptr_t AcknowledgedPawn;
uintptr_t LocalPlayerState;
uintptr_t entityx = 0;
float DistanceBetweenCross(float X, float Y)
{
float ydist = (Y - (ScreenCenterY));
float xdist = (X - (ScreenCenterX));
float Hypotenuse = sqrt(pow(ydist, 2) + pow(xdist, 2));
return Hypotenuse;
}
void Circle(int X, int Y, int radius, int numSides, DWORD Color)
{
D3DXVECTOR2 Line[128];
float Step = M_PI * 2.0 / numSides;
int Count = 0;
for (float a = 0; a < M_PI * 2.0; a += Step)
{
float X1 = radius * cos(a) + X;
float Y1 = radius * sin(a) + Y;
float X2 = radius * cos(a + Step) + X;
float Y2 = radius * sin(a + Step) + Y;
Line[Count].x = X1;
Line[Count].y = Y1;
Line[Count + 1].x = X2;
Line[Count + 1].y = Y2;
Count += 2;
}
S_Line->Begin();
S_Line->Draw(Line, Count, Color);
S_Line->End();
}
struct D3DTLVERTEX
{
float fX;
float fY;
float fZ;
float fRHW;
D3DCOLOR Color;
float fU;
float fV;
};
D3DTLVERTEX CreateD3DTLVERTEX(float X, float Y, float Z, float RHW, D3DCOLOR color, float U, float V)
{
D3DTLVERTEX v =
{
X,
Y,
Z,
RHW,
color,
U,
V
};
return v;
}
void DrawFilledCircle(int xPos, int yPos, int Radius, D3DCOLOR color)
{
const DWORD D3DFVF_TL = D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1;
D3DTLVERTEX Vtex[400];
float x1 = xPos;
float y1 = yPos;
for (int i = 0; i <= 363; i += 3)
{
float angle = (i / 56.3f);
float x2 = xPos + (Radius * sin(angle));
float y2 = yPos + (Radius * cos(angle));
Vtex[i] = CreateD3DTLVERTEX(xPos, yPos, 0, 1, color, 0, 0);
Vtex[i + 1] = CreateD3DTLVERTEX(x1, y1, 0, 1, color, 0, 0);
Vtex[i + 2] = CreateD3DTLVERTEX(x2, y2, 0, 1, color, 0, 0);
y1 = y2;
x1 = x2;
}
d3ddev->SetFVF(D3DFVF_TL);
d3ddev->SetTexture(0, NULL);
d3ddev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 363, Vtex, sizeof(D3DTLVERTEX));
}
float AimFOV = 30.f;
bool GetClosestPlayerToCrossHair(FVector Pos, float& max, float aimfov)
{
float Dist = DistanceBetweenCross(Pos.X, Pos.Y);
if (Dist < max)
{
max = Dist;
AimFOV = aimfov;
return true;
}
return false;
}
void AIms(uintptr_t ent)
{
float max = AimFOV / 2;
FVector rootHeadOut = FVector();
uintptr_t Mesh = read<uintptr_t>(ent + Offsets::Mesh);
FVector rootHead = GetBoneWithRotation(Mesh, 7);
rootHeadOut = WorldToScreen(rootHead);
if (GetClosestPlayerToCrossHair(rootHeadOut, max, AimFOV))
entityx = ent;
return;
}
static bool InsideCircle(float xc, float yc, float r, float x, float y)
{
float dx = xc - x;
float dy = yc - y;
return dx * dx + dy * dy <= r * r;
}
FVector LGetViewAngles()
{
FVector ViewAngle = read<FVector>(PlayerController + Offsets::ControlRotation);
return ViewAngle;
}
void normalize(FVector& in)
{
if (in.X > 89.f) in.X -= 360.f;
else if (in.X < -89.f) in.X += 360.f;
// in.Y = fmodf(in.Y, 360.0f);
while (in.Y > 180)in.Y -= 360;
while (in.Y < -180)in.Y += 360;
in.Z = 0;
}
FVector SmoothAim(FVector Camera_rotation, FVector Target, float SmoothFactor)
{
FVector diff = Target - Camera_rotation;
normalize(diff);
return Camera_rotation + diff / SmoothFactor;
}
void RCS(FVector Target, FVector Camera_rotation, float SmoothFactor) {
// Camera 2 Control space
FVector ConvertRotation = Camera_rotation;
normalize(ConvertRotation);
// Calculate recoil/aimpunch
auto ControlRotation = read<FVector>(PlayerController + Offsets::ControlRotation);
FVector DeltaRotation = ConvertRotation - ControlRotation;
normalize(DeltaRotation);
// Remove aimpunch from CameraRotation
ConvertRotation = Target - (DeltaRotation * SmoothFactor);
normalize(ConvertRotation);
//Smooth the whole thing
FVector Smoothed = SmoothAim(Camera_rotation, ConvertRotation, SmoothFactor);
Smoothed -= (DeltaRotation / SmoothFactor);
Clamp(Smoothed);
// normalize(Smoothed);
*(float*)(PlayerController + 0x418) = Smoothed.X;
*(float*)(PlayerController + 0x41C) = Smoothed.Y;
return;
}
bool LineOfSightTo(uint64_t thiz, uint64_t Other, FVector* ViewPoint)
{
__try {
static DWORD_PTR funcAddress = 0;
if (!funcAddress)funcAddress = valBase + line_of_sight;
if (funcAddress)
{
return reinterpret_cast<int(__fastcall*)(uint64_t thiz, uint64_t Other, FVector * ViewPoint)>(funcAddress)(thiz, Other, ViewPoint);
}
else return false;
}
__except (1) { return false; }
}
float HealthLocal;
float Smooth = 1.f;
void xasdasdascsa()
{
//(LocalPawn + 0xF28) + 0x210 = Matrix
//(LocalPawn + 0xF28) + 0x240 = Pitch & Yaw
bool IsDormant = read<bool>(entityx + Offsets::Dormant);
uintptr_t Mesh = read<uintptr_t>(entityx + Offsets::Mesh);
if (AcknowledgedPawn != 0)
{
uintptr_t DmgHandler = read<uintptr_t>(entityx + Offsets::DamageHandler);
float Health = read<float>(DmgHandler + Offsets::Health);
FVector aim_bone = GetBoneWithRotation(Mesh, (Fun.Scroll_Function1 == 0 ? 8 : Fun.Scroll_Function1 == 1 ? 7 : 5));
FVector vHead = WorldToScreen(aim_bone);
if (entityx != 0) {
if ((Health > 0.f && Health < 200.f) && !IsDormant)