View Single Post
11-13-15, 07:30 PM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,879
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.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 11-14-15 at 03:07 AM.
  Reply With Quote