forked from sadsfae/CEPGP-Retail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtility.lua
3028 lines (2745 loc) · 91.5 KB
/
Utility.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
local L = CEPGP_Locale:GetLocale("CEPGP")
function CEPGP_initialise()
CEPGP.Log = {};
_, _, _, CEPGP_ElvUI = GetAddOnInfo("ElvUI");
if not CEPGP_ElvUI then CEPGP_ElvUI = GetAddOnInfo("TukUI"); end
_G["CEPGP_version_number"]:SetText("Running Version: " .. CEPGP_Info.Version .. " " .. CEPGP_Info.Build);
C_ChatInfo.RegisterAddonMessagePrefix("CEPGP");
if not CEPGP_notice then
CEPGP_notice = false;
end
if CHANNEL == nil then
CHANNEL = "Guild";
end
if CEPGP_lootChannel == nil then
CEPGP_lootChannel = "Raid";
end
if MOD == nil then
MOD = 1;
end
if COEF == nil then
COEF = 4.83;
end
if MOD_COEF == nil then
MOD_COEF = 2;
end
if BASEGP == nil then
BASEGP = 1;
end
if CEPGP_min_threshold == nil then
CEPGP_min_threshold = 2;
end
if CEPGP_keyword == nil then
CEPGP_keyword = "!need";
end
for k, v in pairs(CEPGP_EncounterInfo.Bosses) do
if not EPVALS[k] or not tonumber(EPVALS[k]) then -- An expected number is missing
if k == "The Silithid Royalty" then
EPVALS[k] = EPVALS["Silithid Royalty"] or CEPGP_EncounterInfo.Bosses["The Silithid Royalty"];
elseif k == "The Twin Emperors" then
EPVALS[k] = EPVALS["Twin Emperors"] or CEPGP_EncounterInfo.Bosses["The Twin Emperors"];
else
EPVALS[k] = v;
end
end
if AUTOEP[k] == nil then
AUTOEP[k] = true;
end
end
EPVALS["Teremus the Devourer"] = nil; -- Obsolete entries that need to be removed
AUTOEP["Teremus the Devourer"] = nil;
EPVALS["Emperor Vek'nilash"] = nil;
AUTOEP["Emperor Vek'nilash"] = nil;
EPVALS["Emperor Vek'lor"] = nil;
AUTOEP["Emperor Vek'lor"] = nil;
EPVALS["Vem"] = nil;
AUTOEP["Vem"] = nil;
EPVALS["Lord Kri"] = nil;
AUTOEP["Lord Kri"] = nil;
EPVALS["Princess Yauj"] = nil;
AUTOEP["Princess Yauj"] = nil;
EPVALS["Highlord Mograine"] = nil;
AUTOEP["Highlord Mograine"] = nil;
EPVALS["Thane Korth'azz"] = nil;
AUTOEP["Thane Korth'azz"] = nil;
EPVALS["Lady Blaumeux"] = nil;
AUTOEP["Lady Blaumeux"] = nil;
EPVALS["Sir Zeliek"] = nil;
AUTOEP["Sir Zeliek"] = nil;
EPVALS["Renataki"] = nil;
AUTOEP["Renataki"] = nil;
EPVALS["Wushoolay"] = nil;
AUTOEP["Wushoolay"] = nil;
EPVALS["Gri'lek"] = nil;
AUTOEP["Gri'lek"] = nil;
EPVALS["Hazza'rah"] = nil;
AUTOEP["Hazza'rah"] = nil;
EPVALS["Doom Lord Kazzak"] = nil;
AUTOEP["Doom Lord Kazzak"] = nil;
EPVALS["The Edge of Madness"] = nil;
AUTOEP["The Edge of Madness"] = nil;
local channels = {
[1] = "Party",
[2] = "Raid",
[3] = "Guild",
[4] = "Officer"
};
if not CEPGP_tContains(channels, CHANNEL) then
CHANNEL = channels[3];
--C_Timer.After(5, function()
CEPGP_print("Your reporting channel has changed, please make sure it is set to the correct setting!");
--end);
end
if not CEPGP_tContains(channels, CEPGP.LootChannel) then
CEPGP.LootChannel = channels[2];
--C_Timer.After(5, function()
CEPGP_print("Your loot reporting channel has changed, please make sure it is set to the correct setting!");
--end);
end
-- Localize boss names on the config UI
local bossNames = {};
table.insert(bossNames, _G["CEPGP_EP_options_mc"].bosses);
table.insert(bossNames, _G["CEPGP_EP_options_bwl"].bosses);
table.insert(bossNames, _G["CEPGP_EP_options_zg"].bosses);
table.insert(bossNames, _G["CEPGP_EP_options_aq20"].bosses);
table.insert(bossNames, _G["CEPGP_EP_options_aq40"].bosses);
table.insert(bossNames, _G["CEPGP_EP_options_naxx"].bosses);
table.insert(bossNames, _G["CEPGP_EP_options_worldboss"].bosses);
if CEPGP_ntgetn(SLOTWEIGHTS) == 0 then
SLOTWEIGHTS = {
["2HWEAPON"] = 2,
["WEAPONMAINHAND"] = 1.5,
["WEAPON"] = 1.5,
["WEAPONOFFHAND"] = 0.5,
["HOLDABLE"] = 0.5,
["SHIELD"] = 0.5,
["WAND"] = 0.5,
["RANGED"] = 2,
["THROWN"] = 0.5,
["RELIC"] = 0.5,
["HEAD"] = 1,
["NECK"] = 0.5,
["SHOULDER"] = 0.75,
["CLOAK"] = 0.5,
["CHEST"] = 1,
["ROBE"] = 1,
["WRIST"] = 0.5,
["HAND"] = 0.75,
["WAIST"] = 0.75,
["LEGS"] = 1,
["FEET"] = 0.75,
["FINGER"] = 0.5,
["TRINKET"] = 0.75,
["EXCEPTION"] = 1
}
end
SLOTWEIGHTS["WAND"] = SLOTWEIGHTS["WAND"] or 0.5;
SLOTWEIGHTS["RANGED"] = SLOTWEIGHTS["RANGEDRIGHT"] or SLOTWEIGHTS["RANGED"] or 2;
SLOTWEIGHTS["RANGEDRIGHT"] = nil;
if STANDBYPERCENT == nil then
STANDBYPERCENT = 0;
end
if CEPGP_ntgetn(STANDBYRANKS) == 0 then
for i = 1, 10 do
STANDBYRANKS[i] = {};
STANDBYRANKS[i][1] = GuildControlGetRankName(i);
STANDBYRANKS[i][2] = false;
end
end
if CEPGP_force_sync_rank == nil then
CEPGP_force_sync_rank = 1;
end
if #CEPGP_response_buttons < 6 then
CEPGP_response_buttons = {
[1] = {
true,
"Main Spec",
0,
"Need"
},
[2] = {
false,
"Off Spec",
0,
"Greed"
},
[3] = {
false,
"Disenchant",
0,
"Disenchant"
},
[4] = {
false,
"Minor Upgrade",
0,
"Minor"
},
[5] = {
false,
"",
100
},
[6] = {
false,
"Pass",
100
}
};
end
tinsert(UISpecialFrames, "CEPGP_frame");
tinsert(UISpecialFrames, "CEPGP_context_popup");
tinsert(UISpecialFrames, "CEPGP_save_guild_logs");
tinsert(UISpecialFrames, "CEPGP_restore_guild_logs");
tinsert(UISpecialFrames, "CEPGP_settings_import");
tinsert(UISpecialFrames, "CEPGP_override");
tinsert(UISpecialFrames, "CEPGP_traffic");
tinsert(UISpecialFrames, "CEPGP_changelog");
tinsert(UISpecialFrames, "CEPGP_license");
tinsert(UISpecialFrames, "CEPGP_raid_modifiers");
tinsert(UISpecialFrames, "CEPGP_log");
for i, t in ipairs(bossNames) do
for _, entity in pairs(t) do
local boss = entity:GetText();
if L[boss] then
entity:SetText(L[boss]);
end
end
end
local kids = {_G["CEPGP_frame"]:GetChildren()};
for _, child in ipairs(kids) do
local function setChildText(frame)
if frame.Text then
if frame:GetText() then
frame:SetText(L[frame:GetText()]);
end
end
for _, subChild in ipairs({frame:GetChildren()}) do
setChildText(subChild);
end
end
setChildText(child);
end
CEPGP_initSavedVars();
CEPGP_initInterfaceOptions();
hooksecurefunc("ChatFrame_OnHyperlinkShow", CEPGP_addGPHyperlink);
hooksecurefunc("GameTooltip_UpdateStyle", CEPGP_addGPTooltip);
if not CEPGP_notice then
CEPGP_notice_frame:Show();
end
if IsInRaid() and CEPGP_isML() == 0 then
_G["CEPGP_confirmation"]:Show();
end
C_Timer.After(5, function()
-- Reorganising the override index to the new format
for k, v in pairs(OVERRIDE_INDEX) do
if string.find(k, "item:") then
local args = CEPGP_split(k, ":");
if tonumber(args[10]) then
local id = CEPGP_getItemID(CEPGP_getItemString(k));
local link = CEPGP_getItemLink(id);
if link then
OVERRIDE_INDEX[link] = v;
OVERRIDE_INDEX[k] = nil;
end
end
end
end
C_Timer.After(3, function()
if IsInGuild() then
CEPGP_SendAddonMsg("version-check", "GUILD");
for i = 1, GetNumGuildMembers() do
local _, _, rankIndex = GetGuildRosterInfo(i);
if CEPGP.Exclusions[rankIndex+1] then
CEPGP_Info.NumExcluded = CEPGP_Info.NumExcluded + 1;
end
end
CEPGP_Info.Initialised = true;
CEPGP_rosterUpdate("GUILD_ROSTER_UPDATE");
end
if UnitInRaid("player") then
CEPGP_rosterUpdate("GROUP_ROSTER_UPDATE");
end
end);
DEFAULT_CHAT_FRAME:AddMessage("|c00FFC100Classic EPGP Version: " .. CEPGP_Info.Version .. " " .. CEPGP_Info.Build .. " Loaded|r");
if CEPGP.ChangelogVersion ~= CEPGP_Info.Version then
CEPGP_print("A new version has been installed. The changelog can be viewed in CEPGP options or type /cep changelog.");
CEPGP.ChangelogVersion = CEPGP_Info.Version;
end
end);
end
function CEPGP_initSavedVars()
--[[ Structure Conversions ]]--
if type(CEPGP_raid_wide_dist) == "boolean" then
CEPGP_raid_wide_dist = {[1] = true, [2] = CEPGP_raid_wide_dist};
end
--[[ General Vars ]]--
CEPGP.Channel = CEPGP.Channel or CHANNEL or "Guild";
CEPGP.Exclusions = CEPGP.Exclusions or {false,false,false,false,false,false,false,false,false,false};
CEPGP.Notice = CEPGP.Notice or CEPGP_notice;
CEPGP.PollRate = CEPGP.PollRate or 0.0001;
CEPGP.Sync = CEPGP.Sync or {ALLOW_FORCED_SYNC, CEPGP_force_sync_rank} or {false, 1};
CEPGP.Decay = CEPGP.Decay or {Separate = false};
--CEPGP.Log = {};
--[[ Guild Frame ]]--
CEPGP.Attendance = CEPGP.Attendance or CEPGP_raid_logs or {};
CEPGP.Backups = CEPGP.Backups or RECORDS or {};
CEPGP.Traffic = CEPGP.Traffic or TRAFFIC or {};
--[[ EP States ]]--
CEPGP.EP = CEPGP.EP or {};
CEPGP.EP.BossEP = CEPGP.EP.BossEP or {};
CEPGP.EP.AutoAward = CEPGP.EP.AutoAward or {};
for bossName, EP in pairs(CEPGP_EncounterInfo.Bosses) do
CEPGP.EP.BossEP[bossName] = CEPGP.EP.BossEP[bossName] or EPVALS[bossName] or EP;
end
CEPGP.EP.BossEP["Edge of Madness"] = CEPGP.EP.BossEP["Edge of Madness"] or CEPGP.EP.BossEP["The Edge of Madness"] or CEPGP.EP.BossEP["Renataki"] or CEPGP_EncounterInfo.Bosses["Edge of Madness"];
CEPGP.EP.BossEP["Lord Kazzak"] = CEPGP.EP.BossEP["Doom Lord Kazzak"] or CEPGP.EP.BossEP["Lord Kazzak"] or CEPGP_EncounterInfo.Bosses["Lord Kazzak"];
CEPGP.EP.BossEP["The Twin Emperors"] = CEPGP.EP.BossEP["The Twin Emperors"] or CEPGP.EP.BossEP["Twin Emperors"] or CEPGP_EncounterInfo.Bosses["The Twin Emperors"];
CEPGP.EP.BossEP["The Silithid Royalty"] = CEPGP.EP.BossEP["The Silithid Royalty"] or CEPGP.EP.BossEP["Silithid Royalty"] or CEPGP_EncounterInfo.Bosses["The Silithid Royalty"];
CEPGP.EP.BossEP["Renataki"] = nil;
CEPGP.EP.BossEP["Wushoolay"] = nil;
CEPGP.EP.BossEP["Gri'lek"] = nil;
CEPGP.EP.BossEP["Hazza'rah"] = nil;
CEPGP.EP.BossEP["Doom Lord Kazzak"] = nil;
CEPGP.EP.BossEP["The Edge of Madness"] = nil;
CEPGP.EP.AutoAward["Renataki"] = nil;
CEPGP.EP.AutoAward["Wushoolay"] = nil;
CEPGP.EP.AutoAward["Gri'lek"] = nil;
CEPGP.EP.AutoAward["Hazza'rah"] = nil;
CEPGP.EP.AutoAward["Doom Lord Kazzak"] = nil;
CEPGP.EP.AutoAward["The Edge of Madness"] = nil;
CEPGP.EP.BossEP["Silithid Royalty"] = nil;
CEPGP.EP.BossEP["Twin Emperors"] = nil;
CEPGP.EP.AutoAward["Silithid Royalty"] = nil;
CEPGP.EP.AutoAward["Twin Emperors"] = nil;
CEPGP.EP.BossEP["Highlord Mograine"] = nil;
CEPGP.EP.BossEP["Thane Korth'azz"] = nil;
CEPGP.EP.BossEP["Lady Blaumeux"] = nil;
CEPGP.EP.BossEP["Sir Zeliek"] = nil;
CEPGP.EP.AutoAward["Highlord Mograine"] = nil;
CEPGP.EP.AutoAward["Thane Korth'azz"] = nil;
CEPGP.EP.AutoAward["Lady Blaumeux"] = nil;
CEPGP.EP.AutoAward["Sir Zeliek"] = nil;
--[[ GP States ]]--
local slotDefaults = {
["2HWEAPON"] = 2,
["WEAPONMAINHAND"] = 1.5,
["WEAPON"] = 1.5,
["WEAPONOFFHAND"] = 0.5,
["HOLDABLE"] = 0.5,
["SHIELD"] = 0.5,
["WAND"] = 0.5,
["RANGED"] = 2,
["RELIC"] = 0.5,
["HEAD"] = 1,
["NECK"] = 0.5,
["SHOULDER"] = 0.75,
["CLOAK"] = 0.5,
["CHEST"] = 1,
["ROBE"] = 1,
["WRIST"] = 0.5,
["HAND"] = 0.75,
["WAIST"] = 0.75,
["LEGS"] = 1,
["FEET"] = 0.75,
["FINGER"] = 0.5,
["TRINKET"] = 0.75,
["EXCEPTION"] = 1
};
CEPGP.GP = CEPGP.GP or {};
CEPGP.GP.Base = CEPGP.GP.Base or COEF or 4.83;
CEPGP.GP.Min = CEPGP.GP.Min or BASEGP or 1;
CEPGP.GP.Mod = CEPGP.GP.Mod or MOD or 1;
CEPGP.GP.Multiplier = CEPGP.GP.Multiplier or MOD_COEF or 2;
CEPGP.GP.SlotWeights = CEPGP.GP.SlotWeights or SLOTWEIGHTS or {};
for slot, weight in pairs(slotDefaults) do
CEPGP.GP.SlotWeights[slot] = CEPGP.GP.SlotWeights[slot] or SLOTWEIGHTS[slot] or slotDefaults[slot];
end
CEPGP.GP.SlotWeights["RANGEDRIGHT"] = nil;
CEPGP.Overrides = OVERRIDE_INDEX or CEPGP.Overrides or {};
CEPGP.GP.RaidModifiers = CEPGP.GP.RaidModifiers or {};
local RaidModifiers = {
["Molten Core"] = 100,
["Onyxia's Lair"] = 100,
["Blackwing Lair"] = 100,
["Zul'Gurub"] = 100,
["The Ruins of Ahn'Qiraj"] = 100,
["The Temple of Ahn'Qiraj"] = 100,
["Naxxramas"] = 100
};
for raid, val in pairs(RaidModifiers) do
CEPGP.GP.RaidModifiers[raid] = CEPGP.GP.RaidModifiers[raid] or val;
end
--[[ Loot Management ]]--
CEPGP.LootChannel = CEPGP.LootChannel or CEPGP_lootChannel or "Raid";
CEPGP.Loot = CEPGP.Loot or {};
CEPGP.Loot.Announcement = CEPGP.Loot.Announcement or "Whisper me for loot";
CEPGP.Loot.Keyword = CEPGP.Loot.Keyword or CEPGP_keyword;
CEPGP.Loot.MinThreshold = CEPGP.Loot.MinThreshold or CEPGP_min_threshold or 2;
-- Temporary measure to resolve a structural problem
CEPGP.Loot.MinThreshold = type(CEPGP_min_threshold) == "number" and CEPGP_min_threshold or 2;
CEPGP.Loot.MinReq = CEPGP.Loot.MinReq or CEPGP_minEP or {false, 0};
CEPGP.Loot.RaidVisibility = (type(CEPGP.Loot.RaidVisibility) == "boolean" and {[1] = true, [2] = CEPGP_raid_wide_dist[2]}) or CEPGP.Loot.RaidVisibility or CEPGP_raid_wide_dist or {[1] = false, [2] = false};
CEPGP.Loot.GUI = CEPGP.Loot.GUI or {};
CEPGP.Loot.GUI.Buttons = CEPGP.Loot.GUI.Buttons or {};
CEPGP.Loot.GUI.Buttons[1] = CEPGP.Loot.GUI.Buttons[1] or {};
CEPGP.Loot.GUI.Buttons[1][1] = true;
CEPGP.Loot.GUI.Buttons[1][2] = CEPGP.Loot.GUI.Buttons[1][2] or CEPGP_response_buttons[1][2] or "Main Spec";
CEPGP.Loot.GUI.Buttons[1][3] = CEPGP.Loot.GUI.Buttons[1][3] or CEPGP_response_buttons[1][3] or 0;
CEPGP.Loot.GUI.Buttons[1][4] = CEPGP.Loot.GUI.Buttons[1][4] or CEPGP_response_buttons[1][4] or "Need";
CEPGP.Loot.GUI.Buttons[2] = CEPGP.Loot.GUI.Buttons[2] or {};
CEPGP.Loot.GUI.Buttons[2][2] = CEPGP.Loot.GUI.Buttons[2][2] or CEPGP_response_buttons[2][2] or "Off Spec";
CEPGP.Loot.GUI.Buttons[2][3] = CEPGP.Loot.GUI.Buttons[2][3] or CEPGP_response_buttons[2][3] or 0;
CEPGP.Loot.GUI.Buttons[2][4] = CEPGP.Loot.GUI.Buttons[2][4] or CEPGP_response_buttons[2][4] or "Greed";
CEPGP.Loot.GUI.Buttons[3] = CEPGP.Loot.GUI.Buttons[3] or {};
CEPGP.Loot.GUI.Buttons[3][2] = CEPGP.Loot.GUI.Buttons[3][2] or CEPGP_response_buttons[3][2] or "Disenchant";
CEPGP.Loot.GUI.Buttons[3][3] = CEPGP.Loot.GUI.Buttons[3][3] or CEPGP_response_buttons[3][3] or 0;
CEPGP.Loot.GUI.Buttons[3][4] = CEPGP.Loot.GUI.Buttons[3][4] or CEPGP_response_buttons[3][4] or "Disenchant";
CEPGP.Loot.GUI.Buttons[4] = CEPGP.Loot.GUI.Buttons[4] or {};
CEPGP.Loot.GUI.Buttons[4][2] = CEPGP.Loot.GUI.Buttons[4][2] or CEPGP_response_buttons[4][2] or "Minor Upgrade";
CEPGP.Loot.GUI.Buttons[4][3] = CEPGP.Loot.GUI.Buttons[4][3] or CEPGP_response_buttons[4][3] or 0;
CEPGP.Loot.GUI.Buttons[4][4] = CEPGP.Loot.GUI.Buttons[4][4] or CEPGP_response_buttons[4][4] or "Minor";
CEPGP.Loot.GUI.Buttons[5] = CEPGP.Loot.GUI.Buttons[5] or CEPGP_response_buttons[5];
CEPGP.Loot.GUI.Buttons[6] = CEPGP.Loot.GUI.Buttons[6] or CEPGP_response_buttons[6];
-- Temporary measure to resolve a synchronisation issue
for index, data in ipairs(CEPGP_response_buttons) do
CEPGP.Loot.GUI.Buttons[index][1] = data[1];
CEPGP.Loot.GUI.Buttons[index][2] = data[2];
CEPGP.Loot.GUI.Buttons[index][3] = data[3];
CEPGP.Loot.GUI.Buttons[index][4] = data[4];
end
CEPGP.Loot.GUI.Timer = CEPGP.Loot.GUI.Timer or CEPGP_response_time or 0;
CEPGP.Loot.ExtraKeywords = CEPGP.Loot.ExtraKeywords or {};
CEPGP.Loot.ExtraKeywords.Keywords = CEPGP.Loot.ExtraKeywords.Keywords or {};
--[[ Alt Management ]]--
CEPGP.Alt = CEPGP.Alt or {
SyncEP = true,
SyncGP = true
};
CEPGP.Alt.Links = CEPGP.Alt.Links or {};
--[[ Standby Settings ]]--
CEPGP.Standby = CEPGP.Standby or {};
CEPGP.Standby.Keyword = CEPGP.Standby.Keyword or CEPGP_standby_whisper_msg or "!standby";
CEPGP.Standby.Percent = CEPGP.Standby.Percent or STANDBYPERCENT or 100;
CEPGP.Standby.Ranks = CEPGP.Standby.Ranks or STANDBYRANKS or {};
CEPGP.Standby.Roster = CEPGP.Standby.Roster or CEPGP_standbyRoster or {};
if not CEPGP.Standby.ByRank and not CEPGP.Standby.Manual then
CEPGP.Standby.ByRank = true;
end
end
function CEPGP_initInterfaceOptions()
local panel = {};
panel.main = _G["CEPGP_interface_options"];
panel.main.name = "Classic EPGP";
panel.alt = _G["CEPGP_options_alt_mangement"];
panel.alt.name = "Alt Management";
panel.alt.parent = panel.main.name;
panel.ep = _G["CEPGP_EP_options"];
panel.ep.name = "EP Management";
panel.ep.parent = panel.main.name;
panel.gp = _G["CEPGP_GP_options"];
panel.gp.name = "GP Management";
panel.gp.parent = panel.main.name;
panel.loot = _G["CEPGP_loot_options"];
panel.loot.name = "Loot Distribution";
panel.loot.parent = panel.main.name;
panel.plugins = _G["CEPGP_options_plugins"];
panel.plugins.name = "Plugin Manager";
panel.plugins.parent = panel.main.name;
panel.standby = _G["CEPGP_standby_options"];
panel.standby.name = "Standby EP";
panel.standby.parent = panel.main.name;
InterfaceOptions_AddCategory(panel.main);
InterfaceOptions_AddCategory(panel.alt);
InterfaceOptions_AddCategory(panel.ep);
InterfaceOptions_AddCategory(panel.gp);
InterfaceOptions_AddCategory(panel.loot);
InterfaceOptions_AddCategory(panel.plugins);
InterfaceOptions_AddCategory(panel.standby);
_G["CEPGP_interface_options_version"]:SetText("Classic EPGP Version " .. CEPGP_Info.Version .. " " .. CEPGP_Info.Build);
local varMap = {
["Alt"] = "Alt Management",
["Channel"] = "EPGP Modification Reporting Channel",
["Decay"] = "Decay Configuration",
["EP"] = "EP Management",
["GP"] = "GP Management",
["Loot"] = "Loot Management",
["LootChannel"] = "Loot Response Reporting Channel",
["Overrides"] = "GP Overrides",
["Standby"] = "Standby Configuration"
}
local importFrame = CEPGP_settings_import_sf_container;
local temp = {};
for base, _ in pairs(varMap) do
table.insert(temp, base);
end
table.sort(temp);
for i = 1, #temp do
local frame;
local base = varMap[temp[i]];
if not _G["ImportCheckButton_" .. i] then
frame = CreateFrame('CheckButton', "ImportCheckButton_" .. i, CEPGP_settings_import_sf_container, "ImportOptionCheckTemplate");
if i == 1 then
frame:SetPoint("TOPLEFT", CEPGP_settings_import_sf_container, "TOPLEFT", 5, -10);
else
frame:SetPoint("TOPLEFT", _G["ImportCheckButton_" .. i-1], "BOTTOMLEFT", 0, -2);
end
end
frame:SetAttribute("varName", temp[i]); -- Couldn't think of a better generic name to reflect the name of a saved variable
frame:Show();
_G[frame:GetName() .. "_text"]:SetText(base);
end
end
function CEPGP_initDropdown(frame, initFunction, displayMode, level, menuList)
frame.menuList = menuList;
--securecall("UIDropDownMenu_InitializeHelper", frame);
-- Set the initialize function and call it. The initFunction populates the dropdown list.
if ( initFunction ) then
UIDropDownMenu_SetInitializeFunction(frame, initFunction);
--initFunction(frame, level, frame.menuList);
end
--master frame
if(level == nil) then
level = 1;
end
local dropDownList = _G["DropDownList"..level];
dropDownList.dropdown = frame;
dropDownList.shouldRefresh = true;
UIDropDownMenu_SetDisplayMode(frame, displayMode);
end
function CEPGP_ContainsIllegalChar(str)
return string.find(str, '[^a-zA-ZÀÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ]');
end
function CEPGP_addResponse(player, response, roll)
if response and not tonumber(response) then
response = CEPGP_getResponseIndex(response);
end
CEPGP_itemsTable[player] = {};
CEPGP_itemsTable[player][3] = response;
if CEPGP_indexToLabel(response) or CEPGP_getResponse(response) or CEPGP_getResponseIndex(response) or (CEPGP.Loot.PassRolls and response == 6) or response < 6 then
CEPGP_itemsTable[player][4] = roll;
end
local message = "!need;"..player..";"..CEPGP_DistID..";"..response..";"..roll;
-- Shares the loot distribution results with the raid / assists
if CEPGP.Loot.RaidVisibility[2] and not CEPGP.Loot.DelayResponses then
CEPGP_SendAddonMsg(message, "RAID");
elseif CEPGP.Loot.RaidVisibility[1] and not CEPGP.Loot.DelayResponses then
CEPGP_messageGroup(message, "assists");
if player == UnitName("player") then
CEPGP_respond:Hide();
end
end
if ((CEPGP_ntgetn(CEPGP_itemsTable) == CEPGP_GetNumOnlineGroupMembers()) or (CEPGP_Info.LootRespondants == CEPGP_GetNumOnlineGroupMembers())) and CEPGP.Loot.DelayResponses then
CEPGP_announceResponses();
end
end
function CEPGP_GetNumOnlineGroupMembers()
local count = 0;
local limit = GetNumGroupMembers();
for i = 1, limit do
local online = select(8, GetRaidRosterInfo(i));
if online then count = count + 1; end
end
return count;
end
function CEPGP_announceResponses()
local responses = {};
for _, label in ipairs(CEPGP_Info.LootSchema) do
responses[label] = {};
end
for name, v in pairs(CEPGP_itemsTable) do
local label = CEPGP_Info.LootSchema[v[3]];
table.insert(responses[label], name);
end
for label, _ in pairs(responses) do
responses[label] = CEPGP_tSort(responses[label], nil, false);
end
for _, label in ipairs(CEPGP_Info.LootSchema) do
local msg = label .. ": ";
for index, name in ipairs(responses[label]) do
local EP, GP, PR, roll;
if CEPGP_itemsTable[name][3] ~= 5 and CEPGP_itemsTable[name][3] ~= 6 then -- Ensures that misc responses and passes are not announced
if CEPGP.Loot.DelayResponses and CEPGP.Loot.PRWithDelay then
EP, GP = CEPGP_getEPGP(name);
PR = math.floor((tonumber(EP)*100/tonumber(GP)))/100;
end
if CEPGP.Loot.DelayResponses and CEPGP.Loot.RollWithDelay then
roll = CEPGP_itemsTable[name][4];
end
if #(msg .. name .. (PR and " (PR " .. PR .. ")" or "") .. (roll and " (Roll " .. roll .. ")" or "")) > 249 then
SendChatMessage(msg, "RAID", CEPGP_LANGUAGE);
msg = label .. " (Continued): " .. name .. (PR and " (PR " .. PR .. ")" or "") .. (roll and " (Roll " .. roll .. ")" or "");
else
msg = msg .. name .. (PR and " (PR " .. PR .. ")" or "") .. (roll and " (Roll " .. roll .. ")" or "") .. ((index < #responses[label]) and ", " or "");
end
local message = "!need;"..name..";"..CEPGP_DistID..";"..CEPGP_itemsTable[name][3]..";"..CEPGP_itemsTable[name][4];
if CEPGP.Loot.RaidVisibility[2] and CEPGP.Loot.DelayResponses then
CEPGP_SendAddonMsg(message, "RAID");
elseif CEPGP.Loot.RaidVisibility[1] and CEPGP.Loot.DelayResponses then
CEPGP_messageGroup(message, "assists");
end
end
end
if label ~= "" and label ~= "Pass" and msg ~= label .. ": " then
SendChatMessage(msg, "RAID", CEPGP_LANGUAGE);
end
end
end
function CEPGP_getDiscount(label)
for l, v in pairs(CEPGP.Loot.ExtraKeywords.Keywords) do
for _, discount in pairs(v) do
if l == label then
return tonumber(discount);
end
end
end
end
function CEPGP_indexToLabel(index)
return CEPGP_Info.LootSchema[index];
end
function CEPGP_getResponse(keyword)
if not keyword then return end
for index, v in ipairs(CEPGP.Loot.GUI.Buttons) do
if keyword == index then
return v[2];
end
end
for label, v in pairs(CEPGP.Loot.ExtraKeywords.Keywords) do
for key, _ in pairs(v) do
if string.lower(keyword) == string.lower(key) then
return label;
end
end
end
end
function CEPGP_getResponseIndex(keyword)
if not keyword then return; end
for index, v in ipairs(CEPGP.Loot.GUI.Buttons) do
if string.lower(keyword) == string.lower(v[4]) then
return index;
end
end
end
function CEPGP_getLabelIndex(_label)
for index, v in ipairs(CEPGP.Loot.GUI.Buttons) do
if _label == v[2] then
return index;
end
end
for index, label in ipairs(CEPGP_Info.LootSchema) do
if _label == label then
return index;
end
end
end
function CEPGP_calcGP(link, quantity, id)
local name, rarity, ilvl, itemType, subType, slot, classID, subClassID;
if id then
name, link, rarity, ilvl, itemType, subType, _, _, slot, _, _, classID, subClassID = GetItemInfo(id);
elseif link then
name, _, rarity, ilvl, itemType, subType, _, _, slot, _, _, classID, subClassID = GetItemInfo(link);
else
return 0;
end
if not name and CEPGP_itemExists(tonumber(id)) then
local item = Item:CreateFromItemID(tonumber(id));
item:ContinueOnItemLoad(function()
name, link, rarity, ilvl, itemType, subType, _, _, slot, _, _, classID, subClassID = GetItemInfo(id);
if OVERRIDE_INDEX[name] then return OVERRIDE_INDEX[name]; end
if OVERRIDE_INDEX[CEPGP_getItemLink(id)] then return OVERRIDE_INDEX[CEPGP_getItemLink(id)]; end
for _, k in pairs(CEPGP_tokens) do
for slotName, v in pairs(k) do
if k[slotName][tonumber(id)] then
slot = "INVTYPE_" .. string.upper(slotName);
ilvl = k[slotName][tonumber(id)];
break;
end
end
end
if slot == "" or slot == nil then
slot = "INVTYPE_EXCEPTION";
end
if slot == "INVTYPE_ROBE" then slot = "INVTYPE_CHEST"; end
if classID == 2 and subClassID == 19 then slot = "INVTYPE_WAND" end;
if classID == 2 and (subClassID == 2 or subClassID == 3 or subClassID == 18) then slot = "INVTYPE_RANGED" end;
if CEPGP_Info.Debug then
local quality = rarity == 0 and "Poor" or rarity == 1 and "Common" or rarity == 2 and "Uncommon" or rarity == 3 and "Rare" or rarity == 4 and "Epic" or "Legendary";
CEPGP_print("Name: " .. name);
CEPGP_print("Rarity: " .. quality);
CEPGP_print("Item Level: " .. ilvl);
CEPGP_print("Class ID: " .. classID);
CEPGP_print("Subclass ID: " .. subClassID);
CEPGP_print(GetItemSubClassInfo(classID, subClassID), false);
CEPGP_print("Item Type: " .. itemType);
CEPGP_print("Subtype: " .. subType);
CEPGP_print("Slot: " .. slot);
end
slot = strsub(slot,strfind(slot,"INVTYPE_")+8,string.len(slot));
slot = CEPGP.GP.SlotWeights[slot];
if ilvl and rarity and slot then
return math.floor((((CEPGP.GP.Base * (CEPGP.GP.Multiplier^((ilvl/26) + (rarity-4))) * slot)*CEPGP.GP.Mod)*quantity)*raidScaling);
else
return 0;
end
end);
else
if not ilvl then ilvl = 0; end
if OVERRIDE_INDEX[name] then return OVERRIDE_INDEX[name]; end
if OVERRIDE_INDEX[CEPGP_getItemLink(id)] then return OVERRIDE_INDEX[CEPGP_getItemLink(id)]; end
--local compare = "item[%-?" .. id .. ":]+";
--return OVERRIDE_INDEX[compare];
--for k, v in pairs(OVERRIDE_INDEX) do
--[[local compName = GetItemInfo(k);
if compName == name then
return v;
end]]
--end
for _, k in pairs(CEPGP_tokens) do
for slotName, v in pairs(k) do
if k[slotName][tonumber(id)] then
slot = "INVTYPE_" .. string.upper(slotName);
ilvl = k[slotName][tonumber(id)];
break;
end
end
end
if slot == "" or slot == nil then
slot = "INVTYPE_EXCEPTION";
end
if slot == "INVTYPE_ROBE" then slot = "INVTYPE_CHEST"; end
if classID == 2 and subClassID == 19 then slot = "INVTYPE_WAND" end;
if classID == 2 and (subClassID == 2 or subClassID == 3 or subClassID == 18) then slot = "INVTYPE_RANGED" end;
if CEPGP_Info.Debug then
local quality = rarity == 0 and "Poor" or rarity == 1 and "Common" or rarity == 2 and "Uncommon" or rarity == 3 and "Rare" or rarity == 4 and "Epic" or "Legendary";
CEPGP_print("Name: " .. name);
CEPGP_print("Rarity: " .. quality);
CEPGP_print("Item Level: " .. ilvl);
CEPGP_print("Class ID: " .. classID);
CEPGP_print("Subclass ID: " .. subClassID);
CEPGP_print(GetItemSubClassInfo(classID, subClassID), false);
CEPGP_print("Item Type: " .. itemType);
CEPGP_print("Subtype: " .. subType);
CEPGP_print("Slot: " .. slot);
end
slot = strsub(slot,strfind(slot,"INVTYPE_")+8,string.len(slot));
slot = CEPGP.GP.SlotWeights[slot];
local raidScaling = 1;
for raid, data in pairs(CEPGP_ItemDomain) do
for _, _id in pairs(data) do
if tonumber(id) == _id then
raidScaling = CEPGP.GP.RaidModifiers[raid]/100;
break;
end
end
end
if ilvl and rarity and slot then
return math.floor((((CEPGP.GP.Base * (CEPGP.GP.Multiplier^((ilvl/26) + (rarity-4))) * slot)*CEPGP.GP.Mod)*quantity)*raidScaling);
else
return 0;
end
end
end
function CEPGP_addGPTooltip(frame)
if not CEPGP_gp_tooltips or not frame:GetItem() or frame:GetItem() == nil or frame:GetItem() == "" then return; end
local _, link = frame:GetItem();
local id = CEPGP_getItemID(CEPGP_getItemString(link));
if not CEPGP_itemExists(tonumber(id)) then return; end
local name = GetItemInfo(id);
if not name and CEPGP_itemExists(tonumber(id)) then
local item = Item:CreateFromItemID(tonumber(id));
item:ContinueOnItemLoad(function()
local gp = CEPGP_calcGP(_, 1, id);
frame:AddLine("GP Value: " .. gp, {1,1,1});
end);
else
local gp = CEPGP_calcGP(_, 1, id);
frame:AddLine("GP Value: " .. gp, {1,1,1});
end
end
function CEPGP_addGPHyperlink(self, iString)
if not string.find(iString, "item:") or not CEPGP_gp_tooltips then return; end
local id = CEPGP_getItemID(iString);
local name = GetItemInfo(id);
for i = 1, ItemRefTooltip:NumLines() do
if string.find(_G["ItemRefTooltipTextLeft"..i]:GetText(), "GP Value:") then return end;
end
if not name and CEPGP_itemExists(tonumber(id)) then
local item = Item:CreateFromItemID(tonumber(id));
item:ContinueOnItemLoad(function()
local gp = CEPGP_calcGP(_, 1, id);
ItemRefTooltip:AddLine("GP Value: " .. gp, {1,1,1});
ItemRefTooltip:Show();
end);
else
local gp = CEPGP_calcGP(_, 1, id);
ItemRefTooltip:AddLine("GP Value: " .. gp, {1,1,1});
ItemRefTooltip:Show();
end
end
function CEPGP_populateFrame(items)
local subframe = nil;
if CEPGP_mode == "loot" then
CEPGP_cleanTable();
elseif CEPGP_mode ~= "loot" then
CEPGP_cleanTable();
end
local tempItems = {};
local total;
if CEPGP_mode == "guild" and _G["CEPGP_guild"]:IsVisible() then
CEPGP_UpdateGuildScrollBar();
elseif CEPGP_mode == "raid" and _G["CEPGP_raid"]:IsVisible() then
CEPGP_UpdateRaidScrollBar();
elseif CEPGP_mode == "loot" then
subframe = CEPGP_loot;
local count = 0;
if not items then
total = 0;
else
local i = 1;
for _,value in pairs(items) do
tempItems[i] = value;
i = i + 1;
count = count + 1;
end
i = nil;
end
total = count;
end
if CEPGP_mode == "loot" then
for i = 1, total do
local texture, name, quality, gp, colour, iString, link, slot, x, quantity;
x = i;
texture = tempItems[i][1];
name = tempItems[i][2];
colour = ITEM_QUALITY_COLORS[tempItems[i][3]];
link = tempItems[i][4];
iString = tempItems[i][5];
slot = tempItems[i][6];
quantity = tempItems[i][7];
gp = CEPGP_calcGP(link, quantity, CEPGP_getItemID(iString));
if _G[CEPGP_mode..'item'..i] ~= nil then
_G[CEPGP_mode..'announce'..i]:Show();
_G[CEPGP_mode..'announce'..i]:SetWidth(20);
_G[CEPGP_mode..'announce'..i]:SetScript('OnClick', function()
if CEPGP_ntgetn(CEPGP_roster) < (GetNumGuildMembers() - CEPGP_Info.NumExcluded) and CEPGP_Info.Polling then
local callback = function() CEPGP_announce(link, x, slot, quantity) end;
CEPGP_Info.QueuedAnnouncement = callback;
CEPGP_print(L["This item will be announced in a moment. Please wait and keep the loot window open"]);
else
CEPGP_announce(link, x, slot, quantity);
CEPGP_distribute:SetID(_G[CEPGP_mode..'announce'..i]:GetID());
end
end);
_G[CEPGP_mode..'announce'..i]:SetID(slot);
_G[CEPGP_mode..'icon'..i]:Show();
_G[CEPGP_mode..'icon'..i]:SetScript('OnEnter', function() GameTooltip:SetOwner(_G[CEPGP_mode..'icon'..i], "ANCHOR_BOTTOMLEFT") GameTooltip:SetHyperlink(iString) GameTooltip:Show() end);
_G[CEPGP_mode..'icon'..i]:SetScript('OnLeave', function() GameTooltip:Hide() end);
_G[CEPGP_mode..'texture'..i]:Show();
_G[CEPGP_mode..'texture'..i]:SetTexture(texture);
_G[CEPGP_mode..'item'..i]:Show();
_G[CEPGP_mode..'item'..i].text:SetText(link);
_G[CEPGP_mode..'item'..i].text:SetTextColor(colour.r, colour.g, colour.b);
_G[CEPGP_mode..'item'..i].text:SetPoint('CENTER',_G[CEPGP_mode..'item'..i]);
_G[CEPGP_mode..'item'..i]:SetWidth(_G[CEPGP_mode..'item'..i].text:GetStringWidth());
_G[CEPGP_mode..'item'..i]:SetScript('OnClick', function() SetItemRef(link, iString) end);
_G[CEPGP_mode..'itemGP'..i]:SetText(gp);
_G[CEPGP_mode..'itemGP'..i]:SetTextColor(colour.r, colour.g, colour.b);
_G[CEPGP_mode..'itemGP'..i]:SetWidth(35);
_G[CEPGP_mode..'itemGP'..i]:SetScript('OnEnterPressed', function() _G[CEPGP_mode..'itemGP'..i]:ClearFocus() end);
_G[CEPGP_mode..'itemGP'..i]:SetAutoFocus(false);
_G[CEPGP_mode..'itemGP'..i]:Show();
else
subframe.announce = CreateFrame('Button', CEPGP_mode..'announce'..i, subframe, 'UIPanelButtonTemplate');
subframe.announce:SetHeight(20);
subframe.announce:SetWidth(20);
subframe.announce:SetScript('OnClick', function()
if CEPGP_ntgetn(CEPGP_roster) < (GetNumGuildMembers() - CEPGP_Info.NumExcluded) and CEPGP_Info.Polling then
local callback = function() CEPGP_announce(link, x, slot, quantity) end;
CEPGP_Info.QueuedAnnouncement = callback;
CEPGP_print(L["This item will be announced in a moment. Please wait and keep the loot window open"]);
else
CEPGP_announce(link, x, slot, quantity);
CEPGP_distribute:SetID(_G[CEPGP_mode..'announce'..i]:GetID());
end
end);
subframe.announce:SetID(slot);
subframe.icon = CreateFrame('Button', CEPGP_mode..'icon'..i, subframe);
subframe.icon:SetHeight(20);
subframe.icon:SetWidth(20);
subframe.icon:SetScript('OnEnter', function() GameTooltip:SetOwner(_G[CEPGP_mode..'icon'..i], "ANCHOR_BOTTOMLEFT") GameTooltip:SetHyperlink(link) GameTooltip:Show() end);
subframe.icon:SetScript('OnLeave', function() GameTooltip:Hide() end);