/
Tags.lua
145 lines (129 loc) · 4.26 KB
/
Tags.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
local T, C, L, _ = unpack(select(2, ...))
if C.unitframe.enable ~= true then return end
----------------------------------------------------------------------------------------
-- Tags
----------------------------------------------------------------------------------------
local _, ns = ...
local oUF = ns.oUF
oUF.Tags["Threat"] = function(unit)
local tanking, status, percent = UnitDetailedThreatSituation("player", "target")
if percent and percent > 0 then
return ("%s%d%%|r"):format(Hex(GetThreatStatusColor(status)), percent)
end
end
oUF.TagEvents["Threat"] = "UNIT_THREAT_LIST_UPDATE"
oUF.Tags["DiffColor"] = function(unit)
local r, g, b
local level = UnitLevel(unit)
if level < 1 then
r, g, b = 0.69, 0.31, 0.31
else
local DiffColor = UnitLevel("target") - UnitLevel("player")
if DiffColor >= 5 then
r, g, b = 0.69, 0.31, 0.31
elseif DiffColor >= 3 then
r, g, b = 0.71, 0.43, 0.27
elseif DiffColor >= -2 then
r, g, b = 0.84, 0.75, 0.65
elseif -DiffColor <= GetQuestGreenRange() then
r, g, b = 0.33, 0.59, 0.33
else
r, g, b = 0.55, 0.57, 0.61
end
end
return string.format("|cff%02x%02x%02x", r * 255, g * 255, b * 255)
end
oUF.TagEvents["DiffColor"] = "UNIT_LEVEL"
oUF.Tags["PetNameColor"] = function(unit)
return string.format("|cff%02x%02x%02x", T.color.r * 255, T.color.g * 255, T.color.b * 255)
end
oUF.TagEvents["PetNameColor"] = "UNIT_POWER"
oUF.Tags["GetNameColor"] = function(unit)
local reaction = UnitReaction(unit, "player")
local tapped = UnitIsTapped(unit)
local tappedbyplayer = UnitIsTappedByPlayer(unit)
if UnitIsPlayer(unit) then
return _TAGS["raidcolor"](unit)
elseif tapped and not tappedbyplayer then
local c = T.oUF_colors.tapped
return string.format("|cff%02x%02x%02x", c[1] * 255, c[2] * 255, c[3] * 255)
elseif reaction then
local c = T.oUF_colors.reaction[reaction]
return string.format("|cff%02x%02x%02x", c[1] * 255, c[2] * 255, c[3] * 255)
else
r, g, b = 0.84, 0.75, 0.65
return string.format("|cff%02x%02x%02x", r * 255, g * 255, b * 255)
end
end
oUF.TagEvents["GetNameColor"] = "UNIT_POWER UNIT_FLAGS UNIT_DYNAMIC_FLAGS"
oUF.Tags["NameArena"] = function(unit)
local name = UnitName(unit)
return T.UTF(name, 4, false)
end
oUF.TagEvents["NameArena"] = "UNIT_NAME_UPDATE"
oUF.Tags["NameShort"] = function(unit)
local name = UnitName(unit)
return T.UTF(name, 8, false)
end
oUF.TagEvents["NameShort"] = "UNIT_NAME_UPDATE"
oUF.Tags["NameMedium"] = function(unit)
local name = UnitName(unit)
return T.UTF(name, 11, true)
end
oUF.TagEvents["NameMedium"] = "UNIT_NAME_UPDATE"
oUF.Tags["NameLong"] = function(unit)
local name = UnitName(unit)
return T.UTF(name, 18, true)
end
oUF.TagEvents["NameLong"] = "UNIT_NAME_UPDATE"
oUF.Tags["LFD"] = function(unit)
local role = UnitGroupRolesAssigned(unit)
if role == "HEALER" then
return "|cff8AFF30[H]|r"
elseif role == "TANK" then
return "|cffFFF130[T]|r"
elseif role == "DAMAGER" then
return "|cffFF6161[D]|r"
end
end
oUF.TagEvents["LFD"] = "PLAYER_ROLES_ASSIGNED GROUP_ROSTER_UPDATE"
oUF.Tags["AltPower"] = function(unit)
local min = UnitPower(unit, ALTERNATE_POWER_INDEX)
local max = UnitPowerMax(unit, ALTERNATE_POWER_INDEX)
if max > 0 and not UnitIsDeadOrGhost(unit) then
return ("%s%%"):format(math.floor(min / max * 100 + 0.5))
end
end
oUF.TagEvents["AltPower"] = "UNIT_POWER"
oUF.Tags["IncHeal"] = function(unit)
local incheal = UnitGetIncomingHeals(unit) or 0
local player = UnitGetIncomingHeals(unit, "player") or 0
incheal = incheal - player
if incheal > 0 then
return "|cff00FF00+"..T.ShortValue(incheal).."|r"
end
end
oUF.TagEvents["IncHeal"] = "UNIT_HEAL_PREDICTION"
if T.class == "DRUID" then
for i = 1, 3 do
oUF.Tags["WM"..i] = function(unit)
local _, _, _, dur = GetTotemInfo(i)
if dur > 0 then
return "|cffFF2222_|r"
end
end
oUF.TagEvents["WM"..i] = "PLAYER_TOTEM_UPDATE"
oUF.UnitlessTagEvents.PLAYER_TOTEM_UPDATE = true
end
end
if T.class == "WARLOCK" then
oUF.Tags["DemonicFury"] = function(unit)
local min = UnitPower("player", SPELL_POWER_DEMONIC_FURY)
local max = UnitPowerMax("player", SPELL_POWER_DEMONIC_FURY)
if T.CheckSpec(2) and max > 0 then
return ("%s%%"):format(math.floor(min / max * 100 + 0.5))
end
end
oUF.TagEvents["DemonicFury"] = "UNIT_POWER PLAYER_TALENT_UPDATE"
end
-- Edit by Oz of shestakdotorg --