@@ -206,11 +206,12 @@ local hitbox_Width = 24
206
206
local isMelee = false
207
207
local mresolution = 64
208
208
local pLocal = entities .GetLocalPlayer ()
209
+ local players = entities .FindByClass (" CTFPlayer" )
209
210
local ping = 0
210
211
local swingrange = 48
211
212
local tickRate = 66
212
213
local tick_count = 0
213
- local time = 14
214
+ local time = 13
214
215
local Gcan_attack = false
215
216
local Safe_Strafe = false
216
217
local can_charge = false
@@ -224,7 +225,12 @@ local PredPath = {}
224
225
local vHitbox = { Vector3 (- 24 , - 24 , 0 ), Vector3 (24 , 24 , 80 ) }
225
226
local drawVhitbox = {}
226
227
local gravity = client .GetConVar (" sv_gravity" ) or 800 -- Get the current gravity
227
- local stepSize = pLocal :GetPropFloat (" localdata" , " m_flStepSize" ) or 18
228
+ if pLocal then
229
+ local stepSize = pLocal :GetPropFloat (" localdata" , " m_flStepSize" ) or 18
230
+ else
231
+ local stepSize = 18
232
+ end
233
+
228
234
local backtrackTicks = {}
229
235
local vPlayerViewHeight = 75
230
236
@@ -265,9 +271,8 @@ local maxPositions = 4 -- Number of past positions to consider
265
271
266
272
267
273
local function CalcStrafe ()
268
- local players = entities .FindByClass (" CTFPlayer" )
269
274
local autostrafe = gui .GetValue (" Auto Strafe" )
270
- local flags = pLocal :GetPropInt (" m_fFlags" )
275
+ local flags = entities . GetLocalPlayer () :GetPropInt (" m_fFlags" )
271
276
local OnGround = flags & FL_ONGROUND == 1
272
277
273
278
for idx , entity in ipairs (players ) do
@@ -462,84 +467,66 @@ end
462
467
463
468
local playerTicks = {}
464
469
465
- local function GetBestTarget (me )
470
+ local playerTicks = {}
471
+ local maxTick = math.floor (((defFakeLatency ) / 1000 ) / 0.015 )
466
472
467
- local players = entities . FindByClass ( " CTFPlayer " )
473
+ local function GetBestTarget ( me )
468
474
local localPlayer = entities .GetLocalPlayer ()
469
475
if not localPlayer then return end
470
476
471
477
local bestTarget = nil
472
478
local bestFactor = 0
473
- local target_viewoffset = nil
474
- -- settings.MaxDistance = swingrange * 1.2
475
-
476
479
local localPlayerViewAngles = engine .GetViewAngles ()
477
480
481
+ for _ , player in pairs (players ) do
482
+ if player == nil or not player :IsAlive ()
483
+ or player :IsDormant ()
484
+ or player == me or player :GetTeamNumber () == me :GetTeamNumber ()
485
+ or gui .GetValue (" ignore cloaked" ) == 1 and player :InCond (4 ) then
486
+ goto continue
487
+ end
488
+
489
+ local numBacktrackTicks = gui .GetValue (" Fake Latency" ) == 1 and maxTick or gui .GetValue (" Fake Latency" ) == 0 and gui .GetValue (" Backtrack" ) == 1 and 4 or 0
478
490
479
- for _ , player in ipairs (players ) do
480
- if player ~= nil and player :GetIndex () ~= pLocal :GetIndex () and player :IsAlive () and not player :IsDormant () then
481
- if player :GetTeamNumber () ~= localPlayer :GetTeamNumber () then
482
-
483
-
484
- -- local minTick = math.floor((defFakeLatency / 900) / 0.015)
485
- local maxTick = math.floor (((defFakeLatency ) / 1000 ) / 0.015 )
486
-
487
- local numBacktrackTicks = gui .GetValue (" Fake Latency" ) == 1 and maxTick or gui .GetValue (" Fake Latency" ) == 0 and gui .GetValue (" Backtrack" ) == 1 and 4 or 0
488
-
489
- if numBacktrackTicks ~= 0 then
490
- local playerIndex = player :GetIndex ()
491
- playerTicks [playerIndex ] = playerTicks [playerIndex ] or {}
492
- table.insert (playerTicks [playerIndex ], player :GetAbsOrigin ())
493
-
494
- -- If the player's tick count exceeds maxinteger, remove the oldest tick
495
- if # playerTicks [playerIndex ] > numBacktrackTicks then
496
- table.remove (playerTicks [playerIndex ], 1 )
497
- end
498
- end
491
+ if numBacktrackTicks ~= 0 then
492
+ local playerIndex = player :GetIndex ()
493
+ playerTicks [playerIndex ] = playerTicks [playerIndex ] or {}
494
+ table.insert (playerTicks [playerIndex ], player :GetAbsOrigin ())
499
495
500
- local playerOrigin = player : GetAbsOrigin ()
501
- local distance = math.abs ( playerOrigin . x - pLocalOrigin . x ) +
502
- math.abs ( playerOrigin . y - pLocalOrigin . y ) +
503
- math.abs ( playerOrigin . z - pLocalOrigin . z )
496
+ if # playerTicks [ playerIndex ] > numBacktrackTicks then
497
+ table.remove ( playerTicks [ playerIndex ], 1 )
498
+ end
499
+ end
504
500
505
- if distance <= settings .MaxDistance then
506
- local Pviewoffset = player :GetPropVector (" localdata" , " m_vecViewOffset[0]" )
507
- local Pviewpos = playerOrigin + Pviewoffset
508
- local Pviewoffset2 = (Pviewpos - playerOrigin ):Length ()
501
+ local playerOrigin = player :GetAbsOrigin ()
502
+ local distance = (playerOrigin - localPlayer :GetAbsOrigin ()):Length ()
509
503
510
- local angles = Math .PositionAngles (pLocalOrigin , Pviewpos )
511
- local fov = Math .AngleFov (localPlayerViewAngles , angles )
504
+ if distance <= 770 then
505
+ local Pviewoffset = player :GetPropVector (" localdata" , " m_vecViewOffset[0]" )
506
+ local Pviewpos = playerOrigin + Pviewoffset
512
507
513
- if fov <= settings .MaxFOV then
514
- local distanceFactor = Math .RemapValClamped (distance , settings .MinDistance , settings .MaxDistance , 1 , 0.07 )
515
- local fovFactor = Math .RemapValClamped (fov , settings .MinFOV , settings .MaxFOV , 1 , 0.9 )
516
-
517
- -- Check if the player is visible
518
- local isVisible = Helpers .VisPos (player , pLocalOrigin , Pviewpos )
519
-
520
- -- Add a visibility factor to the calculation
521
- local visibilityFactor = isVisible and 1.0 or 0.5
508
+ local angles = Math .PositionAngles (localPlayer :GetAbsOrigin (), Pviewpos )
509
+ local fov = Math .AngleFov (localPlayerViewAngles , angles )
522
510
523
- local factor = distanceFactor * fovFactor * visibilityFactor
511
+ if fov <= Menu .Aimbot .AimbotFOV then
512
+ local distanceFactor = Math .RemapValClamped (distance , settings .MinDistance , settings .MaxDistance , 1 , 0.9 )
513
+ local fovFactor = Math .RemapValClamped (fov , settings .MinFOV , Menu .Aimbot .AimbotFOV , 1 , 1 )
524
514
525
- if factor > bestFactor then
526
- bestTarget = player
527
- bestFactor = factor
528
- end
529
- end
530
- end
515
+ local factor = distanceFactor * fovFactor
516
+ if factor > bestFactor then
517
+ bestTarget = player
518
+ bestFactor = factor
531
519
end
532
520
end
533
521
end
522
+ :: continue::
523
+ end
534
524
535
- return bestTarget , target_viewoffset
525
+ return bestTarget
536
526
end
537
527
538
528
-- Define function to check InRange between the hitbox and the sphere
539
529
local function checkInRange (targetPos , spherePos , sphereRadius )
540
-
541
- local inaccuracyValue = inaccuracy [vPlayer :GetIndex ()]
542
- if not inaccuracyValue then return nil end
543
530
544
531
local hitbox_min_trigger = targetPos + vHitbox [1 ]
545
532
local hitbox_max_trigger = targetPos + vHitbox [2 ]
@@ -655,19 +642,6 @@ local function UpdateHomingMissile()
655
642
end
656
643
end
657
644
658
- local canatack = false
659
-
660
- -- Returns if the weapon can shoot
661
- --- @param weapon Entity
662
- --- @return boolean
663
- local function CanShoot (weapon )
664
- local nextPrimaryAttack = weapon :GetPropFloat (" LocalActiveWeaponData" , " m_flNextPrimaryAttack" )
665
- local nextAttack = pLocal :GetPropFloat (" bcc_localdata" , " m_flNextAttack" )
666
- if (not nextPrimaryAttack ) or (not nextAttack ) then return false end
667
-
668
- return (nextPrimaryAttack <= globals .CurTime ()) and (nextAttack <= globals .CurTime ())
669
- end
670
-
671
645
local hasNotified = false
672
646
local function checkInRangeWithLatency (playerIndex , swingRange )
673
647
local inRange = false
@@ -677,9 +651,7 @@ local function checkInRangeWithLatency(playerIndex, swingRange)
677
651
678
652
if Backtrack == 0 and fakelatencyON == 0 then
679
653
-- Check for charge range bug
680
- if pLocalClass == 4 -- player is Demoman
681
- and Menu .Misc .ChargeReach -- menu option for such option is true
682
- and chargeLeft == 100 then -- charge metter is full
654
+ if pLocalClass == 4 and Menu .Misc .ChargeReach and chargeLeft == 100 then -- charge metter is full
683
655
if checkInRange (vPlayerOrigin , pLocalOrigin , Charge_Range ) then
684
656
inRange = true
685
657
point = vPlayerOrigin
@@ -701,93 +673,88 @@ local function checkInRangeWithLatency(playerIndex, swingRange)
701
673
return inRange , point , can_charge
702
674
end
703
675
end
704
-
676
+
705
677
-- Adjust hitbox for current position
706
678
inRange , point = checkInRange (vPlayerOrigin , pLocalOrigin , swingRange - 18 )
679
+ print (inRange )
707
680
if inRange then
708
681
return inRange , point
709
682
end
710
683
684
+
711
685
inRange , point = checkInRange (vPlayerFuture , pLocalFuture , swingRange )
712
686
if inRange then
713
687
return inRange , point , can_charge
714
688
end
715
- end
716
-
717
- if fakelatencyON == 1 then
689
+ elseif fakelatencyON == 1 then
718
690
if not hasNotified then
719
691
Notify .Simple (" Fake Latency is enabled" , " this may cause issues with the script" , 7 )
720
692
hasNotified = true
721
693
end
722
694
723
695
local minTick = 1
724
- local maxTick = # playerTicks [playerIndex ]
696
+ maxTick = # playerTicks [playerIndex ]
725
697
726
698
for tick = minTick , maxTick do
727
699
if playerTicks [playerIndex ] then
728
700
local pastOrigin = playerTicks [playerIndex ][tick ]
729
701
730
- -- Check for charge range bug
731
- if pLocalClass == 4 -- player is Demoman
732
- and Menu .Misc .ChargeReach -- menu option for such option is true
733
- and chargeLeft == 100 then -- charge metter is full
734
- if checkInRange (pastOrigin , pLocalOrigin , Charge_Range ) then
735
- inRange = true
736
- point = vPlayerOrigin
737
- tick_count = tick_count + 1
738
- if tick_count >= (time - 1 ) then
739
- tick_count = 0
740
- can_charge = true
702
+ -- Check for charge range bug
703
+ if pLocalClass == 4 -- player is Demoman
704
+ and Menu .Misc .ChargeReach -- menu option for such option is true
705
+ and chargeLeft == 100 then -- charge metter is full
706
+ if checkInRange (pastOrigin , pLocalOrigin , Charge_Range ) then
707
+ inRange = true
708
+ point = vPlayerOrigin
709
+ tick_count = tick_count + 1
710
+ if tick_count >= (time - 1 ) then
711
+ tick_count = 0
712
+ can_charge = true
713
+ end
714
+ end
741
715
end
742
- end
743
- if inRange then
744
- return inRange , point , can_charge
745
- end
746
- end
747
716
748
717
inRange , point = checkInRange (pastOrigin , pLocalOrigin , swingRange )
749
718
if inRange then
750
719
return inRange , point
751
720
end
752
721
end
753
722
end
754
- end
755
-
756
- if Backtrack == 1 then
723
+ elseif Backtrack == 1 then
757
724
758
725
-- Check for charge range bug
759
726
if pLocalClass == 4 -- player is Demoman
760
- and Menu .Misc .ChargeReach -- menu option for such option is true
761
- and chargeLeft == 100 then -- charge metter is full
762
- if checkInRange (vPlayerOrigin , pLocalOrigin , Charge_Range ) then
763
- inRange = true
764
- point = vPlayerOrigin
765
- tick_count = tick_count + 1
766
- if tick_count >= (time - 1 ) then
767
- tick_count = 0
768
- can_charge = true
769
- end
770
- elseif checkInRange (vPlayerFuture , pLocalFuture , Charge_Range ) then
771
- inRange = true
772
- point = vPlayerFuture
773
- tick_count = tick_count + 1
774
- if tick_count >= (time - 1 ) then
775
- tick_count = 0
776
- can_charge = true
727
+ and Menu .Misc .ChargeReach -- menu option for such option is true
728
+ and chargeLeft == 100 then -- charge metter is full
729
+ if checkInRange (vPlayerOrigin , pLocalOrigin , Charge_Range ) then
730
+ inRange = true
731
+ point = vPlayerOrigin
732
+ tick_count = tick_count + 1
733
+ if tick_count >= (time - 1 ) then
734
+ tick_count = 0
735
+ can_charge = true
736
+ elseif checkInRange (vPlayerFuture , pLocalFuture , Charge_Range ) then
737
+ inRange = true
738
+ point = vPlayerFuture
739
+ tick_count = tick_count + 1
740
+ if tick_count >= (time - 1 ) then
741
+ tick_count = 0
742
+ can_charge = true
743
+ end
744
+ end
745
+ if inRange then
746
+ return inRange , point , can_charge
747
+ end
777
748
end
778
- end
779
- if inRange then
780
- return inRange , point , can_charge
781
- end
782
749
end
783
-
750
+
784
751
-- Adjust hitbox for current position
785
752
inRange , point = checkInRange (vPlayerOrigin , pLocalOrigin , swingRange )
786
753
if inRange then
787
754
return inRange , point
788
755
end
789
756
790
- inRange , point = checkInRange (vPlayerFuture , pLocalFuture , swingRange )
757
+ inRange = checkInRange (vPlayerFuture , pLocalFuture , swingRange )
791
758
if inRange then
792
759
return inRange , point
793
760
end
903
870
904
871
-- [-----Get best target------------------]
905
872
local keybind = Menu .Keybind
873
+ players = entities .FindByClass (" CTFPlayer" )
906
874
if keybind == 0 then
907
875
-- Check if player has no key bound
908
876
CurrentTarget = GetBestTarget (pLocal )
@@ -1072,7 +1040,7 @@ vdistance = (vPlayerOrigin - pLocalOrigin):Length()
1072
1040
else
1073
1041
engine .SetViewAngles (EulerAngles (aimpos .pitch , aimpos .yaw , 0 ))
1074
1042
end
1075
- else
1043
+ elseif pLocalClass == 4 then
1076
1044
-- Control charge if charge bot is enabled and the local player is in condition 17
1077
1045
ChargeControl (pCmd )
1078
1046
end
@@ -1311,6 +1279,7 @@ local function handleKeybind(noKeyText, keybind, keybindName)
1311
1279
-- Reset keybind if the Escape key is pressed
1312
1280
keybind = 0
1313
1281
KeybindName = " Always On"
1282
+ Notify .Simple (" Keybind Success" , " Bound Key: " .. KeybindName , 2 )
1314
1283
else
1315
1284
-- Update keybind with the pressed key
1316
1285
keybind = pressedKey
0 commit comments