View Single Post
04-02-13, 01:34 PM   #16
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Finished my test. Thank god. UNIT_HEALTH_FREQUENT does fire correctly for all boss units. No clue what is wrong with UNIT_HEALTH. So adding frequentUpdates to the boss unit healthbars fixes the health issue.

If you are changing your health values via tags make sure that boss unit health strings use a health tag that uses UNIT_HEALTH_FREQUENT aswell. Otherwise only that statusbar will update correctly. I suggest creating a new tag for that purpose since you may not want that event on all units.



I will just post some stuff I'm using atm:

Boss tags
Lua Code:
  1. --boss health value
  2.   oUF.Tags.Methods["diablo:bosshp"] = function(unit)
  3.     local val = oUF.Tags.Methods["perhp"](unit)
  4.     return val or ""
  5.   end
  6.   oUF.Tags.Events["diablo:bosshp"] = "UNIT_HEALTH_FREQUENT UNIT_MAXHEALTH UNIT_TARGETABLE_CHANGED"
  7.  
  8.   --boss power value
  9.   oUF.Tags.Methods["diablo:bosspp"] = function(unit)
  10.     if UnitIsDeadOrGhost(unit) then return "" end
  11.     local str = ""
  12.     --power value tracking (show percentage if max power > 0)
  13.     local pp_max = UnitPowerMax(unit)
  14.     if pp_max > 0 then
  15.       str = str..oUF.Tags.Methods["perpp"](unit).."%"
  16.     end
  17.     --additional altpower tracking
  18.     local ap_max = UnitPowerMax(unit, ALTERNATE_POWER_INDEX)
  19.     local color = "0099ff"
  20.     if pp_max > 0 and ap_max > 0 then
  21.       str = str.." ("
  22.     end
  23.     if ap_max > 0 then
  24.       local ap_cur = UnitPower(unit, ALTERNATE_POWER_INDEX)
  25.       str = str.."|cff"..color..("%s%%"):format(floor(ap_cur/ap_max*100)).."|r"
  26.     end
  27.     if pp_max > 0 and ap_max > 0 then
  28.       str = str..")"
  29.     end
  30.     --return "93% (|cff"..color..("%s%%"):format(30).."|r)" --debug
  31.     return str or ""
  32.   end
  33.   oUF.Tags.Events["diablo:bosspp"] = "UNIT_POWER UNIT_MAXPOWER UNIT_TARGETABLE_CHANGED"

Boss health statusbar. The powerbar does not need frequentupdates it works properly without.
Lua Code:
  1. self.Health.frequentUpdates = true

I added this to oUF/units.lua
Lua Code:
  1. elseif(unit:match'(boss)%d?$' == 'boss') then
  2.     object:RegisterEvent('INSTANCE_ENCOUNTER_ENGAGE_UNIT', object.UpdateAllElements, true)
  3.     object:RegisterEvent('UNIT_TARGETABLE_CHANGED', object.UpdateAllElements)

INSTANCE_ENCOUNTER_ENGAGE_UNIT is unitless thus the third attribute has to be set to true.
__________________
| 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 : 04-02-13 at 01:47 PM.
  Reply With Quote