Thread Tools Display Modes
08-11-14, 07:46 AM   #1
sticklord
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 57
oUF Absorb bar

Hello!

I've got a problem with oUF that i just can't get my head around. Basically its a absorb bar that goes from 0-100% of a units hp, anchored to the health. It's mostly working fine, but if the unit have an absorb on itself when the unitframe is first viewed after a login, it maxes out. If i have opened the unitframe before they get an absorb however, it works fine.

Creating the bars:
Lua Code:
  1. -- Absorb bar
  2. local TotalAbsorb = CreateFrame('StatusBar', nil, self.Health)
  3. TotalAbsorb:SetStatusBarTexture(config.absorbtexture, "OVERLAY")
  4. TotalAbsorb:SetFrameLevel(self:GetFrameLevel() - 1)
  5. TotalAbsorb:SetStatusBarColor(1,1,1,1)
  6. TotalAbsorb:SetAllPoints(self.Health)
  7. TotalAbsorb:Hide()
  8.  
  9. local spark = TotalAbsorb:CreateTexture(nil, 'ARTWORK', "OverAbsorbGlowTemplate")
  10. spark:SetSize(20,5)
  11. spark:Hide()
  12. TotalAbsorb.spark = spark
  13.  
  14. -- Incoming Heals
  15. local incHeals = ns.CreateStatusBar(self.Health)
  16. incHeals:SetPoint('TOPLEFT', self.Health:GetStatusBarTexture(), 'TOPRIGHT')
  17. incHeals:SetPoint('BOTTOMRIGHT')
  18. incHeals:SetFrameLevel(self:GetFrameLevel() - 1)
  19. incHeals:SetStatusBarColor(0, 1, 0, 0.5)
  20. incHeals:SetFrameStrata('MEDIUM')
  21. incHeals:Hide()
  22.  
  23. -- Absorbing Heals
  24. local necroHeals = ns.CreateStatusBar(self.Health, 'OVERLAY')
  25. necroHeals:SetFrameLevel(self:GetFrameLevel() - 1)
  26. necroHeals:SetStatusBarColor(1, 0, 0, 0.3)
  27. necroHeals:SetReverseFill(true)
  28. necroHeals:SetPoint('TOPLEFT')
  29. necroHeals:SetPoint('BOTTOMRIGHT', self.Health:GetStatusBarTexture(), 'BOTTOMRIGHT')
  30.  
  31. self.HealPrediction = {
  32.     incHeals = incHeals,
  33.     necroHeals = necroHeals,
  34.     TotalAbsorb = TotalAbsorb,
  35.     Override = ns.UpdateIncHeals,
  36. }

And the update function:
Lua Code:
  1. function ns.UpdateIncHeals(self, event, unit)
  2.     if (self.unit ~= unit) then return end
  3.     local hp = self.HealPrediction
  4.     local curHP, _, maxHP = self.Health:GetValue(), self.Health:GetMinMaxValues()
  5.     local incHeal = UnitGetIncomingHeals(unit) or 0
  6.     local healAbsorb = UnitGetTotalHealAbsorbs(unit) or 0
  7.  
  8.     if ( healAbsorb > 0) then
  9.         hp.necroHeals:SetMinMaxValues(0, curHP)
  10.         hp.necroHeals:SetValue(math.min(healAbsorb, curHP))
  11.         hp.necroHeals:Show()
  12.     else
  13.         hp.necroHeals:Hide()
  14.     end
  15.  
  16.     if ((incHeal - healAbsorb) <= 0) or (curHP == maxHP) then
  17.         hp.incHeals:Hide()
  18.     else
  19.         hp.incHeals:SetMinMaxValues(0, maxHP - curHP)
  20.         hp.incHeals:SetValue(incHeal - healAbsorb)
  21.         hp.incHeals:Show()
  22.     end
  23.  
  24.     if (hp.TotalAbsorb) then
  25.         local absorb = UnitGetTotalAbsorbs(unit) or 0
  26.         if (absorb == 0) then
  27.             hp.TotalAbsorb.spark:Hide()
  28.             hp.TotalAbsorb:Hide()
  29.         else
  30.             hp.TotalAbsorb:SetMinMaxValues(0, maxHP)
  31.             hp.TotalAbsorb:SetValue(math.min(absorb, maxHP))
  32.             hp.TotalAbsorb:Show()
  33.             hp.TotalAbsorb.spark:ClearAllPoints()
  34.             hp.TotalAbsorb.spark:SetPoint('BOTTOM', hp.TotalAbsorb:GetStatusBarTexture(),'BOTTOMRIGHT', 0, -1)
  35.             hp.TotalAbsorb.spark:Show()
  36.         end
  37.         print(unit, self.unit, absorb,"VALUE:",math.min(absorb, maxHP),"MAXHP", maxHP,"POINTS",hp.TotalAbsorb:GetPoint())
  38.     end
  39. end
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » oUF Absorb bar

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off