-
Notifications
You must be signed in to change notification settings - Fork 0
/
RogueDamage.lua
executable file
·308 lines (259 loc) · 5.94 KB
/
RogueDamage.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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
-- DEBUG TOOL
local function printTable(table, indent)
indent = indent or 0
local indentStr = string.rep(" ", indent)
for key, value in pairs(table) do
if type(value) == "table" then
print(indentStr .. key .. ":")
printTable(value, indent + 4)
else
print(indentStr .. key .. ": " .. tostring(value))
end
end
end
local spellReqs = {}
spellReqs["Backstab"] = function()
return true
end
spellReqs["Sinister Strike"] = function()
return true
end
spellReqs["Eviscerate"] = function()
return true
end
spellReqs["Ambush"] = function()
return IsStealthed()
end
spellReqs["Ghostly Strike"] = function()
return true
end
spellReqs["Riposte"] = function()
return true
end
spellReqs["Garrote"] = function()
return IsStealthed()
end
spellReqs["Rupture"] = function()
return true
end
local spells = {}
local getBaseDamage = function()
local low, high = UnitDamage("player")
local baseDamage = (low + high) / 2
return baseDamage
end
spells["Sinister Strike"] = function(id, baseDamage)
-- 1752
local desc = GetSpellDescription(id)
local addDamage = tonumber(string.match(desc, "%d+"))
local dmg = math.floor(baseDamage + addDamage)
return {
dmg,
dmg,
dmg,
dmg,
dmg,
dmg,
}
end
spells["Eviscerate"] = function(id)
-- 2098
local desc = GetSpellDescription(id)
local list = { 0 }
for line in string.gmatch(desc, "[^\n]+") do
local min = string.match(line, "(%d+)-%d+")
local max = string.match(line, "%d+-(%d+)")
if min ~= nil then
local avg = math.floor((tonumber(min) + tonumber(max)) / 2)
table.insert(list, avg)
end
end
return list
end
spells["Riposte"] = function()
local dmg = math.floor(baseDamage * 1.5)
return {
dmg,
dmg,
dmg,
dmg,
dmg,
dmg,
}
end
spells["Backstab"] = function(id, baseDamage)
-- 53
local desc = GetSpellDescription(id)
local addDamage = tonumber(string.match(desc, "plus (%d+)"))
local dmg = math.floor(baseDamage * 1.5 + addDamage)
return {
dmg,
dmg,
dmg,
dmg,
dmg,
dmg,
}
end
spells["Ambush"] = function(id, baseDamage)
-- 8676
local desc = GetSpellDescription(id)
local addDamage = tonumber(string.match(desc, "plus (%d+)"))
local dmg = math.floor(baseDamage * 2.5 + addDamage)
return {
dmg,
dmg,
dmg,
dmg,
dmg,
dmg,
}
end
spells["Ghostly Strike"] = function(_, baseDamage)
-- 14278
local dmg = math.floor(baseDamage * 1.5)
return {
dmg,
dmg,
dmg,
dmg,
dmg,
dmg,
}
end
spells["Garrote"] = function(id)
-- 703
local desc = GetSpellDescription(id)
local dmg = tonumber(string.match(desc, "causing (%d+)"))
return {
dmg,
0,
0,
0,
0,
0,
}
end
spells["Rupture"] = function(id)
-- 1943
local desc = GetSpellDescription(id)
local list = { 0 }
for line in string.gmatch(desc, "[^\n]+") do
local dmg = string.match(line, ": (%d+)")
table.insert(list, dmg)
end
return list
end
local function getSpellList()
local dmgList = {}
local function shouldParse(name)
for spell in pairs(spells) do
if spell == name then
return true
end
end
return false
end
-- Cycle through all spells in spellbook
for rank = 1, GetNumSpellTabs() do
local _, _, offset, numSpells = GetSpellTabInfo(rank)
for i = offset + 1, offset + numSpells do
local spellType, _, dbSpellId = GetSpellBookItemName(i, "spell")
local baseDamage = getBaseDamage()
if shouldParse(spellType) then
dmgList[spellType] = {
spells[spellType](dbSpellId, baseDamage),
}
end
end
end
return dmgList
end
-- DISPLAY CALCS
local function createPrintList()
local currentDamage = {}
local comboPoints = GetComboPoints("player", "target")
local dmgList = getSpellList()
for key, _ in pairs(dmgList) do
local spellDmg = dmgList[key][1][comboPoints + 1]
local spellPos = dmgList[key][2]
currentDamage[key] = { spellDmg, spellPos }
end
return currentDamage
end
local fontPath = "Fonts\\FRIZQT__.TTF"
local frames = {}
for key, _ in pairs(spells) do
frames[key] = CreateFrame("Frame", key, UIParent)
frames[key]:SetWidth(32)
frames[key]:SetHeight(32)
frames[key]:SetPoint("CENTER", 0, 0)
frames[key]:SetMovable(true)
frames[key]:EnableMouse(true)
frames[key]:RegisterForDrag("RightButton")
frames[key]:SetScript("OnDragStart", function(self)
self:StartMoving()
end)
frames[key]:SetScript("OnDragStop", function(self)
self:StopMovingOrSizing()
end)
local text = frames[key]:CreateFontString(nil, "OVERLAY")
text:SetPoint("CENTER", 0, 32)
text:SetFont(fontPath, 16)
frames[key].text = text
end
local printLines = function()
local className = UnitClass("player")
if className ~= "Rogue" then
frames.List:Hide()
return
end
local targetHealth = UnitHealth("target")
local printList = createPrintList()
for key, value in pairs(printList) do
local texture = frames[key]:CreateTexture(nil, "BACKGROUND")
texture:SetAllPoints(true)
if spellReqs[key]() then
frames[key]:Show()
else
frames[key]:Hide()
end
-- Get the spell texture (icon)
local spellTexture = GetSpellTexture(key)
if spellTexture then
texture:SetTexture(spellTexture)
end
frames[key].text:SetText(value[1])
if value[1] >= targetHealth and targetHealth > 0 then
frames[key].text:SetTextColor(0, 1, 0)
else
frames[key].text:SetTextColor(1, 1, 1)
end
local comboPoints = GetComboPoints("player", "target")
if comboPoints == 5 then
frames[key].text:SetFont(fontPath, 24)
else
frames[key].text:SetFont(fontPath, 16)
end
end
end
local comboTracker = CreateFrame("FRAME")
comboTracker:RegisterEvent("UNIT_POWER_UPDATE")
comboTracker:SetScript("OnEvent", function()
printLines()
end)
local colorAdjust = CreateFrame("FRAME")
colorAdjust:RegisterEvent("UNIT_HEALTH")
colorAdjust:SetScript("OnEvent", function()
printLines()
end)
local targetChange = CreateFrame("FRAME")
targetChange:RegisterEvent("PLAYER_TARGET_CHANGED")
targetChange:SetScript("OnEvent", function()
printLines()
end)
local stealthCheck = CreateFrame("FRAME")
stealthCheck:RegisterEvent("UPDATE_STEALTH")
stealthCheck:SetScript("OnEvent", function()
printLines()
end)