-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathloot.lua
executable file
·8024 lines (7907 loc) · 137 KB
/
loot.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
local function debug(str)
--tinsert(GogoLoot_Config.logs, str)
--print(str)
end
local itemBindings = nil -- populated later
local internalIgnoreList = nil -- populated later
-- used clean up the above tables
local function valToKey(...)
local newList = {}
for _, t in pairs({...}) do
for _, id in pairs(t) do
newList[id] = true
end
end
return newList
end
GogoLoot = {}
CONFIG_VERSION = 10
function GogoLoot:BuildConfig()
GogoLoot_Config = {
["speedyLoot"] = true,
["enabled"] = true,
["autoRoll"] = true,
["autoConfirm"] = false,
["autoRollThreshold"] = 2,
["players"] = {},
["autoGreenRolls"] = "greed"
}
GogoLoot_Config.ignoredItemsSolo = {
[4500] = true,
[11732] = true,
[11733] = true,
[11734] = true,
[11736] = true,
[11737] = true,
[12662] = true,
[12800] = true,
[12811] = true,
[18332] = true,
[18333] = true,
[18334] = true,
[18335] = true,
[18401] = true,
[20520] = true,
}
GogoLoot_Config.ignoredItemsMaster = {
[12662] = true,
[17966] = true,
[19872] = true,
[19902] = true,
[19914] = true,
[21218] = true,
[21321] = true,
[21323] = true,
[21324] = true,
}
if string.byte(GetBuildInfo(), 1) == 50 then -- tbc
GogoLoot_Config.ignoredItemsSolo = {}
for _, v in pairs({
29739,
20520,
12662,
29740,
30183,
23572
}) do
GogoLoot_Config.ignoredItemsSolo[v] = true
GogoLoot_Config.ignoredItemsMaster[v] = true
end
end
GogoLoot_Config.softres = {}
GogoLoot_Config.softres.profiles = {}
GogoLoot_Config._version = CONFIG_VERSION
end
local ItemInfoCache = {}
local ItemIDCache = {}
GogoLoot.validBOPInstances = {
[249] = true, -- onyxia
[309] = true, -- ZG
[409] = true, -- molten core
[469] = true, -- BWL
[509] = true, -- AQ20
[531] = true, -- AQ40
[533] = true, -- naxx
[532] = true, -- kara
[565] = true, -- gruuls
[544] = true, -- magt
[548] = true, -- serpentshrine
[550] = true, -- the eye
[534] = true, -- hyjal
[564] = true, -- black temple
[568] = true, -- za
[580] = true, -- sunwell
}
GogoLoot.validFilters = {
["artifact"] = true,
["orange"] = true,
["purple"] = true,
["blue"] = true,
["green"] = true,
["white"] = true,
["gray"] = true,
["all"] = true,
}
local colorToRarity = {
["9d9d9d"] = 0,
["ffffff"] = 1,
["1eff00"] = 2,
["0070dd"] = 3,
["a335ee"] = 4,
["ff8000"] = 5
}
local badErrors = {
["You can't loot that item now."] = true,
["You don't have permission to loot that corpse."] = true
}
GogoLoot.rarityToText = {
[0] = "gray",
[1] = "white",
[2] = "green",
[3] = "blue",
[4] = "purple",
[5] = "orange",
[6] = "artifact"
}
GogoLoot.textToName = {
["gray"] = "|cff9d9d9dPoor|r",
["white"] = "|cffffffffCommon|r",
["green"] = "|cff1eff00Uncommon|r",
["blue"] = "|cff0070ddRare|r",
["purple"] = "|cffa335eeEpic|r",
["orange"] = "|cffff8000Legendary|r",
}
GogoLoot.textToLink = {
["gray"] = "Poor Items",
["white"] = "Common Items",
["green"] = "Uncommon Items",
["blue"] = "Rare Items",
["purple"] = "Epic Items",
["orange"] = "Legendary Items",
}
GogoLoot.textToRarity = {}
for k,v in pairs(GogoLoot.rarityToText) do
GogoLoot.textToRarity[v] = k
end
function GogoLoot:UnitName(key)
-- if we are on classic era, add realm name
-- this is safe to run on TBC too as the normal function returns no realm
local name, realm = UnitName(key)
if name and realm then
name = name .. "-" .. realm
end
return name
end
function GogoLoot:HideNotification()
if GogoLoot.notificationFrames then
for _, frame in pairs(GogoLoot.notificationFrames) do
frame:Hide()
end
end
end
function GogoLoot:CreateNotification()
local f = CreateFrame("Frame")
f:SetParent(UIParent)
f:SetWidth(400)
f:SetHeight(54)
f:SetPoint("CENTER", UIParent, "CENTER", -200,0)
f:Show()
local l = f:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
l:SetAllPoints(f)
--l:SetJustifyH("LEFT")
l:Show()
local f2 = CreateFrame("Frame")
f2:SetParent(UIParent)
f2:SetWidth(400)
f2:SetHeight(54)
f2:SetPoint("CENTER", UIParent, "CENTER", -200,-20)
f2:Show()
local l2 = f2:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
l2:SetAllPoints(f2)
--l2:SetJustifyH("LEFT")
l2:SetText("|cFF00FF80<GogoLoot Team>|r")
l2:Show()
GogoLoot.notificationFrames = {
l, l2, f, f2
}
end
function GogoLoot:ShowNotification(text)
if not GogoLoot.notificationFrames then
GogoLoot:CreateNotification()
end
GogoLoot.notificationFrames[1]:SetText("|cFF00FF80"..text.."|r")
for _, frame in pairs(GogoLoot.notificationFrames) do
frame:Show()
end
end
function GogoLoot:GetGroupMemberNames()
--[[local ret = {UnitName("Player")}
for i=1,GetNumSubgroupMembers() do
end]]
local fullRaid = {}
local playerSubgroup = nil
local playerName = GogoLoot:UnitName("Player")
for i=1,40 do
local name, rank, subGroup = GetRaidRosterInfo(i)
if name then
--[[if name == playerName then -- only include players in the current subgroup
playerSubgroup = subGroup
end]]
tinsert(fullRaid, {name, rank, subGroup})
end
end
local filtered = {}
local hasPlayer = false
for _, entry in pairs(fullRaid) do
--if entry[3] == playerSubgroup then
filtered[strlower(entry[1])] = entry[1]--tinsert(filtered, entry)
hasPlayer = true
--end
end
if not hasPlayer then -- hack: add ourselves if there are no group members
filtered[strlower(playerName)] = playerName
end
return filtered
end
function GogoLoot:areWeMasterLooter()
local masterLooter = select(2, GetLootMethod()) -- todo: cache this
return 0 == masterLooter--masterLooter and (masterLooter == 0 or (UnitName("player") == GetRaidRosterInfo(masterLooter)))
end
GogoLoot.canOpenWindow = false
function GogoLoot:showLootFrame(reason, force)
if InCombatLockdown() then
debug("Tried to show loot frame while in combat! Blizzard restricted this.")
return
end
if GogoLoot_Config.speedyLoot and (force or GogoLoot.canOpenWindow) then
debug("Showing loot frame because ".. reason)
GogoLoot.canOpenWindow = false
LootFrame:GetScript("OnEvent")(LootFrame, "LOOT_OPENED")
else
--print("Didnt open window because")
--print(GogoLoot.canOpenWindow)
--print(GogoLoot_Config.speedyLoot)
end
end
function GogoLoot:VacuumSlotSolo(index)
debug("Vacuum slot solo " .. tostring(index))
pcall(LootSlot, index)
end
function GogoLoot:VacuumSlot(index, playerIndex, validPreviouslyHack)
debug("Vacuum slot " .. tostring(index) .. " " .. tostring(playerIndex) .. " " .. tostring(GogoLoot:areWeMasterLooter()))
if index and playerIndex and GogoLoot:areWeMasterLooter() then
debug("We are master looter")
local lootLink = GetLootSlotLink(index)
if not lootLink or strlen(lootLink) < 8 then
debug("Invalid item link")
return false -- likely gold TODO: CHECK THIS
end
if lootLink and not ItemInfoCache[lootLink] then
ItemIDCache[lootLink] = {string.find(lootLink,"|?c?f?f?(%x*)|?H?([^:]*):?(%d+):?(%d*):?(%d*):?(%d*):?(%d*):?(%d*):?(%-?%d*):?(%-?%d*):?(%d*):?(%d*):?(%-?%d*)|?h?%[?([^%[%]]*)%]?|?h?|?r?")}
ItemInfoCache[lootLink] = {GetItemInfo(ItemIDCache[lootLink][5])} -- note: GetItemInfo may not be available right away! test this
end
local color = ItemIDCache[lootLink][3]
local rarity = colorToRarity[color] or 6
local doLoot = rarity < 5
if doLoot and rarity >= GetLootThreshold() then
if rarity == 1 then
doLoot = "quest" ~= strlower(ItemInfoCache[lootLink][6] or "")
end
end
local id = tonumber(ItemIDCache[lootLink][5])
debug("ShouldLoot " .. tostring(index) .. " = " .. tostring(doLoot) .. " " .. tostring(rarity) .. " " .. tostring(color) .. " " .. lootLink)
if id and doLoot
and (not internalIgnoreList[id])
and ItemInfoCache[lootLink]
and ((ItemInfoCache[lootLink][12] ~= 9 -- recipes
and (not (ItemInfoCache[lootLink][12] == 15 and ItemInfoCache[lootLink][13] == 2)) -- pets
and (not (ItemInfoCache[lootLink][12] == 15 and ItemInfoCache[lootLink][13] == 5)) -- mounts
) or (GogoLoot_Config.professionRollDisable and itemBindings[id] ~= 1))
and (not GogoLoot_Config.ignoredItemsMaster[id]) -- items from config UI
and ((not GogoLoot_Config.disableBOP) or (not itemBindings[id]) or itemBindings[id] ~= 1) -- check if item is BOP, and check disable BOP config option
and ((not itemBindings[id]) or itemBindings[id] ~= 4) -- check if the item is a quest item
and (itemBindings[id] ~= 1 or GogoLoot.validBOPInstances[select(8, GetInstanceInfo())]) then -- make sure we are inside an instance that allows loot trading
local softresResult = GogoLoot:HandleSoftresLoot(id, playerIndex, index, GetLootSourceInfo(index)) -- todo: player list
local targetPlayerName = GogoLoot_Config.players[GogoLoot.rarityToText[rarity]] or strlower(GogoLoot:UnitName("Player"))--GogoLoot_Config.players["all"]
if softresResult and type(softresResult) == "table" then
debug("Softres roll taking place")
if not GogoLoot.softresRemoveRoll[index] then
GogoLoot.softresRemoveRoll[index] = {}
end
for _, player in pairs(softresResult) do
local lower = strlower(player)
GogoLoot.softresRemoveRoll[index][playerIndex[lower]] = {lower, id}
end
return true -- softres roll taking place
else
if softresResult then
targetPlayerName = strlower(softresResult) -- loot to this player
debug("Softres loot going to " .. targetPlayerName)
end
if targetPlayerName == "standardLootWindow" then
debug("Standard loot window target")
return true -- open loot window
end
-- this redirects loot to the "all" player if the specific players are not available
--local playerID = playerIndex[GogoLoot_Config.players[rarityToText[rarity]]] or playerIndex[GogoLoot_Config.players["all"]]
if targetPlayerName then
debug("Looting to " .. targetPlayerName)
local playerID = playerIndex[targetPlayerName]
if playerID then
validPreviouslyHack[targetPlayerName] = true
GiveMasterLoot(index, playerID, true)
return false
else
debug("Player " .. targetPlayerName .. " has no ID!")
if validPreviouslyHack[targetPlayerName] then -- we already looted it (hack to fix loot window, refactor this later)
return false
end
end
else
debug("No player to loot! " .. GogoLoot.rarityToText[rarity])
end
end
end
end
return true--LootSlot(index)
end
function hookAutoNeed()
--/dump GetLootRollItemLink(GroupLootFrame1.rollID)
for i=1,16 do
local frame = _G["GroupLootFrame" .. tostring(i)]
if frame then
debug("Hooking " .. tostring(i))
frame:HookScript("OnShow", function()
--frame.GreedButton:GetScript("OnClick")(frame.GreedButton)
--StaticPopup1Button1:GetScript("OnClick")(StaticPopup1Button1)
end)
end
end
--/run GroupLootFrame2.NeedButton:GetScript("OnClick")(GroopLootFrame2.NeedButton)
--/run StaticPopup1Button1:GetScript("OnClick")(StaticPopup1Button1)
end
function GogoLoot:AnnounceNeeds()
if not IsInGroup() then
return
end
local types = nil
if GogoLoot_Config.autoGreenRolls == "need" and GogoLoot_Config.autoBlueRolls == "need" and GogoLoot_Config.autoPurpleRolls == "need" then
types = "Greens, Blues, and Purples"
else
if GogoLoot_Config.autoGreenRolls == "need" then
if not types then
types = "Greens"
else
types = types .. " and Greens"
end
end
if GogoLoot_Config.autoBlueRolls == "need" then
if not types then
types = "Blues"
else
types = types .. " and Blues"
end
end
if GogoLoot_Config.autoPurpleRolls == "need" then
if not types then
types = "Purples"
else
types = types .. " and Purples"
end
end
end
if types then
SendChatMessage(string.format(GogoLoot.AUTO_NEED_WARNING, types), UnitInRaid("Player") and "RAID" or "PARTY")
end
end
function GogoLoot:EventHandler(events, evt, arg, message, a, b, c, ...)
--debug(evt)
--if ("LOOT_READY" == evt or "LOOT_OPENED" == evt) and not canLoot then
-- canOpenWindow = true
--[[if "LOOT_BIND_CONFIRM" == evt and GogoLoot_Config.autoConfirm then
local id = select(1, GetLootSlotInfo(arg))
if id and (not internalIgnoreList[id]) and (not GogoLoot_Config.ignoredItemsMaster[id]) and (not GogoLoot_Config.ignoredItemsSolo[id]) then -- items from config UI
lastItemHidden = true
ConfirmLootSlot(arg)
else
lastItemHidden = false
end
else]]
GogoLoot:TradeEvent(evt, arg, message, a, b, c, ...)
if ("ADDON_LOADED" == evt) then
if ("GogoLoot" == arg) then
events:UnregisterEvent("ADDON_LOADED")
GogoLoot:Initialize(events)
end
elseif "LOOT_READY" == evt then
lootAPIOpen = true
elseif ("LOOT_OPENED" == evt) and canLoot then
debug("LootReady! " .. evt)
GogoLoot.canOpenWindow = true
if GetCVarBool("autoLootDefault") ~= IsModifiedClick("AUTOLOOTTOGGLE") then
if not GogoLoot_Config.enabled then
GogoLoot:showLootFrame("GogoLoot disabled")
else
if not GogoLoot:areWeMasterLooter() then
local index = GetNumLootItems()
local hasNormalLoot = false
for i=1,index do
local result = GogoLoot:VacuumSlotSolo(index)
hasNormalLoot = hasNormalLoot or couldntLoot
end
if hasNormalLoot then
GogoLoot:showLootFrame("has normal loot solo")
end
else
canLoot = false
local lootStep = 1
local validPreviouslyHack = {}
local function incrementLootStep()
lootStep = lootStep + 1
if lootStep > GetNumLootItems() then
lootStep = 1
end
end
local function doLootStep()
debug("DoLootStep " .. tostring(lootStep))
local index = GetNumLootItems()
local playerIndex = {}
while index > 0 do -- we run this in its own loop to ensure the player name is available for all slots. Triggering a master loot event can mess with it
for i = 1, GetNumGroupMembers() do
local playerAtIndex = GetMasterLootCandidate(index, i)
if playerAtIndex and not playerIndex[index] then
playerIndex[index] = {}
end
if playerAtIndex then
playerIndex[index][strlower(playerAtIndex)] = i
end
end
index = index - 1
end
if playerIndex[lootStep] and GogoLoot:VacuumSlot(lootStep, playerIndex[lootStep], validPreviouslyHack) then -- normal loot, stop ticking
--if lootTicker then
-- debug("Cancelled loot ticker [1]")
-- lootTicker:Cancel()
-- lootTicker = nil
--end
GogoLoot:showLootFrame("has normal loot")
incrementLootStep()
return true
end
if lootStep > GetNumLootItems() and lootTicker then
debug("Cancelled loot ticker [1]")
lootTicker:Cancel()
lootTicker = nil
return true
end
incrementLootStep()
end
if lootTicker then
debug("Cancelled loot ticker [2]")
lootTicker:Cancel()
lootTicker = nil
end
local hadNormalLoot = false
--for i=1,min(5, GetNumLootItems()) do -- do 1 full iteration right away, up to 5 items
-- hadNormalLoot = doLootStep() or hadNormalLoot
--end
if not hadNormalLoot then
debug("There is loot, continuing timer...")
lootTicker = C_Timer.NewTicker(0.05, doLootStep, 64)
end
end
end
else
GogoLoot:showLootFrame("autoloot disabled")
end
elseif "LOOT_CLOSED" == evt then
lootAPIOpen = false
canLoot = true
GogoLoot.canOpenWindow = false
if lootTicker then
debug("Cancelled loot ticker [3]")
lootTicker:Cancel()
lootTicker = nil
end
elseif "START_LOOT_ROLL" == evt then
local rollid = tonumber(arg)
if rollid and GogoLoot_Config.autoRoll then
local itemLink = GetLootRollItemLink(rollid)
if itemLink then
debug(itemLink)
local data = {string.find(itemLink,"|?c?f?f?(%x*)|?H?([^:]*):?(%d+):?(%d*):?(%d*):?(%d*):?(%d*):?(%d*):?(%-?%d*):?(%-?%d*):?(%d*):?(%d*):?(%-?%d*)|?h?%[?([^%[%]]*)%]?|?h?|?r?")}
debug(data[5])
local itemID = tonumber(data[5])
if itemID then
if not itemLink or strlen(itemLink) < 8 then
debug("Invalid item link")
return -- likely gold TODO: CHECK THIS
end
if itemLink and not ItemInfoCache[itemLink] then
ItemIDCache[itemLink] = {string.find(itemLink,"|?c?f?f?(%x*)|?H?([^:]*):?(%d+):?(%d*):?(%d*):?(%d*):?(%d*):?(%d*):?(%-?%d*):?(%-?%d*):?(%d*):?(%d*):?(%-?%d*)|?h?%[?([^%[%]]*)%]?|?h?|?r?")}
ItemInfoCache[itemLink] = {GetItemInfo(itemID)} -- note: GetItemInfo may not be available right away! test this
end
if (not itemBindings[itemID]) or itemBindings[itemID] ~= 1 then -- not bind on pickup
if ItemInfoCache[itemLink] and (not GogoLoot_Config.ignoredItemsSolo[itemID]) and (not internalIgnoreList[itemID]) and ((ItemInfoCache[itemLink][12] ~= 9 -- recipes
and (not (ItemInfoCache[itemLink][12] == 15 and ItemInfoCache[itemLink][13] == 2)) -- pets
and (not (ItemInfoCache[itemLink][12] == 15 and ItemInfoCache[itemLink][13] == 5)) -- mounts
) or (GogoLoot_Config.professionRollDisable and itemBindings[id] ~= 1)) then
-- we should auto need or greed this
-- find desired roll behavior for item type
local rarity = colorToRarity[data[3]]
local action = nil
if rarity == 2 then -- green
if GogoLoot_Config.autoGreenRolls then
if GogoLoot_Config.autoGreenRolls == "need" then
action = 1
elseif GogoLoot_Config.autoGreenRolls == "greed" then
action = 2
end
end
elseif rarity == 3 then -- blue
if GogoLoot_Config.autoBlueRolls then
if GogoLoot_Config.autoBlueRolls == "need" then
action = 1
elseif GogoLoot_Config.autoBlueRolls == "greed" then
action = 2
end
end
elseif rarity == 4 then -- epic
if GogoLoot_Config.autoPurpleRolls then
if GogoLoot_Config.autoPurpleRolls == "need" then
action = 1
elseif GogoLoot_Config.autoPurpleRolls == "greed" then
action = 2
end
end
end
if action then
debug("Rolling on loot: " .. tostring(rollid) .. " thresh: " .. tostring(action))
RollOnLoot(rollid, action)
end
end
end
end
end
end
--print(arg)
--print(message)
elseif "LOOT_BIND_CONFIRM" == evt then
GogoLoot:showLootFrame("bind confirm")
elseif "UI_ERROR_MESSAGE" == evt and message and (message == ERR_ITEM_MAX_COUNT or message == ERR_INV_FULL or string.match(strlower(message), "inventory") or string.match(strlower(message), "loot")) and not badErrors[message] then
debug(message)
if lootTicker then
debug("Cancelled loot ticker [4]")
lootTicker:Cancel()
lootTicker = nil
end
GogoLoot:showLootFrame("inventory error " .. message)
elseif "BAG_UPDATE" == evt and GogoLoot_Config.enableAutoGray and WOW_PROJECT_ID ~= WOW_PROJECT_BURNING_CRUSADE_CLASSIC then
-- auto gray
--debug("BagUpdate!")
if arg and tonumber(arg) then
local slt = GetContainerNumSlots(arg)
for i=1,slt do
local dat = {GetContainerItemInfo(arg, i)}
if dat[4] == 0 then
PickupContainerItem(arg, i)
DeleteCursorItem()
end
end
end
--print(message)
--print(a)
--print(b)
--print(c)
--print(arg)
elseif "GROUP_ROSTER_UPDATE" == evt then
local inGroup = IsInGroup()
if inGroup ~= GogoLoot.isInGroup then
GogoLoot.isInGroup = inGroup
if inGroup then -- we have just joined a group
if GetLootMethod() == "group" then
GogoLoot:AnnounceNeeds()--SendChatMessage(string.format(GogoLoot.AUTO_ROLL_ENABLED, 1 == GogoLoot_Config.autoRollThreshold and "Need" or "Greed"), UnitInRaid("Player") and "RAID" or "PARTY")
end
else -- we left, clear group-specific settings
GogoLoot_Config.players = {}
GogoLoot_Config.softres.profiles.current = nil
GogoLoot_Config.softres.profiles._current_data = nil
end
end
elseif "PARTY_LOOT_METHOD_CHANGED" == evt and GogoLoot:areWeMasterLooter() and GetLootMethod() == "master" then
GogoLoot:BuildUI()
elseif "LOOT_SLOT_CLEARED" == evt then
--print("LSC: " .. tostring(GetLootSlotInfo(tonumber(arg))))
GogoLoot:HandleSoftresLooted(arg)
elseif "PARTY_LOOT_METHOD_CHANGED" == evt and GetLootMethod() == "group" then
GogoLoot:AnnounceNeeds()
-- SendChatMessage(string.format(GogoLoot.AUTO_ROLL_ENABLED, 1 == GogoLoot_Config.autoRollThreshold and "Need" or "Greed"), UnitInRaid("Player") and "RAID" or "PARTY")
elseif "MODIFIER_STATE_CHANGED" == evt and not canLoot then
if GetCVarBool("autoLootDefault") == IsModifiedClick("AUTOLOOTTOGGLE") then
GogoLoot:showLootFrame("modifier state changed")
end
elseif "PLAYER_REGEN_DISABLED" == evt then
if GogoLoot_Config.speedyLoot then
LootFrame:RegisterEvent('LOOT_OPENED')
end
elseif "PLAYER_REGEN_ENABLED" == evt then
if GogoLoot_Config.speedyLoot then
LootFrame:UnregisterEvent('LOOT_OPENED')
end
elseif "PLAYER_ENTERING_WORLD" == evt then -- init config default
if (not GogoLoot_Config) or (not GogoLoot_Config._version) or GogoLoot_Config._version < CONFIG_VERSION then
GogoLoot:BuildConfig()
end
GogoLoot.isInGroup = IsInGroup() -- used to detect when we joined a group
if GogoLoot.isInGroup then
C_Timer.After(0.5, function()
if GetLootMethod() == "group" and select(5, GetInstanceInfo()) ~= 0 then
GogoLoot:AnnounceNeeds() --SendChatMessage(string.format(GogoLoot.AUTO_ROLL_ENABLED, 1 == GogoLoot_Config.autoRollThreshold and "Need" or "Greed"), UnitInRaid("Player") and "RAID" or "PARTY")
end
end)
end
if select(5, GetInstanceInfo()) == 0 then
GogoLoot._inInstance = false
elseif GogoLoot._inInstance == false then
GogoLoot._inInstance = true
end
for id in pairs(GogoLoot_Config.ignoredItemsSolo) do
GetItemInfo(id)
end
for id in pairs(GogoLoot_Config.ignoredItemsMaster) do
GetItemInfo(id)
end
if GogoLoot_Config.speedyLoot and not InCombatLockdown() then
LootFrame:UnregisterEvent('LOOT_OPENED')
end
local creatorText = "\124TInterface\\TargetingFrame\\UI-RaidTargetingIcon_4.png:0\124t GogoLoot : Team Member"
GameTooltip:HookScript("OnTooltipSetUnit", function(self)
local name, unit = self:GetUnit()
if name and unit and GogoLoot:IsCreator(name, UnitFactionGroup(unit)) then
--if (not UnitInRaid(unit)) and (not UnitInParty(unit)) then
-- GogoLoot:ShowNotification(name)
--end
-- ensure its not already added (blizzard bug)
local alreaydAdded = false
for i = 1, GameTooltip:NumLines() do
if _G["GameTooltipTextLeft" .. tostring(i)]:GetText() == creatorText then
alreaydAdded = true
break
end
end
if not alreaydAdded then
GameTooltip:AddLine(creatorText)
end
else
--GogoLoot:HideNotification()
end
end)
if not GogoLoot_Config.logs then
GogoLoot_Config.logs = {}
end
debug("Started up!")
if not GogoLoot._has_done_conflict_check then
GogoLoot._has_done_conflict_check = true
for _, addon in pairs(GogoLoot.conflicts) do
if IsAddOnLoaded(addon) then
local conflict = addon
C_Timer.After(4, function()
print(GogoLoot.ADDON_CONFLICT) -- send shortly after login, so its not drown out by other addon messages
print("The conflicting AdddOn: " .. conflict)
end)
break
end
end
end
if not GogoLoot_Config._has_notified_api_change then
GogoLoot_Config._has_notified_api_change = true
print(GogoLoot.API_WARNING)
end
GameTooltip:HookScript("OnHide", function()
GogoLoot:HideNotification()
end)
elseif "PLAYER_LOGIN" == evt then
--[[for _, addon in pairs(GogoLoot.conflicts) do
print(addon)
if IsAddOnLoaded(addon) then
print("LD")
C_Timer.After(4, function()
print(GogoLoot.ADDON_CONFLICT) -- send shortly after login, so its not drown out by other addon messages
end)
break
end
end]]
end
end
local events = CreateFrame('Frame')
events:RegisterEvent("ADDON_LOADED")
events:SetScript("OnEvent", function(event, ...) GogoLoot.EventHandler(self, event, ...) end)
function GogoLoot:Initialize(events)
local function capitalize(str)
return (str:gsub("^%l", string.upper))
end
local function printInvalid()
print("|cFFAAFFAA[GogoLoot]|r Invalid arguments! Try |cFF00FF00/lv <player>|r or |cFF00FF00/lv <quality> <player>|r or |cFF00FF00/lv status|r")
end
SlashCmdList["LV"] = function(args)
local parsed = {}
for s in args:gmatch("%S+") do tinsert(parsed, s) end
local filter, player = unpack(parsed)
if not filter and not player then
GogoLoot:BuildUI()
elseif filter == "status" and not player then
print("|cFFAAFFAA[GogoLoot]|r The current configuration:")
for k,v in pairs(GogoLoot_Config.players) do
print(" |cFF00FF00"..k.."|r -> |cFF00FF00" .. v .. "|r")
end
elseif player and filter and GogoLoot.validFilters[filter] and false then
if player == GogoLoot_Config.players[filter] then
GogoLoot_Config.players[filter] = nil
print("|cFFAAFFAA[GogoLoot]|r "..capitalize(filter).." loot is no longer being redirected.")
else
GogoLoot_Config.players[filter] = player
print("|cFFAAFFAA[GogoLoot]|r "..capitalize(filter).." loot is now redirected to \"|cFF00FF00" .. player .. "|r\"")
end
elseif filter and not player and false then
if filter == GogoLoot_Config.players["all"] then
GogoLoot_Config.players["all"] = nil
print("|cFFAAFFAA[GogoLoot]|r Loot is no longer being redirected.")
else
GogoLoot_Config.players["all"] = filter
print("|cFFAAFFAA[GogoLoot]|r Loot is now redirected to \"|cFF00FF00" .. filter .. "|r\"")
end
else
printInvalid()
end
end
SlashCmdList["TG"] = function(args)
local payout = tonumber(args)
if payout and GogoLoot:UnitName("target") then
--print("Payout set to " .. args .. " gold")
_PAYOUT = math.floor(payout * 10000) -- gold to copper
InitiateTrade("target")
if _TradeTimer then
_TradeTimer:Cancel()
end
_TradeTimer=nil
_TradeTimer=C_Timer.NewTicker(0.1, function()
if TradeFrame:IsShown() then
MoneyInputFrame_SetCopper(TradePlayerInputMoneyFrame,_PAYOUT)
_TradeTimer:Cancel()
_TradeTimer=nil
end
end)
else
print("Please specify payout value")
end
end
SLASH_LV1 = "/gl"
SLASH_LV2 = "/gogoloot"
SLASH_TG1 = "/tg"
local canLoot = true
local lootAPIOpen = false
local lootTicker = nil
hooksecurefunc("GiveMasterLoot", function(index, player, isGogoLoot)
if not isGogoLoot then
--print("Manual masterloot: " .. tostring(index) .. " " .. tostring(player))
if GogoLoot.softresRemoveRoll[index] and GogoLoot.softresRemoveRoll[index][player] then
local winningPlayer, item = unpack(GogoLoot.softresRemoveRoll[index][player])
debug("Player " .. winningPlayer .. " won softres roll")
GogoLoot:HandleSoftresRollWin(winningPlayer, item)
end
end
end)
UIParent:UnregisterEvent("LOOT_BIND_CONFIRM") -- ensure our event hook runs before UIParent
events:RegisterEvent("LOOT_BIND_CONFIRM")
UIParent:RegisterEvent("LOOT_BIND_CONFIRM")
events:RegisterEvent("LOOT_READY")
events:RegisterEvent("LOOT_OPENED")
events:RegisterEvent("LOOT_CLOSED")
events:RegisterEvent("LOOT_SLOT_CLEARED")
events:RegisterEvent("MODIFIER_STATE_CHANGED")
events:RegisterEvent("UI_ERROR_MESSAGE")
events:RegisterEvent("BAG_UPDATE")
events:RegisterEvent("PLAYER_ENTERING_WORLD")
events:RegisterEvent("PARTY_LOOT_METHOD_CHANGED")
events:RegisterEvent("GROUP_ROSTER_UPDATE")
events:RegisterEvent("START_LOOT_ROLL")
events:RegisterEvent("PLAYER_LOGIN")
events:RegisterEvent("PLAYER_REGEN_DISABLED")
events:RegisterEvent("PLAYER_REGEN_ENABLED")
local lastItemHidden = false
--[[ -- auto confirm
hooksecurefunc("StaticPopup_Show", function(popup)
if not ((popup ~= "CONFIRM_LOOT_ROLL" and popup ~= "LOOT_BIND") or (not lastItemHidden) or (not GogoLoot_Config.autoConfirm)) then
StaticPopup1:Hide()
StaticPopup2:Hide()
StaticPopup3:Hide()
StaticPopup4:Hide()
end
end)]]
LootFrame.selectedQuality = GetLootThreshold()
UnitPopupItemQuality0DescButtonMixin = CreateFromMixins(UnitPopupItemQuality2DescButtonMixin);
function UnitPopupItemQuality0DescButtonMixin:GetText()
return ITEM_QUALITY0_DESC;
end
function UnitPopupItemQuality0DescButtonMixin:GetID()
return 0;
end
UnitPopupItemQuality1DescButtonMixin = CreateFromMixins(UnitPopupItemQuality2DescButtonMixin);
function UnitPopupItemQuality1DescButtonMixin:GetText()
return ITEM_QUALITY1_DESC;
end
function UnitPopupItemQuality1DescButtonMixin:GetID()
return 1;
end
local UnitPopupLootThresholdButtonMixinGetButtons = UnitPopupLootThresholdButtonMixin.GetButtons
function UnitPopupLootThresholdButtonMixin:GetButtons()
local buttons = UnitPopupLootThresholdButtonMixinGetButtons(self)
table.insert(buttons, UnitPopupItemQuality1DescButtonMixin)
table.insert(buttons, UnitPopupItemQuality0DescButtonMixin)
--Fixup button ids to be in some sort of sane order, fixes an issue in the default UI.
table.sort(buttons, function (a, b)
if (b.GetID == nil) then
return a.GetID ~= nil;
elseif (a.GetID == nil) then
return false;
else
return a.GetID() < b.GetID();
end
end);
return buttons;
end
GogoLoot:HookTrades(events)
end
internalIgnoreList = valToKey(
{ -- manual blacklist
12947, --Alex's Ring of Audacity
13262, --Ashbringer
17182, --Sulfuras, Hand of Ragnaros
17204, --Eye of Sulfuras
17771, --Elementium Bar
17782, --Talisman of Binding Shard
18563, --Bindings of the Windseeker
18564, --Bindings of the Windseeker
18565, --Vessel of Rebirth
18566, --Essence of the Firelord
18582, --The Twin Blades of Azzinoth
18583, --Warglaive of Azzinoth (Right)
18584, --Warglaive of Azzinoth (Left)
19016, --Vessel of Rebirth
19018, --Dormant Wind Kissed Blade
19019, --Thunderfury, Blessed Blade of the Windseeker
21176, --Black Qiraji Resonating Crystal
22589, --Atiesh, Greatstaff of the Guardian
22630, --Atiesh, Greatstaff of the Guardian
22631, --Atiesh, Greatstaff of the Guardian
22632, --Atiesh, Greatstaff of the Guardian
22726, --Splinter of Atiesh
22727, --Frame of Atiesh
22736, --Andonisus, Reaper of Souls
22737, --Atiesh, Greatstaff of the Guardian
23051, --Glaive of the Defender
})
itemBindings = {
[60]=1,
[61]=1,
[79]=1,
[80]=1,
[182]=4,
[710]=1,
[719]=1,
[725]=4,
[735]=4,
[737]=1,
[738]=4,
[739]=4,
[740]=4,
[742]=4,
[743]=4,
[744]=1,
[745]=4,
[748]=4,
[750]=4,