-
Notifications
You must be signed in to change notification settings - Fork 0
/
absorbbar.lua
79 lines (73 loc) · 2.07 KB
/
absorbbar.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
local oUF = _G.oUF
assert(oUF, "oUF not found")
local ABSORB_SPELLS = {
[GetSpellInfo(112048)] = true, -- Shield Barrier
[GetSpellInfo(20925)] = true, -- Sacred Shield
[GetSpellInfo(66099)] = true, -- Power Word: Shield
[GetSpellInfo(47515)] = true, -- Divine Aegis
[GetSpellInfo(11426)] = true, -- Ice Barrier
[GetSpellInfo(56778)] = true, -- Mana Shield
[GetSpellInfo(7812)] = true, -- Sacrifice
-- local AB_MW = 'Mage Ward'
[GetSpellInfo(116631)] = true, -- Colossus (Weapon Enchant)
[GetSpellInfo(118604)] = true, -- Guard (Monk)
[GetSpellInfo(116849)] = true, -- Life Cocoon (Monk)
}
local newdata = {}
local function updateAbsorbInfo(unit, data)
local totalamount = 0
local totalmax = 0
local result = newdata
for i = 1,40 do
local name, _, icon, count, _, duration, expirationTime, unitCaster, _,
_, spellId, _, _, _, amount = UnitBuff(unit, i)
if ABSORB_SPELLS[name] then
if data[spellId] then
newdata[spellId] = data[spellId]
data[spellId] = nil
else
newdata[spellId] = amount
end
totalamount = totalamount + amount
totalmax = totalmax + newdata[spellId]
end
end
newdata = wipe(data)
return totalamount, totalmax, result
end
local Update = function(self, event, unit)
if(not unit or not UnitIsUnit(self.unit, unit)) then return end
local absorb = self.Absorb
local amount, max, data = updateAbsorbInfo(unit, absorb.data)
absorb.data = data
if amount > 0 then
absorb:SetMinMaxValues(0, max)
absorb:SetValue(amount)
if absorb.Value then
absorb.Value:SetText(tostring(amount))
end
else
absorb:SetValue(0)
if absorb.Value then
absorb.Value:SetText("")
end
end
end
local Enable = function(self)
if not self.Absorb then return end
self.Absorb:SetMinMaxValues(0, 1)
self.Absorb:SetValue(0)
self.Absorb.data = {}
if self.Absorb.Value then
self.Absorb.Value:SetText("")
end
self:RegisterEvent("UNIT_AURA", Update)
end
local Disable = function(self)
if not self.Absorb then return end
self:UnregisterEvent("Update")
if absorb.Value then
absorb.Value:SetText("")
end
end
oUF:AddElement('Absorb', Update, Enable, Disable)