Thread Tools Display Modes
10-08-13, 03:24 PM   #1
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
HealPrediction

How are we supposed to implement the oUF's in-house healprediction element in a layout? My problem is how to position the status bars as obviously the example implementation in the comment in the element itself would simply overlap them if I anchor all of them to self.Health:GetTexture(). In Blizzard's heal prediction implementation the absorb bar is anchored either to the healAbsorb or the otherIncomingHeal, based on whether allIncomingHeal is bigger than the current heal absorb. The oUF's element does not support dynamic anchoring.

Aprat from that, Blizzard's heal prediction seems a bit strange (just from looking at the code, can't test this in-game). They seem to not reduce the amount of incoming heals by the amount of heal absorb (apart from when it would overflow the health bar) and always show the incoming heals even if the heal absorb is greater than them. They do reduce the heal absorb by the amount of incoming heals though and it seems they would display both heal absorb and inc heals overlapped (both textures are anchored to the health statusbar texture). Is this correct?
  Reply With Quote
10-08-13, 03:26 PM   #2
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
This is what I'm doing:
Lua Code:
  1. --heal prediction
  2.   func.healPrediction = function(self)
  3.     if not self.cfg.healprediction or (self.cfg.healprediction and not self.cfg.healprediction.show) then return end
  4.     local w = self.Health:GetWidth()
  5.     if w == 0 then
  6.       w = self:GetWidth()-24.5-24.5 --raids and party have no width on the health frame for whatever reason, thus use self and subtract the setpoint values
  7.     end
  8.     -- my heals
  9.     local mhpb = CreateFrame("StatusBar", nil, self.Health)
  10.     mhpb:SetFrameLevel(self.Health:GetFrameLevel())
  11.     mhpb:SetPoint("TOPLEFT", self.Health:GetStatusBarTexture(), "TOPRIGHT", 0, 0)
  12.     mhpb:SetPoint("BOTTOMLEFT", self.Health:GetStatusBarTexture(), "BOTTOMRIGHT", 0, 0)
  13.     mhpb:SetWidth(w)
  14.     mhpb:SetStatusBarTexture(self.cfg.healprediction.texture)
  15.     mhpb:SetStatusBarColor(self.cfg.healprediction.color.myself.r,self.cfg.healprediction.color.myself.g,self.cfg.healprediction.color.myself.b,self.cfg.healprediction.color.myself.a)
  16.     -- other heals
  17.     local ohpb = CreateFrame("StatusBar", nil, self.Health)
  18.     ohpb:SetFrameLevel(self.Health:GetFrameLevel())
  19.     ohpb:SetPoint("TOPLEFT", mhpb:GetStatusBarTexture(), "TOPRIGHT", 0, 0)
  20.     ohpb:SetPoint("BOTTOMLEFT", mhpb:GetStatusBarTexture(), "BOTTOMRIGHT", 0, 0)
  21.     ohpb:SetWidth(w)
  22.     ohpb:SetStatusBarTexture(self.cfg.healprediction.texture)
  23.     ohpb:SetStatusBarColor(self.cfg.healprediction.color.other.r,self.cfg.healprediction.color.other.g,self.cfg.healprediction.color.other.b,self.cfg.healprediction.color.other.a)
  24.     -- Register it with oUF
  25.     self.HealPrediction = {
  26.       myBar = mhpb,
  27.       otherBar = ohpb,
  28.       maxOverflow = self.cfg.healprediction.maxoverflow,
  29.     }
  30.   end
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
10-08-13, 04:22 PM   #3
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
You are not using the healAbsorbBar. The element got updated for 5.4. You also don't need to explicitly set the frame level to that of the health bar as long as it is your bars' parent.

Apart from that, my current implementation is exactly like yours. I just get some strange positioning and can't track it down. I would also like to mimic blizzard's functionality as close as possible, that's why I wonder how they handle the overlapped bars (if I read their code right) and how to anchor the bars dynamically. I could do the latter in PostUpdate with a lot of code repeating from the element's update function, which would be a waste and is a limitation of the element I think, unless I oversee something. So I would like to know how the blizzard implementation behaves and based on that either make my own oUF element for it or use the default one.
  Reply With Quote
