-
Notifications
You must be signed in to change notification settings - Fork 1
/
function.h
230 lines (194 loc) · 6.64 KB
/
function.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
FTransform GetBoneIndex(DWORD_PTR mesh, int index)
{
DWORD_PTR bonearray = READ64(mesh + arraybone);
return RPMFT(bonearray + (index * 0x30));
}
D3DMATRIX MatrixMultiplication(D3DMATRIX pM1, D3DMATRIX pM2)
{
D3DMATRIX pOut;
pOut._11 = pM1._11 * pM2._11 + pM1._12 * pM2._21 + pM1._13 * pM2._31 + pM1._14 * pM2._41;
pOut._12 = pM1._11 * pM2._12 + pM1._12 * pM2._22 + pM1._13 * pM2._32 + pM1._14 * pM2._42;
pOut._13 = pM1._11 * pM2._13 + pM1._12 * pM2._23 + pM1._13 * pM2._33 + pM1._14 * pM2._43;
pOut._14 = pM1._11 * pM2._14 + pM1._12 * pM2._24 + pM1._13 * pM2._34 + pM1._14 * pM2._44;
pOut._21 = pM1._21 * pM2._11 + pM1._22 * pM2._21 + pM1._23 * pM2._31 + pM1._24 * pM2._41;
pOut._22 = pM1._21 * pM2._12 + pM1._22 * pM2._22 + pM1._23 * pM2._32 + pM1._24 * pM2._42;
pOut._23 = pM1._21 * pM2._13 + pM1._22 * pM2._23 + pM1._23 * pM2._33 + pM1._24 * pM2._43;
pOut._24 = pM1._21 * pM2._14 + pM1._22 * pM2._24 + pM1._23 * pM2._34 + pM1._24 * pM2._44;
pOut._31 = pM1._31 * pM2._11 + pM1._32 * pM2._21 + pM1._33 * pM2._31 + pM1._34 * pM2._41;
pOut._32 = pM1._31 * pM2._12 + pM1._32 * pM2._22 + pM1._33 * pM2._32 + pM1._34 * pM2._42;
pOut._33 = pM1._31 * pM2._13 + pM1._32 * pM2._23 + pM1._33 * pM2._33 + pM1._34 * pM2._43;
pOut._34 = pM1._31 * pM2._14 + pM1._32 * pM2._24 + pM1._33 * pM2._34 + pM1._34 * pM2._44;
pOut._41 = pM1._41 * pM2._11 + pM1._42 * pM2._21 + pM1._43 * pM2._31 + pM1._44 * pM2._41;
pOut._42 = pM1._41 * pM2._12 + pM1._42 * pM2._22 + pM1._43 * pM2._32 + pM1._44 * pM2._42;
pOut._43 = pM1._41 * pM2._13 + pM1._42 * pM2._23 + pM1._43 * pM2._33 + pM1._44 * pM2._43;
pOut._44 = pM1._41 * pM2._14 + pM1._42 * pM2._24 + pM1._43 * pM2._34 + pM1._44 * pM2._44;
return pOut;
}
Vector GetBoneWithRotation(DWORD_PTR mesh, int id)
{
FTransform bone = GetBoneIndex(mesh, id);
FTransform ComponentToWorld = RPMFT(mesh + CompotoWorld);
D3DMATRIX Matrix;
Matrix = MatrixMultiplication(bone.ToMatrixWithScale(), ComponentToWorld.ToMatrixWithScale());
return Vector(Matrix._41, Matrix._42, Matrix._43);
}
Vector Camera(unsigned __int64 RootComponent)
{
unsigned __int64 PtrPitch;
Vector Camera;
Camera.x = ReadFloat(RootComponent + CameraX);
auto pitch = READ64(Localplayer + Pitch);
Camera.y = ReadFloat(pitch + CameraY);
float test = asin(Camera.y);
float degrees = test * (180.0 / M_PI);
Camera.y = degrees;
if (Camera.x < 0)
Camera.x = 360 + Camera.x;
return Camera;
}
D3DXMATRIX Matrix(Vector rot, Vector origin = Vector(0, 0, 0))
{
float radPitch = (rot.x * float(M_PI) / 180.f);
float radYaw = (rot.y * float(M_PI) / 180.f);
float radRoll = (rot.z * float(M_PI) / 180.f);
float SP = sinf(radPitch);
float CP = cosf(radPitch);
float SY = sinf(radYaw);
float CY = cosf(radYaw);
float SR = sinf(radRoll);
float CR = cosf(radRoll);
D3DMATRIX matrix;
matrix.m[0][0] = CP * CY;
matrix.m[0][1] = CP * SY;
matrix.m[0][2] = SP;
matrix.m[0][3] = 0.f;
matrix.m[1][0] = SR * SP * CY - CR * SY;
matrix.m[1][1] = SR * SP * SY + CR * CY;
matrix.m[1][2] = -SR * CP;
matrix.m[1][3] = 0.f;
matrix.m[2][0] = -(CR * SP * CY + SR * SY);
matrix.m[2][1] = CY * SR - CR * SP * SY;
matrix.m[2][2] = CR * CP;
matrix.m[2][3] = 0.f;
matrix.m[3][0] = origin.x;
matrix.m[3][1] = origin.y;
matrix.m[3][2] = origin.z;
matrix.m[3][3] = 1.f;
return matrix;
}
Vector ProjectWorldToScreen(Vector WorldLocation, Vector camrot)
{
Vector Screenlocation = Vector(0, 0, 0);
Vector Rotation = camrot; // FRotator
D3DMATRIX tempMatrix = Matrix(Rotation);
Vector vAxisX, vAxisY, vAxisZ;
vAxisX = Vector(tempMatrix.m[0][0], tempMatrix.m[0][1], tempMatrix.m[0][2]);
vAxisY = Vector(tempMatrix.m[1][0], tempMatrix.m[1][1], tempMatrix.m[1][2]);
vAxisZ = Vector(tempMatrix.m[2][0], tempMatrix.m[2][1], tempMatrix.m[2][2]);
Vector camloc = READV(m_base + CameraLocation);
Vector vDelta = WorldLocation - camloc;
Vector vTransformed = Vector(vDelta.Dot(vAxisY), vDelta.Dot(vAxisZ), vDelta.Dot(vAxisX));
if (vTransformed.z < 1.f)
vTransformed.z = 1.f;
uint64_t zoomBase = READ64(Localplayer + Pitch);
float zoom = ReadFloat(zoomBase + ZoomBase);
float FovAngle = 80.0f / (zoom / 1.19f);
float ScreenCenterX = Width / 2;
float ScreenCenterY = Height / 2;
Screenlocation.x = ScreenCenterX + vTransformed.x * (ScreenCenterX / tanf(FovAngle * (float)M_PI / 360.f)) / vTransformed.z;
Screenlocation.y = ScreenCenterY - vTransformed.y * (ScreenCenterX / tanf(FovAngle * (float)M_PI / 360.f)) / vTransformed.z;
return Screenlocation;
}
bool GetAimKey()
{
return (GetAsyncKeyState(0x2));
}
void Aimbot(float x, float y)
{
float ScreenCenterX = (Width / 2);
float ScreenCenterY = (Height / 2);
int AimSpeed = 4.0f;
float TargetX = 0;
float TargetY = 0;
if (x != 0)
{
if (x > ScreenCenterX)
{
TargetX = -(ScreenCenterX - x);
TargetX /= AimSpeed;
if (TargetX + ScreenCenterX > ScreenCenterX * 2) TargetX = 0;
}
if (x < ScreenCenterX)
{
TargetX = x - ScreenCenterX;
TargetX /= AimSpeed;
if (TargetX + ScreenCenterX < 0) TargetX = 0;
}
}
if (y != 0)
{
if (y > ScreenCenterY)
{
TargetY = -(ScreenCenterY - y);
TargetY /= AimSpeed;
if (TargetY + ScreenCenterY > ScreenCenterY * 2) TargetY = 0;
}
if (y < ScreenCenterY)
{
TargetY = y - ScreenCenterY;
TargetY /= AimSpeed;
if (TargetY + ScreenCenterY < 0) TargetY = 0;
}
}
mouse_event(MOUSEEVENTF_MOVE, static_cast<DWORD>(TargetX), static_cast<DWORD>(TargetY), NULL, NULL);
return;
}
double GetCrossDistance(double x1, double y1, double x2, double y2)
{
return sqrt(pow((x2 - x1), 2) + pow((y2 - y1), 2));
}
bool GetClosestPlayerToCrossHair(Vector Pos, float& max, float aimfov, DWORD_PTR entity)
{
if (!GetAimKey() || !isaimbotting)
{
if (entity)
{
float Dist = GetCrossDistance(Pos.x, Pos.y, ScreenCenterX, ScreenCenterY);
if (Dist < max)
{
max = Dist;
entityx = entity;
AimFOV = aimfov;
//return true;
}
}
}
return false;
}
void AimAt(DWORD_PTR entity, Vector Localcam)
{
uint64_t currentactormesh = READ64(entity + Mesh);
auto rootHead = GetBoneWithRotation(currentactormesh, 66);
Vector rootHeadOut = ProjectWorldToScreen(rootHead, Vector(Localcam.y, Localcam.x, Localcam.z));
if (rootHeadOut.y != 0 || rootHeadOut.y != 0)
{
if ((GetCrossDistance(rootHeadOut.x, rootHeadOut.y, ScreenCenterX, ScreenCenterY) <= AimFOV * 8) || isaimbotting)
{
Aimbot(rootHeadOut.x, rootHeadOut.y);
}
}
}
void Aimbot(Vector Localcam)
{
if (entityx != 0)
{
if (GetAimKey())
{
AimAt(entityx, Localcam);
}
else
{
isaimbotting = false;
}
}
}