-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDCR_init.lua
2144 lines (1769 loc) · 81.7 KB
/
DCR_init.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
--[[
This file is part of Decursive.
Decursive (v @project-version@) add-on for World of Warcraft UI
Copyright (C) 2006-2025 John Wellesz (Decursive AT 2072productions.com) ( http://www.2072productions.com/to/decursive.php )
Decursive is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Decursive is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Decursive. If not, see <https://www.gnu.org/licenses/>.
Decursive is inspired from the original "Decursive v1.9.4" by Patrick Bohnet (Quu).
The original "Decursive 1.9.4" is in public domain ( www.quutar.com )
Decursive is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
This file was last updated on @file-date-iso@
--]]
-------------------------------------------------------------------------------
local addonName, T = ...;
-- big ugly scary fatal error message display function {{{
if not T._FatalError then
-- the beautiful error popup : {{{ -
StaticPopupDialogs["DECURSIVE_ERROR_FRAME"] = {
text = "|cFFFF0000Decursive Error:|r\n%s",
button1 = "OK",
OnAccept = function()
return false;
end,
timeout = 0,
whileDead = 1,
hideOnEscape = 1,
showAlert = 1,
preferredIndex = 3,
}; -- }}}
T._FatalError = function (TheError) StaticPopup_Show ("DECURSIVE_ERROR_FRAME", TheError); end
end
-- }}}
if not T._LoadedFiles or not T._LoadedFiles["enUS.lua"] then
if not DecursiveInstallCorrupted then T._FatalError("Decursive installation is corrupted! (enUS.lua not loaded)"); end;
DecursiveInstallCorrupted = true;
return;
end
T._LoadedFiles["DCR_init.lua"] = false;
local D;
local _G = _G;
local select = _G.select;
local GetSpellInfo = _G.C_Spell and _G.C_Spell.GetSpellInfo or _G.GetSpellInfo;
local GetSpellName = _G.C_Spell and _G.C_Spell.GetSpellName or function (spellId) return (GetSpellInfo(spellId)) end;
local IsSpellKnown = nil; -- use D:isSpellReady instead
local GetSpecialization = _G.GetSpecialization;
local IsPlayerSpell = _G.IsPlayerSpell;
local GetAddOnMetadata = _G.C_AddOns and _G.C_AddOns.GetAddOnMetadata or _G.GetAddOnMetadata;
local GetItemInfo = _G.C_Item and _G.C_Item.GetItemInfo or _G.GetItemInfo;
local function RegisterDecursive_Once() -- {{{
T.Dcr = LibStub("AceAddon-3.0"):NewAddon("Decursive", "AceConsole-3.0", "AceEvent-3.0", "AceTimer-3.0", "AceHook-3.0"); -- XXX test this when a library is missing
D = T.Dcr;
--@debug@
--Dcr = T.Dcr;
--@end-debug@
D.name = "Decursive";
D.version = "@project-version@";
D.author = "John Wellesz";
D.DcrFullyInitialized = false;
RegisterDecursive_Once = nil;
end -- }}}
local function RegisterLocals_Once() -- {{{
D.L = LibStub("AceLocale-3.0"):GetLocale("Decursive", true);
-- Make sure to never crash if some locals are missing (seen this happen on
-- Chinese clients when relying on LOCALIZED_CLASS_NAMES_MALE constant)
-- While that was probably caused by a badd-on redefining the constant,
-- it's best to stay on the safe side...
D.LC = setmetatable((FillLocalizedClassList or LocalizedClassList)({}, false), {__index = function(t,k) return k end});
RegisterLocals_Once = nil;
end -- }}}
local function SetBasicConstants_Once() -- these are constants that may be used at parsing time in other .lua and .xml {{{
BINDING_HEADER_DECURSIVE = "Decursive";
local DC = T._C;
DC.IconON = "Interface\\AddOns\\Decursive\\iconON.tga";
DC.IconOFF = "Interface\\AddOns\\Decursive\\iconOFF.tga";
DC.MFSIZE = 20;
-- This value is returned by UnitName when the name of a unit is not available yet
DC.UNKNOWN = UNKNOWNOBJECT;
-- Get the translation for "pet"
DC.PET = SPELL_TARGET_TYPE8_DESC;
DC.DevVersionExpired = false; -- may be used early by the debugger
DC.MAGIC = 1;
DC.ENEMYMAGIC = 2;
DC.CURSE = 4;
DC.POISON = 8;
DC.DISEASE = 16;
DC.CHARMED = 32;
DC.BLEED = 64;
DC.NOTYPE = 128;
DC.CLASS_DRUID = 'DRUID';
DC.CLASS_HUNTER = 'HUNTER';
DC.CLASS_MAGE = 'MAGE';
DC.CLASS_PALADIN = 'PALADIN';
DC.CLASS_PRIEST = 'PRIEST';
DC.CLASS_ROGUE = 'ROGUE';
DC.CLASS_SHAMAN = 'SHAMAN';
DC.CLASS_WARLOCK = 'WARLOCK';
DC.CLASS_WARRIOR = 'WARRIOR';
DC.CLASS_DEATHKNIGHT = 'DEATHKNIGHT';
DC.CLASS_MONK = 'MONK';
DC.CLASS_DEMONHUNTER = 'DEMONHUNTER';
DC.CLASS_EVOKER = 'EVOKER';
DC.MyClass = "NOCLASS";
DC.MyName = "NONAME";
DC.MyGUID = "NONE";
DC.NORMAL = 8;
DC.ABSENT = 16;
DC.FAR = 32;
DC.STEALTHED = 64;
DC.BLACKLISTED = 128;
DC.AFFLICTED = 256;
DC.AFFLICTED_NIR = 512;
DC.CHARMED_STATUS = 1024;
DC.AFFLICTED_AND_CHARMED = bit.bor(DC.AFFLICTED, DC.CHARMED_STATUS);
DC.AfflictionSound = "Interface\\AddOns\\Decursive\\Sounds\\AfflictionAlert.ogg";
DC.FailedSound = "Interface\\AddOns\\Decursive\\Sounds\\FailedSpell.ogg";
DC.DeadlyDebuffAlert = "Interface\\AddOns\\Decursive\\Sounds\\G_NecropolisWound-fast.ogg";
--DC.AfflictionSound = 566027
DC.EMPTY_TABLE = {};
SetBasicConstants_Once = nil;
end -- }}}
local function SetRuntimeConstants_Once () -- {{{
D.CONF = {}; -- this table is only used in dcr opt through a function
D.CONF.TEXT_LIFETIME = 4.0;
D.CONF.MAX_LIVE_SLOTS = 10;
D.CONF.MACRONAME = "Decursive";
D.CONF.MACROCOMMAND = "MACRO " .. D.CONF.MACRONAME;
local DC = T._C;
DC.DebuffHistoryLength = 40; -- we use a rather high value to avoid garbage creation
-- Create MUFs number fontinstance
DC.NumberFontFileName = _G.NumberFont_Shadow_Small:GetFont(); -- XXX only used during MUFs creation
DC.RAID_ICON_LIST = _G.ICON_LIST;
if not DC.RAID_ICON_LIST then
T._AddDebugText("DCR_init.lua: Couldn't get Raid Target Icon List!");
DC.RAID_ICON_LIST = {};
end
DC.RAID_ICON_TEXTURE_LIST = {};
for i,v in ipairs(DC.RAID_ICON_LIST) do
DC.RAID_ICON_TEXTURE_LIST[i] = "Interface\\TargetingFrame\\UI-RaidTargetingIcon_" .. i;
end
DC.TypeNames = {
[DC.MAGIC] = "Magic",
[DC.ENEMYMAGIC] = "Magic",
[DC.CURSE] = "Curse",
[DC.POISON] = "Poison",
[DC.DISEASE] = "Disease",
[DC.CHARMED] = "Charm",
[DC.BLEED] = "Bleed",
}
DC.NameToTypes = D:tReverse(DC.TypeNames);
DC.NameToTypes["Magic"] = DC.MAGIC; -- make sure 'Magic' is set to DC.MAGIC and not to DC.ENEMYMAGIC
DC.TypeToLocalizableTypeNames = {
[DC.MAGIC] = "MAGIC",
[DC.ENEMYMAGIC] = "MAGICCHARMED",
[DC.CURSE] = "CURSE",
[DC.POISON] = "POISON",
[DC.DISEASE] = "DISEASE",
[DC.CHARMED] = "CHARM",
[DC.BLEED] = "BLEED",
}
DC.LocalizableTypeNamesToTypes = D:tReverse(DC.TypeToLocalizableTypeNames);
-- Create some useful cache tables
local DS = T._C.DS;
local DSI = T._C.DSI;
if not DC.WOWC then
DC.IS_STEALTH_BUFF = D:tReverse({DS["Prowl"], DS["Stealth"], DS["Shadowmeld"], DS["Invisibility"], DS["Lesser Invisibility"], DS['Greater Invisibility']});
DC.IS_HARMFULL_DEBUFF = D:tReverse({DC.DS["Unstable Affliction"], DC.DS["Vampiric Touch"], DC.DS["MUTATINGINJECTION"]}); --, , DC.DS["Fluidity"]}); --, "Test item"});
DC.IS_DEADLY_DEBUFF = D:tReverse({DC.DSI["Fluidity"]});
DC.IS_OMNI_DEBUFF = D:tReverse({DC.DSI["DEBUFF_VOID_RIFT"]});
-- SPELL TABLE -- must be parsed after spell translations have been loaded {{{
DC.SpellsToUse = {
-- Druids
[DSI["SPELL_CYCLONE"]] = {
Types = {DC.CHARMED},
Better = 0,
Pet = false,
},
-- Mages
[DSI["SPELL_REMOVE_CURSE_MAGE"]] = {
Types = {DC.CURSE},
Better = 0,
Pet = false,
},
-- Shamans http://www.wowhead.com/?spell=51514
[DSI["SPELL_HEX"]] = {
Types = {DC.CHARMED},
Better = 0,
Pet = false,
},
-- Shamans
[DSI["SPELL_PURGE"]] = {
Types = {DC.ENEMYMAGIC},
Better = 0,
Pet = false,
},
-- Hunters http://www.wowhead.com/?spell=212640
[DSI["SPELL_MENDINGBANDAGE"]] = { -- PVP
Types = {DC.DISEASE, DC.POISON},
Better = 0,
Pet = false,
},
--[=[ -- LEGION GONE
[DSI["SPELL_TRANQUILIZING_SHOT"]] = {
Types = {DC.ENEMYMAGIC},
Better = 0,
Pet = false,
},
--]=]
-- Monks
[DSI["SPELL_DETOX_1"]] = {
Types = {DC.MAGIC},
Better = 3,
Pet = false,
EnhancedBy = 'talent',
EnhancedByCheck = function ()
return (IsPlayerSpell(DSI["SPELL_IMPROVED_DETOX"]));
end,
Enhancements = {
Types = {DC.MAGIC, DC.DISEASE, DC.POISON},
}
},
[DSI["SPELL_DETOX_2"]] = {
Types = {DC.DISEASE, DC.POISON},
Better = 2,
Pet = false,
},
-- Monks
[DSI["SPELL_DIFFUSEMAGIC"]] = {
Types = {DC.MAGIC},
Better = 0,
Pet = false,
UnitFiltering = {
[DC.MAGIC] = 1,
},
},
-- Paladins
[DSI["SPELL_CLEANSE_TOXINS"]] = {
Types = {DC.DISEASE, DC.POISON},
Better = 0,
Pet = false,
},
[DSI["SPELL_CLEANSE"]] = {
Types = {DC.MAGIC, DC.DISEASE, DC.POISON},
Better = 2,
Pet = false,
},
-- Shaman
[DSI["CLEANSE_SPIRIT"]] = { -- same name as PURIFY_SPIRIT in ruRU XXX
Types = {DC.CURSE},
Better = 3,
Pet = false,
-- detect resto spec and enhance this spell
EnhancedBy = 'resto',
EnhancedByCheck = function ()
return (GetSpecialization() == 3) and true or false; -- restoration?
end,
Enhancements = {
Types = {DC.CURSE, DC.MAGIC}, -- see PURIFY_SPIRIT
}
},
--[=[
i=1; while GetSpellBookItemInfo(i, 'spell') do if (select(2, GetSpellBookItemInfo(i, 'spell'))) == 77130 then print(i) end; i = i + 1; end
--]=]
-- Shaman resto
[DSI["PURIFY_SPIRIT"]] = { -- same name as CLEANSE_SPIRIT in ruRU XXX -- IsSpellKnown(DSI["PURIFY_SPIRIT"]) actually fails in all situaions...
Types = {DC.MAGIC},
Better = 4,
Pet = false,
-- detect improved purify spirit
EnhancedBy = 'talent',
EnhancedByCheck = function ()
return (IsPlayerSpell(DSI["IMPROVED_PURIFY_SPIRIT"]));
end,
Enhancements = {
Types = {DC.CURSE, DC.MAGIC}, -- see PURIFY_SPIRIT
}
},
-- Warlocks (Imp)
[DSI["PET_SINGE_MAGIC"]] = {
Types = {DC.MAGIC},
Better = 0,
Pet = true,
},
[DSI["PET_SINGE_MAGIC_PVP"]] = { -- PVP
Types = {DC.MAGIC},
Better = 0,
Pet = true,
},
-- Warlocks (Fel-Imp)
[DSI["PET_SEAR_MAGIC"]] = {
Types = {DC.MAGIC},
Better = 0,
Pet = true,
},
-- Warlocks (Imp singe magic ability when used with Grimoire of Sacrifice)
[DSI["SPELL_COMMAND_DEMON"]] = {
Types = {}, -- does nothing by default
Better = 1, -- the Imp takes time to disappear when sacrificed, during that interlude, Singe Magic is still there
Pet = false,
EnhancedBy = true,
EnhancedByCheck = function ()
return (GetSpellName(DS["SPELL_COMMAND_DEMON"])) == DS["PET_SINGE_MAGIC"] or (GetSpellName(DS["SPELL_COMMAND_DEMON"])) == DS["PET_SEAR_MAGIC"];
end,
Enhancements = {
Types = {DC.MAGIC},
}
},
-- Warlock
[DSI["SPELL_FEAR"]] = {
Types = {DC.CHARMED},
Better = 1,
Pet = false,
UnitFiltering = {
[DC.CHARMED] = 2,
},
},
-- Warlocks
[DSI["PET_TORCH_MAGIC"]] = {
Types = {DC.ENEMYMAGIC},
Better = 0,
Pet = true,
},
[DSI["PET_DEVOUR_MAGIC"]] = {
Types = {DC.ENEMYMAGIC},
Better = 0,
Pet = true,
},
-- Mages
[DSI["SPELL_POLYMORPH"]] = {
Types = {DC.CHARMED},
Better = 0,
Pet = false,
},
-- Druids (Balance Feral Guardian)
[DSI["SPELL_REMOVE_CORRUPTION"]] = {
Types = {DC.POISON, DC.CURSE},
Better = 0,
Pet = false,
},
-- SPELL_POISON_CLEANSING_TOTEM
[DSI["SPELL_POISON_CLEANSING_TOTEM"]] = {
Types = {DC.POISON},
Better = 1,
Pet = false,
},
-- Druids (Restoration)
[DSI["SPELL_NATURES_CURE"]] = {
Types = {DC.MAGIC, DC.POISON, DC.CURSE},
Better = 3,
Pet = false,
},
-- Priests (global)
[DSI["SPELL_DISPELL_MAGIC"]] = {
Types = {DC.ENEMYMAGIC},
Better = 0,
Pet = false,
},
-- Demon Hunters (global)
[DSI["SPELL_CONSUME_MAGIC"]] = {
Types = {DC.ENEMYMAGIC},
Better = 0,
Pet = false,
},
-- Mages (global)
[DSI["SPELL_SPELLSTEAL"]] = {
Types = {DC.ENEMYMAGIC},
Better = 1,
Pet = false,
},
-- Priests (Discipline, Holy)
[DSI["SPELL_PURIFY"]] = {
Types = {DC.MAGIC},
Better = 1,
Pet = false,
EnhancedBy = 'talent',
EnhancedByCheck = function ()
return (IsPlayerSpell(DSI["IMPROVED_PURIFY"]));
end,
Enhancements = {
Types = {DC.MAGIC, DC.DISEASE},
}
},
[DSI["SPELL_PURIFY_DISEASE"]] = {
Types = {DC.DISEASE},
Better = 0,
Pet = false,
},
-- Demon hunters
[DSI["SPELL_REVERSEMAGIC"]] = { -- PVP
Types = {DC.MAGIC},
Better = 1,
Pet = false,
},
-- Evoker
[DSI["SPELL_EXPUNGE"]] = {
Types = {DC.POISON},
Better = 1,
Pet = false,
},
[DSI["SPELL_CAUTERIZING_FLAME"]] = {
Types = {DC.POISON, DC.CURSE, DC.DISEASE, DC.BLEED},
Better = 0,
Pet = false,
},
[DSI["SPELL_NATURALIZE"]] = {
Types = {DC.POISON, DC.MAGIC},
Better = 2,
Pet = false,
},
-- undead racial
[DSI["SPELL_WILL_OF_THE_FORSAKEN"]] = {
Types = {DC.CHARMED},
Better = 0,
Pet = false,
UnitFiltering = {
[DC.CHARMED] = 1, -- player only
},
}
};
-- }}}
else -- WOW CLASSIC
DC.IS_STEALTH_BUFF = D:tReverse({DS["Prowl"], DS["Stealth"], DS["Shadowmeld"], DS["Lesser Invisibility"]});
DC.IS_HARMFULL_DEBUFF = D:tReverse({DC.DS["MUTATINGINJECTION"]}); --, "Test item"});
DC.IS_DEADLY_DEBUFF = D:tReverse({});
DC.IS_OMNI_DEBUFF = D:tReverse({});
-- SPELL TABLE -- must be parsed after spell translations have been loaded {{{
DC.SpellsToUse = {
-- Mage
[DSI["SPELL_REMOVE_CURSE_DRUID"]] = { -- WOW CLASSIC https://classic.wowhead.com/spell=475/remove-lesser-curse
Types = not DC.CATACLYSM and {DC.CURSE} or {DC.CURSE, DC.POISON},
Better = 0,
Pet = false,
EnhancedBy = DC.CATACLYSM and DS["TALENT_NATURES_CURE"] ~= nil,
EnhancedByCheck = function ()
return DC.CATACLYSM and IsPlayerSpell(DSI["TALENT_NATURES_CURE"])
end,
Enhancements = {
Types = {DC.CURSE, DC.POISON, DC.MAGIC},
}
},
-- Druid
[DSI["SPELL_REMOVE_CURSE_MAGE"]] = { -- WOW CLASSIC https://classic.wowhead.com/spell=2782/remove-curse
Types = {DC.CURSE},
Better = 0,
Pet = false,
},
[not DC.CATACLYSM and DSI["SPELL_REMOVE_GREATER_CURSE"] or false] = { -- WOW CLASSIC https://www.wowhead.com/classic/spell=412113/remove-greater-curse
Types = {DC.CURSE, DC.MAGIC},
Better = 1,
Pet = false,
},
-- Shaman
[DSI["SPELL_PURGE"]] = { -- WOW CLASSIC https://classic.wowhead.com/spell=370/purge
Types = {DC.ENEMYMAGIC},
Better = 0,
Pet = false,
},
-- Paladin
[DSI["SPELL_CLEANSE"]] = { -- WOW CLASSIC https://classic.wowhead.com/spell=4987/cleanse
Types = not DC.CATACLYSM and {DC.MAGIC, DC.DISEASE, DC.POISON} or {DC.DISEASE, DC.POISON},
Better = 2,
Pet = false,
EnhancedBy = DC.CATACLYSM and DS["TALENT_SACRED_CLEANSING"] ~= nil,
EnhancedByCheck = function ()
return DC.CATACLYSM and IsPlayerSpell(DSI["TALENT_SACRED_CLEANSING"])
end,
Enhancements = {
Types = {DC.MAGIC, DC.DISEASE, DC.POISON},
}
},
-- Warlock
[DSI["SPELL_FEAR"]] = { -- WOW CLASSIC https://classic.wowhead.com/spell=5782/fear
Types = {DC.CHARMED},
Better = 1,
Pet = false,
UnitFiltering = {
[DC.CHARMED] = 2,
},
},
-- Mages
[DSI["SPELL_POLYMORPH"]] = { -- WOW CLASSIC https://classic.wowhead.com/spell=118/polymorph
Types = {DC.CHARMED},
Better = 0,
Pet = false,
UnitFiltering = {
[DC.CHARMED] = 2,
},
},
-- Priests (global)
[DSI["SPELL_DISPELL_MAGIC"]] = { -- WOW CLASSIC https://classic.wowhead.com/spell=527/dispel-magic
Types = {DC.MAGIC, DC.ENEMYMAGIC},
Better = 0,
Pet = false,
UnitFiltering = DC.CATACLYSM and {
[DC.MAGIC] = 1, -- player only
} or nil,
EnhancedBy = DC.CATACLYSM and (DS["TALENT_ABSOLUTION"] ~= nil),
EnhancedByCheck = function ()
return DC.CATACLYSM and (IsPlayerSpell(DSI["TALENT_ABSOLUTION"]))
end,
Enhancements = DC.CATACLYSM and {
Types = {DC.MAGIC, DC.ENEMYMAGIC},
UnitFiltering = {
[DC.MAGIC] = nil,
},
} or nil,
},
-- Priests (rank 1 is no longer detected once rank 2 is learned apprently)
[not DC.CATACLYSM and DSI["SPELL_DISPELL_MAGIC_PRIEST_R2"] or false] = { -- WOW CLASSIC https://www.wowhead.com/wotlk/spell=988/dispel-magic
Types = {DC.MAGIC, DC.ENEMYMAGIC},
Better = 1,
Pet = false,
},
-- Paladin
[not DC.CATACLYSM and DSI["SPELL_PURIFY"] or false] = { -- WOW CLASSIC https://classic.wowhead.com/spell=1152/purify
Types = {DC.POISON, DC.DISEASE},
Better = 1,
Pet = false,
},
-- Priest
[not DC.CATACLYSM and DSI["SPELL_ABOLISH_DISEASE"] or false] = { -- WOW CLASSIC https://classic.wowhead.com/spell=552/abolish-disease
Types = {DC.DISEASE},
Better = 2,
Pet = false,
},
-- Priest
[DSI["SPELL_CURE_DISEASE_PRIEST"]] = { -- WOW CLASSIC https://classic.wowhead.com/spell=528/cure-disease
Types = {DC.DISEASE},
Better = 0,
Pet = false,
EnhancedBy = DC.CATACLYSM and (DS["TALENT_BODY_AND_SOUL_1"] ~= nil or DS["TALENT_BODY_AND_SOUL_2"]),
EnhancedByCheck = function ()
return DC.CATACLYSM and (IsPlayerSpell(DSI["TALENT_BODY_AND_SOUL_1"]) or IsPlayerSpell(DSI["TALENT_BODY_AND_SOUL_2"]))
end,
Enhancements = {
Types = {DC.DISEASE, DC.POISON},
UnitFiltering = {
[DC.POISON] = 1, -- player only
},
}
},
-- Priest
[not DC.CATACLYSM and DSI["SPELL_CURE_DISEASE_SHAMAN"] or false] = { -- WOW CLASSIC https://classic.wowhead.com/spell=2870/cure-disease
Types = {DC.DISEASE},
Better = 0,
Pet = false,
},
-- Shaman
[DC.CATACLYSM and DSI["CLEANSE_SPIRIT"] or false] = {
Types = {DC.CURSE},
Better = 2,
Pet = false,
EnhancedBy = DS["TALENT_IMPROVED_CLEANSE_SPIRIT"] ~= nil,
EnhancedByCheck = function ()
return IsPlayerSpell(DSI["TALENT_IMPROVED_CLEANSE_SPIRIT"])
end,
Enhancements = {
Types = {DC.MAGIC, DC.CURSE},
}
},
-- HUNTERS http://www.wowhead.com/?spell=19801
[DC.CATACLYSM and DSI["SPELL_TRANQUILIZING_SHOT"] or false] = {
Types = {DC.ENEMYMAGIC},
Better = 0,
Pet = false,
},
-- Shamans http://www.wowhead.com/?spell=51514
[DC.CATACLYSM and DSI["SPELL_HEX"] or false] = {
Types = {DC.CHARMED},
Better = 0,
Pet = false,
},
-- Druid
[not DC.CATACLYSM and DSI["SPELL_ABOLISH_POISON"] or false] = { -- WOW CLASSIC https://classic.wowhead.com/spell=2893/abolish-poison
Types = {DC.POISON},
Better = 2,
Pet = false,
},
-- Shaman
[not DC.CATACLYSM and DSI["SPELL_CURE_POISON_SHAMAN"] or false] = { -- WOW CLASSIC https://classic.wowhead.com/spell=526/cure-poison
Types = DC.CATACLYSM and {DC.POISON, DC.DISEASE} or {DC.POISON},
Better = 0,
Pet = false,
},
-- Druid
[not DC.CATACLYSM and DSI["SPELL_CURE_POISON_DRUID"] or false] = { -- WOW CLASSIC https://classic.wowhead.com/spell=8946/cure-poison
Types = {DC.POISON},
Better = 0,
Pet = false,
},
-- Warlock
[DSI["PET_DEVOUR_MAGIC"]] = { -- WOW CLASSIC https://classic.wowhead.com/spell=19505/devour-magic
Types = not DC.CATACLYSM and {DC.MAGIC, DC.ENEMYMAGIC} or {DC.ENEMYMAGIC},
Better = 0,
Pet = true,
},
-- undead racial
[DSI["SPELL_WILL_OF_THE_FORSAKEN"]] = {
Types = {DC.CHARMED},
Better = 0,
Pet = false,
UnitFiltering = {
[DC.CHARMED] = 1, -- player only
},
}
}
DC.SpellsToUse[false] = nil; -- cleanup compatible layer invalid spells
-- }}}
end
D:CreateClassColorTables();
SetRuntimeConstants_Once = nil;
end -- }}}
local function InitVariables_Once() -- {{{
D.MFContainer = false;
D.LLContainer = false;
D.Status = {}; -- might be used by some script in xml files
-- An acces the debuff table
D.ManagedDebuffUnitCache = {};
-- A table UnitID=>IsDebuffed (boolean)
D.UnitDebuffed = {};
D.Revision = "@project-abbreviated-hash@"; -- not used here but some other add-on may request it from outside
D.date = "@project-date-iso@";
D.version = "@project-version@";
if D.date ~= "@project".."-date-iso@" then
-- @project-timestamp@ doesn't work
--local example = "2008-05-01T12:34:56Z";
local year, month, day, hour, min, sec = string.match( D.date, "(%d+)-(%d+)-(%d+)T(%d+):(%d+):(%d+)");
local projectDate = {["year"] = year, ["month"] = month, ["day"] = day, ["hour"] = hour, ["min"] = min, ["sec"] = sec, ["isdst"] = false };
D.VersionTimeStamp = time(projectDate);
else
D.VersionTimeStamp = 0;
end
InitVariables_Once = nil;
end -- }}}
-- Basic initialization functions, if they fail nothing will work. T._CatchAllErrors allows the debugger to also grab errors happening in libraries
T._CatchAllErrors = "RegisterDecursive_Once"; RegisterDecursive_Once();
T._CatchAllErrors = "RegisterLocals_Once"; RegisterLocals_Once();
T._CatchAllErrors = "SetBasicConstants_Once"; SetBasicConstants_Once();
T._CatchAllErrors = "InitVariables_Once"; InitVariables_Once();
-- Upvalues for faster access
local L = D.L;
local LC = D.LC;
local DC = T._C;
local select = _G.select;
local pairs = _G.pairs;
local ipairs = _G.ipairs;
local next = _G.next;
local InCombatLockdown = _G.InCombatLockdown;
local UnitClass = _G.UnitClass;
local time = _G.time;
function D:AddDebugText(a1, ...)
T._AddDebugText(a1, ...);
end
function D:VersionWarnings(forceDisplay) -- {{{
local alpha = false;
local debug = false;
local fromCheckOut = false;
--@alpha@
alpha = true;
--@end-alpha@
--@debug@
debug = true;
--@end-debug@
-- test if WoW's TOC version is superior to Decursive's, wait 40 days and warn the users that this version has expired
local DcrMaxTOC = tonumber(GetAddOnMetadata("Decursive", "X-Max-Interface") or math.huge); -- once GetAddOnMetadata() was bugged and returned nil...
if DcrMaxTOC < T._tocversion then
-- store the detection of this problem
if not self.db.global.TocExpiredDetection then
self.db.global.TocExpiredDetection = time();
elseif time() - self.db.global.TocExpiredDetection > 3600 * 24 * 40 or debug then -- if more than 40 days elapsed since the detection
DC.DevVersionExpired = true; -- disable error reports
if time() - self.db.global.LastExpirationAlert > 48 * 3600 or forceDisplay or debug then
T._ShowNotice ("|cff00ff00Decursive version: @project-version@|r\n\n" .. "|cFFFFAA66" .. L["TOC_VERSION_EXPIRED"] .. "|r");
self.db.global.LastExpirationAlert = time();
end
end
else
self.db.global.TocExpiredDetection = false;
end
if (("@project-version@"):lower()):find("beta") or ("@project-version@"):find("RC") or ("@project-version@"):find("Candidate") or alpha then
D.RunningADevVersion = true;
-- check for expiration of this dev version
if D.VersionTimeStamp ~= 0 then
local VersionLifeTime = 3600 * 24 * 30; -- 30 days
if time() > D.VersionTimeStamp + VersionLifeTime then
DC.DevVersionExpired = true;
-- Display the expiration notice only once evry 48 hours
if time() - self.db.global.LastExpirationAlert > 48 * 3600 or forceDisplay then
T._ShowNotice ("|cff00ff00Decursive version: @project-version@|r\n\n" .. "|cFFFFAA66" .. L["DEV_VERSION_EXPIRED"] .. "|r");
self.db.global.LastExpirationAlert = time();
end
return;
end
end
-- display a warning if this is a developpment version (avoid insults from people who don't know what they're doing)
if self.db.global.NonRelease ~= "@project-version@" then
self.db.global.NonRelease = "@project-version@";
T._ShowNotice ("|cff00ff00Decursive version: @project-version@|r\n\n" .. "|cFFFFAA66" .. L["DEV_VERSION_ALERT"] .. "|r");
end
end
--@debug@
fromCheckOut = true;
if time() - self.db.global.LastUnpackagedAlert > 24 * 3600 then
T._ShowNotice ("|cff00ff00Decursive version: @project-version@|r\n\n" .. "|cFFFFAA66" ..
[[
|cFFFF0000You're using an unpackaged version of Decursive.|r
Decursive is not meant to be used this way.
Annoying and invasive debugging messages will be displayed.
More resources (memory and CPU) will be used due to debug routines and sanity test code being executed.
Localisation is not working and English text may be wrong.
Using Decursive in this state will bring you nothing but troubles.
|cFF00FF00Alpha versions of Decursive are automatically packaged. You should use those instead.|r
]]
.. "|r");
self.db.global.LastUnpackagedAlert = time();
end
--@end-debug@
-- re-enable new version pop-up alerts when a newer version is installed
if D.db.global.NewVersionsBugMeNot and D.db.global.NewVersionsBugMeNot < D.VersionTimeStamp then
D.db.global.NewVersionsBugMeNot = false;
end
-- Prevent time travelers from blocking the system
if D.db.global.NewerVersionDetected > time() then
D.db.global.NewerVersionDetected = D.VersionTimeStamp;
D.db.global.NewerVersionName = false;
D.db.global.NewerVersionAlert = 0;
D:Debug("|cFFFF0000TIME TRAVELER DETECTED!|r");
end
-- if not fromCheckOut then -- this version is properly packaged
if D.db.global.NewerVersionName then -- a new version was detected some time ago
if D.db.global.NewerVersionDetected > D.VersionTimeStamp and D.db.global.NewerVersionName ~= D.version then -- it's still newer than this one
if time() - D.db.global.NewerVersionAlert > 3600 * 24 * 4 then -- it's been more than 4 days since the new version alert was shown
if not D.db.global.NewVersionsBugMeNot then -- the user did not disable new version alerts
T._ShowNotice ("|cff55ff55Decursive version: @project-version@|r\n\n" .. "|cFF55FFFF" .. (L["NEW_VERSION_ALERT"]):format(D.db.global.NewerVersionName or "none", date("%Y-%m-%d", D.db.global.NewerVersionDetected)) .. "|r");
D.db.global.NewerVersionAlert = time();
end
end
else
D.db.global.NewerVersionDetected = D.VersionTimeStamp;
D.db.global.NewerVersionName = false;
end
end
-- end
end -- }}}
function D:OnInitialize() -- Called on ADDON_LOADED by AceAddon -- {{{
if T._SelfDiagnostic() == 2 then
return false;
end
T._CatchAllErrors = "OnInitialize"; -- During init we catch all the errors else, if a library fails we won't know it.
D:LocalizeBindings ();
D:SetSpellsTranslations(false); -- Register spell translations
D.defaults = D:GetDefaultsSettings();
self.db = LibStub("AceDB-3.0"):New("DecursiveDB", D.defaults, true);
self.db.RegisterCallback(self, "OnProfileChanged", "SetConfiguration")
self.db.RegisterCallback(self, "OnProfileCopied", "SetConfiguration")
self.db.RegisterCallback(self, "OnProfileReset", "SetConfiguration")
-- Register slashes command {{{
self:RegisterChatCommand("dcrdiag" ,function() T._SelfDiagnostic(true, true) end );
self:RegisterChatCommand("decursive" ,function() LibStub("AceConfigDialog-3.0"):Open(D.name) end );
self:RegisterChatCommand("dcrpradd" ,function() D:AddTargetToPriorityList() end, false );
self:RegisterChatCommand("dcrprclear" ,function() D:ClearPriorityList() end, false );
self:RegisterChatCommand("dcrprshow" ,function() D:ShowHidePriorityListUI() end, false );
self:RegisterChatCommand("dcrskadd" ,function() D:AddTargetToSkipList() end, false );
self:RegisterChatCommand("dcrskclear" ,function() D:ClearSkipList() end, false );
self:RegisterChatCommand("dcrskshow" ,function() D:ShowHideSkipListUI() end, false );
self:RegisterChatCommand("dcrreset" ,function() D:ResetWindow() end, false );
self:RegisterChatCommand("dcrshow" ,function() D:HideBar(0) end, false );
self:RegisterChatCommand("dcrhide" ,function() D:HideBar(1) end, false );
self:RegisterChatCommand("dcrshoworder" ,function() D:Show_Cure_Order() end, false );
self:RegisterChatCommand("dcrreport" ,function() T._ShowDebugReport() end, false );
-- }}}
-- Shortcuts to xml created objects
D.MFContainer = DcrMUFsContainer;
D.MFContainerHandle = DcrMUFsContainerDragButton;
D.MicroUnitF.Frame = D.MFContainer;
D.LLContainer = DcrLiveList;
D.LiveList.Frame = DcrLiveList;
D.DebuffHistory = {};
SetRuntimeConstants_Once();
LibStub("AceComm-3.0"):RegisterComm("DecursiveVersion", D.OnCommReceived);
-- Handle events directly without relying on AceEvent to prevent undue
-- "script ran too long" errors caused by the queuing of event handler
-- calls into a per-event dispatcher for ALL add-ons registering an event...
-- (The more add-ons registering an event the more chances to get a random
-- "script ran too long" error)
D.eventFrame = CreateFrame("Frame");
D.eventFrame:Hide();
T._CatchAllErrors = false;
end -- // }}}
local FirstEnable = true;
function D:OnEnable() -- called after PLAYER_LOGIN -- {{{
if T._SelfDiagnostic() == 2 then
return false;
end
-- call _HookErrorHandler() a second time because of BugGrabber versions anerior to the
-- alpha of 2012-11-23 which fail to make their callback available for
-- registration b4 PLAYER_LOGIN...
if not T._HookErrorHandler() then
T._AddDebugText("BG's callbacks were not available after PLAYER_LOGIN. Make sure you are using the very latest version of BugGrabber available at: https://www.wowace.com/projects/bug-grabber/files or disable it.");
end
T._CatchAllErrors = "OnEnable"; -- During init we catch all the errors else, if a library fails we won't know it.
D.debug = D.db.global.debug;
if (FirstEnable) then
D:ExportOptions ();
-- configure the message frame for Decursive
DecursiveTextFrame:SetFading(true);
DecursiveTextFrame:SetFadeDuration(D.CONF.TEXT_LIFETIME / 3);
DecursiveTextFrame:SetTimeVisible(D.CONF.TEXT_LIFETIME);
end
-- hook the load macro thing {{{
-- So Decursive will re-update its macro when the macro UI is closed
D:SecureHook("ShowMacroFrame", function ()
if not D:IsHooked(MacroPopupFrame, "Hide") then
D:Debug("Hooking MacroPopupFrame:Hide()");
D:SecureHook(MacroPopupFrame, "Hide", function () D:UpdateMacro(); end);
end
end); -- }}}
D:SecureHook("CastSpellByName", "HOOK_CastSpellByName");
D:SecureHook(C_Item, "UseItemByName", "HOOK_UseItemByName");
-- these events are automatically stopped when the addon is disabled by Ace
-- Spell changes events
D.eventFrame:RegisterEvent("LEARNED_SPELL_IN_TAB");
D.eventFrame:RegisterEvent("SPELLS_CHANGED");
D.eventFrame:RegisterEvent("PLAYER_EQUIPMENT_CHANGED");
D.eventFrame:RegisterEvent("BAG_UPDATE_DELAYED");
D.eventFrame:RegisterEvent("GET_ITEM_INFO_RECEIVED");
if not DC.WOWC or DC.CATACLYSM then
D.eventFrame:RegisterEvent("PLAYER_TALENT_UPDATE");
end
D.eventFrame:RegisterEvent("PLAYER_ALIVE"); -- talents SHOULD be available
D.eventFrame:RegisterEvent("PLAYER_ENTERING_WORLD");
D.eventFrame:RegisterEvent("PLAYER_LEAVING_WORLD");
-- Combat detection events
D.eventFrame:RegisterEvent("PLAYER_REGEN_DISABLED");
D.eventFrame:RegisterEvent("PLAYER_REGEN_ENABLED");
-- Raid/Group changes events
D.eventFrame:RegisterEvent("PARTY_LEADER_CHANGED");
D.eventFrame:RegisterEvent("GROUP_ROSTER_UPDATE");
if not DC.WOWC or DC.CATACLYSM then
D.eventFrame:RegisterEvent("PLAYER_FOCUS_CHANGED");
end
-- Player pet detection event (used to find pet spells)
D.eventFrame:RegisterEvent("UNIT_PET");