-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathCore.lua
716 lines (681 loc) · 25.8 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
--[[ Globals ]]--
CEPGP = CreateFrame("Frame");
CEPGP_VERSION = "1.11.5";
SLASH_CEPGP1 = "/CEPGP";
SLASH_CEPGP2 = "/cep";
CEPGP_VERSION_NOTIFIED = false;
CEPGP_mode = "guild";
CEPGP_recordholder = "";
CEPGP_distPlayer = "";
CEPGP_combatModule = "";
CEPGP_distGP = false;
CEPGP_lootSlot = nil;
CEPGP_target = nil;
CEPGP_DistID = nil;
CEPGP_distSlot = nil;
CEPGP_distSlotID = nil;
CEPGP_distItemLink = nil;
CEPGP_debugMode = false;
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_kills = 0;
CEPGP_frames = {CEPGP_guild, CEPGP_raid, CEPGP_loot, CEPGP_distribute, CEPGP_options, CEPGP_options_page_2, CEPGP_distribute_popup, CEPGP_context_popup, CEPGP_save_guild_logs, CEPGP_restore_guild_logs, CEPGP_settings_import, CEPGP_override, CEPGP_traffic, CEPGP_standby};
CEPGP_boss_config_frames = {CEPGP_options_page_2_mc, CEPGP_options_page_2_bwl, CEPGP_options_page_2_zg, CEPGP_options_page_2_aq20, CEPGP_options_page_2_aq40, CEPGP_options_page_2_naxx, CEPGP_options_page_2_worldboss};
CEPGP_LANGUAGE = GetDefaultLanguage("player");
CEPGP_responses = {};
CEPGP_itemsTable = {};
CEPGP_roster = {};
CEPGP_standbyRoster = {};
CEPGP_raidRoster = {};
CEPGP_vInfo = {};
CEPGP_vSearch = "GUILD";
CEPGP_ElvUI = nil;
CEPGP_groupVersion = {};
CEPGP_RAZORGORE_EGG_COUNT = 0;
CEPGP_THEKAL_PARAMS = {};
CEPGP_snapshot = nil;
CEPGP_use = false;
--[[ SAVED VARIABLES ]]--
CHANNEL = nil;
MOD = nil;
COEF = nil;
MOD_COEF = nil;
BASEGP = nil;
STANDBYEP = false;
STANDBYOFFLINE = false;
ALLOW_FORCED_SYNC = false;
CEPGP_force_sync_rank = nil;
CEPGP_standby_accept_whispers = false;
CEPGP_standby_whisper_msg = "standby";
CEPGP_keyword = nil;
CEPGP_standby_byrank = true;
CEPGP_standby_manual = false;
CEPGP_notice = false;
CEPGP_loot_GUI = false;
STANDBYPERCENT = nil;
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 = {};
--[[ EVENT AND COMMAND HANDLER ]]--
function CEPGP_OnEvent(event, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
if event == "ADDON_LOADED" and arg1 == "CEPGP" then --arg1 = addon name
CEPGP_initialise();
elseif event == "GUILD_ROSTER_UPDATE" or event == "GROUP_ROSTER_UPDATE" then
CEPGP_rosterUpdate(event);
elseif event == "PARTY_LOOT_METHOD_CHANGED" then
if GetLootMethod() == "master" and IsInRaid("player") and CEPGP_isML() == 0 then
_G["CEPGP_confirmation"]:Show();
else
_G["CEPGP_confirmation"]:Hide();
end
elseif event == "CHAT_MSG_WHISPER" and string.lower(arg1) == 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_tContains(CEPGP_roster, arg5, true) then
CEPGP_addToStandby(arg5);
end
elseif (event == "CHAT_MSG_WHISPER" and string.lower(arg1) == string.lower(CEPGP_keyword) 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
CEPGP_handleComms(event, arg1, arg5);
elseif (event == "CHAT_MSG_ADDON") then
if (arg1 == "CEPGP")then
if string.find(arg4, "-") then
arg4 = string.sub(arg4, 0, string.find(arg4, "-")-1);
end
CEPGP_IncAddonMsg(arg2, arg4);
end
elseif CEPGP_use then --EPGP and loot distribution related
if event == "COMBAT_LOG_EVENT_UNFILTERED" then
local _, action = CombatLogGetCurrentEventInfo();
local name;
if action == "UNIT_DIED" then
_, _, _, _, _, _, _, _, name = CombatLogGetCurrentEventInfo();
if name == "Zealot Zath" or name == "Zealot Lor'Khan" then
CEPGP_handleCombat(name);
return;
end
if name == "Flamewaker Elite" or name == "Flamewaker Healer" then
CEPGP_handleCombat(name, true);
end
if bossNameIndex[name] then
CEPGP_handleCombat(name);
end
elseif action == "SPELL_CAST_SUCCESS" then
local spellID, spellName;
_, _, _, _, name, _, _, _, _, _, _, spellID = CombatLogGetCurrentEventInfo();
if name == "Razorgore the Untamed" and spellID == 19873 then --Razorgore casts destroy egg
CEPGP_kills = CEPGP_kills + 1;
end
end
elseif event == "CHAT_MSG_MONSTER_EMOTE" then
if arg1 == "%s is resurrected by a nearby ally!" then
if arg2 == "Zealot Lor'Khan" then
CEPGP_THEKAL_PARAMS["LOR'KHAN_DEAD"] = false;
elseif arg2 == "Zealot Zath" then
CEPGP_THEKAL_PARAMS["ZATH_DEAD"] = false;
elseif arg2 == "High Priest Thekal" and not (CEPGP_THEKAL_PARAMS["LOR'KHAN_DEAD"] or CEPGP_THEKAL_PARAMS["ZATH_DEAD"]) then
CEPGP_THEKAL_PARAMS["THEKAL_DEAD"] = false;
end
end
elseif event == "CHAT_MSG_MONSTER_YELL" then
if arg2 == "The Prophet Skeram" then
if arg1 == "You only delay... the inevetable." then
CEPGP_handleCombat(arg2, true);
end
end
elseif (event == "LOOT_OPENED" or event == "LOOT_CLOSED" or event == "LOOT_SLOT_CLEARED") then
CEPGP_handleLoot(event, arg1, arg2);
elseif event == "PLAYER_REGEN_DISABLED" then -- Player has started combat
if CEPGP_debugMode then
CEPGP_print("Combat started");
end
CEPGP_kills = 0;
CEPGP_THEKAL_PARAMS = {["ZATH_DEAD"] = false, ["LOR'KHAN_DEAD"] = false, ["THEKAL_DEAD"] = false};
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("|cFF80FF80setDefaultChannel channel|r - |cFFFF8080Sets the default channel to send confirmation messages. Default is Guild|r");
CEPGP_print("|cFF80FF80version|r - |cFFFF8080Checks the version of the addon everyone in your raid is running|r");
elseif msg == "show" then
CEPGP_populateFrame();
ShowUIPanel(CEPGP_frame);
CEPGP_toggleFrame("");
CEPGP_updateGuild();
elseif msg == "version" then
CEPGP_vInfo = {};
CEPGP_SendAddonMsg("version-check", CEPGP_vSearch);
ShowUIPanel(CEPGP_version);
elseif strfind(msg, "currentchannel") then
CEPGP_print("Current channel to report: " .. getCurChannel());
elseif strfind(msg, "debugmode") then
CEPGP_debugMode = not CEPGP_debugMode;
if CEPGP_debugMode then
CEPGP_print("Debug Mode Enabled");
else
CEPGP_print("Debug Mode Disabled");
end
elseif strfind(msg, "debug") then
CEPGP_debuginfo:Show();
elseif strfind(msg, "setdefaultchannel") then
if msg == "setdefaultchannel" or msg == "setdefaultchannel " then
CEPGP_print("|cFF80FFFFPlease enter a valid channel. Valid options are:|r");
CEPGP_print("|cFF80FFFFsay, yell, party, raid, guild, officer|r");
return;
end
local newChannel = CEPGP_getVal(msg);
newChannel = strupper(newChannel);
local valid = false;
local channels = {"SAY","YELL","PARTY","RAID","GUILD","OFFICER"};
local i = 1;
while channels[i] ~= nil do
if channels[i] == newChannel then
valid = true;
end
i = i + 1;
end
if valid then
CHANNEL = newChannel;
CEPGP_print("Default channel set to: " .. CHANNEL);
else
CEPGP_print("Please enter a valid chat channel. Valid options are:");
CEPGP_print("say, yell, party, raid, guild, officer");
end
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()
if UnitIsGroupAssistant("player") then
HideUIPanel(CEPGP_distribute_popup);
HideUIPanel(CEPGP_distribute);
HideUIPanel(CEPGP_loot_CEPGP_distributing);
HideUIPanel(distributing);
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);
for y = 1, 18 do
_G["LootDistButton"..y]:Hide();
_G["LootDistButton" .. y .. "Info"]:SetText("");
_G["LootDistButton" .. y .. "Class"]:SetText("");
_G["LootDistButton" .. y .. "Rank"]:SetText("");
_G["LootDistButton" .. y .. "EP"]:SetText("");
_G["LootDistButton" .. y .. "GP"]:SetText("");
_G["LootDistButton" .. y .. "PR"]:SetText("");
_G["LootDistButton" .. y .. "Tex"]:SetBackdrop(nil);
_G["LootDistButton" .. y .. "Tex2"]:SetBackdrop(nil);
end
end
end
function CEPGP_RaidAssistLootDist(link, gp)
if UnitIsGroupAssistant("player") then --Only returns true if the unit is raid ASSIST, not raid leader
ShowUIPanel(distributing);
local y = 1;
for y = 1, 18 do
_G["LootDistButton"..y]:Hide();
_G["LootDistButton" .. y .. "Info"]:SetText("");
_G["LootDistButton" .. y .. "Class"]:SetText("");
_G["LootDistButton" .. y .. "Rank"]:SetText("");
_G["LootDistButton" .. y .. "EP"]:SetText("");
_G["LootDistButton" .. y .. "GP"]:SetText("");
_G["LootDistButton" .. y .. "PR"]:SetText("");
_G["LootDistButton" .. y .. "Icon"]:SetTexture(nil);
_G["LootDistButton" .. y .. "Icon2"]:SetTexture(nil);
y = y + 1;
end
CEPGP_itemsTable = {};
local name, iString, _, _, _, _, _, _, slot, tex = GetItemInfo(CEPGP_getItemString(link));
CEPGP_DistID = CEPGP_getItemID(iString);
CEPGP_distSlot = slot;
if not CEPGP_DistID then
CEPGP_print("Item not found in game cache. You must see the item in-game before item info can be retrieved and CEPGP will not be able to retrieve what items recipients are wearing in that slot", true);
end
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
--[[ ADD EPGP FUNCTIONS ]]--
function CEPGP_AddRaidEP(amount, msg, encounter)
amount = math.floor(amount);
local total = GetNumGroupMembers();
if total > 0 then
for i = 1, total do
local name = GetRaidRosterInfo(i);
if CEPGP_tContains(CEPGP_roster, name, true) then
local index = CEPGP_getGuildInfo(name);
if not CEPGP_checkEPGP(CEPGP_roster[name][5]) then
GuildRosterSetOfficerNote(index, amount .. "," .. BASEGP);
else
EP,GP = CEPGP_getEPGP(CEPGP_roster[name][5]);
EP = tonumber(EP);
GP = tonumber(GP);
EP = EP + amount;
if GP < BASEGP then
GP = BASEGP;
end
if EP < 0 then
EP = 0;
end
GuildRosterSetOfficerNote(index, EP .. "," .. GP);
end
end
end
end
if msg ~= "" and msg ~= nil or encounter then
if encounter then -- a boss was killed
TRAFFIC[CEPGP_ntgetn(TRAFFIC)+1] = {"Raid", UnitName("player"), "Add Raid EP +" .. amount .. " - " .. encounter};
CEPGP_ShareTraffic("Raid", UnitName("player"), "Add Raid EP +" .. amount .. " - " .. encounter);
SendChatMessage(amount .. " EP awarded to all raid members", "RAID", CEPGP_LANGUAGE);
else -- EP was manually given, could be either positive or negative, and a message was written
if tonumber(amount) <= 0 then
TRAFFIC[CEPGP_ntgetn(TRAFFIC)+1] = {"Raid", UnitName("player"), "Subtract Raid EP +" .. amount .. " (" .. msg .. ")"};
CEPGP_ShareTraffic("Raid", UnitName("player"), "Subtract Raid EP " .. amount .. " (" .. msg .. ")");
SendChatMessage(amount .. " EP taken from all raid members (" .. msg .. ")", "RAID", CEPGP_LANGUAGE);
else
print("Message: " .. msg);
TRAFFIC[CEPGP_ntgetn(TRAFFIC)+1] = {"Raid", UnitName("player"), "Add Raid EP +" .. amount .. " (" .. msg .. ")"};
CEPGP_ShareTraffic("Raid", UnitName("player"), "Add Raid EP +" .. amount .. " (" .. msg .. ")");
SendChatMessage(amount .. " EP awarded to all raid members (" .. msg .. ")", "RAID", CEPGP_LANGUAGE);
end
end
else -- no message was written
if tonumber(amount) <= 0 then
amount = string.sub(amount, 2, string.len(amount));
TRAFFIC[CEPGP_ntgetn(TRAFFIC)+1] = {"Raid", UnitName("player"), "Subtract Raid EP -" .. amount};
CEPGP_ShareTraffic("Raid", UnitName("player"), "Subtract Raid EP -" .. amount);
SendChatMessage(amount .. " EP taken from all raid members", "RAID", CEPGP_LANGUAGE);
else
TRAFFIC[CEPGP_ntgetn(TRAFFIC)+1] = {"Raid", UnitName("player"), "Add Raid EP +" .. amount};
CEPGP_ShareTraffic("Raid", UnitName("player"), "Add Raid EP +" .. amount);
SendChatMessage(amount .. " EP awarded to all raid members", "RAID", CEPGP_LANGUAGE);
end
end
CEPGP_UpdateTrafficScrollBar();
end
function CEPGP_addGuildEP(amount, msg)
if amount == nil then
CEPGP_print("Please enter a valid number", 1);
return;
end
_G["CEPGP_frame"]:UnregisterEvent("GUILD_ROSTER_UPDATE");
local total = CEPGP_ntgetn(CEPGP_roster);
local EP, GP = nil;
amount = math.floor(amount);
if total > 0 then
for name,_ in pairs(CEPGP_roster)do
offNote = CEPGP_roster[name][5];
index = CEPGP_roster[name][1];
if offNote == "" or offNote == "Click here to set an Officer's Note" then
GuildRosterSetOfficerNote(index, amount .. "," .. BASEGP);
else
EP,GP = CEPGP_getEPGP(CEPGP_roster[name][5]);
EP = tonumber(EP) + amount;
GP = tonumber(GP);
if GP < BASEGP then
GP = BASEGP;
end
if EP < 0 then
EP = 0;
end
GuildRosterSetOfficerNote(index, EP .. "," .. GP);
end
end
end
_G["CEPGP_frame"]:RegisterEvent("GUILD_ROSTER_UPDATE");
if tonumber(amount) <= 0 then
amount = string.sub(amount, 2, string.len(amount));
if msg ~= "" and msg ~= nil then
SendChatMessage(amount .. " EP taken from all guild members (" .. msg .. ")", CHANNEL, CEPGP_LANGUAGE);
TRAFFIC[CEPGP_ntgetn(TRAFFIC)+1] = {"Guild", UnitName("player"), "Subtract Guild EP -" .. amount .. " (" .. msg .. ")"};
CEPGP_ShareTraffic("Guild", UnitName("player"), "Subtract Guild EP -" .. amount .. " (" .. msg .. ")");
else
SendChatMessage(amount .. " EP taken from all guild members", CHANNEL, CEPGP_LANGUAGE);
TRAFFIC[CEPGP_ntgetn(TRAFFIC)+1] = {"Guild", UnitName("player"), "Subtract Guild EP -" .. amount};
CEPGP_ShareTraffic("Guild", UnitName("player"), "Subtract Guild EP -" .. amount);
end
else
if msg ~= "" and msg ~= nil then
SendChatMessage(amount .. " EP awarded to all guild members (" .. msg .. ")", CHANNEL, CEPGP_LANGUAGE);
TRAFFIC[CEPGP_ntgetn(TRAFFIC)+1] = {"Guild", UnitName("player"), "Add Guild EP +" .. amount .. " (" .. msg .. ")"};
CEPGP_ShareTraffic("Guild", UnitName("player"), "Add Guild EP +" .. amount .. " (" .. msg .. ")");
else
SendChatMessage(amount .. " EP awarded to all guild members", CHANNEL, CEPGP_LANGUAGE);
TRAFFIC[CEPGP_ntgetn(TRAFFIC)+1] = {"Guild", UnitName("player"), "Add Guild EP +" .. amount};
CEPGP_ShareTraffic("Guild", UnitName("player"), "Add Guild EP +" .. amount);
end
end
CEPGP_UpdateTrafficScrollBar();
end
function CEPGP_addStandbyEP(player, amount, boss)
if amount == nil then
CEPGP_print("Please enter a valid number", 1);
return;
end
amount = (math.floor(amount*100))/100;
local name = CEPGP_getGuildInfo(player);
local EP,GP = CEPGP_getEPGP(CEPGP_roster[player][5]);
EP = tonumber(EP) + amount;
GP = tonumber(GP);
if GP < BASEGP then
GP = BASEGP;
end
if EP < 0 then
EP = 0;
end
if offNote == "" or offNote == "Click here to set an Officer's Note" then
GuildRosterSetOfficerNote(CEPGP_roster[player][1], EP .. "," .. BASEGP);
else
GuildRosterSetOfficerNote(CEPGP_roster[player][1], EP .. "," .. GP);
end
CEPGP_SendAddonMsg("STANDBYEP"..player..",You have been awarded "..amount.." standby EP for encounter " .. boss, "GUILD");
end
function CEPGP_addGP(player, amount, itemID, itemLink, msg)
if amount == nil then
CEPGP_print("Please enter a valid number", 1);
return;
end
local EP, GP = nil;
amount = math.floor(amount);
if CEPGP_tContains(CEPGP_roster, player, true) then
offNote = CEPGP_roster[player][5];
index = CEPGP_roster[player][1];
if offNote == "" or offNote == "Click here to set an Officer's Note" then
GuildRosterSetOfficerNote(index, "0," .. BASEGP);
offNote = "0," .. BASEGP;
end
EP,GP = CEPGP_getEPGP(offNote);
GPB = GP;
GP = tonumber(GP) + amount;
EP = tonumber(EP);
if GP < BASEGP then
GP = BASEGP;
end
if EP < 0 then
EP = 0;
end
GuildRosterSetOfficerNote(index, EP .. "," .. GP);
if not itemID then
if tonumber(amount) <= 0 then
amount = string.sub(amount, 2, string.len(amount));
if msg ~= "" and msg ~= nil then
SendChatMessage(amount .. " GP taken from " .. player .. "(" .. msg .. ")", CHANNEL, CEPGP_LANGUAGE, CHANNEL);
CEPGP_ShareTraffic(player, UnitName("player"), "Subtract GP -" .. amount .. " (" .. msg .. ")", EP, EP, GP - amount, GPB);
TRAFFIC[CEPGP_ntgetn(TRAFFIC)+1] = {
[1] = player,
[2] = UnitName("player"),
[3] = "Subtract GP -" .. amount .. " (" .. msg .. ")",
[4] = EP,
[5] = EP,
[6] = GPB,
[7] = GP
};
else
SendChatMessage(amount .. " GP taken from " .. player, CHANNEL, CEPGP_LANGUAGE, CHANNEL);
CEPGP_ShareTraffic(player, UnitName("player"), "Subtract GP -" .. amount, EP, EP, GP - amount, GPB);
TRAFFIC[CEPGP_ntgetn(TRAFFIC)+1] = {
[1] = player,
[2] = UnitName("player"),
[3] = "Subtract GP -" .. amount,
[4] = EP,
[5] = EP,
[6] = GPB,
[7] = GP
};
end
else
if msg ~= "" and msg ~= nil then
SendChatMessage(amount .. " GP added to " .. player .. " (" .. msg .. ")", CHANNEL, CEPGP_LANGUAGE, CHANNEL);
CEPGP_ShareTraffic(player, UnitName("player"), "Add GP +" .. amount .. " (" .. msg .. ")", EP, EP, GPB, GP);
TRAFFIC[CEPGP_ntgetn(TRAFFIC)+1] = {
[1] = player,
[2] = UnitName("player"),
[3] = "Add GP +" .. amount .. " (" .. msg .. ")",
[4] = EP,
[5] = EP,
[6] = GPB,
[7] = GP
};
else
SendChatMessage(amount .. " GP added to " .. player, CHANNEL, CEPGP_LANGUAGE, CHANNEL);
CEPGP_ShareTraffic(player, UnitName("player"), "Add GP +" .. amount, EP, EP, GPB, GP);
TRAFFIC[CEPGP_ntgetn(TRAFFIC)+1] = {
[1] = player,
[2] = UnitName("player"),
[3] = "Add GP +" .. amount,
[4] = EP,
[5] = EP,
[6] = GPB,
[7] = GP
};
end
end
else
if msg ~= "" and msg ~= nil then
TRAFFIC[CEPGP_ntgetn(TRAFFIC)+1] = {
[1] = player,
[2] = UnitName("player"),
[3] = "Add GP +" .. amount .. " (" .. msg .. ")",
[4] = EP,
[5] = EP,
[6] = GPB,
[7] = GP,
[8] = itemLink
};
else
TRAFFIC[CEPGP_ntgetn(TRAFFIC)+1] = {
[1] = player,
[2] = UnitName("player"),
[3] = "Add GP +" .. amount,
[4] = EP,
[5] = EP,
[6] = GPB,
[7] = GP,
[8] = itemLink
};
end
if itemLink then
if msg ~= "" and msg ~= nil then
TRAFFIC[CEPGP_ntgetn(TRAFFIC)][8] = itemLink;
CEPGP_ShareTraffic(player, UnitName("player"), "Add GP +" .. amount .. " (" .. msg .. ")", EP, EP, GPB, GP, itemID);
else
CEPGP_ShareTraffic(player, UnitName("player"), "Add GP +" .. amount, EP, EP, GPB, GP, itemID);
end
else
if msg ~= "" and msg ~= nil then
CEPGP_ShareTraffic(player, UnitName("player"), "Add GP +" .. amount .. " (" .. msg .. ")", EP, EP, GPB, GP);
else
CEPGP_ShareTraffic(player, UnitName("player"), "Add GP +" .. amount, EP, EP, GPB, GP);
end
end
end
CEPGP_UpdateTrafficScrollBar();
else
CEPGP_print(player .. " not found in guild roster - no GP given");
CEPGP_print("If this was a mistake, you can manually award them GP via the CEPGP guild menu");
end
end
function CEPGP_addEP(player, amount, msg)
if amount == nil then
CEPGP_print("Please enter a valid number", 1);
return;
end
amount = math.floor(amount);
local EP, GP = nil;
if CEPGP_tContains(CEPGP_roster, player, true) then
offNote = CEPGP_roster[player][5];
index = CEPGP_roster[player][1];
if offNote == "" or offNote == "Click here to set an Officer's Note" then
GuildRosterSetOfficerNote(index, "0," .. BASEGP);
offNote = "0," .. BASEGP;
end
EP,GP = CEPGP_getEPGP(offNote);
EPB = EP;
EP = tonumber(EP) + amount;
GP = tonumber(GP);
if GP < BASEGP then
GP = BASEGP;
end
if EP < 0 then
EP = 0;
end
GuildRosterSetOfficerNote(index, EP .. "," .. GP);
if tonumber(amount) <= 0 then
if msg ~= "" and msg ~= nil then
amount = string.sub(amount, 2, string.len(amount));
SendChatMessage(amount .. " EP taken from " .. player .. " (" .. msg .. ")", CHANNEL, CEPGP_LANGUAGE, CHANNEL);
TRAFFIC[CEPGP_ntgetn(TRAFFIC)+1] = {
[1] = player,
[2] = UnitName("player"),
[3] = "Subtract EP -" .. amount .. " (" .. msg .. ")",
[4] = EPB,
[5] = EP,
[6] = GP,
[7] = GP
};
CEPGP_ShareTraffic(player, UnitName("player"), "Subtract EP -" .. amount .. " (" .. msg .. ")", EPB, EP, GP, GP);
else
amount = string.sub(amount, 2, string.len(amount));
SendChatMessage(amount .. " EP taken from " .. player, CHANNEL, CEPGP_LANGUAGE, CHANNEL);
TRAFFIC[CEPGP_ntgetn(TRAFFIC)+1] = {
[1] = player,
[2] = UnitName("player"),
[3] = "Subtract EP -" .. amount,
[4] = EPB,
[5] = EP,
[6] = GP,
[7] = GP
};
CEPGP_ShareTraffic(player, UnitName("player"), "Subtract EP -" .. amount, EPB, EP, GP, GP);
end
else
if msg ~= "" and msg ~= nil then
SendChatMessage(amount .. " EP added to " .. player .. " (" .. msg .. ")", CHANNEL, CEPGP_LANGUAGE, CHANNEL);
TRAFFIC[CEPGP_ntgetn(TRAFFIC)+1] = {
[1] = player,
[2] = UnitName("player"),
[3] = "Add EP +" .. amount .. " (" .. msg .. ")",
[4] = EPB,
[5] = EP,
[6] = GP,
[7] = GP
};
CEPGP_ShareTraffic(player, UnitName("player"), "Add EP +" .. amount .. " (" .. msg ..")", EPB, EP, GP, GP);
else
SendChatMessage(amount .. " EP added to " .. player, CHANNEL, CEPGP_LANGUAGE, CHANNEL);
TRAFFIC[CEPGP_ntgetn(TRAFFIC)+1] = {
[1] = player,
[2] = UnitName("player"),
[3] = "Add EP +" .. amount,
[4] = EPB,
[5] = EP,
[6] = GP,
[7] = GP
};
CEPGP_ShareTraffic(player, UnitName("player"), "Add EP +" .. amount, EPB, EP, GP, GP);
end
end
CEPGP_UpdateTrafficScrollBar();
else
CEPGP_print("Player not found in guild CEPGP_roster.", true);
end
end
function CEPGP_decay(amount, msg)
if amount == nil then
CEPGP_print("Please enter a valid number", 1);
return;
end
CEPGP_updateGuild();
local EP, GP = nil;
for name,_ in pairs(CEPGP_roster)do
EP, GP = CEPGP_getEPGP(CEPGP_roster[name][5]);
index = CEPGP_roster[name][1];
--[[if offNote == "" then
GuildRosterSetOfficerNote(index, 0 .. "," .. BASEGP);
else]]
--EP,GP = CEPGP_getEPGP(offNote);
EP = math.floor(tonumber(EP)*(1-(amount/100)));
GP = math.floor(tonumber(GP)*(1-(amount/100)));
if GP < BASEGP then
GP = BASEGP;
end
if EP < 0 then
EP = 0;
end
GuildRosterSetOfficerNote(index, EP .. "," .. GP);
--end
end
if tonumber(amount) <= 0 then
amount = string.sub(amount, 2, string.len(amount));
if msg ~= "" and msg ~= nil then
SendChatMessage("Guild EPGP inflated by " .. amount .. "% (" .. msg .. ")", CHANNEL, CEPGP_LANGUAGE, CHANNEL);
TRAFFIC[CEPGP_ntgetn(TRAFFIC)+1] = {"Guild", UnitName("player"), "Inflated EPGP +" .. amount .. "% (" .. msg .. ")"};
CEPGP_ShareTraffic("Guild", UnitName("player"), "Inflated EPGP +" .. amount .. "% (" .. msg .. ")");
else
SendChatMessage("Guild EPGP inflated by " .. amount .. "%", CHANNEL, CEPGP_LANGUAGE, CHANNEL);
TRAFFIC[CEPGP_ntgetn(TRAFFIC)+1] = {"Guild", UnitName("player"), "Inflated EPGP +" .. amount .. "%"};
CEPGP_ShareTraffic("Guild", UnitName("player"), "Inflated EPGP +" .. amount .. "%");
end
else
if msg ~= "" and msg ~= nil then
SendChatMessage("Guild EPGP decayed by " .. amount .. "% (" .. msg .. ")", CHANNEL, CEPGP_LANGUAGE, CHANNEL);
TRAFFIC[CEPGP_ntgetn(TRAFFIC)+1] = {"Guild", UnitName("player"), "Decay EPGP -" .. amount .. "% (" .. msg .. ")"};
CEPGP_ShareTraffic("Guild", UnitName("player"), "Decayed EPGP -" .. amount .. "% (" .. msg .. ")");
else
SendChatMessage("Guild EPGP decayed by " .. amount .. "%", CHANNEL, CEPGP_LANGUAGE, CHANNEL);
TRAFFIC[CEPGP_ntgetn(TRAFFIC)+1] = {"Guild", UnitName("player"), "Decay EPGP -" .. amount .. "%"};
CEPGP_ShareTraffic("Guild", UnitName("player"), "Decayed EPGP -" .. amount .. "%");
end
end
CEPGP_UpdateTrafficScrollBar();
end
function CEPGP_resetAll(msg)
local total = CEPGP_ntgetn(CEPGP_roster);
_G["CEPGP_frame"]:UnregisterEvent("GUILD_ROSTER_UPDATE");
if total > 0 then
for i = 1, total, 1 do
GuildRosterSetOfficerNote(i, "0,"..BASEGP);
end
end
_G["CEPGP_frame"]:RegisterEvent("GUILD_ROSTER_UPDATE");
if msg ~= "" and msg ~= nil then
TRAFFIC[CEPGP_ntgetn(TRAFFIC)+1] = {"Guild", UnitName("player"), "Cleared EPGP standings (" .. msg .. ")"};
CEPGP_ShareTraffic("Guild", UnitName("player"), "Cleared EPGP standings (" .. msg .. ")");
SendChatMessage("All EPGP standings have been cleared! (" .. msg .. ")", "GUILD", CEPGP_LANGUAGE);
else
TRAFFIC[CEPGP_ntgetn(TRAFFIC)+1] = {"Guild", UnitName("player"), "Cleared EPGP standings"};
CEPGP_ShareTraffic("Guild", UnitName("player"), "Cleared EPGP standings");
SendChatMessage("All EPGP standings have been cleared!", "GUILD", CEPGP_LANGUAGE);
end
CEPGP_UpdateTrafficScrollBar();
end