-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.cata.lua
216 lines (171 loc) · 7.91 KB
/
config.cata.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
local addonName, ns = ...
local UnitPower = UnitPower
local APILevel = ns.APILevel
local GetSpecialization = APILevel == 4 and function() return 1 end or _G.GetSpecialization
local IsAnySpellKnown = ns.IsAnySpellKnown
local GetSpell = ns.GetSpell
local GetPowerBy5 = ns.GetPowerBy5
local UNIT_HEALTH_EXECUTE = ns.UNIT_HEALTH_EXECUTE
local UNIT_HEALTH_EXECUTE_PLAYER_TARGET_CHANGED = ns.UNIT_HEALTH_EXECUTE_PLAYER_TARGET_CHANGED
local MakeGeneralGetPower = ns.MakeGeneralGetPower
local GENERAL_UNIT_POWER_UPDATE = ns.GENERAL_UNIT_POWER_UPDATE
local FILTERED_UNIT_POWER_UPDATE = ns.FILTERED_UNIT_POWER_UPDATE
local GENERAL_UNIT_MAXPOWER = ns.GENERAL_UNIT_MAXPOWER
local GENERAL_UPDATE_STEALTH = ns.GENERAL_UPDATE_STEALTH
local FindAura = ns.FindAura
if APILevel == 4 then
-- ROGUE
NugEnergy:RegisterConfig("EnergyRogue", {
triggers = { GetSpecialization },
setup = function(self, spec)
self:SetPowerFilter("ENERGY", Enum.PowerType.Energy)
self:SetNormalColor()
self.flags.shouldBeFull = true
self.eventProxy:RegisterEvent("UPDATE_STEALTH")
self.eventProxy.UPDATE_STEALTH = GENERAL_UPDATE_STEALTH
self.eventProxy:RegisterUnitEvent("UNIT_MAXPOWER", "player")
self.eventProxy.UNIT_MAXPOWER = GENERAL_UNIT_MAXPOWER
GENERAL_UNIT_MAXPOWER(self)
self.eventProxy:RegisterUnitEvent("UNIT_POWER_UPDATE", "player")
self.eventProxy.UNIT_POWER_UPDATE = FILTERED_UNIT_POWER_UPDATE("ENERGY")
self.eventProxy:RegisterUnitEvent("UNIT_POWER_FREQUENT", "player")
self.eventProxy.UNIT_POWER_FREQUENT = FILTERED_UNIT_POWER_UPDATE("ENERGY")
self:SetPowerGetter(MakeGeneralGetPower(Enum.PowerType.Energy, nil, 5, nil, true))
end,
}, "ROGUE")
-- WARRIOR
NugEnergy:RegisterConfig("RageWarrior", {
triggers = { GetSpecialization },
setup = function(self, spec)
self:ApplyConfig("GeneralRage")
if IsAnySpellKnown(5308) then
self.eventProxy:RegisterUnitEvent("UNIT_HEALTH", "target")
self.eventProxy.UNIT_HEALTH = UNIT_HEALTH_EXECUTE(0.2)
self.eventProxy:RegisterEvent("PLAYER_TARGET_CHANGED")
self.eventProxy.PLAYER_TARGET_CHANGED = UNIT_HEALTH_EXECUTE_PLAYER_TARGET_CHANGED
end
self:SetPowerGetter(MakeGeneralGetPower(Enum.PowerType.Rage, 30, 10, nil, nil))
end,
}, "WARRIOR")
-- DRUID
NugEnergy:RegisterConfig("RageDruid", {
triggers = { GetSpecialization },
setup = function(self, spec)
self:ApplyConfig("GeneralRage")
self:SetPowerGetter(MakeGeneralGetPower(Enum.PowerType.Rage, 30, 10, nil, nil))
end,
}, "DRUID")
local MakeBalanceGetPower = function(...)
local normalGetPower = MakeGeneralGetPower(...)
local math_abs = math.abs
local GetEclipseDirection = _G.GetEclipseDirection
return function(unit)
local p, p2, execute, shine, capped, insufficient = normalGetPower(unit)
local isSolar = p >= 0
local isEclipse = false
local directionPrefix = ""
if isSolar then
NugEnergy:SetColorOverride(1,0.7,0.3)
if FindAura("player", 48517, "HELPFUL") then
isEclipse = true
end
if GetEclipseDirection() == "sun" then
directionPrefix = ">"
elseif GetEclipseDirection() == "moon" then
directionPrefix = "<"
end
else
NugEnergy:SetColorOverride(0.3,0.52,0.9)
if FindAura("player", 48518, "HELPFUL") then
isEclipse = true
end
if GetEclipseDirection() == "sun" then
directionPrefix = "<"
elseif GetEclipseDirection() == "moon" then
directionPrefix = ">"
end
end
p = math_abs(p)
p2 = directionPrefix..p
return p, p2, execute, shine, not isEclipse, insufficient, isSolar
end
end
NugEnergy:RegisterConfig("DruidBalanceCata", {
triggers = { GetSpecialization },
setup = function(self, spec)
self:SetPowerFilter("BALANCE", Enum.PowerType.Balance)
self:SetColorOverride(0,1,0)
self.eventProxy:RegisterUnitEvent("UNIT_MAXPOWER", "player")
self.eventProxy.UNIT_MAXPOWER = GENERAL_UNIT_MAXPOWER
GENERAL_UNIT_MAXPOWER(self)
self.eventProxy:RegisterUnitEvent("UNIT_POWER_UPDATE", "player")
self.eventProxy.UNIT_POWER_UPDATE = FILTERED_UNIT_POWER_UPDATE("BALANCE")
self:SetPowerGetter(MakeBalanceGetPower(Enum.PowerType.Balance, 0, 10, nil, nil))
end,
}, "DRUID")
NugEnergy:RegisterConfig("ShapeshiftDruid", {
triggers = { GetSpecialization },
setup = function(self, spec)
self:RegisterEvent("UNIT_DISPLAYPOWER") -- Registering on main addon, not event proxy
self.UNIT_DISPLAYPOWER = function(self)
local newPowerType = select(2,UnitPowerType("player"))
self:ResetConfig()
if newPowerType == "ENERGY" then
self:Enable()
self:ApplyConfig("EnergyRogue")
if APILevel == 2 and self.ticker then
self.ticker:Reset()
end
self:Update()
elseif newPowerType == "RAGE" then
self:Enable()
self:ApplyConfig("RageDruid")
self:Update()
elseif IsPlayerSpell(78674) then -- Starsurge / Balance Spec trigger
self:Enable()
self:ApplyConfig("DruidBalanceCata")
self:Update()
-- elseif newPowerType == "MANA" then
-- self:ApplyConfig("GeneralFSRMana")
-- self:Update()
else
self:Disable()
end
end
self.UNIT_DISPLAYPOWER(self)
end
}, "DRUID")
-- HUNTER
NugEnergy:RegisterConfig("Focus", {
triggers = { GetSpecialization },
setup = function(self, spec)
self:SetPowerFilter("FOCUS", Enum.PowerType.Focus)
self:SetNormalColor()
self.flags.shouldBeFull = true
self.eventProxy:RegisterEvent("UPDATE_STEALTH")
self.eventProxy.UPDATE_STEALTH = GENERAL_UPDATE_STEALTH
self.eventProxy:RegisterUnitEvent("UNIT_MAXPOWER", "player")
self.eventProxy.UNIT_MAXPOWER = GENERAL_UNIT_MAXPOWER
GENERAL_UNIT_MAXPOWER(self)
self.eventProxy:RegisterUnitEvent("UNIT_POWER_UPDATE", "player")
self.eventProxy.UNIT_POWER_UPDATE = FILTERED_UNIT_POWER_UPDATE("FOCUS")
self.eventProxy:RegisterUnitEvent("UNIT_POWER_FREQUENT", "player")
self.eventProxy.UNIT_POWER_FREQUENT = FILTERED_UNIT_POWER_UPDATE("FOCUS")
self:SetPowerGetter(MakeGeneralGetPower(Enum.PowerType.Focus, nil, 5, nil, true))
end,
}, "HUNTER")
-- DEATH KNIGHT
NugEnergy:RegisterConfig("RunicPower", {
triggers = { GetSpecialization },
setup = function(self, spec)
self:SetPowerFilter("RUNIC_POWER", Enum.PowerType.RunicPower)
self:SetNormalColor()
self.eventProxy:RegisterUnitEvent("UNIT_MAXPOWER", "player")
self.eventProxy.UNIT_MAXPOWER = GENERAL_UNIT_MAXPOWER
GENERAL_UNIT_MAXPOWER(self)
self.eventProxy:RegisterUnitEvent("UNIT_POWER_UPDATE", "player")
self.eventProxy.UNIT_POWER_UPDATE = FILTERED_UNIT_POWER_UPDATE("RUNIC_POWER")
self:SetPowerGetter(MakeGeneralGetPower(Enum.PowerType.RunicPower, 30, 10, nil, nil))
end,
}, "DEATHKNIGHT")
end