/
RaidDebuffs.lua
288 lines (256 loc) · 6.44 KB
/
RaidDebuffs.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
local T, C, L = unpack(select(2, ...))
if C.unitframe.enable ~= true or C.raidframe.plugins_aura_watch ~= true then return end
----------------------------------------------------------------------------------------
-- Based on oUF_RaidDebuffs(by Yleaf)
----------------------------------------------------------------------------------------
local _, ns = ...
local oUF = ns.oUF
local bossDebuffPrio = 9999999
local invalidPrio = -1
local auraFilters = {
["HARMFUL"] = true,
}
local DispellColor = {
["Magic"] = {0.2, 0.6, 1},
["Curse"] = {0.6, 0, 1},
["Disease"] = {0.6, 0.4, 0},
["Poison"] = {0, 0.6, 0},
["none"] = {unpack(C.media.border_color)},
}
if C.aura.debuff_color_type == true then
DispellColor.none = {1, 0, 0}
end
local DispellPriority = {
["Magic"] = 4,
["Curse"] = 3,
["Disease"] = 2,
["Poison"] = 1,
}
local DispellFilter
do
local dispellClasses = {
["DRUID"] = {
["Magic"] = false,
["Curse"] = true,
["Poison"] = true,
},
["MAGE"] = {
["Curse"] = true,
},
["MONK"] = {
["Magic"] = false,
["Poison"] = true,
["Disease"] = true,
},
["PALADIN"] = {
["Magic"] = false,
["Poison"] = true,
["Disease"] = true,
},
["PRIEST"] = {
["Magic"] = false,
["Disease"] = false,
},
["SHAMAN"] = {
["Magic"] = false,
["Curse"] = true,
},
}
DispellFilter = dispellClasses[T.class] or {}
end
local function CheckSpec()
if T.class == "DRUID" then
if T.CheckSpec(4) then
DispellFilter.Magic = true
else
DispellFilter.Magic = false
end
elseif T.class == "MONK" then
if T.CheckSpec(2) then
DispellFilter.Magic = true
else
DispellFilter.Magic = false
end
elseif T.class == "PALADIN" then
if T.CheckSpec(1)then
DispellFilter.Magic = true
else
DispellFilter.Magic = false
end
elseif T.class == "PRIEST" then
if T.CheckSpec(3) then
DispellFilter.Magic = false
DispellFilter.Disease = false
else
DispellFilter.Magic = true
DispellFilter.Disease = true
end
elseif T.class == "SHAMAN" then
if T.CheckSpec(3) then
DispellFilter.Magic = true
else
DispellFilter.Magic = false
end
end
end
local function formatTime(s)
if s > 60 then
return format("%dm", s / 60), s % 60
else
return format("%d", s), s - floor(s)
end
end
local abs = math.abs
local function OnUpdate(self, elapsed)
self.elapsed = (self.elapsed or 0) + elapsed
if self.elapsed >= 0.1 then
local timeLeft = self.expirationTime - GetTime()
if self.reverse then timeLeft = abs((self.expirationTime - GetTime()) - self.duration) end
if timeLeft > 0 then
local text = formatTime(timeLeft)
self.time:SetText(text)
else
self:SetScript("OnUpdate", nil)
self.time:Hide()
end
self.elapsed = 0
end
end
local UpdateDebuffFrame = function(rd)
if rd.index and rd.type and rd.filter then
local name, rank, icon, count, debuffType, duration, expirationTime, _, _, _, spellId, _, isBossDebuff = UnitAura(rd.__owner.unit, rd.index, rd.filter)
if rd.icon then
rd.icon:SetTexture(icon)
rd.icon:Show()
end
if rd.count then
if count and (count > 1) then
rd.count:SetText(count)
rd.count:Show()
else
rd.count:Hide()
end
end
if spellId and T.RaidDebuffsReverse[spellId] then
rd.reverse = true
else
rd.reverse = nil
end
if rd.time then
rd.duration = duration
if duration and (duration > 0) then
rd.expirationTime = expirationTime
rd.nextUpdate = 0
rd:SetScript("OnUpdate", OnUpdate)
rd.time:Show()
else
rd:SetScript("OnUpdate", nil)
rd.time:Hide()
end
end
if rd.cd then
if duration and (duration > 0) then
rd.cd:SetCooldown(expirationTime - duration, duration)
rd.cd:Show()
else
rd.cd:Hide()
end
end
local c = DispellColor[debuffType] or DispellColor.none
if C.aura.debuff_color_type == true then
rd:SetBackdropBorderColor(c[1], c[2], c[3])
end
if not rd:IsShown() then
rd:Show()
end
else
if rd:IsShown() then
rd:Hide()
end
end
end
local Update = function(self, event, unit)
if unit ~= self.unit then return end
local rd = self.RaidDebuffs
rd.priority = invalidPrio
for filter in next, (rd.Filters or auraFilters) do
local i = 0
while(true) do
i = i + 1
local name, rank, icon, count, debuffType, duration, expirationTime, _, _, _, spellId, _, isBossDebuff = UnitAura(unit, i, filter)
if not name then break end
if rd.ShowBossDebuff and isBossDebuff then
local prio = rd.BossDebuffPriority or bossDebuffPrio
if prio and prio > rd.priority then
rd.priority = prio
rd.index = i
rd.type = "Boss"
rd.filter = filter
end
end
if rd.ShowDispellableDebuff and debuffType then
local disPrio = rd.DispellPriority or DispellPriority
local disFilter = rd.DispellFilter or DispellFilter
local prio
if rd.FilterDispellableDebuff and disFilter then
prio = disFilter[debuffType] and disPrio[debuffType]
else
prio = disPrio[debuffType]
end
if prio and (prio > rd.priority) then
rd.priority = prio
rd.index = i
rd.type = "Dispel"
rd.filter = filter
end
end
local prio = rd.Debuffs and rd.Debuffs[rd.MatchBySpellName and name or spellId]
local prioPvP
if C.raidframe.plugins_pvp_debuffs == true then
prioPvP = rd.Debuffs and T.PvPDebuffs[rd.MatchBySpellName and name or spellId]
end
if not T.RaidDebuffsIgnore[spellId] and (prio and (prio > rd.priority) or prioPvP and (prioPvP > rd.priority)) then
if (prio and not prioPvP) or ((prio and prioPvP) and prio > prioPvP) then
rd.priority = prio
else
rd.priority = prioPvP
end
rd.index = i
rd.type = "Custom"
rd.filter = filter
end
end
end
if rd.priority == invalidPrio then
rd.index = nil
rd.filter = nil
rd.type = nil
end
return UpdateDebuffFrame(rd)
end
local Path = function(self, ...)
return (self.RaidDebuffs.Override or Update) (self, ...)
end
local ForceUpdate = function(element)
return Path(element.__owner, "ForceUpdate", element.__owner.unit)
end
local Enable = function(self)
local rd = self.RaidDebuffs
if rd then
self:RegisterEvent("UNIT_AURA", Path)
rd.ForceUpdate = ForceUpdate
rd.__owner = self
return true
end
self:RegisterEvent("PLAYER_TALENT_UPDATE", CheckSpec)
CheckSpec()
end
local Disable = function(self)
if self.RaidDebuffs then
self:UnregisterEvent("UNIT_AURA", Path)
self.RaidDebuffs:Hide()
self.RaidDebuffs.__owner = nil
end
self:UnregisterEvent("PLAYER_TALENT_UPDATE", CheckSpec)
end
oUF:AddElement("RaidDebuffs", Update, Enable, Disable)