diff --git a/IceBarElement.lua b/IceBarElement.lua index 1c85e3b..aa81e9a 100644 --- a/IceBarElement.lua +++ b/IceBarElement.lua @@ -697,6 +697,10 @@ function IceBarElement.prototype:SetScale(texture, scale) self.CurrScale = IceHUD:Clamp(self:LerpScale(scale), 0, 1) + if not self.currScale or self.currScale == (1/0) or self.currScale == (0/0) then + self.currScale = 0 + end + if oldScale ~= self.CurrScale then if (self.moduleSettings.side == IceCore.Side.Left) then texture:SetTexCoord(1, 0, 1-self.CurrScale, 1) diff --git a/IceCastBar.lua b/IceCastBar.lua index bd5d770..b405e9a 100644 --- a/IceCastBar.lua +++ b/IceCastBar.lua @@ -135,10 +135,10 @@ function IceCastBar.prototype:OnUpdate() -- handle casting and channeling if (self.action == IceCastBar.Actions.Cast or self.action == IceCastBar.Actions.Channel) then local remainingTime = self.actionStartTime + self.actionDuration - time - local scale = 1 - (remainingTime / self.actionDuration) + local scale = 1 - (self.actionDuration > 0 and remainingTime / self.actionDuration or 0) if (self.action == IceCastBar.Actions.Channel) then - scale = remainingTime / self.actionDuration + scale = self.actionDuration > 0 and remainingTime / self.actionDuration or 0 end if (remainingTime < 0) then diff --git a/IceUnitBar.lua b/IceUnitBar.lua index 0fc1732..0369171 100644 --- a/IceUnitBar.lua +++ b/IceUnitBar.lua @@ -203,11 +203,11 @@ function IceUnitBar.prototype:Update() self.health = UnitHealth(self.unit) self.maxHealth = UnitHealthMax(self.unit) - self.healthPercentage = self.health/self.maxHealth + self.healthPercentage = self.maxHealth > 0 and (self.health/self.maxHealth) or 0 self.mana = UnitMana(self.unit) self.maxMana = UnitManaMax(self.unit) - self.manaPercentage = self.mana/self.maxMana + self.manaPercentage = self.maxMana > 0 and (self.mana/self.maxMana) or 0 _, self.unitClass = UnitClass(self.unit) diff --git a/modules/CustomBar.lua b/modules/CustomBar.lua index 47904d1..c4df3b6 100644 --- a/modules/CustomBar.lua +++ b/modules/CustomBar.lua @@ -278,7 +278,7 @@ function IceCustomBar.prototype:UpdateCustomBar(unit, fromUpdate) remaining = self.auraEndTime - now end - self:UpdateBar(remaining / self.auraDuration, "undef") + self:UpdateBar(self.auraDuration > 0 and remaining / self.auraDuration or 0, "undef") else self:UpdateBar(0, "undef") self:Show(false) diff --git a/modules/DruidMana.lua b/modules/DruidMana.lua index fedc0dd..ff128cd 100644 --- a/modules/DruidMana.lua +++ b/modules/DruidMana.lua @@ -59,7 +59,7 @@ function DruidMana.prototype:Update() self:Show(true) end - self:UpdateBar(self.druidMana / self.druidManaMax, "DruidMana") + self:UpdateBar(self.druidManaMax > 0 and self.druidMana / self.druidManaMax or 0, "DruidMana") end diff --git a/modules/FocusHealth.lua b/modules/FocusHealth.lua index 7f71da2..edc0ccf 100644 --- a/modules/FocusHealth.lua +++ b/modules/FocusHealth.lua @@ -368,7 +368,7 @@ function FocusHealth.prototype:Update(unit) self.color = "Tapped" end - self:UpdateBar(self.health/self.maxHealth, self.color) + self:UpdateBar(self.healthPercentage, self.color) if not IceHUD.IceCore:ShouldUseDogTags() then self:SetBottomText1(math.floor(self.healthPercentage * 100)) diff --git a/modules/FocusMana.lua b/modules/FocusMana.lua index fb17937..0c32857 100644 --- a/modules/FocusMana.lua +++ b/modules/FocusMana.lua @@ -83,7 +83,7 @@ function FocusMana.prototype:Update(unit) color = "Tapped" end - self:UpdateBar(self.mana/self.maxMana, color) + self:UpdateBar(self.manaPercentage, color) if not IceHUD.IceCore:ShouldUseDogTags() then self:SetBottomText1(math.floor(self.manaPercentage * 100)) diff --git a/modules/GlobalCoolDown.lua b/modules/GlobalCoolDown.lua index 43205f1..d6d82f7 100644 --- a/modules/GlobalCoolDown.lua +++ b/modules/GlobalCoolDown.lua @@ -161,7 +161,7 @@ function GlobalCoolDown.prototype:UpdateGlobalCoolDown() self:Show(false) else - self:UpdateBar(1 - (remaining / self.duration), "GlobalCoolDown", 0.8) + self:UpdateBar(1 - (self.duration > 0 and remaining / self.duration or 0), "GlobalCoolDown", 0.8) end else self:Show(false) diff --git a/modules/HungerForBlood.lua b/modules/HungerForBlood.lua index a9d8714..3105ac4 100644 --- a/modules/HungerForBlood.lua +++ b/modules/HungerForBlood.lua @@ -191,9 +191,9 @@ function HungerForBlood.prototype:UpdateHungerForBlood(unit, fromUpdate) remaining = hfbEndTime - now end if (hfbBuffCount ~= nil and hfbBuffCount > 2) then - self:UpdateBar(remaining / hfbDuration, "HungerForBloodMax") + self:UpdateBar(hfbDuration > 0 and remaining / hfbDuration or 0, "HungerForBloodMax") else - self:UpdateBar(remaining / hfbDuration, "HungerForBlood") + self:UpdateBar(hfbDuration > 0 and remaining / hfbDuration or 0, "HungerForBlood") end formatString = self.moduleSettings.upperText or '' diff --git a/modules/MirrorBar.lua b/modules/MirrorBar.lua index a6c8263..6c5f450 100644 --- a/modules/MirrorBar.lua +++ b/modules/MirrorBar.lua @@ -73,7 +73,7 @@ function MirrorBar.prototype:OnUpdate(elapsed) self.value = self.value + (self.timerScale * elapsed * 1000) - scale = self.value / self.maxValue + scale = self.maxValue > 0 and self.value / self.maxValue or 0 if (scale < 0) then -- lag compensation scale = 0 diff --git a/modules/PetHealth.lua b/modules/PetHealth.lua index 706dae0..66ffe15 100644 --- a/modules/PetHealth.lua +++ b/modules/PetHealth.lua @@ -110,7 +110,7 @@ function PetHealth.prototype:Update(unit) end if (self.maxHealth > 0) then - self:UpdateBar(self.health/self.maxHealth, color) + self:UpdateBar(self.healthPercentage, color) end if not IceHUD.IceCore:ShouldUseDogTags() then diff --git a/modules/PetMana.lua b/modules/PetMana.lua index 42f9d8a..77cc710 100644 --- a/modules/PetMana.lua +++ b/modules/PetMana.lua @@ -174,7 +174,7 @@ function PetMana.prototype:Update(unit) end if self.maxMana > 0 then - self:UpdateBar(self.mana/self.maxMana, color) + self:UpdateBar(self.manaPercentage, color) end if not IceHUD.IceCore:ShouldUseDogTags() then diff --git a/modules/PlayerHealth.lua b/modules/PlayerHealth.lua index 2fee53f..ceb9164 100644 --- a/modules/PlayerHealth.lua +++ b/modules/PlayerHealth.lua @@ -891,7 +891,7 @@ function PlayerHealth.prototype:Update(unit) textColor = "Text" end - self:UpdateBar(self.health/self.maxHealth, color) + self:UpdateBar(self.healthPercentage, color) -- sadly, animation uses bar-local variables so we can't use the animation for 2 bar textures on the same bar element if self.moduleSettings.showIncomingHeals and self.healFrame and self.healFrame.bar and incomingHealAmt then diff --git a/modules/SliceAndDice.lua b/modules/SliceAndDice.lua index d1b9842..ec6ea8b 100644 --- a/modules/SliceAndDice.lua +++ b/modules/SliceAndDice.lua @@ -225,7 +225,8 @@ function SliceAndDice.prototype:UpdateSliceAndDice(unit, fromUpdate) if not remaining then remaining = sndEndTime - now end - self:UpdateBar(remaining / (self.moduleSettings.showAsPercentOfMax and CurrMaxSnDDuration or sndDuration), "SliceAndDice") + local denominator = (self.moduleSettings.showAsPercentOfMax and CurrMaxSnDDuration or sndDuration) + self:UpdateBar(denominator > 0 and remaining / denominator or 0, "SliceAndDice") formatString = self.moduleSettings.upperText or '' else diff --git a/modules/TargetCC.lua b/modules/TargetCC.lua index 2a18c6a..1f40567 100644 --- a/modules/TargetCC.lua +++ b/modules/TargetCC.lua @@ -293,8 +293,8 @@ function TargetCC.prototype:UpdateTargetDebuffs(unit, isUpdate) if (name ~= nil) then self:Show(true) - if (duration ~= nil) then - self:UpdateBar(remaining / duration, "CC:" .. self.debuffList[name]) + if (duration ~= nil and duration > 0) then + self:UpdateBar(duration > 0 and remaining / duration or 0, "CC:" .. self.debuffList[name]) self:SetBottomText2(floor(remaining * 10) / 10) else self:UpdateBar(0, "CC:" .. self.debuffList[name]) diff --git a/modules/TargetHealth.lua b/modules/TargetHealth.lua index 5c2e180..a02bf2c 100644 --- a/modules/TargetHealth.lua +++ b/modules/TargetHealth.lua @@ -678,7 +678,7 @@ function IceTargetHealth.prototype:Update(unit) end end - self:UpdateBar(self.health/self.maxHealth, self.color) + self:UpdateBar(self.healthPercentage, self.color) if not IceHUD.IceCore:ShouldUseDogTags() then self:SetBottomText1(math.floor(self.healthPercentage * 100))