This repository has been archived by the owner on Apr 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAimAssistance.cpp
331 lines (243 loc) · 8.75 KB
/
AimAssistance.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
#include "Gamehooking.hpp"
#include "AimAssistance.hpp"
LineThroughSmokeFn LineThroughSmoke;
void AimAssist::work(UserCMD *userCMD, char *bSendPacket)
{
setTarget(-1);
bActive = false;
this->userCMD = userCMD;
this->bSendPacket = bSendPacket;
if (!Global::locPlayer || Global::locPlayer->getLeben() <= 0)
return;
if (!Global::locPlayer->getWeapon() || csFuncs->isWeapNonAim(Global::locPlayer->getWeaponId()) || Global::locPlayer->getWeapon()->isEmpty())
return;
if (mVars.bEnableSkelet)
{
if ((GetAsyncKeyState(mVars.kAim) || GetAsyncKeyState(mVars.kAim2)) && !csFuncs->isWeapNonAim(Global::locPlayer->getWeaponId()))
{
getBestTarget();
if (hasTarget())
targetRegion();
}
}
/*if ((!(userCMD->buttons & IN_ATTACK) || !hasTarget()) && mVars.bEnableSkelet)
getBestTarget();
if (hasTarget() && (GetAsyncKeyState(mVars.kAim) || GetAsyncKeyState(mVars.kAim2)) && mVars.bEnableSkelet)
targetRegion();*/
if (mVars.bEnableTrig || (mVars.bEnableTrigWithKey && (mVars.kAim != 0 || mVars.kAim2 != 0)))
trig();
if (mVars.bEnableRK)
rk();
if (!mVars.bSilent)
p_Engine->setViewAechse(userCMD->viewangles);
}
void AimAssist::getBestTarget()
{
float maxDistancija = 8192.f;
float najblizi;
int iIndex = -1;
float fov;
if (mVars.maxFov == 0)
fov = static_cast<float>(1);
else
fov = static_cast<float>(mVars.maxFov);
int locPlyrFrdShots = Global::locPlayer->getFiredShots();
for (int i = 1; i <= p_GlobVars->maxClients; i++)
{
Entity *player = reinterpret_cast<Entity *>(p_ClientEntList->GetClientEntity(i));
if (!checkTarget(player))
continue;
Vector3 locViewAechse = userCMD->viewangles;
Vector3 locVecAechse = Global::locPlayer->getVecAechse();
Vector3 locViewOriginal = Global::locPlayer->getViewOriginal();
Vector3 neu;
neu = locViewOriginal + locVecAechse;
Vector3 glava;
if (locPlyrFrdShots > mVars.afterShots)
glava = player->getSkeletById(realAimSpot[mVars.afterAim]);
else if (locPlyrFrdShots < mVars.afterShots)
glava = player->getSkeletById(realAimSpot[mVars.preAim]);
float najblizi = csFuncs->getFoV(locViewAechse, csFuncs->racunajAechse(neu, glava));
if (najblizi > fov)
continue;
float distancija = csFuncs->distance(Global::locPlayer->getViewOriginal(), player->getViewOriginal());
if (fabs(fov - najblizi) < 5)
{
if (distancija < maxDistancija)
{
fov = najblizi;
iIndex = i;
maxDistancija = distancija;
}
}
else if (najblizi < fov)
{
fov = najblizi;
iIndex = i;
maxDistancija = distancija;
}
}
setTarget(iIndex);
}
void AimAssist::targetRegion()
{
Entity *player = reinterpret_cast<Entity *>(p_ClientEntList->GetClientEntity(iTarget));
int locPlyrFrdShots = Global::locPlayer->getFiredShots();
Vector3 locPlyrVekPunch = Global::locPlayer->getVektPunch();
std::random_device r3nd0m;
std::mt19937 r3nd0mGen(r3nd0m());
std::uniform_real<float> r3nd0mXAechse(1.7f, 1.9f);
std::uniform_real<float> r3nd0mYAechse(1.7f, 1.9f);
locPlyrVekPunch.xAechse *= r3nd0mXAechse(r3nd0mGen);
locPlyrVekPunch.yAechse *= r3nd0mYAechse(r3nd0mGen);
locPlyrVekPunch.zAechse = 0.0f;
csFuncs->normaleAechse(locPlyrVekPunch);
Vector3 locViewAechse = userCMD->viewangles;
Vector3 locVecAechse = Global::locPlayer->getVecAechse();
Vector3 locViewOriginal = Global::locPlayer->getViewOriginal();
Vector3 neu;
neu = locViewOriginal + locVecAechse;
Vector3 glava;
if (locPlyrFrdShots > mVars.afterShots /* || csFuncs->isWeapPistol(Global::locPlayer->getWeaponId()) || Global::locPlayer->getWeaponId() == weapon_ssg08*/)
glava = player->getSkeletById(realAimSpot[mVars.afterAim]);
else if (locPlyrFrdShots < mVars.afterShots)
glava = player->getSkeletById(realAimSpot[mVars.preAim]);
Vector3 ugao;
ugao = csFuncs->racunajAechse(neu, glava);
ugao.xAechse -= locPlyrVekPunch.xAechse;
ugao.yAechse -= locPlyrVekPunch.yAechse;
if (mVars.umiriFactor != 0)
csFuncs->umiri(locViewAechse, ugao, mVars.umiriFactor);
csFuncs->normaleAechse(ugao);
bActive = true;
userCMD->viewangles = ugao;
}
bool AimAssist::checkTarget(Entity *player)
{
if (!player)
return false;
if (player == Global::locPlayer)
return false;
if (player->isStationary())
return false;
if (player->getLeben() <= 0)
return false;
if (player->getTeam() == Global::locPlayer->getTeam())
return false;
int locPlayerFrdShots = Global::locPlayer->getFiredShots();
Vector3 locVecAechse = Global::locPlayer->getVecAechse();
Vector3 locViewOriginal = Global::locPlayer->getViewOriginal();
Vector3 neu;
neu = locViewOriginal + locVecAechse;
Vector3 glava;
if (locPlayerFrdShots > mVars.afterShots)
glava = player->getSkeletById(realAimSpot[mVars.afterAim]);
else if (locPlayerFrdShots < mVars.afterShots)
glava = player->getSkeletById(realAimSpot[mVars.preAim]);
if (!csFuncs->isVis(neu, glava, player))
return false;
if (isBehindSmoke(neu, glava))
return false;
return true;
}
bool AimAssist::isBehindSmoke(Vector3 loc, Vector3 rem)
{
static bool initLGTS = false;
if (!initLGTS)
{
offs.lgtSmoke = csFuncs->findPattern(XorStr("\x55\x8B\xEC\x83\xEC\x08\x8B\x15\x00\x00\x00\x00\x0F\x57\xC0"), XorStr("xxxxxxxx????xxx"), csFuncs->dClientDll, csFuncs->dClientDll + csFuncs->dClientDllSize, 0);
initLGTS = true;
}
LineThroughSmoke = (LineThroughSmokeFn)(offs.lgtSmoke);
return LineThroughSmoke(loc, rem, true);
}
Vector3 stariVekPunch;
void AimAssist::rk()
{
int locPlyrFrdShots = Global::locPlayer->getFiredShots();
if (userCMD->buttons & IN_ATTACK)
{
Vector3 locPlyrVekPunch = Global::locPlayer->getVektPunch();
std::random_device r3nd0m;
std::mt19937 r3nd0mGen(r3nd0m());
std::uniform_real<float> r3nd0mXAechse(1.7f, 1.9f);
std::uniform_real<float> r3nd0mYAechse(1.7f, 1.9f);
locPlyrVekPunch.xAechse *= r3nd0mXAechse(r3nd0mGen);
locPlyrVekPunch.yAechse *= r3nd0mYAechse(r3nd0mGen);
locPlyrVekPunch.zAechse = 0.0f;
csFuncs->normaleAechse(locPlyrVekPunch);
if (locPlyrFrdShots > 2)
{
Vector3 viewAechse = userCMD->viewangles;
Vector3 viewAechseMod = locPlyrVekPunch;
viewAechseMod -= stariVekPunch;
viewAechseMod.zAechse = 0.0f;
csFuncs->normaleAechse(viewAechseMod);
viewAechse -= viewAechseMod;
viewAechse.zAechse = 0.0f;
csFuncs->normaleAechse(viewAechse);
userCMD->viewangles = viewAechse;
}
stariVekPunch = locPlyrVekPunch;
}
else
{
stariVekPunch.xAechse = stariVekPunch.yAechse = stariVekPunch.zAechse = 0;
}
}
void AimAssist::trig()
{
Vector3 neu, rem, forward;
trace_t tr;
Ray_t ray;
TraceFilterSkipCurrentEntity filter;
filter.pSkip = reinterpret_cast<void *>(Global::locPlayer);
Vector3 viewAechse = userCMD->viewangles;
viewAechse += Global::locPlayer->getVektPunch() * 2.f;
csFuncs->praviVektor(viewAechse, forward);
forward *= Global::locPlayer->getWeapon()->getWeapInfo()->m_fRange;
Vector3 locVecAechse = Global::locPlayer->getVecAechse();
Vector3 locViewOriginal = Global::locPlayer->getViewOriginal();
neu = locViewOriginal + locVecAechse;
rem = neu + forward;
ray.Init(neu, rem);
p_EngineTrace->TraceRay(ray, 0x46004003, (TraceFilter *)&filter, &tr);
if (!tr.m_pEntityHit)
return;
bool dh = false;
if (tr.hitgroup == HITGROUP_HEAD || tr.hitgroup == HITGROUP_CHEST || tr.hitgroup == HITGROUP_STOMACH || (tr.hitgroup == HITGROUP_LEFTARM || tr.hitgroup == HITGROUP_RIGHTARM) || (tr.hitgroup == HITGROUP_LEFTLEG || tr.hitgroup == HITGROUP_RIGHTLEG))
dh = true;
Entity *player = reinterpret_cast<Entity *>(tr.m_pEntityHit);
if (player && !player->isStationary() && player->getLeben() > 0 && player->isPlayer())
{
if (player->getTeam() != Global::locPlayer->getTeam())
{
if (mVars.bEnableTrigWithKey)
{
if (dh && (!(userCMD->buttons & IN_ATTACK) && (!GetAsyncKeyState(mVars.kAim) != 1 || !GetAsyncKeyState(mVars.kAim2) != 1))) // if you don't attack currently
userCMD->buttons |= IN_ATTACK;
static bool pucao = false;
if (csFuncs->isWeapPistol(Global::locPlayer->getWeaponId()))
{
if (userCMD->buttons & IN_ATTACK)
if (pucao)
userCMD->buttons &= ~IN_ATTACK;
pucao = userCMD->buttons & IN_ATTACK ? true : false;
}
}
else
{
if (dh && (!(userCMD->buttons & IN_ATTACK) && GetAsyncKeyState(VK_LBUTTON) != 1)) // if you don't attack currently
userCMD->buttons |= IN_ATTACK;
static bool pucao = false;
if (csFuncs->isWeapPistol(Global::locPlayer->getWeaponId()))
{
if (userCMD->buttons & IN_ATTACK)
if (pucao)
userCMD->buttons &= ~IN_ATTACK;
pucao = userCMD->buttons & IN_ATTACK ? true : false;
}
}
}
}
}