-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbrDebuffs.lua
More file actions
62 lines (52 loc) · 1.86 KB
/
brDebuffs.lua
File metadata and controls
62 lines (52 loc) · 1.86 KB
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
---@TYPE _,br,_
local _, br, _ = ...
---@type br.Logging
local log = br.Logging or {}
---@class br.Debuffs
local auras = {}
br.Debuffs = auras
function auras:AuraSetup(AuraList)
self.auras = self.auras or {}
self.auras.up = {}
self.auras.down = {}
self.auras.stacks={}
self.auras.remaining={}
for auraName,auraID in pairs(AuraList) do
self.auras.up[auraName] = function(unit)
for i=1,40 do
if not br.ObjectExists(unit.guid) then return false end
---@type AuraData
local aura = br.api.GetDebuffDataByIndex(unit.WoWGUID,i,"HARMFUL")
if aura and aura.spellId == auraID then
--print("Unit ", unit.name, " has debuff ", auraName, " with ", aura.charges or 0, " stacks and ", math.max(0,aura.expirationTime - GetTime()), " seconds remaining.")
return true
end
end
return false
end
self.auras.down[auraName] = function(unit)
return not self.auras.up[auraName](unit)
end
self.auras.stacks[auraName] = function(unit)
for i=1,40 do
---@type AuraData?
local aura = br.api.GetDebuffDataByIndex(unit.WoWGUID,i,"HARMFUL")
if aura and aura.spellId == auraID then
return aura.charges or 0
end
end
return 0
end
self.auras.remaining[auraName] = function(unit)
for i=1,40 do
---@type AuraData?
local aura = br.api.GetDebuffDataByIndex(unit.WoWGUID,i,"HARMFUL")
if aura and aura.spellId == auraID then
return aura.expirationTime - GetTime()
end
end
return 0
end
end
br.Debuffs = self.auras
end