-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathLibClassicCasterino.lua
3560 lines (3463 loc) · 56.2 KB
/
LibClassicCasterino.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
--[================[
LibClassicCasterino
Author: d87
--]================]
if WOW_PROJECT_ID ~= WOW_PROJECT_CLASSIC then return end
local apiLevel = math.floor(select(4,GetBuildInfo())/10000)
local isClassic = apiLevel <= 2
local isVanilla = apiLevel == 1
local isBC = apiLevel == 2
local MAJOR, MINOR = "LibClassicCasterino", 37
local lib = LibStub:NewLibrary(MAJOR, MINOR)
if not lib then return end
lib.callbacks = lib.callbacks or LibStub("CallbackHandler-1.0"):New(lib)
lib.frame = lib.frame or CreateFrame("Frame")
local f = lib.frame
local callbacks = lib.callbacks
lib.casters = lib.casters or {} -- setmetatable({}, { __mode = "v" })
local casters = lib.casters
lib.movecheckGUIDs = lib.movecheckGUIDs or {}
local movecheckGUIDs = lib.movecheckGUIDs
local MOVECHECK_TIMEOUT = 4
local UnitGUID = UnitGUID
local bit_band = bit.band
local GetSpellInfo = GetSpellInfo
local GetTime = GetTime
local CastingInfo = CastingInfo
local ChannelInfo = ChannelInfo
local GetUnitSpeed = GetUnitSpeed
local UnitIsUnit = UnitIsUnit
local COMBATLOG_OBJECT_REACTION_FRIENDLY = COMBATLOG_OBJECT_REACTION_FRIENDLY
local COMBATLOG_OBJECT_TYPE_PLAYER_OR_PET = COMBATLOG_OBJECT_TYPE_PLAYER + COMBATLOG_OBJECT_TYPE_PET
local classCasts
local classChannelsByAura
local classChannelsByCast
local talentDecreased
local crowdControlAuras
local FireToUnits
f:SetScript("OnEvent", function(self, event, ...)
return self[event](self, event, ...)
end)
local spellNameToID = {}
local NPCspellNameToID = {}
local NPCSpells
local function makeCastUIDFromSpellID(npcID, spellID)
return tostring(npcID)..GetSpellInfo(spellID)
end
local castTimeCache = {
[makeCastUIDFromSpellID(15990, 8407)] = 2, -- Kel'Thuzad, "Frostbolt"
}
local castTimeCacheStartTimes = setmetatable({}, { __mode = "v" })
local AIMED_SHOT = GetSpellInfo(19434)
local MULTI_SHOT = GetSpellInfo(25294)
local AimedDelay = 1
local castingAimedShot = false
local playerGUID = UnitGUID("player")
--[[
function DUMPCASTS()
local castedSpells = {}
local counter = 0
for id=1,40000 do
local name, _, texture, castTime = GetSpellInfo(id)
136235 -- interface/icons/temp.blp -- Samwise Didier Icon aka missing icon
if name and castTime > 500 and texture ~= 136235 then
castedSpells[id] = true
counter = counter + 1
end
end
print(counter)
NugHealthDB.LCDDUMP = castedSpells
end
]]
local refreshCastTable = function(tbl, ...)
local numArgs = select("#", ...)
for i=1, numArgs do
tbl[i] = select(i, ...)
end
end
local makeCastUID = function(guid, spellName)
local _, _, _, _, _, npcID = strsplit("-", guid);
npcID = npcID or "Unknown"
return npcID..spellName
end
local function CastStart(srcGUID, castType, spellName, spellID, overrideCastTime, isSrcEnemyPlayer )
-- This cast time can't be used reliably because it's changing depending on player's own haste
local _, _, icon, castTime = GetSpellInfo(spellID)
if castType == "CAST" then
local knownCastDuration = classCasts[spellID]
if knownCastDuration then
castTime = knownCastDuration*1000
end
end
if castType == "CHANNEL" then
local channelDuration = classChannelsByAura[spellID] or classChannelsByCast[spellID]
castTime = channelDuration*1000
end
local decreased = talentDecreased[spellID]
if decreased then
castTime = castTime - decreased*1000
end
if overrideCastTime then
castTime = overrideCastTime
end
local now = GetTime()*1000
local startTime = now
local endTime = now + castTime
local currentCast = casters[srcGUID]
if currentCast then
refreshCastTable(currentCast, castType, spellName, icon, startTime, endTime, spellID )
else
casters[srcGUID] = { castType, spellName, icon, startTime, endTime, spellID }
end
if isSrcEnemyPlayer then
if not (spellID == 4068 or spellID == 19769) then -- Iron Grenade, Thorium Grenade
movecheckGUIDs[srcGUID] = MOVECHECK_TIMEOUT
end
end
if castType == "CAST" then
if srcGUID == playerGUID and (spellName == AIMED_SHOT or spellName == MULTI_SHOT) then
castingAimedShot = true
AimedDelay = 1
movecheckGUIDs[srcGUID] = MOVECHECK_TIMEOUT
if spellName == MULTI_SHOT then
casters[srcGUID][5] = startTime + 500
end
callbacks:Fire("UNIT_SPELLCAST_START", "player")
end
FireToUnits("UNIT_SPELLCAST_START", srcGUID)
else
FireToUnits("UNIT_SPELLCAST_CHANNEL_START", srcGUID)
end
end
local function CastStop(srcGUID, castType, suffix, suffix2 )
local currentCast = casters[srcGUID]
if currentCast then
castType = castType or currentCast[1]
casters[srcGUID] = nil
movecheckGUIDs[srcGUID] = nil
if castType == "CAST" then
local event = "UNIT_SPELLCAST_"..suffix
if srcGUID == playerGUID and castingAimedShot then
castingAimedShot = false
callbacks:Fire(event, "player")
end
FireToUnits(event, srcGUID)
if suffix2 then
FireToUnits("UNIT_SPELLCAST_"..suffix2, srcGUID)
end
else
FireToUnits("UNIT_SPELLCAST_CHANNEL_STOP", srcGUID)
end
end
end
function f:COMBAT_LOG_EVENT_UNFILTERED(event)
local timestamp, eventType, hideCaster,
srcGUID, srcName, srcFlags, srcFlags2,
dstGUID, dstName, dstFlags, dstFlags2,
spellID, spellName, arg3, arg4, arg5,
arg6, resisted, blocked, absorbed = CombatLogGetCurrentEventInfo()
local isSrcPlayer = bit_band(srcFlags, COMBATLOG_OBJECT_TYPE_PLAYER_OR_PET) > 0
if isSrcPlayer and spellID == 0 then
spellID = spellNameToID[spellName]
end
if eventType == "SPELL_CAST_START" then
if isSrcPlayer then
local isCasting = classCasts[spellID]
if isCasting then
local isSrcFriendlyPlayer = bit_band(srcFlags, COMBATLOG_OBJECT_REACTION_FRIENDLY) > 0
CastStart(srcGUID, "CAST", spellName, spellID, nil, not isSrcFriendlyPlayer)
end
else
local castUID = makeCastUID(srcGUID, spellName)
local cachedTime = castTimeCache[castUID]
local spellID = NPCspellNameToID[spellName] -- just for the icon
if not spellID then
spellID = 4036 -- Engineering Icon
end
if cachedTime then
CastStart(srcGUID, "CAST", spellName, spellID, cachedTime*1000)
else
castTimeCacheStartTimes[srcGUID..castUID] = GetTime()
CastStart(srcGUID, "CAST", spellName, spellID, 1500) -- using default 1.5s cast time for now
end
end
elseif eventType == "SPELL_CAST_FAILED" then
CastStop(srcGUID, "CAST", "INTERRUPTED", "STOP")
elseif eventType == "SPELL_CAST_SUCCESS" then
if isSrcPlayer then
if classChannelsByAura[spellID] then
-- SPELL_CAST_SUCCESS can come right after AURA_APPLIED, so ignoring it
return
elseif classChannelsByCast[spellID] then
-- Channels fire SPELL_CAST_SUCCESS at their start
local isChanneling = classChannelsByCast[spellID]
if isChanneling then
local isSrcFriendlyPlayer = bit_band(srcFlags, COMBATLOG_OBJECT_REACTION_FRIENDLY) > 0
CastStart(srcGUID, "CHANNEL", spellName, spellID, nil, not isSrcFriendlyPlayer)
end
return
end
end
if not isSrcPlayer then
local castUID = makeCastUID(srcGUID, spellName)
local cachedTime = castTimeCache[castUID]
if not cachedTime then
local restoredStartTime = castTimeCacheStartTimes[srcGUID..castUID]
if restoredStartTime then
local now = GetTime()
local castTime = now - restoredStartTime
if castTime < 10 then
castTimeCache[castUID] = castTime
end
end
end
end
CastStop(srcGUID, nil, "SUCCEEDED", "STOP")
elseif eventType == "SPELL_INTERRUPT" then
CastStop(dstGUID, nil, "INTERRUPTED", "STOP")
elseif eventType == "UNIT_DIED" then
CastStop(dstGUID, nil, "INTERRUPTED", "STOP")
elseif eventType == "SPELL_AURA_APPLIED" or
eventType == "SPELL_AURA_REFRESH" or
eventType == "SPELL_AURA_APPLIED_DOSE"
then
if isSrcPlayer then
if crowdControlAuras[spellName] then
CastStop(dstGUID, nil, "INTERRUPTED", "STOP")
return
end
local isChanneling = classChannelsByAura[spellID]
if isChanneling then
local isSrcFriendlyPlayer = bit_band(srcFlags, COMBATLOG_OBJECT_REACTION_FRIENDLY) > 0
CastStart(srcGUID, "CHANNEL", spellName, spellID, nil, not isSrcFriendlyPlayer)
end
end
elseif eventType == "SPELL_AURA_REMOVED" then
if isSrcPlayer then
local isChanneling = classChannelsByAura[spellID]
if isChanneling then
CastStop(srcGUID, "CHANNEL", "STOP")
end
end
elseif castingAimedShot and dstGUID == UnitGUID("player") then
if eventType == "SWING_DAMAGE" or
eventType == "ENVIRONMENTAL_DAMAGE" or
eventType == "RANGE_DAMAGE" or
eventType == "SPELL_DAMAGE"
then
if resisted or blocked or absorbed then return end
local currentCast = casters[UnitGUID("player")]
if currentCast then
refreshCastTable(currentCast, currentCast[1], currentCast[2], currentCast[3], currentCast[4], currentCast[5] + (AimedDelay *1000))
if AimedDelay > 0.2 then
AimedDelay = AimedDelay - 0.2
end
callbacks:Fire("UNIT_SPELLCAST_DELAYED", "player")
end
end
end
end
local castTimeIncreases = {
[1714] = 1.5, -- Curse of Tongues (Rank 1) (50%)
[11719] = 1.6, -- Curse of Tongues (Rank 2) (60%)
[5760] = 1.4, -- Mind-Numbing Poison (Rank 1) (40%)
[8692] = 1.5, -- Mind-Numbing Poison (Rank 2) (50%)
[11398] = 1.6, -- Mind-Numbing Poison (Rank 3) (60%)
[1098] = 1.3, -- Enslave Demon (Rank 1) (30%)
[11725] = 1.3, -- Enslave Demon (Rank 2) (30%)
[11726] = 1.3, -- Enslave Demon (Rank 3) (30%)
}
local attackTimeDecreases = {
[6150] = 1.3, -- Quick Shots/ Imp Aspect of the Hawk (Aimed)
[3045] = 1.4, -- Rapid Fire (Aimed)
[28866] = 1.2, -- Kiss of the Spider (Increases your _attack speed_ by 20% for 15 sec.) -- For Aimed
}
local function GetTrollBerserkHaste(unit)
local perc = UnitHealth(unit)/UnitHealthMax(unit)
local speed = min((1.3 - perc)/3, .3) + 1
return speed
end
local function GetRangedHaste(unit)
local positiveMul = 1
for i=1, 100 do
local name, _, _, _, _, _, _, _, _, spellID = UnitAura(unit, i, "HELPFUL")
if not name then return positiveMul end
if attackTimeDecreases[spellID] or spellID == 26635 then
positiveMul = positiveMul * (attackTimeDecreases[spellID] or GetTrollBerserkHaste(unit))
end
end
return positiveMul
end
local function GetCastSlowdown(unit)
local negativeEx = 1
for i=1, 100 do
local name, _, _, _, _, _, _, _, _, spellID = UnitAura(unit, i, "HARMFUL")
if not name then return negativeEx end
if castTimeIncreases[spellID] then
negativeEx = math.max(negativeEx, castTimeIncreases[spellID])
end
end
return negativeEx
end
function lib:UnitCastingInfo(unit)
if UnitIsUnit(unit,"player") then
if not castingAimedShot then
return CastingInfo()
end
end
local guid = UnitGUID(unit)
local cast = casters[guid]
if cast then
local castType, name, icon, startTimeMS, endTimeMS, spellID = unpack(cast)
if castingAimedShot and spellID ~= 25294 then -- Multi-Shot spellID
local haste = GetRangedHaste(unit)
local duration = endTimeMS - startTimeMS
endTimeMS = startTimeMS + duration/haste
end
local slowdown = GetCastSlowdown(unit)
if slowdown ~= 1 then
local duration = endTimeMS - startTimeMS
endTimeMS = startTimeMS + duration * slowdown
end
if castType == "CAST" and endTimeMS > GetTime()*1000 then
local castID = nil
return name, nil, icon, startTimeMS, endTimeMS, nil, castID, false, spellID
end
end
end
function lib:UnitChannelInfo(unit)
if UnitIsUnit(unit, "player") then return ChannelInfo() end
local guid = UnitGUID(unit)
local cast = casters[guid]
if cast then
local castType, name, icon, startTimeMS, endTimeMS, spellID = unpack(cast)
-- Curse of Tongues doesn't matter that much for channels, skipping
if castType == "CHANNEL" and endTimeMS > GetTime()*1000 then
return name, nil, icon, startTimeMS, endTimeMS, nil, false, spellID
end
end
end
local Passthrough = function(self, event, unit, ...)
if unit == "player" or UnitIsUnit(unit, "player") then
callbacks:Fire(event, unit, ...)
end
end
if isBC then
Passthrough = function(self, event, unit, ...)
callbacks:Fire(event, unit, ...)
end
lib.UnitChannelInfo = function(self, ...)
return _G.UnitChannelInfo(...)
end
lib.UnitCastingInfo = function(self, ...)
return _G.UnitCastingInfo(...)
end
end
f.UNIT_SPELLCAST_START = Passthrough
f.UNIT_SPELLCAST_DELAYED = Passthrough
f.UNIT_SPELLCAST_STOP = Passthrough
f.UNIT_SPELLCAST_FAILED = Passthrough
f.UNIT_SPELLCAST_INTERRUPTED = Passthrough
f.UNIT_SPELLCAST_CHANNEL_START = Passthrough
f.UNIT_SPELLCAST_CHANNEL_UPDATE = Passthrough
f.UNIT_SPELLCAST_CHANNEL_STOP = Passthrough
f.UNIT_SPELLCAST_SUCCEEDED = Passthrough
function callbacks.OnUsed()
if isVanilla then
f:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
-- for unit lookup
f:RegisterEvent("GROUP_ROSTER_UPDATE")
f:RegisterEvent("NAME_PLATE_UNIT_ADDED")
f:RegisterEvent("NAME_PLATE_UNIT_REMOVED")
end
f:RegisterEvent("UNIT_SPELLCAST_START")
f:RegisterEvent("UNIT_SPELLCAST_DELAYED")
f:RegisterEvent("UNIT_SPELLCAST_STOP")
f:RegisterEvent("UNIT_SPELLCAST_FAILED")
f:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED")
f:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START")
f:RegisterEvent("UNIT_SPELLCAST_CHANNEL_UPDATE")
f:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP")
f:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
end
function callbacks.OnUnused()
f:UnregisterAllEvents()
end
talentDecreased = {
[25311] = 0.8, -- Corruption (while leveling)
[17924] = 2, -- Soul Fire
[25307] = 0.5, -- Shadow Bolt
[25309] = 0.5, -- Immolate
[691] = 4, -- Summon Felhunter
[688] = 4, -- Summon Imp
[697] = 4, -- Summon Voidwalker
[712] = 4, -- Summon Succubus
[15208] = 1, -- Lightning Bolt
[10605] = 1, -- Chain Lightning
[25357] = 0.5, -- Healing Wave
[2645] = 2, -- Ghost Wolf
[25304] = 0.5, -- Frostbolt
[25306] = 0.5, -- Fireball
[10934] = 0.5, -- Smite
[15261] = 0.5, -- Holy Fire
[6064] = 0.5, -- Heal
[25314] = 0.5, -- Greater Heal
[10876] = 0.5, -- Mana Burn
[9912] = 0.5, -- Wrath
[25298] = 0.5, -- Starfire
[25297] = 0.5, -- Healing Touch
}
classCasts = {
[25311] = 2, -- Corruption
[6215] = 1.5, -- Fear
[17928] = 2, -- Howl of Terror
[18647] = 1.5, -- Banish
[6366] = 3, -- Create Firestone (Lesser)
[17951] = 3, -- Create Firestone
[17952] = 3, -- Create Firestone (Greater)
[17953] = 3, -- Create Firestone (Major)
[28023] = 3, -- Create Healthstone
[11729] = 3, -- Create Healthstone (Greater)
[6202] = 3, -- Create Healthstone (Lesser)
[11730] = 3, -- Create Healthstone (Major)
[6201] = 3, -- Create Healthstone (Minor)
[20755] = 3, -- Create Soulstone
[20756] = 3, -- Create Soulstone (Greater)
[20752] = 3, -- Create Soulstone (Lesser)
[20757] = 3, -- Create Soulstone (Major)
[693] = 3, -- Create Soulstone (Minor)
[2362] = 5, -- Create Spellstone
[17727] = 5, -- Create Spellstone (Greater)
[17728] = 5, -- Create Spellstone (Major)
[11726] = 3, -- Enslave Demon
[126] = 5, -- Eye of Kilrogg
[1122] = 2, -- Inferno
[23161] = 3, -- Summon Dreadsteed
[5784] = 3, -- Summon Felsteed
[691] = 10, -- Summon Felhunter
[688] = 10, -- Summon Imp
[697] = 10, -- Summon Voidwalker
[712] = 10, -- Summon Succubus
[25309] = 2, -- Immolate
[17923] = 1.5, -- Searing Pain
[25307] = 3, -- Shadow Bolt
[17924] = 4, -- Soul Fire
[6358] = 1.5, -- Seduction
[11763] = 2, -- Firebolt (Imp)
[9853] = 1.5, -- Entangling Roots
[18658] = 1.5, -- Hibernate
[9901] = 1.5, -- Soothe Animal
[25298] = 3.5, -- Starfire
[18960] = 10, -- Teleport: Moonglade
[9912] = 2, -- Wrath
[25297] = 3.5, -- Healing Touch
[20748] = 2, -- Rebirth
[9858] = 2, -- Regrowth
[28612] = 3, -- Conjure Food
[759] = 3, -- Conjure Mana Agate
[10053] = 3, -- Conjure Mana Citrine
[3552] = 3, -- Conjure Mana Jade
[10054] = 3, -- Conjure Mana Ruby
[10140] = 3, -- Conjure Water
[12826] = 1.5, -- Polymorph
[25306] = 3.5, -- Fireball
[10216] = 3, -- Flamestrike
[10207] = 1.5, -- Scorch
[25304] = 3, -- Frostbolt
[3561] = 10, -- Teleport: Stormwind
[3562] = 10, -- Teleport: Ironforge
[3563] = 10, -- Teleport: Undercity
[3565] = 10, -- Teleport: Darnassus
[3566] = 10, -- Teleport: Thuner Bluff
[3567] = 10, -- Teleport: Orgrimmar
[10059] = 10, -- Portal: Stormwind
[11416] = 10, -- Portal: Ironforge
[11418] = 10, -- Portal: Undercity
[11419] = 10, -- Portal: Darnassus
[11420] = 10, -- Portal: Thuner Bluff
[11417] = 10, -- Portal: Orgrimmar
[10876] = 3, -- Mana Burn
[10955] = 1.5, -- Shackle Undead
[10917] = 1.5, -- Flash Heal
[25314] = 3, -- Greater Heal
[6064] = 3, -- Heal
[15261] = 3.5, -- Holy Fire
[2053] = 2.5, -- Lesser Heal
[25316] = 3, -- Prayer of Healing
[20770] = 10, -- Resurrection
[10934] = 2.5, -- Smite
[10947] = 1.5, -- Mind Blast
[10912] = 3, -- Mind Control
[19943] = 1.5, -- Flash of Light
[24239] = 1, -- Hammer of Wrath
[25292] = 2.5, -- Holy Light
[10318] = 2, -- Holy Wrath
[20773] = 10, -- Redemption
[23214] = 3, -- Summon Charger
[13819] = 3, -- Summon Warhorse
[10326] = 1.5, -- Turn Undead
[10605] = 2.5, -- Chain Lightning
[15208] = 3, -- Lightning Bolt
[556] = 10, -- Astral Recall
[6196] = 2, -- Far Sight
[2645] = 3, -- Ghost Wolf
[20777] = 10, -- Ancestral Spirit
[10623] = 2.5, -- Chain Heal
[25357] = 3, -- Healing Wave
[10468] = 1.5, -- Lesser Healing Wave
[1842] = 2, -- Disarm Trap
-- missing poison creation
[11605] = 1.5, -- Slam
[20904] = 3, -- Aimed Shot
[25294] = 0.5, -- Multi-Shot
[1002] = 2, -- Eyes of the Beast
[2641] = 5, -- Dismiss pet
[982] = 10, -- Revive Pet
[14327] = 1.5, -- Scare Beast
[8690] = 10, -- Hearthstone
[4068] = 1, -- Iron Grenade
[19769] = 1, -- Thorium Grenade
[20589] = 0.5, -- Escape Artist
-- Munts do not generate SPELL_CAST_START
-- [8394] = 3, -- Striped Frostsaber
-- [10793] = 3, -- Striped Nightsaber
}
classChannelsByAura = {
[746] = 6, -- First Aid
[20577] = 10, -- Cannibalize
[19305] = 6, -- Starshards
-- DRUID
[17402] = 10, -- Hurricane
[9863] = 10, -- Tranquility
-- HUNTER
[6197] = 60, -- Eagle Eye
[13544] = 5, -- Mend Pet
[1515] = 20, -- Tame Beast
[1002] = 60, -- Eyes of the Beast
[14295] = 6, -- Volley
[10187] = 8, -- Blizzard
[12051] = 8, -- Evocation
-- PRIEST
[18807] = 3, -- Mind Flay
[2096] = 60, -- Mind Vision
[10912] = 3, -- Mind Control
-- WARLOCK
[126] = 45, -- Eye of Kilrogg
[11700] = 5, -- Drain Life
[11704] = 5, -- Drain Mana
[11675] = 15, -- Drain Soul
[11678] = 8, -- Rain of Fire
[11684] = 15, -- Hellfire
[11695] = 10, -- Health Funnel
[6358] = 15, -- Seduction
[17854] = 10, -- Consume Shadows (Voidwalker)
}
classChannelsByCast = {
[13278] = 4, -- Gnomish Death Ray
-- MAGE
[25345] = 5, -- Arcane Missiles
}
for id in pairs(classCasts) do
spellNameToID[GetSpellInfo(id)] = id
end
for id in pairs(classChannelsByAura) do
spellNameToID[GetSpellInfo(id)] = id
end
for id in pairs(classChannelsByCast) do
spellNameToID[GetSpellInfo(id)] = id
end
local partyGUIDtoUnit = {}
local raidGUIDtoUnit = {}
local nameplateGUIDtoUnit = {}
local commonUnits = {
-- "player",
"target",
"targettarget",
"pet",
}
function f:NAME_PLATE_UNIT_ADDED(event, unit)
local unitGUID = UnitGUID(unit)
nameplateGUIDtoUnit[unitGUID] = unit
end
function f:NAME_PLATE_UNIT_REMOVED(event, unit)
local unitGUID = UnitGUID(unit) -- Unit still exists at this point
nameplateGUIDtoUnit[unitGUID] = nil
end
function f:GROUP_ROSTER_UPDATE()
table.wipe(partyGUIDtoUnit)
table.wipe(raidGUIDtoUnit)
if IsInGroup() then
for i=1,4 do
local unit = "party"..i
local guid = UnitGUID(unit)
if guid then
partyGUIDtoUnit[guid] = unit
end
end
end
if IsInRaid() then
for i=1,40 do
local unit = "raid"..i
local guid = UnitGUID(unit)
if guid then
raidGUIDtoUnit[guid] = unit
end
end
end
end
FireToUnits = function(event, guid, ...)
for _, unit in ipairs(commonUnits) do
if UnitGUID(unit) == guid then
callbacks:Fire(event, unit, ...)
end
end
local partyUnit = partyGUIDtoUnit[guid]
if partyUnit then
callbacks:Fire(event, partyUnit, ...)
end
local raidUnit = raidGUIDtoUnit[guid]
if raidUnit then
callbacks:Fire(event, raidUnit, ...)
end
local nameplateUnit = nameplateGUIDtoUnit[guid]
if nameplateUnit then
callbacks:Fire(event, nameplateUnit, ...)
end
end
crowdControlAuras = { -- from ClassicCastbars
[GetSpellInfo(5211)] = true, -- Bash
[GetSpellInfo(24394)] = true, -- Intimidation
[GetSpellInfo(853)] = true, -- Hammer of Justice
[GetSpellInfo(22703)] = true, -- Inferno Effect (Summon Infernal)
[GetSpellInfo(408)] = true, -- Kidney Shot
[GetSpellInfo(12809)] = true, -- Concussion Blow
[GetSpellInfo(20253)] = true, -- Intercept Stun
[GetSpellInfo(20549)] = true, -- War Stomp
[GetSpellInfo(2637)] = true, -- Hibernate
[GetSpellInfo(3355)] = true, -- Freezing Trap
[GetSpellInfo(19386)] = true, -- Wyvern Sting
[GetSpellInfo(118)] = true, -- Polymorph
[GetSpellInfo(28271)] = true, -- Polymorph: Turtle
[GetSpellInfo(28272)] = true, -- Polymorph: Pig
[GetSpellInfo(20066)] = true, -- Repentance
[GetSpellInfo(1776)] = true, -- Gouge
[GetSpellInfo(6770)] = true, -- Sap
[GetSpellInfo(1513)] = true, -- Scare Beast
[GetSpellInfo(8122)] = true, -- Psychic Scream
[GetSpellInfo(2094)] = true, -- Blind
[GetSpellInfo(5782)] = true, -- Fear
[GetSpellInfo(5484)] = true, -- Howl of Terror
[GetSpellInfo(6358)] = true, -- Seduction
[GetSpellInfo(5246)] = true, -- Intimidating Shout
[GetSpellInfo(6789)] = true, -- Death Coil
[GetSpellInfo(9005)] = true, -- Pounce
[GetSpellInfo(1833)] = true, -- Cheap Shot
[GetSpellInfo(16922)] = true, -- Improved Starfire
[GetSpellInfo(19410)] = true, -- Improved Concussive Shot
[GetSpellInfo(12355)] = true, -- Impact
[GetSpellInfo(20170)] = true, -- Seal of Justice Stun
[GetSpellInfo(15269)] = true, -- Blackout
[GetSpellInfo(18093)] = true, -- Pyroclasm
[GetSpellInfo(12798)] = true, -- Revenge Stun
[GetSpellInfo(5530)] = true, -- Mace Stun
[GetSpellInfo(19503)] = true, -- Scatter Shot
[GetSpellInfo(605)] = true, -- Mind Control
[GetSpellInfo(7922)] = true, -- Charge Stun
[GetSpellInfo(18469)] = true, -- Counterspell - Silenced
[GetSpellInfo(15487)] = true, -- Silence
[GetSpellInfo(18425)] = true, -- Kick - Silenced
[GetSpellInfo(24259)] = true, -- Spell Lock
[GetSpellInfo(18498)] = true, -- Shield Bash - Silenced
-- ITEMS
[GetSpellInfo(13327)] = true, -- Reckless Charge
[GetSpellInfo(1090)] = true, -- Sleep
[GetSpellInfo(5134)] = true, -- Flash Bomb Fear
[GetSpellInfo(19821)] = true, -- Arcane Bomb Silence
[GetSpellInfo(4068)] = true, -- Iron Grenade
[GetSpellInfo(19769)] = true, -- Thorium Grenade
[GetSpellInfo(13808)] = true, -- M73 Frag Grenade
[GetSpellInfo(4069)] = true, -- Big Iron Bomb
[GetSpellInfo(12543)] = true, -- Hi-Explosive Bomb
[GetSpellInfo(4064)] = true, -- Rough Copper Bomb
[GetSpellInfo(12421)] = true, -- Mithril Frag Bomb
[GetSpellInfo(19784)] = true, -- Dark Iron Bomb
[GetSpellInfo(4067)] = true, -- Big Bronze Bomb
[GetSpellInfo(4066)] = true, -- Small Bronze Bomb
[GetSpellInfo(4065)] = true, -- Large Copper Bomb
[GetSpellInfo(13237)] = true, -- Goblin Mortar
[GetSpellInfo(835)] = true, -- Tidal Charm
[GetSpellInfo(13181)] = true, -- Gnomish Mind Control Cap
[GetSpellInfo(12562)] = true, -- The Big One
[GetSpellInfo(15283)] = true, -- Stunning Blow (Weapon Proc)
[GetSpellInfo(56)] = true, -- Stun (Weapon Proc)
[GetSpellInfo(26108)] = true, -- Glimpse of Madness
}
------------------------------
-- Cast Interruption Checker
------------------------------
-- There's an issue that if you start a cast and immediately after cancel it, CAST_FAILED event won't ever come for it
-- This leads to zombie casts that have to run until completion
-- So for 4s after non-friendly player controlled guid started a cast we're watching if it's moving and cancel
do
local GetUnitForFreshGUID = function(guid)
local targetGUID = UnitGUID('target')
if guid == targetGUID then
return "target"
end
return nameplateGUIDtoUnit[guid]
end
f:SetScript("OnUpdate", function(self, elapsed)
local guid, timeout = next(movecheckGUIDs)
while guid ~= nil do
-- Removing while iterating here, but it doesn't matter
local timeStart = MOVECHECK_TIMEOUT - timeout
if timeStart > 0.25 then
local unit = GetUnitForFreshGUID(guid)
if unit then
if GetUnitSpeed(unit) ~= 0 then
CastStop(guid, nil, "INTERRUPTED")
movecheckGUIDs[guid] = nil
return
end
end
end
movecheckGUIDs[guid] = timeout - elapsed
if timeout - elapsed < 0 then
movecheckGUIDs[guid] = nil
end
-- print(guid, movecheckGUIDs[guid])
guid, timeout = next(movecheckGUIDs, guid)
end
end)
end
------------------------------
if lib.NPCSpellsTimer then
lib.NPCSpellsTimer:Cancel()
end
local prevID
local counter = 0
local function processNPCSpellTable()
counter = 0
local index, id = next(NPCSpells, prevID)
while (id and counter < 150) do
local spellName = GetSpellInfo(id)
if spellName then
NPCspellNameToID[spellName] = id
end
counter = counter + 1
prevID = index
index, id = next(NPCSpells, prevID)
end
if (id) then
C_Timer.After(1, processNPCSpellTable)
end
end
if isVanilla then
lib.NPCSpellsTimer = C_Timer.NewTimer(6.5, processNPCSpellTable)
end
NPCSpells = {
10215,
16587,
16651,
20874,
16971,
10695,
7428,
30152,
7588,
15238,
11399,
11431,
7828,
23242,
7892,
15910,
8004,
11975,
16102,
12039,
12071,
12167,
20299,
20427,
513,
16588,
4165,
20811,
20875,
25034,
529,
21067,
21131,
8552,
8712,
547,
8776,
555,
8936,
569,
9224,
4629,
581,
585,
587,
591,
2371,
13607,
2387,
2395,
9672,
27658,
27722,
13895,
9928,
4981,
19980,
14119,
635,
2547,
639,
10248,
2579,
647,
5189,
20876,
16973,
2667,
17293,
10792,
17613,
2739,
11016,
11048,
693,
15207,
697,
2795,
5605,
18445,
707,
2835,
711,
11400,
22924,
5781,
23308,
15783,
735,
27659,
23628,
19725,
16071,
19981,
12072,
28299,
759,
3067,
3075,
3083,
3091,
16590,
6213,
3115,
8489,
25292,
8617,
17294,
8681,
6405,
6421,
8809,
6469,
8873,
8905,
6517,
3275,
26444,
3323,
3331,
837,
6725,
13480,
6757,
3387,
9481,
9513,
13640,
855,
857,
3443,
6917,
867,
6949,
3491,
3507,
9961,
9993,
24141,
7077,
3563,
895,
7221,
16655,
3635,