forked from sadsfae/CEPGP-Retail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCore.lua
1289 lines (1188 loc) · 41.1 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
--[[ Globals ]]--
CEPGP_VERSION = "1.12.25.Release"
SLASH_CEPGP1 = "/CEPGP";
SLASH_CEPGP2 = "/cep";
CEPGP_VERSION_NOTIFIED = false;
CEPGP_mode = "guild";
CEPGP_recordholder = "";
CEPGP_distPlayer = "";
CEPGP_distGP = false;
CEPGP_lootSlot = nil;
CEPGP_target = nil;
CEPGP_DistID = nil;
CEPGP_distSlot = nil;
CEPGP_distItemLink = nil;
CEPGP_critReverse = false; --Criteria reverse
CEPGP_distributing = false;
CEPGP_overwritelog = false;
CEPGP_override_confirm = false;
CEPGP_confirmrestore = false;
CEPGP_looting = false;
CEPGP_traffic_clear = false;
CEPGP_criteria = 4;
CEPGP_frames = {CEPGP_guild, CEPGP_raid, CEPGP_loot, CEPGP_distribute, CEPGP_context_popup};
CEPGP_boss_config_frames = {CEPGP_EP_options_mc, CEPGP_EP_options_bwl, CEPGP_EP_options_zg, CEPGP_EP_options_aq20, CEPGP_EP_options_aq40, CEPGP_EP_options_naxx, CEPGP_EP_options_worldboss};
CEPGP_LANGUAGE = GetDefaultLanguage("player");
CEPGP_responses = {};
CEPGP_itemsTable = {};
CEPGP_roster = {};
CEPGP_raidRoster = {};
CEPGP_vInfo = {};
CEPGP_vSearch = "GUILD";
CEPGP_ElvUI = nil;
CEPGP_groupVersion = {};
CEPGP_snapshot = nil;
CEPGP_use = false;
CEPGP_award = false;
CEPGP_rate = 1;
CEPGP_plugins = {};
--[[ SAVED VARIABLES ]]--
CHANNEL = "Guild";
CEPGP_lootChannel = "Raid";
MOD = 1;
COEF = 4.83;
MOD_COEF = 2;
BASEGP = 1;
STANDBYEP = false;
STANDBYOFFLINE = false;
CEPGP_min_threshold = 2;
ALLOW_FORCED_SYNC = false;
CEPGP_force_sync_rank = 1;
CEPGP_standby_accept_whispers = false;
CEPGP_standby_share = false;
CEPGP_standby_whisper_msg = "standby";
CEPGP_keyword = nil;
CEPGP_standby_byrank = true;
CEPGP_standby_manual = false;
CEPGP_notice = false;
CEPGP_loot_GUI = false;
CEPGP_auto_pass = false;
CEPGP_raid_wide_dist = {[1] = true, [2] = false};
CEPGP_gp_tooltips = false;
CEPGP_suppress_announcements = false;
STANDBYPERCENT = 100;
STANDBYRANKS = {};
SLOTWEIGHTS = {};
DEFSLOTWEIGHTS = {["2HWEAPON"] = 2,["WEAPONMAINHAND"] = 1.5,["WEAPON"] = 1.5,["WEAPONOFFHAND"] = 0.5,["HOLDABLE"] = 0.5,["SHIELD"] = 0.5,["RANGED"] = 0.5,["RANGEDRIGHT"] = 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};
AUTOEP = {};
EPVALS = {};
RECORDS = {};
OVERRIDE_INDEX = {};
TRAFFIC = {};
CEPGP_raid_logs = {};
CEPGP_standbyRoster = {};
CEPGP_minEP = {false, 0};
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, "", 0},[6]={false, "Pass", 100}};
CEPGP_response_time = 0;
CEPGP_show_passes = false;
CEPGP_PR_sort = true;
CEPGP_Info = {
Version = "1.12.25",
Build = "Release",
Debug = false,
Initialised = false;
Active = {false, false}, -- Active state, queried for current raid
SharingTraffic = false,
ImportingTraffic = false,
NumExcluded = 0,
IgnoreUpdates = false,
LastImport = time(),
SyncInProgress = false,
LastUpdate = GetTime(),
QueuedAnnouncement = nil,
QueuedAward = nil,
Polling = false,
Rescan = false,
MessageStack = {},
RosterStack = {},
Sorting = { -- Sorting index, reverse
Attendance = {1, false},
Guild = {4, false},
Loot = {4, false},
Raid = {4, false},
Standby = {1, false},
Version = {1, false},
},
VersionNotified = false,
VerboseLogging = false,
TrafficImport = {},
TrafficScope = 1,
LastRun = {
DistSB = 0,
GuildSB = 0,
LogSB = 0,
RaidSB = 0,
TrafficSB = 0,
VersionSB = 0,
ItemCall = time()
},
LootGUID = "",
LootRespondants = 0,
LootSchema = {},
ClassColours = {
["DRUID"] = {
r = 1,
g = 0.49,
b = 0.04,
colorStr = "#FF7D0A"
},
["HUNTER"] = {
r = 0.67,
g = 0.83,
b = 0.45,
colorStr = "#A9D271"
},
["MAGE"] = {
r = 0.25,
g = 0.78,
b = 0.92,
colorStr = "#40C7EB"
},
["PALADIN"] = {
r = 0.96,
g = 0.55,
b = 0.73,
colorStr = "#F58CBA"
},
["PRIEST"] = {
r = 1,
g = 1,
b = 1,
colorStr = "#FFFFFF"
},
["ROGUE"] = {
r = 1,
g = 0.96,
b = 0.41,
colorStr = "#FFF569"
},
["SHAMAN"] = {
r = 0,
g = 0.44,
b = 0.87,
colorStr = "#0070DE"
},
["WARLOCK"] = {
r = 0.53,
g = 0.53,
b = 0.93,
colorStr = "#8787ED"
},
["WARRIOR"] = {
r = 0.78,
g = 0.61,
b = 0.43,
colorStr = "#C79C6E"
}
}
};
CEPGP = {};
--[[Attendance = CEPGP_raid_logs,
Backups = RECORDS,
Channel = CHANNEL,
Exclusions = {false,false,false,false,false,false,false,false,false,false},
ChangelogVersion = CEPGP_Info.Version,
LootChannel = CEPGP_lootChannel,
Notice = CEPGP_notice,
Overrides = OVERRIDE_INDEX,
PollRate = 0.0001,
Sync = {ALLOW_FORCED_SYNC, CEPGP_force_sync_rank},
Traffic = TRAFFIC,
Alt = {
Links = {},
BlockAwards = false,
SyncEP = true,
SyncGP = true,
},
Decay = {Separate = false},
EP = {
AutoAward = AUTOEP,
BossEP = EPVALS,
Keyword = CEPGP_keyword,
},
GP = {
Base = 4.83,
DecayFactor = false,
Min = 1,
Mod = 1,
Multiplier = 2,
SlotWeights = {
["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
},
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
},
Tooltips = false,
},
Loot = {
Announcement = "Whisper me for loot",
AutoPass = CEPGP_auto_pass,
AutoShow = false,
AutoSort = CEPGP_PR_sort,
DelayResponses = false,
ExtraKeywords = {Keywords = {}},
Keyword = CEPGP_keyword,
HideKeyphrases = false,
MinThreshold = CEPGP_min_threshold,
MinReq = CEPGP_minEP,
RaidVisibility = {[1] = true, [2] = CEPGP_raid_wide_dist[2]},
RaidWarning = false,
ShowPass = CEPGP_show_passes,
SuppressResponses = CEPGP_suppress_announcements,
GUI = {
Buttons = CEPGP_response_buttons,
Enabled = CEPGP_loot_GUI,
Timer = CEPGP_response_time
}
},
Standby = {
AcceptWhispers = CEPGP_standby_accept_whispers,
ByRank = CEPGP_standby_byrank,
Enabled = STANDBYEP,
Keyword = CEPGP_standby_whisper_msg,
Manual = CEPGP_standby_manual,
Offline = STANDBYOFFLINE,
Percent = STANDBYPERCENT,
Ranks = STANDBYRANKS,
Roster = CEPGP_standbyRoster,
Share = CEPGP_standby_share,
}
}]]
local L = CEPGP_Locale:GetLocale("CEPGP")
--[[ EVENT AND COMMAND HANDLER ]]--
function CEPGP_OnEvent(event, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17)
local function isLootKeyword()
for i = 1, 4 do
if string.lower(arg1) == string.lower(CEPGP_response_buttons[i][4]) then
return true;
end
end
for _, v in pairs(CEPGP.Loot.ExtraKeywords.Keywords) do
for key, _ in pairs(v) do
if string.lower(arg1) == string.lower(key) then
return true;
end
end
end
return false;
end
if event == "ADDON_LOADED" and arg1 == "CEPGP" then --arg1 = addon name
local success, failMsg = pcall(function()
CEPGP_initialise();
return;
end);
C_Timer.After(6, function()
if not success then
CEPGP_print("Addon failed to initialise!", true);
CEPGP_print(failMsg);
end
end);
elseif event == "GUILD_ROSTER_UPDATE" or event == "GROUP_ROSTER_UPDATE" then
CEPGP_rosterUpdate(event);
return;
elseif event == "GET_ITEM_INFO_RECEIVED" then
local id, success = arg1, arg2;
if success then
CEPGP_updateOverride(id);
end
return;
elseif event == "PARTY_LOOT_METHOD_CHANGED" or event == "PLAYER_ROLES_ASSIGNED" then
if GetLootMethod() == "master" and IsInRaid() and (CEPGP_isML() == 0 or CEPGP_Info.Debug) and not CEPGP_Info.Active[2] then
_G["CEPGP_confirmation"]:Show();
else
_G["CEPGP_confirmation"]:Hide();
end
if GetLootMethod() ~= "master" or not IsInRaid() or CEPGP_isML() ~= 0 then
CEPGP_Info.Active[1] = false;
CEPGP_Info.Active[2] = false; -- Whenever the loot method, loot master or group type is changed, this will enable the check again
end
return;
elseif event == "CHAT_MSG_BN_WHISPER" then
local sender = arg2;
if not UnitInRaid("player") then return; end
for i = 1, BNGetNumFriends() do
local _, accName, _, _, name = BNGetFriendInfo(i);
local inRaid = false;
for x = 1, GetNumGroupMembers() do
if CEPGP_raidRoster[x][1] == name then
inRaid = true;
break;
end
end
if sender == accName then --Behaves the same way for both Battle Tag and RealID friends
if string.lower(arg1) == string.lower(CEPGP_standby_whisper_msg) then
if (CEPGP_standby_manual and CEPGP_standby_accept_whispers) and
not CEPGP_tContains(CEPGP_standbyRoster, name) and not inRaid and CEPGP_roster[name] then
CEPGP_addToStandby(name);
end
elseif (isLootKeyword() and CEPGP_distributing) or
(string.lower(arg1) == "!info" or string.lower(arg1) == "!infoguild" or
string.lower(arg1) == "!inforaid" or string.lower(arg1) == "!infoclass") then
CEPGP_handleComms("CHAT_MSG_WHISPER", arg1, name);
end
return;
end
end
return;
elseif event == "CHAT_MSG_WHISPER" and string.lower(arg1) == string.lower(CEPGP_standby_whisper_msg) and CEPGP_standby_manual and CEPGP_standby_accept_whispers then
if not CEPGP_tContains(CEPGP_standbyRoster, arg5)
and not CEPGP_tContains(CEPGP_raidRoster, arg5, true)
and CEPGP_roster[arg5] then
CEPGP_addToStandby(arg5);
end
return;
elseif (event == "CHAT_MSG_WHISPER" and isLootKeyword() and CEPGP_distributing) or
(event == "CHAT_MSG_WHISPER" and string.lower(arg1) == "!info") or
(event == "CHAT_MSG_WHISPER" and (string.lower(arg1) == "!infoguild" or string.lower(arg1) == "!inforaid" or string.lower(arg1) == "!infoclass")) then
-- arg1 - message | arg5 - sender
CEPGP_handleComms(event, arg1, arg5);
return;
elseif (event == "CHAT_MSG_ADDON") or (event == "CHAT_MSG_ADDON_LOGGED") then
if (arg1 == "CEPGP")then
local message = arg2;
local channel = arg3;
local player = arg5;
CEPGP_IncAddonMsg(message, arg5, arg3);
end
return;
end
if CEPGP_Info.Active[1] or CEPGP_Info.Debug then --EPGP and loot distribution related
-- An encounter has been defeated
local function handleEncounter(event, arg1, arg5)
if event == "ENCOUNTER_END" and arg5 == 1 then
local id = tonumber(arg1);
local name = CEPGP_EncounterInfo.ID[id];
if name then
if AUTOEP[name] and tonumber(EPVALS[name]) > 0 then
CEPGP_handleCombat(name);
end
end
return;
end
end
local success, failMsg = pcall(handleEncounter, event, arg1, arg5);
if not success then
CEPGP_print("Failed to award GP for encounter!", true);
CEPGP_print(failMsg, true);
end
if (event == "LOOT_OPENED" or event == "LOOT_CLOSED" or event == "LOOT_SLOT_CLEARED") then
CEPGP_handleLoot(event, arg1, arg2);
end
end
end
function SlashCmdList.CEPGP(msg, editbox)
msg = string.lower(msg);
if msg == "" then
CEPGP_print("Classic EPGP Usage");
CEPGP_print("|cFF80FF80show|r - |cFFFF8080Manually shows the CEPGP window|r");
CEPGP_print("|cFF80FF80version|r - |cFFFF8080Checks the version of the addon everyone in your raid is running|r");
CEPGP_print("|cFF80FF80options or config|r - |cFFFF8080Opens the configuration menu for CEPGP|r");
CEPGP_print("|cFF80FF80traffic|r - |cFFFF8080Opens the CEPGP traffic window|r");
CEPGP_print("|cFF80FF80changelog|r - |cFFFF8080Shows the latest changelog|r");
elseif msg == "show" or msg == "open" then
CEPGP_populateFrame();
ShowUIPanel(CEPGP_frame);
CEPGP_toggleFrame("");
CEPGP_updateGuild();
elseif msg == "options" or msg == "opt" or msg == "config" or msg == "conf" then
InterfaceOptionsFrame_Show();
InterfaceOptionsFrame_OpenToCategory("Classic EPGP");
elseif msg == "change" or msg == "changelog" then
ShowUIPanel(CEPGP_changelog);
elseif msg == "traffic" then
ShowUIPanel(CEPGP_traffic);
elseif msg == "version" or msg == "ver" then
CEPGP_vInfo = {};
CEPGP_vSearch = "GUILD";
CEPGP_SendAddonMsg("version-check", "GUILD");
CEPGP_groupVersion = {};
for i = 1, GetNumGuildMembers() do
local name, _, _, _, class, _, _, _, online, _, classFileName = GetGuildRosterInfo(i);
if string.find(name, "-") then
name = string.sub(name, 0, string.find(name, "-")-1);
end
if online then
CEPGP_groupVersion[i] = {
[1] = name,
[2] = "Addon not enabled",
[3] = class,
[4] = classFileName
};
else
CEPGP_groupVersion[i] = {
[1] = name,
[2] = "Offline",
[3] = class,
[4] = classFileName
};
end
end
ShowUIPanel(CEPGP_version);
CEPGP_UpdateVersionScrollBar();
elseif msg == "debugmode" then
CEPGP_Info.Debug = not CEPGP_Info.Debug;
if CEPGP_Info.Debug then
CEPGP_print("Debug Mode Enabled");
else
CEPGP_print("Debug Mode Disabled");
end
elseif msg == "log" then
CEPGP_log:Show();
elseif msg == "debug" then
CEPGP_debuginfo:Show();
else
CEPGP_print("|cFF80FF80" .. msg .. "|r |cFFFF8080is not a valid request. Type /CEPGP to check addon usage|r", true);
end
end
--[[ LOOT COUNCIL FUNCTIONS ]]--
function CEPGP_RaidAssistLootClosed()
HideUIPanel(CEPGP_distribute_popup);
HideUIPanel(CEPGP_distributing_button);
HideUIPanel(CEPGP_loot_distributing);
HideUIPanel(CEPGP_frame);
CEPGP_distribute_item_tex:SetBackdrop(nil);
_G["CEPGP_distribute_item_tex"]:SetScript('OnEnter', function() end);
_G["CEPGP_distribute_item_name_frame"]:SetScript('OnClick', function() end);
CEPGP_UpdateLootScrollBar();
end
function CEPGP_RaidAssistLootDist(link, gp, raidwide) --raidwide refers to whether or not the ML would like everyone in the raid to be able to see the distribution window
if ((UnitIsGroupLeader("player") or UnitIsGroupAssistant("player")) and CEPGP_isML ~= 0) or raidwide then --Only returns true if the unit is raid ASSIST, not raid leader
ShowUIPanel(CEPGP_distributing_button);
CEPGP_UpdateLootScrollBar();
local name, iString, _, _, _, _, _, _, slot, tex = GetItemInfo(CEPGP_DistID);
CEPGP_distSlot = slot;
if not name and CEPGP_itemExists(CEPGP_DistID) then
local item = Item:CreateFromItemID(tonumber(CEPGP_DistID));
item:ContinueOnItemLoad(function()
name, iString, _, _, _, _, _, _, slot, tex = GetItemInfo(CEPGP_DistID);
CEPGP_responses = {};
_G["CEPGP_distribute_item_name"]:SetText(link);
if iString then
_G["CEPGP_distribute_item_tex"]:SetScript('OnEnter', function()
GameTooltip:SetOwner(_G["CEPGP_distribute_item_tex"], "ANCHOR_TOPLEFT") GameTooltip:SetHyperlink(iString)
GameTooltip:Show()
end);
_G["CEPGP_distribute_item_texture"]:SetTexture(tex);
_G["CEPGP_distribute_item_name_frame"]:SetScript('OnClick', function() SetItemRef(iString) end);
else
_G["CEPGP_distribute_item_tex"]:SetScript('OnEnter', function() end);
_G["CEPGP_distribute_item_texture"]:SetTexture(nil);
end
_G["CEPGP_distribute_item_tex"]:SetScript('OnLeave', function() GameTooltip:Hide() end);
_G["CEPGP_distribute_GP_value"]:SetText(gp);
end);
else
CEPGP_responses = {};
_G["CEPGP_distribute_item_name"]:SetText(link);
if iString then
_G["CEPGP_distribute_item_tex"]:SetScript('OnEnter', function()
GameTooltip:SetOwner(_G["CEPGP_distribute_item_tex"], "ANCHOR_TOPLEFT") GameTooltip:SetHyperlink(iString)
GameTooltip:Show()
end);
_G["CEPGP_distribute_item_texture"]:SetTexture(tex);
_G["CEPGP_distribute_item_name_frame"]:SetScript('OnClick', function() SetItemRef(iString) end);
else
_G["CEPGP_distribute_item_tex"]:SetScript('OnEnter', function() end);
_G["CEPGP_distribute_item_texture"]:SetTexture(nil);
end
_G["CEPGP_distribute_item_tex"]:SetScript('OnLeave', function() GameTooltip:Hide() end);
_G["CEPGP_distribute_GP_value"]:SetText(gp);
end
end
if raidwide and CEPGP.Loot.AutoShow then
ShowUIPanel(CEPGP_frame);
CEPGP_toggleFrame("CEPGP_distribute");
end
end
--[[ ADD EPGP FUNCTIONS ]]--
function CEPGP_AddRaidEP(amount, msg, encounter)
amount = math.floor(amount);
local function callback()
local success, failMsg = pcall(function()
local total = GetNumGroupMembers();
CEPGP_Info.IgnoreUpdates = true;
CEPGP_SendAddonMsg("?IgnoreUpdates;true");
local roster = {};
for _, v in pairs(CEPGP_raidRoster) do
roster[v[1]] = "";
end
local function update()
if msg ~= "" and msg ~= nil or encounter then
if encounter then -- a boss was killed
CEPGP_addTraffic("Raid", UnitName("player"), "Add Raid EP +" .. amount .. " - " .. encounter, "", "", "", "", "", time());
CEPGP_sendChatMessage(msg, CHANNEL);
else -- EP was manually given, could be either positive or negative, and a message was written
if tonumber(amount) <= 0 then
CEPGP_addTraffic("Raid", UnitName("player"), "Subtract Raid EP -" .. amount .. " (" .. msg .. ")", "", "", "", "", "", time());
CEPGP_sendChatMessage(amount .. " EP taken from all raid members (" .. msg .. ")", CHANNEL);
else
CEPGP_addTraffic("Raid", UnitName("player"), "Add Raid EP +" .. amount .. " (" .. msg .. ")", "", "", "", "", "", time());
CEPGP_sendChatMessage(amount .. " EP awarded to all raid members (" .. msg .. ")", CHANNEL);
end
end
else -- no message was written
if tonumber(amount) <= 0 then
amount = string.sub(amount, 2, string.len(amount));
CEPGP_addTraffic("Raid", UnitName("player"), "Subtract Raid EP -" .. amount, "", "", "", "", "", time());
CEPGP_sendChatMessage(amount .. " EP taken from all raid members", CHANNEL);
else
CEPGP_addTraffic("Raid", UnitName("player"), "Add Raid EP +" .. amount, "", "", "", "", "", time());
CEPGP_sendChatMessage(amount .. " EP awarded to all raid members", CHANNEL);
end
end
if _G["CEPGP_traffic"]:IsVisible() then
CEPGP_UpdateTrafficScrollBar();
end
C_Timer.After(2, function()
CEPGP_Info.IgnoreUpdates = false;
CEPGP_SendAddonMsg("?IgnoreUpdates;false");
CEPGP_rosterUpdate("GUILD_ROSTER_UPDATE");
end);
end
local i = 0;
local mains = {};
C_Timer.NewTicker(0.0001, function()
i = i + 1;
local name = GetRaidRosterInfo(i);
local EP, GP, EPB;
if CEPGP_roster[name] then
local index = CEPGP_getIndex(name);
local main = CEPGP_getMain(name);
if main then
for v, _ in pairs(mains) do
if v == main then
return;
end
end
if not roster[main] then
mains[main] = name;
end
else
EP, GP = CEPGP_getEPGP(name, index);
EPB = EP;
EP = math.max(math.floor(EP + amount), 0);
GP = math.max(math.floor(GP), CEPGP.GP.Min);
GuildRosterSetOfficerNote(index, EP .. "," .. GP);
if CEPGP.Alt.Links[name] and not mains[name] then
mains[name] = {};
end
end
end
if i == total then
C_Timer.After(2, function()
for main, alt in pairs(mains) do
if #mains[main] == 0 then
CEPGP_syncAltStandings(main);
else
CEPGP_addAltEPGP(amount, 0, alt, main);
end
end
end);
update();
end
end, total);
end);
if not success then
CEPGP_print("A problem was encountered while awarding EP to the raid", true);
CEPGP_print(failMsg, true);
end
end
if CEPGP_ntgetn(CEPGP_roster) < (GetNumGuildMembers() - CEPGP_Info.NumExcluded) and CEPGP_Info.Polling then
CEPGP_print("Scanning guild roster. Raid EP will be applied soon.");
if encounter then
CEPGP_Info.RosterStack["BossEP"] = callback;
else
CEPGP_Info.RosterStack["RaidEP"] = callback;
end
else
callback();
end
end
function CEPGP_addGuildEP(amount, msg)
if amount == nil then
CEPGP_print("Please enter a valid number", 1);
return;
end
local success, failMsg = pcall(function()
local EP, GP = nil;
amount = math.floor(amount);
local function update()
if tonumber(amount) <= 0 then
amount = string.sub(amount, 2, string.len(amount));
if msg ~= "" and msg ~= nil then
CEPGP_sendChatMessage(amount .. " EP taken from all guild members (" .. msg .. ")", CHANNEL);
CEPGP_addTraffic("Guild", UnitName("player"), "Subtract Guild EP -" .. amount .. " (" .. msg .. ")", "", "", "", "", "", time());
else
CEPGP_sendChatMessage(amount .. " EP taken from all guild members", CHANNEL);
CEPGP_addTraffic("Guild", UnitName("player"), "Subtract Guild EP -" .. amount, "", "", "", "", "", time());
end
else
if msg ~= "" and msg ~= nil then
CEPGP_sendChatMessage(amount .. " EP awarded to all guild members (" .. msg .. ")", CHANNEL);
CEPGP_addTraffic("Guild", UnitName("player"), "Add Guild EP +" .. amount .. " (" .. msg .. ")", "", "", "", "", "", time());
else
CEPGP_sendChatMessage(amount .. " EP awarded to all guild members", CHANNEL);
CEPGP_addTraffic("Guild", UnitName("player"), "Add Guild EP +" .. amount, "", "", "", "", "", time());
end
end
if _G["CEPGP_traffic"]:IsVisible() then
CEPGP_UpdateTrafficScrollBar();
end
C_Timer.After(2, function()
CEPGP_Info.IgnoreUpdates = false;
CEPGP_SendAddonMsg("?IgnoreUpdates;false");
CEPGP_rosterUpdate("GUILD_ROSTER_UPDATE");
end);
end
CEPGP_Info.IgnoreUpdates = true;
CEPGP_SendAddonMsg("?IgnoreUpdates;true");
local temp = {};
local mains = {};
for k, _ in pairs(CEPGP_roster) do
table.insert(temp, k);
end
local i = 0;
C_Timer.After(0.1, function()
C_Timer.NewTicker(0.0001, function()
i = i + 1;
local name = temp[i];
local main = CEPGP_getMain(name);
if main then
for _, v in ipairs(mains) do
if v == main then
return;
end
end
table.insert(mains, main);
else
local index = CEPGP_getIndex(name);
EP, GP = CEPGP_getEPGP(name, index);
EP = math.max(math.floor(EP + amount), 0);
GP = math.max(math.floor(GP), CEPGP.GP.Min);
if index then
if main then
CEPGP_addAltEPGP(amount, 0, name, main);
else
GuildRosterSetOfficerNote(index, EP .. "," .. GP);
C_Timer.After(1, function()
CEPGP_syncAltStandings(player);
end);
end
end
end
if i == #temp then
C_Timer.After(2, function()
for _, name in ipairs(mains) do
CEPGP_syncAltStandings(name);
end
end);
update();
end
end, #temp);
end);
end);
if not success then
CEPGP_print("A problem was encountered while awarding EP to the raid", true);
CEPGP_print(failMsg, true);
end
end
function CEPGP_addStandbyEP(amount, boss, msg)
if amount == nil then
CEPGP_print("Please enter a valid number", 1);
return;
end
local function callback()
local success, failMsg = pcall(function()
local function update()
if tonumber(amount) > 0 then
CEPGP_addTraffic("Guild", UnitName("player"), "Standby EP +" .. amount);
elseif tonumber(amount) < 0 then
CEPGP_addTraffic("Guild", UnitName("player"), "Standby EP " .. amount);
end
if _G["CEPGP_traffic"]:IsVisible() then
CEPGP_UpdateTrafficScrollBar();
end
if _G["CEPGP_standby_options"]:IsVisible() then
CEPGP_UpdateStandbyScrollBar();
end
C_Timer.After(2, function()
CEPGP_Info.IgnoreUpdates = false;
CEPGP_SendAddonMsg("?IgnoreUpdates;false");
CEPGP_rosterUpdate("GUILD_ROSTER_UPDATE");
end);
end
CEPGP_Info.IgnoreUpdates = true;
CEPGP_SendAddonMsg("?IgnoreUpdates;true");
local i = 0;
local mains = {};
local roster = {};
for _, v in pairs(CEPGP_raidRoster) do
roster[v[1]] = "";
end
C_Timer.After(0.1, function()
local temp = {};
if CEPGP.Standby.ByRank then
local inRaid = false;
for k, _ in pairs(CEPGP_roster) do
table.insert(temp, k);
end
C_Timer.NewTicker(0.0001, function()
i = i + 1;
local name = temp[i];
inRaid = false;
for _, v in ipairs(CEPGP_raidRoster) do
if name == v[1] then
inRaid = true;
break;
end
end
if not inRaid then
local main = CEPGP_getMain(name);
if main then
for v, _ in pairs(mains) do
if v == main then
return;
end
end
if not roster[main] then
mains[main] = name;
end
else
local index = CEPGP_getIndex(name);
local _, rank, rankIndex, _, _, _, _, _, online = GetGuildRosterInfo(index);
local EP,GP = CEPGP_getEPGP(name, index);
EP = math.max(math.floor(EP + amount), 0);
GP = math.max(math.floor(GP), CEPGP.GP.Min);
for i = 1, #STANDBYRANKS do
if STANDBYRANKS[i][1] == rank then
if STANDBYRANKS[i][2] == true and (online or STANDBYOFFLINE) then
if main then
CEPGP_addAltEPGP(amount, 0, name, main);
else
GuildRosterSetOfficerNote(index, EP .. "," .. GP);
end
if boss then
CEPGP_SendAddonMsg("STANDBYEP;"..name..";You have been awarded "..amount.." standby EP for encounter " .. boss, "GUILD");
elseif msg ~= "" and msg ~= nil then
if tonumber(amount) > 0 then
CEPGP_SendAddonMsg("STANDBYEP;"..name..";You have been awarded "..amount.." standby EP - "..msg, "GUILD");
elseif tonumber(amount) < 0 then
CEPGP_SendAddonMsg("STANDBYEP;"..name..";"..amount.." standby EP has been taken from you - "..msg, "GUILD");
end
else
if tonumber(amount) > 0 then
CEPGP_SendAddonMsg("STANDBYEP;"..name..";You have been awarded "..amount.." standby EP", "GUILD");
elseif tonumber(amount) < 0 then
CEPGP_SendAddonMsg("STANDBYEP;"..name..";"..amount.." standby EP has been taken from you", "GUILD");
end
end
end
end
end
end
end
if i == #temp then
update();
end
end, #temp);
elseif CEPGP.Standby.Manual and #CEPGP_standbyRoster > 0 then
C_Timer.NewTicker(0.0001, function()
i = i + 1;
local name = CEPGP_standbyRoster[i][1];
local main = CEPGP_getMain(name);
local index = CEPGP_getIndex(name);
local online = select(9, GetGuildRosterInfo(index));
if online or STANDBYOFFLINE then
local EP,GP = CEPGP_getEPGP(name, index);
if main then
for v, _ in pairs(mains) do
if v == main then
return;
end
end
if not roster[main] then
mains[main] = name;
end
else
EP = math.max(math.floor(EP + amount), 0);
GP = math.max(math.floor(GP), CEPGP.GP.Min);
GuildRosterSetOfficerNote(index, EP .. "," .. GP);
end
if boss then
CEPGP_SendAddonMsg("STANDBYEP;"..name..";You have been awarded "..amount.." standby EP for encounter " .. boss, "GUILD");
elseif msg ~= "" and msg ~= nil then
if tonumber(amount) > 0 then
CEPGP_SendAddonMsg("STANDBYEP;"..name..";You have been awarded "..amount.." standby EP - "..msg, "GUILD");
elseif tonumber(amount) < 0 then
CEPGP_SendAddonMsg("STANDBYEP;"..name..";"..amount.." standby EP has been taken from you - "..msg, "GUILD");
end
else
if tonumber(amount) > 0 then
CEPGP_SendAddonMsg("STANDBYEP;"..name..";You have been awarded "..amount.." standby EP", "GUILD");
elseif tonumber(amount) < 0 then
CEPGP_SendAddonMsg("STANDBYEP;"..name..";"..amount.." standby EP has been taken from you", "GUILD");
end
end
end
if i == #CEPGP_standbyRoster then
C_Timer.After(2, function()
for main, alt in pairs(mains) do
if #mains[main] == 0 then
CEPGP_syncAltStandings(main);
else
CEPGP_addAltEPGP(amount, 0, alt, main);
end
end
end);
update();
end
end, #CEPGP_standbyRoster);
end
end);
end);
if not success then
CEPGP_print("A problem was encountered while awarding EP to the standby list", true);
CEPGP_print(failMsg);
end
end
if CEPGP_ntgetn(CEPGP_roster) < (GetNumGuildMembers() - CEPGP_Info.NumExcluded) and CEPGP_Info.Polling then
CEPGP_print("Scanning guild roster. Standby EP will be applied soon.");
CEPGP_Info.RosterStack["StandbyEP"] = callback;
else
callback();
end
end
function CEPGP_addGP(player, amount, itemID, itemLink, msg, response)
if amount == nil then
CEPGP_print("Please enter a valid number", 1);
return;
end
local EP, GP = nil;
local GPB, GPA;
local success, failMsg = pcall(function()
amount = math.floor(amount);
if CEPGP_roster[player] then
local index = CEPGP_getIndex(player);
local main = CEPGP_getMain(player);
EP, GP = CEPGP_getEPGP(player, index);
GPB = GP;
GP = math.max(math.floor(GP + amount), CEPGP.GP.Min + amount);
EP = math.max(math.floor(EP), 0);
if main then
CEPGP_addAltEPGP(0, amount, player, main);
if CEPGP.Alt.BlockAwards then
if itemID then
CEPGP_addTraffic(player, UnitName("player"), "Awarded for free (Alt)", nil, nil, nil, nil, itemID);
return;
else
CEPGP_print("Cannot award GP directly to " .. player .. " because they are an alt and you have blocked alt EPGP modifications", true);
return;
end
end
else
GuildRosterSetOfficerNote(index, EP .. "," .. GP);
C_Timer.After(1, function()
CEPGP_syncAltStandings(player);
end);
end
if not itemID then
if tonumber(amount) < 0 then -- Number is negative
amount = string.sub(amount, 2, string.len(amount));
if msg ~= "" and msg ~= nil then
CEPGP_sendChatMessage(amount .. " GP taken from " .. player .. " (" .. msg .. ")", CHANNEL);
CEPGP_addTraffic(player, UnitName("player"), "Subtract GP -" .. amount .. " (" .. msg .. ")", EP, EP, GPB, GP);
else