This repository was archived by the owner on Nov 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 470
Expand file tree
/
Copy pathantiaim.cpp
More file actions
279 lines (227 loc) · 7.19 KB
/
Copy pathantiaim.cpp
File metadata and controls
279 lines (227 loc) · 7.19 KB
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
#include "antiaim.h"
bool Settings::AntiAim::Yaw::enabled = false;
bool Settings::AntiAim::Pitch::enabled = false;
AntiAimType_Y Settings::AntiAim::Yaw::type = AntiAimType_Y::SPIN_FAST;
AntiAimType_Y Settings::AntiAim::Yaw::typeFake = AntiAimType_Y::SPIN_FAST;
bool Settings::AntiAim::Yaw::antiResolver = false;
AntiAimType_X Settings::AntiAim::Pitch::type = AntiAimType_X::STATIC_DOWN;
bool Settings::AntiAim::HeadEdge::enabled = false;
float Settings::AntiAim::HeadEdge::distance = 25.0f;
bool Settings::AntiAim::AutoDisable::noEnemy = false;
bool Settings::AntiAim::AutoDisable::knifeHeld = false;
float Distance(Vector a, Vector b)
{
return sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2) + pow(a.z - b.z, 2));
}
bool AntiAim::GetBestHeadAngle(QAngle& angle)
{
C_BasePlayer* localplayer = (C_BasePlayer*) entityList->GetClientEntity(engine->GetLocalPlayer());
Vector position = localplayer->GetVecOrigin() + localplayer->GetVecViewOffset();
float closest_distance = 100.0f;
float radius = Settings::AntiAim::HeadEdge::distance + 0.1f;
float step = M_PI * 2.0 / 8;
for (float a = 0; a < (M_PI * 2.0); a += step)
{
Vector location(radius * cos(a) + position.x, radius * sin(a) + position.y, position.z);
Ray_t ray;
trace_t tr;
ray.Init(position, location);
CTraceFilter traceFilter;
traceFilter.pSkip = localplayer;
trace->TraceRay(ray, 0x4600400B, &traceFilter, &tr);
float distance = Distance(position, tr.endpos);
if (distance < closest_distance)
{
closest_distance = distance;
angle.y = RAD2DEG(a);
}
}
return closest_distance < Settings::AntiAim::HeadEdge::distance;
}
bool HasViableEnemy()
{
C_BasePlayer* localplayer = (C_BasePlayer*) entityList->GetClientEntity(engine->GetLocalPlayer());
for (int i = 1; i < engine->GetMaxClients(); ++i)
{
C_BasePlayer* entity = (C_BasePlayer*) entityList->GetClientEntity(i);
if (!entity
|| entity == localplayer
|| entity->GetDormant()
|| !entity->GetAlive()
|| entity->GetImmune())
continue;
IEngineClient::player_info_t entityInformation;
engine->GetPlayerInfo(i, &entityInformation);
if (std::find(Aimbot::friends.begin(), Aimbot::friends.end(), entityInformation.xuid) != Aimbot::friends.end())
continue;
if (Settings::Aimbot::friendly || entity->GetTeam() != localplayer->GetTeam())
return true;
}
return false;
}
void DoAntiAimY(QAngle& angle, int command_number, bool bFlip, bool& clamp)
{
AntiAimType_Y aa_type = bFlip ? Settings::AntiAim::Yaw::typeFake : Settings::AntiAim::Yaw::type;
static bool yFlip;
float temp;
double factor;
static float trigger;
QAngle temp_qangle;
if (bFlip)
yFlip = !yFlip;
switch (aa_type)
{
case AntiAimType_Y::SPIN_FAST:
factor = 360.0 / M_PHI;
factor *= 25;
angle.y = fmod(globalVars->curtime * factor, 360.0);
break;
case AntiAimType_Y::SPIN_SLOW:
factor = 360.0 / M_PHI;
angle.y = fmod(globalVars->curtime * factor, 360.0);
break;
case AntiAimType_Y::JITTER:
yFlip ? angle.y -= 90.0f : angle.y -= 270.0f;
break;
case AntiAimType_Y::SIDEJITTER:
yFlip ? angle.y += 90.f : angle.y -= 90.0f;
break;
case AntiAimType_Y::BACKWARDS:
angle.y -= 180.0f;
break;
case AntiAimType_Y::FORWARDS:
angle.y -= 0.0f;
break;
case AntiAimType_Y::SIDEWAYS_LEFT:
angle.y += 90.0f;
break;
case AntiAimType_Y::SIDEWAYS_RIGHT:
angle.y -= 90.0f;
break;
case AntiAimType_Y::STATICAA:
angle.y = 0.0f;
break;
case AntiAimType_Y::STATICJITTER:
trigger += 15.0f;
angle.y = trigger > 50.0f ? 150.0f : -150.0f;
if (trigger > 100.0f)
trigger = 0.0f;
break;
case AntiAimType_Y::STATICSMALLJITTER:
trigger += 15.0f;
angle.y = trigger > 50.0f ? -30.0f : 30.0f;
if (trigger > 100.0f)
trigger = 0.0f;
break;
}
}
void DoAntiAimX(QAngle& angle, bool bFlip, bool& clamp)
{
static float pDance = 0.0f;
AntiAimType_X aa_type = Settings::AntiAim::Pitch::type;
switch (aa_type)
{
case AntiAimType_X::STATIC_UP:
angle.x = -89.0f;
break;
case AntiAimType_X::STATIC_DOWN:
angle.x = 89.0f;
break;
case AntiAimType_X::DANCE:
pDance += 45.0f;
if (pDance > 100)
pDance = 0.0f;
else if (pDance > 75.f)
angle.x = -89.f;
else if (pDance < 75.f)
angle.x = 89.f;
break;
case AntiAimType_X::FRONT:
angle.x = 0.0f;
break;
case AntiAimType_X::STATIC_UP_FAKE:
angle.x = bFlip ? 89.0f : -89.0f;
break;
case AntiAimType_X::STATIC_DOWN_FAKE:
angle.x = bFlip ? -89.0f : 89.0f;
break;
}
}
void AntiAim::CreateMove(CUserCmd* cmd)
{
if (!Settings::AntiAim::Yaw::enabled && !Settings::AntiAim::Pitch::enabled)
return;
if (Settings::Aimbot::AimStep::enabled && Aimbot::aimStepInProgress)
return;
QAngle oldAngle = cmd->viewangles;
float oldForward = cmd->forwardmove;
float oldSideMove = cmd->sidemove;
QAngle angle = cmd->viewangles;
C_BasePlayer* localplayer = (C_BasePlayer*) entityList->GetClientEntity(engine->GetLocalPlayer());
if (!localplayer)
return;
C_BaseCombatWeapon* activeWeapon = (C_BaseCombatWeapon*) entityList->GetClientEntityFromHandle(localplayer->GetActiveWeapon());
if (!activeWeapon)
return;
if (activeWeapon->GetCSWpnData()->GetWeaponType() == CSWeaponType::WEAPONTYPE_GRENADE)
{
C_BaseCSGrenade* csGrenade = (C_BaseCSGrenade*) activeWeapon;
if (csGrenade->GetThrowTime() > 0.f)
return;
}
if (cmd->buttons & IN_USE || cmd->buttons & IN_ATTACK || (cmd->buttons & IN_ATTACK2 && *activeWeapon->GetItemDefinitionIndex() == ItemDefinitionIndex::WEAPON_REVOLVER))
return;
if (localplayer->GetMoveType() == MOVETYPE_LADDER || localplayer->GetMoveType() == MOVETYPE_NOCLIP)
return;
// AutoDisable checks
// Knife
if (Settings::AntiAim::AutoDisable::knifeHeld && localplayer->GetAlive() && activeWeapon->GetCSWpnData()->GetWeaponType() == CSWeaponType::WEAPONTYPE_KNIFE)
return;
if (Settings::AntiAim::AutoDisable::noEnemy && localplayer->GetAlive() && !HasViableEnemy())
return;
QAngle edge_angle = angle;
bool edging_head = Settings::AntiAim::HeadEdge::enabled && GetBestHeadAngle(edge_angle);
static bool bFlip;
bFlip = !bFlip;
bool should_clamp = true;
if (!ValveDSCheck::forceUT && (*csGameRules) && (*csGameRules)->IsValveDS())
{
if (Settings::AntiAim::Pitch::type >= AntiAimType_X::STATIC_UP_FAKE)
Settings::AntiAim::Pitch::type = AntiAimType_X::STATIC_UP;
}
if (Settings::AntiAim::Yaw::enabled)
{
DoAntiAimY(angle, cmd->command_number, bFlip, should_clamp);
Math::NormalizeAngles(angle);
if (!Settings::FakeLag::enabled)
CreateMove::sendPacket = bFlip;
if (Settings::AntiAim::HeadEdge::enabled && edging_head && !bFlip)
angle.y = edge_angle.y;
}
if (Settings::AntiAim::Pitch::enabled)
DoAntiAimX(angle, bFlip, should_clamp);
if (should_clamp)
{
Math::NormalizeAngles(angle);
Math::ClampAngles(angle);
}
cmd->viewangles = angle;
if (Settings::AntiAim::Yaw::antiResolver)
{
static bool antiResolverFlip = false;
if (cmd->viewangles.y == *localplayer->GetLowerBodyYawTarget())
{
if (antiResolverFlip)
cmd->viewangles.y += 60.f;
else
cmd->viewangles.y -= 60.f;
antiResolverFlip = !antiResolverFlip;
if (should_clamp)
{
Math::NormalizeAngles(cmd->viewangles);
Math::ClampAngles(cmd->viewangles);
}
}
}
Math::CorrectMovement(oldAngle, cmd, oldForward, oldSideMove);
}