-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathThreatClassModuleCore.lua
1197 lines (1034 loc) · 44.1 KB
/
ThreatClassModuleCore.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
if not _G.THREATLIB_LOAD_MODULES then return end -- only load if LibThreatClassic2.lua allows it
if not LibStub then return end
local ThreatLib, MINOR = LibStub("LibThreatClassic2", true)
if not ThreatLib then return end
ThreatLib:Debug("Loading class module core revision %s", MINOR)
---------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
-- Blizzard Combat Log constants, in case your addon loads before Blizzard_CombatLog or it's disabled by the user
---------------------------------------------------------------------------------------------------------------
local bit_band = _G.bit.band
local bit_bor = _G.bit.bor
local COMBATLOG_OBJECT_AFFILIATION_MINE = COMBATLOG_OBJECT_AFFILIATION_MINE or 0x00000001
local COMBATLOG_OBJECT_AFFILIATION_PARTY = COMBATLOG_OBJECT_AFFILIATION_PARTY or 0x00000002
local COMBATLOG_OBJECT_AFFILIATION_RAID = COMBATLOG_OBJECT_AFFILIATION_RAID or 0x00000004
local COMBATLOG_OBJECT_AFFILIATION_OUTSIDER = COMBATLOG_OBJECT_AFFILIATION_OUTSIDER or 0x00000008
local COMBATLOG_OBJECT_AFFILIATION_MASK = COMBATLOG_OBJECT_AFFILIATION_MASK or 0x0000000F
-- Reaction
local COMBATLOG_OBJECT_REACTION_FRIENDLY = COMBATLOG_OBJECT_REACTION_FRIENDLY or 0x00000010
local COMBATLOG_OBJECT_REACTION_NEUTRAL = COMBATLOG_OBJECT_REACTION_NEUTRAL or 0x00000020
local COMBATLOG_OBJECT_REACTION_HOSTILE = COMBATLOG_OBJECT_REACTION_HOSTILE or 0x00000040
local COMBATLOG_OBJECT_REACTION_MASK = COMBATLOG_OBJECT_REACTION_MASK or 0x000000F0
-- Ownership
local COMBATLOG_OBJECT_CONTROL_PLAYER = COMBATLOG_OBJECT_CONTROL_PLAYER or 0x00000100
local COMBATLOG_OBJECT_CONTROL_NPC = COMBATLOG_OBJECT_CONTROL_NPC or 0x00000200
local COMBATLOG_OBJECT_CONTROL_MASK = COMBATLOG_OBJECT_CONTROL_MASK or 0x00000300
-- Unit type
local COMBATLOG_OBJECT_TYPE_PLAYER = COMBATLOG_OBJECT_TYPE_PLAYER or 0x00000400
local COMBATLOG_OBJECT_TYPE_NPC = COMBATLOG_OBJECT_TYPE_NPC or 0x00000800
local COMBATLOG_OBJECT_TYPE_PET = COMBATLOG_OBJECT_TYPE_PET or 0x00001000
local COMBATLOG_OBJECT_TYPE_GUARDIAN = COMBATLOG_OBJECT_TYPE_GUARDIAN or 0x00002000
local COMBATLOG_OBJECT_TYPE_OBJECT = COMBATLOG_OBJECT_TYPE_OBJECT or 0x00004000
local COMBATLOG_OBJECT_TYPE_MASK = COMBATLOG_OBJECT_TYPE_MASK or 0x0000FC00
-- Special cases (non-exclusive)
local COMBATLOG_OBJECT_TARGET = COMBATLOG_OBJECT_TARGET or 0x00010000
local COMBATLOG_OBJECT_FOCUS = COMBATLOG_OBJECT_FOCUS or 0x00020000
local COMBATLOG_OBJECT_MAINTANK = COMBATLOG_OBJECT_MAINTANK or 0x00040000
local COMBATLOG_OBJECT_MAINASSIST = COMBATLOG_OBJECT_MAINASSIST or 0x00080000
local COMBATLOG_OBJECT_RAIDTARGET1 = COMBATLOG_OBJECT_RAIDTARGET1 or 0x00100000
local COMBATLOG_OBJECT_RAIDTARGET2 = COMBATLOG_OBJECT_RAIDTARGET2 or 0x00200000
local COMBATLOG_OBJECT_RAIDTARGET3 = COMBATLOG_OBJECT_RAIDTARGET3 or 0x00400000
local COMBATLOG_OBJECT_RAIDTARGET4 = COMBATLOG_OBJECT_RAIDTARGET4 or 0x00800000
local COMBATLOG_OBJECT_RAIDTARGET5 = COMBATLOG_OBJECT_RAIDTARGET5 or 0x01000000
local COMBATLOG_OBJECT_RAIDTARGET6 = COMBATLOG_OBJECT_RAIDTARGET6 or 0x02000000
local COMBATLOG_OBJECT_RAIDTARGET7 = COMBATLOG_OBJECT_RAIDTARGET7 or 0x04000000
local COMBATLOG_OBJECT_RAIDTARGET8 = COMBATLOG_OBJECT_RAIDTARGET8 or 0x08000000
local COMBATLOG_OBJECT_NONE = COMBATLOG_OBJECT_NONE or 0x80000000
local COMBATLOG_OBJECT_SPECIAL_MASK = COMBATLOG_OBJECT_SPECIAL_MASK or 0xFFFF0000
-- Object type constants
local COMBATLOG_FILTER_ME = bit_bor(
COMBATLOG_OBJECT_AFFILIATION_MINE,
COMBATLOG_OBJECT_REACTION_FRIENDLY,
COMBATLOG_OBJECT_CONTROL_PLAYER,
COMBATLOG_OBJECT_TYPE_PLAYER
)
local COMBATLOG_FILTER_MINE = bit_bor(
COMBATLOG_OBJECT_AFFILIATION_MINE,
COMBATLOG_OBJECT_REACTION_FRIENDLY,
COMBATLOG_OBJECT_CONTROL_PLAYER,
COMBATLOG_OBJECT_TYPE_PLAYER,
COMBATLOG_OBJECT_TYPE_OBJECT
)
local COMBATLOG_FILTER_MY_PET = bit_bor(
COMBATLOG_OBJECT_AFFILIATION_MINE,
COMBATLOG_OBJECT_REACTION_FRIENDLY,
COMBATLOG_OBJECT_CONTROL_PLAYER,
COMBATLOG_OBJECT_TYPE_GUARDIAN,
COMBATLOG_OBJECT_TYPE_PET
)
local COMBATLOG_FILTER_FRIENDLY_UNITS = bit_bor(
COMBATLOG_OBJECT_AFFILIATION_PARTY,
COMBATLOG_OBJECT_AFFILIATION_RAID,
COMBATLOG_OBJECT_AFFILIATION_OUTSIDER,
COMBATLOG_OBJECT_REACTION_FRIENDLY,
COMBATLOG_OBJECT_CONTROL_PLAYER,
COMBATLOG_OBJECT_CONTROL_NPC,
COMBATLOG_OBJECT_TYPE_PLAYER,
COMBATLOG_OBJECT_TYPE_NPC,
COMBATLOG_OBJECT_TYPE_PET,
COMBATLOG_OBJECT_TYPE_GUARDIAN,
COMBATLOG_OBJECT_TYPE_OBJECT
)
local COMBATLOG_FILTER_HOSTILE_UNITS = bit_bor(
COMBATLOG_OBJECT_AFFILIATION_PARTY,
COMBATLOG_OBJECT_AFFILIATION_RAID,
COMBATLOG_OBJECT_AFFILIATION_OUTSIDER,
COMBATLOG_OBJECT_REACTION_NEUTRAL,
COMBATLOG_OBJECT_REACTION_HOSTILE,
COMBATLOG_OBJECT_CONTROL_PLAYER,
COMBATLOG_OBJECT_CONTROL_NPC,
COMBATLOG_OBJECT_TYPE_PLAYER,
COMBATLOG_OBJECT_TYPE_NPC,
COMBATLOG_OBJECT_TYPE_PET,
COMBATLOG_OBJECT_TYPE_GUARDIAN,
COMBATLOG_OBJECT_TYPE_OBJECT
)
local COMBATLOG_FILTER_NEUTRAL_UNITS = bit_bor(
COMBATLOG_OBJECT_AFFILIATION_PARTY,
COMBATLOG_OBJECT_AFFILIATION_RAID,
COMBATLOG_OBJECT_AFFILIATION_OUTSIDER,
COMBATLOG_OBJECT_REACTION_NEUTRAL,
COMBATLOG_OBJECT_CONTROL_PLAYER,
COMBATLOG_OBJECT_CONTROL_NPC,
COMBATLOG_OBJECT_TYPE_PLAYER,
COMBATLOG_OBJECT_TYPE_NPC,
COMBATLOG_OBJECT_TYPE_PET,
COMBATLOG_OBJECT_TYPE_GUARDIAN,
COMBATLOG_OBJECT_TYPE_OBJECT
)
local COMBATLOG_FILTER_EVERYTHING = COMBATLOG_FILTER_EVERYTHING or 0xFFFFFFFF
-- Power Types
local SPELL_POWER_MANA = Enum.PowerType.Mana or 0
local SPELL_POWER_RAGE = Enum.PowerType.Rage or 1
local SPELL_POWER_FOCUS = Enum.PowerType.Focus or 2
local SPELL_POWER_ENERGY = Enum.PowerType.Energy or 3
local SPELL_POWER_HAPPINESS = Enum.PowerType.Happiness or 4
local SPELL_POWER_RUNES = Enum.PowerType.Runes or 5
local SPELL_POWER_RUNIC_POWER = Enum.PowerType.RunicPower or 6
local SPELL_POWER_SOUL_SHARDS = Enum.PowerType.SoulShards or 7
local SPELL_POWER_ECLIPSE = Enum.PowerType.LunarPower or 8
local SPELL_POWER_HOLY_POWER = Enum.PowerType.HolyPower or 9
-- Temporary
local SCHOOL_MASK_NONE = SCHOOL_MASK_NONE or 0x00
local SCHOOL_MASK_PHYSICAL = SCHOOL_MASK_PHYSICAL or 0x01
local SCHOOL_MASK_HOLY = SCHOOL_MASK_HOLY or 0x02
local SCHOOL_MASK_FIRE = SCHOOL_MASK_FIRE or 0x04
local SCHOOL_MASK_NATURE = SCHOOL_MASK_NATURE or 0x08
local SCHOOL_MASK_FROST = SCHOOL_MASK_FROST or 0x10
local SCHOOL_MASK_SHADOW = SCHOOL_MASK_SHADOW or 0x20
local SCHOOL_MASK_ARCANE = SCHOOL_MASK_ARCANE or 0x40
local AURA_TYPE_DEBUFF = "DEBUFF" -- hardcode because _G.AURA_TYPE_DEBUFF returns nil here
---------------------------------------------------------------------------------------------------------------
-- End Combat Log constants
---------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
local _G = _G
local tonumber = _G.tonumber
local pairs = _G.pairs
local tinsert = _G.tinsert
local tremove = _G.tremove
local math_max, math_min = _G.math.max, _G.math.min
local select = _G.select
local setmetatable = _G.setmetatable
local strsplit = _G.string.split
local GetSpellInfo = _G.GetSpellInfo
local GetInventoryItemLink = _G.GetInventoryItemLink
local UnitIsDead = _G.UnitIsDead
local UnitAffectingCombat = _G.UnitAffectingCombat
local UnitExists = _G.UnitExists
local GetNetStats = _G.GetNetStats
local GetTime = _G.GetTime
local IsEquippedItem = _G.IsEquippedItem
local UnitLevel = _G.UnitLevel
local GetNumTalents = _G.GetNumTalents or function() return 51 end -- for when testing in retail
local UnitGUID = _G.UnitGUID
local UnitAura = _G.UnitAura
local GetWeaponEnchantInfo = _G.GetWeaponEnchantInfo
local prototype = {}
-- thunderfury tracking, as it applies two debuffs with different threat but same name
-- one debuff is aoe and adds 145 threat, the other is single target and always hits after the damage
-- this is used for tracking that the damage got applied and ignoring the next debuff that follows
local thunderfury = {
lastMobGUID = nil,
lastHitTimestamp = 0,
}
local guidLookup = ThreatLib.GUIDNameLookup
local new, del, newHash, newSet = ThreatLib.new, ThreatLib.del, ThreatLib.newHash, ThreatLib.newSet
local BLACKLIST_MOB_IDS = ThreatLib.BLACKLIST_MOB_IDS or {} -- Default takes care of people that update and don't reboot WoW :P
local BuffModifiers = {
-- Tranquil Air
[25909] = function(self, action)
if action == "exist" then
self:AddBuffThreatMultiplier(0.8)
end
end,
-- Blessing of Salvation
[1038] = function(self, action)
if action == "exist" then
self:AddBuffThreatMultiplier(0.7)
end
end,
-- Greater Blessing of Salvation
[25895] = function(self, action)
if action == "exist" then
self:AddBuffThreatMultiplier(0.7)
end
end,
-- Arcane Shroud
[26400] = function(self, action)
if action == "exist" then
local value = 0.3
local pl = UnitLevel("player")
if pl > 60 then
value = value + (pl - 60) * 0.02
end
self:AddBuffThreatMultiplier(value)
end
end,
-- The Eye of Diminution
[28862] = function(self, action)
if action == "exist" then
local value = 0.65
local pl = UnitLevel("player")
if pl > 60 then
value = value + (pl - 60) * 0.01
end
self:AddBuffThreatMultiplier(value)
end
end,
}
local DebuffModifiers = {
-- Fungal Bloom (Loatheb)
[29232] = function(self, action)
if action == "exist" then
self:AddBuffThreatMultiplier(0)
end
end,
-- Insignifigance (Gurtogg Bloodboil)
[40618] = function(self, action)
if action == "exist" then
self:AddDebuffThreatMultiplier(0)
end
end,
-- Fel Rage (Gurtogg Bloodboil)
[40604] = function(self, action)
if action == "exist" then
self:AddDebuffThreatMultiplier(0)
end
end,
-- Kaliri hamstring, for testing
--[[
[31553] = function(self, action)
if action == "exist" then
self:AddDebuffThreatMultiplier(0)
end
end,
]]--
-- Spiteful Fury (Arcatraz)
[36886] = function(self, action)
if action == "exist" then
self:AddDebuffThreatMultiplier(6)
end
end,
-- Seethe (Essence of Anger, Relinquary of Souls)
[41520] = function(self, action)
if action == "exist" then
self:AddDebuffThreatMultiplier(3)
end
end,
-- Wild Magic (Kalecgos)
[45006] = function(self, action)
if action == "exist" then
self:AddDebuffThreatMultiplier(2)
end
end
}
------------------------------------------
-- Module prototype
------------------------------------------
function prototype:OnInitialize()
if self.initted then return end
self.initted = true
self.timers = self.timers or {}
self.unitEventFrame = self.unitEventFrame or CreateFrame("Frame", self:GetName().."-eventFrame")
self.unitEventFrame:SetScript("OnEvent", function(eventSelf, event, ...)
-- eventSelf is the context of the onEvent handler, while self is the
-- LTC2 class module initialized by Ace based on the prototype
return self[event] and self[event](self, event, ...)
end)
ThreatLib:Debug("Init %s", self:GetName())
self.unitType = "player"
self.itemSets = new()
self.itemSetsWorn = new()
-- To be filled in by each class module
self.BuffHandlers = new() -- Called when the player gains or loses a buff
self.DebuffHandlers = new() -- Called when the player gains or loses a debuff
self.AbilityHandlers = new() -- Called when the player uses an ability (ie, has a combatlog entry)
self.CastHandlers = new() -- Called when the player uses an ability (ie, casts, used for flat-threat adds like buffing)
self.CastMissHandlers = new() -- Called when an ability misses.
self.CastSuccessHandlers = new() -- Called upon SPELL_CAST_SUCCESS
self.MobDebuffHandlers = new()
self.MobSpellNameDebuffHandlers = new() -- used to match single rank debuffs that return nil with GetSpellInfo(spellName)
self.SpellDamageSpellNameHandlers = new() -- used to act on SPELL_DAMAGE with spellname, when GetSpellInfo(spellname) won't work
-- Gift of Arthas
self.MobSpellNameDebuffHandlers[GetSpellInfo(11374)] = function(self, target)
self:AddTargetThreat(target, 90 * self:threatMods())
end
-- thunderfury; apply debuff threat, unless we just had a thunderfury spell damage hit on the same target
-- effectively skips the second debuff because spell damage is always applied right before it on the same timestamp
self.MobSpellNameDebuffHandlers[GetSpellInfo(21992)] = function(self, target, timestamp)
if(thunderfury.lastMobGUID ~= target or thunderfury.lastHitTimestamp + 0.01 < timestamp) then
self:AddTargetThreat(target, 145 * self:threatMods())
end
end
-- thunderfury; apply direct hit bonus threat (as a substitute for direct hit attack speed slow threat)
self.SpellDamageSpellNameHandlers[GetSpellInfo(21992)] = function(self, target, timestamp)
self:AddTargetThreat(target, 90 * self:threatMods())
thunderfury.lastMobGUID = target
thunderfury.lastHitTimestamp = timestamp
end
-- Pain Suppression - Maybe 44416?
self.BuffHandlers[33206] = function(self, action)
if action == "gain" then
self:MultiplyThreat(0.95)
end
end
self.SpellReflectSources = new()
self.ClassDebuffs = new()
self.ThreatQueries = new()
-- Shrouding potion effect
self.CastSuccessHandlers[28548] = function(self)
self:AddThreat(-800 * self:threatMods())
end
self.CastMissHandlers[28548] = function(self)
self:AddThreat(800 * self:threatMods())
end
-- Imp LOTP heals are 0 threat, and in the prototype as any class can proc them
self.ExemptGains = newHash()
self.ExemptGains[34299] = true
-- Same for Lifebloom end heals
self.ExemptGains[33778] = true
-- Used to modify all data from a particular school. Only applies to some classes.
self.schoolThreatMods = new()
-- Stores a hash of GUID = threat level
self.targetThreat = new()
self.unitTypeFilter = 0xFFFFFFFF
self.playerCastSpellIDs = {}
self.playerBuffSpellIDs = setmetatable({__owner = self}, {
__index = function(t, spellId)
for k, v in pairs(BuffModifiers) do
t[k] = k
if k == spellId then
return k
end
end
for k, v in pairs(t.__owner.BuffHandlers) do
t[k] = k
if k == spellId then
return k
end
end
t[spellId] = false
return false
end
})
self.playerDebuffSpellIDs = setmetatable({__owner = self}, {
__index = function(t, spellId)
for k, v in pairs(DebuffModifiers) do
t[k] = k
if k == spellId then
return k
end
end
for k, v in pairs(t.__owner.DebuffHandlers) do
t[k] = k
if k == spellId then
return k
end
end
t[spellId] = false
return false
end
})
end
function prototype:ResetBuffLookups()
for k, v in pairs(self.playerBuffSpellIDs) do
if k ~= "__owner" then
self.playerBuffSpellIDs[k] = nil
end
end
for k, v in pairs(self.playerDebuffSpellIDs) do
if k ~= "__owner" then
self.playerDebuffSpellIDs[k] = nil
end
end
end
function prototype:Boot()
self:OnInitialize()
ThreatLib:Debug("Enable %s", self:GetName())
if GetNumTalents(1) == 0 then return end -- talents aren't available
ThreatLib:Debug("Talents are available, continuing...")
self.buffThreatMultipliers = 1
self.debuffThreatMultipliers = 1
self.buffThreatFlatMods = 0
self.debuffThreatFlatMods = 0
self.enchantMods = 1
self.rockbiterMHVal = 0
self.rockbiterOHVal = 0
self.totalThreatMods = nil
self.meleeCritReduction = 0
self.spellCritReduction = 0
self.passiveThreatModifiers = 1
self.isTanking = false
self:ScanTalents()
if not self.classInitted then
self:ClassInit()
self.classInitted = true
end
self:ClassEnable()
if self.unitType ~= "pet" then
self:RegisterBucketEvent("UNIT_INVENTORY_CHANGED", 0.5, "equipChanged")
self:equipChanged()
end
self.unitTypeFilter = (self.unitType == "player" and COMBATLOG_FILTER_ME) or (self.unitType == "pet" and 0x1111)
self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
self:RegisterEvent("CHARACTER_POINTS_CHANGED")
if self.unitType == "pet" then
self:RegisterEvent("PET_ATTACK_START")
self:RegisterEvent("PET_ATTACK_STOP")
end
self:RegisterEvent("PLAYER_REGEN_ENABLED")
self:RegisterEvent("PLAYER_DEAD", "PLAYER_REGEN_ENABLED")
self:RegisterEvent("PLAYER_REGEN_DISABLED")
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
self.unitEventFrame:RegisterUnitEvent("UNIT_AURA", "player")
ThreatLib:Debug("Initialized actor module")
self:ResetBuffLookups()
self:calcBuffMods()
self:calcDebuffMods()
end
function prototype:OnEnable()
self:Boot()
self.unitGUID = UnitGUID(self.unitType)
end
function prototype:OnDisable()
self:MultiplyThreat(0)
self:PLAYER_REGEN_ENABLED()
self.unitGUID = nil
ThreatLib:Debug("Disable %s", self:GetName())
if self.timers.PetInCombat then
self:CancelTimer(self.timers.PetInCombat)
self.timers.PetInCombat = nil
end
self:ClassDisable()
self:UnregisterEvent("UNIT_SPELLCAST_SUCCEEDED")
self:UnregisterEvent("CHARACTER_POINTS_CHANGED")
if self.unitType == "pet" then
self:UnregisterEvent("PET_ATTACK_START")
self:UnregisterEvent("PET_ATTACK_STOP")
end
self:UnregisterEvent("PLAYER_REGEN_ENABLED")
self:UnregisterEvent("PLAYER_DEAD")
self:UnregisterEvent("PLAYER_REGEN_DISABLED")
self:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
self.unitEventFrame:UnregisterEvent("UNIT_AURA")
end
local AFFILIATION_IN_GROUP = bit_bor(COMBATLOG_OBJECT_AFFILIATION_PARTY, COMBATLOG_OBJECT_AFFILIATION_RAID, COMBATLOG_OBJECT_AFFILIATION_MINE)
local NPC_TARGET = bit_bor(COMBATLOG_OBJECT_TYPE_NPC, COMBATLOG_OBJECT_TYPE_PET)
local REACTION_ATTACKABLE = bit_bor(COMBATLOG_OBJECT_REACTION_HOSTILE, COMBATLOG_OBJECT_REACTION_NEUTRAL)
local FAKE_HOSTILE = bit_bor(COMBATLOG_OBJECT_AFFILIATION_OUTSIDER, COMBATLOG_OBJECT_REACTION_NEUTRAL, COMBATLOG_OBJECT_CONTROL_NPC, COMBATLOG_OBJECT_TYPE_NPC)
local cleuHandlers = {}
function cleuHandlers:SWING_DAMAGE(timestamp, subEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, amount, overkill, school, resisted, blocked, absorbed, critical, glancing, crushing, isOffHand)
if bit_band(sourceFlags, self.unitTypeFilter) == self.unitTypeFilter and bit_band(destFlags, COMBATLOG_OBJECT_CONTROL_PLAYER) == 0 then
self:parseDamage(destGUID, amount, 0, MELEE, school, critical, subEvent, isOffHand)
end
end
function cleuHandlers:RANGE_DAMAGE(timestamp, subEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, spellId, spellName, spellSchool, amount, _, _, _, _, _, critical)
if bit_band(sourceFlags, self.unitTypeFilter) == self.unitTypeFilter and bit_band(destFlags, COMBATLOG_OBJECT_CONTROL_PLAYER) == 0 then
self:parseDamage(destGUID, amount, 0, spellName, spellSchool, critical, subEvent)
end
end
function cleuHandlers:SPELL_DAMAGE(timestamp, subEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, spellId, spellName, spellSchool, amount, overkill, school, resisted, blocked, absorbed, critical, glancing, crushing, isOffHand)
if bit_band(sourceFlags, self.unitTypeFilter) == self.unitTypeFilter and bit_band(destFlags, COMBATLOG_OBJECT_CONTROL_PLAYER) == 0 then
self:parseDamage(destGUID, amount, spellId, spellName, spellSchool, critical, subEvent)
if self.SpellDamageSpellNameHandlers[spellName] then
self.SpellDamageSpellNameHandlers[spellName](self, destGUID, timestamp)
end
elseif sourceGUID == destGUID and self.SpellReflectSources[sourceGUID] then
self:parseDamage(destGUID, amount, spellId, spellName, spellSchool, critical, subEvent)
self.SpellReflectSources[sourceGUID] = nil
end
end
function cleuHandlers:SPELL_PERIODIC_DAMAGE(timestamp, subEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, spellId, spellName, spellSchool, amount, overkill, school, resisted, blocked, absorbed, critical, glancing, crushing, isOffHand)
if bit_band(sourceFlags, self.unitTypeFilter) == self.unitTypeFilter and bit_band(destFlags, COMBATLOG_OBJECT_CONTROL_PLAYER) == 0 then
self:parseDamage(destGUID, amount, spellId, spellName, spellSchool, critical, subEvent)
end
end
function cleuHandlers:SPELL_CAST_SUCCESS(timestamp, subEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags,
spellId, spellName)
if bit_band(sourceFlags, self.unitTypeFilter) == self.unitTypeFilter then
self:parseCast(destGUID, spellId, spellName)
end
end
function cleuHandlers:SPELL_HEAL(timestamp, subEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags,
spellId, spellName, spellSchool, amount, overhealing, absorbed, critical)
if bit_band(sourceFlags, self.unitTypeFilter) == self.unitTypeFilter then
local effective_heal = amount - overhealing
self:parseHeal(destGUID, destName, effective_heal, spellId, spellName, spellSchool, critical)
end
end
cleuHandlers.SPELL_PERIODIC_HEAL = cleuHandlers.SPELL_HEAL
function cleuHandlers:SPELL_MISSED(timestamp, subEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, spellId, spellName, spellSchool, missType)
-- spellId = ThreatLib.Classic and ThreatLib:GetSpellID(spellName, "player", auraType) or spellId
spellId = ThreatLib:GetSpellID(spellName, "player", auraType) or spellId
if bit_band(sourceFlags, self.unitTypeFilter) == self.unitTypeFilter and self.CastMissHandlers[spellId] then
self.CastMissHandlers[spellId](self, spellId, destGUID)
elseif bit_band(destFlags, self.unitTypeFilter) == self.unitTypeFilter and missType == "REFLECT" then
self.SpellReflectSources[sourceGUID] = spellId
elseif sourceGUID == destGUID and self.SpellReflectSources[sourceGUID] then
self.SpellReflectSources[sourceGUID] = nil
end
end
function cleuHandlers:DAMAGE_SHIELD(timestamp, subEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, spellId, spellName, spellSchool, amount, overkill, school, resisted, blocked, absorbed, critical, glancing, crushing, isOffHand)
if bit_band(sourceFlags, self.unitTypeFilter) == self.unitTypeFilter then
self:parseDamage(destGUID, amount, spellId, spellName, spellSchool, critical, subEvent)
end
end
function cleuHandlers:SPELL_ENERGIZE(timestamp, subEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, spellId, spellName, spellSchool, amount, overEnergize, powerType)
if bit_band(sourceFlags, self.unitTypeFilter) == self.unitTypeFilter then
self:parseGain(destGUID, destName, amount, spellId, spellName, spellSchool, overEnergize, powerType)
end
end
cleuHandlers.SPELL_PERIODIC_ENERGIZE = cleuHandlers.SPELL_ENERGIZE
function cleuHandlers:SPELL_AURA_APPLIED(timestamp, subEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags,
spellId, spellName, _, auraType)
if bit_band(destFlags, self.unitTypeFilter) == self.unitTypeFilter then
-- spellId = ThreatLib.Classic and ThreatLib:GetSpellID(spellName, "player", auraType) or spellId
spellId = ThreatLib:GetSpellID(spellName, "player", auraType) or spellId
ThreatLib:Debug("Applied spell %s ID %s ", spellName, spellId)
if self.BuffHandlers[spellId] then
ThreatLib:Debug("Running gain handler for spell ID %s", spellId)
self.BuffHandlers[spellId](self, "gain", spellId, 1)
end
if self.DebuffHandlers[spellId] then
self.DebuffHandlers[spellId](self, "gain", spellId, 1)
end
elseif auraType == AURA_TYPE_DEBUFF and bit_band(sourceFlags, self.unitTypeFilter) == self.unitTypeFilter and bit_band(destFlags, COMBATLOG_OBJECT_REACTION_HOSTILE) == COMBATLOG_OBJECT_REACTION_HOSTILE then
spellId = ThreatLib:GetSpellID(spellName, "target", auraType) or spellId
ThreatLib:Debug("aura applied debuff spellId %s name %s", spellId, spellName)
if self.MobDebuffHandlers[spellId] then
self.MobDebuffHandlers[spellId](self, spellId, destGUID)
end
if self.MobSpellNameDebuffHandlers[spellName] then
self.MobSpellNameDebuffHandlers[spellName](self, destGUID, timestamp)
end
end
end
function cleuHandlers:SPELL_AURA_APPLIED_DOSE(timestamp, subEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, spellId, spellName, _, auraType)
if auraType == AURA_TYPE_DEBUFF and bit_band(sourceFlags, self.unitTypeFilter) == self.unitTypeFilter and bit_band(destFlags, COMBATLOG_OBJECT_REACTION_HOSTILE) == COMBATLOG_OBJECT_REACTION_HOSTILE then
spellId = ThreatLib:GetSpellID(spellName, "target", auraType) or spellId
ThreatLib:Debug("aura applied dose debuff spellId %s name %s", spellId, spellName)
if self.MobDebuffHandlers[spellId] then
self.MobDebuffHandlers[spellId](self, spellId, destGUID)
end
if self.MobSpellNameDebuffHandlers[spellName] then
self.MobSpellNameDebuffHandlers[spellName](self, destGUID, timestamp)
end
end
end
function cleuHandlers:SPELL_AURA_REFRESH(timestamp, subEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, spellId, spellName, _, auraType)
if auraType == AURA_TYPE_DEBUFF and bit_band(sourceFlags, self.unitTypeFilter) == self.unitTypeFilter and bit_band(destFlags, COMBATLOG_OBJECT_REACTION_HOSTILE) == COMBATLOG_OBJECT_REACTION_HOSTILE then
spellId = ThreatLib:GetSpellID(spellName, "target", auraType) or spellId
ThreatLib:Debug("aura refresh debuff spellId %s name %s", spellId, spellName)
if self.MobDebuffHandlers[spellId] then
self.MobDebuffHandlers[spellId](self, spellId, destGUID)
end
if self.MobSpellNameDebuffHandlers[spellName] then
self.MobSpellNameDebuffHandlers[spellName](self, destGUID, timestamp)
end
end
end
function cleuHandlers:SPELL_AURA_REMOVED(timestamp, subEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags,
spellId, spellName)
if bit_band(destFlags, self.unitTypeFilter) == self.unitTypeFilter then
-- spellId = ThreatLib.Classic and ThreatLib:GetSpellID(spellName) or spellId
spellId = ThreatLib:GetSpellID(spellName) or spellId
ThreatLib:Debug("Removed spell %s ID %s ", spellName, spellId)
if self.BuffHandlers[spellId] then
ThreatLib:Debug("Running buff loss handler for spell ID %s", spellId)
self.BuffHandlers[spellId](self, "lose", spellId, 1)
rb = true
elseif self.DebuffHandlers[spellId] then
ThreatLib:Debug("Running debuff loss handler for spell ID %s", spellId)
self.DebuffHandlers[spellId](self, "lose", spellId, 1)
rd = true
end
end
end
function cleuHandlers:UNIT_DIED(timestamp, subEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags)
if bit_band(destFlags, self.unitTypeFilter) == self.unitTypeFilter then -- we died
self.totalThreatMods = nil
self:MultiplyThreat(0)
elseif self.targetThreat[destGUID] and self.targetThreat[destGUID] > 0 then -- something else died
self:MultiplyTargetThreat(destGUID, 0) -- Sort of a notification thing
end
self.targetThreat[destGUID] = nil
end
cleuHandlers.UNIT_DESTROYED = cleuHandlers.UNIT_DIED
function prototype:COMBAT_LOG_EVENT_UNFILTERED(event, ...)
local timestamp, subEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, param12, param13, param14, param15, param16, param17, param18, param19, param20, param21, param22, param23, param24 = CombatLogGetCurrentEventInfo()
guidLookup[sourceGUID] = sourceName
guidLookup[destGUID] = destName
-- We don't need to handle SPELL_SUMMON, and it's causing issues with shaman totems. Just kill it.
if subEvent == "SPELL_SUMMON" then return end
-- This catches heals/energizes from totems -> players, before the totems are friendly. Prevent them from being put into the threat table.
if (subEvent == "SPELL_PERIODIC_HEAL" or subEvent == "SPELL_PERIODIC_ENERGIZE") and sourceFlags == FAKE_HOSTILE then return end
-- Some mobs we really don't want to track, like Crypt Scarabs. Just return immediately.
-- Oddly, they don't have death or despawn events in the combat log, either. WHEE.
-- This generates extra garbage, but the net/CPU savings is well, well worth it.
if BLACKLIST_MOB_IDS[ThreatLib:NPCID(sourceGUID)] or BLACKLIST_MOB_IDS[ThreatLib:NPCID(destGUID)] then return end
-- If this is a hostile <-> party action then enter them into the list of threat targets for global threat accumulation
if not self.targetThreat[sourceGUID] and
bit_band(destFlags, AFFILIATION_IN_GROUP) > 0 and
bit_band(sourceFlags, REACTION_ATTACKABLE) > 0 and
bit_band(sourceFlags, COMBATLOG_OBJECT_CONTROL_NPC) == COMBATLOG_OBJECT_CONTROL_NPC and
bit_band(sourceFlags, NPC_TARGET) > 0 then
self.targetThreat[sourceGUID] = 0
elseif not self.targetThreat[destGUID] and
bit_band(sourceFlags, AFFILIATION_IN_GROUP) > 0 and
bit_band(destFlags, REACTION_ATTACKABLE) > 0 and
bit_band(destFlags, COMBATLOG_OBJECT_CONTROL_NPC) == COMBATLOG_OBJECT_CONTROL_NPC and
bit_band(destFlags, NPC_TARGET) > 0 then
self.targetThreat[destGUID] = 0
end
local nextEventHook = self.nextEventHook
if nextEventHook then
nextEventHook(self, timestamp, subEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, param12, param13, param14, param15, param16, param17, param18, param19, param20, param21, param22, param23, param24)
self.nextEventHook = nil
end
local handler = cleuHandlers[subEvent]
if handler then
handler(self, timestamp, subEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, param12, param13, param14, param15, param16, param17, param18, param19, param20, param21, param22, param23, param24)
end
end
------------------------------------------------
-- Internal utility methods
------------------------------------------------
function prototype:NumMobs()
-- self.targetThreat is a hash, so #self.targetThreat won't work
-- TODO: Cache this value
local ct = 0
for k, v in pairs(self.targetThreat) do
ct = ct + 1
end
return ct
end
function prototype:threatMods()
if self.totalThreatMods ~= nil then
return self.totalThreatMods
end
local deathMod = 1
if UnitIsDead(self.unitType) then
deathMod = 0
end
self.totalThreatMods = self.buffThreatMultipliers * self.passiveThreatModifiers * self.debuffThreatMultipliers * self.enchantMods * deathMod
return self.totalThreatMods
end
------------------------------------------------
-- Equipment handling
------------------------------------------------
function prototype:getWornSetPieces(name)
if self.unitType == "pet" then
return 0
end
if self.itemSetsWorn[name] then
return self.itemSetsWorn[name]
end
local ct = 0
local data = self.itemSets[name]
if data then
for i = 1, #data do
if IsEquippedItem(data[i]) then
ct = ct + 1
end
end
end
self.itemSetsWorn[name] = ct
return ct
end
-- Rockbiter
local rockbiterEnchants = {
[29] = 6, -- 1
[6] = 10, -- 2
[1] = 16, -- 3
[503] = 27, -- 4
[1663] = 41, -- 5
[683] = 55, -- 6
[1664] = 72, -- 7
}
function prototype:equipChanged(units)
if (units and not units.player) then
return
end
local _, _, _, mainHandEnchantID, _, _, _, offHandEnchantId = GetWeaponEnchantInfo()
local mainSpeed, offSpeed = UnitAttackSpeed("player")
if mainHandEnchantID then
for k, v in pairs(rockbiterEnchants) do
if mainHandEnchantID == k then
self.rockbiterMHVal = v and (v * mainSpeed) or 0
break
elseif offHandEnchantId ~= k then
self.rockbiterOHVal = 0
end
end
else
self.rockbiterMHVal = 0
end
if offHandEnchantId then
for k, v in pairs(rockbiterEnchants) do
if offHandEnchantId == k then
self.rockbiterOHVal = v and (v * offSpeed) or 0
break
elseif offHandEnchantId ~= k then
self.rockbiterOHVal = 0
end
end
else
self.rockbiterOHVal = 0
end
if ThreatLib.inCombat() then return end -- only check weapons above if in combat
for k in pairs(self.itemSetsWorn) do
self.itemSetsWorn[k] = nil
end
self.enchantMods = 1
-- Enchant Cloak - Subtlety: Decreases threat caused by 2%.
local enchant = select(3, strsplit(":", GetInventoryItemLink("player", 15) or ""))
if tonumber(enchant) == 2621 then
self.enchantMods = self.enchantMods - 0.02
end
-- Enchant Gloves - Threat: Increases threat generation from all attacks and spells by 2%.
enchant = select(3, strsplit(":", GetInventoryItemLink("player", 10) or ""))
if tonumber(enchant) == 2613 then
self.enchantMods = self.enchantMods + 0.02
end
-- tonumber here to speed up with possible future trinkets
local trinket1ID = GetInventoryItemID("player", 13)
local trinket2ID = GetInventoryItemID("player", 14)
self.meleeCritReduction = 0
self.spellCritReduction = 0
-- Prism of Inner Calm, see http://www.wowhead.com/?item=30621
if trinket1ID == 30621 or trinket2ID == 30621 then
self.meleeCritReduction = 150
self.spellCritReduction = 1000
end
self.totalThreatMods = nil
end
----------------------------------------------------------------------------------
-- Buff modifier handling
----------------------------------------------------------------------------------
function prototype:AddBuffThreatMultiplier(multiplier)
self.buffThreatMultipliers = self.buffThreatMultipliers * multiplier
ThreatLib:Debug("Set buffThreatMultipliers to %s", multiplier)
self.totalThreatMods = nil
end
function prototype:AddBuffThreatModifier(amount)
self.buffThreatFlatMods = self.buffThreatFlatMods + amount
self.totalThreatMods = nil
end
----------------------------------------------------------------------------------
-- Used to construct your buff modifiers. Currently O(n^2) due to the need to get
-- the spell ID, yech!
-- Metatables make this O(n) for subsequent lookups, so it sucks less, yay!
----------------------------------------------------------------------------------
function prototype:calcBuffMods(action, spellId)
ThreatLib:Debug("Calculating buff mods, action is %s, spell ID is %s", action, spellId)
self.buffThreatMultipliers = 1
local name, count, sid, id, _
for i = 1, 40 do
name, _, count, _, _, _, _, _, _, sid = UnitAura("player", i)
if not name then break end
id = self.playerBuffSpellIDs[sid]
if id and not (action == "lose" and id == spellId) then
local func = BuffModifiers[id] or self.BuffHandlers[id]
if func then
func(self, "exist", id, count)
end
end
end
ThreatLib:Debug("Final buff mods: %s", self.buffThreatMultipliers)
self.totalThreatMods = nil
end
function prototype:calcDebuffMods(action, spellId)
ThreatLib:Debug("Calculating debuff mods, action is %s, spell ID is %s", action, spellId)
self.debuffThreatMultipliers = 1
local name, count, sid, id, _
for i = 1, 40 do
name, _, count, _, _, _, _, _, _, sid = UnitAura("player", i, "HARMFUL")
if not name then break end
id = self.playerDebuffSpellIDs[sid]
if id and not (action == "lose" and id == spellId) then
ThreatLib:Debug("Running action for spell ID %s (%s)", id, GetSpellInfo(id))
local func = DebuffModifiers[id] or self.DebuffHandlers[id]
if func then
func(self, "exist", id, count)
end
end
end
ThreatLib:Debug("Final debuff mods: %s", self.debuffThreatMultipliers)
self.totalThreatMods = nil
end
----------------------------------------------------------------------------------
-- Debuff modifier handling
----------------------------------------------------------------------------------
function prototype:AddDebuffThreatMultiplier(multiplier)
self.debuffThreatMultipliers = self.debuffThreatMultipliers * multiplier
ThreatLib:Debug("Set debuffThreatMultipliers to %s", multiplier)
self.totalThreatMods = nil
end
function prototype:AddDebuffThreatModifier(amount)
self.debuffThreatFlatMods = self.debuffThreatFlatMods + amount
self.totalThreatMods = nil
end
---------------------------------------------------------------------------
-- End buffs/debuffs
---------------------------------------------------------------------------
function prototype:parseDamage(recipient, threat, spellId, spellName, spellSchool, isCrit, subEvent, isOffHand)
if isCrit then
if self.meleeCritReduction > 0 and spellSchool == SCHOOL_MASK_PHYSICAL then
threat = threat - self.meleeCritReduction
elseif self.spellCritReduction > 0 and spellSchool ~= SCHOOL_MASK_PHYSICAL then
threat = threat - self.spellCritReduction
end
end
if spellName == MELEE and not isOffHand and self.rockbiterMHVal > 0 then
threat = threat + self.rockbiterMHVal
elseif spellName == MELEE and isOffHand and self.rockbiterMHVal > 0 then
threat = threat + self.rockbiterOHVal
end
spellId = ThreatLib:GetSpellID(spellName) or spellId
local handler = self.AbilityHandlers[spellId]
if handler then
threat = handler(self, threat, isCrit)
end
handler = self.schoolThreatMods[spellSchool]
if handler then
threat = handler(self, threat)
end
self:AddTargetThreat(recipient, threat * self:threatMods())
end
function prototype:parseHeal(recipient, recipientName, amount, spellId, spellName, spellSchool, isCrit)
local unitID = recipientName
if not ThreatLib.inCombat() or not unitID or not UnitAffectingCombat(unitID) then
return
end
local threat = amount
spellId = ThreatLib:GetSpellID(spellName) or spellId
if not self.ExemptGains[spellId] then
local handler = self.AbilityHandlers[spellId]
if handler then
threat = handler(self, threat, isCrit)
end
handler = self.schoolThreatMods[spellSchool]
if handler then
threat = handler(self, threat)
end
threat = threat * 0.5 * self:threatMods()
if threat ~= 0 then
self:AddThreat(threat)
end
end
end
function prototype:parseGain(recipient, recipientName, amount, spellId, spellName, spellSchool, overEnergize, powerType)
if not ThreatLib.inCombat() then
return
end
local maxgain
if recipientName then
maxgain = UnitPowerMax(recipientName) - UnitPower(recipientName)
else
return -- This can happen if a gain is procced on someone that is not in our party - for example, Blackheart MCs someone and benefits from a gain from that person.
end
local amount = math_min(maxgain, amount)