-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathClassicSpellActivations.lua
1379 lines (1239 loc) · 46.6 KB
/
ClassicSpellActivations.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
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
local addonName, ns = ...
local f = CreateFrame("Frame", "ClassicSpellActivations") --, UIParent)
f:SetScript("OnEvent", function(self, event, ...)
return self[event](self, event, ...)
end)
local APILevel = math.floor(select(4,GetBuildInfo())/10000)
local UnitGUID = UnitGUID
local bit_band = bit.band
local CombatLogGetCurrentEventInfo = CombatLogGetCurrentEventInfo
local AFFILIATION_MINE = COMBATLOG_OBJECT_AFFILIATION_MINE
local _, class = UnitClass("player")
ns.configs = {}
local procCombatLog
local registeredFrames = {}
local activations = {}
local LocalizedOverpower = GetSpellInfo(7384)
local LocalizedRevenge = GetSpellInfo(6572)
local LocalizedRampage = GetSpellInfo(29801)
local LocalizedSlam = GetSpellInfo(1464)
local LocalizedRiposte = GetSpellInfo(14251)
local LocalizedCounterattack = GetSpellInfo(19306)
-- local LocalizedExecute = GetSpellInfo(20662)
-- local LocalizedShadowBolt = GetSpellInfo(686)
local LocalizedMongooseBite = GetSpellInfo(1495)
local LocalizedEarthShock = GetSpellInfo(8042)
local LocalizedFlameShock = GetSpellInfo(8050)
local LocalizedFrostShock = GetSpellInfo(8056)
local LBG
local LCG
local spellNamesByID = {}
local reverseSpellRanks = {}
local function AddSpellName(name, ...)
local ranks = { ... }
local numArgs = #ranks
for i=1, #ranks do
local spellID = select(i, ...)
spellNamesByID[spellID] = name
end
reverseSpellRanks[name] = ranks
end
-- Wrath
-- Priest: Serendipity
-- Druid: Predatory Swiftness, Eclipses
-- DK: Frost procs
AddSpellName("VictoryRush", 34428 ) -- 402927 = Season of Discovery
AddSpellName("Overpower", 11585, 11584, 7887, 7384 ) -- 7384 - only Wrath rank
AddSpellName("Rampage", 30033, 30030, 29801 ) -- TBC only
AddSpellName("Slam", 1464, 8820, 11604, 11605, 25241, 25242, 47474, 47475)
AddSpellName("Riposte", 14251 )
AddSpellName("Counterattack", 27067, 20910, 20909, 19306 )
AddSpellName("KillCommand", 34026 )
AddSpellName("MongooseBite", 36916, 14271, 14270, 14269, 1495 )
AddSpellName("FrostShock", 49236, 49235, 25464, 10473, 10472, 8058, 8056)
AddSpellName("FlameShock", 49233, 49232, 29228, 25457, 10448, 10447, 8053, 8052, 8050)
AddSpellName("EarthShock", 49231, 49230, 25454, 10414, 10413, 10412, 8046, 8045, 8044, 8042)
AddSpellName("HammerOfWrath", 48806, 48805, 27180, 24239, 24274, 24275)
AddSpellName("Exorcism", 48801, 48800, 27138, 10314, 10313, 10312, 5615, 5614, 879)
AddSpellName("DivineStorm", 53385)
AddSpellName("ShadowBolt", 47809, 47808, 27209, 25307, 11661, 11660, 11659, 7641, 1106, 1088, 705, 695, 686)
AddSpellName("Incinerate", 47838, 47837, 32231, 29722)
AddSpellName("Execute", 47471, 47470, 25236, 25234, 20662, 20661, 20660, 20658, 5308)
AddSpellName("Revenge", 57823, 30357, 25288, 25269, 11601, 11600, 7379, 6574, 6572)
AddSpellName("ShieldSlam", 47488, 47487, 30356, 25258, 23925, 23924, 23923, 23922)
AddSpellName("ArcaneMissiles", 42846, 42843, 38704, 38699, 27075, 25345, 10212, 10211, 8417, 8416, 5145, 5144, 5143)
AddSpellName("FrostBolt", 42842, 42841, 38697, 27072, 27071, 25304, 10181, 10180, 10179, 8408, 8407, 8406, 7322, 837, 205, 116)
AddSpellName("IceLance", 42914, 42913, 30455)
AddSpellName("FrostfireBolt", 47610, 44614, 401502 ) -- 401502 - SoD rune
AddSpellName("SpellfrostBolt", 412532 ) -- SoD Rune
AddSpellName("Fireball", 42833, 42832, 38692, 27070, 25306, 10151, 10150, 10149, 10148, 8402, 8401, 8400, 3140, 145, 143, 133)
AddSpellName("Pyroblast", 42891, 42890, 33938, 27132, 18809, 12526, 12525, 12524, 12523, 12522, 12505, 11366)
AddSpellName("Flamestrike", 42926, 42925, 27086, 10216, 10215, 8423, 8422, 2121, 2120)
AddSpellName("FlashOfLight", 48785, 48784, 27137, 19943, 19942, 19941, 19940, 19939, 19750)
AddSpellName("DrainSoul", 47855, 27217, 11675, 8289, 8288, 1120)
AddSpellName("SoulFire", 47825, 47824, 30545, 27211, 17924, 6353)
AddSpellName("Starfire", 48465, 48464, 26986, 25298, 9876, 9875, 8951, 8950, 8949, 2912)
AddSpellName("Wrath", 48461, 48459, 26985, 26984, 9912, 8905, 6780, 5180, 5179, 5178, 5177, 5176)
AddSpellName("GreaterHeal", 48063, 48062, 25314, 25213, 25210, 10965, 10964, 10963, 2060)
AddSpellName("HealingTouchSoD", 25297, 9889, 9888, 9758, 8903, 6778, 5189, 5188, 5187, 5186, 5185)
AddSpellName("HowlingBlast", 51411, 51410, 51409, 49184)
AddSpellName("FrostStrike", 55268, 51419, 51418, 51417, 51416, 49143)
AddSpellName("ChainLightning", 408484, 408482, 408481, 408479, 10605, 2860, 930, 421)
AddSpellName("ChainHeal", 416246, 416245, 416244, 10623, 10622, 1064)
AddSpellName("LavaBurst", 408490)
AddSpellName("FlashHeal", 48071, 48070, 25235, 25233, 10917, 10916, 10915, 9474, 9473, 9472, 2061)
AddSpellName("Smite", 48123, 48122, 25364, 25363, 10934, 10933, 6060, 1004, 984, 598, 591, 585)
local function OnAuraStateChange(conditionFunc, actions)
local state = -1
return function()
local name, _, count, _, duration, expirationTime = conditionFunc()
local newState = name ~= nil
if newState ~= state then
actions(newState, duration, expirationTime)
state = newState
end
end
end
f:RegisterEvent("PLAYER_LOGIN")
function f:PLAYER_LOGIN()
-- if class == "WARRIOR" or class == "ROGUE" or class == "HUNTER" or class == "WARLOCK" or class == "PALADIN" or class == "SHAMAN" then
if true then
self:RegisterEvent("SPELLS_CHANGED")
self:SPELLS_CHANGED()
self:RegisterEvent("UPDATE_BONUS_ACTIONBAR")
-- In case of button swaps for macros it goes like
-- ACTIONBAR_SLOT_CHANGED 77
-- ACTIONBAR_SLOT_CHANGED 78
-- ACTIONBAR_UPDATE_COOLDOWN -- UPDATE_COOLDOWN always finishing the chain of button updates
-- So only when detecting this pattern buttons are reactivated. Because normal ACTIONBAR_UPDATE_COOLDOWN happens all the time
self:RegisterEvent("ACTIONBAR_SLOT_CHANGED")
self:RegisterEvent("ACTIONBAR_UPDATE_COOLDOWN")
local bars = {"ActionButton","MultiBarBottomLeftButton","MultiBarBottomRightButton","MultiBarLeftButton","MultiBarRightButton"}
for _,bar in ipairs(bars) do
for i = 1,12 do
local btn = _G[bar..i]
self:RegisterForActivations(btn)
end
end
hooksecurefunc("ActionButton_UpdateOverlayGlow", function(self)
ns.UpdateOverlayGlow(self)
end)
local LAB = LibStub and LibStub("LibActionButton-1.0", true) -- Bartener support
if LAB then
LBG = LibStub("LibButtonGlow-1.0", true)
self:RegisterForActivations(LAB.eventFrame)
LAB:RegisterCallback("OnButtonUpdate", function(event, self)
ns.LAB_UpdateOverlayGlow(self)
end)
end
local LAB2 = LibStub and LibStub("LibActionButton-1.0-ElvUI", true) -- ElvUI support
if LAB2 then
LCG = LibStub("LibCustomGlow-1.0", true)
self:RegisterForActivations(LAB2.eventFrame)
LAB2:RegisterCallback("OnButtonUpdate", function(event, self)
ns.LAB_UpdateOverlayGlowLibCustomGlow(self)
end)
end
if IsAddOnLoaded("Dominos") then
local dominosPrefix = "DominosActionButton"
for i = 1, 72 do
local btnName = dominosPrefix..i
local btn = _G[btnName]
if btn then
self:RegisterForActivations(btn)
end
end
end
-- if Neuron then
-- for i,bar in ipairs(Neuron.BARIndex) do
-- for btnID, btn in pairs(bar.buttons) do
-- if btn.objType == "ACTIONBUTTON" then
-- self:RegisterForActivations(btn)
-- end
-- end
-- end
-- end
end
-- self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
end
local UnitAura = UnitAura
local function FindAura(unit, spellID, filter)
for i=1, 100 do
local name, icon, count, debuffType, duration, expirationTime, unitCaster, canStealOrPurge, nameplateShowPersonal, auraSpellID = UnitAura(unit, i, filter)
if not name then return nil end
if spellID == auraSpellID then
return name, icon, count, debuffType, duration, expirationTime, unitCaster, canStealOrPurge, nameplateShowPersonal, auraSpellID
end
end
end
function f:SPELLS_CHANGED()
local config = ns.configs[class]
if config then
config(self)
end
end
function f:RegisterForActivations(frame)
registeredFrames[frame] = true
-- registeredFrames:GetScript("OnEvent")
end
local function IsSpellOverlayed(spellID)
local spellName = spellNamesByID[spellID]
if not spellName then return false end
local state = activations[spellName]
if state then return state.active end
end
local GetActionInfo = _G.GetActionInfo
local GetMacroSpell = _G.GetMacroSpell
local ActionButton_ShowOverlayGlow = _G.ActionButton_ShowOverlayGlow
local ActionButton_HideOverlayGlow = _G.ActionButton_HideOverlayGlow
function ns.UpdateOverlayGlow(self)
local spellType, id, subType = GetActionInfo(self.action);
if ( spellType == "spell" and IsSpellOverlayed(id) ) then
ActionButton_ShowOverlayGlow(self);
elseif ( spellType == "macro" ) then
local spellId = GetMacroSpell(id);
if ( spellId and IsSpellOverlayed(spellId) ) then
ActionButton_ShowOverlayGlow(self);
else
ActionButton_HideOverlayGlow(self);
end
else
ActionButton_HideOverlayGlow(self);
end
end
function ns.LAB_UpdateOverlayGlow(self)
local spellId = self:GetSpellId()
if spellId and IsSpellOverlayed(spellId) then
if LBG then
LBG.ShowOverlayGlow(self)
end
else
if LBG then
LBG.HideOverlayGlow(self)
end
end
end
function ns.LAB_UpdateOverlayGlowLibCustomGlow(self)
local spellId = self:GetSpellId()
if spellId and IsSpellOverlayed(spellId) then
if LCG then
LCG.ButtonGlow_Start(self)
end
else
if LCG then
LCG.ButtonGlow_Stop(self)
end
end
end
function f:FanoutEvent(event, ...)
for frame, _ in pairs(registeredFrames) do
local eventHandler = frame:GetScript("OnEvent")
if eventHandler then
eventHandler(frame, event, ...)
end
end
end
local runeSpells = {
-- [403470] = 402927
["VictoryRush"] = 402927,
[402927] = 403470, -- spell ID = engraving ID
["BloodSurgeSoD"] = 413380,
[413380] = 416004,
["PowerSurgeSoD"] = 415100
}
function ns.knownEngravedSpell(spellID)
local engravingAbilityID = runeSpells[spellID]
return C_Engraving.IsKnownRuneSpell(engravingAbilityID)
end
function ns.findHighestRank(spellName)
if C_Engraving then
if runeSpells[spellName] then
return runeSpells[spellName]
elseif not reverseSpellRanks[spellName] then
return
end
end
if not reverseSpellRanks[spellName] then return end
for _, spellID in ipairs(reverseSpellRanks[spellName]) do
if IsPlayerSpell(spellID) then return spellID end
end
end
local findHighestRank = ns.findHighestRank
function f:Activate(spellName, actID, duration, keepExpiration)
local states = activations[spellName]
if not states then
activations[spellName] = {}
states = activations[spellName]
end
local state = states[actID]
if not state then
states[actID] = {}
state = states[actID]
end
local expirationTime = state
if not state.active then
state.active = true
state.expirationTime = duration and GetTime() + duration
local highestRankSpellID = findHighestRank(spellName)
self:FanoutEvent("SPELL_ACTIVATION_OVERLAY_GLOW_SHOW", highestRankSpellID)
elseif not keepExpiration then
state.expirationTime = duration and GetTime() + duration
end
end
local slotJustChanged = false
function f:ACTIONBAR_SLOT_CHANGED()
slotJustChanged = true
end
function f:ACTIONBAR_UPDATE_COOLDOWN()
if slotJustChanged then
return f:ReactivateButtons()
end
slotJustChanged = false
end
function f:UPDATE_BONUS_ACTIONBAR()
return f:ReactivateButtons()
end
function f:ReactivateButtons()
local now = GetTime()
for spellName, states in pairs(activations) do
for actID, state in pairs(states) do
if state.active and (state.expirationTime == nil or state.expirationTime > now) then
local highestRankSpellID = findHighestRank(spellName)
self:FanoutEvent("SPELL_ACTIVATION_OVERLAY_GLOW_SHOW", highestRankSpellID)
end
end
end
end
function f:Deactivate(spellName, actID)
local states = activations[spellName]
if not states then return end
local state = states[actID]
if state and state.active == true then
states[actID] = nil
-- state.active = false
-- state.expirationTime = nil
end
if not next(states) then
local highestRankSpellID = findHighestRank(spellName)
self:FanoutEvent("SPELL_ACTIVATION_OVERLAY_GLOW_HIDE", highestRankSpellID)
end
end
local _OnUpdateCounter = 0
local periodicCheck = nil
function f.timerOnUpdate(self, elapsed)
_OnUpdateCounter = _OnUpdateCounter + elapsed
if _OnUpdateCounter < 0.2 then return end
_OnUpdateCounter = 0
if periodicCheck then
periodicCheck()
end
local now = GetTime()
for spellName, states in pairs(activations) do
for actID, state in pairs(states) do
if state.expirationTime and now >= state.expirationTime then
f:Deactivate(spellName, actID)
end
end
end
end
function f:COMBAT_LOG_EVENT_UNFILTERED(event)
local timestamp, eventType, hideCaster,
srcGUID, srcName, srcFlags, srcFlags2,
dstGUID, dstName, dstFlags, dstFlags2,
arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 = CombatLogGetCurrentEventInfo()
local isSrcPlayer = srcGUID == UnitGUID("player") -- bit_band(srcFlags, AFFILIATION_MINE) == AFFILIATION_MINE
local isDstPlayer = dstGUID == UnitGUID("player")
procCombatLog(eventType, isSrcPlayer, isDstPlayer, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10)
end
-----------------
-- WARRIOR
-----------------
function ns.ExecuteCheck(self, event, unit)
if UnitExists("target") and not UnitIsFriend("player", "target") then
local h = UnitHealth("target")
local hm = UnitHealthMax("target")
local executeID = ns.findHighestRank("Execute")
if h > 0 and (h/hm < 0.2 or IsUsableSpell(executeID)) then
f:Activate("Execute", "Health", 10)
else
f:Deactivate("Execute", "Health")
end
else
f:Deactivate("Execute", "Health")
end
end
function ns.CheckOverpower(eventType, isSrcPlayer, isDstPlayer, ...)
if isSrcPlayer then
if eventType == "SWING_MISSED" or eventType == "SPELL_MISSED" then
local missedType
if eventType == "SWING_MISSED" then
missedType = select(1, ...)
elseif eventType == "SPELL_MISSED" then
missedType = select(4, ...)
end
if missedType == "DODGE" then
f:Activate("Overpower", "Dodge", 5)
end
end
if eventType == "SPELL_CAST_SUCCESS" then
local spellName = select(2, ...)
if spellName == LocalizedOverpower then
f:Deactivate("Overpower", "Dodge")
f:Deactivate("Overpower", "TasteForBlood")
end
end
end
end
function ns.CheckRevenge(eventType, isSrcPlayer, isDstPlayer, ...)
if isDstPlayer then
if eventType == "SWING_MISSED" or eventType == "SPELL_MISSED" then
local missedType
if eventType == "SWING_MISSED" then
missedType = select(1, ...)
elseif eventType == "SPELL_MISSED" then
-- missedType = select(4, ...)
local spellID, _
spellID, _, _, missedType = select(1, ...)
if spellID == 53739 or spellID == 42463 then return end -- Ignore Seal of Vengeance
end
if missedType == "BLOCK" or missedType == "DODGE" or missedType == "PARRY" then
f:Activate("Revenge", "Parry", 5)
end
end
if eventType == "SWING_DAMAGE" then
local blocked = select(5, ...)
if blocked then
f:Activate("Revenge", "Parry", 5)
end
end
end
if isSrcPlayer and eventType == "SPELL_CAST_SUCCESS" then
local spellName = select(2, ...)
if spellName == LocalizedRevenge then
f:Deactivate("Revenge", "Parry")
end
end
end
function ns.CheckRampage(eventType, isSrcPlayer, isDstPlayer, ...)
if isSrcPlayer then
if eventType == "SWING_DAMAGE" or eventType == "SPELL_DAMAGE" then
local isCrit
if eventType == "SWING_DAMAGE" then
isCrit = select(7, ...)
elseif eventType == "SPELL_DAMAGE" then
isCrit = select(10, ...)
end
if isCrit == true then
f:Activate("Rampage", "Crit", 5)
end
end
end
end
local CheckTasteForBloodSoD = OnAuraStateChange(function() return FindAura("player", 426969, "HELPFUL") end,
function(present, duration)
if present then
f:Activate("Overpower", "TasteForBlood", duration, true)
else
f:Deactivate("Overpower", "TasteForBlood")
end
end
)
local CheckTasteForBlood = OnAuraStateChange(function() return FindAura("player", 60503, "HELPFUL") end,
function(present, duration)
if present then
f:Activate("Overpower", "TasteForBlood", duration, true)
else
f:Deactivate("Overpower", "TasteForBlood")
end
end
)
local CheckSuddenDeath = OnAuraStateChange(function() return FindAura("player", 52437, "HELPFUL") end,
function(present, duration)
if present then
f:Activate("Execute", "SuddenDeath", duration, true)
else
f:Deactivate("Execute", "SuddenDeath")
end
end
)
local CheckSwordAndBoard = OnAuraStateChange(function() return FindAura("player", 50227, "HELPFUL") end,
function(present, duration)
if present then
f:Activate("ShieldSlam", "Reset", duration, true)
else
f:Deactivate("ShieldSlam", "Reset")
end
end
)
local CheckBloodsurge = OnAuraStateChange(function() return FindAura("player", 46916, "HELPFUL") end,
function(present, duration)
if present then
f:Activate("Slam", "Bloodsurge", duration, true)
else
f:Deactivate("Slam", "Bloodsurge")
end
end
)
local CheckBloodsurgeSoD = OnAuraStateChange(function() return FindAura("player", 413399, "HELPFUL") end,
function(present, duration)
if present then
f:Activate("Slam", "BloodSurgeSoD", duration, true)
else
f:Deactivate("Slam", "BloodSurgeSoD")
end
end
)
ns.configs.WARRIOR = function(self)
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
self:SetScript("OnUpdate", self.timerOnUpdate)
local hasOverpower = ns.findHighestRank("Overpower")
local hasRevenge = ns.findHighestRank("Revenge")
local hasRampage = ns.findHighestRank("Rampage")
local hasVictoryRush = ns.findHighestRank("VictoryRush") or ns.knownEngravedSpell(402927)
local hasShieldSlam = ns.findHighestRank("ShieldSlam")
local CheckOverpower = ns.CheckOverpower
local CheckRevenge = ns.CheckRevenge
local CheckRampage = ns.CheckRampage
procCombatLog = function(...)
if hasOverpower then
CheckOverpower(...)
end
if hasRevenge then
CheckRevenge(...)
end
if hasRampage then
CheckRampage(...)
end
end
if not hasOverpower and not hasRevenge and not hasRampage then
self:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
self:SetScript("OnUpdate", nil)
end
if ns.findHighestRank("Execute") then
self:RegisterEvent("PLAYER_TARGET_CHANGED")
self:RegisterUnitEvent("UNIT_HEALTH", "target")
self.PLAYER_TARGET_CHANGED = ns.ExecuteCheck
self.UNIT_HEALTH = ns.ExecuteCheck
else
self:UnregisterEvent("PLAYER_TARGET_CHANGED")
self:UnregisterEvent("UNIT_HEALTH")
end
if hasVictoryRush or ns.findHighestRank("Execute") then
local VictoryRushSpellID = ns.findHighestRank("VictoryRush")
self:RegisterEvent("SPELL_UPDATE_USABLE")
local wasUsable = IsUsableSpell(VictoryRushSpellID)
local wasUsableExecute = IsUsableSpell("Execute")
self.SPELL_UPDATE_USABLE = function()
local isUsable = IsUsableSpell(VictoryRushSpellID)
if wasUsable ~= isUsable then
if isUsable then
f:Activate("VictoryRush", "Usable", 20, true)
else
f:Deactivate("VictoryRush", "Usable")
end
wasUsable = isUsable
end
end
end
local hasTasteForBloodTalent = IsPlayerSpell(56636) or IsPlayerSpell(56637) or IsPlayerSpell(56638)
local hasSuddenDeathTalent = IsPlayerSpell(29723) or IsPlayerSpell(29725) or IsPlayerSpell(29724)
local hasSwordAndBoardTalent = IsPlayerSpell(46951) or IsPlayerSpell(46952) or IsPlayerSpell(46953)
local hasBloodsurgeTalent = IsPlayerSpell(46913) or IsPlayerSpell(46914) or IsPlayerSpell(46915)
-- local hasBloodsurgeEngraving = ns.findHighestRank("BloodSurgeSoD")
local hasBloodsurgeEngraving = APILevel == 1
local hasTasteForBloodRune = APILevel == 1
if hasTasteForBloodTalent or hasSuddenDeathTalent or hasSwordAndBoardTalent or hasBloodsurgeTalent or hasBloodsurgeEngraving then
self:RegisterUnitEvent("UNIT_AURA", "player")
self.UNIT_AURA = function(self, event, unit)
if hasTasteForBloodTalent then
CheckTasteForBlood()
end
if hasSuddenDeathTalent then
CheckSuddenDeath()
end
if hasSwordAndBoardTalent then
CheckSwordAndBoard()
end
if hasBloodsurgeTalent then
CheckBloodsurge()
end
if hasBloodsurgeEngraving then -- Season of Discovery
CheckBloodsurgeSoD()
end
if hasTasteForBloodRune then -- Season of Discovery
CheckTasteForBloodSoD()
end
end
else
self:UnregisterEvent("UNIT_AURA")
end
end
-----------------
-- ROGUE
-----------------
function ns.CheckRiposte(eventType, isSrcPlayer, isDstPlayer, ...)
if isDstPlayer then
if eventType == "SWING_MISSED" or eventType == "SPELL_MISSED" then
local missedType
if eventType == "SWING_MISSED" then
missedType = select(1, ...)
elseif eventType == "SPELL_MISSED" then
missedType = select(4, ...)
end
if missedType == "PARRY" then
f:Activate("Riposte", "Parry", 5)
end
end
end
if isSrcPlayer and eventType == "SPELL_CAST_SUCCESS" then
local spellName = select(2, ...)
if spellName == LocalizedRiposte then -- Riposte
f:Deactivate("Riposte", "Parry")
end
end
end
ns.configs.ROGUE = function(self)
if ns.findHighestRank("Riposte") then
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
procCombatLog = ns.CheckRiposte
self:SetScript("OnUpdate", self.timerOnUpdate)
else
self:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
self:SetScript("OnUpdate", nil)
end
end
-----------------
-- HUNTER
-----------------
function ns.CheckCounterattack(eventType, isSrcPlayer, isDstPlayer, ...)
if isDstPlayer then
if eventType == "SWING_MISSED" or eventType == "SPELL_MISSED" then
local missedType
if eventType == "SWING_MISSED" then
missedType = select(1, ...)
elseif eventType == "SPELL_MISSED" then
missedType = select(4, ...)
end
if missedType == "PARRY" then
f:Activate("Counterattack", "Parry", 5)
end
end
end
if isSrcPlayer and eventType == "SPELL_CAST_SUCCESS" then
local spellName = select(2, ...)
if spellName == LocalizedCounterattack then
f:Deactivate("Counterattack", "Parry", 5)
end
end
end
function ns.CheckMongooseBite(eventType, isSrcPlayer, isDstPlayer, ...)
if isDstPlayer then
if eventType == "SWING_MISSED" or eventType == "SPELL_MISSED" then
local missedType
if eventType == "SWING_MISSED" then
missedType = select(1, ...)
elseif eventType == "SPELL_MISSED" then
missedType = select(4, ...)
end
if missedType == "DODGE" then
f:Activate("MongooseBite", "Dodge", 5)
end
end
end
if isSrcPlayer and eventType == "SPELL_CAST_SUCCESS" then
local spellName = select(2, ...)
if spellName == LocalizedMongooseBite then
f:Deactivate("MongooseBite", "Dodge", 5)
end
end
end
function ns.CheckKillCommand(eventType, isSrcPlayer, isDstPlayer, ...)
if isSrcPlayer then
if eventType == "RANGE_DAMAGE" or eventType == "SWING_DAMAGE" or eventType == "SPELL_DAMAGE" then
local isCrit
if eventType == "SWING_DAMAGE" then
isCrit = select(7, ...)
elseif eventType == "RANGE_DAMAGE" then
isCrit = select(10, ...)
elseif eventType == "SPELL_DAMAGE" then
isCrit = select(10, ...)
end
if isCrit == true then
f:Activate("KillCommand", "Crit", 5)
end
end
end
end
ns.configs.HUNTER = function(self)
local hasMongooseBite = APILevel <= 2 ns.findHighestRank("MongooseBite")
local hasCounterattack = ns.findHighestRank("Counterattack")
local hasKillCommand = APILevel == 2 and ns.findHighestRank("KillCommand")
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
self:SetScript("OnUpdate", self.timerOnUpdate)
if hasMongooseBite or hasCounterattack or hasKillCommand then
local CheckCounterattack = ns.CheckCounterattack
local CheckMongooseBite = ns.CheckMongooseBite
local CheckKillCommand = ns.CheckKillCommand
procCombatLog = function(...)
if hasCounterattack then
CheckCounterattack(...)
end
if hasMongooseBite then
CheckMongooseBite(...)
end
if hasKillCommand then
CheckKillCommand(...)
end
end
else
self:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
self:SetScript("OnUpdate", nil)
end
end
-----------------
-- PALADIN
-----------------
do
local LocalDemonTypes = { "Demon", "Dämon", "Demonio", "Demonio", "Démon", "Demone", "Demônio", "Демон", "악마", "恶魔", "惡魔" }
local LocalUndeadTypes = { "Undead", "Untoter", "No-muerto", "No-muerto", "Mort-vivant", "Non Morto", "Renegado", "Нежить", "언데드", "亡灵", "不死族" }
local LocIDs = {
["enUS"] = 1,
["deDE"] = 2,
["esES"] = 3,
["esMX"] = 4,
["frFR"] = 5,
["itIT"] = 6,
["ptBR"] = 7,
["ruRU"] = 8,
["koKR"] = 9,
["zhCN"] = 10,
["zhTW"] = 11,
}
local UndeadType
local DemonType
local locID = LocIDs[GetLocale()]
if locID then
UndeadType = LocalUndeadTypes[locID]
DemonType = LocalDemonTypes[locID]
end
local exorcismTicker
local exorcismCooldownState
local exorcismTickerFunc = function()
local startTime, duration, enabled = GetSpellCooldown(8092) -- fistt Rank
local newState
if duration <= 1.5 then
newState = false
else
newState = true
end
if newState ~= exorcismCooldownState then
if newState == false then
f:Activate("Exorcism", "NPCType", 5)
else
f:Deactivate("Exorcism", "NPCType")
end
end
exorcismCooldownState = newState
end
function ns.PaladinExorcismCheck(self, event)
if UnitExists("target") and (UnitCreatureType("target") == UndeadType or UnitCreatureType("target") == DemonType) then
exorcismCooldownState = not exorcismCooldownState
exorcismTickerFunc()
periodicCheck = exorcismTickerFunc
else
f:Deactivate("Exorcism", "NPCType")
periodicCheck = nil
end
end
end
function ns.HOWCheck(self, event, unit)
if UnitExists("target") and not UnitIsFriend("player", "target") then
local h = UnitHealth("target")
local hm = UnitHealthMax("target")
if h > 0 and h/hm <= 0.2 then
f:Activate("HammerOfWrath", "Health", 10)
else
f:Deactivate("HammerOfWrath", "Health")
end
else
f:Deactivate("HammerOfWrath", "Health")
end
end
local CheckArtOfWar = OnAuraStateChange(function() return FindAura("player", 59578, "HELPFUL") end,
function(present, duration)
if present then
f:Activate("FlashOfLight", "ArtOfWar", duration, true)
f:Activate("Exorcism", "ArtOfWar", duration, true)
else
f:Deactivate("FlashOfLight", "ArtOfWar")
f:Deactivate("Exorcism", "ArtOfWar")
end
end
)
-- 53672 -- Rank1
-- 54149 -- Rank2
local CheckInfusionOfLight = OnAuraStateChange(function() return FindAura("player", 54149, "HELPFUL") end,
function(present, duration)
if present then
f:Activate("FlashOfLight", "InfusionOfLight", duration, true)
else
f:Deactivate("FlashOfLight", "InfusionOfLight")
end
end
)
local function CheckDivineStorm(eventType, isSrcPlayer, isDstPlayer, spellID)
if isSrcPlayer then
if spellID == 70769 then -- Divine Storm reset
if eventType == "SPELL_CAST_SUCCESS" or eventType == "SPELL_AURA_APPLIED" then
f:Activate("DivineStorm", "Reset", 2)
end
end
end
end
ns.configs.PALADIN = function(self)
self:SetScript("OnUpdate", self.timerOnUpdate)
local hasArtOfWar = IsPlayerSpell(53486) or IsPlayerSpell(53488)
local hasInfusionOfLight = IsPlayerSpell(53569) or IsPlayerSpell(53576)
if APILevel <= 2 then
if ns.findHighestRank("Exorcism") then
self:RegisterEvent("PLAYER_TARGET_CHANGED")
self.PLAYER_TARGET_CHANGED = ns.PaladinExorcismCheck
end
end
if ns.findHighestRank("HammerOfWrath") then
self:RegisterUnitEvent("UNIT_HEALTH", "target")
self.PLAYER_TARGET_CHANGED = function(...)
if APILevel <= 2 then
-- if not hasArtOfWar then
ns.PaladinExorcismCheck(...)
end
ns.HOWCheck(...)
end
self.UNIT_HEALTH = ns.HOWCheck
end
if APILevel == 3 and IsPlayerSpell(53385) then
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
procCombatLog = CheckDivineStorm
else
self:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
end
if hasArtOfWar or hasInfusionOfLight then
self:RegisterUnitEvent("UNIT_AURA", "player")
self:SetScript("OnUpdate", self.timerOnUpdate)
self.UNIT_AURA = function(self, event, unit)
if hasArtOfWar then
CheckArtOfWar()
end
if hasInfusionOfLight then
CheckInfusionOfLight()
end
end
else
self:UnregisterEvent("UNIT_AURA")
end
end
-----------------
-- WARLOCK
-----------------
local CheckNightfall = OnAuraStateChange(function() return FindAura("player", 17941, "HELPFUL") end,
function(present, duration)
if present then
f:Activate("ShadowBolt", "Nightfall", duration, true)
else
f:Deactivate("ShadowBolt", "Nightfall")
end
end
)
local CheckBacklash = OnAuraStateChange(function() return FindAura("player", 34936, "HELPFUL") end,
function(present, duration)
if present then
f:Activate("ShadowBolt", "Backlash", duration, true)
f:Activate("Incinerate", "Backlash", duration, true)
else
f:Deactivate("ShadowBolt", "Backlash")
f:Deactivate("Incinerate", "Backlash")
end
end
)
local CheckDecimation = OnAuraStateChange(function() return FindAura("player", 63167, "HELPFUL") end,
function(present, duration)
if present then
f:Activate("SoulFire", "Decimation")
else
f:Deactivate("SoulFire", "Decimation")
end
end
)
local CheckMoltenCore = OnAuraStateChange(function() return FindAura("player", 71165, "HELPFUL") end,
function(present, duration)
if present then
f:Activate("Incinerate", "MoltenCore", duration, true)
else
f:Deactivate("Incinerate", "MoltenCore")
end
end
)
function ns.DrainSoulExecuteCheck(self, event, unit)
if UnitExists("target") and not UnitIsFriend("player", "target") then
local h = UnitHealth("target")
local hm = UnitHealthMax("target")
local executeID = ns.findHighestRank("DrainSoul")
if h > 0 and (h/hm < 0.25) then
f:Activate("DrainSoul", "Health", 10)
else
f:Deactivate("DrainSoul", "Health")
end
else
f:Deactivate("DrainSoul", "Health")
end
end
ns.configs.WARLOCK = function(self)