Originally Posted by Freebaser
You can drop the PostUpdate healAbsorbPercent and healAbsorbBar:SetPoint stuff. Use something like this when creating the bar.
Lua Code:
local healAbsorbBar = CreateFrame("StatusBar", nil, self.Health) healAbsorbBar:SetStatusBarTexture[[Interface\RaidFrame\Absorb-Fill]] healAbsorbBar:SetPoint("TOP") healAbsorbBar:SetPoint("BOTTOM") healAbsorbBar:SetPoint("LEFT", self.Health:GetStatusBarTexture(), "RIGHT", -(self.Health:GetWidth()), 0) healAbsorbBar:SetWidth(self.Health:GetWidth()) healAbsorbBar:SetReverseFill(true) healAbsorbBar:Hide()
|
Nice one, thank you.
It appears that local _, maxHealth = health:GetMinMaxValues() is not a save way to retrieve maxHealth as it returns 0 after /reloadui when I apply a heal absorb on me and then target myself. Subsequent targeting seems to return correct values. Wasn't able to reproduce this with UnitHealthMax(unit).
My code so far:
lua Code:
local PostUpdateHealPrediction = function(element, unit, overAbsorb, overHealAbsorb)
local health = element.__owner.Health
local maxHealth = UnitHealthMax(unit)
local myBar = element.myBar
local absorbBar = element.absorbBar
local healAbsorbBar = element.healAbsorbBar
local myCurrentHealAbsorb = UnitGetTotalHealAbsorbs(unit) or 0
local myCurrentHealAbsorbPercent = myCurrentHealAbsorb / maxHealth
if (absorbBar:GetValue() > 0) then
absorbBar:ClearAllPoints()
absorbBar:SetPoint("TOP")
absorbBar:SetPoint("BOTTOM")
if (healAbsorbBar:GetValue() > 0) then
absorbBar:SetPoint("LEFT", healAbsorbBar:GetStatusBarTexture(), "RIGHT", 0, 0)
else
absorbBar:SetPoint("LEFT", element.otherBar:GetStatusBarTexture(), "RIGHT", 0, 0)
end
end
if (overHealAbsorb) then
element.overHealAbsorbGlow:Show()
myBar:Hide() -- will this hide otherBar as well? Is hiding it the right way to go
else
element.overHealAbsorbGlow:Hide()
myBar:ClearAllPoints()
myBar:SetPoint("TOP")
myBar:SetPoint("BOTTOM")
myBar:SetPoint("LEFT", health:GetStatusBarTexture(), "RIGHT", -(230 * myCurrentHealAbsorbPercent), 0)
myBar:Show()
end
if (overAbsorb) then
element.overAbsorbGlow:Show()
else
element.overAbsorbGlow:Hide()
end
end
lua Code:
local AddHealPredictionBar = function(self, unit)
local health = self.Health
local hab = CreateFrame("StatusBar", nil, health)
hab:SetStatusBarTexture(ns.media.TEXTURE)
hab:SetStatusBarColor(0.75, 0.75, 0, 0.5)
hab:SetPoint("TOP")
hab:SetPoint("BOTTOM")
hab:SetPoint("LEFT", health:GetStatusBarTexture(), "RIGHT", -230, 0)
hab:SetWidth(230)
hab:SetReverseFill(true)
local mhpb = CreateFrame("StatusBar", nil, health)
mhpb:SetStatusBarTexture(ns.media.TEXTURE)
mhpb:SetStatusBarColor(0, 0.5, 0.5, 0.5)
mhpb:SetPoint("TOP")
mhpb:SetPoint("BOTTOM")
mhpb:SetPoint("LEFT", health:GetStatusBarTexture(), "RIGHT")
mhpb:SetWidth(230)
local ohpb = CreateFrame("StatusBar", nil, health)
ohpb:SetStatusBarTexture(ns.media.TEXTURE)
ohpb:SetStatusBarColor(0, 1, 0, 0.5)
ohpb:SetPoint("TOP")
ohpb:SetPoint("BOTTOM")
ohpb:SetPoint("LEFT", mhpb:GetStatusBarTexture(), "RIGHT")
ohpb:SetWidth(230)
local absorb = CreateFrame("StatusBar", nil, health)
absorb:SetStatusBarTexture(ns.media.TEXTURE)
absorb:SetStatusBarColor(1, 1, 1, 0.5)
absorb:SetPoint("TOP")
absorb:SetPoint("BOTTOM")
absorb:SetPoint("LEFT", ohpb:GetStatusBarTexture(), "RIGHT")
absorb:SetWidth(230)
local overAbsorb = health:CreateTexture(nil, "OVERLAY")
overAbsorb:SetTexture([[Interface\RaidFrame\Shield-Overshield]])
overAbsorb:SetBlendMode("ADD")
overAbsorb:SetPoint("TOP")
overAbsorb:SetPoint("BOTTOM")
overAbsorb:SetPoint("LEFT", health, "RIGHT", -7, 0)
overAbsorb:Hide()
local overHealAbsorb = health:CreateTexture(nil, "OVERLAY")
overHealAbsorb:SetTexture([[Interface\RaidFrame\Absorb-Overabsorb]])
overHealAbsorb:SetBlendMode("ADD")
overHealAbsorb:SetPoint("TOP")
overHealAbsorb:SetPoint("BOTTOM")
overHealAbsorb:SetPoint("RIGHT", health, "LEFT", 7, 0)
overHealAbsorb:Hide()
self.HealPrediction = {
healAbsorbBar = hab,
myBar = mhpb,
otherBar = ohpb,
absorbBar = absorb,
overAbsorbGlow = overAbsorb,
overHealAbsorbGlow = overHealAbsorb,
maxOverflow = unit == "target" and 1.25 or 1,
PostUpdate = PostUpdateHealPrediction
}
end
ns.AddHealPredictionBar = AddHealPredictionBar
@zork
I also have issues with 0 returns for GetWidth(), I'll open a new thread for it.