Skip to content

Commit 90f3100

Browse files
committed
Don't give negative XP for damaging units as they die.
Fixes #5650
1 parent 43c8ea0 commit 90f3100

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

LuaRules/Gadgets/unit_xp.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function gadget:UnitDamaged(unitID, unitDefID, unitTeam, damage, paralyzer, weap
6363

6464
local hp, maxHP = spGetUnitHealth(unitID)
6565

66-
local percentageDamage = ((hp > 0) and damage or (damage + hp)) / maxHP
66+
local percentageDamage = math.max(0, ((hp > 0) and damage or (damage + hp)) / maxHP) -- Units can be damaged further as they die.
6767
local targetCost = getCost(unitID, unitDefID) * (GG.att_CostMult[unitID] or 1)
6868
local attackerCost = getCost(attackerID, attackerDefID) * (GG.att_CostMult[attackerID] or 1)
6969
local oldXp = spGetUnitExperience(attackerID)

0 commit comments

Comments
 (0)