local addonName, addon = ...
local frameName = "ZAMESTOTV_BUY299"
if not _G[frameName] then
_G[frameName] = CreateFrame("Frame")
_G[frameName]:RegisterEvent("MERCHANT_SHOW")
end
local vendors = {
['Arvik'] = {['Skrog Liver Oil'] = true, },
['Bukarakikk'] = {['Hunk o\' Blubber'] = true, },
['Erugosa'] = {['Exquisite Ohn\'ahran Potato'] = true, ['Flaky Pastry Dough'] = true, ['Dark Thaldraszian Cocoa Powder'] = true, ['Four-Cheese Blend'] = true, },
['Gracus'] = {['Greenberry'] = true, ['Fresh Dragon Fruit'] = true, ['Juicy Bushfruit'] = true, ['Dried Coldsnap Sagittate'] = true, },
['Hanu'] = {['Eye of Bass'] = true, },
['Head Chef Stacks'] = {['Rations: Scorpid Surprise'] = true, ['Rations: Undermine Clam Chowder'] = true, ['Rations: Westfall Stew'] = true, ['Rations: Dragonbreath Chili'] = true, },
['Jinkutuk'] = {['Salted Fish Scraps'] = true, },
['Junnik'] = {['Thousandbite Piranha Collar'] = true, },
['Elder Nappa'] = {['Nappa\'s Famous Tea'] = true, },
['Norukk'] = {['Norukk\'s "All-Purpose" Fish Powder'] = true, },
['Qariin Dotur'] = {['Seven Spices Bruffalon'] = true, ['Dragonflame Argali'] = true, ['Thrice-Charred Mammoth Ribs'] = true, ['"Volcano" Duck'] = true, },
['Patchu'] = {['Lunker Bits'] = true, },
['Rokkutuk'] = {['Deepsquid Ink'] = true, },
['Tattukiaka'] = {['Fermented Mackerel Paste'] = true, },
['Tikukk'] = {['Island Crab Jerky'] = true, },
['Tuukanit'] = {['Piping-Hot Orca Milk'] = true, },
}
local function PrintMessage(msg)
print("[ZAMESTOTV: Community Feast] " .. msg)
end
local function BuyItemsFromVendor(vendorName)
local vendor = vendors[vendorName]
if not vendor then return end
local numItems = GetMerchantNumItems()
for i = numItems, 1, -1 do
local name = GetMerchantItemInfo(i)
if vendor[name] then
local success = BuyMerchantItem(i)
if success then
PrintMessage("Purchased: " .. name)
else
PrintMessage("Failed to purchase: " .. name)
end
end
end
end
local frame = _G[frameName]
frame:SetScript("OnEvent", function(self, event, ...)
if IsShiftKeyDown() then return end
local targetName = UnitName("target")
if not targetName then return end
BuyItemsFromVendor(targetName)
end)
local function AutoPurchaseSelectedItems()
local targetName = UnitName("target")
if not targetName then return end
BuyItemsFromVendor(targetName)
end
local function OnEvent(self, event, ...)
if event == "MERCHANT_SHOW" then
self:RegisterEvent("MERCHANT_UPDATE")
elseif event == "MERCHANT_UPDATE" then
self:UnregisterEvent(event)
AutoPurchaseSelectedItems()
end
end
local eventWatcher = CreateFrame("Frame")
eventWatcher:RegisterEvent("MERCHANT_SHOW")
eventWatcher:SetScript("OnEvent", OnEvent)