@@ -42,6 +42,7 @@ local Mchargebot = menu:AddComponent(MenuLib.Checkbox("Charge Controll", true
42
42
local mSensetivity = menu :AddComponent (MenuLib .Slider (" Charge Sensetivity" ,1 ,100 ,50 ))
43
43
local mAutoRefill = menu :AddComponent (MenuLib .Checkbox (" Crit Refill" , true ))
44
44
local mInstaHit = menu :AddComponent (MenuLib .Checkbox (" Instant attack" , true ))
45
+ local mWhipMate = menu :AddComponent (MenuLib .Checkbox (" Whip teamamtes" , true ))
45
46
-- local AutoFakelat = menu:AddComponent(MenuLib.Checkbox("Adaptive Latency", true, ItemFlags.FullWidth))
46
47
local AchargeRange = menu :AddComponent (MenuLib .Checkbox (" Charge Reach" , false , ItemFlags .FullWidth ))
47
48
local mAutoGarden = menu :AddComponent (MenuLib .Checkbox (" Troldier assist" , false ))
298
299
local function GetBestTarget (me )
299
300
settings = {
300
301
MinDistance = swingrange ,
301
- MaxDistance = 1000 ,
302
+ MaxDistance = 770 ,
302
303
MinFOV = 0 ,
303
304
MaxFOV = 360 ,
304
305
}
@@ -307,41 +308,49 @@ local function GetBestTarget(me)
307
308
local localPlayer = entities .GetLocalPlayer ()
308
309
if not localPlayer then return end
309
310
311
+ local localPlayerOrigin = localPlayer :GetAbsOrigin ()
312
+ local localPlayerTeam = localPlayer :GetTeamNumber ()
313
+ local localPlayerViewAngles = engine .GetViewAngles ()
314
+
310
315
local targetList = {}
311
316
local targetCount = 0
312
-
313
317
-- Calculate target factors
314
318
for i , player in ipairs (players ) do
315
- if not Helpers .VisPos (player , pLocalOrigin , player :GetAbsOrigin ()) then
316
- -- Skip players not visible
317
- goto continue
318
- end
319
+ local playerTeam = player :GetTeamNumber ()
320
+ local playerOrigin = player :GetAbsOrigin ()
319
321
320
- if player == localPlayer or player : GetTeamNumber () == localPlayer : GetTeamNumber () then
321
- -- Skip local player and teammates
322
+ -- Check if the player is invalid
323
+ if player == nil or player == pLocal or not player : IsAlive () or player : IsDormant () then
322
324
goto continue
323
325
end
324
326
325
- if player == nil or not player : IsAlive () then
326
- -- Skip dead players or nil references
327
+ -- Check if we have a whip and the "whip teammates" option is off, but the player is on the local player's team
328
+ if not mWhipMate : GetValue () and swingrange == 109.5 and playerTeam == localPlayerTeam then
327
329
goto continue
328
330
end
329
-
331
+
330
332
if gui .GetValue (" ignore cloaked" ) == 1 and player :InCond (4 ) then
331
- -- Skip cloaked players if enabled
333
+ goto continue
334
+ end
335
+
336
+ if not Helpers .VisPos (player , localPlayerOrigin , playerOrigin ) then
332
337
goto continue
333
338
end
334
339
335
- if player :IsDormant () then
336
- -- Skip dormant players
340
+
341
+ -- Calculate Manhattan distance
342
+ local distance = math.abs (playerOrigin .x - localPlayerOrigin .x ) + math.abs (playerOrigin .y - localPlayerOrigin .y ) + math.abs (playerOrigin .z - localPlayerOrigin .z )
343
+
344
+ if distance > settings .MaxDistance then
337
345
goto continue
338
346
end
339
347
340
- local distance = (player :GetAbsOrigin () - localPlayer :GetAbsOrigin ()):Length ()
348
+ local angles = Math .PositionAngles (localPlayerOrigin , playerOrigin + Vector3 (0 , 0 , viewheight ))
349
+ local fov = Math .AngleFov (localPlayerViewAngles , angles )
341
350
342
- -- Visibility Check
343
- local angles = Math . PositionAngles ( pLocalOrigin , player : GetAbsOrigin () + Vector3 ( 0 , 0 , viewheight ))
344
- local fov = Math . AngleFov ( engine . GetViewAngles (), angles )
351
+ if fov > settings . MaxFOV then
352
+ goto continue
353
+ end
345
354
346
355
local distanceFactor = Math .RemapValClamped (distance , settings .MinDistance , settings .MaxDistance , 1 , 0.07 )
347
356
local fovFactor = Math .RemapValClamped (fov , settings .MinFOV , settings .MaxFOV , 1 , 1 )
@@ -366,20 +375,22 @@ local function GetBestTarget(me)
366
375
local bestTarget = nil
367
376
368
377
if targetCount > 0 then
369
- local player = targetList [1 ].player
370
- local aimPos = player :GetAbsOrigin () + Vector3 (0 , 0 , 75 )
371
- local angles = Math .PositionAngles (localPlayer :GetAbsOrigin (), aimPos )
372
- local fov = Math .AngleFov (angles , engine .GetViewAngles ())
378
+ local bestPlayer = targetList [1 ].player
379
+ local bestPlayerOrigin = bestPlayer :GetAbsOrigin ()
380
+ local aimPos = bestPlayerOrigin + Vector3 (0 , 0 , 75 )
381
+ local angles = Math .PositionAngles (localPlayerOrigin , aimPos )
382
+ local fov = Math .AngleFov (angles , localPlayerViewAngles )
373
383
374
384
-- Set as best target
375
- bestTarget = { entity = player , angles = angles , factor = targetList [1 ].factor }
385
+ bestTarget = { entity = bestPlayer , angles = angles , factor = targetList [1 ].factor }
376
386
end
377
387
378
388
return bestTarget
379
389
end
380
390
391
+
381
392
-- Define function to check InRange between the hitbox and the sphere
382
- local function checkInRange (targetPos , spherePos , sphereRadius )
393
+ local function checkInRange (targetPos , spherePos , sphereRadius , target )
383
394
if vPlayerFuture == nil or not isMelee then
384
395
return false , nil
385
396
end
@@ -670,15 +681,13 @@ local cornerposition = Vector3( --ToDO: fix this
670
681
671
682
-- [--------------Prediction-------------------]
672
683
-- Predict both players' positions after swing
673
- strafeAngle = 0
674
684
gravity = client .GetConVar (" sv_gravity" )
675
685
stepSize = pLocal :GetPropFloat (" localdata" , " m_flStepSize" )
676
686
677
687
-- Local player prediction
678
688
if pLocal :EstimateAbsVelocity () == 0 then
679
689
-- If the local player is not accelerating, set the predicted position to the current position
680
690
pLocalFuture = pLocalOrigin
681
- strafeAngle = 0
682
691
else
683
692
local player = WPlayer .FromEntity (pLocal )
684
693
CalcStrafe (player )
@@ -687,7 +696,7 @@ local cornerposition = Vector3( --ToDO: fix this
687
696
local pHitbox = CalculateHitboxOffsets (player )
688
697
689
698
local predData = PredictPlayer (player , time , strafeAngle , pHitbox )
690
- local straightPredData = PredictPlayer (player , time , 0 , pHitbox )
699
+ -- local straightPredData = PredictPlayer(player, time, 0, pHitbox)
691
700
692
701
if predData == nil then
693
702
goto continue
@@ -698,12 +707,9 @@ local cornerposition = Vector3( --ToDO: fix this
698
707
end
699
708
700
709
-- Target player prediction
701
- strafeAngle = 0
702
-
703
710
if CurrentTarget :EstimateAbsVelocity () == 0 then
704
711
-- If the target player is not accelerating, set the predicted position to their current position
705
712
vPlayerFuture = CurrentTarget :GetAbsOrigin ()
706
- strafeAngle = 0
707
713
else
708
714
local player = WPlayer .FromEntity (CurrentTarget )
709
715
CalcStrafe (player )
@@ -712,16 +718,16 @@ local cornerposition = Vector3( --ToDO: fix this
712
718
local pHitbox = CalculateHitboxOffsets (player )
713
719
714
720
local predData = PredictPlayer (player , time , strafeAngle , pHitbox )
715
- local straightPredData = PredictPlayer (player , time , 0 , pHitbox )
721
+ -- local straightPredData = PredictPlayer(player, time, 0, pHitbox)
716
722
717
723
if not predData then
718
724
goto continue
719
725
end
720
726
721
- local hitchance = calculateHitChancePercentage (predData .pos [time ], straightPredData .pos [time ])
722
- if hitchance < 10 then
723
- predData = straightPredData
724
- end
727
+ -- local hitchance = calculateHitChancePercentage(predData.pos[time], straightPredData.pos[time])
728
+ -- if hitchance < 10 then
729
+ -- predData = straightPredData
730
+ -- end
725
731
726
732
vPlayerPath = predData .pos
727
733
vPlayerFuture = predData .pos [time ]
@@ -738,25 +744,33 @@ fDistance = (vPlayerFuture - pLocalFuture):Length()
738
744
-- Simulate swing and return result
739
745
local InRangePoint
740
746
741
- --[[ ---Check for hit detection--------]]
742
- ONGround = (flags & FL_ONGROUND == 1 )
743
- local InRange = false
744
- can_charge = false
745
-
746
747
-- Check for InRange with current position
747
748
InRange , InRangePoint = checkInRange (vPlayerOrigin , pLocalOrigin , swingrange )
748
- -- Trigger doubletap only if in range, attacking, and doubletap conditions are met
749
-
750
- if not InRange then
751
- -- If not in range, check future positions
752
- InRange = checkInRange (vPlayerFuture , pLocalFuture , swingrange )
753
- end
754
749
755
750
-- Decide if can attack based on InRange
756
751
can_attack = InRange
757
-
758
752
753
+ if can_attack then
754
+ -- If in range, move players to their future positions
755
+ CurrentTarget :SetPropVector (vPlayerFuture , " tfnonlocaldata" , " m_vecOrigin" )
756
+ pLocal :SetPropVector (pLocalFuture , " tfnonlocaldata" , " m_vecOrigin" )
757
+
758
+ -- Make pLocal aim at the InRangePoint
759
+ local aimAngles = Math .PositionAngles (pLocalFuture , InRangePoint )
760
+ pCmd :SetViewAngles (aimAngles .pitch , aimAngles .yaw , 0 )
759
761
762
+ -- Run a swing trace from pLocal to the target
763
+ local swingTrace = pLocal :DoSwingTrace ()
764
+
765
+ -- If the entity hit by the swing trace is the same as the target, consider the attack successful
766
+ if swingTrace then
767
+ can_charge = true
768
+ end
769
+
770
+ -- Move players back to their original positions
771
+ CurrentTarget :SetPropVector (vPlayerOrigin , " tfnonlocaldata" , " m_vecOrigin" )
772
+ pLocal :SetPropVector (pLocalOrigin , " tfnonlocaldata" , " m_vecOrigin" )
773
+ end
760
774
-- Check for charge range bug
761
775
if pLocalClass == 4 -- player is Demoman
762
776
and AchargeRange :GetValue () -- menu option for such option is true
@@ -797,20 +811,23 @@ can_attack = InRange
797
811
goto continue
798
812
end
799
813
800
- if Maimbot :GetValue () and Helpers .VisPos (CurrentTarget , vPlayerFuture , pLocalFuture )
801
- and pLocal :InCond (17 )
802
- and not InRange
803
- then
804
- Eaimpos = Math .PositionAngles (pLocalOrigin , Eaimpos )
805
- pCmd :SetViewAngles (engine .GetViewAngles ().pitch , Eaimpos .yaw , 0 )
806
- elseif Maimbot :GetValue () and can_attack then
807
- Eaimpos = Math .PositionAngles (pLocalOrigin , Eaimpos )
808
- if MSilent :GetValue () then
809
- pCmd :SetViewAngles (Eaimpos .pitch , Eaimpos .yaw , 0 )
810
- else
811
- engine .SetViewAngles (EulerAngles (Eaimpos .pitch , Eaimpos .yaw , 0 ))
814
+ -- Calculate aim position only once
815
+ Eaimpos = Math .PositionAngles (pLocalOrigin , Eaimpos )
816
+
817
+ if Maimbot :GetValue () then
818
+ if Helpers .VisPos (CurrentTarget , vPlayerFuture , pLocalFuture ) and not InRange then
819
+ -- Set view angles based on the future position of the local player
820
+ pCmd :SetViewAngles (engine .GetViewAngles ().pitch , Eaimpos .yaw , 0 )
821
+ elseif can_attack then
822
+ -- Set view angles based on whether silent aim is enabled
823
+ if MSilent :GetValue () then
824
+ pCmd :SetViewAngles (Eaimpos .pitch , Eaimpos .yaw , 0 )
825
+ else
826
+ engine .SetViewAngles (EulerAngles (Eaimpos .pitch , Eaimpos .yaw , 0 ))
827
+ end
812
828
end
813
829
elseif Mchargebot :GetValue () and pLocal :InCond (17 ) then
830
+ -- Control charge if charge bot is enabled and the local player is in condition 17
814
831
ChargeControl (pCmd )
815
832
end
816
833
0 commit comments