|
| Macros and Addons No we're not bots... Check the Macro wiki for examples. |
|
[Addon] Jamba - An assistant for multiboxers. 28th Update - 0.7a released.
|
Thread Tools | Display Modes |
|
|
Post #11 |
|
Junior Member
Join Date: Jan 2010
Posts: 1
|
Jafula,
Not sure if anyone will find this useful - I think they might - I wrote this to support a new quest reward selection method. This code will attempt to choose an item upgrades for each character from quest rewards, if it doesn't believe there is an upgrade, it will simply choose the most valuable item for vendoring. This is my first time writing anything in LUA, but I think dropping this code in AJM oChooseQuestReward will get you most of the way there (I've been testing in a separate addon):At the very top of AJM oChooseQuestReward add:Code:
local numberOfQuestRewards = GetNumQuestChoices() Then, in the conditional for "more than one quest reward", a new option like "AJM.db.hasChoiceAquireBestQuestRewardForCharacter " would contain the logic below: Code:
-- Choose the best item for this character, otherwise choose the most valuable to vendor:
local mostValuableQuestItemIndex, mostValuableQuestItemValue, bestQuestItemIndex, bestQuestItemArmorWeight = 1, 0, -1, -1
local armorWeights = { Plate = 4, Mail = 2, Leather = 1, Cloth = 0 }
-- Yanked this from LibItemUtils; sucks that we need this lookup table, but GetItemInfo only
-- returns an equipment location, which must first be converted to a slot value that GetInventoryItemLink understands:
local equipmentSlotLookup = {
INVTYPE_HEAD = {"HeadSlot", nil},
INVTYPE_NECK = {"NeckSlot", nil},
INVTYPE_SHOULDER = {"ShoulderSlot", nil},
INVTYPE_CLOAK = {"BackSlot", nil},
INVTYPE_CHEST = {"ChestSlot", nil},
INVTYPE_WRIST = {"WristSlot", nil},
INVTYPE_HAND = {"HandsSlot", nil},
INVTYPE_WAIST = {"WaistSlot", nil},
INVTYPE_LEGS = {"LegsSlot", nil},
INVTYPE_FEET = {"FeetSlot", nil},
INVTYPE_SHIELD = {"SecondaryHandSlot", nil},
INVTYPE_ROBE = {"ChestSlot", nil},
INVTYPE_2HWEAPON = {"MainHandSlot", "SecondaryHandSlot"},
INVTYPE_WEAPONMAINHAND = {"MainHandSlot", nil},
INVTYPE_WEAPONOFFHAND = {"SecondaryHandSlot", "MainHandSlot"},
INVTYPE_WEAPON = {"MainHandSlot","SecondaryHandSlot"},
INVTYPE_THROWN = {"RangedSlot", nil},
INVTYPE_RANGED = {"RangedSlot", nil},
INVTYPE_RANGEDRIGHT = {"RangedSlot", nil},
INVTYPE_FINGER = {"Finger0Slot", "Finger1Slot"},
INVTYPE_HOLDABLE = {"SecondaryHandSlot", "MainHandSlot"},
INVTYPE_TRINKET = {"Trinket0Slot", "Trinket1Slot"}
}
for questItemIndex = 1, numberOfQuestRewards do
local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount,
itemEquipLoc, itemTexture, itemSellPrice = GetItemInfo(GetQuestItemLink("choice", questItemIndex))
local itemId = itemLink:match("|Hitem:(%d+)")
local isItemEquippable = IsEquippableItem(itemId)
local _, _, _, _, isItemUsable = GetQuestItemInfo("choice", questItemIndex)
if itemSellPrice > mostValuableQuestItemValue then
-- Keep track of which item is most valuable:
mostValuableQuestItemIndex = questItemIndex
mostValuableQuestItemValue = itemSellPrice
end
if isItemEquippable == 1 and isItemUsable ~= nil then
-- NPC is offering us an item we can actually wear:
local currentEquippedItemLinksInSlots = {}
local currentWorstEquippedItemInSlot = nil
-- Figure out what we already have equipped:
for _, itemSlot in ipairs(equipmentSlotLookup[itemEquipLoc]) do
if itemSlot ~= nil then
local currentEquippedItemLinkInSlot = GetInventoryItemLink("player", GetInventorySlotInfo(itemSlot))
if currentEquippedItemLinkInSlot == nil then
-- Of the n item slots available, at least one of them has nothing equipped. Ergo, it is the worst:
currentWorstEquippedItemInSlot = nil
break
else
-- There's an item in this slot, get some details on it:
local _, _, _, currentEquippedItemLevelInSlot, _, _, currentEquippedItemSubTypeInSlot = GetItemInfo(currentEquippedItemLinkInSlot)
-- We haven't yet determined the worst item, or the item we see in this slot happens to be worse than the other item
-- we saw in this partner slot (ie. a ring in one slot is worse than a ring in another slot):
if currentWorstEquippedItemInSlot == nil or currentWorstEquippedItemInSlot.itemLevel > currentEquippedItemLevelInSlot then
currentWorstEquippedItemInSlot = {
itemLink = currentEquippedItemLinkInSlot,
itemLevel = currentEquippedItemLevelInSlot,
itemSubType = currentEquippedItemSubTypeInSlot
}
end
end
end
end
if currentWorstEquippedItemInSlot == nil then
-- We're not even wearing an item in this slot, and the vendor has something we can use, take it:
bestQuestItemIndex = questItemIndex
else
if itemLevel > currentWorstEquippedItemInSlot.itemLevel then
-- NPC is providing us with an better item than what we currently have in this slot:
if armorWeights[itemSubType] ~= nil then
-- Armor subtype is one which we care to select based on some priority order:
if armorWeights[itemSubType] > bestQuestItemArmorWeight then
-- If this piece of armor is a better subtype (ie. Plate is better than Cloth if we can wear it):
bestQuestItemIndex = questItemIndex
bestQuestItemArmorWeight = armorWeights[itemSubType]
end
elseif currentWorstEquippedItemInSlot.itemSubType == itemSubType then
-- This isn't a piece of armor (ie. might be a weapon) - only take it if it's the same
-- subtype as the item we are already wearing (if we're wearing a staff, and NPC offers
-- a staff and a dagger, we'll take the staff):
bestQuestItemIndex = questItemIndex
bestQuestItemArmorWeight = -1
end
end
end
end
end
if bestQuestItemIndex < 0 then
-- If we haven't determined an item upgrade by now, just choose the one that we can vendor for the most gold:
bestQuestItemIndex = mostValuableQuestItemIndex
end
GetQuestReward(bestQuestItemIndex)
EDIT: Here's the code on PasteBin - easier to read w/ syntax highlighting: http://pastebin.com/m5ee57c2d Last edited by loop : 01-09-2010 at 09:38 AM |
|
|
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Jamba, the Dual-Boxing addon you wish you always had | Ellay | The Blog | 29 | 06-27-2009 02:09 AM |
| Any idea when we'll see a Jamba update to work with 3.1? -NT | Clovis | Macros and Addons | 1 | 04-23-2009 04:57 PM |
| Any idea when we'll see an update for Jamba? | Clovis | Macros and Addons | 2 | 04-20-2009 08:21 AM |
| Jamba Addon new features suggetion | Ivanhalf | Macros and Addons | 3 | 04-01-2009 03:26 AM |
| SickOfClickingDailies AddOn - great for multiboxers | puppychow | Macros and Addons | 1 | 10-16-2008 03:14 PM |