forked from faggotman69/Prometheus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRageBot.cpp
More file actions
1316 lines (1109 loc) · 31.9 KB
/
RageBot.cpp
File metadata and controls
1316 lines (1109 loc) · 31.9 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
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
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "RageBot.h"
#include "Render.h"
#include "Autowall.h"
#include <iostream>
#include "MathFunctions.h"
#include "SDK.h"
#include "EnginePrediction.h"
#include "LagComp.h"
//#include "Resolver.h"
#include "Chams.h"
using namespace std;
#define TICK_INTERVAL (g_Globals->interval_per_tick)
#define TICKS_TO_TIME( t ) ( g_Globals->interval_per_tick *( t ) )
#define TIME_TO_TICKS( dt ) ( (int)( 0.5f + (float)(dt) / TICK_INTERVAL ) )
ragebot::ragebot()
{
IsLocked = false;
TargetID = -1;
pTarget = nullptr;
}
void ragebot::OnCreateMove(CInput::CUserCmd *pCmd, bool& bSendPacket)
{
bool storedHitscan = g_Options.Ragebot.Hitscan;
if (!g_Options.Ragebot.MainSwitch)
return;
C_BaseEntity *pLocal = g_EntityList->GetClientEntity(g_Engine->GetLocalPlayer());
if (pLocal && pLocal->IsAlive())
{
if (g_Options.Ragebot.BAIMkey && G::PressedKeys[g_Options.Ragebot.BAIMkey] && g_Options.Ragebot.Hitscan != 4)
{
g_Options.Ragebot.Hitscan = 4;
}
else if (g_Options.Ragebot.BAIMkey && !G::PressedKeys[g_Options.Ragebot.BAIMkey] && g_Options.Ragebot.Hitscan != 3)
{
g_Options.Ragebot.Hitscan = storedHitscan;
}
CBaseCombatWeapon* weapon = (CBaseCombatWeapon*)g_EntityList->GetClientEntityFromHandle(pLocal->GetActiveWeaponHandle());
if (weapon && weapon->m_AttributeManager()->m_Item()->GetItemDefinitionIndex() == 64)
{
if (!CanAttack() && weapon->ammo() > 0)
{
pCmd->buttons |= IN_ATTACK;
}
}
if (g_Options.Ragebot.Enabled)
DoAimbot(pCmd, bSendPacket);
if (g_Options.Ragebot.AntiRecoil)
DoNoRecoil(pCmd);
if (g_Options.Ragebot.EnabledAntiAim)
DoAntiAim(pCmd, bSendPacket);
if (g_Options.Ragebot.FakeLag)
FakeLag(pCmd);
}
}
bool ragebot::hit_chance(C_BaseEntity* local, CInput::CUserCmd* cmd, CBaseCombatWeapon* weapon, C_BaseEntity* target)
{
Vector forward, right, up;
C_BaseEntity *pLocal = g_EntityList->GetClientEntity(g_Engine->GetLocalPlayer());
CBaseCombatWeapon* pWeapon = (CBaseCombatWeapon*)g_EntityList->GetClientEntityFromHandle(pLocal->GetActiveWeaponHandle());
constexpr auto max_traces = 256;
AngleVectors(cmd->viewangles, &forward, &right, &up);
int total_hits = 0;
int needed_hits;
if (MiscFunctions::IsSniper(pWeapon))
{
needed_hits = static_cast<int>(max_traces * (g_Options.Ragebot.HitchanceSniper / 100.f));
}
else if (MiscFunctions::IsPistol(pWeapon))
{
needed_hits = static_cast<int>(max_traces * (g_Options.Ragebot.HitchancePistol / 100.f));
}
else if (MiscFunctions::IsHeavy(pWeapon))
{
needed_hits = static_cast<int>(max_traces * (g_Options.Ragebot.HitchanceHeavy / 100.f));
}
else if (MiscFunctions::IsSmg(pWeapon))
{
needed_hits = static_cast<int>(max_traces * (g_Options.Ragebot.HitchanceSmgs / 100.f));
}
else if (MiscFunctions::IsRifle(pWeapon))
{
needed_hits = static_cast<int>(max_traces * (g_Options.Ragebot.HitchanceRifle / 100.f));
}
else if (MiscFunctions::IsRevolver(pWeapon))
{
needed_hits = static_cast<int>(max_traces * (g_Options.Ragebot.HitchanceRevolver / 100.f));
}
weapon->UpdateAccuracyPenalty(weapon);
auto eyes = local->GetEyePosition();
auto flRange = weapon->GetCSWpnData()->m_fRange;
for (int i = 0; i < max_traces; i++) {
RandomSeed(i + 1);
float fRand1 = RandomFloat(0.f, 1.f);
float fRandPi1 = RandomFloat(0.f, XM_2PI);
float fRand2 = RandomFloat(0.f, 1.f);
float fRandPi2 = RandomFloat(0.f, XM_2PI);
float fRandInaccuracy = fRand1 * weapon->GetInaccuracy();
float fRandSpread = fRand2 * weapon->GetSpread();
float fSpreadX = cos(fRandPi1) * fRandInaccuracy + cos(fRandPi2) * fRandSpread;
float fSpreadY = sin(fRandPi1) * fRandInaccuracy + sin(fRandPi2) * fRandSpread;
auto viewSpreadForward = (forward + fSpreadX * right + fSpreadY * up).Normalized();
Vector viewAnglesSpread;
VectorAngles(viewSpreadForward, viewAnglesSpread);
MiscFunctions::NormaliseViewAngle(viewAnglesSpread);
Vector viewForward;
AngleVectors(viewAnglesSpread, &viewForward);
viewForward.NormalizeInPlace();
viewForward = eyes + (viewForward * flRange);
trace_t tr;
Ray_t ray;
ray.Init(eyes, viewForward);
g_EngineTrace->ClipRayToEntity(ray, MASK_SHOT | CONTENTS_GRATE, target, &tr);
if (tr.m_pEnt == target)
total_hits++;
if (total_hits >= needed_hits)
return true;
if ((max_traces - i + total_hits) < needed_hits)
return false;
}
return false;
}
template<class T, class U>
T clamp(T in, U low, U high)
{
if (in <= low)
return low;
if (in >= high)
return high;
return in;
}
void ragebot::DoAimbot(CInput::CUserCmd *pCmd, bool& bSendPacket)
{
C_BaseEntity* pLocal = g_EntityList->GetClientEntity(g_Engine->GetLocalPlayer());
bool FindNewTarget = true;
//IsLocked = false;
// Don't aimbot with the knife..
CBaseCombatWeapon* pWeapon = (CBaseCombatWeapon*)g_EntityList->GetClientEntityFromHandle(pLocal->GetActiveWeaponHandle());
if (pWeapon != nullptr)
{
if (pWeapon->ammo() == 0 || MiscFunctions::IsKnife(pWeapon) || MiscFunctions::IsGrenade(pWeapon))
{
//TargetID = 0;
//pTarget = nullptr;
//HitBox = -1;
return;
}
}
else
return;
// Make sure we have a good target
if (IsLocked && TargetID >= 0 && HitBox >= 0)
{
pTarget = g_EntityList->GetClientEntity(TargetID);
if (pTarget && TargetMeetsRequirements(pTarget))
{
HitBox = HitScan(pTarget);
if (HitBox >= 0)
{
Vector ViewOffset = pLocal->GetOrigin() + pLocal->GetViewOffset();
Vector View; g_Engine->GetViewAngles(View);
float FoV = FovToPlayer(ViewOffset, View, pTarget, HitBox);
if (FoV < g_Options.Ragebot.FOV)
FindNewTarget = false;
}
}
}
// Find a new target, apparently we need to
if (FindNewTarget)
{
Globals::Shots = 0;
TargetID = 0;
pTarget = nullptr;
HitBox = -1;
TargetID = GetTargetCrosshair();
// Memesj
if (TargetID >= 0)
{
pTarget = g_EntityList->GetClientEntity(TargetID);
}
}
if (TargetID >= 0 && pTarget)
{
HitBox = HitScan(pTarget);
// Key
if (g_Options.Ragebot.KeyPress)
{
if (g_Options.Ragebot.KeyPress > 0 && !G::PressedKeys[g_Options.Ragebot.KeyPress])
{
TargetID = -1;
pTarget = nullptr;
HitBox = -1;
return;
}
}
Globals::AimPoint = GetHitboxPosition(pTarget, HitBox);
if (AimAtPoint(pLocal, Globals::AimPoint, pCmd))
{
if (g_Options.Ragebot.AutoFire && CanAttack() && MiscFunctions::IsSniper(pWeapon) && g_Options.Ragebot.AutoScope)
{
if (pLocal->IsScoped()) if (!g_Options.Ragebot.Hitchance || hit_chance(pLocal, pCmd, pWeapon, pTarget)) pCmd->buttons |= IN_ATTACK;
if (!pLocal->IsScoped()) pCmd->buttons |= IN_ATTACK2;
}
if (g_Options.Ragebot.AutoFire && CanAttack() && !(MiscFunctions::IsSniper(pWeapon)))
{
if (!g_Options.Ragebot.Hitchance || hit_chance(pLocal, pCmd, pWeapon, pTarget)) pCmd->buttons |= IN_ATTACK;
}
if (g_Options.Ragebot.AutoFire && CanAttack() && (MiscFunctions::IsSniper(pWeapon)) && !g_Options.Ragebot.AutoScope)
{
if (!g_Options.Ragebot.Hitchance || hit_chance(pLocal, pCmd, pWeapon, pTarget)) if (pLocal->IsScoped()) pCmd->buttons |= IN_ATTACK;
}
}
//Calculate shot fired
if (pWeapon)
{
if (!(pCmd->buttons & IN_ATTACK) && pWeapon->GetNextPrimaryAttack() <= (pLocal->GetTickBase() * g_Globals->interval_per_tick)) {
Globals::Shots = 0;
Globals::missedshots = 0;
}
else {
Globals::Shots += pLocal->m_iShotsFired();
}
}
if (g_Options.Ragebot.AutoStop)
{
pCmd->forwardmove = 0.f;
pCmd->sidemove = 0.f;
}
if (g_Options.Ragebot.AutoCrouch)
{
pCmd->buttons |= IN_DUCK;
}
}
// Auto Pistol
static bool WasFiring = false;
if (pWeapon != nullptr)
{
if (MiscFunctions::IsPistol(pWeapon) && g_Options.Ragebot.AutoPistol && pWeapon->m_AttributeManager()->m_Item()->GetItemDefinitionIndex() != 64)
{
if (pCmd->buttons & IN_ATTACK && !MiscFunctions::IsKnife(pWeapon) && !MiscFunctions::IsGrenade(pWeapon))
{
if (WasFiring)
{
pCmd->buttons &= ~IN_ATTACK;
}
}
WasFiring = pCmd->buttons & IN_ATTACK ? true : false;
}
}
}
bool ragebot::TargetMeetsRequirements(C_BaseEntity* pEntity)
{
auto local = g_EntityList->GetClientEntity(g_Engine->GetLocalPlayer());
// Is a valid player
if (pEntity && pEntity->IsDormant() == false && pEntity->IsAlive() && pEntity->GetIndex() != local->GetIndex())
{
// Entity Type checks
ClientClass *pClientClass = pEntity->GetClientClass();
player_info_t pinfo;
if (pClientClass->m_ClassID == (int)ClassID::CCSPlayer && g_Engine->GetPlayerInfo(pEntity->GetIndex(), &pinfo))
{
// Team Check
if (pEntity->GetTeamNum() != local->GetTeamNum() || g_Options.Ragebot.FriendlyFire)
{
// Spawn Check
if (!pEntity->HasGunGameImmunity())
{
return true;
}
}
}
}
// They must have failed a requirement
return false;
}
float ragebot::FovToPlayer(Vector ViewOffSet, Vector View, C_BaseEntity* 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); //pvs fix disabled
// 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 ragebot::GetTargetCrosshair()
{
// Target selection
int target = -1;
float minFoV = g_Options.Ragebot.FOV;
C_BaseEntity* pLocal = g_EntityList->GetClientEntity(g_Engine->GetLocalPlayer());
Vector ViewOffset = pLocal->GetOrigin() + pLocal->GetViewOffset();
Vector View; g_Engine->GetViewAngles(View);
for (int i = 0; i < g_EntityList->GetHighestEntityIndex(); i++)
{
C_BaseEntity *pEntity = g_EntityList->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 ragebot::HitScan(C_BaseEntity* pEntity)
{
vector<int> HitBoxesToScan{ Head , Neck, Chest, Stomach };
C_BaseEntity *pLocal = g_EntityList->GetClientEntity(g_Engine->GetLocalPlayer());
CBaseCombatWeapon* pWeapon = (CBaseCombatWeapon*)g_EntityList->GetClientEntityFromHandle(pLocal->GetActiveWeaponHandle());
int HitScanMode = g_Options.Ragebot.Hitscan;
if (!g_Options.Ragebot.Hitscan)
{
switch (g_Options.Ragebot.Hitbox)
{
case 0:
HitBoxesToScan.push_back(Head);
break;
case 1:
HitBoxesToScan.push_back(Neck);
break;
case 2:
HitBoxesToScan.push_back(Pelvis);
break;
}
}
else
{
switch (HitScanMode)
{
case 1:
// low
HitBoxesToScan.push_back(Head);
HitBoxesToScan.push_back(Neck);
HitBoxesToScan.push_back(UpperChest);
HitBoxesToScan.push_back(Chest);
HitBoxesToScan.push_back(Stomach);
HitBoxesToScan.push_back(Pelvis);
break;
case 2:
// medium
HitBoxesToScan.push_back(Head);
HitBoxesToScan.push_back(Neck);
HitBoxesToScan.push_back(UpperChest);
HitBoxesToScan.push_back(Chest);
HitBoxesToScan.push_back(Stomach);
HitBoxesToScan.push_back(Pelvis);
HitBoxesToScan.push_back(LeftUpperArm);
HitBoxesToScan.push_back(RightUpperArm);
HitBoxesToScan.push_back(LeftThigh);
HitBoxesToScan.push_back(RightThigh);
break;
case 3:
// high
HitBoxesToScan.push_back(Head);
HitBoxesToScan.push_back(Neck);
HitBoxesToScan.push_back(UpperChest);
HitBoxesToScan.push_back(Chest);
HitBoxesToScan.push_back(Stomach);
HitBoxesToScan.push_back(Pelvis);
HitBoxesToScan.push_back(LeftThigh);
HitBoxesToScan.push_back(RightThigh);
HitBoxesToScan.push_back(LeftFoot);
HitBoxesToScan.push_back(RightFoot);
HitBoxesToScan.push_back(LeftShin);
HitBoxesToScan.push_back(RightShin);
HitBoxesToScan.push_back(LeftLowerArm);
HitBoxesToScan.push_back(RightLowerArm);
HitBoxesToScan.push_back(LeftUpperArm);
HitBoxesToScan.push_back(RightUpperArm);
HitBoxesToScan.push_back(LeftHand);
HitBoxesToScan.push_back(RightHand);
break;
case 4:
// baim
HitBoxesToScan.push_back(UpperChest);
HitBoxesToScan.push_back(Chest);
HitBoxesToScan.push_back(Stomach);
HitBoxesToScan.push_back(Pelvis);
HitBoxesToScan.push_back(LeftUpperArm);
HitBoxesToScan.push_back(RightUpperArm);
HitBoxesToScan.push_back(LeftThigh);
HitBoxesToScan.push_back(RightThigh);
HitBoxesToScan.push_back(LeftHand);
HitBoxesToScan.push_back(RightHand);
HitBoxesToScan.push_back(LeftFoot);
HitBoxesToScan.push_back(RightFoot);
HitBoxesToScan.push_back(LeftShin);
HitBoxesToScan.push_back(RightShin);
HitBoxesToScan.push_back(LeftLowerArm);
HitBoxesToScan.push_back(RightLowerArm);
break;
}
}
static vector<int> baim{ UpperChest ,Chest ,Stomach ,Pelvis ,LeftUpperArm ,RightUpperArm ,LeftThigh,RightThigh ,LeftHand ,RightHand, LeftFoot, RightFoot, LeftShin, RightShin,LeftLowerArm,RightLowerArm };
int bestHitbox = -1;
float highestDamage;
if (MiscFunctions::IsSniper(pWeapon))
{
highestDamage = g_Options.Ragebot.MinimumDamageSniper;
}
else if (MiscFunctions::IsPistol(pWeapon))
{
highestDamage = g_Options.Ragebot.MinimumDamagePistol;
}
else if (MiscFunctions::IsHeavy(pWeapon))
{
highestDamage = g_Options.Ragebot.MinimumDamageHeavy;
}
else if (MiscFunctions::IsSmg(pWeapon))
{
highestDamage = g_Options.Ragebot.MinimumDamageSmg;
}
else if (MiscFunctions::IsRifle(pWeapon))
{
highestDamage = g_Options.Ragebot.MinimumDamageRifle;
}
else if (MiscFunctions::IsRevolver(pWeapon))
{
highestDamage = g_Options.Ragebot.MinimumDamageRevolver;
}
for (auto HitBoxID : HitBoxesToScan)
{
Vector Point = GetHitboxPosition(pEntity, HitBoxID); //pvs fix disabled
float damage = 0.0f;
if (CanHit(pEntity, Point, &damage))
{
if (damage > highestDamage || damage > pEntity->GetHealth())
{
bestHitbox = HitBoxID;
highestDamage = damage;
}
}
}
return bestHitbox;
}
void ragebot::DoNoRecoil(CInput::CUserCmd *pCmd)
{
// Ghetto rcs shit, implement properly later
C_BaseEntity* pLocal = g_EntityList->GetClientEntity(g_Engine->GetLocalPlayer());
if (pLocal != nullptr)
{
Vector AimPunch = pLocal->localPlayerExclusive()->GetAimPunchAngle();
if (AimPunch.Length2D() > 0 && AimPunch.Length2D() < 150)
{
pCmd->viewangles -= AimPunch * 2;
MiscFunctions::NormaliseViewAngle(pCmd->viewangles);
}
}
}
float FovToPoint(Vector ViewOffSet, Vector View, Vector Point)
{
// Get local view / eye position
Vector Origin = ViewOffSet;
// Create and intiialize vectors for calculations below
Vector Delta(0, 0, 0);
Vector Forward(0, 0, 0);
// Convert angles to normalized directional forward vector
AngleVectors(View, &Forward);
Vector AimPos = Point;
// Get delta vector between our local eye position and passed vector
Delta = AimPos - Origin;
//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) * (180.f / PI));
}
bool me123 = false;
bool ragebot::AimAtPoint(C_BaseEntity* pLocal, Vector point, CInput::CUserCmd *pCmd)
{
bool ReturnValue = false;
if (point.Length() == 0) return ReturnValue;
Vector angles;
Vector src = pLocal->GetOrigin() + pLocal->GetViewOffset();
VectorAngles(point - src, angles);
IsLocked = true;
ReturnValue = true;
if (g_Options.Ragebot.Silent)
{
if (CanAttack()) {
pCmd->viewangles = angles;
}
}
if (!g_Options.Ragebot.Silent)
{
pCmd->viewangles = angles;
g_Engine->SetViewAngles(pCmd->viewangles);
}
return ReturnValue;
}
void NormalizeVector(Vector& vec) {
for (int i = 0; i < 3; ++i) {
while (vec[i] > 180.f)
vec[i] -= 360.f;
while (vec[i] < -180.f)
vec[i] += 360.f;
}
vec[2] = 0.f;
}
void VectorAngles2(const Vector &vecForward, Vector &vecAngles)
{
Vector vecView;
if (vecForward[1] == 0.f && vecForward[0] == 0.f)
{
vecView[0] = 0.f;
vecView[1] = 0.f;
}
else
{
vecView[1] = vec_t(atan2(vecForward[1], vecForward[0]) * 180.f / M_PI);
if (vecView[1] < 0.f)
vecView[1] += 360.f;
vecView[2] = sqrt(vecForward[0] * vecForward[0] + vecForward[1] * vecForward[1]);
vecView[0] = vec_t(atan2(vecForward[2], vecView[2]) * 180.f / M_PI);
}
vecAngles[0] = -vecView[0];
vecAngles[1] = vecView[1];
vecAngles[2] = 0.f;
}
bool EdgeAntiAim(C_BaseEntity* pLocalBaseEntity, CInput::CUserCmd* cmd, float flWall, float flCornor)
{
Ray_t ray;
trace_t tr;
CTraceFilter traceFilter;
traceFilter.pSkip = pLocalBaseEntity;
auto bRetVal = false;
auto vecCurPos = pLocalBaseEntity->GetEyePosition();
for (float i = 0; i < 360; i++)
{
Vector vecDummy(10.f, cmd->viewangles.y, 0.f);
vecDummy.y += i;
NormalizeVector(vecDummy);
Vector vecForward;
AngleVectors2(vecDummy, vecForward);
auto flLength = ((16.f + 3.f) + ((16.f + 3.f) * sin(DEG2RAD(10.f)))) + 7.f;
vecForward *= flLength;
ray.Init(vecCurPos, (vecCurPos + vecForward));
g_EngineTrace->TraceRay(ray, MASK_SHOT, (CTraceFilter *)&traceFilter, &tr);
if (tr.fraction != 1.0f)
{
Vector qAngles;
auto vecNegate = tr.plane.normal;
vecNegate *= -1.f;
VectorAngles2(vecNegate, qAngles);
vecDummy.y = qAngles.y;
NormalizeVector(vecDummy);
trace_t leftTrace, rightTrace;
Vector vecLeft;
AngleVectors2(vecDummy + Vector(0.f, 30.f, 0.f), vecLeft);
Vector vecRight;
AngleVectors2(vecDummy - Vector(0.f, 30.f, 0.f), vecRight);
vecLeft *= (flLength + (flLength * sin(DEG2RAD(30.f))));
vecRight *= (flLength + (flLength * sin(DEG2RAD(30.f))));
ray.Init(vecCurPos, (vecCurPos + vecLeft));
g_EngineTrace->TraceRay(ray, MASK_SHOT, (CTraceFilter*)&traceFilter, &leftTrace);
ray.Init(vecCurPos, (vecCurPos + vecRight));
g_EngineTrace->TraceRay(ray, MASK_SHOT, (CTraceFilter*)&traceFilter, &rightTrace);
if ((leftTrace.fraction == 1.f) && (rightTrace.fraction != 1.f))
vecDummy.y -= flCornor; // left
else if ((leftTrace.fraction != 1.f) && (rightTrace.fraction == 1.f))
vecDummy.y += flCornor; // right
cmd->viewangles.y = vecDummy.y;
cmd->viewangles.y -= flWall;
cmd->viewangles.x = 89.0f;
bRetVal = true;
}
}
return bRetVal;
}
// AntiAim
void ragebot::DoAntiAim(CInput::CUserCmd *pCmd, bool& bSendPacket)
{
C_BaseEntity* pLocal = g_EntityList->GetClientEntity(g_Engine->GetLocalPlayer());
CBaseCombatWeapon* pWeapon = (CBaseCombatWeapon*)g_EntityList->GetClientEntityFromHandle(pLocal->GetActiveWeaponHandle());
// If the aimbot is doing something don't do anything
if (pCmd->buttons & IN_ATTACK && CanAttack())
return;
if ((pCmd->buttons & IN_USE))
return;
if (pLocal->GetMoveType() == MOVETYPE_LADDER)
return;
// Weapon shit
if (pWeapon)
{
CSWeaponInfo* pWeaponInfo = pWeapon->GetCSWpnData();
CCSGrenade* csGrenade = (CCSGrenade*)pWeapon;
if (MiscFunctions::IsKnife(pWeapon) && !g_Options.Ragebot.KnifeAA)
return;
if (csGrenade->GetThrowTime() > 0.f)
return;
}
// Don't do antiaim
// if (DoExit) return;
if (g_Options.Ragebot.Edge) {
auto bEdge = EdgeAntiAim(pLocal, pCmd, 360.f, 89.f);
if (bEdge)
return;
}
if (g_Options.Ragebot.YawFake != 0)
Globals::ySwitch = !Globals::ySwitch;
else
Globals::ySwitch = true;
bSendPacket = Globals::ySwitch;
Vector SpinAngles = { 0,0,0 };
Vector FakeAngles = { 0,0,0 };
float server_time = pLocal->GetTickBase() * g_Globals->interval_per_tick;
static int ticks;
static bool flip;
if (ticks < 15 + rand() % 20)
ticks++;
else
{
flip = !flip;
ticks = 0;
}
Vector StartAngles;
double rate = 360.0 / 1.618033988749895;
double yaw = fmod(static_cast<double>(server_time)*rate, 360.0);
double factor = 360.0 / M_PI;
factor *= 25;
switch (g_Options.Ragebot.YawTrue)
{
case 1: //sideways
{
g_Engine->GetViewAngles(StartAngles);
SpinAngles.y = flip ? StartAngles.y - 90.f : StartAngles.y + 90.f;
}
break;
case 2://slowspin
SpinAngles.y += static_cast<float>(yaw);
break;
case 3://fastspin
{
SpinAngles.y = (float)(fmod(server_time / 0.05f * 360.0f, 360.0f));
}
break;
case 4://backwards
{
g_Engine->GetViewAngles(StartAngles);
StartAngles.y -= 180.f;
SpinAngles = StartAngles;
}
break;
case 5:
{
SpinAngles.y = pLocal->GetLowerBodyYaw();
}
break;
case 6:
{
g_Engine->GetViewAngles(StartAngles);
static bool dir = false;
if (GetAsyncKeyState(VK_LEFT)) dir = false; else if (GetAsyncKeyState(VK_RIGHT)) dir = true;
if (dir && pLocal->GetVelocity().Length2D() < 1)
{
if (Globals::shouldflip)
{
SpinAngles.y = StartAngles.y - 110;
}
else
{
SpinAngles.y = StartAngles.y + 135;
}
}
else if (!dir && pLocal->GetVelocity().Length2D() < 1)
{
if (Globals::shouldflip)
{
SpinAngles.y = StartAngles.y + 110;
}
else
{
SpinAngles.y = StartAngles.y - 135;
}
}
else if (pLocal->GetVelocity().Length2D() > 0)
{
SpinAngles.y = StartAngles.y + 180;
}
}
break;
case 7:
{
g_Engine->GetViewAngles(StartAngles);
SpinAngles.y = flip ? StartAngles.y - 145.f : StartAngles.y + 145.f;
}
break;
case 8:
{
g_Engine->GetViewAngles(StartAngles);
static bool dir = false;
static int jitterangle = 0;
if (GetAsyncKeyState(VK_LEFT)) dir = false; else if (GetAsyncKeyState(VK_RIGHT)) dir = true;
if (dir && pLocal->GetVelocity().Length2D() < 1)
{
if (Globals::shouldflip)
{
SpinAngles.y = StartAngles.y - 90;
}
else
{
SpinAngles.y = StartAngles.y + 125;
if (jitterangle <= 1)
{
SpinAngles.y = StartAngles.y + 125;
jitterangle += 1;
}
else if (jitterangle > 1 && jitterangle <= 3)
{
SpinAngles.y = StartAngles.y + 145;
jitterangle += 1;
}
else
{
jitterangle = 0;
}
}
}
else if (!dir && pLocal->GetVelocity().Length2D() < 1)
{
if (Globals::shouldflip)
{
SpinAngles.y = StartAngles.y + 90;
}
else
{
SpinAngles.y = StartAngles.y - 125;
if (jitterangle <= 1)
{
SpinAngles.y = StartAngles.y - 125;
jitterangle += 1;
}
else if (jitterangle > 1 && jitterangle <= 3)
{
SpinAngles.y = StartAngles.y - 145;
jitterangle += 1;
}
else
{
jitterangle = 0;
}
}
}
else if (pLocal->GetVelocity().Length2D() > 0)
{
SpinAngles.y = StartAngles.y + 155;
if (jitterangle <= 1)
{
SpinAngles.y = StartAngles.y + 155;
jitterangle += 1;
}
else if (jitterangle > 1 && jitterangle <= 3)
{
SpinAngles.y = StartAngles.y - 155;
jitterangle += 1;
}
else
{
jitterangle = 0;
}
}
}
break;
}
switch (g_Options.Ragebot.YawFake)
{
case 1://sideways
{
g_Engine->GetViewAngles(StartAngles);
FakeAngles.y = flip ? StartAngles.y + 90.f : StartAngles.y - 90.f;
}
break;
case 2://slowspin
FakeAngles.y += static_cast<float>(yaw);
break;
case 3://fastspin
FakeAngles.y = (float)(fmod(server_time / 0.05f * 360.0f, 360.0f));
break;
case 4://backwards
{
g_Engine->GetViewAngles(StartAngles);
StartAngles -= 180.f;
FakeAngles = StartAngles;
}
break;
case 5: //lby antiaim