-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
helpers.lua
198 lines (173 loc) · 5.49 KB
/
helpers.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
local addonName, ns = ...
local frame = CreateFrame("Frame")
frame:SetScript("OnEvent", function(self, event, ...)
return self[event](self, event, ...)
end)
frame:RegisterEvent("SPELLS_CHANGED")
local isClassic = select(4,GetBuildInfo()) <= 19999
local GetSpecialization = isClassic and function() return 1 end or _G.GetSpecialization
local ranges
local function SimplePercentCheck(threshold)
return function(p, unit, cur, max)
return p < threshold
end
end
local function CondemnExecute()
local isMassacre = IsPlayerSpell(281001) or IsPlayerSpell(206315) -- arms, fury massacres
local lowT = isMassacre and 0.35 or 0.2
local isCondemn = IsPlayerSpell(317320) or IsPlayerSpell(317485) -- arms/prot, fury condemn
local highT = isCondemn and 0.8 or 1
return function(p, unit, cur, max)
return p < lowT or p > highT
end
end
local function TouchOfDeath()
local pressurePoints = IsPlayerSpell(287599)
return function(p, unit, cur, max)
if pressurePoints and UnitIsPlayer(unit) then
return p < 0.1
else
-- local playerMaxHealth = UnitHealthMax("player")
-- local isWeak = max < playerMaxHealth
-- if isWeak then
-- return true
-- else
return p < 0.15
-- end
end
end
end
local function Wrap(func)
return function()
return func
end
end
if isClassic then
local IsAnySpellKnown = function (...)
for i=1, select("#", ...) do
local spellID = select(i, ...)
if not spellID then break end
if IsPlayerSpell(spellID) then return spellID end
end
end
ranges = {
WARRIOR = {
function() return IsAnySpellKnown(20662, 20661, 20660, 20658, 5308) and SimplePercentCheck(0.2) end,
},
PALADIN = {
function() return IsAnySpellKnown(24275, 24274, 24239) and SimplePercentCheck(0.2) end,
},
}
else
ranges = {
WARRIOR = {
CondemnExecute, CondemnExecute, CondemnExecute,
},
ROGUE = {
function() return IsPlayerSpell(328085) and SimplePercentCheck(0.35) end, -- blindside
},
WARLOCK = {
function() return IsPlayerSpell(198590) and SimplePercentCheck(0.20) end, -- drain soul
},
PRIEST = {
Wrap(SimplePercentCheck(0.20)), Wrap(SimplePercentCheck(0.20)), Wrap(SimplePercentCheck(0.20)),
},
PALADIN = {
Wrap(SimplePercentCheck(0.20)), Wrap(SimplePercentCheck(0.20)), Wrap(SimplePercentCheck(0.20)),
},
HUNTER = {
Wrap(SimplePercentCheck(0.20)), Wrap(SimplePercentCheck(0.20)), Wrap(SimplePercentCheck(0.20)),
},
MONK = {
Wrap(SimplePercentCheck(0.15)), Wrap(SimplePercentCheck(0.15)), Wrap(SimplePercentCheck(0.15)),
},
}
end
function frame:SPELLS_CHANGED()
local class = select(2, UnitClass("player"))
local spec = GetSpecialization()
if not spec then ns.UpdateExecute(nil); return end
local classopts = ranges[class]
local range
if classopts then
range = classopts[spec]
if range then
range = range()
end
end
ns.UpdateExecute(range)
end
-- local function SetupDefaults(t, defaults)
-- if not defaults then return end
-- for k,v in pairs(defaults) do
-- if type(v) == "table" then
-- if t[k] == nil then
-- t[k] = CopyTable(v)
-- elseif t[k] == false then
-- t[k] = false --pass
-- else
-- SetupDefaults(t[k], v)
-- end
-- else
-- if t[k] == nil then t[k] = v end
-- end
-- end
-- end
-- local function RemoveDefaults(t, defaults)
-- if not defaults then return end
-- for k, v in pairs(defaults) do
-- if type(t[k]) == 'table' and type(v) == 'table' then
-- RemoveDefaults(t[k], v)
-- if next(t[k]) == nil then
-- t[k] = nil
-- end
-- elseif t[k] == v then
-- t[k] = nil
-- end
-- end
-- return t
-- end
-- local defaults = {
-- }
-- function frame:PLAYER_LOGIN()
-- _G.oUF_NugAnchorsDB = _G.oUF_NugAnchorsDB or {}
-- oUF_NugAnchorsDB = _G.oUF_NugAnchorsDB
-- SetupDefaults(oUF_NugAnchorsDB, defaults)
-- end
-- function frame:PLAYER_LOGOUT()
-- RemoveDefaults(oUF_NugAnchorsDB, defaults)
-- end
-- function frame:CreateAnchor(db_tbl)
-- local f = CreateFrame("Frame", "NugStatsAnchor",UIParent)
-- f:SetHeight(20)
-- f:SetWidth(20)
-- f:EnableMouse(true)
-- f:SetMovable(true)
-- f:Hide()
-- local t = f:CreateTexture(nil,"BACKGROUND")
-- t:SetTexture("Interface\\Buttons\\UI-RadioButton")
-- t:SetTexCoord(0,0.25,0,1)
-- t:SetAllPoints(f)
-- t = f:CreateTexture(nil,"BACKGROUND")
-- t:SetTexture("Interface\\Buttons\\UI-RadioButton")
-- t:SetTexCoord(0.25,0.49,0,1)
-- t:SetVertexColor(1, 0, 0)
-- t:SetAllPoints(f)
-- f.db_tbl = db_tbl
-- f:SetScript("OnMouseDown",function(self)
-- self:StartMoving()
-- end)
-- f:SetScript("OnMouseUp",function(self)
-- local opts = self.db_tbl
-- self:StopMovingOrSizing();
-- local point,_,to,x,y = self:GetPoint(1)
-- opts.point = point
-- opts.parent = "UIParent"
-- opts.to = to
-- opts.x = x
-- opts.y = y
-- end)
-- local pos = f.db_tbl
-- f:SetPoint(pos.point, pos.parent, pos.to, pos.x, pos.y)
-- return f
-- end