-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathLazyPig.lua
2199 lines (1970 loc) · 66.6 KB
/
LazyPig.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
LPCONFIG = {
DISMOUNT = true,
CAM = false,
GINV = true,
FINV = true,
SINV = nil,
DINV = true,
SUMM = true,
EBG = true,
LBG = true,
QBG = true,
RBG = true,
SBG = false,
AQUE = true,
LOOT = true,
EPLATE = false,
FPLATE = false,
HPLATE = false,
RIGHT = true,
ZG = 1,
DUEL = false,
NOSAVE = false,
GREEN = 2,
SPECIALKEY = true,
WORLDDUNGEON = false,
WORLDRAID = false,
WORLDBG = false,
WORLDUNCHECK = nil,
SPAM = true,
SPAM_UNCOMMON = true,
SPAM_RARE = true,
SHIFTSPLIT = true,
REZ = true,
GOSSIP = true,
SALVA = false
}
BINDING_HEADER_LP_HEADER = "_LazyPig";
BINDING_NAME_LOGOUT = "Logout";
BINDING_NAME_UNSTUCK = "Unstuck";
BINDING_NAME_RELOAD = "Reaload UI";
BINDING_NAME_DUEL = "Target WSG EFC/Duel Request-Cancel";
BINDING_NAME_WSGDROP = "Drop WSG Flag/Remove Slow Fall";
BINDING_NAME_MENU = "_LazyPig Menu";
local Original_SelectGossipActiveQuest = SelectGossipActiveQuest;
local Original_SelectGossipAvailableQuest = SelectGossipAvailableQuest;
local Original_SelectActiveQuest = SelectActiveQuest;
local Original_SelectAvailableQuest = SelectAvailableQuest;
local OriginalLootFrame_OnEvent = LootFrame_OnEvent;
local OriginalLootFrame_Update = LootFrame_Update;
local OriginalUseContainerItem = UseContainerItem;
local Original_SetItemRef = SetItemRef;
local Original_ChatFrame_OnEvent = ChatFrame_OnEvent;
local Original_StaticPopup_OnShow = StaticPopup_OnShow;
local roster_task_refresh = 0
local last_click = 0
local delayaction = 0
local tradedelay = 0
local bgstatus = 0
local save_check = 0
local save_time = 0
local tmp_splitval = 1
local passpopup = 0
local ctrltime = 0
local alttime = 0
local shift_time = 0
local ctrlalttime = 0
local ctrlshifttime = 0
local altshifttime = 0
local greenrolltime = 0
local timer_split = false
local player_summon_confirm = false
local player_summon_message = false
local player_bg_confirm = false
local player_bg_message = false
local afk_active = false
local dnd_active = false
local duel_active = false
local merchantstatus = false
local tradestatus = false
local mailstatus = false
local auctionstatus = false
local auctionbrowse = false
local bankstatus = false
local channelstatus = false
local battleframe = false
local wsgefc = nil
local WHITE = "|cffffffff"
local RED = "|cffff0000"
local GREEN = "|cff00ff00"
local BLUE = "|cff00eeee"
local ScheduleButton = {}
local ScheduleFunction = {}
local ScheduleSplit = {}
local QuestRecord = {}
local ActiveQuest = {}
local AvailableQuest = {}
local GreySell = {}
local ChatMessage = {{}, {}, INDEX = 1}
local ScheduleSplit = {}
local ScheduleSplitCount = {}
ScheduleSplit.active = nil
ScheduleSplit.sslot = {}
ScheduleSplit.dbag = {}
ScheduleSplit.dslot = {}
ScheduleSplit.sbag = {}
ScheduleSplit.count = {}
local LazyPigMenuObjects = {}
local LazyPigMenuStrings = {
[00]= "Need",
[01]= "Greed",
[02]= "Pass",
[10]= "Need",
[11]= "Greed",
[12]= "Pass",
[20]= "Dungeon",
[21]= "Raid",
[22]= "Battleground",
[23]= "Mute Permanently",
[30]= "GuildMates",
[31]= "Friends",
[32]= "Strangers",
[33]= "Idle while in BG or Queue",
[40]= "Show Friends",
[41]= "Show Enemies",
[42]= "Hide if Unchecked",
[50]= "Enter BG",
[51]= "Leave BG",
[52]= "Queue BG",
[53]= "Auto Release",
[54]= "Leader Queue Announce",
[55]= "Block BG Quest Sharing",
[60]= "Always",
[61]= "Warrior Shield/Druid Bear",
[70]= "Players' Spam",
[71]= "Uncommon Roll",
[72]= "Rare Roll",
[73]= "Poor-Common-Money Loot",
[90]= "Summon Auto Accept",
[91]= "Loot Window Auto Position",
[92]= "Improved Right Click",
[93]= "Easy Split/Merge (Shift+Right_Click)",
[94]= "Extended Camera Distance",
[95]= "Special Key Combinations",
[96]= "Duel Auto Decline (Shift to ByPass)",
[97]= "Instance Resurrection Accept OOC",
[98]= "Gossip Auto Processing",
[99]= "Character Auto-Save",
[100]= "Auto Dismount",
[101]= "Chat Spam Filter"
}
function LazyPig_OnLoad()
SelectGossipActiveQuest = LazyPig_SelectGossipActiveQuest;
SelectGossipAvailableQuest = LazyPig_SelectGossipAvailableQuest;
SelectActiveQuest = LazyPig_SelectActiveQuest;
SelectAvailableQuest = LazyPig_SelectAvailableQuest;
LootFrame_OnEvent = LazyPig_LootFrame_OnEvent;
LootFrame_Update = LazyPig_LootFrame_Update;
UseContainerItem = LazyPig_UseContainerItem;
SetItemRef = LazyPig_SetItemRef_OnEvent;
ChatFrame_OnEvent = LazyPig_ChatFrame_OnEvent;
StaticPopup_OnShow = LazyPig_StaticPopup_OnShow;
SLASH_LAZYPIG1 = "/lp";
SLASH_LAZYPIG2 = "/lazypig";
SlashCmdList["LAZYPIG"] = LazyPig_Command;
this:RegisterEvent("ADDON_LOADED");
this:RegisterEvent("PLAYER_LOGIN")
--this:RegisterEvent("PLAYER_ENTERING_WORLD")
end
function LazyPig_Command()
if LazyPigOptionsFrame:IsShown() then
LazyPigOptionsFrame:Hide()
LazyPigKeybindsFrame:Hide()
else
LazyPigOptionsFrame:Show()
if getglobal("LazyPigOptionsFrameKeibindsButton"):GetText() == "Hide Keybinds" then
LazyPigKeybindsFrame:Show()
end
end
end
function LazyPig_OnUpdate()
local current_time = GetTime();
local shiftstatus = IsShiftKeyDown();
local ctrlstatus = IsControlKeyDown();
local altstatus = IsAltKeyDown();
if shiftstatus then
shift_time = current_time
elseif altstatus and not ctrlstatus and current_time > alttime then
alttime = current_time + 0.75
elseif not altstatus and ctrlstatus and current_time > ctrltime then
ctrltime = current_time + 0.75
elseif not altstatus and not ctrlstatus or altstatus and ctrlstatus then
ctrltime = 0
alttime = 0
end
if ctrlstatus and not shiftstatus and altstatus and current_time > ctrlalttime then
ctrlalttime = current_time + 0.75
elseif ctrlstatus and shiftstatus and not altstatus and current_time > ctrlshifttime then
ctrlshifttime = current_time + 0.75
elseif not ctrlstatus and shiftstatus and altstatus and current_time > altshifttime then
altshifttime = current_time + 0.75
elseif ctrlstatus and shiftstatus and altstatus then
ctrlshifttime = 0
ctrlalttime = 0
altshifttime = 0
end
if shift_time == current_time then
if not (UnitExists("target") and UnitIsUnit("player", "target")) then
--
elseif not battleframe then
battleframe = current_time
elseif (current_time - battleframe) > 3 then
BattlefieldFrame:Show()
battleframe = current_time
end
elseif battleframe then
battleframe = nil
end
if LPCONFIG.SPECIALKEY then
if ctrlstatus and shiftstatus and altstatus and current_time > delayaction then
delayaction = current_time + 1
Logout();
elseif ctrlstatus and not shiftstatus and altstatus and not auctionstatus and not mailstatus and current_time > delayaction then
if tradestatus then
AcceptTrade();
elseif not tradestatus and UnitExists("target") and UnitIsPlayer("target") and UnitIsFriend("target", "player") and not UnitIsUnit("player", "target") and CheckInteractDistance("target", 2) and (current_time + 0.25) > ctrlalttime and current_time > tradedelay then
InitiateTrade("target");
delayaction = current_time + 2
end
elseif ctrlstatus and shiftstatus and not altstatus and UnitIsPlayer("target") and UnitIsFriend("target", "player") and current_time > delayaction and (current_time + 0.25) > ctrlshifttime then
delayaction = current_time + 1.5
FollowUnit("target");
elseif not ctrlstatus and shiftstatus and altstatus and UnitIsPlayer("target") and current_time > delayaction and (current_time + 0.25) > altshifttime then
delayaction = current_time + 1.5
InspectUnit("target");
end
if ctrlstatus and not shiftstatus and altstatus or passpopup > current_time then
if current_time > delayaction and not LazyPig_BindLootOpen() and not LazyPig_RollLootOpen() and LazyPig_GreenRoll() then
delayaction = current_time + 1
elseif current_time > delayaction then
for i=1,STATICPOPUP_NUMDIALOGS do
local frame = getglobal("StaticPopup"..i)
if frame:IsShown() then
--DEFAULT_CHAT_FRAME:AddMessage(frame.which)
if frame.which == "DEATH" and HasSoulstone() then
getglobal("StaticPopup"..i.."Button2"):Click();
if passpopup < current_time then delayaction = current_time + 0.5 end
elseif frame.which ~= "CONFIRM_SUMMON" and frame.which ~= "CONFIRM_BATTLEFIELD_ENTRY" and frame.which ~= "CAMP" and frame.which ~= "AREA_SPIRIT_HEAL" then --and release and
getglobal("StaticPopup"..i.."Button1"):Click();
if passpopup < current_time then delayaction = current_time + 0.5 end
end
end
end
end
end
if ctrlstatus and not shiftstatus and altstatus then
if current_time > delayaction then
if auctionstatus and AuctionFrameAuctions and AuctionFrameAuctions:IsVisible() and AuctionsCreateAuctionButton then
ScheduleButtonClick(AuctionsCreateAuctionButton, 0);
elseif auctionstatus and AuctionFrameBrowse and AuctionFrameBrowse:IsVisible() and BrowseBuyoutButton then
ScheduleButtonClick(BrowseBuyoutButton, 0.55);
elseif CT_MailFrame and CT_MailFrame:IsVisible() and CT_MailFrame.num > 0 and strlen(CT_MailNameEditBox:GetText()) > 0 and CT_Mail_AcceptSendFrameSendButton then
ScheduleButtonClick(CT_Mail_AcceptSendFrameSendButton, 1.25);
elseif GMailFrame and GMailFrame:IsVisible() and GMailFrame.num > 0 and strlen(GMailSubjectEditBox:GetText()) > 0 and GMailAcceptSendFrameSendButton then
ScheduleButtonClick(GMailAcceptSendFrameSendButton, 1.25);
elseif mailstatus and SendMailFrame and SendMailFrame:IsVisible() and SendMailMailButton then
ScheduleButtonClick(SendMailMailButton, 0);
elseif mailstatus and OpenMailFrame and OpenMailFrame:IsVisible() then
if OpenMailFrame.money and OpenMailMoneyButton then
ScheduleButtonClick(OpenMailMoneyButton, 0);
elseif OpenMailPackageButton then
ScheduleButtonClick(OpenMailPackageButton, 0);
end
end
end
LazyPig_AutoLeaveBG();
elseif not ctrlstatus and shiftstatus and altstatus and current_time > delayaction then
if auctionstatus and AuctionFrameBrowse and AuctionFrameBrowse:IsVisible() and BrowseBidButton then
ScheduleButtonClick(BrowseBidButton, 0.55);
end
end
end
if merchantstatus and shiftstatus and current_time > last_click and not CursorHasItem() then
last_click = current_time + 0.25
LazyPig_GreySellRepair();
end
if shiftstatus or altstatus then
if QuestFrameDetailPanel:IsVisible() then
AcceptQuest();
end
elseif QuestRecord["details"] and not shiftstatus then
LazyPig_RecordQuest();
end
if not afk_active and player_bg_confirm then
Check_Bg_Status();
end
if bgstatus ~= 0 and (bgstatus + 0.5) > current_time then
bgstatus = 0
Check_Bg_Status()
LazyPig_AutoLeaveBG()
end
if(current_time - roster_task_refresh) > 29 then
roster_task_refresh = current_time
GuildRoster();
ChatSpamClean();
end
if save_time ~= 0 and (current_time - save_time) > 3 and not GetBattlefieldWinner() and not UnitAffectingCombat("player") then
save_check = current_time
save_time = 0
SaveData();
end
if player_summon_confirm then
LazyPig_AutoSummon();
end
LazyPig_CheckSalvation();
ScheduleButtonClick();
ScheduleFunctionLaunch();
ScheduleItemSplit();
LazyPig_WatchSplit();
end
function ScheduleButtonClick(button, delay)
local current_time = GetTime()
if button and not ScheduleButton[button] then
delay = delay or 0.75
ScheduleButton[button] = current_time + delay
else
for blockindex,blockmatch in pairs(ScheduleButton) do
if current_time < delayaction then
ScheduleButton[blockindex] = nil
elseif current_time >= blockmatch then
blockindex:Click()
passpopup = current_time + 0.75
ScheduleButton[blockindex] = nil
end
end
end
end
function ScheduleFunctionLaunch(func, delay)
local current_time = GetTime()
if func and not ScheduleFunction[func] then
delay = delay or 0.75
ScheduleFunction[func] = current_time + delay
else
for blockindex,blockmatch in pairs(ScheduleFunction) do
if current_time >= blockmatch then
blockindex()
ScheduleFunction[blockindex] = nil
end
end
end
end
function LazyPig_OnEvent(event)
if (event == "ADDON_LOADED") and (arg1 == "_LazyPig") then
local LP_TITLE = GetAddOnMetadata("_LazyPig", "Title")
local LP_VERSION = GetAddOnMetadata("_LazyPig", "Version")
local LP_AUTHOR = GetAddOnMetadata("_LazyPig", "Author")
DEFAULT_CHAT_FRAME:AddMessage(LP_TITLE .. " v" .. LP_VERSION .. " by " .."|cffFF0066".. LP_AUTHOR .."|cffffffff".. " loaded, type".."|cff00eeee".." /lp".."|cffffffff for options")
elseif (event == "PLAYER_LOGIN") then
--if (event == "PLAYER_ENTERING_WORLD") then
-- this:UnregisterEvent("PLAYER_ENTERING_WORLD")
this:RegisterEvent("CHAT_MSG")
this:RegisterEvent("CHAT_MSG_SYSTEM")
this:RegisterEvent("PARTY_INVITE_REQUEST")
this:RegisterEvent("CONFIRM_SUMMON")
this:RegisterEvent("RESURRECT_REQUEST")
this:RegisterEvent("UPDATE_BATTLEFIELD_STATUS")
this:RegisterEvent("CHAT_MSG_BG_SYSTEM_ALLIANCE")
this:RegisterEvent("CHAT_MSG_BG_SYSTEM_HORDE")
this:RegisterEvent("CHAT_MSG_BG_SYSTEM_NEUTRAL")
this:RegisterEvent("BATTLEFIELDS_SHOW")
this:RegisterEvent("GOSSIP_SHOW")
this:RegisterEvent("QUEST_GREETING")
this:RegisterEvent("UI_ERROR_MESSAGE")
this:RegisterEvent("CHAT_MSG_LOOT")
--this:RegisterEvent("CHAT_MSG_MONEY")
this:RegisterEvent("QUEST_PROGRESS")
this:RegisterEvent("QUEST_COMPLETE")
this:RegisterEvent("START_LOOT_ROLL")
this:RegisterEvent("DUEL_REQUESTED")
this:RegisterEvent("MERCHANT_SHOW")
this:RegisterEvent("MERCHANT_CLOSED")
this:RegisterEvent("TRADE_SHOW")
this:RegisterEvent("TRADE_CLOSED")
this:RegisterEvent("MAIL_SHOW")
this:RegisterEvent("MAIL_CLOSED")
this:RegisterEvent("AUCTION_HOUSE_SHOW")
this:RegisterEvent("AUCTION_HOUSE_CLOSED")
this:RegisterEvent("BANKFRAME_OPENED")
this:RegisterEvent("BANKFRAME_CLOSED")
this:RegisterEvent("ZONE_CHANGED_NEW_AREA")
this:RegisterEvent("PLAYER_UNGHOST")
this:RegisterEvent("PLAYER_DEAD")
this:RegisterEvent("PLAYER_AURAS_CHANGED")
this:RegisterEvent("UPDATE_BONUS_ACTIONBAR")
this:RegisterEvent("UNIT_INVENTORY_CHANGED")
this:RegisterEvent("UI_INFO_MESSAGE")
LazyPigOptionsFrame = LazyPig_CreateOptionsFrame()
LazyPigKeybindsFrame = LazyPig_CreateKeybindsFrame()
LazyPig_CheckSalvation();
Check_Bg_Status();
LazyPig_AutoLeaveBG();
LazyPig_AutoSummon();
ScheduleFunctionLaunch(LazyPig_ZoneCheck, 6);
ScheduleFunctionLaunch(LazyPig_ZoneCheck2, 7);
ScheduleFunctionLaunch(LazyPig_RefreshNameplates, 0.25);
MailtoCheck();
if LPCONFIG.CAM then SetCVar("cameraDistanceMax",50) end
if LPCONFIG.LOOT then UIPanelWindows["LootFrame"] = nil end
QuestRecord["index"] = 0
--TargetUnit("player")
--SendChatMessage(".xp 8", "SAY") --qgaming version
--SendChatMessage(".exp 5", "SAY") --scriptcraft version
elseif (LPCONFIG.SALVA and (event == "PLAYER_AURAS_CHANGED" or event == "UPDATE_BONUS_ACTIONBAR" and LazyPig_PlayerClass("Druid", "player") or event == "UNIT_INVENTORY_CHANGED")) then
LazyPig_CheckSalvation()
elseif(event == "DUEL_REQUESTED") then
duel_active = true
if LPCONFIG.DUEL and not IsShiftKeyDown() then --dnd_active and
duel_active = nil
CancelDuel()
UIErrorsFrame:AddMessage(arg1.." - Duel Cancelled")
end
elseif(event == "PLAYER_DEAD") then
if LPCONFIG.RBG and LazyPig_BG() then
RepopMe();
end
elseif(event == "ZONE_CHANGED_NEW_AREA" or event == "PLAYER_UNGHOST") then
if event == "ZONE_CHANGED_NEW_AREA" then
tradestatus = nil
mailstatus = nil
auctionstatus = nil
bankstatus = nil
wsgefc = nil
end
ScheduleFunctionLaunch(LazyPig_RefreshNameplates, 0.25)
ScheduleFunctionLaunch(LazyPig_ZoneCheck, 5)
ScheduleFunctionLaunch(LazyPig_ZoneCheck, 6)
--DEFAULT_CHAT_FRAME:AddMessage(event);
elseif(event == "BANKFRAME_OPENED") then
bankstatus = true
tmp_splitval = 1
elseif(event == "BANKFRAME_CLOSED") then
bankstatus = false
LazyPig_EndSplit()
elseif(event == "AUCTION_HOUSE_SHOW") then
auctionstatus = true
auctionbrowse = nil
tmp_splitval = 1
elseif(event == "AUCTION_HOUSE_CLOSED") then
auctionstatus = false
LazyPig_EndSplit()
elseif(event == "MAIL_SHOW") then
mailstatus = true
tmp_splitval = 1
elseif(event == "MAIL_CLOSED") then
mailstatus = false
LazyPig_EndSplit()
elseif(event == "MERCHANT_SHOW") then
merchantstatus = true
GreySell = {}
elseif(event == "MERCHANT_CLOSED") then
merchantstatus = false
elseif(event == "TRADE_SHOW") then
tradestatus = true
tmp_splitval = 1
elseif(event == "TRADE_CLOSED") then
tradedelay = GetTime() + 1
tradestatus = false
LazyPig_EndSplit()
elseif(event == "START_LOOT_ROLL") then
LazyPig_ZGRoll(arg1)
elseif(event == "CHAT_MSG_LOOT") then
if (string.find(arg1 ,"You won") or string.find(arg1 ,"You receive")) and (string.find(arg1 ,"cffa335e") or string.find(arg1, "cff0070d") or string.find(arg1, "cffff840")) and not string.find(arg1 ,"Bijou") and not string.find(arg1 ,"Idol") and not string.find(arg1 ,"Shard") then
save_time = GetTime()
end
elseif(event == "UI_ERROR_MESSAGE") then
if(string.find(arg1, "mounted") or string.find(arg1, "while silenced")) and LPCONFIG.DISMOUNT then
UIErrorsFrame:Clear()
LazyPig_Dismount()
end
elseif (event == "UI_INFO_MESSAGE") then
if string.find(arg1 ,"Duel cancelled") then
duel_active = nil
end
elseif (event == "CHAT_MSG_SYSTEM") then
if arg1 == CLEARED_DND or arg1 == CLEARED_AFK then
dnd_active = false
afk_active = false
Check_Bg_Status()
elseif(string.find(arg1, string.sub(MARKED_DND, 1, string.len(MARKED_DND) -3))) then
afk_active = false
dnd_active = true
--if LPCONFIG.DUEL then CancelDuel() UIErrorsFrame:AddMessage("Duel Decline Atctive - DND") end
elseif(string.find(arg1, string.sub(MARKED_AFK, 1, string.len(MARKED_AFK) -2))) then
afk_active = true
if LPCONFIG.EBG and not LazyPig_Raid() and not LazyPig_Dungeon() then UIErrorsFrame:AddMessage("Auto Join BG Inactive - AFK") end
elseif string.find(arg1, "There is no such command") and (GetTime() - save_check) < 1 then
LPCONFIG.NOSAVE = GetRealmName()
DEFAULT_CHAT_FRAME:AddMessage("LazyPig:"..RED.."Auto Save Disabled - Command not Supported");
elseif LPCONFIG.AQUE and string.find(arg1 ,"Queued") and UnitIsPartyLeader("player") then
if UnitInRaid("player") then
SendChatMessage(arg1, "RAID");
elseif GetNumPartyMembers() > 1 then
SendChatMessage(arg1, "PARTY");
end
elseif string.find(arg1 ,"completed.") then
LazyPig_FixQuest(arg1)
QuestRecord["progress"] = nil
elseif string.find(arg1 ,"Duel starting:") or string.find(arg1 ,"requested a duel") then
duel_active = true
elseif string.find(arg1 ,"in a duel") then
duel_active = nil
end
elseif(event == "QUEST_GREETING") then
ActiveQuest = {}
AvailableQuest = {}
for i=1, GetNumActiveQuests() do
ActiveQuest[i] = GetActiveTitle(i).." "..GetActiveLevel(i)
end
for i=1, GetNumAvailableQuests() do
AvailableQuest[i] = GetAvailableTitle(i).." "..GetAvailableLevel(i)
end
LazyPig_ReplyQuest(event);
--DEFAULT_CHAT_FRAME:AddMessage("active_: "..table.getn(ActiveQuest))
--DEFAULT_CHAT_FRAME:AddMessage("available_: "..table.getn(AvailableQuest))
elseif(event == "GOSSIP_SHOW") then
local GossipOptions = {};
local dsc = nil
local gossipnr = nil
local gossipbreak = nil
local processgossip = IsShiftKeyDown() or LPCONFIG.GOSSIP
dsc,GossipOptions[1],_,GossipOptions[2],_,GossipOptions[3],_,GossipOptions[4],_,GossipOptions[5] = GetGossipOptions()
ActiveQuest = LazyPig_ProcessQuests(GetGossipActiveQuests())
AvailableQuest = LazyPig_ProcessQuests(GetGossipAvailableQuests())
if QuestRecord["qnpc"] ~= UnitName("target") then
QuestRecord["index"] = 0
QuestRecord["qnpc"] = UnitName("target")
end
if table.getn(AvailableQuest) ~= 0 or table.getn(ActiveQuest) ~= 0 then
gossipbreak = true
end
--DEFAULT_CHAT_FRAME:AddMessage("gossip: "..table.getn(GossipOptions))
--DEFAULT_CHAT_FRAME:AddMessage("active: "..table.getn(ActiveQuest))
--DEFAULT_CHAT_FRAME:AddMessage("available: "..table.getn(AvailableQuest))
for i=1, getn(GossipOptions) do
if GossipOptions[i] == "binder" then
local bind = GetBindLocation();
if not (bind == GetSubZoneText() or bind == GetZoneText() or bind == GetRealZoneText() or bind == GetMinimapZoneText()) then
gossipbreak = true
end
elseif gossipnr then
gossipbreak = true
elseif (GossipOptions[i] == "trainer" and dsc == "Reset my talents.") then
gossipbreak = false
elseif (GossipOptions[i] == "trainer" or GossipOptions[i] == "vendor" and processgossip or GossipOptions[i] == "battlemaster" and (LPCONFIG.QBG or processgossip) or GossipOptions[i] == "gossip" and (IsAltKeyDown() or IsShiftKeyDown() or string.find(dsc, "Teleport me to the Molten Core") and processgossip)) then
gossipnr = i
elseif GossipOptions[i] == "taxi" and processgossip then
gossipnr = i
LazyPig_Dismount();
end
end
if not gossipbreak and gossipnr then
SelectGossipOption(gossipnr);
else
LazyPig_ReplyQuest(event);
end
elseif(event == "QUEST_PROGRESS" or event == "QUEST_COMPLETE") then
LazyPig_ReplyQuest(event);
elseif (event == "CHAT_MSG_BG_SYSTEM_ALLIANCE" or event == "CHAT_MSG_BG_SYSTEM_HORDE") then
--DEFAULT_CHAT_FRAME:AddMessage(event.." - "..arg1);
LazyPig_Track_EFC(arg1)
elseif(event == "UPDATE_BATTLEFIELD_STATUS" and not afk_active or event == "CHAT_MSG_BG_SYSTEM_NEUTRAL" and arg1 and string.find(arg1, "wins!")) then
bgstatus = GetTime()
elseif(event == "BATTLEFIELDS_SHOW") then
LazyPig_QueueBG();
elseif (event == "CONFIRM_SUMMON") then
LazyPig_AutoSummon();
elseif(event == "PARTY_INVITE_REQUEST") then
local check1 = not LPCONFIG.DINV or LPCONFIG.DINV and not LazyPig_BG() and not LazyPig_Queue()
local check2 = LPCONFIG.GINV and IsGuildMate(arg1) or LPCONFIG.FINV and IsFriend(arg1) or not IsGuildMate(arg1) and not IsFriend(arg1) and LPCONFIG.SINV
if check1 and check2 then
AcceptGroupInvite();
end
elseif(event == "RESURRECT_REQUEST" and LPCONFIG.REZ) then
UIErrorsFrame:AddMessage(arg1.." - Resurrection")
TargetByName(arg1, true)
if GetCorpseRecoveryDelay() == 0 and (LazyPig_Raid() or LazyPig_Dungeon() or LazyPig_BG()) and UnitIsPlayer("target") and UnitIsVisible("target") and not UnitAffectingCombat("target") then
AcceptResurrect()
StaticPopup_Hide("RESURRECT_NO_TIMER");
StaticPopup_Hide("RESURRECT_NO_SICKNESS");
StaticPopup_Hide("RESURRECT");
end
TargetLastTarget();
end
--DEFAULT_CHAT_FRAME:AddMessage(event);
end
function LazyPig_StaticPopup_OnShow()
if this.which == "QUEST_ACCEPT" and LazyPig_BG() and LPCONFIG.SBG then
UIErrorsFrame:Clear();
UIErrorsFrame:AddMessage("Quest Blocked Successfully");
this:Hide();
else
Original_StaticPopup_OnShow();
end
end
function MailtoCheck(msg)
if MailTo_Option then -- to avoid conflicts with mailto addon
local disable = LPCONFIG.RIGHT or LPCONFIG.SHIFT
MailTo_Option.noshift = disable
MailTo_Option.noauction = disable
MailTo_Option.notrade = disable
MailTo_Option.noclick = disable
if msg then DEFAULT_CHAT_FRAME:AddMessage("_LazyPig: Warning Improved Right Click and Easy Split/Merge features may override MailTo addon functionality !") end
end
end
function LazyPig_Text(txt)
if txt then
LazyPigText:SetTextColor(0, 1, 0)
LazyPigText:SetText(txt)
LazyPigText:Show()
else
LazyPigText:SetText()
LazyPigText:Hide()
end
end
--code taken from quickloot
local function LazyPig_ItemUnderCursor()
if LPCONFIG.LOOT then
local index;
local x, y = GetCursorPosition();
local scale = LootFrame:GetEffectiveScale();
x = x / scale;
y = y / scale;
LootFrame:ClearAllPoints();
for index = 1, LOOTFRAME_NUMBUTTONS, 1 do
local button = getglobal("LootButton"..index);
if( button:IsVisible() ) then
x = x - 42;
y = y + 56 + (40 * index);
LootFrame:SetPoint("TOPLEFT", "UIParent", "BOTTOMLEFT", x, y);
return;
end
end
if LootFrameDownButton:IsVisible() then
x = x - 158;
y = y + 223;
else
if GetNumLootItems() == 0 then
HideUIPanel(LootFrame);
return
end
x = x - 173;
y = y + 25;
end
LootFrame:SetPoint("TOPLEFT", "UIParent", "BOTTOMLEFT", x, y);
end
end
function LazyPig_LootFrame_OnEvent(event)
OriginalLootFrame_OnEvent(event);
if(event == "LOOT_SLOT_CLEARED") then
LazyPig_ItemUnderCursor();
end
end
function LazyPig_LootFrame_Update()
OriginalLootFrame_Update();
LazyPig_ItemUnderCursor();
end
function IsFriend(name)
for i = 1, GetNumFriends() do
if GetFriendInfo(i) == name then
return true
end
end
return nil
end
function IsGuildMate(name)
if IsInGuild() then
local ngm=GetNumGuildMembers()
for i=1, ngm do
n, rank, rankIndex, level, class, zone, note, officernote, online, status, classFileName = GetGuildRosterInfo(i);
if strlower(n) == strlower(name) then
return true
end
end
end
return nil
end
function AcceptGroupInvite()
AcceptGroup();
StaticPopup_Hide("PARTY_INVITE");
PlaySoundFile("Sound\\Doodad\\BellTollNightElf.wav");
UIErrorsFrame:AddMessage("Group Auto Accept");
end
function LazyPig_AutoSummon()
local keyenter = IsAltKeyDown() and IsControlKeyDown() and not tradestatus and not mailstatus and not auctionstatus and GetTime() > delayaction and GetTime() > (tradedelay + 0.5)
if LPCONFIG.SUMM then
local expireTime = GetSummonConfirmTimeLeft()
if not player_summon_message and expireTime ~= 0 then
player_summon_message = true
player_summon_confirm = true
DEFAULT_CHAT_FRAME:AddMessage("LazyPig: Auto Summon in "..math.floor(expireTime).."s", 1.0, 1.0, 0.0);
elseif expireTime <= 3 or keyenter then
player_summon_confirm = false
player_summon_message = false
for i=1,STATICPOPUP_NUMDIALOGS do
local frame = getglobal("StaticPopup"..i)
if frame.which == "CONFIRM_SUMMON" and frame:IsShown() then
ConfirmSummon();
delayaction = GetTime() + 0.75
StaticPopup_Hide("CONFIRM_SUMMON");
end
end
elseif expireTime == 0 then
player_summon_confirm = false
player_summon_message = false
end
end
end
function Check_Bg_Status()
local bgStatus = {};
local player_bg_active = false
local player_bg_request = false
for i=1, MAX_BATTLEFIELD_QUEUES do
local status, mapName, instanceID = GetBattlefieldStatus(i);
bgStatus[i] = {};
bgStatus[i]["status"] = status;
bgStatus[i]["map"] = mapName;
bgStatus[i]["id"] = instanceID;
if(status == "confirm" ) then
player_bg_request = true
elseif((status == "active") and not (mapName == "Eastern Kingdoms") and not (mapName == "Kalimdor")) then
player_bg_active = true
end
end
player_bg_confirm = player_bg_request
if(player_bg_message and not player_bg_active and not player_bg_request) then
player_bg_message = false
end
if(not player_bg_active and player_bg_request) then
local index = 1
while bgStatus[index] do
if(bgStatus[index]["status"] == "confirm" ) then
LazyPig_AutoJoinBG(index, bgStatus[index]["map"]);
end
index = index + 1
end
end
end
function LazyPig_QueueBG()
if LPCONFIG.QBG then
for i=1, MAX_BATTLEFIELD_QUEUES do
local status = GetBattlefieldStatus(i);
if IsShiftKeyDown() and (status == "queued" or status == "confirm") then
AcceptBattlefieldPort(i,nil);
end
end
if (GetNumPartyMembers() > 0 or GetNumRaidMembers() > 0) and IsPartyLeader() then
JoinBattlefield(0,1);
else
JoinBattlefield(0);
end
ClearTarget();
BattlefieldFrameCancelButton:Click()
end
end
function LazyPig_AutoJoinBG(index, map_name)
local keyenter = IsAltKeyDown() and IsControlKeyDown() and not tradestatus and not mailstatus and not auctionstatus and GetTime() > delayaction and GetTime() > (tradedelay + 0.5)
if LPCONFIG.EBG or keyenter then
local expireTime = GetBattlefieldPortExpiration(index)/1000
expireTime = math.floor(expireTime);
if not player_bg_message and expireTime > 3 and GetTime() > delayaction then
player_bg_message = true
DEFAULT_CHAT_FRAME:AddMessage("LazyPig: Auto Join ".. map_name.." in "..expireTime.."s", 1.0, 1.0, 0.0)
elseif expireTime <= 3 or keyenter then
AcceptBattlefieldPort(index, true);
StaticPopup_Hide("CONFIRM_BATTLEFIELD_ENTRY")
delayaction = GetTime() + 0.75
if player_bg_message then
player_bg_message = false
end
end
end
end
function LazyPig_AutoLeaveBG()
local keyenter = IsAltKeyDown() and IsControlKeyDown()
if LPCONFIG.LBG or keyenter then
local bg_winner = GetBattlefieldWinner()
local winner_name = "Alliance"
if bg_winner ~= nil then
save_time = GetTime() + 15
if bg_winner == 0 then winner_name = "Horde" end
UIErrorsFrame:Clear();
UIErrorsFrame:AddMessage(winner_name.." Wins");
LeaveBattlefield();
end
end
end
function SaveData()
if LPCONFIG.NOSAVE ~= GetRealmName() then
SendChatMessage(".save", "SAY");
UIErrorsFrame:Clear()
UIErrorsFrame:AddMessage("Character Saved");
end
end
function LazyPig_BagReturn(find)
local link = nil
local bagslots = nil
for bag=0,NUM_BAG_FRAMES do
bagslots = GetContainerNumSlots(bag)
if bagslots and bagslots > 0 then
for slot=1,bagslots do
link = GetContainerItemLink(bag, slot)
if not find and not link or find and link and string.find(link, find) then
return bag, slot
end
end
end
end
return nil
end
function LazyPig_ZGRoll(id)
RollReturn = function()
local txt = ""
if LPCONFIG.ZG == 1 then
txt = "NEED"
elseif LPCONFIG.ZG == 2 then
txt = "GREED"
elseif LPCONFIG.ZG == 0 then
txt = "PASS"
end
return txt
end
if LPCONFIG.ZG then
local _, name, _, quality = GetLootRollItemInfo(id);
if string.find(name ,"Hakkari Bijou") or string.find(name ,"Coin") then
RollOnLoot(id, LPCONFIG.ZG);
local _, _, _, hex = GetItemQualityColor(quality)
DEFAULT_CHAT_FRAME:AddMessage("LazyPig: Auto "..hex..RollReturn().." "..GetLootRollItemLink(id))
return
end
if string.find(name ,"Necrotic Rune") then
RollOnLoot(id, 2);
local _, _, _, hex = GetItemQualityColor(quality)
DEFAULT_CHAT_FRAME:AddMessage("LazyPig: Auto "..hex.."GREED "..GetLootRollItemLink(id))
for i=1,STATICPOPUP_NUMDIALOGS do
local frame = getglobal("StaticPopup"..i)
if frame:IsShown() then
getglobal("StaticPopup"..i.."Button1"):Click();
end
end
return
end
if string.find(name ,"Corrupted Sand") then
RollOnLoot(id, 2);
local _, _, _, hex = GetItemQualityColor(quality)
DEFAULT_CHAT_FRAME:AddMessage("LazyPig: Auto "..hex.."GREED "..GetLootRollItemLink(id))
for i=1,STATICPOPUP_NUMDIALOGS do
local frame = getglobal("StaticPopup"..i)
if frame:IsShown() then
getglobal("StaticPopup"..i.."Button1"):Click();
end
end
return
end
end
end
function LazyPig_GreenRoll()
RollReturn = function()
local txt = ""
if LPCONFIG.GREEN == 1 then
txt = "NEED"
elseif LPCONFIG.GREEN == 2 then
txt = "GREED"
elseif LPCONFIG.GREEN == 0 then
txt = "PASS"
end
return txt
end
local pass = nil
if LPCONFIG.GREEN then
for i=1, NUM_GROUP_LOOT_FRAMES do
local frame = getglobal("GroupLootFrame"..i);
if frame:IsVisible() then
local id = frame.rollID
local _, name, _, quality = GetLootRollItemInfo(id);
if quality == 2 then
RollOnLoot(id, LPCONFIG.GREEN);
local _, _, _, hex = GetItemQualityColor(quality)