Skip to content

Commit 2572457

Browse files
increased iq of code used
1 parent c82633a commit 2572457

File tree

1 file changed

+62
-51
lines changed

1 file changed

+62
-51
lines changed

A_Swing_Prediction.lua

Lines changed: 62 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -665,46 +665,7 @@ end
665665

666666
-- Function to get the best target
667667
-- Function to calculate the appropriate swing range based on current situation
668-
local function CalculateEffectiveSwingRange()
669-
local baseRange = swingrange + (SwingHullSize / 2)
670668

671-
-- Check if charge reach is available
672-
local hasFullCharge = chargeLeft == 100
673-
local isDemoman = pLocalClass == 4
674-
local isExploitReady = Menu.Misc.ChargeReach and hasFullCharge and isDemoman
675-
local withinAttackWindow = (globals.TickCount() - lastAttackTick) <= 13
676-
local isCurrentlyCharging = pLocal and pLocal:InCond(17)
677-
678-
if isCurrentlyCharging then
679-
-- When charging: check if we swung within last 13 ticks for exploit
680-
local isDoingExploit = Menu.Misc.ChargeReach and withinAttackWindow
681-
if isDoingExploit then
682-
return Charge_Range + (SwingHullSize / 2)
683-
else
684-
return normalTotalSwingRange
685-
end
686-
else
687-
-- Not charging: determine if we should show charge reach or normal range
688-
if isExploitReady and CurrentTarget then
689-
local currentDistance = (CurrentTarget:GetAbsOrigin() - pLocalOrigin):Length()
690-
local normalRange = normalTotalSwingRange
691-
692-
-- Show charge reach range if target is beyond normal range
693-
if currentDistance > normalRange then
694-
local chargeReachRange = Charge_Range + (SwingHullSize / 2)
695-
if currentDistance <= chargeReachRange then
696-
return chargeReachRange
697-
end
698-
end
699-
elseif isExploitReady and not CurrentTarget then
700-
-- No target but charge reach is ready - show charge reach range as potential
701-
return Charge_Range + (SwingHullSize / 2)
702-
end
703-
704-
-- Default to normal range
705-
return baseRange
706-
end
707-
end
708669

709670
local function GetBestTarget(me)
710671
local localPlayer = entities.GetLocalPlayer()
@@ -994,30 +955,60 @@ local function UpdateHomingMissile()
994955
end
995956

996957
local hasNotified = false
997-
local function checkInRangeSimple(playerIndex, swingRange, pWeapon, cmd)
958+
local function checkInRangeSimple(playerIndex, pWeapon, cmd)
998959
local inRange = false
999960
local point = nil
961+
local usedChargeReach = false
962+
963+
-- Always start with normal weapon range
964+
local normalRange = normalTotalSwingRange
1000965

1001-
-- Simple range check with current positions
1002-
inRange, point = checkInRange(vPlayerOrigin, pLocalOrigin, swingRange)
966+
-- First check: Can we hit with normal range? (current positions)
967+
inRange, point = checkInRange(vPlayerOrigin, pLocalOrigin, normalRange)
1003968
if inRange then
1004-
return inRange, point, false
969+
return inRange, point, false -- Hit with normal range, no charge reach used
1005970
end
1006971

1007972
-- If instant attack (warp) is ready, skip future prediction checks.
1008973
local instantAttackReady = Menu.Misc.InstantAttack and warp.CanWarp() and
1009974
warp.GetChargedTicks() >= Menu.Aimbot.SwingTime
1010975
if instantAttackReady then
976+
-- For instant attack, we only need to check current positions, not future
977+
-- Check if charge reach can help
978+
local hasFullCharge = chargeLeft == 100
979+
local isDemoman = pLocalClass == 4
980+
local isChargeReachReady = Menu.Misc.ChargeReach and hasFullCharge and isDemoman
981+
982+
if isChargeReachReady then
983+
local chargeReachRange = Charge_Range + (SwingHullSize / 2)
984+
inRange, point = checkInRange(vPlayerOrigin, pLocalOrigin, chargeReachRange)
985+
if inRange then
986+
return inRange, point, true -- Hit with charge reach
987+
end
988+
end
1011989
return false, nil, false
1012990
end
1013991

1014-
-- Simple range check with predicted positions
1015-
inRange, point = checkInRange(vPlayerFuture, pLocalFuture, swingRange)
992+
-- Second check: Can we hit with normal range? (predicted positions)
993+
inRange, point = checkInRange(vPlayerFuture, pLocalFuture, normalRange)
1016994
if inRange then
1017-
return inRange, point, false
995+
return inRange, point, false -- Hit with normal range, no charge reach used
996+
end
997+
998+
-- Third check: Can we hit with charge reach? (only if normal range failed)
999+
local hasFullCharge = chargeLeft == 100
1000+
local isDemoman = pLocalClass == 4
1001+
local isChargeReachReady = Menu.Misc.ChargeReach and hasFullCharge and isDemoman
1002+
1003+
if isChargeReachReady then
1004+
local chargeReachRange = Charge_Range + (SwingHullSize / 2)
1005+
inRange, point = checkInRange(vPlayerFuture, pLocalFuture, chargeReachRange)
1006+
if inRange then
1007+
return inRange, point, true -- Hit with charge reach
1008+
end
10181009
end
10191010

1020-
return false, nil, false
1011+
return false, nil, false -- Cannot hit at all
10211012
end
10221013

10231014
-- Store the original Crit Hack Key value outside the main loop or function
@@ -1175,8 +1166,7 @@ local function OnCreateMove(pCmd)
11751166
vPlayer = nil
11761167
end
11771168

1178-
-- Calculate swing range after getting target
1179-
TotalSwingRange = CalculateEffectiveSwingRange()
1169+
11801170

11811171
---------------critHack------------------
11821172
-- Main logic
@@ -1350,11 +1340,32 @@ local function OnCreateMove(pCmd)
13501340
local inRange = false
13511341
local inRangePoint = Vector3(0, 0, 0)
13521342

1353-
-- Use TotalSwingRange for range checking (already calculated with charge reach logic)
1354-
inRange, InRangePoint, can_charge = checkInRangeSimple(CurrentTarget:GetIndex(), TotalSwingRange, pWeapon, pCmd)
1343+
-- Check if we can hit the target (tries normal range first, then charge reach)
1344+
local usedChargeReach = false
1345+
inRange, InRangePoint, usedChargeReach = checkInRangeSimple(CurrentTarget:GetIndex(), pWeapon, pCmd)
13551346
-- Use inRange to decide if can attack
13561347
can_attack = inRange
13571348

1349+
-- Update TotalSwingRange to reflect what was actually used for visuals
1350+
if inRange then
1351+
if usedChargeReach then
1352+
TotalSwingRange = Charge_Range + (SwingHullSize / 2)
1353+
else
1354+
TotalSwingRange = normalTotalSwingRange
1355+
end
1356+
else
1357+
-- No target in range, show potential range
1358+
local hasFullCharge = chargeLeft == 100
1359+
local isDemoman = pLocalClass == 4
1360+
local isChargeReachReady = Menu.Misc.ChargeReach and hasFullCharge and isDemoman
1361+
1362+
if isChargeReachReady then
1363+
TotalSwingRange = Charge_Range + (SwingHullSize / 2)
1364+
else
1365+
TotalSwingRange = normalTotalSwingRange
1366+
end
1367+
end
1368+
13581369
--[--------------AimBot-------------------]
13591370
local aimpos = CurrentTarget:GetAbsOrigin() + Vheight
13601371

0 commit comments

Comments
 (0)