Skip to content

Commit 43c8ea0

Browse files
committed
Apparently being transport also counts as being stunned.
1 parent c272fa5 commit 43c8ea0

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

LuaRules/Utilities/unitStates.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
local REVERSE_COMPAT = not Script.IsEngineMinVersion(104, 0, 1120)
22

3+
local spGetUnitHealth = Spring.GetUnitHealth
34
local speedCache = {}
45

56
function Spring.Utilities.GetUnitRepeat(unitID)
@@ -52,6 +53,11 @@ function Spring.Utilities.GetUnitTrajectoryState(unitID)
5253
return trajectory
5354
end
5455

56+
function Spring.Utilities.GetIsUnitEmped(unitID)
57+
local _, maxHealth, paralyzeDamage = spGetUnitHealth(unitID)
58+
return ((paralyzeDamage or 0) / (((maxHealth or 0) > 0.1) and maxHealth or 1)) > 1
59+
end
60+
5561
function Spring.Utilities.EstimateCurrentMaxSpeed(unitID, unitDefID)
5662
unitDefID = unitDefID or Spring.GetUnitDefID(unitID)
5763
local _, stunned, inbuild = Spring.GetUnitIsStunned(unitID)

LuaUI/Widgets/gfx_paralyze_effect.lua

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ end
1616

1717
-- Localized Spring API for performance
1818
local spGetUnitDefID = Spring.GetUnitDefID
19-
local spGetUnitIsStunned = Spring.GetUnitIsStunned
19+
local utGetIsUnitEmped = Spring.Utilities.GetIsUnitEmped
2020
local spGetGameFrame = Spring.GetGameFrame
2121
local spGetUnitRulesParam = Spring.GetUnitRulesParam
2222

@@ -580,8 +580,7 @@ function widget:GameFrame(n)
580580
if n % UPDATE_RATE == 0 then
581581
for unitID, index in pairs(paralyzedDrawUnitVBOTable.instanceIDtoIndex) do
582582
if Spring.ValidUnitID(unitID) then
583-
local _, stunned = spGetUnitIsStunned(unitID)
584-
local para = stunned and 1
583+
local para = utGetIsUnitEmped(unitID) and 1
585584
local disarmed = (spGetUnitRulesParam(unitID, "disarmed") == 1) and 1
586585
local slow = spGetUnitRulesParam(unitID, "slowState")
587586
local fire = (spGetUnitRulesParam(unitID, "on_fire") == 1)
@@ -654,7 +653,7 @@ function widget:UnitCreated(unitID, unitDefID)
654653
if not uniformSet[unitID] then
655654
gl.SetUnitBufferUniforms(unitID, uniformcache, 4)
656655
end
657-
local _, stunned = spGetUnitIsStunned(unitID)
656+
local stunned = utGetIsUnitEmped(unitID)
658657
local disarmed = spGetUnitRulesParam(unitID, "disarmed")
659658
local slow = spGetUnitRulesParam(unitID, "slowState")
660659
local fire = (spGetUnitRulesParam(unitID, "on_fire") == 1)

0 commit comments

Comments
 (0)