I think its something like this. Check for every possible combination, and neutral is the ‘else’ at the very end.
local function getReactionColor(unit)
if UnitIsFriend(unit, "player") then
if UnitInParty(unit) or UnitInRaid(unit) then
return 0, 0.5, 0.5
elseif UnitIsInMyGuild(unit) then
return 0, 0.33, 0.33
elseif UnitIsPVP(unit) then
return 0, 1, 0
else
return 0, 0, 1
end
elseif UnitIsEnemy(unit, "player") or UnitIsPVP(unit) or UnitIsPVPFreeForAll(unit) then
return 1, 0, 0
elseif UnitIsPlayer(unit) then
return 0.75, 0.25, 0
else
return 0.5, 0.5, 0
end
end