-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinsanityBar.lua
105 lines (90 loc) · 3.45 KB
/
insanityBar.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
-- init
aura_env.generators = {
[73510] = 4, -- Mind Spike
[407466] = 6, -- Mind Spike: Insanity
[8092] = 6, -- Mind Blast
[34914] = 4, -- Vampiric Touch
[375901] = 10, -- Mindgames
[120644] = 10, -- Halo
[391109] = 30, -- Dark Ascension
[32375] = 4, -- Mass Dispel
}
-- TSU: UNIT_SPELLCAST_START:player, UNIT_SPELLCAST_STOP:player, UNIT_POWER_FREQUENT:player, UNIT_MAXPOWER:player, STATUS
function(allstates, event, ...)
local state = allstates[""]
if state == nil then
state = {
["show"] = true,
["progressType"] = "static",
["additionalProgress"] = {
[1] = {
["direction"] = "forward",
["width"] = 0
}
},
["castingGain"] = 0
}
allstates[""] = state
end
if event == "STATUS" or event == "UNIT_MAXPOWER" then
state["total"] = UnitPowerMax("player", Enum.PowerType.Insanity)
state["value"] = UnitPower("player", Enum.PowerType.Insanity)
state["valueDeficit"] = state["total"] - state["value"]
state["valueAfterCast"] = math.min(
state["value"] + state["castingGain"],
state["total"])
state["valueDeficitAfterCast"] = (state["total"]
- state["valueAfterCast"])
state["changed"] = true
return true
elseif event == "UNIT_POWER_FREQUENT" then
local powerType = select(2, ...)
if powerType ~= "INSANITY" then
return false
end
state["value"] = UnitPower("player", Enum.PowerType.Insanity)
state["valueDeficit"] = state["total"] - state["value"]
state["valueAfterCast"] = math.min(
state["value"] + state["castingGain"],
state["total"])
state["valueDeficitAfterCast"] = (state["total"]
- state["valueAfterCast"])
state["changed"] = true
return true
elseif event == "UNIT_SPELLCAST_STOP" then
if 0 == state["castingGain"] then
return false
end
state["castingGain"] = 0
state["additionalProgress"][1]["width"] = 0
state["valueAfterCast"] = state["value"]
state["valueDeficitAfterCast"] = (state["total"]
- state["valueAfterCast"])
state["changed"] = true
return true
elseif event == "UNIT_SPELLCAST_START" then
local spellId = select(3, ...)
local castingGain = aura_env.generators[spellId]
if castingGain == nil then
return false
end
state["castingGain"] = castingGain
state["additionalProgress"][1]["width"] = castingGain
state["valueAfterCast"] = math.min(state["value"] + castingGain,
state["total"])
state["valueDeficitAfterCast"] = (state["total"]
- state["valueAfterCast"])
state["changed"] = true
return true
end
end
-- custom variables
{
["value"] = true,
["total"] = true,
["additionalProgress"] = 1,
["castingGain"] = "number",
["valueDeficit"] = "number",
["valueAfterCast"] = "number",
["valueDeficitAfterCast"] = "number"
}