1) If a set does not have an item for a wearable location, wearing the set now

leaves whatever is at that location alone unless it conflicts with the set
master
Durel 7 years ago
parent 9ad13b7c51
commit 6db4500b39

@ -13299,20 +13299,42 @@ function inv.set.wear(equipSet)
-- Disable the prompt to make the output look cleaner -- Disable the prompt to make the output look cleaner
dbot.prompt.hide() dbot.prompt.hide()
-- Store any items that simply aren't part of the current equipment set. This typically happens -- It's possible that an equipment set doesn't specify what to wear at a particular location.
-- when you switch from a single weapon to a dual weapon setup. -- In this case we would like to simply leave that wearable location alone and keep using
-- the equipment (if any) that is already equipped at that location. However, some locations
-- are incompatible with each other and we may be forced to store an item to avoid a conflict.
-- For example, if a set does not have anything at the "second" location but it does include
-- a "hold" or "shield" item, them we don't have any choice. We must store the item that
-- previously was at the "second" location. The code below loops through all items to find
-- all currently equipped items and then stores anything that would be incompatible with the
-- new set.
for _, v in pairs(inv.wearLoc) do for _, v in pairs(inv.wearLoc) do
itemLoc = v or "none" itemLoc = v or "none"
if (equipSet[itemLoc] == nil) then if (equipSet[itemLoc] == nil) then
for objId, objInfo in pairs(inv.items.table) do for objId, objInfo in pairs(inv.items.table) do
local currentLoc = inv.items.getField(objId, invFieldObjLoc) or "" local currentLoc = inv.items.getField(objId, invFieldObjLoc) or ""
if (currentLoc == itemLoc) then if (currentLoc == itemLoc) then
local eqPrimary = equipSet[inv.wearLoc[invWearableLocWielded]]
local eqSecond = equipSet[inv.wearLoc[invWearableLocSecond]]
local eqHold = equipSet[inv.wearLoc[invWearableLocHold]]
local eqShield = equipSet[inv.wearLoc[invWearableLocWielded]]
if ((itemLoc == inv.wearLoc[invWearableLocSecond]) and ((eqHold ~= nil) or (eqShield ~= nil))) or
((itemLoc == inv.wearLoc[invWearableLocHold]) and (eqSecond ~= nil)) or
((itemLoc == inv.wearLoc[invWearableLocShield]) and (eqSecond ~= nil)) or
((itemLoc == inv.wearLoc[invWearableLocSecond]) and (eqPrimary ~= nil) and
(2 * tonumber(inv.items.getStatField(objId, invStatFieldWeight) or 0) >
tonumber(inv.items.getStatField(eqPrimary.id, invStatFieldWeight) or 0))) then
dbot.debug("Storing incompatible item at location \"" .. itemLoc .. "\"")
retval = inv.items.storeItem(objId, commandArray) retval = inv.items.storeItem(objId, commandArray)
if (retval ~= DRL_RET_SUCCESS) then if (retval ~= DRL_RET_SUCCESS) then
dbot.debug("inv.set.wear: Failed to store item " .. objId .. ": " .. dbot.debug("inv.set.wear: Failed to store item " .. objId .. ": " ..
dbot.retval.getString(retval)) dbot.retval.getString(retval))
end -- if end -- if
end -- if end -- if
end -- if
end -- for end -- for
end -- if end -- if
end -- for end -- for

Loading…
Cancel
Save