-
Notifications
You must be signed in to change notification settings - Fork 0
/
AntiAims.cpp
363 lines (293 loc) · 8.8 KB
/
AntiAims.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
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
#include "Hooks.h"
#include "Features.h"
bool CanExploit() {
return (
((g_Binds[bind_double_tap].active || g_Binds[bind_hide_shots].active) && csgo->skip_ticks >= 16)
/*|| (g_Binds[bind_hide_shots].active && csgo->skip_ticks >= 8)*/)
&& !csgo->need_to_recharge;
}
IBasePlayer* GetNearestTarget(bool check = false)
{
int y, x;
y = csgo->h / 2;
x = csgo->w / 2;
IBasePlayer* best_ent = nullptr;
float best_dist = FLT_MAX;
for (int i = 1; i < 65; i++)
{
auto ent = interfaces.ent_list->GetClientEntity(i);
if (!ent)
continue;
if (
!ent->isAlive()
|| !ent->IsPlayer()
|| ent == csgo->local
|| ent->GetTeam() == csgo->local->GetTeam()
|| ent->IsDormant()
|| ent->DormantWrapped())
continue;
Vector origin_2d;
if (!Math::WorldToScreen(ent->GetOrigin(), origin_2d) && check)
continue;
float dist = Vector(x, y, 0).DistTo(origin_2d);
if (dist < best_dist)
{
best_ent = ent;
best_dist = dist;
}
}
if (best_ent)
return best_ent;
return nullptr;
}
bool CanTriggerFakeLag() {
const bool disable_fakelag_on_exploit = []() {
if (vars.antiaim.fakelag_when_exploits)
return CanExploit();
else
return g_Binds[bind_double_tap].active || g_Binds[bind_hide_shots].active;
}();
if (vars.antiaim.fakelag_on_peek && !disable_fakelag_on_exploit) {
auto predicted_eye_pos = csgo->eyepos + csgo->vecUnpredictedVel * (TICKS_TO_TIME(15));
IBasePlayer* best_ent = GetNearestTarget();
if (best_ent) {
auto head_pos = best_ent->GetBonePos(best_ent->GetBoneCache().Base(), 8);
Ray_t ray;
ray.Init(predicted_eye_pos, head_pos);
trace_t trace;
CTraceFilterWorldAndPropsOnly filter;
interfaces.trace->TraceRay(ray, MASK_SHOT | CONTENTS_GRATE, &filter, &trace);
return trace.fraction > 0.97f;
}
return false;
}
if (disable_fakelag_on_exploit
|| (csgo->local->GetVelocity().Length2D() < 10.f && !vars.antiaim.fakelag_when_standing)
|| vars.antiaim.fakelag == 0)
return false;
return true;
}
void CAntiAim::Fakelag()
{
if (!vars.antiaim.enable)
return;
if (vars.antiaim.fakelagfactor == 0)
return;
if (csgo->game_rules->IsFreezeTime()
|| csgo->local->HasGunGameImmunity()
|| csgo->local->GetFlags() & FL_FROZEN)
return;
if (csgo->fake_duck && csgo->local->GetFlags() & FL_ONGROUND && !(csgo->cmd->buttons & IN_JUMP))
{
if (csgo->local->GetFlags() & FL_ONGROUND)
return;
}
static Vector origin = Vector();
if (!CanTriggerFakeLag()) {
csgo->send_packet = csgo->client_state->iChokedCommands >= 1;
csgo->max_fakelag_choke = 1;
}
else {
csgo->max_fakelag_choke = clamp(vars.antiaim.fakelagfactor, 1,
((vars.misc.restrict_type == 0 || csgo->game_rules->IsValveDS()) ? 6 : 14));
switch (vars.antiaim.fakelag)
{
case 1:
csgo->send_packet = false;
break;
case 2:
{
if (csgo->cmd->command_number % 30 < csgo->max_fakelag_choke)
csgo->send_packet = false;
else
csgo->send_packet = csgo->client_state->iChokedCommands >= 1;
}
break;
case 3:
{
float diff = (csgo->local->GetAbsOrigin() - origin).LengthSqr();
if (diff <= 4096.f)
csgo->send_packet = false;
}
break;
}
if (vars.antiaim.fakelag != 2 &&
csgo->client_state->iChokedCommands >= csgo->max_fakelag_choke)
csgo->send_packet = true;
}
if (csgo->send_packet)
origin = csgo->local->GetAbsOrigin();
}
void CAntiAim::Pitch(bool legit_aa)
{
if (legit_aa)
return;
auto state = csgo->local->GetPlayerAnimState();
if (!state)
return;
switch (vars.antiaim.pitch)
{
case 1:
csgo->cmd->viewangles.x = vars.misc.antiuntrusted ? 89.f : 179.98f;
break;
case 2:
csgo->cmd->viewangles.x = state->m_aim_pitch_max;
break;
}
}
void CAntiAim::Sidemove() {
if (csgo->weapon->GetItemDefinitionIndex() != weapon_revolver) {
if (g_Binds[bind_double_tap].active && csgo->skip_ticks > 0 && csgo->cmd->buttons & IN_ATTACK || csgo->game_rules->IsFreezeTime())
return;
}
if (csgo->local->GetMoveType() == MoveType_t::MOVETYPE_NOCLIP || csgo->local->GetMoveType() == MoveType_t::MOVETYPE_LADDER)
return;
if (!csgo->should_sidemove)
return;
const float& sideAmount = csgo->cmd->buttons & IN_DUCK || csgo->fake_duck ? 3.25f : 1.01f;
if (csgo->local->GetVelocity().Length2D() <= 0.f || std::fabs(csgo->local->GetVelocity().z) <= 100.f)
csgo->cmd->sidemove += csgo->cmd->command_number % 2 ? sideAmount : -sideAmount;
}
void CAntiAim::Yaw(bool legit_aa)
{
bool check = vars.antiaim.ignore_attarget &&
(g_Binds[bind_manual_back].active
|| g_Binds[bind_manual_right].active
|| g_Binds[bind_manual_left].active
|| g_Binds[bind_manual_forward].active);
if (vars.antiaim.attarget && !check && !legit_aa)
{
auto best_ent = GetNearestTarget(vars.antiaim.attarget_off_when_offsreen);
if (best_ent)
csgo->cmd->viewangles.y = Math::CalculateAngle(csgo->local->GetOrigin(), best_ent->GetOrigin()).y;
}
static bool sw = false;
static bool avoid_overlap_side = false;
static float last_angle = 0.f;
int side = csgo->SwitchAA ? 1 : -1;
if (vars.antiaim.desync_direction == 3) {
side = sw ? -1 : 1;
}
else if (vars.antiaim.desync_direction != 0) {
static int last_side = -1;
auto best_ent = GetNearestTarget();
if (best_ent) {
Vector ang{};
interfaces.engine->GetViewAngles(ang);
Vector src, dst, sc1, sc2, fw1;
src = csgo->local->GetBonePos(csgo->local->GetBoneCache().Base(), 8);
Math::AngleVectors(Vector(0, ang.y - 90.f, 0), &fw1);
Vector left_side = src + (fw1 * 40);
Vector right_side = src - (fw1 * 40);
side = last_side;
float damage_left = g_AutoWall->Think(left_side, csgo->local, HITGROUP_HEAD, best_ent->GetEyePosition(), best_ent).m_damage;
float damage_right = g_AutoWall->Think(right_side, csgo->local, HITGROUP_HEAD, best_ent->GetEyePosition(), best_ent).m_damage;
if (abs(damage_left - damage_right) > 10) {
if (damage_left > damage_right)
side = vars.antiaim.desync_direction == 1 ? -1 : 1;
else if (damage_left < damage_right)
side = vars.antiaim.desync_direction == 1 ? 1 : -1;
last_side = side;
}
}
}
if (legit_aa)
side *= -1;
const float desync_amount = legit_aa ? 60.f : 60.f * (vars.antiaim.desync_amount / 100.f);
csgo->should_sidemove = true;
if (vars.antiaim.desync)
{
if (!csgo->send_packet)
{
float angle = csgo->local->GetVelocity().Length2D() > 10.f ? 180.f : 120.f;
csgo->cmd->viewangles.y += (angle - desync_amount) * side;
}
}
// ñìûñë äåëàòü ñâèò÷, åñëè àíòè-àèì îäèí? (@opai)
if (vars.antiaim.yaw == 1)
csgo->cmd->viewangles.y += body_lean + 60.f;
if (!legit_aa) {
csgo->cmd->viewangles.y += vars.antiaim.jitter_angle * (sw ? 1 : -1);
if (vars.antiaim.manual_antiaim) {
if (g_Binds[bind_manual_forward].active)
csgo->cmd->viewangles.y -= 180.f;
if (g_Binds[bind_manual_left].active)
csgo->cmd->viewangles.y -= 90.f;
if (g_Binds[bind_manual_right].active)
csgo->cmd->viewangles.y += 90.f;
}
}
else
{
if (vars.antiaim.yaw == 1)
csgo->cmd->viewangles.y -= 180.f;
}
if (csgo->send_packet)
sw = !sw;
else
last_angle = csgo->cmd->viewangles.y;
}
bool CAntiAim::ShouldAA()
{
bool use_aa_on_e = !csgo->local->IsDefusing() && vars.antiaim.aa_on_use && csgo->cmd->buttons & IN_USE;
if (csgo->game_rules->IsFreezeTime()
|| csgo->local->HasGunGameImmunity()
|| csgo->local->GetFlags() & FL_FROZEN)
return false;
if (!vars.antiaim.enable)
return false;
if (csgo->local->GetMoveType() == MOVETYPE_NOCLIP
|| csgo->local->GetMoveType() == MOVETYPE_LADDER)
return false;
if (csgo->cmd->buttons & IN_USE && !use_aa_on_e)
return false;
bool in_attack = [&]() {
bool atk = csgo->cmd->buttons & IN_ATTACK;
if (csgo->weapon->GetItemDefinitionIndex() == WEAPON_REVOLVER)
return g_Ragebot->m_revolver_fire && atk;
else
return atk;
}();
if (F::Shooting()/* || (CanExploit() && in_attack)*/)
return false;
return true;
}
void CAntiAim::Initialize()
{
override_off_yaw = false;
override_off_pitch = false;
body_lean = 120.f;
}
void CAntiAim::Run()
{
if (g_Binds[bind_slow_walk].active || csgo->should_stop_slide)
{
const auto weapon = csgo->weapon;
const auto info = csgo->weapon->GetCSWpnData();
if (!weapon)
return;
if (!info)
return;
float speed = csgo->local->IsScoped() ? info->m_flMaxSpeedAlt : info->m_flMaxSpeed;
speed /= 3.4f;
float min_speed = (float)(sqrt(pow(csgo->cmd->forwardmove, 2) + pow(csgo->cmd->sidemove, 2) + pow(csgo->cmd->upmove, 2)));
if (min_speed > speed && min_speed > 0.f)
{
float ratio = speed / min_speed;
csgo->cmd->forwardmove *= ratio;
csgo->cmd->sidemove *= ratio;
csgo->cmd->upmove *= ratio;
}
csgo->should_stop_slide = false;
}
bool use_aa_on_e = !csgo->local->IsDefusing() && vars.antiaim.aa_on_use && csgo->cmd->buttons & IN_USE;
if (!vars.ragebot.enable && vars.legitbot.enable)
use_aa_on_e = true;
if (ShouldAA())
{
if (!override_off_pitch)
Pitch(use_aa_on_e);
if (!override_off_yaw)
Yaw(use_aa_on_e);
}
}