09-27-10, 06:34 PM | #1 |
HealPrediction issue..
I'm really new to oUF, so any criticism is very welcome.
I'm modifying oUF_Simple by Zork (it's a great layout to start with ), but I can't seem to get HealPrediction to not overflow. Yes - I've set maxOverFlow to 1. Yes - maxOverFlow works. .. wait what? The overflow setting works like it's supposed to when I heal myself slowly, however when I spam myself with, lets say, healing surge.. the heal prediction statusbar goes way out, then corrects itself. It's kind of annoying.. though I have a feeling that there's a way to fix it. I'm using the heal prediction code almost exactly from the example on the oUF_HealPrediction page on WoWInterface: Code:
--gen healthbar func lib.gen_hpbar = function(f) if f.mystyle == "party" or f.mystyle =="raid" then --statusbar local s = CreateFrame("StatusBar", nil, f) s:SetStatusBarTexture(cfg.statusbar_texture) s:SetHeight(f.height) s:SetWidth(f.width) s:SetPoint("CENTER",0,0) --helper local h = CreateFrame("Frame", nil, s) h:SetFrameLevel(0) h:SetPoint("TOPLEFT",-5,5) h:SetPoint("BOTTOMRIGHT",5,-5) lib.gen_backdrop(h) --bg local b = s:CreateTexture(nil, "BACKGROUND") b:SetTexture(cfg.statusbar_texture) b:SetAllPoints(s) f.Health = s f.Health.bg = b else --statusbar local s = CreateFrame("StatusBar", nil, f) s:SetStatusBarTexture(cfg.statusbar_texture) s:SetHeight(f.height) s:SetWidth(f.width) s:SetPoint("CENTER",0,0) --helper local h = CreateFrame("Frame", nil, s) h:SetFrameLevel(0) h:SetPoint("TOPLEFT",-5,5) h:SetPoint("BOTTOMRIGHT",5,-5) lib.gen_backdrop(h) --bg local b = s:CreateTexture(nil, "BACKGROUND") b:SetTexture(cfg.statusbar_texture) b:SetAllPoints(s) f.Health = s f.Health.bg = b if cfg.healprediction then local mhpb = CreateFrame('StatusBar', nil, f) mhpb:SetPoint('TOPLEFT', s:GetStatusBarTexture(), 'TOPRIGHT', 0, 0) mhpb:SetPoint('BOTTOMLEFT', s:GetStatusBarTexture(), 'BOTTOMRIGHT', 0, 0) mhpb:SetWidth(f.width) mhpb:SetStatusBarTexture(cfg.statusbar_texture) mhpb:SetStatusBarColor(0, 1, 0.5, 0.25) local ohpb = CreateFrame('StatusBar', nil, f) ohpb:SetPoint('TOPLEFT', s:GetStatusBarTexture(), 'TOPRIGHT', 0, 0) ohpb:SetPoint('BOTTOMLEFT', s:GetStatusBarTexture(), 'BOTTOMRIGHT', 0, 0) ohpb:SetWidth(f.width) ohpb:SetStatusBarTexture(cfg.statusbar_texture) ohpb:SetStatusBarColor(0, 1, 0, 0.25) f.HealPrediction = { -- status bar to show my incoming heals myBar = mhpb, -- status bar to show other peoples incoming heals otherBar = ohpb, -- amount of overflow past the end of the health bar maxOverflow = 1, } end end end -J |
|
09-27-10, 07:05 PM | #2 |
Hi,
I've not got time to test the problem at the moment, but something to note is that the "otherBar" should be anchored to the right-hand side of "myBar". In your code incoming heals from yourself and from others would overlap as both statusbars are anchored to the end of the statusbar "s". Changing this will not affect any overflow, but it should help to show incoming heals as intended. I'll try and get some testing done on beta servers, but it might be a while before I can get any meaningful results. |
|
09-27-10, 09:29 PM | #3 | |
|
||
09-28-10, 03:48 PM | #4 |
I've had a quick play on the beta and when standing around just healing myself there doesn't seem to be an issue.
I suspect there might be a slight issue when you've got changes in health values and incoming heals at the same time, due to a minor delay between updates of the health and healprediction elements. Can you give some more details on the situation where you are seeing unexpected overflow? |
|
09-28-10, 04:34 PM | #5 |
Here's a visual aid:
http://www.youtube.com/watch?v=ovnMbCw182Y I noticed a new bug when doing this.. the texture keeps disappearing for some reason while spamming my heal. Maybe this is all on my end of things Here's all my heal prediction code: Code:
--gen healthbar func lib.gen_hpbar = function(f) local s = CreateFrame("StatusBar", nil, f) if f.mystyle == "party" or f.mystyle =="raid" then --statusbar s:SetStatusBarTexture(cfg.statusbar_texture) s:SetHeight(f.height) s:SetWidth(f.width) s:SetPoint("CENTER",0,0) --helper local h = CreateFrame("Frame", nil, s) h:SetFrameLevel(0) h:SetPoint("TOPLEFT",-5,5) h:SetPoint("BOTTOMRIGHT",5,-5) lib.gen_backdrop(h) --bg local b = s:CreateTexture(nil, "BACKGROUND") b:SetTexture(cfg.statusbar_texture) b:SetAllPoints(s) f.Health = s f.Health.bg = b else --statusbar s:SetStatusBarTexture(cfg.statusbar_texture) s:SetHeight(f.height) s:SetWidth(f.width) s:SetPoint("CENTER",0,0) --helper local h = CreateFrame("Frame", nil, s) h:SetFrameLevel(0) h:SetPoint("TOPLEFT",-5,5) h:SetPoint("BOTTOMRIGHT",5,-5) lib.gen_backdrop(h) --bg local b = s:CreateTexture(nil, "BACKGROUND") b:SetTexture(cfg.statusbar_texture) b:SetAllPoints(s) f.Health = s f.Health.bg = b end if cfg.healprediction then local mhpb = CreateFrame('StatusBar', nil, f) mhpb:SetPoint('TOPLEFT', s:GetStatusBarTexture(), 'TOPRIGHT', 0, 0) mhpb:SetPoint('BOTTOMLEFT', s:GetStatusBarTexture(), 'BOTTOMRIGHT', 0, 0) mhpb:SetWidth(f.width) mhpb:SetStatusBarTexture(cfg.statusbar_texture) mhpb:SetStatusBarColor(0, 1, 0.5, 0.25) local ohpb = CreateFrame('StatusBar', nil, mhpb) ohpb:SetPoint('TOPLEFT', s:GetStatusBarTexture(), 'TOPRIGHT', 0, 0) ohpb:SetPoint('BOTTOMLEFT', s:GetStatusBarTexture(), 'BOTTOMRIGHT', 0, 0) ohpb:SetWidth(f.width) ohpb:SetStatusBarTexture(cfg.statusbar_texture) ohpb:SetStatusBarColor(0, 1, 0, 0.25) f.HealPrediction = { -- status bar to show my incoming heals myBar = mhpb, -- status bar to show other peoples incoming heals otherBar = ohpb, -- amount of overflow past the end of the health bar maxOverflow = 1, } end end |
|
09-28-10, 05:01 PM | #6 | |
I need to get on the official forums to report it. For the overflow issue I'll try some more stuff tomorrow. |
||
09-29-10, 12:24 PM | #7 |
The heal prediction overflow issue happens because of the healthbar updating before the prediction bar updates. I ran into the same issue with HealComm in my layout and ended up writing my own implementation to get around it (which had the nice side effect of letting me use a second bar for hots).
The trick is the double anchor for the statusbar - Anchor from the right of the healthbar texture to the right of the healthbar (so that at full health its size is 0). From there some math is needed to find the proper value for the incoming heal bar. Here's the code, you might be able to adapt something from it. Code:
local UpdateHealComm = function (self,event,unit) if unit and (not self.unit or self.unit ~= unit) or (self.unit and event and event == 'PLAYER_TARGET_CHANGED' and self.unit ~= 'target') then return end if not self.unit or UnitIsDeadOrGhost(self.unit) or not UnitIsConnected(self.unit) then return Hide(self) end local maxHP = UnitHealthMax(self.unit) or 0 if maxHP == 0 or maxHP == 100 then return Hide(self) end local guid = UnitGUID(self.unit) local overTime = bit.bor(healcomm.HOT_HEALS, healcomm.BOMB_HEALS) local timeFrame = self.HCTimeframe and GetTime() + self.HCTimeframe or nil local incHeals = healcomm:GetHealAmount(guid, healcomm.CASTED_HEALS, timeFrame) or 0 local hotHeals = healcomm:GetHealAmount(guid, overTime, timeFrame) or 0 if hotHeals == 0 and incHeals == 0 then return Hide(self) end incHeals = incHeals * healcomm:GetHealModifier(guid) if self.HCT then if incHeals and incHeals > 0 then self.HCT:SetText(self.HCTFormat and self.HCTFormat(incHeals) or format("%d", incHeals)) else self.HCT:SetText("") end end local curHP = UnitHealth(self.unit) if self.HCB then -- Direct heals local percInc = math.min(incHeals, maxHP - curHP) / maxHP if percInc == 0 then self.HCB:SetValue(0) self.HCB:Hide() else self.HCB:SetValue( (math.min(incHeals, maxHP - curHP) / maxHP) / (1 - curHP/maxHP) ) -- This basically scales the healcomm bar inverse to the unit's missing health. Strange concept, but it allows dynamic anchoring, which is exactly what we're shooting for. self.HCB:Show() end end if self.HCB2 then -- HoT effects + lifebloom bomb local percInc = math.min(hotHeals, maxHP - curHP) / maxHP if percInc == 0 then self.HCB2:SetValue(0) self.HCB2:Hide() else self.HCB2:SetValue( (math.min(hotHeals, maxHP - curHP) / maxHP) / (1 - curHP/maxHP) ) self.HCB2:Show() end end end Code:
-- Healcomm self.HCB = CreateFrame('StatusBar',nil,self.Health) self.HCB:SetMinMaxValues(0,1) self.HCB:SetStatusBarTexture(texture) self.HCB:SetStatusBarColor(0.25,1,0,0.5) self.HCB:SetPoint("BOTTOMLEFT", self.Health:GetStatusBarTexture(), "BOTTOMRIGHT") self.HCB:SetPoint("TOPRIGHT", self.Health, "TOPRIGHT") self.HCB:SetOrientation("HORIZONTAL") self.HCB2 = CreateFrame('StatusBar',nil,self.Health) self.HCB2:SetMinMaxValues(0,1) self.HCB2:SetStatusBarTexture(texture) self.HCB2:SetStatusBarColor(0,0.5,0.75,0.5) self.HCB2:SetPoint("BOTTOMLEFT", self.Health:GetStatusBarTexture(), "BOTTOMRIGHT") self.HCB2:SetPoint("TOPRIGHT", self.Health, "TOPRIGHT") self.HCB2:SetOrientation("HORIZONTAL") self.HCTimeframe = 2.5 |
|
09-29-10, 12:52 PM | #8 |
Yup. It looks like my suspicion was right and Taroven described it nicely.
When you have in incoming heal bar showing and your health updates (e.g. from a HoT tick) then your health bar will increase and push the incoming heal bar past the overflow limit. When the event then gets propagated to the healprediction element it then updates the heal bar size. To stop this happening you can do as Taroven describes and anchor the incoming heal bar to the end of the health bar (only if you want to stop all overflow), the element *should* work fine as it is, so only your layout code would change. |
|
10-04-10, 10:11 AM | #9 | |
I've been trying and trying to do what you said ("anchor the inc. heal bar to the end of the health bar"), but everything I try ends up not working. I've tried to adapt Taroven's code to my own but it yields no proper result when I try.. This is all so confusing Isn't it already anchored to the health bar..? Code:
mhpb:SetPoint('TOPLEFT', s:GetStatusBarTexture(), 'TOPRIGHT', 0, 0) mhpb:SetPoint('BOTTOMLEFT', s:GetStatusBarTexture(), 'BOTTOMRIGHT', 0, 0) PS- Shouldn't there be a default PreUpdate and PostUpdate function within the core HealPrediction stuff to check for changed values and such, or do I really have to make a PostUpdate function like Taroven said to check for accurate values.. Last edited by JStrese : 10-04-10 at 10:14 AM. |
||
10-04-10, 10:58 AM | #10 |
In your code the heal prediction bars are anchored on the left side, but not on the right. This means that there in no limit on where the right hand side of the status bar could theoretically reach.
If you add an additional anchor on the right hand side then the status bar will never go beyond that point. For the Health PostUpdate routine, Taroven meant that after each update from the Health element then force an update of the HealPrediction element. This reduces any delay between updates and will reduce the time in which the overflow issue could be shown. e.g. Code:
self.Health.PostUpdate = function(element, unit, min, max) element.__owner.HealPrediction:ForceUpdate() end |
|
WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » HealPrediction issue.. |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|