Skip to content

Commit

Permalink
[Bugfix] Fix Shield Bar going beyond Health Bar
Browse files Browse the repository at this point in the history
  • Loading branch information
Krealle committed Sep 23, 2024
1 parent 9c47ab0 commit 6cafe87
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Widgets/Bars/ShieldBar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ end
local function Enable(self)
self._owner:AddEventListener("UNIT_ABSORB_AMOUNT_CHANGED", Update)
self._owner:AddEventListener("UNIT_MAXHEALTH", Update)
self._owner:AddEventListener("UNIT_HEALTH", Update)

self.Update(self._owner)

Expand All @@ -104,6 +105,7 @@ end
local function Disable(self)
self._owner:RemoveEventListener("UNIT_ABSORB_AMOUNT_CHANGED", Update)
self._owner:RemoveEventListener("UNIT_MAXHEALTH", Update)
self._owner:RemoveEventListener("UNIT_HEALTH", Update)
end

-------------------------------------------------
Expand All @@ -119,20 +121,19 @@ local function ShieldBar_SetValue(bar, percent)
local barWidth = maxWidth * percent

if bar.currentPoint == "healthBar" then
local maxLossWidth = bar.parentHealthBarLoss:GetWidth()
local ratio = maxLossWidth / maxWidth
local ratio = 1 - bar._owner.states.healthPercent

if percent > ratio then
if bar.reverseFill then
bar:Repoint("RIGHT")
else
barWidth = maxLossWidth
barWidth = maxWidth * ratio
end
elseif bar.reverseFill then
bar:Repoint()
end

if bar.showOverShield and maxLossWidth == 0 then
if bar.showOverShield and ratio == 0 then
bar.overShieldGlow:Show()
end
end
Expand Down

0 comments on commit 6cafe87

Please sign in to comment.