Skip to content

Commit 25fb281

Browse files
fixed charge reach
1 parent af97206 commit 25fb281

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

A_Swing_Prediction.lua

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ local stepSize = 18
262262
local attackStarted = false
263263
local attackTickCount = 0
264264
local lastChargeTime = 0
265+
local chargeAimAngles = nil -- yaw/pitch to look at when triggering charge reach exploit
265266

266267
-- Track the tick index of the last +attack press (user or script)
267268
local lastAttackTick = -1000 -- initialize far in the past
@@ -1515,6 +1516,12 @@ local function OnCreateMove(pCmd)
15151516
if pLocalClass == 4 and Menu.Misc.ChargeReach and chargeLeft == 100 and not attackStarted then
15161517
attackStarted = true
15171518
attackTickCount = 0
1519+
-- Store aim direction to target future position so charge travels correctly
1520+
if InRangePoint then
1521+
chargeAimAngles = Math.PositionAngles(pLocalOrigin, InRangePoint)
1522+
else
1523+
chargeAimAngles = Math.PositionAngles(pLocalOrigin, vPlayerFuture)
1524+
end
15181525
end
15191526

15201527
can_attack = false
@@ -1533,12 +1540,20 @@ local function OnCreateMove(pCmd)
15331540
-- Execute charge exactly at the end of the swing animation (1 tick before the hit registers)
15341541
if attackTickCount >= (weaponSmackDelay - 2) then
15351542
--client.ChatPrintf("[Debug] Executing charge at end of swing, tick: " .. attackTickCount)
1543+
-- Ensure we are facing stored aim direction before initiating charge
1544+
if chargeAimAngles then
1545+
-- Apply instantly so movement vector aligns with shield charge
1546+
engine.SetViewAngles(EulerAngles(chargeAimAngles.pitch, chargeAimAngles.yaw, 0))
1547+
pCmd:SetViewAngles(chargeAimAngles.pitch, chargeAimAngles.yaw, 0)
1548+
end
1549+
15361550
pCmd:SetButtons(pCmd:GetButtons() | IN_ATTACK2) -- charge
15371551

15381552
-- Reset attack tracking
15391553
attackStarted = false
15401554
attackTickCount = 0
15411555
can_charge = false
1556+
chargeAimAngles = nil
15421557
end
15431558
end
15441559

0 commit comments

Comments
 (0)