-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
333 lines (273 loc) · 7.61 KB
/
main.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
#include <Windows.h>
#include <ctime>
#include <string>
#include <list>
#include <sstream>
#include <conio.h>
#include <math.h>
#include <iostream>
#include <exception>
#include <time.h>
#include "MainPlayer.h"
#include "PlayerPointers.h"
#include "MousePosition.h"
#include "LastEnemyState.h"
#include "AutoTrigger.h"
#include "PlayerJump.h"
using namespace std;
float Get3dDistance(MainPlayer* me, PlayerObject* otherPlayer);
DWORD WINAPI MainThread(LPVOID lpThreadParameter);
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, PVOID lpvReserved)
{
if(fdwReason == DLL_PROCESS_ATTACH)
{
AllocConsole();
AttachConsole(GetProcessId(hinstDLL));
CreateThread(NULL, NULL, MainThread, NULL, NULL, NULL);
}
return TRUE; // TRUE MEANS SUCCESSFUL INJECT!
}
DWORD WINAPI MainThread(LPVOID lpThreadParameter)
{
MousePosition* mousePosition = NULL;
MainPlayer* mainPlayer = NULL;
PlayerPointers* playerPointers = NULL;
AutoTrigger* autoTrigger = NULL;
PlayerJump* bHop = NULL;
boolean enemyFound = false;
boolean targetLock = false;
boolean aimActive = false;
boolean aquireAddresses = false;
boolean autoTriggerStatus = false;
boolean noBangStatus = false;
boolean noSmogStatus = false;
boolean noRecoilStatus = false;
float PI = 3.14159265358979f;
float pitch;
float yaw;
float crouchOffset = 0;
float closestEnemyDistance;
int closestEnemy = 0;
clock_t time = 0;
LastEnemyState lastEnemyState[32];
while(true)
{
if(GetAsyncKeyState(VK_F1) && clock() - time > 1000)
{
aquireAddresses = !aquireAddresses;
time = clock();
if(!aquireAddresses)
{
aimActive = false;
autoTriggerStatus = false;
noBangStatus = false;
noSmogStatus = false;
noRecoilStatus = false;
}
}
if(GetAsyncKeyState(VK_F2) && clock() - time > 1000)
{
aimActive = !aimActive;
time = clock();
}
if(GetAsyncKeyState(VK_F3) && clock() - time > 1000)
{
autoTriggerStatus = !autoTriggerStatus;
time = clock();
}
if(GetAsyncKeyState(VK_F4) && clock() - time > 1000)
{
noBangStatus = !noBangStatus;
time = clock();
}
if(GetAsyncKeyState(VK_F5) && clock() - time > 1000)
{
noSmogStatus = !noSmogStatus;
time = clock();
}
if(GetAsyncKeyState(VK_F6) && clock() - time > 1000)
{
noRecoilStatus = !noRecoilStatus;
time = clock();
}
if(aquireAddresses)
{
_cprintf("[F1] Load Addresses: ON\n");
}
else
{
_cprintf("[F1] Load Addresses: OFF\n");
}
if(aimActive)
{
_cprintf("[F2] Aimbot: ON\n");
}
else
{
_cprintf("[F2] Aimbot: OFF\n");
}
if(autoTriggerStatus)
{
_cprintf("[F3] Auto Trigger: ON\n");
}
else
{
_cprintf("[F3] Auto Trigger: OFF\n");
}
if(noBangStatus)
{
_cprintf("[F4] No Bang: ON\n");
}
else
{
_cprintf("[F4] No Bang: OFF\n");
}
if(noSmogStatus)
{
_cprintf("[F5] No Smog: ON\n");
}
else
{
_cprintf("[F5] No Smog: OFF\n");
}
if(noRecoilStatus)
{
_cprintf("[F6] No Recoil: ON\n");
}
else
{
_cprintf("[F6] No Recoil: OFF\n");
}
if(aquireAddresses)
{
DWORD mouseBaseAddress = (DWORD)GetModuleHandleA("engine.dll") + 0x466E8C;
mousePosition = (MousePosition*) mouseBaseAddress;
DWORD BaseAddress = (DWORD)GetModuleHandleA("client.dll") + 0x539984;
mainPlayer = *((MainPlayer**)BaseAddress);
DWORD playerArrayPointer = (DWORD)GetModuleHandleA("client.dll") + 0x546204;
playerPointers = (PlayerPointers*) playerArrayPointer;
DWORD autoTriggerBase = (DWORD)GetModuleHandleA("client.dll") + 0x565498;
autoTrigger = (AutoTrigger*) autoTriggerBase;
DWORD bHopBase = (DWORD)GetModuleHandleA("client.dll") + 0x5654A4;
bHop = (PlayerJump*) bHopBase;
if(playerPointers->PlayerArray[closestEnemy]->isDead)
{
targetLock = false;
}
if(!targetLock)
{
closestEnemyDistance = 9999;
enemyFound = false;
int i = 0;
while(i < 128)
{
// Is the pointer valid and is the pointer not pointing at me
if(!(playerPointers->PlayerArray[i] == NULL) && playerPointers->PlayerArray[i]->posX != mainPlayer->posX)
{
//Is the player dead/has hp or is the enmy on my team
if(playerPointers->PlayerArray[i]->isDead == 0 && playerPointers->PlayerArray[i]->health > 0 && mainPlayer->team != playerPointers->PlayerArray[i]->team)
{
//Is the enemy moving? (This solves "ghost bodies" issue
//Should add lastEnemyStat with xpos, mouseX, mouseY
if(lastEnemyState[i/4].posX != playerPointers->PlayerArray[i]->posX)
{
if(Get3dDistance(mainPlayer, playerPointers->PlayerArray[i]) < closestEnemyDistance)
{
closestEnemyDistance = Get3dDistance(mainPlayer, playerPointers->PlayerArray[i]);
closestEnemy = i;
enemyFound = true;
lastEnemyState[i/4].posX = playerPointers->PlayerArray[i]->posX;
//lastEnemyState[i/4].mouseY = playerPointers->PlayerArray[i]->mouseY;
//lastEnemyState[i/4].mouseX = playerPointers->PlayerArray[i]->mouseX;
}
}
}
}
i = i+4;
}
}
}
if(aimActive && aquireAddresses)
{
if(GetAsyncKeyState(VK_MBUTTON) && enemyFound)
{
targetLock = true;
crouchOffset = 0;
if(playerPointers->PlayerArray[closestEnemy]->bodyState == 7 || playerPointers->PlayerArray[closestEnemy]->bodyState == 5)
{
crouchOffset = -16;
}
// Up/down motion
pitch = -((float)asin((((playerPointers->PlayerArray[closestEnemy]->posZ + crouchOffset) - mainPlayer->posZ)) / Get3dDistance(mainPlayer, playerPointers->PlayerArray[closestEnemy]))
* 180 / PI);
// left/right motion
yaw = -atan2f(playerPointers->PlayerArray[closestEnemy]->posX - mainPlayer->posX, playerPointers->PlayerArray[closestEnemy]->posY - mainPlayer->posY)
* 180 / PI + 90.0f;
if(yaw > 180)
{
yaw -= 360;
}
else if(yaw < -180)
{
yaw += 360;
}
mousePosition->mouseY = pitch;
mousePosition->mouseX = yaw;
}
else
{
targetLock = false;
}
if(enemyFound)
{
if(mainPlayer->lookingAtPlayer > 0 && mainPlayer->team != playerPointers->PlayerArray[closestEnemy]->team)
{
_cprintf("Looking at enemy: TRUE\n");
}
else
{
_cprintf("Looking at enemy: FALSE\n\n");
}
_cprintf("Enemy Stats: \n\n");
_cprintf("Your body state: %x\n", mainPlayer->bodyState);
_cprintf("Your jump value: %i\n", bHop->jump);
_cprintf("Health: %i\n", playerPointers->PlayerArray[closestEnemy]->health);
_cprintf("BodyState: %x\n\n", playerPointers->PlayerArray[closestEnemy]->bodyState);
_cprintf("Team: %x\n", playerPointers->PlayerArray[closestEnemy]->team);
}
}
if(aquireAddresses && autoTriggerStatus && mainPlayer->lookingAtPlayer > 0 && mainPlayer->team != playerPointers->PlayerArray[closestEnemy]->team)
{
autoTrigger->shoot = 5;
}
else if(aquireAddresses && autoTriggerStatus && mainPlayer->lookingAtPlayer == 0)
{
autoTrigger->shoot = 4;
}
if(aquireAddresses && noBangStatus)
{
mainPlayer->flashAlpha = 0;
}
else if(aquireAddresses && !noBangStatus)
{
mainPlayer->flashAlpha = 255;
}
if(aquireAddresses && noRecoilStatus)
{
}
if(aquireAddresses && mainPlayer->bodyState == 0)
{
bHop->jump = 4;
}
if(aquireAddresses && GetAsyncKeyState(VK_SPACE) && mainPlayer->bodyState == 1)
{
bHop->jump = 5;
}
system("cls");
}
return NULL;
}
float Get3dDistance(MainPlayer* me, PlayerObject* otherPlayer)
{
return (float) (sqrt(((me->posX - otherPlayer->posX) * (me->posX - otherPlayer->posX)) + ((me->posY - otherPlayer->posY) * (me->posY - otherPlayer->posY)) + ((me->posZ - otherPlayer->posZ) * (me->posZ - otherPlayer->posZ))));
}