-
Notifications
You must be signed in to change notification settings - Fork 0
/
quartzprocs.lua
2102 lines (1909 loc) · 60.2 KB
/
quartzprocs.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
--[[
Copyright 2010 Baffler
This file is part of 'Quartz: Procs' (World of Warcraft addon).
'Quartz: Procs' 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.
'Quartz: Procs' 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 'Quartz: Procs'. If not, see <http://www.gnu.org/licenses/>.
]]
local MAJOR_VERS = 3
local MINOR_VERS = 63
local vers = tostring(MAJOR_VERS) .. "." .. tostring(MINOR_VERS)
local Quartz3 = LibStub("AceAddon-3.0"):GetAddon("Quartz3")
local MODNAME = "Procs"
local QuartzProcs = Quartz3:NewModule(MODNAME, "AceEvent-3.0")
local Mirror = Quartz3:GetModule("Mirror")
local ex = Mirror.ExternalTimers
local media = LibStub("LibSharedMedia-3.0")
function del(tbl)
wipe(tbl)
end
local db
local defaults = {
profile = {
fixCustomProcCaps = true,
debugProcsAddon = false,
procMode = false,
cooldowns = { },
spells = {
[string.lower(GetSpellInfo(32182))] = {
enabled = true, name = GetSpellInfo(32182),
color = {1, 0.65, 0}, ptype = "custom",
}, -- Heroism
[string.lower(GetSpellInfo(2825))] = {
enabled = true, name = GetSpellInfo(2825),
color = {1, 0.65, 0}, ptype = "custom",
},-- Bloodlust
[string.lower(GetSpellInfo(80353))] = {
enabled = true, name = GetSpellInfo(80353),
color = {1, 0.65, 0}, ptype = "custom",
},-- Time Warp
[string.lower(GetSpellInfo(90355))] = {
enabled = true, name = GetSpellInfo(90355),
color = {1, 0.65, 0}, ptype = "custom",
},-- Ancient Hysteria
},
}
}
local procs = {}
local buffThrottle = GetTime()
local combatThrottle = GetTime()
function QuartzProcs:DEBUGPRINT(text)
if (db.debugProcsAddon == true) then
print("Quartz:Procs~ " .. text)
end
end
function QuartzProcs:SetupDebugging(debugstate)
FrameXML_Debug(debugstate)
if (debugstate == true) then
--[[
if (LoggingChat()) then
print("Chat is already being logged")
else
LoggingChat(true)
print("Chat is now being logged to Logs\\WOWChatLog.txt");
end
]]
local _, curClass = UnitClass("player")
print("Quartz:Procs~ Version = " .. vers)
print("Quartz:Procs~ Class = " .. curClass)
print("Quartz:Procs~ Level = " .. UnitLevel("player"))
end
--LoggingChat(false)
--end
end
function QuartzProcs:OnInitialize()
self.db = Quartz3.db:RegisterNamespace(MODNAME, defaults)
db = self.db.profile
self:SetupDebugging(db.debugProcsAddon)
self:DEBUGPRINT("Initializing...")
self:DEBUGPRINT("GetModuleEnabled("..MODNAME..") = " .. tostring(Quartz3:GetModuleEnabled(MODNAME)))
self:SetEnabledState(Quartz3:GetModuleEnabled(MODNAME))
Quartz3:RegisterModuleOptions(MODNAME, getOptions, "Procs")
Quartz3:RegisterChatCommand("procs", function()
if (Quartz3.optFrames[MODNAME] ~= nil) then
if (db.version == nil) or (db.version ~= vers) then
--print("|cFF00FF00Quartz: Procs|r ~ |cFFFF0000Attention!|r ~ If you added Triggers with an earlier version, then you need to go through each trigger you have in your custom proc list, and change the Event to SPELL_CAST_SUCCESS. If the proc doesn't work with that setting, change it to SPELL_DAMAGE for spells that have a cast time or SPELL_CAST_START for instant cast spells");
--print("|cFF00FF00Quartz: Procs|r ~ |cFFFF0000Attention!|r ~ 'Proc Mode' added under the Settings tab. This lets you view Spell IDs and Event for each spell you cast, to make it easier to add Triggers")
--print("|cFF00FF00Quartz: Procs|r ~ |cFFFF0000Attention!|r ~ New 'CoolDowns' tab to allow adding of any spell (by name) that has a cooldown time. If you added any cooldowns with 'Add Trigger', then you need to delete those.")
db.version = vers
end
InterfaceOptionsFrame_OpenToCategory(Quartz3.optFrames[MODNAME])
-- Won't open to the procs settings initially unless this is done twice
InterfaceOptionsFrame_OpenToCategory(Quartz3.optFrames[MODNAME])
else
print(MODNAME .. " options have not been setup!")
end
end)
Quartz3:RegisterChatCommand("procstest", function()
self:createCustomTimer("Test Proc", 30, (GetTime() + 30), 2825, {1,0,0}, false, "", "combatlog")
end)
Quartz3:RegisterChatCommand("procsdebug", function()
--self:createCustomTimer("Test Proc", 30, (GetTime() + 30), 2825, {1,0,0}, false, "", "combatlog")
if (db.debugProcsAddon == false) then
FrameXML_Debug(true)
db.debugProcsAddon = true
print("Debugging enabled.")
--[[
if (LoggingChat()) then
print("Chat is already being logged")
else
LoggingChat(true)
print("Chat is now being logged to Logs\\WOWChatLog.txt");
end
]]
else
FrameXML_Debug(false)
db.debugProcsAddon = false
print("Debugging disabled.")
--LoggingChat(false)
end
end)
local tempprocs = self:returnProcList()
for spellkey,spell in pairs(tempprocs) do
if (GetSpellInfo(tonumber(spellkey)) ~= nil) then
procs[string.lower(GetSpellInfo(tonumber(spellkey)))] = spell
procs[string.lower(GetSpellInfo(tonumber(spellkey)))].name = GetSpellInfo(tonumber(spellkey))
elseif (string.lower(spellkey) == "combatlog") then
procs.combatlog = {}
for ckey,cspell in pairs(spell) do
if (GetSpellInfo(tonumber(ckey)) ~= nil) then
procs.combatlog[ckey] = cspell
procs.combatlog[ckey].name = GetSpellInfo(tonumber(ckey))
end
end
else
self:DEBUGPRINT("Key: '" .. spellkey .. "' was not valid!")
end
end
-- fix the custom procs that have already been added
-- TODO: remove this in a future version
--[[if (db.fixCustomProcCaps == true) then
local tmptbl = { }
for spellkey,spell in pairs(db.spells) do
if (spell.ptype ~= nil) and (spell.ptype == "custom") then
tmptbl[string.lower(spellkey)] = {}
tmptbl[string.lower(spellkey)].name = (spell.name ~= nil and spell.name or spellkey)
tmptbl[string.lower(spellkey)].sound = (spell.sound ~= nil and spell.sound or "None")
tmptbl[string.lower(spellkey)].color = (spell.color ~= nil and spell.color or {1,0,0})
tmptbl[string.lower(spellkey)].ptype = "custom"
--print(string.lower(spellkey))
else
tmptbl[spellkey] = db.spells[spellkey]
end
end
table.wipe(db.spells)
db.spells = nil
db.spells = tmptbl
db.fixCustomProcCaps = false
end--]]
for spellkey,spell in pairs(db.spells) do
if (spell.ptype ~= nil) and (spell.ptype == "custom") then
procs[string.lower(spellkey)] = db.spells[spellkey]
end
end
if (db.debugProcsAddon == true) then
for spellkey,spell in pairs(procs) do
print("Quartz:Procs~ spell= ".. tostring(spellkey) .. " " .. tostring(spell.color))
end
end
--self:checkTalentPoints()
end
function QuartzProcs:OnEnable()
self:DEBUGPRINT("Registering Events...")
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
self:RegisterEvent("UNIT_AURA")
--self:RegisterEvent("PLAYER_TALENT_UPDATE")
self:RegisterEvent("SPELL_UPDATE_COOLDOWN")
end
function QuartzProcs:OnDisable()
self:DEBUGPRINT("Addon Disabled")
end
function QuartzProcs:SPELL_UPDATE_COOLDOWN()
if (db.cooldowns ~= nil) then
for spellkey,spell in pairs(db.cooldowns) do
local startTime, sDuration, sEnabled = GetSpellCooldown(spell.name)
if (sDuration ~= nil) and (sDuration > 1.5) then
self:DEBUGPRINT(spellkey .. " - startTime: " .. tostring(startTime) .. " - dur: ".. tostring(sDuration))
if (spell.enabled == nil) or (spell.enabled == true) then
local expr = startTime + sDuration
local spellcolor = {1, 0, 0}
if (spell.color ~= nil) then
spellcolor = spell.color
end
local tname, trank, sIcon = GetSpellInfo(spell.name)
self:createCustomCooldownTimer(spell.name .. " CD", sDuration, expr, spellcolor, sIcon, "customcooldown")
end
end
end
end
end
function QuartzProcs:UNIT_AURA(event, unit)
if (unit == "player") then
self:CheckBuffs()
end
end
function QuartzProcs:COMBAT_LOG_EVENT_UNFILTERED(event, ...)
local timestamp, eventType, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags = select(1, CombatLogGetCurrentEventInfo())
if (event == "COMBAT_LOG_EVENT_UNFILTERED") then
if ((GetTime() - combatThrottle) > 10) then
self:DEBUGPRINT("COMBAT_LOG_EVENT_UNFILTERED")
combatThrottle = GetTime()
end
if (sourceGUID == UnitGUID("player")) then --check if the player is casting the spell
local spellID, spellname, spellSchool = select(12, CombatLogGetCurrentEventInfo())
if (spellID ~= nil) and (spellID ~= "") then spellID = tostring(spellID) end
if (db.procMode ~= nil) and (db.procMode == true) then
print("-- " .. tostring(spellname) .. " id: "..tostring(spellID))
print("- event = " .. tostring(eventType))
print("----")
end
-- cooldown check
-- ignore SPELL_CAST_FAILED cause it gets called if you spam the button and its not off cooldown
-- SPELL_CAST_START/SUCCESS seems to show incorrect times too
--[[
if (eventType ~= "SPELL_CAST_FAILED") and (eventType ~= "SPELL_CAST_START") and
(eventType ~= "SPELL_CAST_SUCCESS") and (spellname ~= nil) and
((db.cooldowns[string.lower(spellname)] ~= nil) and
((db.cooldowns[string.lower(spellname)].enabled == nil) or
(db.cooldowns[string.lower(spellname)].enabled == true)))
then
local spell = db.cooldowns[string.lower(spellname)]
local startTime, sDuration, sEnabled = GetSpellCooldown(spellname)
--print(spellname .. " - startTime: " .. startTime .. " - dur: ".. sDuration)
-- sDuration shows up as just 1/1.5 sometimes, do > 1.5 to fix it
if (sEnabled == 1) and (startTime > 0) and (sDuration > 1.5) then
local expr = startTime + sDuration
local spellcolor = {1, 0, 0}
if (spell.color ~= nil) then
spellcolor = spell.color
end
--self:createCustomTimer(spell.name .. " CD", sDuration, expr, tonumber(spellID), spellcolor, false, "", "customcooldown")
end
end
]]
-- custom combat log event
if ((db.spells[spellID] ~= nil) and (db.spells[spellID].ptype == "customcombatlog"))
then
local spell = db.spells[spellID]
local expr = GetTime() + spell.dur
local _,_,icon = GetSpellInfo(tonumber(spellID))
if (spell.event ~= nil) and ((string.upper(spell.event) == eventType)
or ((eventType == "SPELL_MISSED") and (spell.eventmiss ~= nil) and (spell.eventmiss == true)))
then
local sound = "None"
if (spell.sound ~= nil) then
sound = spell.sound
end
local spellcolor = {1, 0, 0}
if (spell.color ~= nil) then
spellcolor = spell.color
end
self:createCustomTimer(spell.name, spell.dur, expr, tonumber(spellID), spellcolor, false, sound, "customcombatlog")
local spellcd = 0
if (spell.cooldown ~= nil) and (type(spell.cooldown) == "number")
then spellcd = spell.cooldown end
if (spellcd > 0) then
self:createCustomTimer(spell.name .. " CD", spellcd, 0, tonumber(spellID), {1,0,0}, true, "", "customcombatlog")
end
end
end
--if (eventType == "SPELL_CAST_SUCCESS") or (eventType == "SPELL_AURA_APPLIED") then
if (eventType == "SPELL_AURA_APPLIED") or (eventType == "SPELL_AURA_REFRESH") then
if (procs ~= nil) and (procs.combatlog ~= nil) and (procs.combatlog[spellID] ~= nil)
--and (procs.combatlog[spellID].cast ~= nil) and (procs.combatlog[spellID].cast == true)
then
local spell = procs.combatlog[spellID]
local expr = GetTime() + spell.dur
local _,_,icon = GetSpellInfo(tonumber(spellID))
local sdb = db.spells
if ((sdb[spellID] == nil) or (sdb[spellID].enabled == nil) or (sdb[spellID].enabled == true))
then
local sound = "None"
if ((sdb[spellID] ~= nil) and (sdb[spellID].sound ~= nil)) then
sound = sdb[spellID].sound
end
local spellcolor = spell.color or {1, 0, 0}
if ((sdb[spellID] ~= nil) and (sdb[spellID].color ~= nil)) then
spellcolor = sdb[spellID].color
end
if (eventType == "SPELL_AURA_REFRESH") then
-- refresh timer (used so like Arcane Blast(4) will stay at 4)
self:refreshSpell(spell.name, spell.dur, expr, tonumber(spellID), spellcolor, sound, "combatlog")
else
self:createCustomTimer(spell.name, spell.dur, expr, tonumber(spellID), spellcolor, false, sound, "combatlog")
end
end
--[[
if ((sdb[spellID] == nil) or (sdb[spellID].enabled == nil) or (sdb[spellID].enabled == true))
then
local sound = "None"
if ((sdb[spellID] ~= nil) and (sdb[spellID].sound ~= nil)) then
sound = sdb[spellID].sound
end
local spellcolor = spell.color or {1, 0, 0}
if ((sdb[spellID] ~= nil) and (sdb[spellID].color ~= nil)) then
spellcolor = sdb[spellID].color
end
self:createCustomTimer(spell.name, spell.dur, expr, tonumber(spellID), spellcolor, false, sound, "combatlog")
end]]
end
-- for spell stacking (so far this is only going to be used for ArcaneBlast debuff.. hmmm)
elseif (eventType == "SPELL_AURA_APPLIED_DOSE") then
if (procs ~= nil) and (procs.combatlog ~= nil) and (procs.combatlog[spellID] ~= nil) then
local spellStack = select(16,...)
local spell = procs.combatlog[spellID]
local expr = GetTime() + spell.dur
local _,_,icon = GetSpellInfo(tonumber(spellID))
local sdb = db.spells
if ((sdb[spellID] == nil) or (sdb[spellID].enabled == nil) or (sdb[spellID].enabled == true))
then
local spellcolor = spell.color or {1, 0, 0}
if ((sdb[spellID] ~= nil) and (sdb[spellID].color ~= nil)) then
spellcolor = sdb[spellID].color
end
--self:createCustomTimer(spell.name, spell.dur, expr, tonumber(spellID), spellcolor, false, "", "combatlog")
self:checkSpellStack(spell.name, spellStack, spell.dur, expr, tonumber(spellID), spellcolor, "", "combatlog")
end
end
-- remove the timer
elseif (eventType == "SPELL_AURA_REMOVED") then
if (procs ~= nil) and (procs.combatlog ~= nil) and (procs.combatlog[spellID] ~= nil) then
for k,v in pairs(ex) do
if (tostring(v.spellid) == tostring(spellID)) and (v.spelltype == "combatlog") then
--print("Update 2")
ex[k] = del(ex[k])
Mirror:SendMessage("Quartz3Mirror_UpdateCustom")
end
end
end
end
elseif (destGUID == UnitGUID("player")) then --check if the player is receiving the buff
local spellID, spellname, spellSchool = select(12, ...)
if (spellID ~= nil) and (spellID ~= "") then spellID = tostring(spellID) end
if (eventType == "SPELL_AURA_APPLIED") or (eventType == "SPELL_AURA_REFRESH") then
if (procs ~= nil) and (procs.combatlog ~= nil) and (procs.combatlog[spellID] ~= nil)
--and ((procs.combatlog[spellID].cast == nil) or (procs.combatlog[spellID].cast == false))
then
local spell = procs.combatlog[spellID]
local expr = GetTime() + spell.dur
local _,_,icon = GetSpellInfo(tonumber(spellID))
local sdb = db.spells
if ((sdb[spellID] == nil) or (sdb[spellID].enabled == nil) or (sdb[spellID].enabled == true))
then
local sound = "None"
if ((sdb[spellID] ~= nil) and (sdb[spellID].sound ~= nil)) then
sound = sdb[spellID].sound
end
local spellcolor = spell.color or {1, 0, 0}
if ((sdb[spellID] ~= nil) and (sdb[spellID].color ~= nil)) then
spellcolor = sdb[spellID].color
end
if (eventType == "SPELL_AURA_REFRESH") then
-- refresh timer (used so like Arcane Blast(4) will stay at 4)
self:refreshSpell(spell.name, spell.dur, expr, tonumber(spellID), spellcolor, sound, "combatlog")
else
self:createCustomTimer(spell.name, spell.dur, expr, tonumber(spellID), spellcolor, false, sound, "combatlog")
end
end
end
elseif (eventType == "SPELL_AURA_REMOVED") then
if (procs ~= nil) and (procs.combatlog ~= nil) and (procs.combatlog[spellID] ~= nil) then
for k,v in pairs(ex) do
--if (v.spellname == spellname) and (v.spelltype == "combatlog") then
if (tostring(v.spellid) == tostring(spellID)) and (v.spelltype == "combatlog") then
--print("Update 1")
ex[k] = del(ex[k])
Mirror:SendMessage("Quartz3Mirror_UpdateCustom")
end
end
end
end
end
end
end
function QuartzProcs:CheckBuffs()
if ((GetTime() - buffThrottle) > 10) then
self:DEBUGPRINT("CheckBuffs()")
buffThrottle = GetTime()
end
-- debuffs
for i = 1, 40 do
local name,icon,count,dtype,dur,expr,caster,isStealable,shouldConsolidate,spellId=UnitAura("player", i, "HARMFUL")
if not name then break end
if (procs[string.lower(name)] ~= nil) or (procs[tostring(spellId)] ~= nil) then
local spellname
local spellkey
if (procs[tostring(spellId)] ~= nil) then
spellkey = tostring(spellId)
spell = procs[spellkey]
spellname = spell.name
else
spellkey = string.lower(name)
spell = procs[spellkey]
spellname = name
end
local sdb = db.spells
if ((spell ~= nil) and (spell.debuff ~= nil) and (spell.debuff == true))
then
if ((sdb[spellkey] == nil) or (sdb[spellkey].enabled == nil) or (sdb[spellkey].enabled == true))
then
if (dur ~= nil) and (dur > 0) then
-- create timer
local pColor = spell.color
if (sdb[spellkey] ~= nil) and (sdb[spellkey].color ~= nil) then
pColor = sdb[spellkey].color
end
local pSound = "None"
if (sdb[spellkey] ~= nil) and (sdb[spellkey].sound ~= nil) then
pSound = sdb[spellkey].sound
end
-- check if timer exists
if (rawget(ex, spellname) == nil) then
if (count == nil) or ((count ~= nil) and (count < 1)) then
self:createCustomTimer(spellname, dur, expr, tonumber(spellId), pColor, false, pSound, "debuff")
end
-- create cooldown timer
local spellcd = 0
if (spell.cooldown ~= nil) and (type(spell.cooldown) == "number")
then spellcd = spell.cooldown end
if (sdb[spellkey] ~= nil) and (sdb[spellkey].cooldown ~= nil)
and (type(sdb[spellkey].cooldown) == "number")
then spellcd = sdb[spellkey].cooldown end
-- TODO: spellcd needs to be spellcd - expires
if (spellcd > 0) then
self:createCustomTimer(spellname .. " CD", spellcd, 0, tonumber(spellId), {1,0,0}, true, "", "cooldown")
end
-- update timer
elseif (rawget(ex, spellname) ~= nil) and (ex[spellname].expires ~= expr) then
-- TODO: need to check this?
if (count == nil) or ((count ~= nil) and (count < 1)) then
self:createCustomTimer(spellname, dur, expr, tonumber(spellId), pColor, false, "", "debuff")
end
end
-- check spell stack here
if (count) and (count > 0) then
self:checkSpellStack(spellname, count, dur, expr, tonumber(spellId), pColor, pSound, "debuff")
end
end
end
end
end
end
-- buffs
for i = 1, 40 do
local name,icon,count,dtype,dur,expr,caster,isStealable,shouldConsolidate,spellId=UnitAura("player",i)
if not name then break end
if (procs[string.lower(name)] ~= nil) or (procs[tostring(spellId)] ~= nil) then
local spellname
local spellkey
if (procs[tostring(spellId)] ~= nil) then
spellkey = tostring(spellId)
spell = procs[spellkey]
spellname = spell.name
else
spellkey = string.lower(name)
spell = procs[spellkey]
spellname = name
end
local sdb = db.spells
if ((sdb[spellkey] == nil) or (sdb[spellkey].enabled == nil) or (sdb[spellkey].enabled == true))
then
if (dur ~= nil) and (dur > 0) then
-- create timer
local pColor = spell.color
if (sdb[spellkey] ~= nil) and (sdb[spellkey].color ~= nil) then
pColor = sdb[spellkey].color
end
local pSound = "None"
if (sdb[spellkey] ~= nil) and (sdb[spellkey].sound ~= nil) then
pSound = sdb[spellkey].sound
end
-- check if timer exists
if (rawget(ex, spellname) == nil) then
if (count == nil) or ((count ~= nil) and (count < 1)) then
self:createCustomTimer(spellname, dur, expr, tonumber(spellId), pColor, false, pSound, "aura")
end
-- create cooldown timer
local spellcd = 0
if (spell.cooldown ~= nil) and (type(spell.cooldown) == "number")
then spellcd = spell.cooldown end
if (sdb[spellkey] ~= nil) and (sdb[spellkey].cooldown ~= nil)
and (type(sdb[spellkey].cooldown) == "number")
then spellcd = sdb[spellkey].cooldown end
-- TODO: spellcd needs to be spellcd - expires
if (spellcd > 0) then
self:createCustomTimer(spellname .. " CD", spellcd, 0, tonumber(spellId), {1,0,0}, true, "", "cooldown")
end
-- update timer
elseif (rawget(ex, spellname) ~= nil) and (ex[spellname].expires ~= expr) then
-- TODO: need to check this?
if (count == nil) or ((count ~= nil) and (count < 1)) then
self:createCustomTimer(spellname, dur, expr, tonumber(spellId), pColor, false, "", "aura")
end
end
-- check spell stack here
if (count) and (count > 0) then
self:checkSpellStack(spellname, count, dur, expr, tonumber(spellId), pColor, pSound, "aura")
end
end
end
end
end
for k,v in pairs(ex) do
local remSpell = true
if (v.spelltype == "aura") then
for i = 1, 40 do
local name,icon,count,dtype,dur,expr,caster,isStealable,shouldConsolidate,spellId=UnitAura("player",i)
if not name then break end
if (tonumber(v.spellid) == tonumber(spellId)) then
remSpell = false
break
end
end
elseif (v.spelltype == "debuff") then
for i = 1, 40 do
local name,icon,count,dtype,dur,expr,caster,isStealable,shouldConsolidate,spellId=UnitAura("player",i, "HARMFUL")
if not name then break end
if (tonumber(v.spellid) == tonumber(spellId)) then
remSpell = false
break
end
end
--[[
elseif (v.spelltype == "cooldown") then
-- check if cooldown is solar, and check if lunar eclipse exists
if (v.spellid == 48517) and (spellId == 48518) then
remSpell = true
break
-- check if cooldown is lunar, and check if solar eclipse exists
elseif (v.spellid == 48518) and (spellId == 48517) then
remSpell = true
break
else
remSpell = false
end
]]--
else
remSpell = false
end
if (remSpell == true) then
if (rawget(ex, k) ~= nil) then
--print("Update 3 ".. k)
ex[k] = del(ex[k])
Mirror:SendMessage("Quartz3Mirror_UpdateCustom")
end
end
end
end
function QuartzProcs:refreshSpell(spellname, duration, sExpires, spellid, spellcolor, spellsound, spelltype)
self:DEBUGPRINT("refreshSpell")
local foundSpell = false
for k,v in pairs(ex) do
--if (v.cooldown == false) and (v.spellname == spellname)
if (v.cooldown == false) and (tonumber(v.spellid) == tonumber(spellid))
then
--if (rawget(ex,k) ~= nil) then
--ex[k] = del(ex[k])
--Mirror:SendMessage("Quartz3Mirror_UpdateCustom")
--end
self:createCustomTimer(k, duration, sExpires, spellid, spellcolor, false, "", spelltype)
foundSpell = true
break
end
end
if (not foundSpell) then
self:createCustomTimer(spellname, duration, sExpires, spellid, spellcolor, false, spellsound, spelltype)
end
end
function QuartzProcs:checkSpellStack(spellname, spellcount, duration, sExpires, spellid, spellcolor, spellsound, spelltype)
local dname = spellname.." ("..spellcount..")"
self:DEBUGPRINT("checkSpellStack:: dname = "..tostring(dname))
if (rawget(ex, dname) == nil) then
local foundSpell = false
for k,v in pairs(ex) do
if (v.cooldown == false) and (tonumber(v.spellid) == tonumber(spellid)) and (k ~= dname)
then
if (rawget(ex, k) ~= nil) then
--print("Update 4")
ex[k] = del(ex[k])
Mirror:SendMessage("Quartz3Mirror_UpdateCustom")
end
--print("1")
-- refreshing timer
self:createCustomTimer(dname, duration, sExpires, spellid, spellcolor, false, "", spelltype)
foundSpell = true
break
end
end
if (not foundSpell) then
--print("2")
-- creating timer
self:createCustomTimer(dname, duration, sExpires, spellid, spellcolor, false, spellsound, spelltype)
end
elseif (rawget(ex, dname) ~= nil) and (ex[dname].expires ~= sExpires) then
--print("3")
-- updating timer
self:createCustomTimer(dname, duration, sExpires, spellid, spellcolor, false, spellsound, spelltype)
end
end
function QuartzProcs:createCustomTimer(spellname, duration, sExpires, spellid, spellcolor, isCoolDown, spellsound, stype)
self:DEBUGPRINT("createTimer:: "..tostring(spellname)..", "..tostring(duration)..", "..tostring(sExpires)..", "..tostring(spellid)..", "..tostring(spellcolor)..", "..tostring(isCoolDown)..", "..tostring(spellsound)..", "..tostring(stype))
-- Misdirection, 324000.617, player, nill, table, false, None, aura
local sdb = db.spells[spellname]
if (sdb == nil) then sdb = db.spells[spellid] end
if (sdb == nil) or ((sdb ~= nil) and ((sdb.enabled == nil) or (sdb.enabled == true))) then
local sIcon = ''
local sName = ''
local sColor = spellcolor
if (sdb ~= nil) and (not isCoolDown) then sColor = sdb.color or spellcolor end
if (type(spellid) == "number") and (spellid > 0) then
local spellName,_,_ = GetSpellInfo(spellid)
sName = spellName
if (isCoolDown == false) then
local _,_,spellIcon = GetSpellInfo(spellid)
sIcon = spellIcon
end
end
self:DEBUGPRINT("Updating Mirror.ExternalTimers")
ex[spellname] = {
startTime = GetTime(),
endTime = GetTime() + duration,
icon = sIcon,
color = sColor,
spellid = spellid,
spellname = sname,
expires = sExpires,
cooldown = isCoolDown,
spelltype = stype,
}
Mirror:SendMessage("Quartz3Mirror_UpdateCustom")
if (string.lower(spellsound) ~= "none") and (spellsound ~= "") then
PlaySoundFile(spellsound)
end
if (not isCoolDown) then
ex[spellname].startTime = GetTime() - ((GetTime() + duration) - sExpires)
ex[spellname].endTime = sExpires
end
end
end
function QuartzProcs:createCustomCooldownTimer(spellname, duration, sExpires, spellcolor, spellicon, stype)
ex[spellname] = {
startTime = GetTime(),
endTime = GetTime() + duration,
icon = spellicon,
color = spellcolor,
spellid = 0,
spellname = spellname,
expires = sExpires,
cooldown = false,
spelltype = stype,
}
Mirror:SendMessage("Quartz3Mirror_UpdateCustom")
ex[spellname].startTime = GetTime() - ((GetTime() + duration) - sExpires)
ex[spellname].endTime = sExpires
end
--[[
*********************************************
*** Configuration ***************************
*********************************************
]]
do
local cTmpName = ""
local cTmpColor = {0,0,0}
local cTmpDebuff = false
--combat log
--local cCombatLog = false
--local cCombatLogSpellID = 0
--local cCombatLogTime = 0
--local cCombatLogCD = false
--local cCombatLogCDTime = 0
local cCombatLogName = ''
local cCombatLogColor = {0,0,0}
local cCombatLogSpellID = 0
local cCombatLogDur = 0
local cCombatLogEvent = "SPELL_CAST_SUCCESS"
local cCombatLogEventMiss = false
--
local cCooldownName = ''
local cCooldownColor = {0,0,0}
--
local cEventTypes = { ["SPELL_CAST_SUCCESS"] = "SPELL_CAST_SUCCESS", ["SPELL_CAST_START"] = "SPELL_CAST_START", ["SPELL_DAMAGE"] = "SPELL_DAMAGE", ["SPELL_AURA_APPLIED"] = "SPELL_AURA_APPLIED" }
local soundslist
local options
function cAddBtnFunc()
if (cTmpName ~= nil) and (cTmpName ~= "") then
local tmpTbl = {
name = cTmpName,
color = cTmpColor,
ptype = 'custom',
}
if (cTmpDebuff == true) then
tmpTbl.debuff = true
end
db.spells[string.lower(cTmpName)] = tmpTbl
procs[string.lower(cTmpName)] = tmpTbl
options.args.customprocs.args[string.lower(cTmpName)] = {
type = 'group',
name = cTmpName,
desc = cTmpName,
arg = tostring(cTmpName),
args = spellCustomOptions,
}
print("Added '"..cTmpName.."'")
cTmpName = ""
else
print("Some fields were empty or invalid!")
end
end
function cCombatLogAddBtnFunc()
if (cCombatLogName ~= nil) and (cCombatLogName ~= "")
and (cCombatLogSpellID ~= nil) and (cCombatLogSpellID > 0)
then
local spellkey = tostring(cCombatLogSpellID)
local tmpTbl = {
name = cCombatLogName,
color = cCombatLogColor,
dur = cCombatLogDur,
event = cCombatLogEvent,
eventmiss = cCombatLogEventMiss,
ptype = 'customcombatlog',
}
db.spells[spellkey] = {
name = cCombatLogName,
color = cCombatLogColor,
dur = cCombatLogDur,
event = cCombatLogEvent,
eventmiss = cCombatLogEventMiss,
ptype = 'customcombatlog',
}
procs[spellkey] = tmpTbl
options.args.customprocs.args[spellkey] = {
type = 'group',
name = cCombatLogName,
desc = cCombatLogName,
arg = spellkey,
args = spellCLCustomOptions,
}
print("Added '"..cCombatLogName.."'")
cCombatLogName = ""
cCombatLogSpellID = 0
cCombatLogDur = 0
cCombatLogEvent = "SPELL_CAST_SUCCESS"
cCombatLogEventMiss = false
else
print("Some fields were empty or invalid!")
end
end
function cCooldownAddBtnFunc()
if (cCooldownName ~= nil) and (cCooldownName ~= "") then
local spellkey = string.lower(tostring(cCooldownName))
local tmpTbl = {
name = cCooldownName,
color = cCooldownColor,
--ptype = 'customcombatlog',
}
db.cooldowns[spellkey] = {
name = cCooldownName,
color = cCooldownColor,
}
--procs[spellkey] = tmpTbl
options.args.cooldownProcs.args[spellkey] = {
type = 'group',
name = cCooldownName,
desc = cCooldownName,
arg = spellkey,
args = spellCoolDownCustomOptions,
}
print("Added Cooldown: '"..cCooldownName.."'")
cCooldownName = ""
else
print("Some fields were empty or invalid!")
end
end
function getOptions()
if not soundslist then
if not media:Fetch("sound", "Meow", true) then
media:Register("sound", "Meow", [[Interface\AddOns\Quartz_Procs\media\kitten19.ogg]])
end
if not media:Fetch("sound", "Warning", true) then
media:Register("sound", "Warning", [[Interface\AddOns\Quartz_Procs\media\warn1.ogg]])
end
if not media:Fetch("sound", "System Failure", true) then
media:Register("sound", "System Failure", [[Interface\AddOns\Quartz_Procs\media\system_failure.ogg]])
end
soundslist = {
["None"] = "None",
["Sound\\Spells\\Sunwell_Fel_PortalStand.wav"] = "Fel Portal",
["Sound\\Spells\\SeepingGaseous_Fel_Nova.wav"] = "Fel Nova",
["Sound\\Doodad\\Hellfire_Raid_FX_Explosion05.wav"] = "Explosion",
["Sound\\Doodad\\KharazahnBellToll.wav"] = "Kara Bell Toll",
["Sound\\Interface\\AlarmClockWarning1.wav"] = "Alarm 1",
["Sound\\Interface\\AlarmClockWarning2.wav"] = "Alarm 2",
["Sound\\Interface\\AlarmClockWarning3.wav"] = "Alarm 3",
["Sound\\Spells\\YarrrrImpact.wav"] = "Yarrr",
}
for idx, sound in next, media:List("sound") do
if (string.lower(sound) ~= "none") then
soundslist[media:Fetch("sound", sound)] = sound
end
end
end
if not spellCustomOptions then
spellCustomOptions = {
cToggle = {
type = 'toggle',
name = 'Enabled',
desc = 'Enable/Disable',
get = function(info)
local sKey = info[3]
if (db.spells[sKey] ~= nil) then
if (db.spells[sKey].enabled ~= nil) then
return db.spells[sKey].enabled
else
return true
end
end
return true
end,
set = function(info, v)
local sKey = info[3]
if (db.spells[sKey] ~= nil) then
db.spells[sKey].enabled = v
end
end,
order = 10,
},
cColor = {
type = 'color',
name = 'color',
get = function(info)
local sKey = info[3]
if (db.spells[sKey] ~= nil) then
return unpack(db.spells[sKey].color)
end
return {1,0,0}
end,
set = function(info, ...)
local sKey = info[3]
if (db.spells[sKey] ~= nil) then
db.spells[sKey].color = {...}
end
end,
order = 30,
},
cSpellSound = {
type = 'select',