local _, addon = ... local lib = addon.lib local cfg = addon.config -- ---------------------------------------------------------------------------------------------------- local tags = oUF.Tags.Methods or oUF.Tags local tagEvents = oUF.TagEvents or oUF.Tags.Events oUF.colors.power['MANA'] = {0.37, 0.6, 1} oUF.colors.power['RAGE'] = {0.9, 0.3, 0.23} oUF.colors.power['FOCUS'] = {1, 0.81, 0.27} oUF.colors.power['RUNIC_POWER'] = {0, 0.81, 1} oUF.colors.power['AMMOSLOT'] = {0.78,1, 0.78} oUF.colors.power['FUEL'] = {0.9, 0.3, 0.23} oUF.colors.power['POWER_TYPE_STEAM'] = {0.55, 0.57, 0.61} oUF.colors.power['POWER_TYPE_PYRITE'] = {0.60, 0.09, 0.17} oUF.colors.power['POWER_TYPE_HEAT'] = {0.55,0.57,0.61} oUF.colors.power['POWER_TYPE_OOZE'] = {0.76,1,0} oUF.colors.power['POWER_TYPE_BLOOD_POWER'] = {0.7,0,1} -- ROLES tags['lyn:role'] = function(unit) local role = UnitGroupRolesAssigned(unit) if role == 'HEALER' then return '|cff8AFF30H|r' elseif role == 'TANK' then return '|cff5F9BFFT|r' elseif role == 'DAMAGER' then return '|cffFF6161D|r' end -- return '|cFF444444P|R' return '' end tagEvents['lyn:role'] = 'PLAYER_ROLES_ASSIGNED PARTY_MEMBERS_CHANGED' -- PVP tags['lyn:pvp'] = function(unit) if UnitIsPVP(unit) or UnitIsPVPFreeForAll(unit) then return '|cff50BB33PVP|r' end return '' end tagEvents['lyn:pvp'] = 'UNIT_FACTION' -- CLASSIFICATION tags['lyn:classification'] = function(unit) local c = UnitClassification(unit) if(c == 'rare') then return '|cffF6C6F9rare|r' elseif(c == 'rareelite') then return '|cffF6C6F9rare+|r' elseif(c == 'elite') then return '|cff41C2B3elite|r' elseif(c == 'worldboss') then return '|cff9AF5DEboss|r' elseif(c == 'minus') then return '' end return '' end tagEvents['lyn:classification'] = 'UNIT_CLASSIFICATION_CHANGED' -- HEALTH SHORTENED -- shows shortened hp value if hp > 0 and not dead/ghost/offline tags['lyn:hps'] = function(unit) local min, max = UnitHealth(unit), UnitHealthMax(unit) if min <= 1 or ( (unit == 'player' or unit:sub(1, 5) == 'party' or unit == 'pet') and min == max) or not UnitIsConnected(unit) or UnitIsGhost(unit) or UnitIsDead(unit) then return '' end return lib.formatValue(min) end tagEvents['lyn:hps'] = "UNIT_HEALTH UNIT_MAXHEALTH UNIT_CONNECTION UNIT_NAME_UPDATE" -- HEALTH PERCENT -- shows health percent by health threshold if < 100% tags["lyn:hpp"] = function(unit) if not UnitIsConnected(unit) then return "|cff999999OFFLINE|r" elseif UnitIsGhost(unit) then return "|cff999999GHOST|r" elseif UnitIsDead(unit) then return "|cff999999DEAD|r" end local min, max = UnitHealth(unit), UnitHealthMax(unit) local percent = math.floor((min / max) * 100+0.5) if percent < 100 then --if percent > 0 then return lib.hex(oUF.ColorGradient(min, max, 1,0,0, 1,1,0, 0,1,0)) .. percent .. "%" end return '' end tagEvents["lyn:hpp"] = "UNIT_HEALTH UNIT_MAXHEALTH UNIT_CONNECTION PLAYER_DEAD PLAYER_ALIVE" -- HEALTH tags['lyn:hp'] = function(unit) if UnitIsGhost(unit) then return "|cff999999('o')|r" elseif UnitIsDead(unit) then return "|cff999999(x.x)|r" end local min, max = UnitHealth(unit), UnitHealthMax(unit) local percent = math.floor((min / max) * 100+0.5) return '|cffffffff' .. lib.formatValue(min) .. '|r ' .. lib.hex(oUF.ColorGradient(min, max, 1,0,0, 1,1,0, 0,1,0)) .. percent .. '%|r' end tagEvents['lyn:hp'] = "UNIT_HEALTH UNIT_MAXHEALTH UNIT_CONNECTION PLAYER_DEAD PLAYER_ALIVE" -- HEALTH NAME -- shows the name colored by class color till 95%, after that, the name is colored by health threshold tags["lyn:hpn"] = function(unit) local name, realm = UnitName(unit) name = lib.utf8sub(name, 13, true) if not UnitIsConnected(unit) then return "|cff333333"..name.."|r" elseif UnitIsGhost(unit) then return "|cff999999"..name.."|r" elseif UnitIsDead(unit) then return "|cff555555"..name.."|r" end local _, class = UnitClass(unit) local min, max = UnitHealth(unit), UnitHealthMax(unit) local percent = math.floor((min / max) * 100+0.5) if percent > 95 and class ~= nil then return lib.hex(oUF.colors.class[class]) .. name else return lib.hex(oUF.ColorGradient(min, max, 1,0,0, 1,1,0, 0,1,0)) .. name end end tagEvents["lyn:hpn"] = "UNIT_HEALTH UNIT_MAXHEALTH UNIT_CONNECTION UNIT_NAME_UPDATE" -- POWER tags['lyn:power'] = function(unit) local min, max = UnitPower(unit, UnitPowerType(unit)), UnitPowerMax(unit, UnitPowerType(unit)) if(min == 0 or max == 0 or min == max or not UnitIsConnected(unit) or UnitIsDead(unit) or UnitIsGhost(unit)) then return '' end local _, powerType = UnitPowerType(unit) return lib.hex(oUF.colors.power[powerType]) .. lib.formatValue(min) .. '|r' end tagEvents['lyn:power'] = "UNIT_MAXPOWER UNIT_POWER UNIT_CONNECTION PLAYER_DEAD PLAYER_ALIVE" -- NAME: TARGET -- shortened after 19 characters, adds "..." after that tags["lyn:targetname"] = function(unit) local name, realm = UnitName(unit) return lib.shortenName(name) --return lib.utf8sub(name, 19, true) end tagEvents["lyn:targetname"] = "UNIT_NAME_UPDATE" -- NAME: RAID -- shortened after 10 tags["lyn:raidname"] = function(unit) if UnitIsDead(unit) then return '|cff999999DEAD|r' elseif UnitIsGhost(unit) then return '|cff999999GHOST|r' elseif not UnitIsConnected(unit) then return '|cff666666DC|r' else local name, realm = UnitName(unit) return lib.utf8sub(name, 5) end end tagEvents["lyn:raidname"] = "UNIT_NAME_UPDATE UNIT_HEALTH UNIT_CONNECTION" -- NAME -- shortened after 15 characters, adds "..." after that tags["lyn:name"] = function(unit) local name, realm = UnitName(unit) return lib.shortenName(name) --return lib.utf8sub(name, 15, true) end tagEvents["lyn:name"] = "UNIT_NAME_UPDATE" -- COLORS tags["lyn:color"] = function(unit) local _, class = UnitClass(unit) local reaction = UnitReaction(unit, "player") if UnitIsDead(unit) or UnitIsGhost(unit) or not UnitIsConnected(unit) then return "|cffA0A0A0" elseif UnitIsTapDenied(unit) then return lib.hex(oUF.colors.tapped) elseif unit == "pet" then return lib.hex(oUF.colors.class[class]) elseif UnitIsPlayer(unit) then return lib.hex(oUF.colors.class[class]) elseif reaction then return lib.hex(oUF.colors.reaction[reaction]) end return lib.hex(1, 1, 1) end tagEvents["lyn:color"] = 'UNIT_REACTION UNIT_HEALTH UNIT_HAPPINESS UNIT_CONNECTION'