-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvesperTotemBar.lua
216 lines (175 loc) · 6.34 KB
/
vesperTotemBar.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
-------------------------------------------------------------------------------
-- init
aura_env.healingSpells = {
[1064] = true, -- Chain Heal
[61295] = true, -- Riptide
[77472] = true, -- Healing Wave
[197995] = true, -- Wellspring
[73920] = true, -- Healing Rain
[8004] = true, -- Healing Surge
[73685] = true, -- Unleash Life
[108280] = true, -- Healing Tide Totem
[98008] = true, -- Spirit Link Totem
[207778] = true, -- Downpour
[320746] = true, -- Surge of Earth
[5394] = true, -- Healing Stream Totem
[108281] = true, -- Ancestral Guidance
[201764] = true, -- Recall Cloudburst Totem
[77130] = true, -- Purify Spirit
[312411] = true, -- Bag of Tricks (Vulpera racial)
}
aura_env.damageSpells = {
[51505] = true, -- Lava Burst
[188196] = true, -- Lightning Bolt
[188389] = true, -- Flame Shock
[188443] = true, -- Chain Lightning
[117014] = true, -- Elemental Blast
[320125] = true, -- Echoing Shock
[192222] = true, -- Liquid Magma Totem
[210714] = true, -- Icefury
[51490] = true, -- Thunderstorm
[61882] = true, -- Earthquake
[196840] = true, -- Frost Shock
[187874] = true, -- Crash Lightning
[17364] = true, -- Stormstrike
[60103] = true, -- Lava Lash
[333974] = true, -- Fire Nova
[196884] = true, -- Feral Lunge
[197214] = true, -- Sundering
[188089] = true, -- Earthen Spike
[73899] = true, -- Primal Strike
[8042] = true, -- Earth Shock
[342243] = true, -- Static Discharge
}
aura_env.healingCharges = 0
aura_env.damageCharges = 0
-------------------------------------------------------------------------------
-- TSU: UNIT_SPELLCAST_SUCCEEDED:player, PLAYER_TOTEM_UPDATE
function(allstates, event, ...)
if event == "UNIT_SPELLCAST_SUCCEEDED" then
local spellId = select(3, ...)
if spellId == 324386 then -- Vesper Totem
local expirationTime = GetTime() + 30
for i = 1, 6 do
local chargeType
local chargeNum
local sortIndex
if i < 4 then
chargeType = "damage"
chargeNum = i
sortIndex = -chargeNum
else
chargeType = "healing"
chargeNum = i - 3
sortIndex = chargeNum
end
local stateKey = chargeType .. chargeNum
local state = {
["show"] = true,
["changed"] = true,
["progressType"] = "timed",
["autoHide"] = true,
["expirationTime"] = expirationTime,
["duration"] = 30,
["index"] = sortIndex,
["chargeType"] = chargeType,
}
allstates[stateKey] = state
end
aura_env.healingCharges = 3
aura_env.damageCharges = 3
return true
elseif aura_env.healingCharges > 0 or aura_env.damageCharges > 0 then
if aura_env.healingSpells[spellId] then
if aura_env.healingCharges > 0 then
local index = "healing" .. aura_env.healingCharges
local state = allstates[index]
state.show = false
state.changed = true
aura_env.healingCharges = aura_env.healingCharges - 1
return true
end
elseif aura_env.damageSpells[spellId] then
if aura_env.damageCharges > 0 then
local index = "damage" .. aura_env.damageCharges
local state = allstates[index]
state.show = false
state.changed = true
aura_env.damageCharges = aura_env.damageCharges - 1
return true
end
end
return false
end
elseif event == "PLAYER_TOTEM_UPDATE"
and (aura_env.healingCharges > 0 or aura_env.damageCharges > 0) then
-- Check for "PLAYER_TOTEM_UPDATE" in case the player cancels the
-- totem.
local vesperTotemName = GetSpellInfo(324386)
for i = 1, MAX_TOTEMS do
local _, totemName = GetTotemInfo(i)
if totemName == vesperTotemName then
-- Vesper Totem is still active. Do nothing.
return false
end
end
-- Vesper Totem is inactive. Disable all of the states.
for index, state in pairs(allstates) do
state.show = false
state.changed = true
end
-- Clear the charge counters.
aura_env.healingCharges = 0
aura_env.damageCharges = 0
return true
end
end
-------------------------------------------------------------------------------
-- Custom Variables
{
["expirationTime"] = true,
["duration"] = true,
["chargeType"] = {
["display"] = "Charge Type",
["type"] = "select",
["values"] = {
["damage"] = "Damage",
["healing"] = "Healing",
},
},
}
-------------------------------------------------------------------------------
-- Custom Grow
function(positions, activeRegions)
-- This grow algorithm places each region such that damage charges "grow
-- right" from (0, 0), and healing charges "grow left" from (0, 0). Custom
-- Options can also reconfigure this algorithm to inverse the directions
-- and to grow vertically instead of horizontally.
local config = aura_env.child_envs[1].config
local growVertically = config.growVertically
local inverse = config.inverse
local spacing = config.spacing
for i, regionData in ipairs(activeRegions) do
local region = regionData.region
local index = region.state.index
if index == nil then
return
end
local sign = index > 0 and 1 or -1
if inverse then
index = -index
sign = -sign
end
if growVertically then
positions[i] = {
0,
(index - sign / 2) * (region:GetHeight() + spacing)
}
else
positions[i] = {
(index - sign / 2) * (region:GetWidth() + spacing),
0
}
end
end
end