Skip to content

Commit ff842db

Browse files
committed
Disarm during jump windup cancels the jump (rather than permastunning).
Fixes #5675
1 parent 556c426 commit ff842db

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

LuaRules/Gadgets/unit_jumpjets.lua

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ local CMD_MOVE = CMD.MOVE
3838
local CMD_REMOVE = CMD.REMOVE
3939
local privateTable = {private = true}
4040
local sightTable = {inlos = true}
41+
local DISARM_CANCEL_FACTOR = 2
4142

4243
local spGetHeadingFromVector = Spring.GetHeadingFromVector
4344
local spGetUnitPosition = Spring.GetUnitPosition
@@ -413,13 +414,18 @@ local function Jump(unitID, goal, origCmdParams, mustJump)
413414
end
414415

415416
if delay > 0 then
417+
local timeoutFrames = delay*DISARM_CANCEL_FACTOR
416418
while delay > 0 do
417419
local stunned = Spring.GetUnitIsStunned(unitID)
418420
if not stunned then
419-
delay = delay - (GG.att_ReloadChange[unitID] or 1) -- Disarm or slow
421+
local speedMult = (GG.att_ReloadChange[unitID] or 1) -- Disarm or slow
422+
delay = delay - speedMult
423+
if speedMult == 0 then
424+
timeoutFrames = timeoutFrames - 1
425+
end
420426
end
421427
local attachedTransport = Spring.GetUnitTransporter(unitID)
422-
if attachedTransport then
428+
if attachedTransport or timeoutFrames <= 0 then
423429
FinishJump(unitID)
424430
-- Transport cancels jump
425431
CallAsUnitIfExists(unitID, env.cancelJump)
@@ -433,7 +439,7 @@ local function Jump(unitID, goal, origCmdParams, mustJump)
433439
end
434440

435441
CallAsUnitIfExists(unitID,env.beginJump)
436-
if PLAY_SOUND and (not cannotJumpMidair) then -- don't make sound if we jump with legs instead of jets
442+
if PLAY_SOUND and (not cannotJumpMidair) then -- don't make sound if we jump with legs instead of jets
437443
GG.PlayFogHiddenSound("Jump", UnitDefs[unitDefID].mass/10, start[1], start[2], start[3])
438444
end
439445
if rotateMidAir then

0 commit comments

Comments
 (0)