Thread Tools Display Modes
12-30-11, 03:02 AM   #1
lessterlll
A Murloc Raider
Join Date: Jul 2011
Posts: 6
Focus target class

hello everyone!
Need class color on focus target name, or hp bar, or portret icon replace to class icon
Can someone write this script for me?
only focus target, not all frames
  Reply With Quote
12-30-11, 06:16 AM   #2
whoarrior
A Deviate Faerie Dragon
 
whoarrior's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 14
Code:
local color = nil
local w = CreateFrame("Frame")
w:RegisterEvent("PLAYER_FOCUS_CHANGED")
function w:OnEvent(event, ...)
    if event == "PLAYER_FOCUS_CHANGED" then
        if UnitIsPlayer("focus") then
            color = RAID_CLASS_COLORS[select(2, UnitClass("focus"))]
        end
        if color then
            FocusFrameHealthBar:SetStatusBarColor(color.r, color.g, color.b)
            FocusFrameHealthBar.lockColor = true
        end
    end
end
w:SetScript("OnEvent", w.OnEvent)
(:
  Reply With Quote
12-30-11, 08:02 AM   #3
lessterlll
A Murloc Raider
Join Date: Jul 2011
Posts: 6
thx, but not focus class, need class target of focus

like it:
Code:
local color = nil
local w = CreateFrame("Frame")
w:RegisterEvent("FOCUS_TARGET_CHANGED")
function w:OnEvent(event, ...)
    if event == "FOCUS_TARGET_CHANGED" then
        if UnitIsPlayer("focustarget") then
            color = RAID_CLASS_COLORS[select(2, UnitClass("focustarget"))]
        end
        if color then
            TargetofFocusFrameHealthBar:SetStatusBarColor(color.r, color.g, color.b)
            TargetofFocusFrameHealthBar.lockColor = true
        end
    end
end
w:SetScript("OnEvent", w.OnEvent)
but this don't work and i don't know whats wrong
  Reply With Quote
12-30-11, 08:35 AM   #4
whoarrior
A Deviate Faerie Dragon
 
whoarrior's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 14
Code:
local color = nil
local w = CreateFrame("Frame")
w:RegisterEvent("UNIT_TARGET")
function w:OnEvent(event, ...)
    if event == "UNIT_TARGET" then
        local unitID = ...
        if UnitIsUnit("focus", unitID) then
            if UnitExists("focus-target") then
                if UnitIsPlayer("focus-target") then
                    color = RAID_CLASS_COLORS[select(2, UnitClass("focus-target"))]
                end
                if color then
                    TargetofFocusHealthBar:SetStatusBarColor(color.r, color.g, color.b)
                    TargetofFocusHealthBar.lockColor = true
                end
            end
        end
    end
end
w:SetScript("OnEvent", w.OnEvent)
not tested
  Reply With Quote
12-30-11, 09:00 AM   #5
lessterlll
A Murloc Raider
Join Date: Jul 2011
Posts: 6
not working
  Reply With Quote
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,313
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

WoWInterface » AddOns, Compilations, Macros » AddOn Search/Requests » Focus target class

Thread Tools
Display Modes

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