Skip to content

Commit

Permalink
Shield tracker prefers displaying Lightning/Water Shield over Earth S…
Browse files Browse the repository at this point in the history
…hield if both are active
  • Loading branch information
Xianghar committed Jul 11, 2024
1 parent e34ff9f commit 1daf40a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 34 deletions.
74 changes: 41 additions & 33 deletions Shield.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,12 @@ for k,v in pairs(TotemTimers.ShieldSpells) do
ShieldSpellNames[SpellNames[v]] = true
end

local EarthShieldName = nil
if WOW_PROJECT_ID > WOW_PROJECT_CLASSIC then
EarthShieldName = SpellNames[SpellIDs.EarthShield]
local EarthShieldName = SpellNames[SpellIDs.EarthShield]
local LightningShieldName = SpellNames[SpellIDs.LightningShield]
local WaterShieldName = SpellNames[SpellIDs.WaterShield]

local function ShieldPredicate(_, _, _, auraName)
return auraName == LightningShieldName or auraName == WaterShieldName
end

function TotemTimers.ShieldEvent(self, event, unit)
Expand All @@ -75,41 +78,46 @@ function TotemTimers.ShieldEvent(self, event, unit)
self.count:SetText("")
local name, texture, count, duration, endtime
local hasBuff = false
for i = 1, 40 do
name, texture, count, _, duration, endtime = UnitBuff("player", i)
if not name then break end
if ShieldSpellNames[name] and (name ~= EarthShieldName or TotemTimers.ActiveProfile.EarthShieldOnSelf) then
hasBuff = true
local timeleft = endtime - GetTime()
if name ~= self.shield
or (not ShieldChargesOnly and timeleft > self.timer.timers[1])
or ShieldChargesOnly
then
self.icons[1]:SetTexture(texture)
self.timer.expirationMsgs[1] = "Shield"
self.timer.earlyExpirationMsgs[1] = "Shield"
self.timer.warningIcons[1] = texture
self.timer.warningSpells[1] = name
self.shield = name
if not ShieldChargesOnly then
self.timer.warningPoint = 10
self.timer:Start(1, timeleft, duration)
else
self.timer.warningPoint = 0
self.timer:Start(1, count, 3)
end
end

name, texture, count, _, duration, endtime = AuraUtil.FindAura(ShieldPredicate, "player", "HELPFUL")
if not name and TotemTimers.ActiveProfile.EarthShieldOnSelf then
name, texture, count, _, duration, endtime = AuraUtil.FindAuraByName(EarthShieldName, "player", "HELPFUL")
end

if name then
hasBuff = true
local timeleft = endtime - GetTime()
if name == EarthShieldName and self.name ~= EarthShieldName then
self.timer:Stop(1)
end
if name ~= self.shield
or (not ShieldChargesOnly and timeleft > self.timer.timers[1])
or ShieldChargesOnly
then
self.icons[1]:SetTexture(texture)
self.timer.expirationMsgs[1] = "Shield"
self.timer.earlyExpirationMsgs[1] = "Shield"
self.timer.warningIcons[1] = texture
self.timer.warningSpells[1] = name
self.shield = name
if not ShieldChargesOnly then
if count and count > 0 then
self.count:SetText(count)
else
self.count:SetText("")
end
self.timer.warningPoint = 10
self.timer:Start(1, timeleft, duration)
else
self.timer.warningPoint = 0
self.timer:Start(1, count, 3)
end
end
if not ShieldChargesOnly then
if count and count > 0 then
self.count:SetText(count)
else
self.count:SetText("")
end
break
end
end
if not hasBuff and self.timer.timers[1] > 0 then
self.shield = nil
self.timer:Stop(1)
end
end
Expand Down
2 changes: 1 addition & 1 deletion TotemTimers_Vanilla.toc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Interface: 11502
## Interface: 11503
## Title: TotemTimers
## Author: Xianghar
## Version: @project-version@
Expand Down
2 changes: 2 additions & 0 deletions changes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
4.0.4
- Shield tracker prefers displaying Lightning/Water Shield over Earth Shield if both are active
4.0.3
- Fix weapon tracker loading default spell on login
- Fix default totems loading on login in SOD
Expand Down

0 comments on commit 1daf40a

Please sign in to comment.