10-08-13, 05:40 PM   #4
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
Just found an easy way to see the whole thing in action: Glyph of Life Tap for heal absorb, Overgrown Lilypad for incoming heal and Sacrificial Pact for shield. I'll probably set for creating my own element, based on blizzard's code.
  Reply With Quote
10-08-13, 09:27 PM   #5
Freebaser
A Molten Kobold Bandit
 
Freebaser's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 135
This is where you can use PostUpdate, instead of an override function or writing a separate element.

Lua Code:
  1. local function HealPostUpdate = function(hp, unit)
  2.  
  3.     if(hp.absorbBar:GetValue() > 0) then
  4.         hp.absorbBar:ClearAllPoints()
  5.         hp.absorbBar:SetPoint('TOP')
  6.         hp.absorbBar:SetPoint('BOTTOM')
  7.  
  8.         if(hp.healAbsorbBar:GetValue() > 0) then
  9.             hp.absorbBar:SetPoint('LEFT', hp.healAbsorbBar:GetStatusBarTexture(), 'RIGHT')
  10.         else
  11.             hp.absorbBar:SetPoint('LEFT', hp.otherBar:GetStatusBarTexture(), 'RIGHT')
  12.         end
  13.     end
  14. end

Lua Code:
  1. ...
  2.  
  3. self.HealPrediction.PostUpdate = HealPostUpdate
  Reply With Quote
10-09-13, 02:09 AM   #6
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
@Rainrider
I have my own absorbbar module. That's why.

Module
http://code.google.com/p/rothui/sour...otalAbsorb.lua

Create Function
Lua Code:
  1. --total absorb
  2.   func.totalAbsorb = function(self)
  3.     if not self.cfg.totalabsorb or (self.cfg.totalabsorb and not self.cfg.totalabsorb.show) then return end
  4.     local w = self.Health:GetWidth()
  5.     if w == 0 then
  6.       w = self:GetWidth()-24.5-24.5 --raids and party have no width on the health frame for whatever reason, thus use self and subtract the setpoint values
  7.     end
  8.     local absorbBar = CreateFrame("StatusBar", nil, self.Health)
  9.     --new anchorpoint, absorb will now overlay the healthbar from right to left
  10.     absorbBar:SetFrameLevel(self.Health:GetFrameLevel()+1)
  11.     absorbBar:SetPoint("TOPRIGHT", self.Health, 0, 0)
  12.     absorbBar:SetPoint("BOTTOMRIGHT", self.Health, 0, 0)
  13.     absorbBar:SetWidth(w)
  14.     absorbBar:SetStatusBarTexture(self.cfg.totalabsorb.texture)
  15.     absorbBar:SetStatusBarColor(self.cfg.totalabsorb.color.bar.r,self.cfg.totalabsorb.color.bar.g,self.cfg.totalabsorb.color.bar.b,self.cfg.totalabsorb.color.bar.a)    
  16.     absorbBar:SetReverseFill(true)
  17.     -- Register with oUF
  18.     self.TotalAbsorb = absorbBar    
  19.   end

Result:


Basically I overlay the healthbar with the absorb bar from right-to-left. The healprediction is underneath.

That way when loosing health I can easily see how much of the health lost is covered by a shield. My shield display caps at maxhealth.

I see no point in adding absorb bar to the healprediction display. Healprediction fills up health that is lost. Absorbbar shows how much of your health is covered by a shield.

My orb uses the same module, just a different create function.
http://code.google.com/p/rothui/sour...player.lua#389

Sidenote

I really would have loved to not using a fake statusbar on my orb. The problem is that when setting
Lua Code:
  1. bar:SetOrientation("VERTICAL")
  2. bar:SetReverseFill(true)

The statusbar texture crop is wrong. At least for what I'm needing. It will look like the texture is moving in from the top, not filling top-to-bottom.
I tried to hook the SetTexCoord function call on the statusbar texture to swap some values but it does not fire :/
Funny enough before applying the Smooth module I tried changing the SetTexCoord via the PostUpdate function but when PostUpdate was called (after SetValue) the SetTexCoord on the statusbar texture had not yet been applied. GetTexCoord() always delivered the old value, never the new one. Wierd!
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 10-09-13 at 06:19 AM.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » HealPrediction


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