-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathDecursive.lua
More file actions
2827 lines (2304 loc) · 83.8 KB
/
Decursive.lua
File metadata and controls
2827 lines (2304 loc) · 83.8 KB
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
--[[
Decursive (v 1.9.8.3) add-on for World of Warcraft UI
Copyright (C) 2006 Archarodim ( http://www.2072productions.com/?to=decursive-continued.txt )
This is the continued work of the original Decursive (v1.9.4) by Quu
Decursive 1.9.4 is in public domain ( www.quutar.com )
License:
This program 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 2
of the License, or (at your option) any later version.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
--]]
-------------------------------------------------------------------------------
-- this will spam... really only use it for testing
local Dcr_Print_Spell_Found = false;
-- how many seconds... can be fractional... needs to be more than 0.4... 1.0 is optimal
local Dcr_SpellCombatDelay = 1.0;
-- print out a fuckload of info
Dcr_Print_DEBUG = false;
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- and any internal HARD settings for decursive
DCR_MAX_LIVE_SLOTS = 15;
local DCR_TEXT_LIFETIME = 4.0;
-------------------------------------------------------------------------------
-- this is something I use for remote debugging
DCR_REMOTE_DEBUG = { };
-------------------------------------------------------------------------------
-- variables {{{
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- The stored variables {{{
-------------------------------------------------------------------------------
Dcr_Saved = {
-- this is the items that are stored...
Dcr_Print_DEBUG_bis = false;
-- this is the priority list of people to cure
PriorityList = { };
-- this is the people to skip
SkipList = { };
-- this is wether or not to show the "live" list
Hide_LiveList = false;
-- This will turn on and off the sending of messages to the default chat frame
Print_ChatFrame = false;
-- this will send the messages to a custom frame that is moveable
Print_CustomFrame = true;
-- this will disable error messages
Print_Error = true;
-- check for abolish before curing poison or disease
Check_For_Abolish = true;
-- this is "fix" for the fact that rank 1 of dispell magic does not always remove
-- the high level debuffs properly. This carrys over to other things.
AlwaysUseBestSpell = true;
-- should we do the orders randomly?
Random_Order = false;
-- should we scan pets
Scan_Pets = true;
-- should we ignore stealthed units
Ingore_Stealthed = false;
-- how many to show in the livelist
Amount_Of_Afflicted = 5;
-- how many seconds to "black list" someone with a failed spell
CureBlacklist = 5.0;
-- how often to poll for afflictions in seconds
ScanTime = 0.2;
-- Are prio list members protected from blacklisting?
DoNot_Blacklist_Prio_List = false;
-- Play a sound when there is something to decurse
PlaySound = true;
-- Hide the buttons
HideButtons = false;
-- Cure magic if possible
CureMagic = true;
-- Cure Poison if possible
CurePoison = true;
-- Cure Disease if possible
CureDisease = true;
-- Cure Curse if possible
CureCurse = true;
-- Display text above in the custom frame
CustomeFrameInsertBottom = false;
-- Disable tooltips in affliction list
AfflictionTooltips = true;
-- Reverse LiveList Display
ReverseLiveDisplay = false;
-- Hide everything but the livelist
Hidden = false;
-- if true then the live list will show only if the main window is shown
LiveListTied = false;
-- allow to changes the default output window
Dcr_OutputWindow = DEFAULT_CHAT_FRAME;
-- cure order list
CureOrderList = {
[1] = DCR_MAGIC,
[2] = DCR_CURSE,
[3] = DCR_POISON,
[4] = DCR_DISEASE
}
}; -- // }}}
-------------------------------------------------------------------------------
-- This array avoid to test someone we've just blackisted twice.
local DCR_ThisCleanBlaclisted = { };
local Dcr_CuringAction_Icons = { };
-- the new spellbook (made it simpler due to localization problems)
local DCR_HAS_SPELLS = false;
local DCR_SPELL_MAGIC_1 = {0,"", ""};
local DCR_SPELL_MAGIC_2 = {0,"", ""};
DCR_CAN_CURE_MAGIC = false;
local DCR_SPELL_ENEMY_MAGIC_1 = {0,"", ""};
local DCR_SPELL_ENEMY_MAGIC_2 = {0,"", ""};
DCR_CAN_CURE_ENEMY_MAGIC = false;
local DCR_SPELL_DISEASE_1 = {0,"", ""};
local DCR_SPELL_DISEASE_2 = {0,"", ""};
DCR_CAN_CURE_DISEASE = false;
local DCR_SPELL_POISON_1 = {0,"", ""};
local DCR_SPELL_POISON_2 = {0,"", ""};
DCR_CAN_CURE_POISON = false;
local DCR_SPELL_CURSE = {0,"", ""};
DCR_CAN_CURE_CURSE = false;
local DCR_SPELL_COOLDOWN_CHECK = {0,"", ""};
-- for the blacklist
local Dcr_Casting_Spell_On = nil;
local Dcr_Blacklist_Array = { };
local DEBUFF_CACHE_LIFE = 30.0;
local Dcr_Debuff_Texture_to_name_cache = {};
local Dcr_Debuff_Texture_to_name_cache_life = 0.0;
local Dcr_Buff_Texture_to_name_cache = {};
local Dcr_Buff_Texture_to_name_cache_life = 0.0;
local Dcr_CheckingPET = false;
local Dcr_DelayedReconf = false;
Dcr_Groups_datas_are_invalid = false; -- not local because changed from the xml file when clicking on random cure
local InternalPrioList = { };
local InternalSkipList = { };
local Dcr_Unit_Array = { };
local Dcr_Unit_ArrayByName = { };
local target_added = false;
local SortingTable = {};
local Dcr_CheckPet_Delay = 2;
local Dcr_DelayedReconf_delay = 1;
local Dcr_DelayedReconf_timer = 0;
local Dcr_CheckPet_Timer = 0;
local Dcr_Delay_Timer = 0;
local last_DemonType = nil;
local curr_DemonType = nil;
local Dcr_AlreadyCleanning = false;
local Dcr_RestoreTarget = true;
local Dcr_SoundPlayed = false;
local Dcr_CombatMode = false;
local Dcr_timeLeft = 0;
Dcr_PlayerClass = "";
-- The rotatibg cure table functions array
local Curing_functions = {};
Dcr_CureTypeCheckBoxes = {};
local RestorSelfAutoCastTimeOut = 1;
local RestorSelfAutoCast = false;
-- // }}}
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- The UI functions {{{
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- The printing functions {{{
-------------------------------------------------------------------------------
function Dcr_debug( Message) --{{{
if (Dcr_Print_DEBUG) then
table.insert(DCR_REMOTE_DEBUG, Message);
Dcr_Saved.Dcr_OutputWindow:AddMessage(Message, 0.1, 0.1, 1);
end
return true;
end --}}}
function Dcr_debug_bis( Message) --{{{
if (Dcr_Saved.Dcr_Print_DEBUG_bis) then
table.insert(DCR_REMOTE_DEBUG, Message);
Dcr_Saved.Dcr_OutputWindow:AddMessage(Message, 0.1, 0.1, 1);
end
return true;
end --}}}
function Dcr_Toggle_debug_bis() --{{{
if (Dcr_Saved.Dcr_Print_DEBUG_bis) then
Dcr_debug_bis("Debug: Disabled");
Dcr_Saved.Dcr_Print_DEBUG_bis = false;
DCR_REMOTE_DEBUG = {};
else
Dcr_Saved.Dcr_Print_DEBUG_bis = true;
Dcr_debug_bis("Debug: Enabled");
end
end --}}}
function MakePlayerName (name) --{{{
return "|cFFFFAA22|Hplayer:" .. name .. "|h" .. string.upper(name) .. "|h|r";
end --}}}
function MakeAfflictionName (name) --{{{
if (name) then
return "|cFFFF6622" .. DCR_LOC_AF_TYPE[name] .. "|r";
else
return "";
end
end --}}}
function Dcr_println( Message) --{{{
if (Dcr_Saved.Print_ChatFrame) then
if (Dcr_Saved.Dcr_OutputWindow) then -- this FUCKING variable find the fucking way of being fucking NIL for some players.... *spitting on LUA language*
Dcr_Saved.Dcr_OutputWindow:AddMessage(Message, 1, 1, 1);
else
DEFAULT_CHAT_FRAME:AddMessage(Message, 1, 1, 1);
end
end
if (Dcr_Saved.Print_CustomFrame) then
DecursiveTextFrame:AddMessage(Message, 1, 1, 1, 0.9);
end
end --}}}
function Dcr_errln( Message) --{{{
if (Dcr_Saved.Print_Error) then
if (Dcr_Saved.Print_ChatFrame) then
if (Dcr_Saved.Dcr_OutputWindow) then -- this FUCKING variable find the fucking way of being fucking NIL for some players.... *spitting on LUA language*
Dcr_Saved.Dcr_OutputWindow:AddMessage(Message, 1, 0.1, 0.1);
else
DEFAULT_CHAT_FRAME:AddMessage(Message, 1, 0.1, 0.1);
end
end
if (Dcr_Saved.Print_CustomFrame) then
DecursiveTextFrame:AddMessage(Message, 1, 0.1, 0.1, 0.9);
end
end
end --}}}
function Dcr_PrintPriorityList() --{{{
for id, name in Dcr_Saved.PriorityList do
Dcr_println( id.." - "..name);
end
end --}}}
function TMP_pr() --{{{
for index, unit in Dcr_Unit_Array do
Dcr_println( unit.." - "..MakePlayerName((UnitName(unit))) .. " Index: "..index);
end
end --}}}
-- }}}
-------------------------------------------------------------------------------
-- Show Hide FUNCTIONS -- {{{
function Dcr_ShowHideAfflictedListUI() --{{{-- here for compatibility -- deprecated
Dcr_Hide(false);
end --}}}
function Dcr_ShowHideLiveList(hide) --{{{
-- if hide is requested or if hide is not set and the live-list is shown
if (hide==1 or (not hide and DecursiveAfflictedListFrame:IsVisible())) then
Dcr_Saved.Hide_LiveList = true;
DecursiveAfflictedListFrame:Hide();
else
Dcr_Saved.Hide_LiveList = false;
DecursiveAfflictedListFrame:ClearAllPoints();
DecursiveAfflictedListFrame:SetPoint("TOPLEFT", "DecursiveMainBar", "BOTTOMLEFT");
DecursiveAfflictedListFrame:Show();
end
if (Dcr_Saved.Hide_LiveList) then
DcrOptionsFrameHideLL:SetChecked(1);
else
DcrOptionsFrameHideLL:SetChecked(0);
end
end --}}}
function Dcr_Hide(hide) --{{{
if (hide==1 or (not hide and DecursiveMainBar:IsVisible())) then
if (Dcr_Saved.LiveListTied) then
Dcr_ShowHideLiveList(1);
end
Dcr_Saved.Hidden = true;
DecursiveMainBar:Hide();
else
if (Dcr_Saved.LiveListTied) then
Dcr_ShowHideLiveList(0);
end
Dcr_Saved.Hidden = false;
DecursiveMainBar:Show();
end
if DecursiveMainBar:IsVisible() and DecursiveAfflictedListFrame:IsVisible() then
DecursiveAfflictedListFrame:ClearAllPoints();
DecursiveAfflictedListFrame:SetPoint("TOPLEFT", "DecursiveMainBar", "BOTTOMLEFT");
else
Dcr_Saved.Dcr_OutputWindow:AddMessage(DCR_SHOW_MSG, 0.3, 0.5, 1);
end
end --}}}
function Dcr_ShowHidePriorityListUI() --{{{
if (DecursivePriorityListFrame:IsVisible()) then
DecursivePriorityListFrame:Hide();
else
DecursivePriorityListFrame:Show();
end
end --}}}
-- skip list stuff
function Dcr_ShowHideSkipListUI() --{{{
if (DecursiveSkipListFrame:IsVisible()) then
DecursiveSkipListFrame:Hide();
else
DecursiveSkipListFrame:Show();
end
end --}}}
function Dcr_ShowHideOptionsUI() --{{{
if (DcrOptionsFrame:IsVisible()) then
DcrOptionsFrame:Hide();
else
DcrOptionsFrame:Show();
DcrOptionsFrame2:ClearAllPoints();
DcrOptionsFrame2:SetPoint("TOPLEFT", "DcrOptionsFrame", "TOPRIGHT");
end
end --}}}
function Dcr_ShowHideTextAnchor() --{{{
if (DecursiveAnchor:IsVisible()) then
DecursiveAnchor:Hide();
else
DecursiveAnchor:Show();
end
end --}}}
function Dcr_ShowHideButtons(UseCurrentValue) --{{{
local DecrFrame = "DecursiveMainBar";
local buttons = {
DecrFrame .. "Priority",
DecrFrame .. "Skip",
DecrFrame .. "Options",
DecrFrame .. "Hide",
}
DCRframeObject = getglobal(DecrFrame);
if (not UseCurrentValue) then
Dcr_Saved.HideButtons = (not Dcr_Saved.HideButtons);
end
for _, ButtonName in buttons do
Button = getglobal(ButtonName);
if (Dcr_Saved.HideButtons) then
Button:Hide();
DCRframeObject.isLocked = 1;
else
Button:Show();
DCRframeObject.isLocked = 0;
end
end
end --}}}
-- }}}
-- OPTION RELATED FUNCTIONS {{{
function Dcr_ChangeTextFrameDirection(bottom) --{{{
buton = DecursiveAnchorDirection;
if (bottom) then
DecursiveTextFrame:SetInsertMode("BOTTOM");
buton:SetText("v");
else
DecursiveTextFrame:SetInsertMode("TOP");
buton:SetText("^");
end
end --}}}
function Dcr_AmountOfAfflictedSlider_OnShow() --{{{
getglobal(this:GetName().."High"):SetText("15");
getglobal(this:GetName().."Low"):SetText("5");
getglobal(this:GetName() .. "Text"):SetText(DCR_AMOUNT_AFFLIC .. Dcr_Saved.Amount_Of_Afflicted);
this:SetMinMaxValues(1, 15);
this:SetValueStep(1);
this:SetValue(Dcr_Saved.Amount_Of_Afflicted);
end --}}}
function Dcr_AmountOfAfflictedSlider_OnValueChanged() --{{{
Dcr_Saved.Amount_Of_Afflicted = this:GetValue();
getglobal(this:GetName() .. "Text"):SetText(DCR_AMOUNT_AFFLIC .. Dcr_Saved.Amount_Of_Afflicted);
end --}}}
function Dcr_ScanTimeSlider_OnShow() --{{{
getglobal(this:GetName().."High"):SetText("1");
getglobal(this:GetName().."Low"):SetText("0.1");
getglobal(this:GetName() .. "Text"):SetText(DCR_SCAN_LENGTH .. Dcr_Saved.ScanTime);
this:SetMinMaxValues(0.1, 1);
this:SetValueStep(0.1);
this:SetValue(Dcr_Saved.ScanTime);
end --}}}
function Dcr_ScanTimeSlider_OnValueChanged() --{{{
Dcr_Saved.ScanTime = this:GetValue() * 10;
if (Dcr_Saved.ScanTime < 0) then
Dcr_Saved.ScanTime = ceil(Dcr_Saved.ScanTime - 0.5)
else
Dcr_Saved.ScanTime = floor(Dcr_Saved.ScanTime + 0.5)
end
Dcr_Saved.ScanTime = Dcr_Saved.ScanTime / 10;
getglobal(this:GetName() .. "Text"):SetText(DCR_SCAN_LENGTH .. Dcr_Saved.ScanTime);
end --}}}
function Dcr_CureBlacklistSlider_OnShow() --{{{
getglobal(this:GetName().."High"):SetText("20");
getglobal(this:GetName().."Low"):SetText("1");
getglobal(this:GetName() .. "Text"):SetText(DCR_BLACK_LENGTH .. Dcr_Saved.CureBlacklist);
this:SetMinMaxValues(1, 20);
this:SetValueStep(0.1);
this:SetValue(Dcr_Saved.CureBlacklist);
end --}}}
function Dcr_CureBlacklistSlider_OnValueChanged() --{{{
Dcr_Saved.CureBlacklist = this:GetValue() * 10;
if (Dcr_Saved.CureBlacklist < 0) then
Dcr_Saved.CureBlacklist = ceil(Dcr_Saved.CureBlacklist - 0.5)
else
Dcr_Saved.CureBlacklist = floor(Dcr_Saved.CureBlacklist + 0.5)
end
Dcr_Saved.CureBlacklist = Dcr_Saved.CureBlacklist / 10;
getglobal(this:GetName() .. "Text"):SetText(DCR_BLACK_LENGTH .. Dcr_Saved.CureBlacklist);
end --}}}
function Dcr_On_CureOrderCheckBox_Update (CheckBox) -- {{{
--Dcr_debug_bis(CheckBox.CureType .. " cb called");
-- if it's unchecked
if (CheckBox.CurePos ~= 0 and not CheckBox:GetChecked()) then
Dcr_debug_bis("===> UN checked");
-- remove its position in the cure order list
CheckBox.CurePos = 0;
-- remove the debuff type from the saved ordered list
Dcr_tremovebyval(Dcr_Saved.CureOrderList, CheckBox.CureType);
-- remove the green number before the checkbox text
getglobal(CheckBox:GetName().."LText"):SetText("");
-- if done here then update the actual cure order list
Dcr_SetCureOrderList ();
elseif ( CheckBox.CurePos == 0 and CheckBox:GetChecked()) then -- it seems that (not CheckBox.CurePos) is not the same than (CheckBox.CurePos == false) in LUA so we forgot booleans................
Dcr_debug_bis("===> CHECKED");
-- set the object position
CheckBox.CurePos = table.getn(Dcr_Saved.CureOrderList) + 1;
-- register its type in the saved list
Dcr_Saved.CureOrderList[CheckBox.CurePos] = CheckBox.CureType;
-- if done here then update the actual cure order list
Dcr_SetCureOrderList ();
end
end -- }}}
function Dcr_SetCureOrderList () -- {{{
-- Dcr_debug_bis("Dcr_SetCureOrderList called");
local i;
local j = 0;
local CheckBox;
local temp_table = {};
-- clear curing functions
Curing_functions = {};
for i=1, 4 do
if (Dcr_Saved.CureOrderList[i]) then
-- set a shortcut to our checkbox object
CheckBox = Dcr_CureTypeCheckBoxes[Dcr_Saved.CureOrderList[i]];
-- re-index Dcr_Saved.CureOrderList
j = j + 1;
temp_table[j] = Dcr_Saved.CureOrderList[i];
-- register the curing function
Curing_functions[j] = CheckBox.CureFunction;
CheckBox.CurePos = j;
-- set a green number before the checkbox text
getglobal(CheckBox:GetName().."LText"):SetText("|cFF00FF00"..j.."|r ");
end
end
-- save our reordered Dcr_Saved.CureOrderList
Dcr_Saved.CureOrderList = temp_table;
end -- }}}
function VerifyOrderList ()
local TempTable = {};
local i;
Dcr_debug_bis("Verifying CureOrderList...");
-- take the 4 first value of the Dcr_Saved.CureOrderList table
for i=1, 4 do
-- add it only if not already listed
if ( Dcr_Saved.CureOrderList[i] and not Dcr_tcheckforval(TempTable, Dcr_Saved.CureOrderList[i])) then
TempTable[i] = Dcr_Saved.CureOrderList[i];
Dcr_debug_bis("Already in list: "..TempTable[i]);
end
end
if (Dcr_Saved.CureMagic and not Dcr_tcheckforval(TempTable, DCR_MAGIC )) then
table.insert(TempTable, DCR_MAGIC);
Dcr_debug_bis("Adding " .. DCR_MAGIC);
end
if (Dcr_Saved.CureCurse and not Dcr_tcheckforval(TempTable, DCR_CURSE )) then
table.insert(TempTable, DCR_CURSE);
Dcr_debug_bis("Adding " .. DCR_CURSE);
end
if (Dcr_Saved.CurePoison and not Dcr_tcheckforval(TempTable, DCR_POISON )) then
table.insert(TempTable, DCR_POISON);
Dcr_debug_bis("Adding " .. DCR_POISON);
end
if (Dcr_Saved.CureDisease and not Dcr_tcheckforval(TempTable, DCR_DISEASE )) then
table.insert(TempTable, DCR_DISEASE);
Dcr_debug_bis("Adding " .. DCR_DISEASE);
end
Dcr_Saved.CureOrderList = TempTable;
end
function Dcr_tremovebyval(tab, val) -- {{{
local k;
local v;
for k,v in tab do
if(v==val) then
table.remove(tab, k);
return true;
end
end
return false;
end -- }}}
function Dcr_tcheckforval(tab, val) -- {{{
local k;
local v;
for k,v in tab do
if(v==val) then
return true;
end
end
return false;
end -- }}}
-- // }}}
-- this resets the location of the windows
function Dcr_ResetWindow() --{{{
DecursiveMainBar:ClearAllPoints();
DecursiveMainBar:SetPoint("CENTER", "UIParent");
DecursiveMainBar:Show();
DecursiveAfflictedListFrame:ClearAllPoints();
DecursiveAfflictedListFrame:SetPoint("TOPLEFT", "DecursiveMainBar", "BOTTOMLEFT");
DecursiveAfflictedListFrame:Show();
DecursivePriorityListFrame:ClearAllPoints();
DecursivePriorityListFrame:SetPoint("CENTER", "UIParent");
DecursiveSkipListFrame:ClearAllPoints();
DecursiveSkipListFrame:SetPoint("CENTER", "UIParent");
DecursivePopulateListFrame:ClearAllPoints();
DecursivePopulateListFrame:SetPoint("CENTER", "UIParent");
DcrOptionsFrame:ClearAllPoints();
DcrOptionsFrame:SetPoint("CENTER", "UIParent");
DcrOptionsFrame2:ClearAllPoints();
DcrOptionsFrame2:SetPoint("TOPLEFT", "DcrOptionsFrame", "TOPRIGHT");
end --}}}
function Dcr_ThisSetText(text) --{{{
getglobal(this:GetName().."Text"):SetText(text);
end --}}}
function Dcr_DisplayTooltip(Message, RelativeTo) --{{{
DcrDisplay_Tooltip:SetOwner(RelativeTo, "ANCHOR_TOPRIGHT");
DcrDisplay_Tooltip:ClearLines();
DcrDisplay_Tooltip:SetText(Message);
DcrDisplay_Tooltip:Show();
end --}}}
function Dcr_DebuffTemplate_OnEnter() --{{{
if (Dcr_Saved.AfflictionTooltips) then
DcrDisplay_Tooltip:SetOwner(this, "ANCHOR_CURSOR");
DcrDisplay_Tooltip:ClearLines();
DcrDisplay_Tooltip:SetUnitDebuff(this.unit,this.debuff); -- OK
DcrDisplay_Tooltip:Show();
end
end --}}}
-- Prio and skip list LIST {{{
function Dcr_PriorityListEntryTemplate_OnClick() --{{{
local id = this:GetID();
if (id) then
if (this.Priority) then
Dcr_RemoveIDFromPriorityList(id);
else
Dcr_RemoveIDFromSkipList(id);
end
end
this.UpdateYourself = true;
end --}}}
function Dcr_PriorityListEntryTemplate_OnUpdate() --{{{
if (this.UpdateYourself) then
this.UpdateYourself = false;
local baseName = this:GetName();
local NameText = getglobal(baseName.."Name");
local id = this:GetID();
if (id) then
local name
if (this.Priority) then
name = Dcr_Saved.PriorityList[id];
else
name = Dcr_Saved.SkipList[id];
end
if (name) then
NameText:SetText(id.." - "..name);
else
NameText:SetText("Error - ID Invalid!");
end
else
NameText:SetText("Error - No ID!");
end
end
end --}}}
function Dcr_PriorityListFrame_OnUpdate() --{{{
if (this.UpdateYourself) then
this.UpdateYourself = false;
Dcr_Groups_datas_are_invalid = true;
local baseName = this:GetName();
local up = getglobal(baseName.."Up");
local down = getglobal(baseName.."Down");
local size = table.getn(Dcr_Saved.PriorityList);
if (size < 11 ) then
this.Offset = 0;
up:Hide();
down:Hide();
else
if (this.Offset <= 0) then
this.Offset = 0;
up:Hide();
down:Show();
elseif (this.Offset >= (size - 10)) then
this.Offset = (size - 10);
up:Show();
down:Hide();
else
up:Show();
down:Show();
end
end
local i;
for i = 1, 10 do
local id = ""..i;
if (i < 10) then
id = "0"..i;
end
local btn = getglobal(baseName.."Index"..id);
btn:SetID( i + this.Offset);
btn.UpdateYourself = true;
if (i <= size) then
btn:Show();
else
btn:Hide();
end
end
end
end --}}}
function Dcr_SkipListFrame_OnUpdate() --{{{
if (this.UpdateYourself) then
this.UpdateYourself = false;
Dcr_Groups_datas_are_invalid = true;
local baseName = this:GetName();
local up = getglobal(baseName.."Up");
local down = getglobal(baseName.."Down");
local size = table.getn(Dcr_Saved.SkipList);
if (size < 11 ) then
this.Offset = 0;
up:Hide();
down:Hide();
else
if (this.Offset <= 0) then
this.Offset = 0;
up:Hide();
down:Show();
elseif (this.Offset >= (size - 10)) then
this.Offset = (size - 10);
up:Show();
down:Hide();
else
up:Show();
down:Show();
end
end
local i;
for i = 1, 10 do
local id = ""..i;
if (i < 10) then
id = "0"..i;
end
local btn = getglobal(baseName.."Index"..id);
btn:SetID( i + this.Offset);
btn.UpdateYourself = true;
if (i <= size) then
btn:Show();
else
btn:Hide();
end
end
end
end --}}}
function Dcr_PopulateButtonPress() --{{{
local addFunction = this:GetParent().addFunction;
if (this.ClassType) then
-- for the class type stuff... we do party
local _, pclass = UnitClass("player");
if (pclass == this.ClassType) then
addFunction("player");
end
_, pclass = UnitClass("party1");
if (pclass == this.ClassType) then
addFunction("party1");
end
_, pclass = UnitClass("party2");
if (pclass == this.ClassType) then
addFunction("party2");
end
_, pclass = UnitClass("party3");
if (pclass == this.ClassType) then
addFunction("party3");
end
_, pclass = UnitClass("party4");
if (pclass == this.ClassType) then
addFunction("party4");
end
end
local max = GetNumRaidMembers();
local i;
if (max > 0) then
for i = 1, max do
local _, _, pgroup, _, _, pclass = GetRaidRosterInfo(i);
if (this.ClassType) then
if (pclass == this.ClassType) then
addFunction("raid"..i);
end
end
if (this.GroupNumber) then
if (pgroup == this.GroupNumber) then
addFunction("raid"..i);
end
end
end
end
end --}}}
-- }}}
function Dcr_PlaySound () --{{{
if (Dcr_Saved.PlaySound and not Dcr_SoundPlayed) then
-- good sounds: Sound\\Doodad\\BellTollTribal.wav
-- Sound\\interface\\AuctionWindowOpen.wav
PlaySoundFile("Sound\\Doodad\\BellTollTribal.wav");
Dcr_SoundPlayed = true;
end
end --}}}
-- LIVE DISPLAY functions {{{
function Dcr_AfflictedListFrame_OnUpdate(elapsed) --{{{
-- XXX find the use of this block
if Dcr_Saved.Amount_Of_Afflicted < 1 then
Dcr_Saved.Amount_Of_Afflicted = 1;
elseif Dcr_Saved.Amount_Of_Afflicted > DCR_MAX_LIVE_SLOTS then
Dcr_Saved.Amount_Of_Afflicted = DCR_MAX_LIVE_SLOTS;
end
Dcr_timeLeft = Dcr_timeLeft - elapsed;
if (Dcr_timeLeft <= 0) then
Dcr_timeLeft = Dcr_Saved.ScanTime;
local Dcr_Unit_Array = Dcr_Unit_Array;
local index = 1;
local targetexists = false;
Dcr_GetUnitArray();
-- First scan the current target
if (UnitExists("target") and UnitIsFriend("target", "player")) then
if (UnitIsVisible("target")) then
targetexists = true;
if (Dcr_ScanUnit("target", index)) then
if (index == 1) then
Dcr_PlaySound();
end
index = index + 1;
end
end
end
if (DCR_CAN_CURE_ENEMY_MAGIC) then
for _, unit in Dcr_Unit_Array do
if (index > Dcr_Saved.Amount_Of_Afflicted) then
break;
end
if (UnitIsVisible(unit) and not (targetexists and UnitIsUnit(unit, "target"))) then
-- if the unit is even close by
if (UnitIsCharmed(unit)) then
-- if the unit is mind controlled
if (Dcr_ScanUnit(unit, index)) then
if (index == 1) then
Dcr_PlaySound();
end
index = index + 1;
end
end
end
end
end
-- Dcr_debug(" normal loop");
for _, unit in Dcr_Unit_Array do
if (index > Dcr_Saved.Amount_Of_Afflicted) then
break;
end
if (UnitIsVisible(unit) and not (targetexists and UnitIsUnit(unit, "target"))) then
if (not UnitIsCharmed(unit)) then
-- if the unit is even close by
if (Dcr_ScanUnit(unit, index)) then
if (index == 1) then
Dcr_PlaySound();
end
index = index + 1;
end
end
end
end
-- clear livelist
local i;
for i = index, DCR_MAX_LIVE_SLOTS do
if i == 1 then
Dcr_SoundPlayed = false;
end
local Index = i;
if (Dcr_Saved.ReverseLiveDisplay and not (i > Dcr_Saved.Amount_Of_Afflicted)) then
Index = Dcr_Saved.Amount_Of_Afflicted + -1 * (Index - 1);
end
local item = getglobal("DecursiveAfflictedListFrameListItem"..Index);
item.unit = "player";
item.debuff = 0;
item:Hide();
end
-- for testing only
-- Dcr_UpdateLiveDisplay( 1, "player", 1)
end
end --}}}
function Dcr_ScanUnit( Unit, Index) --{{{
local AllUnitDebuffs = {};
AllUnitDebuffs = Dcr_GetUnitDebuffAll(Unit);
for debuff_name, debuff_params in AllUnitDebuffs do
-- test if we have to ignore this debuf {{{ --
if (DCR_IGNORELIST[debuff_name]) then
-- these are the BAD ones... the ones that make the target immune... abort the user
-- Dcr_debug( string.gsub( string.gsub(DCR_IGNORE_STRING, "$t", (UnitName(Unit))), "$a", debuff_name));