-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgroupOffensiveAuras.lua
88 lines (74 loc) · 2.91 KB
/
groupOffensiveAuras.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
-- TSU: TRIGGER:1
function(allstates, event, triggerNum, triggerStates)
if event ~= 'TRIGGER' then
return false
end
-- Construct a two-dimensional mapping: 'unitCaster->spellId->stackData',
-- where 'stackData' is information about the target count of 'spellId' for
-- that 'unitCaster' and about the max expiration and corresponding
-- duration.
local spellMap = {}
for _, state in pairs(triggerStates) do
local spells = spellMap[state['unitCaster']]
if spells == nil then
spells = {}
spellMap[state['unitCaster']] = spells
end
local stackData = spells[state['spellId']]
if stackData == nil then
stackData = {
['targetCount'] = 0,
['expirationTime'] = 0,
['duration'] = 0,
}
spells[state['spellId']] = stackData
end
stackData['targetCount'] = stackData['targetCount'] + 1
if state['expirationTime'] > stackData['expirationTime'] then
stackData['expirationTime'] = state['expirationTime']
stackData['duration'] = state['duration']
end
end
-- Prune any states in 'allstates' for spells that are not in 'spellMap'.
local changed = false
for key, state in pairs(allstates) do
local unitCaster, spellId = string.match(key, '(.+)%.(.+)')
spellId = tonumber(spellId)
if spellMap[unitCaster] == nil
or spellMap[unitCaster][spellId] == nil then
state['show'] = false
state['changed'] = true
changed = true
end
end
-- Add and update states from 'spellMap'.
for unitCaster, spells in pairs(spellMap) do
for spellId, stackData in pairs(spells) do
local key = unitCaster .. '.' .. spellId
local state = allstates[key]
if state == nil then
local spellInfo = C_Spell.GetSpellInfo(spellId)
state = {
['show'] = true,
['progressType'] = 'timed',
['autoHide'] = true,
['spellId'] = spellId,
['name'] = spellInfo['name'],
['icon'] = spellInfo['iconID'],
['unit'] = unitCaster,
}
allstates[key] = state
end
if state['expirationTime'] ~= stackData['expirationTime']
or state['duration'] ~= stackData['duration']
or state['stacks'] ~= stackData['targetCount'] then
state['expirationTime'] = stackData['expirationTime']
state['duration'] = stackData['duration']
state['stacks'] = stackData['targetCount']
state['changed'] = true
changed = true
end
end
end
return changed
end