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:
hooksecurefunc("TargetofFocus_Update",function(self)
if not self then self=TargetofFocusFrame; end
if UnitExists("focus-target") then
if UnitIsPlayer("focus-target") then
-- Unit can exist, but if we haven't received data yet, UnitClass() can return nil
local color=RAID_CLASS_COLORS[select(2,UnitClass("focus-target")) or ""];
if color then
self.healthbar:SetStatusBarColor(color.r,color.g,color.b);
self.healthbar.lockColor=true;
return;-- Force out of function
end
end
end
-- If we reach here by any way, we wern't able to change the color
self.healthbar.lockColor=false;
end)
-- Update handler pointer to the hooked function
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.