-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharcaneMana.lua
80 lines (64 loc) · 2.27 KB
/
arcaneMana.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
-- Show a mana bar, but add additional fields and an overlay for the cost of
-- Arcane Blast at max Arcane Charges.
-- TSU: TRIGGER:1, TRAIT_TREE_CURRENCY_INFO_UPDATED, PLAYER_LEVEL_CHANGED
function(allstates, event, ...)
local state = allstates['']
if event == 'TRIGGER' then
if state == nil then
-- Alias to the other trigger's state table.
local _, triggerStates = ...
state = triggerStates['']
allstates[''] = state
state['additionalProgress'] = {
[1] = {
['direction'] = 'backward',
}
}
if aura_env.baseCost ~= nil then
state['baseCost'] = aura_env.baseCost
state['maxCost'] = aura_env.maxCost
state['additionalProgress'][1]['width'] = aura_env.maxCost
end
end
if state['maxCost'] ~= nil then
state['maxPercentCost'] = state['maxCost'] / state['total'] * 100
end
state['changed'] = true
return true
else
local currentCost = nil
local currentCosts = C_Spell.GetSpellPowerCost(30451)
for i = 1, #currentCosts do
if currentCosts[i].type == Enum.PowerType.Mana then
currentCost = currentCosts[i].cost
break
end
end
if currentCost == nil then
return false
end
local currentCharges = UnitPower('player', Enum.PowerType.ArcaneCharges)
local maxCharges = UnitPowerMax('player', Enum.PowerType.ArcaneCharges)
local baseCost = currentCost / (currentCharges + 1)
local maxCost = baseCost * (maxCharges + 1)
if state ~= nil then
state['changed'] = true
state['baseCost'] = baseCost
state['maxCost'] = maxCost
state['maxPercentCost'] = maxCost / state['total'] * 100
state['additionalProgress'][1]['width'] = maxCost
return true
else
aura_env.baseCost = baseCost
aura_env.maxCost = maxCost
return false
end
end
end
-- custom variables
{
['additionalProgress'] = 1,
['baseCost'] = 'number',
['maxCost'] = 'number',
['maxPercentCost'] = 'number',
}