Originally Posted by p3lim
UnitIsEnemy(unit, 'player')
|
Thank you for the suggestion, but I tried this, too, without success
Code:
-- check if the target is friendly for a blue bar or hostile for a red one
if (UnitIsEnemy('target', 'player')) then
self.Castbar:SetStatusBarColor(0.80, 0.01, 0)
else
self.Castbar:SetStatusBarColor(0, 0.01, 0.80)
end
-- original line in Lyn's layout code
-- self.Castbar:SetStatusBarColor(0.80, 0.01, 0)
I tried various stuff like UnitIsEnemy(unit, 'player'), ('target', 'player') and the like, all to no avail. The "else" branch is always chosen and the bar is colored blue.
I'm feeling quite stumped at this, and I can't see any other parts of the code that may alter this behaviour.
edit: tried on the same mob:
/script if (UnitIsEnemy("target","player")) then SendChatMessage("%t is evil!","SAY"); end;
and the chat message is correctly spammed (but still, cast bar is coloured wrong).
edit 2: tried with if (false) then <set color1> else <set color2> end, and it always chooses color2; if (true) always chooses color1, so I'm quite assured that nothing else is interfering in the colouring process itself. It seems the problem rests in the condition itself. Tried UnitIsPlayer(unit) with no avail, it always goes down the "false" branch even when I'm targeting myself.