Originally Posted by Fizzlemizz
This might be closer to what you'r looking for, it doesn't account for tapped or dead.
Code:
if UnitExists("target") then
local r, g, b
local playerFaction, targetFaction = UnitFactionGroup("player"), UnitFactionGroup("target")
if targetFaction == "Neutral" then -- level less than 20 Panda or 55-58 DK
-- r, g, b, = 1, 1, 1 -- whatever color works for you
elseif targetFaction and playerFaction ~= targetFaction then -- enemy faction NPC or player
r, g, b = 1, 0, 0 -- red
elseif UnitIsPlayer("target") then -- friendly player
local _, Class = UnitClass("target")
local Color = RAID_CLASS_COLORS[Class] or {r = 1, g = 1, b = 1}
r, g, b = Color.r, Color.g, Color.b
else -- non "factioned" NPC
r, g, b = UnitSelectionColor("target") -- your "reaction" to the target (neutral, friendly, die you sob)
end
self.bg:SetVertexColor(r, g, b)
else -- target out of range
self.bg:SetVertexColor(0, 0, 0) -- or hide or...
end
Someone might have better or more definitive solution.
|
http://i.imgur.com/VLZVVue.jpg
Okay this seem to work how i want it to be, but i can't get the colors to match :S
As you can see in the preview, this is what my bars look like, they don't match my hp bars! I've included the colors i want the bars to be on the certain targets like neutral(yellow), green/faction/friendly mob(green) and hostile (red).
I tried to edit the "r,g,b" values i could in the script but they still didn't match the colors..
This is how my script looks like after i edited something, what am i doing wrong?
OnEvent
if UnitExists("target") then
local r, g, b
local playerFaction, targetFaction = UnitFactionGroup("player"), UnitFactionGroup("target")
if targetFaction == "Neutral" then -- level less than 20 Panda or 55-58 DK
-- r, g, b, = 247, 236, 54
elseif targetFaction and playerFaction ~= targetFaction then -- enemy faction NPC or player
r, g, b = 247, 88, 54
elseif UnitIsPlayer("target") then -- friendly player
local _, Class = UnitClass("target")
local Color = RAID_CLASS_COLORS[Class] or {r = 1, g = 1, b = 1}
r, g, b = Color.r, Color.g, Color.b
else -- non "factioned" NPC
r, g, b = UnitSelectionColor("target") -- your "reaction" to the target (neutral, friendly, die you sob)
end
self.bg:SetVertexColor(r, g, b)
else -- target out of range
self.bg:SetVertexColor(0, 0, 0)
end
OnLoad
self:RegisterEvent("PLAYER_TARGET_CHANGED")