View Single Post
12-30-11, 04:22 PM   #6
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,323
It doesn't look like FocusFrame even registers UNIT_TARGET for TargetofFocusFrame. It looks like you can hook TargetofFocus_Update() to accomplish this.

lua Code:
  1. hooksecurefunc("TargetofFocus_Update",function(self)
  2.     if not self then self=TargetofFocusFrame; end
  3.  
  4.     if UnitExists("focus-target") then
  5.         if UnitIsPlayer("focus-target") then
  6. --          Unit can exist, but if we haven't received data yet, UnitClass() can return nil
  7.             local color=RAID_CLASS_COLORS[select(2,UnitClass("focus-target")) or ""];
  8.  
  9.             if color then
  10.                 self.healthbar:SetStatusBarColor(color.r,color.g,color.b);
  11.                 self.healthbar.lockColor=true;
  12.                 return;--   Force out of function
  13.             end
  14.         end
  15.     end
  16.  
  17. --  If we reach here by any way, we wern't able to change the color
  18.     self.healthbar.lockColor=false;
  19. end)
  20.  
  21. --  Update handler pointer to the hooked function
  22. TargetofTargetFrame:SetScript("OnUpdate",TargetofFocus_Update);

Note not only is TargetofFocus_Update() the OnUpdate handler for TargetofFocusFrame, but is also called with no arguments from FocusFrame's OnUpdate handler.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 12-30-11 at 04:29 PM.
  Reply With Quote