forked from kaminaris/MaxDps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Helper.lua
1228 lines (1069 loc) · 34.3 KB
/
Helper.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
--- @type MaxDps MaxDps
local _, MaxDps = ...;
-- Global cooldown spell id
local _GlobalCooldown = 61304;
-- Bloodlust effects
local _Bloodlust = 2825;
local _TimeWrap = 80353;
local _Heroism = 32182;
local _AncientHysteria = 90355;
local _Netherwinds = 160452;
local _DrumsOfFury = 178207;
local _Exhaustion = 57723;
local _Bloodlusts = { _Bloodlust, _TimeWrap, _Heroism, _AncientHysteria, _Netherwinds, _DrumsOfFury };
-- Global functions
local UnitAura = UnitAura;
local pairs = pairs;
local ipairs = ipairs;
local StringSplit = strsplit;
local Select = select;
local TableInsert = tinsert;
local GetTalentInfo = GetTalentInfo;
local C_AzeriteEmpoweredItem = C_AzeriteEmpoweredItem;
local GetSpecialization = GetSpecialization;
local GetSpecializationInfo = GetSpecializationInfo;
local AzeriteUtil = AzeriteUtil;
local C_AzeriteEssence = C_AzeriteEssence;
local FindSpellOverrideByID = FindSpellOverrideByID;
local UnitCastingInfo = UnitCastingInfo;
local GetTime = GetTime;
local GetSpellCooldown = GetSpellCooldown;
local GetSpellInfo = GetSpellInfo;
local UnitGUID = UnitGUID;
local GetSpellBaseCooldown = GetSpellBaseCooldown;
local IsSpellInRange = IsSpellInRange;
local UnitSpellHaste = UnitSpellHaste;
local GetSpellCharges = GetSpellCharges;
local UnitPower = UnitPower;
local UnitPowerMax = UnitPowerMax;
local UnitHealth = UnitHealth;
local UnitHealthMax = UnitHealthMax;
local IsEquippedItem = IsEquippedItem;
local GetManaRegen = GetManaRegen;
local GetSpellTabInfo = GetSpellTabInfo;
local GetSpellBookItemInfo = GetSpellBookItemInfo;
local GetSpellBookItemName = GetSpellBookItemName;
local IsInInstance = IsInInstance;
local IsItemInRange = IsItemInRange;
local UnitThreatSituation = UnitThreatSituation;
local GetActiveCovenantID = C_Covenants.GetActiveCovenantID;
local GetActiveSoulbindID = C_Soulbinds.GetActiveSoulbindID;
local GetSoulbindData = C_Soulbinds.GetSoulbindData;
-----------------------------------------------------------------
--- Internal replacement for UnitAura that no longer has ability
--- to filter by spell name
-----------------------------------------------------------------
function MaxDps:IntUnitAura(unit, nameOrId, filter, timeShift)
local aura = {
name = nil,
up = false,
upMath = 0,
count = 0,
expirationTime = 0,
remains = 0,
refreshable = true -- well if it doesn't exist, then it is refreshable
};
local i = 1;
local t = GetTime();
while true do
local name, _, count, _, duration, expirationTime, _, _, _, id = UnitAura(unit, i, filter);
if not name then
break;
end
if name == nameOrId or id == nameOrId then
local remains = 0;
if expirationTime == nil then
remains = 0;
elseif (expirationTime - t) > timeShift then
remains = expirationTime - t - timeShift;
elseif expirationTime == 0 then
remains = 99999;
end
if count == 0 then
count = 1;
end
return {
name = name,
up = remains > 0,
upMath = remains > 0 and 1 or 0,
count = count,
expirationTime = expirationTime,
remains = remains,
refreshable = remains < 0.3 * duration,
};
end
i = i + 1;
end
return aura;
end
function MaxDps:CollectAura(unit, timeShift, output, filter)
filter = filter and filter or (unit == 'target' and 'PLAYER|HARMFUL' or nil);
local t = GetTime();
local i = 1;
for k, _ in pairs(output) do
output[k] = nil;
end
while true do
local name, _, count, _, duration, expirationTime, _, _, _, id = UnitAura(unit, i, filter);
if not name then
break;
end
local remains = 0;
if expirationTime == nil then
remains = 0;
elseif (expirationTime - t) > timeShift then
remains = expirationTime - t - timeShift;
elseif expirationTime == 0 then
remains = 99999;
end
if count == 0 then
count = 1;
end
output[id] = {
name = name,
up = remains > 0,
upMath = remains > 0 and 1 or 0,
count = count,
expirationTime = expirationTime,
remains = remains,
duration = duration,
refreshable = remains < 0.3 * duration,
};
i = i + 1;
end
end
local auraMetaTable = {
__index = function()
return {
up = false,
upMath = 0,
count = 0,
remains = 0,
duration = 0,
refreshable = true,
};
end
};
MaxDps.PlayerAuras = setmetatable({}, auraMetaTable);
MaxDps.TargetAuras = setmetatable({}, auraMetaTable);
MaxDps.PlayerCooldowns = setmetatable({}, {
__index = function(table, key)
return MaxDps:CooldownConsolidated(key, MaxDps.FrameData.timeShift);
end
});
MaxDps.ActiveDots = setmetatable({}, {
__index = function(table, key)
return MaxDps:DebuffCounter(key, MaxDps.FrameData.timeShift);
end
});
function MaxDps:CollectAuras()
self:CollectAura('player', self.FrameData.timeShift, self.PlayerAuras);
self:CollectAura('target', self.FrameData.timeShift, self.TargetAuras);
return self.PlayerAuras, self.TargetAuras;
end
function MaxDps:DumpAuras()
print('Player Auras');
for id, aura in pairs(self.PlayerAuras) do
print(aura.name .. '(' .. id .. '): ' .. aura.count);
end
print('Target Auras');
for id, aura in pairs(self.TargetAuras) do
print(aura.name .. '(' .. id .. '): ' .. aura.count);
end
end
-----------------------------------------------------------------
--- Talents and specializations functions
-----------------------------------------------------------------
function MaxDps:SpecName()
local currentSpec = GetSpecialization();
local currentSpecName = currentSpec and select(2, GetSpecializationInfo(currentSpec)) or 'None';
return currentSpecName;
end
function MaxDps:CheckTalents()
self.PlayerTalents = {};
-- last selected configID or fall back to default spec config
local configID = C_ClassTalents.GetActiveConfigID();
local configInfo = configID and C_Traits.GetConfigInfo(configID);
local treeIDs = configInfo and configInfo.treeIDs;
if not treeIDs then
return
end
for _, treeID in ipairs(treeIDs) do
local nodes = C_Traits.GetTreeNodes(treeID);
for _, nodeID in ipairs(nodes) do
local nodeInfo = C_Traits.GetNodeInfo(configID, nodeID)
if nodeInfo.currentRank and nodeInfo.currentRank > 0 then
local entryID = nodeInfo.activeEntry and nodeInfo.activeEntry.entryID and nodeInfo.activeEntry.entryID;
local entryInfo = entryID and C_Traits.GetEntryInfo(configID, entryID);
local definitionInfo = entryInfo and entryInfo.definitionID and C_Traits.GetDefinitionInfo(entryInfo.definitionID);
if definitionInfo ~= nil then
self.PlayerTalents[definitionInfo.spellID] = 1;
end
end
end
end
end
MaxDps.isMelee = false;
function MaxDps:CheckIsPlayerMelee()
self.isMelee = false;
local class = select(3, UnitClass('player'));
local spec = GetSpecialization();
-- Warrior, Paladin, Rogue, DeathKnight, Monk, Demon Hunter
if class == 1 or class == 2 or class == 4 or class == 6 or class == 10 or class == 12 then
self.isMelee = true;
elseif class == 3 and spec == 3 then
-- Survival Hunter
self.isMelee = true;
elseif class == 7 and spec == 2 then
-- Enh Shaman
self.isMelee = true;
elseif class == 11 and (spec == 2 or spec == 3) then
-- Guardian or Feral Druid
self.isMelee = true;
end
return self.isMelee;
end
function MaxDps:HasTalent(talent)
return self.PlayerTalents[talent];
end
function MaxDps:GetAzeriteTraits()
local t = setmetatable({}, { __index = function()
return 0;
end });
for _, itemLocation in AzeriteUtil.EnumerateEquipedAzeriteEmpoweredItems() do
local tierInfo = C_AzeriteEmpoweredItem.GetAllTierInfo(itemLocation);
for i = 1, #tierInfo do
for x = 1, #tierInfo[i].azeritePowerIDs do
local powerId = tierInfo[i].azeritePowerIDs[x];
if C_AzeriteEmpoweredItem.IsPowerSelected(itemLocation, powerId) then
local spellId = C_AzeriteEmpoweredItem.GetPowerInfo(powerId).spellID;
if t[spellId] then
t[spellId] = t[spellId] + 1;
else
t[spellId] = 1;
end
end
end
end
end
self.AzeriteTraits = t;
return t;
end
function MaxDps:GetAzeriteEssences()
if not self.AzeriteEssences then
self.AzeriteEssences = {
major = false,
minor = {}
};
else
self.AzeriteEssences.major = false;
self.AzeriteEssences.minor = {};
end
local result = self.AzeriteEssences;
return result;
end
--- Get active covenant and soulbind Ids, use Enum.CovenantType for covenantId
---
function MaxDps:GetCovenantInfo()
local covenantId = GetActiveCovenantID();
local soulbindId = GetActiveSoulbindID();
--if soulbindId == 0 then
-- soulbindId = Soulbinds.GetDefaultSoulbindID(covenantId);
--end
local soulbindData = {};
local soulbindAbilities = {};
local soulbindConduits = {};
if soulbindId ~= 0 then
soulbindData = GetSoulbindData(soulbindId);
if soulbindData.tree then
for _, node in ipairs(soulbindData.tree.nodes) do
if node.state == Enum.SoulbindNodeState.Selected then
if node.spellID ~= 0 then
soulbindAbilities[node.spellID] = true;
end
if node.conduitID ~= 0 then
soulbindConduits[node.conduitID] = node.conduitRank;
end
end
end
end
end
self.CovenantInfo = {
covenantId = covenantId,
soulbindId = soulbindId,
soulbindData = soulbindData,
soulbindAbilities = soulbindAbilities,
soulbindConduits = soulbindConduits,
};
return self.CovenantInfo;
end
--[[
Borrowed from WeakAuras
This is free software: you can redistribute it and/or modify it under the terms of
the GNU General Public License version 2 as published by the Free Software
Foundation.
For more information see WeakAuras License
]]
--------------------------------------------
--- Legendaries
--------------------------------------------
local generalLegendaries = {
[7100] = true, -- Echo of Eonar
[7102] = true, -- Norgannon's Sagacity
[7103] = true, -- Sephuz's Proclamation
[7104] = true, -- Stable Phantasma Lure
[7105] = true, -- Third Eye of the Jailer
[7106] = true, -- Vitality Sacrifice
}
local allLegendaryBonusIds = {
SHAMAN = { -- 7
[6993] = true, -- Doom Winds
[6997] = true, -- Jonat's Natural Focus
[7102] = true, -- Norgannon's Sagacity
[7106] = true, -- Vitality Sacrifice
[6986] = true, -- Deeptremor Stone
[6990] = true, -- Elemental Equilibrium
[6994] = true, -- Legacy of the Frost Witch
[6998] = true, -- Spiritwalker's Tidal Totem
[7103] = true, -- Sephuz's Proclamation
[6987] = true, -- Deeply Rooted Elements
[6991] = true, -- Echoes of Great Sundering
[6995] = true, -- Witch Doctor's Wolf Bones
[6999] = true, -- Primal Tide Core
[7100] = true, -- Echo of Eonar
[7104] = true, -- Stable Phantasma Lure
[6988] = true, -- Chains of Devastation
[6992] = true, -- Windspeaker's Lava Resurgence
[6996] = true, -- Primal Lava Actuators
[7000] = true, -- Earthen Harmony
[7159] = true, -- Maw Rattle
[7101] = true, -- Judgment of the Arbiter
[7105] = true, -- Third Eye of the Jailer
[6985] = true, -- Ancestral Reminder
[6989] = true, -- Skybreaker's Fiery Demise
},
WARRIOR = { -- 1
[6962] = true, -- Enduring Blow
[6966] = true, -- Will of the Berserker
[6970] = true, -- Unhinged
[7102] = true, -- Norgannon's Sagacity
[7106] = true, -- Vitality Sacrifice
[6955] = true, -- Leaper
[6959] = true, -- Signet of Tormented Kings
[6963] = true, -- Cadence of Fujieda
[6967] = true, -- Unbreakable Will
[6971] = true, -- Seismic Reverberation
[7103] = true, -- Sephuz's Proclamation
[6956] = true, -- Thunderlord
[6960] = true, -- Battlelord
[6964] = true, -- Deathmaker
[7100] = true, -- Echo of Eonar
[7104] = true, -- Stable Phantasma Lure
[6957] = true, -- The Wall
[6961] = true, -- Exploiter
[6965] = true, -- Reckless Defense
[6969] = true, -- Reprisal
[7159] = true, -- Maw Rattle
[7101] = true, -- Judgment of the Arbiter
[7105] = true, -- Third Eye of the Jailer
[6958] = true, -- Misshapen Mirror
},
PALADIN = { -- 2
[7055] = true, -- Of Dusk and Dawn
[7059] = true, -- Shock Barrier
[7063] = true, -- Reign of Endless Kings
[7067] = true, -- Tempest of the Lightbringer
[7102] = true, -- Norgannon's Sagacity
[7106] = true, -- Vitality Sacrifice
[7056] = true, -- The Magistrate's Judgment
[7060] = true, -- Holy Avenger's Engraved Sigil
[7064] = true, -- Final Verdict
[7103] = true, -- Sephuz's Proclamation
[7053] = true, -- Uther's Devotion
[7057] = true, -- Shadowbreaker, Dawn of the Sun
[7061] = true, -- The Ardent Protector's Sanctum
[7065] = true, -- Vanguard's Momentum
[7100] = true, -- Echo of Eonar
[7104] = true, -- Stable Phantasma Lure
[7054] = true, -- The Mad Paragon
[7058] = true, -- Inflorescence of the Sunwell
[7062] = true, -- Bulwark of Righteous Fury
[7128] = true, -- Maraad's Dying Breath
[7101] = true, -- Judgment of the Arbiter
[7105] = true, -- Third Eye of the Jailer
[7159] = true, -- Maw Rattle
[7066] = true, -- Relentless Inquisitor
},
ROGUE = { -- 4
[7117] = true, -- Zoldyck Insignia
[7121] = true, -- Celerity
[7125] = true, -- The Rotten
[7102] = true, -- Norgannon's Sagacity
[7106] = true, -- Vitality Sacrifice
[7114] = true, -- Invigorating Shadowdust
[7118] = true, -- Duskwalker's Patch
[7122] = true, -- Concealed Blunderbuss
[7126] = true, -- Deathly Shadows
[7103] = true, -- Sephuz's Proclamation
[7111] = true, -- Mark of the Master Assassin
[7115] = true, -- Dashing Scoundrel
[7119] = true, -- Greenskin's Wickers
[7123] = true, -- Finality
[7100] = true, -- Echo of Eonar
[7104] = true, -- Stable Phantasma Lure
[7112] = true, -- Tiny Toxic Blade
[7116] = true, -- Doomblade
[7120] = true, -- Guile Charm
[7124] = true, -- Akaari's Soul Fragment
[7159] = true, -- Maw Rattle
[7101] = true, -- Judgment of the Arbiter
[7105] = true, -- Third Eye of the Jailer
[7113] = true, -- Essence of Bloodfang
},
MAGE = { -- 8
[6931] = true, -- Fevered Incantation
[7102] = true, -- Norgannon's Sagacity
[7106] = true, -- Vitality Sacrifice
[6831] = true, -- Expanded Potential
[6928] = true, -- Siphon Storm
[6932] = true, -- Firestorm
[6936] = true, -- Triune Ward
[7103] = true, -- Sephuz's Proclamation
[6828] = true, -- Cold Front
[6832] = true, -- Disciplinary Command
[6933] = true, -- Molten Skyfall
[6937] = true, -- Grisly Icicle
[7100] = true, -- Echo of Eonar
[7104] = true, -- Stable Phantasma Lure
[6829] = true, -- Freezing Winds
[6926] = true, -- Arcane Infinity
[6934] = true, -- Sun King's Blessing
[6823] = true, -- Slick Ice
[7159] = true, -- Maw Rattle
[7101] = true, -- Judgment of the Arbiter
[7105] = true, -- Third Eye of the Jailer
[6830] = true, -- Glacial Fragments
[6834] = true, -- Temporal Warp
[6927] = true, -- Arcane Bombardment
},
WARLOCK = { -- 9
[7028] = true, -- Pillars of the Dark Portal
[7032] = true, -- Wrath of Consumption
[7036] = true, -- Balespider's Burning Core
[7102] = true, -- Norgannon's Sagacity
[7106] = true, -- Vitality Sacrifice
[7025] = true, -- Wilfred's Sigil of Superior Summoning
[7029] = true, -- Perpetual Agony of Azj'Aqir
[7033] = true, -- Implosive Potential
[7037] = true, -- Odr, Shawl of the Ymirjar
[7103] = true, -- Sephuz's Proclamation
[7026] = true, -- Claw of Endereth
[7030] = true, -- Sacrolash's Dark Strike
[7034] = true, -- Grim Inquisitor's Dread Calling
[7100] = true, -- Echo of Eonar
[7104] = true, -- Stable Phantasma Lure
[7040] = true, -- Embers of the Diabolic Raiment
[7027] = true, -- Relic of Demonic Synergy
[7031] = true, -- Malefic Wrath
[7159] = true, -- Maw Rattle
[7101] = true, -- Judgment of the Arbiter
[7105] = true, -- Third Eye of the Jailer
[7039] = true, -- Madness of the Azj'Aqir
[7038] = true, -- Cinders of the Azj'Aqir
[7035] = true, -- Forces of the Horned Nightmare
},
PRIEST = { -- 5
[6974] = true, -- Flash Concentration
[7102] = true, -- Norgannon's Sagacity
[7106] = true, -- Vitality Sacrifice
[7002] = true, -- Twins of the Sun Priestess
[6975] = true, -- Cauterizing Shadows
[7103] = true, -- Sephuz's Proclamation
[6983] = true, -- Eternal Call to the Void
[7162] = true, -- Talbadar's Stratagem
[6982] = true, -- Shadowflame Prism
[6981] = true, -- Painbreaker Psalm
[6972] = true, -- Vault of Heavens
[7100] = true, -- Echo of Eonar
[7104] = true, -- Stable Phantasma Lure
[6984] = true, -- X'anshi, Return of Archbishop Benedictus
[6973] = true, -- Divine Image
[6977] = true, -- Harmonious Apparatus
[6976] = true, -- The Penitent One
[6978] = true, -- Crystalline Reflection
[7159] = true, -- Maw Rattle
[7101] = true, -- Judgment of the Arbiter
[7105] = true, -- Third Eye of the Jailer
[6979] = true, -- Kiss of Death
[6980] = true, -- Clarity of Mind
[7161] = true, -- Measured Contemplation
},
MONK = { -- 10
[7102] = true, -- Norgannon's Sagacity
[7106] = true, -- Vitality Sacrifice
[7079] = true, -- Shaohao's Might
[7184] = true, -- Escape from Reality
[7068] = true, -- Keefer's Skyreach
[7103] = true, -- Sephuz's Proclamation
[7076] = true, -- Charred Passions
[7080] = true, -- Swiftsure Wraps
[7069] = true, -- Last Emperor's Capacitor
[7071] = true, -- Jade Ignition
[7070] = true, -- Xuen's Treasure
[7100] = true, -- Echo of Eonar
[7104] = true, -- Stable Phantasma Lure
[7077] = true, -- Stormstout's Last Keg
[7081] = true, -- Fatal Touch
[7072] = true, -- Tear of Morning
[7074] = true, -- Clouded Focus
[7073] = true, -- Yu'lon's Whisper
[7159] = true, -- Maw Rattle
[7101] = true, -- Judgment of the Arbiter
[7105] = true, -- Third Eye of the Jailer
[7078] = true, -- Celestial Infusion
[7082] = true, -- Invoker's Delight
[7075] = true, -- Ancient Teachings of the Monastery
},
HUNTER = { -- 3
[7005] = true, -- Soulforge Embers
[7102] = true, -- Norgannon's Sagacity
[7106] = true, -- Vitality Sacrifice
[7017] = true, -- Latent Poison Injectors
[7006] = true, -- Craven Strategem
[7103] = true, -- Sephuz's Proclamation
[7014] = true, -- Secrets of the Unblinking Vigil
[7018] = true, -- Butcher's Bone Fragments
[7009] = true, -- Qa'pla, Eredun War Order
[7013] = true, -- Serpentstalker's Trickery
[7003] = true, -- Call of the Wild
[7100] = true, -- Echo of Eonar
[7104] = true, -- Stable Phantasma Lure
[7015] = true, -- Wildfire Cluster
[7012] = true, -- Surging Shots
[7011] = true, -- Eagletalon's True Focus
[7007] = true, -- Dire Command
[7008] = true, -- Flamewaker's Cobra Sting
[7004] = true, -- Nessingwary's Trapping Apparatus
[7101] = true, -- Judgment of the Arbiter
[7105] = true, -- Third Eye of the Jailer
[7016] = true, -- Rylakstalker's Confounding Strikes
[7010] = true, -- Rylakstalker's Piercing Fangs
[7159] = true, -- Maw Rattle
},
DEATHKNIGHT = { -- 6
[6943] = true, -- Gorefiend's Domination
[7102] = true, -- Norgannon's Sagacity
[7106] = true, -- Vitality Sacrifice
[6940] = true, -- Bryndaor's Might
[6944] = true, -- Koltira's Favor
[7103] = true, -- Sephuz's Proclamation
[6952] = true, -- Deadliest Coil
[6951] = true, -- Death's Certainty
[6950] = true, -- Frenzied Monstrosity
[6949] = true, -- Reanimated Shambler
[6941] = true, -- Crimson Rune Weapon
[7100] = true, -- Echo of Eonar
[7104] = true, -- Stable Phantasma Lure
[6953] = true, -- Superstrain
[7160] = true, -- Rage of the Frozen Champion
[6946] = true, -- Absolute Zero
[6945] = true, -- Biting Cold
[6947] = true, -- Death's Embrace
[6942] = true, -- Vampiric Aura
[7101] = true, -- Judgment of the Arbiter
[7105] = true, -- Third Eye of the Jailer
[6954] = true, -- Phearomones
[6948] = true, -- Grip of the Everlasting
[7159] = true, -- Maw Rattle
},
DEMONHUNTER = { -- 12
[7102] = true, -- Norgannon's Sagacity
[7044] = true, -- Darkest Hour
[7048] = true, -- Fiery Soul
[7052] = true, -- Burning Wound
[7041] = true, -- Collective Anguish
[7045] = true, -- Spirit of the Darkness Flame
[7049] = true, -- Darker Nature
[7100] = true, -- Echo of Eonar
[7104] = true, -- Stable Phantasma Lure
[7046] = true, -- Razelikh's Defilement
[7050] = true, -- Chaos Theory
[7042] = true, -- Fel Bombardment
[7043] = true, -- Darkglare Medallion
[7103] = true, -- Sephuz's Proclamation
[7159] = true, -- Maw Rattle
[7101] = true, -- Judgment of the Arbiter
[7105] = true, -- Third Eye of the Jailer
[7047] = true, -- Fel Flame Fortification
[7051] = true, -- Erratic Fel Core
[7106] = true, -- Vitality Sacrifice
},
DRUID = { -- 11
[7086] = true, -- Draught of Deep Focus
[7090] = true, -- Eye of Fearful Symmetry
[7094] = true, -- Ursoc's Fury Remembered
[7098] = true, -- Verdant Infusion
[7102] = true, -- Norgannon's Sagacity
[7106] = true, -- Vitality Sacrifice
[7110] = true, -- Lycara's Fleeting Glimpse
[7087] = true, -- Oneth's Clear Vision
[7091] = true, -- Apex Predator's Craving
[7095] = true, -- Legacy of the Sleeper
[7099] = true, -- Vision of Unending Growth
[7103] = true, -- Sephuz's Proclamation
[7107] = true, -- Balance of All Things
[7084] = true, -- Oath of the Elder Druid
[7088] = true, -- Primordial Arcanic Pulsar
[7092] = true, -- Luffa-Infused Embrace
[7096] = true, -- Memory of the Mother Tree
[7100] = true, -- Echo of Eonar
[7104] = true, -- Stable Phantasma Lure
[7108] = true, -- Timeworn Dreambinder
[7085] = true, -- Circle of Life and Death
[7089] = true, -- Cat-eye Curio
[7093] = true, -- The Natural Order's Will
[7159] = true, -- Maw Rattle
[7101] = true, -- Judgment of the Arbiter
[7105] = true, -- Third Eye of the Jailer
[7109] = true, -- Frenzyband
[7097] = true, -- The Dark Titan's Lesson
},
EVOKER = {}
}
local function GetItemSplit(itemLink)
local itemString = string.match(itemLink, 'item:([%-?%d:]+)');
local itemSplit = {};
-- Split data into a table
for _, v in ipairs({ strsplit(':', itemString) }) do
if v == '' then
itemSplit[#itemSplit + 1] = 0;
else
itemSplit[#itemSplit + 1] = tonumber(v);
end
end
return itemSplit;
end
local OFFSET_BONUS_ID = 13;
function MaxDps:ExtractBonusIds(itemLink)
local itemSplit = GetItemSplit(itemLink);
local bonuses = {}
for i = 1, itemSplit[OFFSET_BONUS_ID] do
bonuses[itemSplit[OFFSET_BONUS_ID + i]] = true;
end
return bonuses;
end
function MaxDps:GetLegendaryEffects()
local legendaryBonusIds = {};
local playerClass = select(2, UnitClass('player'));
for i = 1, 19 do
local link = GetInventoryItemLink('player', i);
if link then
local itemBonusIds = self:ExtractBonusIds(link);
for bonusId, _ in pairs(generalLegendaries) do
if itemBonusIds[bonusId] then
legendaryBonusIds[bonusId] = true;
end
end
for bonusId, _ in pairs(allLegendaryBonusIds[playerClass]) do
if itemBonusIds[bonusId] then
legendaryBonusIds[bonusId] = true;
end
end
end
end
self.LegendaryBonusIds = legendaryBonusIds;
return legendaryBonusIds;
end
local bfaConsumables = {
[169299] = true, -- Potion of Unbridled Fury
[168529] = true, -- Potion of Empowered Proximity
[168506] = true, -- Potion of Focused Resolve
[168489] = true, -- Superior Battle Potion of Agility
[168498] = true, -- Superior Battle Potion of Intellect
[168500] = true, -- Superior Battle Potion of Strength
[163223] = true, -- Battle Potion of Agility
[163222] = true, -- Battle Potion of Intellect
[163224] = true, -- Battle Potion of Strength
[152559] = true, -- Potion of Rising Death
[152560] = true, -- Potion of Bursting Blood
};
function MaxDps:GlowConsumables()
if self.db.global.disableConsumables then
return
end
for itemId, _ in pairs(bfaConsumables) do
local itemSpellId = self.ItemSpells[itemId];
if itemSpellId then
self:GlowCooldown(itemSpellId, self:ItemCooldown(itemId, 0).ready);
end
end
end
function MaxDps:GlowEssences()
local fd = MaxDps.FrameData;
if not fd.essences.major then
return
end
MaxDps:GlowCooldown(fd.essences.major, fd.cooldown[fd.essences.major].ready);
end
function MaxDps:DumpAzeriteTraits()
for id, rank in pairs(self.AzeriteTraits) do
local n = GetSpellInfo(id);
print(n .. ' (' .. id .. '): ' .. rank);
end
end
-----------------------------------------------------------------
--- Aura helper functions
-----------------------------------------------------------------
-- Aura on specific unit
-- @deprecated
function MaxDps:UnitAura(auraId, timeShift, unit, filter)
timeShift = timeShift or 0;
local aura = self:IntUnitAura(unit, auraId, filter, timeShift);
return aura.up, aura.count, aura.remains;
end
-- Aura on player
function MaxDps:Aura(name, timeShift)
return self:UnitAura(name, timeShift, 'player');
end
-- Aura on target
function MaxDps:TargetAura(name, timeShift)
return self:UnitAura(name, timeShift, 'target');
end
-----------------------------------------------------------------
--- Casting info helpers
-----------------------------------------------------------------
function MaxDps:EndCast(target)
target = target or 'player';
local t = GetTime();
local c = t * 1000;
local gcd = 0;
local _, _, _, _, endTime, _, _, _, spellId = UnitCastingInfo(target or 'player');
if not spellId then
_, _, _, _, endTime, _, _, spellId = UnitChannelInfo(target or 'player');
end
-- we can only check player global cooldown
if target == 'player' then
local gstart, gduration = GetSpellCooldown(_GlobalCooldown);
gcd = gduration - (t - gstart);
if gcd < 0 then
gcd = 0;
end ;
end
if not endTime then
return gcd, nil, gcd;
end
local timeShift = (endTime - c) / 1000;
if gcd > timeShift then
timeShift = gcd;
end
return timeShift, spellId, gcd;
end
function MaxDps:GlobalCooldown(spellId)
local baseGCD = 1.5;
if spellId then
baseGCD = select(2, GetSpellBaseCooldown(spellId)) / 1000;
end
local haste = UnitSpellHaste('player');
local gcd = baseGCD / ((haste / 100) + 1);
if gcd < 0.75 then
gcd = 0.75;
end
return gcd;
end
function MaxDps:AttackHaste()
local haste = UnitSpellHaste('player');
return 1 / ((haste / 100) + 1);
end
-----------------------------------------------------------------
--- Spell helpers
-----------------------------------------------------------------
function MaxDps:ItemCooldown(itemId, timeShift)
local start, duration, enabled = GetItemCooldown(itemId);
local t = GetTime();
local remains = 100000;
if enabled and duration == 0 and start == 0 then
remains = 0;
elseif enabled then
remains = duration - (t - start) - timeShift;
end
return {
ready = remains <= 0,
remains = remains,
};
end
function MaxDps:CooldownConsolidated(spellId, timeShift)
timeShift = timeShift or 0;
local remains = 100000;
local t = GetTime();
local enabled;
local charges, maxCharges, start, duration = GetSpellCharges(spellId);
local fullRecharge, partialRecharge = 0, 0;
if charges == nil then
start, duration, enabled = GetSpellCooldown(spellId);
maxCharges = 1;
if enabled and duration == 0 and start == 0 then
remains = 0;
elseif enabled then
remains = duration - (t - start) - timeShift;
end
fullRecharge = remains;
partialRecharge = remains;
else
remains = duration - (t - start) - timeShift;
if remains > duration then
remains = 0;
end
if remains > 0 then
charges = charges + (1 - (remains / duration));
end
fullRecharge = (maxCharges - charges) * duration;
partialRecharge = remains;
if charges >= 1 then
remains = 0;
end
end
local cooldownMS, gcdMS = GetSpellBaseCooldown(spellId)
return {
duration = ((cooldownMS and cooldownMS) or (gcdMS and gcdMS) or 500) / 1000,
ready = remains <= 0,
remains = remains,
fullRecharge = fullRecharge,
partialRecharge = partialRecharge,
charges = charges,
maxCharges = maxCharges
};
end
-- @deprecated
function MaxDps:Cooldown(spell, timeShift)
local start, duration, enabled = GetSpellCooldown(spell);
if enabled and duration == 0 and start == 0 then
return 0;
elseif enabled then
return (duration - (GetTime() - start) - (timeShift or 0));
else
return 100000;
end ;
end
-- @deprecated
function MaxDps:SpellCharges(spell, timeShift)
local currentCharges, maxCharges, cooldownStart, cooldownDuration = GetSpellCharges(spell);
if currentCharges == nil then
local cd = MaxDps:Cooldown(spell, timeShift);
if cd <= 0 then
return 0, 1, 0;
else
return cd, 0, 1;
end
end
local cd = cooldownDuration - (GetTime() - cooldownStart) - (timeShift or 0);
if cd > cooldownDuration then
cd = 0;
end
if cd > 0 then
currentCharges = currentCharges + (1 - (cd / cooldownDuration));
end
return cd, currentCharges, maxCharges;
end
-- @deprecated
function MaxDps:SpellAvailable(spell, timeShift)
local cd = MaxDps:Cooldown(spell, timeShift);
return cd <= 0, cd;
end
-----------------------------------------------------------------
--- Utility functions
-----------------------------------------------------------------
function MaxDps:TargetPercentHealth(unit)
local health = UnitHealth(unit or 'target');
if health <= 0 then
return 0;
end ;