-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRageBot.cpp
672 lines (584 loc) · 16.2 KB
/
RageBot.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
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
#include "RageBot.h"
#include "RenderManager.h"
#include "Autowall.h"
void CRageBot::Init()
{
IsAimStepping = false;
IsLocked = false;
TargetID = -1;
}
void CRageBot::Draw()
{
}
void CRageBot::Move(CUserCmd *pCmd)
{
// Master switch
if (!Menu::Window.RageBotTab.Active.GetState())
return;
// Aimbot
if (Menu::Window.RageBotTab.AimbotEnable.GetState())
DoAimbot(pCmd);
// Recoil
if (Menu::Window.RageBotTab.AccuracyRecoil.GetState())
DoNoRecoil(pCmd);
// No Spread
if (Menu::Window.RageBotTab.AccuracySpread.GetState())
DoNoSpread(pCmd);
// Anti-Aim
if (Menu::Window.RageBotTab.AntiAimEnable.GetState())
DoAntiAim(pCmd);
if (Menu::Window.RageBotTab.AimbotAimStep.GetState())
{
Vector AddAngs = pCmd->viewangles - LastAngle;
if (AddAngs.Length2D() > 25.f)
{
Normalize(AddAngs, AddAngs);
AddAngs *= 25;
pCmd->viewangles = LastAngle + AddAngs;
GameUtils::NormaliseViewAngle(pCmd->viewangles);
}
}
LastAngle = pCmd->viewangles;
}
// Functionality
void CRageBot::DoAimbot(CUserCmd *pCmd)
{
IClientEntity* pTarget = nullptr;
IClientEntity* pLocal = hackManager.pLocal();
bool FindNewTarget = true;
//IsLocked = false;
// Don't aimbot with the knife..
CBaseCombatWeapon* pWeapon = (CBaseCombatWeapon*)Interfaces::EntList->GetClientEntityFromHandle(pLocal->GetActiveWeaponHandle());
if (pWeapon)
{
if (pWeapon->GetAmmoInClip() == 0 || !GameUtils::IsBallisticWeapon(pWeapon))
{
//TargetID = 0;
//pTarget = nullptr;
//HitBox = -1;
return;
}
}
else
return;
// Make sure we have a good target
if (IsLocked && TargetID >= 0 && HitBox >= 0)
{
pTarget = Interfaces::EntList->GetClientEntity(TargetID);
if (pTarget && TargetMeetsRequirements(pTarget))
{
HitBox = HitScan(pTarget);
if (HitBox >= 0)
{
Vector ViewOffset = pLocal->GetOrigin() + pLocal->GetViewOffset();
Vector View; Interfaces::Engine->GetViewAngles(View);
float FoV = FovToPlayer(ViewOffset, View, pTarget, HitBox);
if (FoV < Menu::Window.RageBotTab.AimbotFov.GetValue())
FindNewTarget = false;
}
}
}
// Find a new target, apparently we need to
if (FindNewTarget)
{
TargetID = 0;
pTarget = nullptr;
HitBox = -1;
// Target selection type
switch (Menu::Window.RageBotTab.TargetSelection.GetIndex())
{
case 0:
TargetID = GetTargetCrosshair();
break;
case 1:
TargetID = GetTargetDistance();
break;
case 2:
TargetID = GetTargetHealth();
break;
}
// Memes
if (TargetID >= 0)
{
pTarget = Interfaces::EntList->GetClientEntity(TargetID);
}
else
{
pTarget = nullptr;
HitBox = -1;
}
}
// If we finally have a good target
if (TargetID >= 0 && pTarget)
{
HitBox = HitScan(pTarget);
// Key
if (Menu::Window.RageBotTab.AimbotKeyPress.GetState())
{
int Key = Menu::Window.RageBotTab.AimbotKeyBind.GetKey();
if (Key >= 0 && !GUI.GetKeyState(Key))
{
TargetID = -1;
pTarget = nullptr;
HitBox = -1;
return;
}
}
Vector AimPoint = GetHitboxPosition(pTarget, HitBox);
float Spread = pWeapon->GetInaccuracy();
if (!Menu::Window.RageBotTab.AccuracySpreadLimit.GetState() || Spread <= (Menu::Window.RageBotTab.AccuracyMinimumSpread.GetValue() / 100.f))
{
if (AimAtPoint(pLocal, AimPoint, pCmd))
{
//IsLocked = true;
if (Menu::Window.RageBotTab.AimbotAutoFire.GetState() && !(pCmd->buttons & IN_ATTACK))
{
pCmd->buttons |= IN_ATTACK;
}
}
}
if (Menu::Window.RageBotTab.AccuracyAutoStop.GetState())
{
pCmd->forwardmove = 0.f;
pCmd->sidemove = 0.f;
}
if (Menu::Window.RageBotTab.AccuracyAutoCrouch.GetState())
{
pCmd->buttons |= IN_DUCK;
}
}
// Auto Pistol
static bool WasFiring = false;
CSWeaponInfo* WeaponInfo = pWeapon->GetCSWpnData();
if (!WeaponInfo->m_IsFullAuto && Menu::Window.RageBotTab.AimbotAutoPistol.GetState())
{
if (pCmd->buttons & IN_ATTACK)
{
if (WasFiring)
{
pCmd->buttons &= ~IN_ATTACK;
}
}
WasFiring = pCmd->buttons & IN_ATTACK ? true : false;
}
}
bool CRageBot::TargetMeetsRequirements(IClientEntity* pEntity)
{
// Is a valid player
if (pEntity && pEntity->IsDormant() == false && pEntity->IsAlive() && pEntity->GetIndex() != hackManager.pLocal()->GetIndex())
{
// Entity Type checks
ClientClass *pClientClass = pEntity->GetClientClass();
player_info_t pinfo;
if (pClientClass->m_ClassID == (int)CSGOClassID::CCSPlayer && Interfaces::Engine->GetPlayerInfo(pEntity->GetIndex(), &pinfo))
{
// Team Check
if (pEntity->GetTeamNum() != hackManager.pLocal()->GetTeamNum() || Menu::Window.RageBotTab.TargetFriendlyFire.GetState())
{
// Spawn Check
if (!pEntity->HasGunGameImmunity())
{
return true;
}
}
}
}
// They must have failed a requirement
return false;
}
float CRageBot::FovToPlayer(Vector ViewOffSet, Vector View, IClientEntity* pEntity, int aHitBox)
{
// Anything past 180 degrees is just going to wrap around
CONST FLOAT MaxDegrees = 180.0f;
// Get local angles
Vector Angles = View;
// Get local view / eye position
Vector Origin = ViewOffSet;
// Create and intiialize vectors for calculations below
Vector Delta(0, 0, 0);
//Vector Origin(0, 0, 0);
Vector Forward(0, 0, 0);
// Convert angles to normalized directional forward vector
AngleVectors(Angles, &Forward);
Vector AimPos = GetHitboxPosition(pEntity, aHitBox);
// Get delta vector between our local eye position and passed vector
VectorSubtract(AimPos, Origin, Delta);
//Delta = AimPos - Origin;
// Normalize our delta vector
Normalize(Delta, Delta);
// Get dot product between delta position and directional forward vectors
FLOAT DotProduct = Forward.Dot(Delta);
// Time to calculate the field of view
return (acos(DotProduct) * (MaxDegrees / PI));
}
int CRageBot::GetTargetCrosshair()
{
// Target selection
int target = -1;
float minFoV = Menu::Window.RageBotTab.AimbotFov.GetValue();
IClientEntity* pLocal = hackManager.pLocal();
Vector ViewOffset = pLocal->GetOrigin() + pLocal->GetViewOffset();
Vector View; Interfaces::Engine->GetViewAngles(View);
for (int i = 0; i < Interfaces::EntList->GetHighestEntityIndex(); i++)
{
IClientEntity *pEntity = Interfaces::EntList->GetClientEntity(i);
if (TargetMeetsRequirements(pEntity))
{
int NewHitBox = HitScan(pEntity);
if (NewHitBox >= 0)
{
float fov = FovToPlayer(ViewOffset, View, pEntity, 0);
if (fov < minFoV)
{
minFoV = fov;
target = i;
}
}
}
}
return target;
}
int CRageBot::GetTargetDistance()
{
// Target selection
int target = -1;
int minDist = 99999;
IClientEntity* pLocal = hackManager.pLocal();
Vector ViewOffset = pLocal->GetOrigin() + pLocal->GetViewOffset();
Vector View; Interfaces::Engine->GetViewAngles(View);
for (int i = 0; i < Interfaces::EntList->GetHighestEntityIndex(); i++)
{
IClientEntity *pEntity = Interfaces::EntList->GetClientEntity(i);
if (TargetMeetsRequirements(pEntity))
{
int NewHitBox = HitScan(pEntity);
if (NewHitBox >= 0)
{
Vector Difference = pLocal->GetOrigin() - pEntity->GetOrigin();
int Distance = Difference.Length();
float fov = FovToPlayer(ViewOffset, View, pEntity, 0);
if (Distance < minDist && fov < Menu::Window.RageBotTab.AimbotFov.GetValue())
{
minDist = Distance;
target = i;
}
}
}
}
return target;
}
int CRageBot::GetTargetHealth()
{
// Target selection
int target = -1;
int minHealth = 101;
IClientEntity* pLocal = hackManager.pLocal();
Vector ViewOffset = pLocal->GetOrigin() + pLocal->GetViewOffset();
Vector View; Interfaces::Engine->GetViewAngles(View);
for (int i = 0; i < Interfaces::EntList->GetHighestEntityIndex(); i++)
{
IClientEntity *pEntity = Interfaces::EntList->GetClientEntity(i);
if (TargetMeetsRequirements(pEntity))
{
int NewHitBox = HitScan(pEntity);
if (NewHitBox >= 0)
{
int Health = pEntity->GetHealth();
float fov = FovToPlayer(ViewOffset, View, pEntity, 0);
if (Health < minHealth && fov < Menu::Window.RageBotTab.AimbotFov.GetValue())
{
minHealth = Health;
target = i;
}
}
}
}
return target;
}
int CRageBot::HitScan(IClientEntity* pEntity)
{
std::vector<int> HitBoxesToScan;
bool AWall = Menu::Window.RageBotTab.AccuracyAutoWall.GetState();
// Get the hitboxes to scan
#pragma region GetHitboxesToScan
int HitScanMode = Menu::Window.RageBotTab.TargetHitscan.GetIndex();
if (HitScanMode == 0)
{
// No Hitscan, just a single hitbox
switch (Menu::Window.RageBotTab.TargetHitbox.GetIndex())
{
case 0:
HitBoxesToScan.push_back((int)CSGOHitboxID::Head);
break;
case 1:
HitBoxesToScan.push_back((int)CSGOHitboxID::Neck);
break;
case 2:
HitBoxesToScan.push_back((int)CSGOHitboxID::Chest);
break;
case 3:
HitBoxesToScan.push_back((int)CSGOHitboxID::Stomach);
break;
}
}
else
{
switch (HitScanMode)
{
case 1:
// head/body
HitBoxesToScan.push_back((int)CSGOHitboxID::Head);
HitBoxesToScan.push_back((int)CSGOHitboxID::Neck);
HitBoxesToScan.push_back((int)CSGOHitboxID::UpperChest);
HitBoxesToScan.push_back((int)CSGOHitboxID::Chest);
HitBoxesToScan.push_back((int)CSGOHitboxID::Stomach);
HitBoxesToScan.push_back((int)CSGOHitboxID::Pelvis);
break;
case 2:
// basic +(arms, thighs)
HitBoxesToScan.push_back((int)CSGOHitboxID::Head);
HitBoxesToScan.push_back((int)CSGOHitboxID::Neck);
HitBoxesToScan.push_back((int)CSGOHitboxID::UpperChest);
HitBoxesToScan.push_back((int)CSGOHitboxID::Chest);
HitBoxesToScan.push_back((int)CSGOHitboxID::Stomach);
HitBoxesToScan.push_back((int)CSGOHitboxID::Pelvis);
HitBoxesToScan.push_back((int)CSGOHitboxID::LeftUpperArm);
HitBoxesToScan.push_back((int)CSGOHitboxID::RightUpperArm);
HitBoxesToScan.push_back((int)CSGOHitboxID::LeftThigh);
HitBoxesToScan.push_back((int)CSGOHitboxID::RightThigh);
case 3:
// heaps ++(just all the random shit)
HitBoxesToScan.push_back((int)CSGOHitboxID::Head);
HitBoxesToScan.push_back((int)CSGOHitboxID::Neck);
HitBoxesToScan.push_back((int)CSGOHitboxID::UpperChest);
HitBoxesToScan.push_back((int)CSGOHitboxID::Chest);
HitBoxesToScan.push_back((int)CSGOHitboxID::Stomach);
HitBoxesToScan.push_back((int)CSGOHitboxID::Pelvis);
HitBoxesToScan.push_back((int)CSGOHitboxID::LeftUpperArm);
HitBoxesToScan.push_back((int)CSGOHitboxID::RightUpperArm);
HitBoxesToScan.push_back((int)CSGOHitboxID::LeftThigh);
HitBoxesToScan.push_back((int)CSGOHitboxID::RightThigh);
HitBoxesToScan.push_back((int)CSGOHitboxID::LeftHand);
HitBoxesToScan.push_back((int)CSGOHitboxID::RightHand);
HitBoxesToScan.push_back((int)CSGOHitboxID::LeftFoot);
HitBoxesToScan.push_back((int)CSGOHitboxID::RightFoot);
HitBoxesToScan.push_back((int)CSGOHitboxID::LeftShin);
HitBoxesToScan.push_back((int)CSGOHitboxID::RightShin);
HitBoxesToScan.push_back((int)CSGOHitboxID::LeftLowerArm);
HitBoxesToScan.push_back((int)CSGOHitboxID::RightLowerArm);
}
}
#pragma endregion Get the list of shit to scan
// check hits
for (auto HitBoxID : HitBoxesToScan)
{
if (AWall)
{
Vector Point = GetHitboxPosition(pEntity, HitBoxID);
float Damage = 0.f;
Color c = Color(255, 255, 255, 255);
if (CanHit(Point, &Damage))
{
c = Color(0, 255, 0, 255);
if (Damage >= Menu::Window.RageBotTab.AccuracyMinimumDamage.GetValue())
{
return HitBoxID;
}
}
}
else
{
if (GameUtils::IsVisible(hackManager.pLocal(), pEntity, HitBoxID))
return HitBoxID;
}
}
return -1;
}
void CRageBot::DoNoSpread(CUserCmd *pCmd)
{
}
void CRageBot::DoNoRecoil(CUserCmd *pCmd)
{
// Ghetto rcs shit, implement properly later
IClientEntity* pLocal = hackManager.pLocal();
if (pLocal)
{
Vector AimPunch = pLocal->localPlayerExclusive()->GetAimPunchAngle();
if (AimPunch.Length2D() > 0 && AimPunch.Length2D() < 150)
{
pCmd->viewangles -= AimPunch * 2;
GameUtils::NormaliseViewAngle(pCmd->viewangles);
}
}
}
bool CRageBot::AimAtPoint(IClientEntity* pLocal, Vector point, CUserCmd *pCmd)
{
bool ReturnValue = false;
// Get the full angles
if (point.Length() == 0) return ReturnValue;
Vector angles;
Vector src = pLocal->GetOrigin() + pLocal->GetViewOffset();
CalcAngle(src, point, angles);
GameUtils::NormaliseViewAngle(angles);
if (angles[0] != angles[0] || angles[1] != angles[1])
{
return ReturnValue;
}
IsLocked = true;
//-----------------------------------------------
// Aim Step Calcs
Vector ViewOffset = pLocal->GetOrigin() + pLocal->GetViewOffset();
if (!IsAimStepping)
LastAimstepAngle = LastAngle; // Don't just use the viewangs because you need to consider aa
float fovLeft = FovToPlayer(ViewOffset, LastAimstepAngle, Interfaces::EntList->GetClientEntity(TargetID), 0);
if (fovLeft > 25.0f && Menu::Window.RageBotTab.AimbotAimStep.GetState())
{
Vector AddAngs = angles - LastAimstepAngle;
Normalize(AddAngs, AddAngs);
AddAngs *= 25;
LastAimstepAngle += AddAngs;
GameUtils::NormaliseViewAngle(LastAimstepAngle);
angles = LastAimstepAngle;
}
else
{
ReturnValue = true;
}
pCmd->viewangles = angles;
if (!Menu::Window.RageBotTab.AimbotSilentAim.GetState())
Interfaces::Engine->SetViewAngles(angles);
return ReturnValue;
}
namespace AntiAims
{
// Pitches
void StaticPitch(CUserCmd *pCmd, bool up)
{
if (up)
// Up
pCmd->viewangles.x = -88;
else
// Up
pCmd->viewangles.x = 88;
}
void JitterPitch(CUserCmd *pCmd)
{
static bool up = true;
if (up) pCmd->viewangles.x = -88;
else pCmd->viewangles.x = 88;
up = !up;
}
// Yaws
void FastSpint(CUserCmd *pCmd)
{
int random = 160 + rand() % 40;
static float current_y = pCmd->viewangles.y;
current_y += random;
pCmd->viewangles.y = current_y;
}
void SlowSpin(CUserCmd *pCmd)
{
int random = rand() % 100;
int random2 = rand() % 1000;
static bool dir;
static float current_y = pCmd->viewangles.y;
if (random == 1) dir = !dir;
if (dir)
current_y += 5;
else
current_y -= 5;
pCmd->viewangles.y = current_y;
if (random == random2)
pCmd->viewangles.y += random;
}
void BackJitter(CUserCmd *pCmd)
{
int random = rand() % 100;
// Small chance of starting fowards
if (random < 98)
// Look backwards
pCmd->viewangles.y -= 180;
// Some gitter
if (random < 15)
{
float change = -70 + (rand() % (int)(140 + 1));
pCmd->viewangles.y += change;
}
if (random == 69)
{
float change = -90 + (rand() % (int)(180 + 1));
pCmd->viewangles.y += change;
}
}
void Flip(CUserCmd *pCmd)
{
static bool back = false;
back = !back;
if (back)
pCmd->viewangles.y -= 180;
}
}
// AntiAim
void CRageBot::DoAntiAim(CUserCmd *pCmd)
{
// If the aimbot is doing something don't do anything
if (IsAimStepping || pCmd->buttons & IN_ATTACK)
return;
// Weapon shit
CBaseCombatWeapon* pWeapon = (CBaseCombatWeapon*)Interfaces::EntList->GetClientEntityFromHandle(hackManager.pLocal()->GetActiveWeaponHandle());
if (pWeapon)
{
CSWeaponInfo* pWeaponInfo = pWeapon->GetCSWpnData();
// Knives or grenades
if (!GameUtils::IsBallisticWeapon(pWeapon))
return;
}
// Don't do antiaim
// if (DoExit) return;
// Anti-Aim Pitch
switch (Menu::Window.RageBotTab.AntiAimPitch.GetIndex())
{
case 0:
// No Pitch AA
break;
case 1:
// up
AntiAims::StaticPitch(pCmd, true);
break;
case 2:
// Down
AntiAims::StaticPitch(pCmd, false);
break;
case 3:
// Jitter
AntiAims::JitterPitch(pCmd);
break;
}
//Anti-Aim Yaw
switch (Menu::Window.RageBotTab.AntiAimYaw.GetIndex())
{
case 0:
// No Yaw AA
break;
case 1:
// Fast Spin
AntiAims::FastSpint(pCmd);
break;
case 2:
// Slow Spin
AntiAims::SlowSpin(pCmd);
break;
case 3:
// Inverse
pCmd->viewangles.y -= 180;
break;
case 4:
// Jitter
AntiAims::BackJitter(pCmd);
break;
case 5:
// Flip
AntiAims::Flip(pCmd);
break;
}
}