-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore.lua
1503 lines (1302 loc) · 60.2 KB
/
core.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
-- vim: set ts=3 sw=3 foldmethod=indent:
if select(2, UnitClass("player")) == "DEATHKNIGHT" then
local _, DKROT = ...
DKROT:Debug("Starting")
----- Create Main Frame -----
DKROT.MainFrame = CreateFrame("Button", "DKROT", UIParent)
DKROT.MainFrame:RegisterEvent("ADDON_LOADED")
DKROT.MainFrame:SetWidth(94)
DKROT.MainFrame:SetHeight(68)
DKROT.MainFrame:SetFrameStrata("BACKGROUND")
----- Locals -----
-- Constants
local PLAYER_PRESENCE = 0
local IS_BUFF = 2
local ITEM_LOAD_THRESHOLD = .5
local RUNE_COLOR = {
{1, 0, 0}, -- Blood
{0, 0.95, 0}, -- Unholy
{0, 1, 1}, -- Frost
{0.8, 0.1, 1} -- Death
}
local RuneOrder = {
[DKROT.RuneOrder.BBUUFF] = { 1, 2, 3, 4, 5, 6 },
[DKROT.RuneOrder.BBFFUU] = { 1, 2, 5, 6, 3, 4 },
[DKROT.RuneOrder.UUBBFF] = { 3, 4, 1, 2, 5, 6 },
[DKROT.RuneOrder.UUFFBB] = { 3, 4, 5, 6, 1, 2 },
[DKROT.RuneOrder.FFUUBB] = { 5, 6, 3, 4, 1, 2 },
[DKROT.RuneOrder.FFBBUU] = { 5, 6, 1, 2, 3, 4 },
}
local RuneTexture = {
"Interface\\PlayerFrame\\UI-PlayerFrame-Deathknight-Blood",
"Interface\\PlayerFrame\\UI-PlayerFrame-Deathknight-Unholy",
"Interface\\PlayerFrame\\UI-PlayerFrame-Deathknight-Frost",
"Interface\\PlayerFrame\\UI-PlayerFrame-Deathknight-Death",
}
-- Variables
local mutex = false
local mousex, mousey
local darksim = {0, 0}
local simtime = 0
local bsamount = 0
local launchtime = 0
local updatetimer = 0
local delayedInit = false
DKROT:Debug("Locals Done")
------ Update Frames ------
-- In:location - name or location of the settings for specific CD frame- frame in which to set the icon for
-- Out:: N/A (does not return but does set icon settings
function DKROT:UpdateIcon(location, frame)
-- Reset Icon
frame.Time:SetText("")
frame.Stack:SetText("")
-- Easy access to settings variables
local cdLoc = DKROT_Settings.CD[DKROT.Current_Spec][location] and DKROT_Settings.CD[DKROT.Current_Spec][location][1] or nil
cdLoc = (DKROT.spells[cdLoc] ~= nil and DKROT.spells[cdLoc] or cdLoc)
local cdIsBuff = DKROT_Settings.CD[DKROT.Current_Spec][location][IS_BUFF]
-- If the option is not set to nothing
if cdLoc and cdLoc ~= DKROT_OPTIONS_FRAME_VIEW_NONE then
frame.Icon:SetVertexColor(1, 1, 1, 1)
-- Priority Icon
if cdLoc == DKROT_OPTIONS_CDR_CD_PRIORITY then
-- If targeting something that you can attack and is not dead
if (UnitCanAttack("player", "target") and (not UnitIsDead("target"))) then
-- Get Icon from Priority Rotation
frame.Icon:SetTexture(DKROT:GetNextMove(frame.Icon))
else
frame.Icon:SetTexture(nil)
end
-- Presence
elseif cdLoc == DKROT_OPTIONS_CDR_CD_PRESENCE then
frame.Icon:SetTexture(nil)
if PLAYER_PRESENCE > 0 then
frame.Icon:SetTexture(select(1, GetShapeshiftFormInfo(PLAYER_PRESENCE)))
end
-- Buff or Debuff
elseif cdIsBuff then
local icon, count, dur, expirationTime
if cdLoc == DKROT.spells["Dark Simulacrum"] then
local id
-- If its more than 5 seconds since last time, locate the button
-- that has Dark Simulacrum on it
if (DKROT.curtime - simtime) >= 5 then
simtime = DKROT.curtime
for i = 1, 120 do
_, id = GetActionInfo(i)
if id == 77606 then
darksim[1] = i
darksim[2] = 0
DKROT:Debug("Dark Simulacrum Action Slot " .. i)
break
end
end
end
-- Set the icon to the DS mirrored spell
_, id = GetActionInfo(darksim[1])
if id ~= nil and id ~= 77606 then
if DKROT_Settings.Range and IsSpellInRange(GetSpellInfo(id), "target") == 0 then
frame.Icon:SetVertexColor(0.8, 0.05, 0.05, 1)
end
frame.Icon:SetTexture(GetSpellTexture(id))
if darksim[2] == 0 or darksim[2] < DKROT.curtime then
darksim[2] = DKROT.curtime + 20
end
frame.Time:SetText(floor(darksim[2] - DKROT.curtime))
return
end
end
-- if its on a target then its a debuff, otherwise its a buff
if DKROT.Cooldowns.Buffs[cdLoc][1] == "target" then
_, _, icon, count, _, dur, expirationTime = UnitDebuff("target", cdLoc)
else
_, _, icon, count, _, dur, expirationTime = UnitBuff(DKROT.Cooldowns.Buffs[cdLoc][1], cdLoc)
end
frame.Icon:SetTexture(icon)
-- If not an aura, set time
if icon ~= nil and ceil(expirationTime - DKROT.curtime) > 0 then
frame.Icon:SetVertexColor(0.5, 0.5, 0.5, 1)
frame.Time:SetText(DKROT:formatTime(ceil(expirationTime - DKROT.curtime)))
if DKROT_Settings.CD[DKROT.Current_Spec][location][1] == DKROT.spells["Blood Shield"] then
count = DKROT:SimpleNumbers(bsamount)
frame.Stack:SetText(DKROT:SimpleNumbers(bsamount))
else
if count > 1 then
frame.Stack:SetText(count)
end
end
end
-- Move (spell to be cast)
elseif DKROT:inTable(DKROT.Cooldowns.Moves, cdLoc) then
local icon = GetSpellTexture(cdLoc)
if icon ~= nil then
-- Check if move is off CD
if DKROT:isOffCD(cdLoc) and IsUsableSpell(cdLoc) then
icon = DKROT:GetRangeandIcon(frame.Icon, cdLoc)
else
icon = nil
end
end
frame.Icon:SetTexture(icon)
-- Trinkets
elseif cdLoc == DKROT_OPTIONS_CDR_CD_TRINKETS_SLOT1 or cdLoc == DKROT_OPTIONS_CDR_CD_TRINKETS_SLOT2 then
local invSlotID = (cdLoc == DKROT_OPTIONS_CDR_CD_TRINKETS_SLOT1 and 13 or 14)
local trinketID = GetInventoryItemID("player", invSlotID)
local trinket = (trinketID ~= nil and DKROT.Cooldowns.Trinkets[trinketID] or nil)
if trinket ~= nil then
if trinket.type == DKROT.TrinketType.OnUse then
local start, dur, active = GetItemCooldown(trinketID)
local timeLeft = DKROT:round(start + dur - DKROT.curtime)
frame.Icon:SetTexture(GetItemIcon(trinketID))
if timeLeft > 0 and active == 1 then
frame.Icon:SetVertexColor(0.5, 0.5, 0.5, 1)
frame.Time:SetText(timeLeft > 10 and DKROT:round(timeLeft, 1) or DKROT:formatTime(timeLeft))
if DKROT_Settings.CDS then
frame.c:SetCooldown(start, dur)
end
end
elseif trinket.type == DKROT.TrinketType.Stacking then
local start, dur, active = GetItemCooldown(trinketID)
local timeLeft = DKROT:round(start + dur - DKROT.curtime)
local _, _, icon, stacks, _, dur, expTime = UnitBuff("PLAYER", select(1, GetSpellInfo(trinket.spell)))
if icon ~= nil then
frame.Icon:SetTexture(icon)
frame.Icon:SetVertexColor(0.5, 0.5, 0.5, 1)
frame.Time:SetText(DKROT:formatTime(math.floor(expTime - DKROT.curtime)))
if stacks > 1 then
frame.Stack:SetText(stacks)
end
else
frame.Icon:SetTexture(GetItemIcon(trinketID))
if active then
frame.Icon:SetVertexColor(0.5, 0.5, 0.5, 1)
frame.Time:SetText(DKROT:formatTime(timeLeft))
if DKROT_Settings.CDS then
frame.c:SetCooldown(start, dur)
end
end
end
elseif trinket.type == DKROT.TrinketType.RPPM then
local _, _, _, _, _, dur, expTime = UnitBuff("PLAYER", select(1, GetSpellInfo(trinket.spell)))
frame.Icon:SetTexture(select(3, GetSpellInfo(trinket.spell)))
if dur ~= nil then
frame.Time:SetText(DKROT:formatTime(math.floor(expTime - DKROT.curtime)))
if DKROT_Settings.CDS then
frame.c:SetCooldown(math.ceil(expTime - dur), dur)
else
frame.Icon:SetVertexColor(0.5, 0.5, 0.5, 1)
end
end
elseif trinket.type == DKROT.TrinketType.Debuff then
local _, _, _, stacks, _, dur, expTime = UnitDebuff("TARGET", select(1, GetSpellInfo(trinket.spell)))
if stacks then
frame.Icon:SetTexture(select(3, GetSpellInfo(trinket.spell)))
frame.Time:SetText(DKROT:formatTime(math.floor(expTime - DKROT.curtime)))
if (stacks > 1) then
frame.Stack:SetText(stacks)
else
frame.Stack:SetText(nil)
end
else
frame.Icon:SetTexture(nil)
end
end
else
frame.Icon:SetTexture(nil)
end
-- Racials
elseif cdLoc == DKROT_OPTIONS_CDR_RACIAL then
local icon = DKROT:GetRangeandIcon(frame.Icon, DKROT.PLAYER_RACE)
frame.Icon:SetTexture(icon)
if icon ~= nil then
start, dur, active = GetSpellCooldown(DKROT.spells[DKROT.PLAYER_RACE])
local t = ceil(start + dur - DKROT.curtime)
if active == 1 and dur > 7 then
if DKROT_Settings.CDS then
frame.c:SetCooldown(start, dur)
end
frame.Icon:SetVertexColor(0.5, 0.5, 0.5, 1)
frame.Time:SetText(DKROT:formatTime(t))
end
end
-- Cooldown
else
local icon = DKROT:GetRangeandIcon(frame.Icon, cdLoc)
frame.Icon:SetTexture(icon)
if icon ~= nil then
start, dur, active = GetSpellCooldown(cdLoc)
local t = ceil(start + dur - DKROT.curtime)
if active == 1 and dur > 7 then
if DKROT_Settings.CDS then
frame.c:SetCooldown(start, dur)
end
frame.Icon:SetVertexColor(0.5, 0.5, 0.5, 1)
frame.Time:SetText(DKROT:formatTime(t))
end
end
end
-- if the icon is nil, then just hide the frame
if frame.Icon:GetTexture() == nil then
frame:SetAlpha(0)
else
frame:SetAlpha(1)
end
else
cdLoc = DKROT_OPTIONS_FRAME_VIEW_NONE
frame:SetAlpha(0)
end
end
-- Used to move individual frames where they are suppose to be displayed, also enables and disables mouse depending on settings
function DKROT:MoveFrame(self)
local loc = DKROT_Settings.Location[self:GetName()]
self:ClearAllPoints()
self:SetPoint(loc.Point, loc.Rel, loc.RelPoint, loc.X, loc.Y)
-- Handle the backdrop opacity correctly for the Disease Tracker
if self:GetName() == "DKROT.DT" then
local dtopacity = DKROT_Settings.DT.Enable and DKROT_Settings.DTTrans or 0
self:SetBackdropColor(0, 0, 0, dtopacity)
else
self:SetBackdropColor(0, 0, 0, DKROT_Settings.BackdropOpacity)
end
self:EnableMouse(not DKROT_Settings.Locked)
if loc.Scale ~= nil then
self:SetScale(loc.Scale)
else
loc.Scale = 1
self:SetScale(1)
end
end
-- Called to update all the frames positions and scales
function DKROT:PositionUpdateAll()
for idx, frame in pairs(DKROT.MovableFrames) do
DKROT:MoveFrame(_G[frame.frame])
end
DKROT:Debug("PositionUpdateAll")
end
function DKROT_UnlockUI()
for idx, movFrame in pairs(DKROT.MovableFrames) do
local frame = _G[movFrame.frame]
if frame.overlay == nil then
if frame:GetObjectType() == "Button" then
frame.overlay = CreateFrame("Button", movFrame.frame .. "Overlay", frame)
else
frame.overlay = CreateFrame("Frame", movFrame.frame .. "Overlay", frame)
end
frame.overlay:EnableMouse(false)
frame.overlay:SetBackdrop({
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
tile = true,
tileSize = 16
})
frame.overlay:SetBackdropColor(0, 1, 0, 0.5)
frame.overlay:SetFrameLevel(frame:GetFrameLevel() + 10)
frame.overlay:SetAllPoints(frame)
else
frame.overlay:SetAlpha(1)
end
end
end
function DKROT_LockUI()
for idx, movFrame in pairs(DKROT.MovableFrames) do
local frame = _G[movFrame.frame]
if frame.overlay ~= nil then
frame.overlay:SetAlpha(0)
end
end
end
function DKROT:BuildRuneBar()
local runebar = ""
local place = 1
for _, rune in pairs(RuneOrder[DKROT_Settings.RuneOrder]) do
local start, cooldown = GetRuneCooldown(rune)
local r, g, b = unpack(RUNE_COLOR[GetRuneType(rune)])
local cdtime = start + cooldown - DKROT.curtime
if DKROT_Settings.RuneBars then
DKROT.RuneBars[place]:SetMinMaxValues(0, cooldown)
DKROT.RuneBars[place]:SetValue(cdtime)
DKROT.RuneBars[place].back:SetTexture(r, g, b, 0.2)
DKROT.RuneBars[place].Spark:SetTexture(RuneTexture[GetRuneType(rune)])
DKROT.RuneBars[place].Spark:SetPoint("CENTER", DKROT.RuneBars[place], "BOTTOM", 0, (cdtime <= 0 and 0) or (cdtime < cooldown and (80*cdtime)/cooldown) or 80)
if cdtime > 0 then
DKROT.RuneBars[place].Spark.c.lock = false
DKROT.RuneBars[place]:SetAlpha(0.75)
end
if cdtime <= 0 and not DKROT.RuneBars[place].Spark.c.lock then
DKROT.RuneBars[place].Spark.c:SetCooldown(0,0)
DKROT.RuneBars[place].Spark.c.lock = true
DKROT.RuneBars[place]:SetAlpha(1)
end
place = place + 1
end
cdtime = math.ceil(cdtime)
if cdtime >= cooldown or cdtime >= 10 then
cdtime = "X"
elseif cdtime <= 0 then
cdtime = "*"
end
runebar = runebar .. string.format("|cff%02x%02x%02x%s|r", r*255, g*255, b*255, cdtime)
end
return runebar
end
local function getOpacity(frameName)
if not DKROT_Settings.Location[frameName] or not DKROT_Settings.Location[frameName].Opacity then
DKROT_Settings.Location[frameName].Opacity = 1
DKROT:Debug("Unable to find an Opacity level for " .. frameName)
print("Unable to find an Opacity level for " .. frameName)
end
return DKROT_Settings.Location[frameName].Opacity
end
-- Main function for updating all information
function DKROT:UpdateUI()
if DKROT_Settings.Locked == false and (DKROT.LockDialog == nil or DKROT.LockDialog == false) then
DKROT_UnlockUI()
DKROT.LockDialog = true
StaticPopup_Show("DKROT_FRAME_UNLOCKED")
end
-- GCD
local gcdStart, gcdDur
DKROT.GCD, gcdStart, gcdDur = DKROT:GetGCD()
if DKROT_Settings.GCD and DKROT.GCD ~= 0 then
DKROT.Move.c:SetCooldown(gcdStart, gcdDur)
end
-- Runes
if DKROT_Settings.Rune then
DKROT.RuneBar:SetAlpha(getOpacity("DKROT.RuneBar"))
else
DKROT.RuneBar:SetAlpha(0)
end
if DKROT_Settings.RuneBars then
DKROT.RuneBarHolder:SetAlpha(getOpacity("DKROT.RuneBarHolder"))
else
DKROT.RuneBarHolder:SetAlpha(0)
end
if DKROT_Settings.Rune or DKROT_Settings.RuneBars then
DKROT.RuneBar.Text:SetText(DKROT:BuildRuneBar())
end
-- RunicPower
if DKROT_Settings.RP then
DKROT.RunicPower:SetAlpha(getOpacity("DKROT.RunicPower"))
DKROT.RunicPower.Text:SetText(string.format("|cff00ffff%.3d|r", UnitPower("player")))
else
DKROT.RunicPower:SetAlpha(0)
end
-- Time to Die tracker
if DKROT_Settings.TTD then
DKROT.TTD:SetAlpha(getOpacity("DKROT.TTD"))
local ttd = DKROT:GetTimeToDie()
if not ttd then
if DKROT_Settings.Locked ~= true then
DKROT.TTD.Text:SetText(DKROT:FormatTTD(math.random(60, 700)))
else
DKROT.TTD.Text:SetText("")
end
else
DKROT.TTD.Text:SetText(DKROT:FormatTTD(ttd))
end
else
DKROT.TTD:SetAlpha(0)
end
-- Diseases
if DKROT_Settings.Disease then
DKROT.Diseases:SetAlpha(getOpacity("DKROT.Diseases"))
if DKROT:SpellKnown(DKROT.spells["Necrotic Plague"]) then
DKROT.Diseases.FF:SetAlpha(0)
DKROT.Diseases.BP:SetAlpha(0)
DKROT.Diseases.NP:SetAlpha(1)
DKROT.Diseases.NP.Icon:SetVertexColor(1, 1, 1, 1)
DKROT.Diseases.NP.Time:SetText("")
DKROT.Diseases.NP.Stack:SetText("")
if UnitCanAttack("player", "target") and (not UnitIsDead("target")) then
local _, _, _, stacks, _, _, expires = UnitDebuff("TARGET", DKROT.spells["Necrotic Plague"], nil, "PLAYER")
if expires ~= nil and (expires - DKROT.curtime) > 0 then
DKROT.Diseases.NP.Icon:SetVertexColor(.5, .5, .5, 1)
DKROT.Diseases.NP.Time:SetText(string.format("|cffffffff%.2d|r", expires - DKROT.curtime))
DKROT.Diseases.NP.Stack:SetText(stacks)
end
end
else
DKROT.Diseases.FF:SetAlpha(1)
DKROT.Diseases.BP:SetAlpha(1)
DKROT.Diseases.NP:SetAlpha(0)
DKROT.Diseases.FF.Icon:SetVertexColor(1, 1, 1, 1)
DKROT.Diseases.BP.Icon:SetVertexColor(1, 1, 1, 1)
DKROT.Diseases.FF.Time:SetText("")
DKROT.Diseases.BP.Time:SetText("")
if UnitCanAttack("player", "target") and (not UnitIsDead("target")) then
local expires = select(7,UnitDebuff("TARGET", DKROT.spells["Frost Fever"], nil, "PLAYER"))
if expires ~= nil and (expires - DKROT.curtime) > 0 then
DKROT.Diseases.FF.Icon:SetVertexColor(.5, .5, .5, 1)
DKROT.Diseases.FF.Time:SetText(string.format("|cffffffff%.2d|r", expires - DKROT.curtime))
end
expires = select(7,UnitDebuff("TARGET", DKROT.spells["Blood Plague"], nil, "PLAYER"))
if expires ~= nil and (expires - DKROT.curtime) > 0 then
DKROT.Diseases.BP.Icon:SetVertexColor(.5, .5, .5, 1)
DKROT.Diseases.BP.Time:SetText(string.format("|cffffffff%.2d|r", expires - DKROT.curtime))
end
end
end
else
DKROT.Diseases:SetAlpha(0)
end
-- Priority Icon
DKROT.AOE:SetAlpha(0)
DKROT.Interrupt:SetAlpha(0)
if DKROT_Settings.CD[DKROT.Current_Spec]["DKROT_CDRPanel_DD_Priority"][1] ~= DKROT_OPTIONS_FRAME_VIEW_NONE then
DKROT:UpdateIcon("DKROT_CDRPanel_DD_Priority", DKROT.Move)
DKROT.Move:SetAlpha(getOpacity("DKROT.Move"))
-- If Priority on Main Icon
if DKROT_Settings.CD[DKROT.Current_Spec]["DKROT_CDRPanel_DD_Priority"][1] == DKROT_OPTIONS_CDR_CD_PRIORITY then
-- Show Interrupt icon
if DKROT_Settings.MoveAltInterrupt then
local castInfo = UnitCastingInfo("target")
local spell, notint = select(1, castInfo), select(9, castInfo)
if spell == nil then
local chanInfo = UnitChannelInfo("target")
spell = select(1, chanInfo)
notint = select(8, chanInfo)
end
if spell ~= nil and not notint then
if DKROT:isOffCD("Mind Freeze") then
DKROT.Interrupt:SetAlpha(getOpacity("DKROT.Interrupt"))
end
end
end
end
else
DKROT.Move:SetAlpha(0)
end
-- CDs
for i = 1, #DKROT.CDDisplayList do
local idx = ceil(i/2)
if DKROT_Settings.CD[DKROT.Current_Spec][idx] then
DKROT:UpdateIcon(DKROT.CDDisplayList[i], DKROT.CD[DKROT.CDDisplayList[i]])
DKROT.CD[idx]:SetAlpha(getOpacity("DKROT.CD" .. idx))
else
DKROT.CD[idx]:SetAlpha(0)
end
end
bsamount = (select(15, UnitBuff("PLAYER", DKROT.spells["Blood Shield"])) or 0)
end
-- Disease Tracker
-- Gather the info and apply them to it's frame
function DKROT:DTUpdateInfo(guid, info)
if not DKROT_Settings.DT.Target and UnitGUID("target") == guid then
return
end
-- Create Frame
if info.Frame == nil then
info.Frame = DKROT:DTCreateFrame()
end
info.Frame:SetAlpha(getOpacity("DKROT.DT"))
-- Set Settings
if info.spot == nil or info.spot ~= DKROT.DT.spot then
info.spot = DKROT.DT.spot
info.Frame:ClearAllPoints()
if DKROT_Settings.DT.GrowDown then
info.Frame:SetPoint("TOP", 0, -(DKROT.DT.spot*27)-1)
else
info.Frame:SetPoint("BOTTOM", 0, (DKROT.DT.spot*27)+1)
end
end
-- Change Colour
if DKROT_Settings.DT.TColours then
if (UnitGUID("target") == guid) then
info.Frame:SetBackdropColor(0.1, 0.75, 0.1, 0.9)
elseif (UnitGUID("focus") == guid) then
info.Frame:SetBackdropColor(0.2, 0.2, 0.75, 0.9)
else
info.Frame:SetBackdropColor(0, 0, 0, 0.5)
end
end
-- Threat
info.Frame:SetMinMaxValues(DKROT_Settings.DT.Threat, 100)
if DKROT_Settings.DT.Threat ~= DKROT.ThreatMode.Off and info.Threat ~= nil then
info.Frame:SetValue(info.Threat)
else
info.Frame:SetValue(0)
end
-- Name
local name = info.Name
local color
if DKROT_Settings.DT.CColours then
color = RAID_CLASS_COLORS[select(2, GetPlayerInfoByGUID(guid))]
end
if color == nil then
color = {}
color.r, color.g, color.b = 1, 1, 1
end
name = (string.len(name) > 9 and string.gsub(name, '%s?(.)%S+%s', '%1. ') or name)
info.Frame.Name:SetText(string.format("|cff%02x%02x%02x%.9s|r", color.r*255, color.g*255, color.b*255, name))
-- Dots
if info.Frame.Icons == nil or info.OldDots ~= info.NumDots then
local count = 0
local texture
if info.Frame.Icons ~= nil then
for j, v in pairs(info.Frame.Icons) do
info.Frame.Icons[j]:SetAlpha(0)
end
info.Frame.Icons = nil
end
info.Frame.Icons = {}
info.OldDots = info.NumDots
for j, v in pairs(info.Spells) do
info.Frame.Icons[j] = DKROT:CreateIcon("DKROT.DT."..j, info.Frame, j, 20)
info.Frame.Icons[j].Time:SetFont(DKROT.font, 11, "OUTLINE")
info.Frame.Icons[j]:SetPoint("RIGHT", -(count*22)-1, 0)
info.Frame.Icons[j].Icon:SetTexture(GetSpellTexture(DKROT.DTspells[j][1]))
count = count + 1
end
end
-- Update Dots
if info.Frame.Icons ~= nil and next(info.Spells) ~= nil then
for j, v in pairs(info.Spells) do
if v ~= nil and info.Frame.Icons[j]~= nil then
local t = floor(v - DKROT.curtime)
if t >= 0 then
info.Frame.Icons[j]:SetAlpha(1)
info.Frame.Icons[j].Icon:SetVertexColor(0.5, 0.5, 0.5, 1)
if t > DKROT_Settings.DT.Warning then
info.Frame.Icons[j].Time:SetText(DKROT:formatTime(t))
else
info.Frame.Icons[j].Time:SetText(format("|cffff2222%s|r", DKROT:formatTime(t)))
end
else
info.NumDots = info.NumDots - 1
info.Frame.Icons[j]:SetAlpha(0)
info.Spells[j] = nil
end
else
if info.Frame.Icons[j]~= nil then
info.Frame.Icons[j]:SetAlpha(0)
end
info.NumDots = info.NumDots - 1
info.Spells[j] = nil
end
end
else
return
end
info.Updated = true
DKROT.DT.spot = DKROT.DT.spot + 1
end
function DKROT:DTupdateGUIDFrame(guid)
if DKROT.DT.Unit[guid] ~= nil then
DKROT.DT.Unit[guid].Updated = false
if DKROT.DT.spot < DKROT_Settings.DT.Numframes then
DKROT:DTUpdateInfo(guid, DKROT.DT.Unit[guid])
end
if DKROT.DT.Unit[guid] ~= nil and DKROT.DT.Unit[guid].Updated == false and DKROT.DT.Unit[guid].Frame ~= nil then
DKROT.DT.Unit[guid].Frame:SetAlpha(0)
if next(DKROT.DT.Unit[guid].Spells) == nil then
DKROT.DT.Unit[guid] = nil
end
end
end
end
-- Update the frames
function DKROT:DTUpdateFrames()
DKROT.DT.spot = 0
local targetguid, focusguid
if DKROT_Settings.DT.TPriority then
targetguid, focusguid = UnitGUID("target"), UnitGUID("focus")
DKROT:DTupdateGUIDFrame(targetguid)
if targetguid ~= focusguid then
DKROT:DTupdateGUIDFrame(focusguid)
end
end
for k, v in pairs(DKROT.DT.Unit) do
if k ~= targetguid and k ~= focusguid then
DKROT:DTupdateGUIDFrame(k)
end
end
end
-- Update Threat and Dots from checking target infos
function DKROT:DTCheckTargets()
local updatedGUIDs = {}
local function updateGUIDInfo(unit)
local guid = UnitGUID(unit)
if guid ~= nil and updatedGUIDs[guid] == nil then
if UnitIsDead(unit) and DKROT.DT.Unit[guid] ~= nil and DKROT.DT.Unit[guid].Frame ~= nil then
DKROT.DT.Unit[guid].Frame:SetAlpha(0)
DKROT.DT.Unit[guid].Frame = nil
DKROT.DT.Unit[guid] = nil
end
if select(1, UnitDebuff(unit, 1, "PLAYER")) ~= nil then
local name, expt
for j= 1, 10 do
name, _, _, _, _, _, expt = UnitDebuff(unit, j, "PLAYER")
if name == nil then break end
if DKROT_Settings.DT.Dots[name] then
if DKROT.DT.Unit[guid] == nil then
local targetName = UnitName(unit)
DKROT.DT.Unit[guid] = {}
DKROT.DT.Unit[guid].Spells = {}
DKROT.DT.Unit[guid].NumDots = 0
DKROT.DT.Unit[guid].Name = select(3, string.find(targetName, "(.-)-")) or targetName
end
updatedGUIDs[guid] = true
if DKROT.DT.Unit[guid].Spells[name] == nil then
DKROT.DT.Unit[guid].NumDots = DKROT.DT.Unit[guid].NumDots + 1
end
if name == DKROT.spells["Death and Decay"] then
DKROT.DT.Unit[guid].Spells[name] = select(1, GetSpellCooldown(name)) + 10
else
DKROT.DT.Unit[guid].Spells[name] = expt
end
if DKROT_Settings.DT.Threat ~= DKROT.ThreatMode.Off then
DKROT.DT.Unit[guid].Threat = select(3, UnitDetailedThreatSituation("player", unit))
if DKROT_Settings.DT.Threat == DKROT.ThreatMode.Health then
DKROT.DT.Unit[guid].Threat = (UnitHealth(unit)/UnitHealthMax(unit))*100
end
end
end
end
end
end
end
updatedGUIDs = {}
updateGUIDInfo("target")
updateGUIDInfo("focus")
updateGUIDInfo("pettarget")
for i = 1, MAX_BOSS_FRAMES do
updateGUIDInfo("boss"..i)
end
end
-- Priority System
-- Called to update a priority icon with next move
function DKROT:GetNextMove(icon)
local rotation = DKROT.Rotations[DKROT.Current_Spec][DKROT_Settings.CD[DKROT.Current_Spec].Rotation]
-- Call correct function based on spec
if DKROT_Settings.MoveAltAOE then
local aoeNextCast, aoeNocheckRange
if rotation.aoe ~= nil then
aoeNextCast, aoeNoCheckRange = rotation.aoe()
else
if (DKROT.Current_Spec == DKROT.SPECS.UNHOLY) then
aoeNextCast, aoeNoCheckRange = DKROT:UnholyAOEMove()
elseif (DKROT.Current_Spec == DKROT.SPECS.FROST) then
aoeNextCast, aoeNoCheckRange = DKROT:FrostAOEMove()
elseif (DKROT.Current_Spec == DKROT.SPECS.BLOOD) then
aoeNextCast, aoeNoCheckRange = nil, nil
end
end
if aoeNextCast ~= nil then
DKROT.AOE:SetAlpha(getOpacity("DKROT.AOE"))
if aoeNoCheckRange ~= nil and aoeNoCheckRange == true then
DKROT.AOE.Icon:SetTexture(GetSpellTexture(DKROT.spells[aoeNextCast]))
else
DKROT.AOE.Icon:SetTexture(GetSpellTexture(DKROT.spells[aoeNextCast]))
end
end
end
-- If we arent in combat yet, and we have a pre-pull timer up, show the prepull rotation
-- if the user has opted to
if DKROT_Settings.CD[DKROT.Current_Spec].PrePull and not InCombatLockdown() and DKROT.PullTimer > DKROT.curtime then
local nextPrePullCast, isItem = rotation.prepull()
if nextPrePullCast ~= nil then
if isItem then
return select(10, GetItemInfo(nextPrePullCast))
else
return GetSpellTexture(nextPrePullCast)
end
end
end
local nextCast, noCheckRange = rotation.func()
if noCheckRange ~= nil and noCheckRange == true then
return GetSpellTexture(DKROT.spells[nextCast])
else
return DKROT:GetRangeandIcon(icon, nextCast)
end
end
-- Determines if player is in range with spell and sets colour and icon accordingly
-- In: icon: icon in which to change the vertex colour of move: spellID of spell to be cast next
-- Out: returns the texture of the icon (probably unessesary since icon is now being passed in, will look into it more)
function DKROT:GetRangeandIcon(icon, move)
move = (DKROT.spells[move] ~= nil and DKROT.spells[move] or move)
if move ~= nil then
if DKROT_Settings.Range and IsSpellInRange(move, "target") == 0 then
icon:SetVertexColor(0.8, 0.05, 0.05, 1)
else
icon:SetVertexColor(1, 1, 1, 1)
end
return GetSpellTexture(move)
end
return nil
end
-- Returns if move is off cooldown or not
function DKROT:QuickAOESpellCheck(move)
if DKROT_Settings.MoveAltAOE and GetSpellTexture(DKROT.spells[move]) ~= nil then
if DKROT:CanUse(move) and DKROT:isOffCD(DKROT.spells[move]) then
return true
end
end
return false
end
-- Function to check spec and presence
function DKROT:CheckSpec()
-- Set all settings to default
DKROT.Current_Spec = DKROT.SPECS.UNKNOWN
if GetSpecialization() == 1 then
DKROT.Current_Spec = DKROT.SPECS.BLOOD
elseif GetSpecialization() == 2 then
DKROT.Current_Spec = DKROT.SPECS.FROST
elseif GetSpecialization() == 3 then
DKROT.Current_Spec = DKROT.SPECS.UNHOLY
end
-- Presence
PLAYER_PRESENCE = 0
for i = 1, GetNumShapeshiftForms() do
local icon, _, active = GetShapeshiftFormInfo(i)
if active then
PLAYER_PRESENCE = i
end
end
DKROT:Debug("Check Spec - " .. DKROT.Current_Spec)
end
function DKROT:Initialize()
DKROT:Debug("Initialize")
if InCombatLockdown() then
if delayedInit == false then
delayedInit = true
DKROT:Log("Delaying initialization due to combat lockdown")
end
return
end
mutex = true
DKROT:LoadSpells()
DKROT:LoadCooldowns()
if not DKROT:LoadTrinkets() and (DKROT.curtime - launchtime < ITEM_LOAD_THRESHOLD) then
DKROT:Debug("Initialize Failed")
mutex = false
return
end
if (DKROT.curtime - launchtime >= ITEM_LOAD_THRESHOLD) then
DKROT:Debug("Launch Threshold Met")
end
if DKROT.debug then
DKROT:Debug("~~Spell Difference Start~~")
for k, v in pairs(DKROT.spells) do
if v == nil or k ~= v then
DKROT:Debug(k.." =/= ".. v)
end
end
DKROT:Debug("~~Spell Difference End~~")
end
-- DKROT:SetDefaults()
-- Check Settings
DKROT:CheckSpec()
DKROT:CheckSettings()
DKROT:Debug("Initialize - Version " .. DKROT_Settings.Version)
if DKROT_Settings.DT.Combat or not DKROT_Settings.DT.Enable then
DKROT.MainFrame:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
else
DKROT.MainFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
end
DKROT.MainFrame:SetAlpha(0)
DKROT:CreateCDs()
DKROT:CreateUI()
-- Setup Masque if enabled
local MSQ = LibStub("Masque", true)
if MSQ then
local msqMainGrp = MSQ:Group("DKRot")
local msqCDGrp = MSQ:Group("DKRot", "Cooldowns")
local msqDiseaseGrp = MSQ:Group("DKRot", "Diseases")
msqMainGrp:AddButton(DKROT.Move)
msqMainGrp:AddButton(DKROT.AOE)
msqMainGrp:AddButton(DKROT.Interrupt)
msqDiseaseGrp:AddButton(DKROT.Diseases.NP)
msqDiseaseGrp:AddButton(DKROT.Diseases.FF)
msqDiseaseGrp:AddButton(DKROT.Diseases.BP)
for i = 1, #DKROT.CDDisplayList do
msqCDGrp:AddButton(DKROT.CD[DKROT.CDDisplayList[i]])
end
end
local PosPanel = DKROT:SetupPositionPanel(function() DKROT:PositionUpdate() end)
-- Background Opacity slider
local backdropInfo = { parent = DKROT_FramePanel, value = 1, label = "Backdrop Opacity", minValue = 0, maxValue = 1 }
DKROT.FramePanel_BackdropOpacity = DKROT:BuildSliderOption(backdropInfo, function()
DKROT_Settings.BackdropOpacity = DKROT.FramePanel_BackdropOpacity:GetValue()
for idx, frame in pairs(DKROT.MovableFrames) do
DKROT:MoveFrame(_G[frame.frame])
end
end)
DKROT.FramePanel_BackdropOpacity:SetPoint("TOPLEFT", DKROT_FramePanel_ViewDD, "BOTTOMLEFT", 15, -10)
-- Global Opacity override slider
local overrideInfo = { parent = DKROT_FramePanel, value = 1, label = "Global Opacity Override", minValue = 0, maxValue = 1 }
DKROT.FramePanel_OpacityOverride = DKROT:BuildSliderOption(overrideInfo, function()
for idx, frame in pairs(DKROT.MovableFrames) do
DKROT_Settings.Location[frame.frame].Opacity = DKROT.FramePanel_OpacityOverride:GetValue()
end
end)
DKROT.FramePanel_OpacityOverride:SetPoint("TOPLEFT", DKROT.FramePanel_BackdropOpacity, "BOTTOMLEFT", 0, -10)
-- ActiveTarget time threshold
local overrideInfo = { parent = DKROT_FramePanel, value = 1.5, label = "Active Target Timeout", minValue = 1.5, maxValue = 5 }
DKROT.FramePanel_ActiveTargetThreshold = DKROT:BuildSliderOption(overrideInfo, function()
DKROT_Settings.ActiveTargetThreshold = DKROT.FramePanel_ActiveTargetThreshold:GetValue()
end)
DKROT.FramePanel_ActiveTargetThreshold:SetPoint("TOPLEFT", DKROT.FramePanel_OpacityOverride, "BOTTOMLEFT", 0, -10)
DKROT.CDRPanel_RotOptions = CreateFrame("Frame", "DKROT.CDRPanel_RotOptions", DKROT_CDRPanel)
DKROT.CDRPanel_RotOptions:SetBackdrop({
bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
tile = true, tileSize = 32, edgeSize = 16,
insets = { left = 5, right = 6, top = 6, bottom = 5 }
})
DKROT.CDRPanel_RotOptions:SetPoint("TOPLEFT", DKROT_CDRPanel_Rotation_Title, "TOPLEFT", -5, -12)
DKROT.CDRPanel_RotOptions:SetWidth(240)
DKROT.CDRPanel_RotOptions.children = {}
DKROT_CDRPanel:SetScript("OnShow", function()
DKROT:BuildRotationOptions()
end)
DKROT:BuildRotationOptions()
InterfaceOptions_AddCategory(DKROT_Options)
InterfaceOptions_AddCategory(DKROT_FramePanel)
InterfaceOptions_AddCategory(DKROT_CDRPanel)
InterfaceOptions_AddCategory(DKROT_CDPanel)
InterfaceOptions_AddCategory(DKROT_DTPanel)
InterfaceOptions_AddCategory(DKROT_PositionPanel)
InterfaceOptions_AddCategory(DKROT_ABOUTPanel)
-- DKROT_CDRPanel_DG_Text:SetText(DKROT.spells["Death Grip"])
DKROT:OptionsRefresh()