@@ -102,6 +102,7 @@ local Menu = {
102
102
InstantAttack = true ,
103
103
ChargeReach = false ,
104
104
TroldierAssist = false ,
105
+ advancedHitreg = false ,
105
106
},
106
107
Keybind = KEY_NONE ,
107
108
KeybindName = " Always On" ,
@@ -212,7 +213,7 @@ local swingrange = 48
212
213
local tickRate = 66
213
214
local tick_count = 0
214
215
local time = 13
215
- local Gcan_attack = false
216
+ local can_attack = false
216
217
local Safe_Strafe = false
217
218
local can_charge = false
218
219
local Charge_Range = 128
@@ -525,11 +526,10 @@ local function GetBestTarget(me)
525
526
return bestTarget
526
527
end
527
528
528
- local can_attack = false
529
- local OriginalAngles = Vector3 ()
530
- local OriginalPosition = Vector3 ()
531
- local lastswingtracedata = {}
532
- local swingresult
529
+ -- Global flags and data storage
530
+ local attackReady = false
531
+ local attackData = {}
532
+ local isAttackSuccessful = false
533
533
534
534
-- Function to check if target is in range
535
535
local function checkInRange (targetPos , spherePos , sphereRadius , pWeapon )
@@ -548,50 +548,60 @@ local function checkInRange(targetPos, spherePos, sphereRadius, pWeapon)
548
548
549
549
-- Check if the target is within the sphere radius
550
550
if sphereRadius > distanceAlongVector then
551
- -- Target is in range, store data for PropUpdate
552
- OriginalPosition = pLocal :GetPropVector (" tfnonlocaldata" , " m_vecOrigin" )
553
- OriginalAngles = pLocal :GetPropVector (" tfnonlocaldata" , " m_angEyeAngles[0]" )
554
- lastswingtracedata = {pWeapon , spherePos , closestPoint }
555
- return true , closestPoint
551
+ if not Menu .Misc .advancedHitreg then return true , closestPoint end
552
+ if Menu .Misc .ChargeReach and pLocalClass == 4 and chargeLeft == 100 then return true , closestPoint end
553
+
554
+ -- Prepare data for PropUpdate
555
+ attackReady = true
556
+ attackData = {
557
+ pWeapon = pWeapon ,
558
+ spherePos = spherePos ,
559
+ closestPoint = closestPoint ,
560
+ originalPosition = pLocal :GetPropVector (" tfnonlocaldata" , " m_vecOrigin" ),
561
+ originalAngles = pLocal :GetPropVector (" tfnonlocaldata" , " m_angEyeAngles[0]" )
562
+ }
563
+ return isAttackSuccessful , closestPoint
556
564
else
557
- lastswingtracedata = nil
558
565
-- Target is not in range
559
566
return false , nil
560
567
end
561
568
end
562
569
570
+ local counter = 0
563
571
564
572
-- PostPropUpdate function to adjust player position and angle
565
573
local function PropUpdate ()
566
- if lastswingtracedata and not can_attack then
567
- local pWeapon = lastswingtracedata [1 ]
568
- local spherePos = lastswingtracedata [2 ]
569
- local closestPoint = lastswingtracedata [3 ]
570
- if spherePos and closestPoint then
571
- local Angle = Math .PositionAngles (spherePos , closestPoint )
572
-
573
- -- Adjust player position and view angles for swing trace
574
- pLocal :SetPropVector (spherePos , " tfnonlocaldata" , " m_vecOrigin" )
575
- pLocal :SetPropVector (Vector3 (Angle .x , Angle .y , Angle .z ), " tfnonlocaldata" , " m_angEyeAngles[0]" )
576
-
577
- -- Perform the swing trace
578
- local SwingTrace = pLocal .DoSwingTrace (pWeapon )
579
- swingresult = SwingTrace
580
-
581
- -- Reset the player's original position and view angles
582
- pLocal :SetPropVector (OriginalPosition , " tfnonlocaldata" , " m_vecOrigin" )
583
- pLocal :SetPropVector (OriginalAngles , " tfnonlocaldata" , " m_angEyeAngles[0]" )
584
-
585
- -- Clear last swing trace data
586
- lastswingtracedata = nil
574
+ counter = counter + 1
575
+ if counter % 2 == 0 and attackReady and Menu .Misc .advancedHitreg then
576
+ local angle = Math .PositionAngles (attackData .spherePos , attackData .closestPoint )
577
+
578
+ -- Adjust player position and view angles for swing trace
579
+ pLocal :SetPropVector (attackData .spherePos , " tfnonlocaldata" , " m_vecOrigin" )
580
+ pLocal :SetPropVector (Vector3 (angle .x , angle .y , angle .z ), " tfnonlocaldata" , " m_angEyeAngles[0]" )
581
+
582
+ -- Perform the swing trace
583
+ local swingTraceResult = pLocal .DoSwingTrace (attackData .pWeapon )
584
+
585
+ -- Check if the swing trace hit something
586
+ if swingTraceResult and swingTraceResult .fraction < 1 then
587
+ -- Attack hit
588
+ isAttackSuccessful = true
589
+ else
590
+ isAttackSuccessful = false -- Reset attack success flag
587
591
end
588
- end
589
- end
590
592
591
- callbacks .Unregister (" PostPropUpdate" , " swingcheck" ) -- Unregister the "CreateMove" callback
592
- callbacks .Register (" PostPropUpdate" ," swingcheck" , PropUpdate )
593
+ -- Reset the player's original position and view angles
594
+ pLocal :SetPropVector (attackData .originalPosition , " tfnonlocaldata" , " m_vecOrigin" )
595
+ pLocal :SetPropVector (attackData .originalAngles , " tfnonlocaldata" , " m_angEyeAngles[0]" )
593
596
597
+ -- Reset the flags and clear data
598
+ attackReady = false
599
+ attackData = {}
600
+ end
601
+ end
594
602
603
+ callbacks .Unregister (" PostPropUpdate" , " MyPostPropUpdate" )
604
+ callbacks .Register (" PostPropUpdate" , " MyPostPropUpdate" , PropUpdate )
595
605
596
606
597
607
local Hitbox = {
@@ -716,7 +726,7 @@ local function checkInRangeWithLatency(playerIndex, swingRange, pWeapon, cmd)
716
726
return inRange , point , can_charge
717
727
end
718
728
end
719
-
729
+
720
730
-- Adjust hitbox for current position
721
731
inRange , point = checkInRange (vPlayerOrigin , pLocalOrigin , swingRange - 18 , pWeapon , cmd )
722
732
if inRange then
@@ -860,7 +870,7 @@ local function OnCreateMove(pCmd)
860
870
pUsingMargetGarden = true
861
871
-- Set "pUsingProjectileWeapon" to true
862
872
end -- Set "pUsingProjectileWeapon" to false
863
-
873
+
864
874
-- [--Troldier assist--]
865
875
if Menu .Misc .TroldierAssist then
866
876
local state = " "
994
1004
local player = WPlayer .FromEntity (pLocal )
995
1005
996
1006
strafeAngle = Menu .Misc .strafePred and strafeAngles [pLocal :GetIndex ()] or 0
1007
+ if not Menu .Misc .advancedHitreg then
1008
+ swingrange = swingrange - math.abs (strafeAngle )
1009
+ end
997
1010
998
1011
local predData = PredictPlayer (player , time , strafeAngle )
999
1012
@@ -1006,6 +1019,7 @@ if CurrentTarget == nil then
1006
1019
vPlayerFuture = nil
1007
1020
return
1008
1021
end
1022
+
1009
1023
vPlayerOrigin = CurrentTarget :GetAbsOrigin () -- Get closest player origin
1010
1024
1011
1025
local VpFlags = CurrentTarget :GetPropInt (" m_fFlags" )
@@ -1043,7 +1057,7 @@ vdistance = (vPlayerOrigin - pLocalOrigin):Length()
1043
1057
-- Get distance between local player and closest player after swing
1044
1058
fDistance = (vPlayerFuture - pLocalFuture ):Length ()
1045
1059
local inRange = false
1046
- local inRangePoint = nil
1060
+ local inRangePoint = Vector3 ( 0 , 0 , 0 )
1047
1061
1048
1062
inRange , InRangePoint , can_charge = checkInRangeWithLatency (CurrentTarget :GetIndex (), swingrange , pWeapon , pCmd )
1049
1063
-- Use inRange to decide if can attack
@@ -1054,7 +1068,7 @@ vdistance = (vPlayerOrigin - pLocalOrigin):Length()
1054
1068
local hitbox = hitboxes [6 ]
1055
1069
local aimpos = nil
1056
1070
-- else
1057
- -- aimpos = CurrentTarget:GetAbsOrigin() + Vheight --aimpos = (hitbox[1] + hitbox[2]) * 0.5 --if no InRange point accesable then aim at defualt hitbox
1071
+ aimpos = CurrentTarget :GetAbsOrigin () + Vheight -- aimpos = (hitbox[1] + hitbox[2]) * 0.5 --if no InRange point accesable then aim at defualt hitbox
1058
1072
-- end
1059
1073
1060
1074
-- Inside your game loop
@@ -1086,7 +1100,7 @@ vdistance = (vPlayerOrigin - pLocalOrigin):Length()
1086
1100
-- Control charge if charge bot is enabled and the local player is in condition 17
1087
1101
ChargeControl (pCmd )
1088
1102
end
1089
-
1103
+
1090
1104
elseif Menu .Misc .ChargeControl and pLocal :InCond (17 ) then
1091
1105
-- Control charge if charge bot is enabled and the local player is in condition 17
1092
1106
ChargeControl (pCmd )
@@ -1095,32 +1109,21 @@ vdistance = (vPlayerOrigin - pLocalOrigin):Length()
1095
1109
-- Check if attack simulation was succesfull
1096
1110
if can_attack == true then
1097
1111
-- remove tick
1098
-
1099
- Gcan_attack = false
1100
- if Menu .Misc .InstantAttack == true and warp .GetChargedTicks () > 15 then
1101
- warp .TriggerDoubleTap ()
1102
- warp .TriggerWarp ()
1103
- end
1104
- pCmd :SetButtons (pCmd :GetButtons () | IN_ATTACK )-- attack
1105
-
1106
- elseif Menu .Misc .CritRefill then
1107
- if pWeapon :GetCritTokenBucket () <= 18 and fDistance > 350 then
1108
- pCmd :SetButtons (pCmd :GetButtons () | IN_ATTACK )-- refill
1109
- end
1110
- Gcan_attack = true
1111
- else
1112
-
1113
- Gcan_attack = true
1112
+ if Menu .Misc .InstantAttack == true and warp .GetChargedTicks () > 15 then
1113
+ warp .TriggerDoubleTap ()
1114
+ warp .TriggerWarp ()
1115
+ end
1116
+ pCmd :SetButtons (pCmd :GetButtons () | IN_ATTACK )-- attack
1117
+ can_attack = false
1114
1118
end
1115
1119
1116
1120
if can_charge then
1117
1121
pCmd :SetButtons (pCmd :GetButtons () | IN_ATTACK2 )-- charge
1122
+ can_charge = false
1118
1123
end
1119
1124
1120
1125
-- Update last variables
1121
-
1122
1126
Safe_Strafe = false -- reset safe strafe
1123
- can_charge = false
1124
1127
vHitbox [2 ].z = 82
1125
1128
:: continue::
1126
1129
end
@@ -1812,6 +1815,7 @@ if not (engine.Con_IsVisible() or engine.IsGameUIVisible()) and Menu.Visuals.Ena
1812
1815
1813
1816
ImMenu .BeginFrame (1 )
1814
1817
Menu .Misc .InstantAttack = ImMenu .Checkbox (" Instant Attack" , Menu .Misc .InstantAttack )
1818
+ Menu .Misc .advancedHitreg = ImMenu .Checkbox (" Advanced Hitreg" , Menu .Misc .advancedHitreg )
1815
1819
Menu .Misc .TroldierAssist = ImMenu .Checkbox (" Troldier Assist" , Menu .Misc .TroldierAssist )
1816
1820
ImMenu .EndFrame ()
1817
1821
0 commit comments