-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDr.lua
448 lines (377 loc) · 14.8 KB
/
Dr.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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
local TEST_MODE = false;
local RESET = 18.5;
local DURATIONS = { 1.0, 0.5, 0.25 };
local CATEGORY_ROOT = 1;
local CATEGORY_STUN = 2;
local CATEGORY_INCAPACITATE = 3;
local CATEGORY_DISORIENT = 4;
local CATEGORY_SILENCE = 5;
-- iterator support (category ids must be continous)
local MIN_CATEGORY = CATEGORY_ROOT;
local MAX_CATEGORY = CATEGORY_SILENCE;
-- description
local CATEGORY = {};
CATEGORY[CATEGORY_ROOT] = "root";
CATEGORY[CATEGORY_STUN] = "stun";
CATEGORY[CATEGORY_INCAPACITATE] = "incapacitate";
CATEGORY[CATEGORY_DISORIENT] = "disorient";
CATEGORY[CATEGORY_SILENCE] = "silence";
-- DrUnit
local DrUnit;
do
-- imports
local kCore = kCore;
-- private
local GetInfo = function(self, category, create)
local info = self.store[category];
if (info == nil) then
if (not create) then
return nil;
end
info = {
category = category,
index = 1,
coeff = DURATIONS[1],
updated = 0,
expires = 0
};
self.store[category] = info;
else
if (info.updated + RESET < GetTime()) then
info.index = 1;
info.coeff = DURATIONS[1];
info.updated = 0;
info.expires = 0;
end
end
return info;
end
-- public
local Activate = function(self, category, icon)
assert(type(category) == "number", "Category must be a number");
local info = GetInfo(self, category, true);
info.index = info.index + 1;
info.coeff = DURATIONS[info.index] or 0;
info.updated = GetTime();
info.expires = info.updated + RESET;
info.icon = icon;
return info.coeff, info.expires, RESET, info.icon;
end
local Get = function(self, category)
assert(type(category) == "number", "Category must be a number");
local info = GetInfo(self, category, false);
if (info ~= nil and info.coeff ~= DURATIONS[1]) then
return info.coeff, info.expires, RESET, info.icon;
else
return nil;
end
end
-- ctor
local ctor = function(self, baseCtor, guid)
assert(type(guid) == "string", "Guid must be a string");
self.guid = guid;
self.store = {};
end
-- main
DrUnit = kCore.CreateClass(ctor, {
Activate = Activate,
Get = Get
}, nil);
end
-- kDr
do
-- imports
local kCore = kCore;
local COMBATLOG_OBJECT_TYPE_PLAYER = COMBATLOG_OBJECT_TYPE_PLAYER;
local COMBATLOG_OBJECT_CONTROL_PLAYER = COMBATLOG_OBJECT_CONTROL_PLAYER;
-- private
local auras = {};
local store = {};
local GetInfo = function(guid, create)
local info = store[guid];
if (info == nil) then
if (not create) then
return nil;
end
info = DrUnit(guid);
store[guid] = info;
end
return info;
end
local AuraFaded = function(aura, unitGuid, unitName)
local info = GetInfo(unitGuid, true);
local nextCoeff, expires = info:Activate(aura.category, aura.icon);
if (TEST_MODE) then
print(unitName .. " " .. CATEGORY[aura.category] .. " coeff=" .. nextCoeff .. " expires=" .. expires);
end
end
local IteratorInternal = function(guid, category)
for category = category + 1, MAX_CATEGORY, 1 do
local coeff, expires, duration, icon = kDr.Get(guid, category);
if (coeff ~= nil) then
return category, coeff, expires, duration, icon;
end
end
return nil;
end
-- events
kEvents.RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED", function(_, timeStamp, event, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, ...)
-- todo: apply event
local isFadeEvent = event == "SPELL_AURA_REFRESH" or event == "SPELL_AURA_REMOVED" or event == "SPELL_AURA_BROKEN";
local isApplyEvent = false or event == "SPELL_AURA_REFRESH" or event == "SPELL_AURA_APPLIED";
if (not isFadeEvent and not isApplyEvent) then
return;
end
local isPlayer = bit.band(destFlags, COMBATLOG_OBJECT_TYPE_PLAYER) == COMBATLOG_OBJECT_TYPE_PLAYER or
bit.band(destFlags, COMBATLOG_OBJECT_CONTROL_PLAYER) == COMBATLOG_OBJECT_CONTROL_PLAYER;
if (not isPlayer) then
return;
end
local spellId, spellName, spellSchool, auraType, amount = ...;
if (auraType ~= "DEBUFF" and not TEST_MODE) then
return;
end
local info = auras[spellId];
if (not info) then
return;
end
-- -- debug start
-- if (destGUID ~= UnitGUID("player")) then
-- return;
-- end
-- print(time(), event);
-- -- debug end
if (isFadeEvent) then
AuraFaded(info, destGUID, destName);
end
-- if (isApplyEvent) then
-- AuraApplied(info, destGUID, destName, duration);
-- end
end);
-- public
local RegisterAura = function(category, id)
assert(type(category) == "number", "Category must be a number");
assert(type(id) == "number", "Handler must be a number");
local name, rank, icon, _, _, _, _ = GetSpellInfo(id);
auras[id] = {
id = id,
name = name,
icon = icon,
category = category
};
end
local Get = function(guid, category)
assert(type(guid) == "string", "Guid must be a string");
assert(type(category) == "number", "Guid must be a number");
local info = GetInfo(guid, true);
if (not info) then
return nil;
else
return info:Get(category);
end
end
local Iterator = function(guid)
return IteratorInternal, guid, MIN_CATEGORY - 1;
end
local Test = function(unit)
unit = unit or "player";
local aura;
for _, v in pairs(auras) do
aura = v;
break;
end
AuraFaded(aura, UnitGUID(unit), UnitName(unit));
end
-- class
kDr = {
CATEGORY_ROOT = CATEGORY_ROOT,
CATEGORY_STUN = CATEGORY_STUN,
CATEGORY_INCAPACITATE = CATEGORY_INCAPACITATE,
CATEGORY_DISORIENT = CATEGORY_DISORIENT,
CATEGORY_SILENCE = CATEGORY_SILENCE,
RegisterAura = RegisterAura,
Get = Get,
Iterator = Iterator,
Test = Test
};
end
-- data import
do
--[[ INCAPACITATES ]]--
-- Druid
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 99); -- Incapacitating Roar (talent)
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 203126); -- Maim (with blood trauma pvp talent)
-- Hunter
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 3355); -- Freezing Trap
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 19386); -- Wyvern Sting
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 209790); -- Freezing Arrow
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 213691); -- Scatter Shot
-- Mage
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 118); -- Polymorph
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 28272); -- Polymorph (pig)
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 28271); -- Polymorph (turtle)
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 61305); -- Polymorph (black cat)
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 61721); -- Polymorph (rabbit)
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 61780); -- Polymorph (turkey)
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 126819); -- Polymorph (procupine)
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 161353); -- Polymorph (bear cub)
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 161354); -- Polymorph (monkey)
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 161355); -- Polymorph (penguin)
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 161372); -- Polymorph (peacock)
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 82691); -- Ring of Frost
-- Monk
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 115078); -- Paralysis
-- Paladin
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 20066); -- Repentance
-- Priest
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 605); -- Mind Control
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 9484); -- Shackle Undead
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 64044); -- Psychic Horror (Horror effect)
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 88625); -- Holy Word: Chastise
-- Rogue
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 1776); -- Gouge
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 6770); -- Sap
-- Shaman
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 51514); -- Hex
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 211004); -- Hex (spider)
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 210873); -- Hex (raptor)
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 211015); -- Hex (cockroach)
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 211010); -- Hex (snake)
-- Warlock
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 710); -- Banish
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 6789); -- Mortal Coil
-- Pandaren
kDr.RegisterAura(kDr.CATEGORY_INCAPACITATE, 107079); -- Quaking Palm
--[[ SILENCES ]]--
-- Death Knight
kDr.RegisterAura(kDr.CATEGORY_SILENCE, 47476); -- Strangulate
-- Demon Hunter
kDr.RegisterAura(kDr.CATEGORY_SILENCE, 204490); -- Sigil of Silence
-- Druid
-- Hunter
kDr.RegisterAura(kDr.CATEGORY_SILENCE, 202933); -- Spider Sting (pvp talent)
-- Mage
-- Paladin
kDr.RegisterAura(kDr.CATEGORY_SILENCE, 31935); -- Avenger's Shield
-- Priest
kDr.RegisterAura(kDr.CATEGORY_SILENCE, 15487); -- Silence
kDr.RegisterAura(kDr.CATEGORY_SILENCE, 199683); -- Last Word (SW: Death silence)
-- Rogue
kDr.RegisterAura(kDr.CATEGORY_SILENCE, 1330); -- Garrote
-- Blood Elf
kDr.RegisterAura(kDr.CATEGORY_SILENCE, 25046); -- Arcane Torrent (Energy version)
kDr.RegisterAura(kDr.CATEGORY_SILENCE, 28730); -- Arcane Torrent (Priest/Mage/Lock version)
kDr.RegisterAura(kDr.CATEGORY_SILENCE, 50613); -- Arcane Torrent (Runic power version)
kDr.RegisterAura(kDr.CATEGORY_SILENCE, 69179); -- Arcane Torrent (Rage version)
kDr.RegisterAura(kDr.CATEGORY_SILENCE, 80483); -- Arcane Torrent (Focus version)
kDr.RegisterAura(kDr.CATEGORY_SILENCE, 129597); -- Arcane Torrent (Monk version)
kDr.RegisterAura(kDr.CATEGORY_SILENCE, 155145); -- Arcane Torrent (Paladin version)
kDr.RegisterAura(kDr.CATEGORY_SILENCE, 202719); -- Arcane Torrent (DH version)
--[[ DISORIENTS ]]--
-- Death Knight
kDr.RegisterAura(kDr.CATEGORY_DISORIENT, 207167); -- Blinding Sleet (talent) -- FIXME: is this the right category?
-- Demon Hunter
kDr.RegisterAura(kDr.CATEGORY_DISORIENT, 207685); -- Sigil of Misery
-- Druid
kDr.RegisterAura(kDr.CATEGORY_DISORIENT, 33786); -- Cyclone
-- Hunter
kDr.RegisterAura(kDr.CATEGORY_DISORIENT, 186387); -- Bursting Shot
-- Mage
kDr.RegisterAura(kDr.CATEGORY_DISORIENT, 31661); -- Dragon's Breath
-- Monk
kDr.RegisterAura(kDr.CATEGORY_DISORIENT, 198909); -- Song of Chi-ji -- FIXME: is this the right category( tooltip specifically says disorient, so I guessed here)
kDr.RegisterAura(kDr.CATEGORY_DISORIENT, 202274); -- Incendiary Brew -- FIXME: is this the right category( tooltip specifically says disorient, so I guessed here)
-- Paladin
kDr.RegisterAura(kDr.CATEGORY_DISORIENT, 105421); -- Blinding Light -- FIXME: is this the right category? Its missing from blizzard's list
-- Priest
kDr.RegisterAura(kDr.CATEGORY_DISORIENT, 8122); -- Psychic Scream
-- Rogue
kDr.RegisterAura(kDr.CATEGORY_DISORIENT, 2094); -- Blind
-- Warlock
kDr.RegisterAura(kDr.CATEGORY_DISORIENT, 5782); -- Fear -- probably unused
kDr.RegisterAura(kDr.CATEGORY_DISORIENT, 118699); -- Fear -- new debuff ID since MoP
kDr.RegisterAura(kDr.CATEGORY_DISORIENT, 130616); -- Fear (with Glyph of Fear)
kDr.RegisterAura(kDr.CATEGORY_DISORIENT, 5484); -- Howl of Terror (talent)
kDr.RegisterAura(kDr.CATEGORY_DISORIENT, 115268); -- Mesmerize (Shivarra)
kDr.RegisterAura(kDr.CATEGORY_DISORIENT, 6358); -- Seduction (Succubus)
-- Warrior
kDr.RegisterAura(kDr.CATEGORY_DISORIENT, 5246); -- Intimidating Shout (main target)
--[[ STUNS ]]--
-- Death Knight
-- Abomination's Might note: 207165 is the stun, but is never applied to players,
-- so I haven't included it.
kDr.RegisterAura(kDr.CATEGORY_STUN, 108194); -- Asphyxiate (talent for unholy)
kDr.RegisterAura(kDr.CATEGORY_STUN, 221562); -- Asphyxiate (baseline for blood)
kDr.RegisterAura(kDr.CATEGORY_STUN, 91800); -- Gnaw (Ghoul)
kDr.RegisterAura(kDr.CATEGORY_STUN, 91797); -- Monstrous Blow (Dark Transformation Ghoul)
kDr.RegisterAura(kDr.CATEGORY_STUN, 207171); -- Winter is Coming (Remorseless winter stun)
-- Demon Hunter
kDr.RegisterAura(kDr.CATEGORY_STUN, 179057); -- Chaos Nova
kDr.RegisterAura(kDr.CATEGORY_STUN, 200166); -- Metamorphosis
kDr.RegisterAura(kDr.CATEGORY_STUN, 205630); -- Illidan's Grasp, primary effect
kDr.RegisterAura(kDr.CATEGORY_STUN, 208618); -- Illidan's Grasp, secondary effect
kDr.RegisterAura(kDr.CATEGORY_STUN, 211881); -- Fel Eruption
-- Druid
kDr.RegisterAura(kDr.CATEGORY_STUN, 203123); -- Maim
kDr.RegisterAura(kDr.CATEGORY_STUN, 5211); -- Mighty Bash
kDr.RegisterAura(kDr.CATEGORY_STUN, 163505); -- Rake (Stun from Prowl)
-- Hunter
kDr.RegisterAura(kDr.CATEGORY_STUN, 117526); -- Binding Shot
kDr.RegisterAura(kDr.CATEGORY_STUN, 24394); -- Intimidation
-- Mage
-- Monk
kDr.RegisterAura(kDr.CATEGORY_STUN, 119381); -- Leg Sweep
-- Paladin
kDr.RegisterAura(kDr.CATEGORY_STUN, 853); -- Hammer of Justice
-- Priest
kDr.RegisterAura(kDr.CATEGORY_STUN, 200200); -- Holy word: Chastise
kDr.RegisterAura(kDr.CATEGORY_STUN, 226943); -- Mind Bomb
-- Rogue
-- Shadowstrike note: 196958 is the stun, but it never applies to players,
-- so I haven't included it.
kDr.RegisterAura(kDr.CATEGORY_STUN, 1833); -- Cheap Shot
kDr.RegisterAura(kDr.CATEGORY_STUN, 408); -- Kidney Shot
kDr.RegisterAura(kDr.CATEGORY_STUN, 199804); -- Between the Eyes
-- Shaman
kDr.RegisterAura(kDr.CATEGORY_STUN, 118345); -- Pulverize (Primal Earth Elemental)
kDr.RegisterAura(kDr.CATEGORY_STUN, 118905); -- Static Charge (Capacitor Totem)
kDr.RegisterAura(kDr.CATEGORY_STUN, 204399); -- Earthfury (pvp talent)
-- Warlock
kDr.RegisterAura(kDr.CATEGORY_STUN, 89766); -- Axe Toss (Felguard)
kDr.RegisterAura(kDr.CATEGORY_STUN, 30283); -- Shadowfury
kDr.RegisterAura(kDr.CATEGORY_STUN, 22703); -- Summon Infernal
-- Warrior
kDr.RegisterAura(kDr.CATEGORY_STUN, 132168); -- Shockwave
kDr.RegisterAura(kDr.CATEGORY_STUN, 132169); -- Storm Bolt
-- Tauren
kDr.RegisterAura(kDr.CATEGORY_STUN, 20549); -- War Stomp
--[[ ROOTS ]]--
-- Death Knight
kDr.RegisterAura(kDr.CATEGORY_ROOT, 96294); -- Chains of Ice (Chilblains Root)
kDr.RegisterAura(kDr.CATEGORY_ROOT, 204085); -- Deathchill (pvp talent)
-- Druid
kDr.RegisterAura(kDr.CATEGORY_ROOT, 339); -- Entangling Roots
kDr.RegisterAura(kDr.CATEGORY_ROOT, 102359); -- Mass Entanglement (talent)
kDr.RegisterAura(kDr.CATEGORY_ROOT, 45334); -- Immobilized (wild charge, bear form)
-- Hunter
kDr.RegisterAura(kDr.CATEGORY_ROOT, 53148); -- Charge (Tenacity pet)
kDr.RegisterAura(kDr.CATEGORY_ROOT, 162480); -- Steel Trap
kDr.RegisterAura(kDr.CATEGORY_ROOT, 190927); -- Harpoon
kDr.RegisterAura(kDr.CATEGORY_ROOT, 200108); -- Ranger's Net
kDr.RegisterAura(kDr.CATEGORY_ROOT, 212638); -- tracker's net
kDr.RegisterAura(kDr.CATEGORY_ROOT, 201158); -- Super Sticky Tar (Expert Trapper, Hunter talent, Tar Trap effect)
-- Mage
kDr.RegisterAura(kDr.CATEGORY_ROOT, 122); -- Frost Nova
kDr.RegisterAura(kDr.CATEGORY_ROOT, 33395); -- Freeze (Water Elemental)
-- kDr.RegisterAura(kDr.CATEGORY_ROOT, 157997); -- Ice Nova -- since 6.1, ice nova doesn't DR with anything
kDr.RegisterAura(kDr.CATEGORY_ROOT, 228600); -- Glacial spike (talent)
-- Monk
kDr.RegisterAura(kDr.CATEGORY_ROOT, 116706); -- Disable
-- Priest
-- Shaman
kDr.RegisterAura(kDr.CATEGORY_ROOT, 64695); -- Earthgrab Totem
-- test
if (TEST_MODE) then
kDr.RegisterAura(kDr.CATEGORY_STUN, 194384); -- Atonement
end
end