17,097
edits
(getItemUseTable: Fix quantity for non-shard Summoning recipe costs) |
(getItemUseTable: Resolve Summoning tablets with no non-shard item costs being excluded from output) |
||
Line 490: | Line 490: | ||
end | end | ||
-- Non-shard items | -- Non-shard items | ||
for j, nonShardItemID in ipairs( | -- Familiar recipes may also have a currency cost without any non-shard | ||
-- items, so account for this with a dummy ID such that one iteration | |||
-- of the below loop always occurs | |||
local nonShardItemIDs = (Shared.tableIsEmpty(recipe.nonShardItemCosts) and {''} or recipe.nonShardItemCosts) | |||
for j, nonShardItemID in ipairs(nonShardItemIDs) do | |||
if useShards or nonShardItemID == item.id then | if useShards or nonShardItemID == item.id then | ||
-- Item is used in this particular synergy recipe | -- Item is used in this particular synergy recipe | ||
Line 497: | Line 501: | ||
end | end | ||
local nonShardItem = Items.getItemByID(nonShardItemID) | local nonShardItem = Items.getItemByID(nonShardItemID) | ||
local recipeCosts = Shared.clone(recipe.itemCosts) | local recipeCosts = Shared.clone(recipe.itemCosts) | ||
local recipeCosts = {} | local recipeCosts = {} | ||
Line 504: | Line 506: | ||
table.insert(recipeCosts, {id = itemCost.id, quantity = itemCost.quantity}) | table.insert(recipeCosts, {id = itemCost.id, quantity = itemCost.quantity}) | ||
end | end | ||
table.insert(recipeCosts, {id = nonShardItemID, quantity = nonShardQty}) | if nonShardItem ~= nil then | ||
-- Item ID can be nil for recipes such as Leprechaun or Cyclops | |||
local itemValue = math.max(nonShardItem.sellsFor, 20) | |||
local nonShardQty = math.max(1, math.floor(recipeGPCost / itemValue)) | |||
table.insert(recipeCosts, {id = nonShardItemID, quantity = nonShardQty}) | |||
end | |||
table.insert(useArray, {item = {id = recipeItem.id, name = recipeItem.name}, qty = recipe.baseQuantity, mats = recipeCosts, gp = recipe.gpCost, sc = recipe.scCost, skill = 'Summoning', req = recipe.level, xp = recipe.baseExperience}) | table.insert(useArray, {item = {id = recipeItem.id, name = recipeItem.name}, qty = recipe.baseQuantity, mats = recipeCosts, gp = recipe.gpCost, sc = recipe.scCost, skill = 'Summoning', req = recipe.level, xp = recipe.baseExperience}) | ||
end | end |