Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if not AutoAmmo_Quantity then
- AutoAmmo_Quantity = 0
- end
- local ammoLink, rangedItemLink;
- local arrowTable = {
- [1] = select(2,GetItemInfo(2512)), -- "Rauer Pfeil",
- [10] = select(2,GetItemInfo(2515)), -- "Scharfer Pfeil",
- [25] = select(2,GetItemInfo(3030)), -- "Schneidenofeil",
- [40] = select(2,GetItemInfo(11285)), -- "Gezackter Pfeil",
- }
- local bulletTable = {
- [1] = select(2,GetItemInfo(2516)), -- "Leichtes Geschoss",
- [10] = select(2,GetItemInfo(2519)), -- "Schweres Geschoss",
- [25] = select(2,GetItemInfo(3033)), -- "Robustes Geschoss",
- [40] = select(2,GetItemInfo(11284)), -- "Genaue Patronen",
- }
- function AutoAmmo_ItemToBuy()
- rangedItemLink = GetInventoryItemLink("player", GetInventorySlotInfo("RangedSlot"))
- if rangedItemLink ~= nil then
- -- get SubclassID
- local subclassID = select(13, GetItemInfo(rangedItemLink))
- ammoLink = nil
- -- compare with ITEM ENUM subClassIDs
- if subclassID == LE_ITEM_WEAPON_GUNS then
- local playerLevel = UnitLevel("PLAYER");
- while (playerLevel > 0) and (ammoLink == nil) do
- ammoLink = bulletTable[playerLevel]
- playerLevel = playerLevel - 1;
- end
- elseif subclassID == LE_ITEM_WEAPON_BOWS then
- local playerLevel = UnitLevel("PLAYER");
- while (playerLevel > 0) and (ammoLink == nil) do
- ammoLink = arrowTable[playerLevel]
- playerLevel = playerLevel - 1;
- end
- else
- ammoLink = nil;
- end
- else
- ammoLink = nil;
- end
- end
- local frame = CreateFrame("Frame")
- frame:RegisterEvent("MERCHANT_SHOW")
- frame:SetScript("OnEvent", function(self, event, ...)
- AutoAmmo_ItemToBuy();
- local merchItemLink = "";
- local i = 1;
- local toBuy = AutoAmmo_Quantity - GetItemCount(ammoLink)
- if toBuy > 100 and ammoLink ~= nil then
- while (merchItemLink ~= nil) do
- merchItemLink = GetMerchantItemLink(i);
- if merchItemLink == ammoLink then
- while (toBuy > 200) do
- BuyMerchantItem(i, 200)
- toBuy = toBuy - 200
- end
- if toBuy > 100 then
- BuyMerchantItem(i, toBuy)
- end
- end
- i = i + 1;
- end
- end
- end)
- function AutoAmmo_Command(arg1)
- AutoAmmo_ItemToBuy(); -- So we can print the correct ammo
- if tonumber(arg1) ~= nil then
- AutoAmmo_Quantity = tonumber(arg1)
- if ammoLink ~= nil then
- print("Stockpiling " .. AutoAmmo_Quantity .. " " .. ammoLink .. " for " .. rangedItemLink)
- else
- print("You currently have no ranged wepon that needs ammo, but when you do, we'll stockpile " .. AutoAmmo_Quantity .. " ammo.")
- end
- else
- print("Available command is \/aa <number>")
- end
- end
- SLASH_AUTOAMMO1 = "/aa"
- SLASH_AUTOAMMO2 = "/autoammo"
- SlashCmdList.AUTOAMMO = AutoAmmo_Command
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement