17,097
edits
Falterfire (talk | contribs) (Fixed indenting) |
(Update for v1.0.2) |
||
Line 13: | Line 13: | ||
local Agility = require('Module:Skills/Agility') | local Agility = require('Module:Skills/Agility') | ||
local Shop = require('Module:Shop') | local Shop = require('Module:Shop') | ||
--Brute forcing some item uses to make things easier | --Brute forcing some item uses to make things easier | ||
Line 74: | Line 73: | ||
[29] = 'Astrology' | [29] = 'Astrology' | ||
} | } | ||
local SkillEnum = {} | |||
for i, skill in pairs(SkillData.Skills) do | |||
SkillEnum[skill.name] = Constants.getSkillID(skill.name) | |||
end | |||
function p._getItemUses(item, asList, addCategories) | function p._getItemUses(item, asList, addCategories) | ||
Line 82: | Line 86: | ||
--Before anything else, if this is a potion add it to the appropriate override section | --Before anything else, if this is a potion add it to the appropriate override section | ||
if item.masteryID ~= nil and item.masteryID[1] == | if item.masteryID ~= nil and item.masteryID[1] == SkillEnum.Herblore then | ||
if potionUseArray[item.masteryID[2]] ~= nil then | if potionUseArray[item.masteryID[2]] ~= nil then | ||
table.insert(itemUseArray[potionUseArray[item.masteryID[2]]], item.name) | table.insert(itemUseArray[potionUseArray[item.masteryID[2]]], item.name) | ||
Line 140: | Line 144: | ||
local canSummon = false | local canSummon = false | ||
local canCook = false | local canCook = false | ||
local canSmith = false | |||
if item.trimmedItemID ~= nil then | if item.trimmedItemID ~= nil then | ||
Line 146: | Line 151: | ||
for i, item2 in pairs(ItemData.Items) do | for i, item2 in pairs(ItemData.Items) do | ||
if item2.itemsRequired ~= nil then | if not canUpgrade and item2.itemsRequired ~= nil then | ||
for j, req in pairs(item2.itemsRequired) do | for j, req in pairs(item2.itemsRequired) do | ||
if req[1] == item.id then | if req[1] == item.id then | ||
Line 154: | Line 159: | ||
end | end | ||
end | end | ||
if not canCraft and item2.craftReq ~= nil then | |||
if item2.craftReq ~= nil then | |||
for j, req in pairs(item2.craftReq) do | for j, req in pairs(item2.craftReq) do | ||
if req.id == item.id then | if req.id == item.id then | ||
Line 163: | Line 167: | ||
end | end | ||
end | end | ||
if item2.fletchReq ~= nil then | if not canFletch and item2.fletchReq ~= nil then | ||
for j, req in pairs(item2.fletchReq) do | for j, req in pairs(item2.fletchReq) do | ||
if req.id == item.id then | if req.id == item.id then | ||
Line 171: | Line 175: | ||
end | end | ||
end | end | ||
if item2.runecraftReq ~= nil then | if not canRunecraft and item2.runecraftReq ~= nil then | ||
for j, req in pairs(item2.runecraftReq) do | for j, req in pairs(item2.runecraftReq) do | ||
if req.id == item.id then | if req.id == item.id then | ||
Line 179: | Line 183: | ||
end | end | ||
end | end | ||
if not canSummon and item2.summoningReq ~= nil then | |||
if item2.summoningReq ~= nil then | |||
for j, reqSet in pairs(item2.summoningReq) do | for j, reqSet in pairs(item2.summoningReq) do | ||
for k, req in pairs(reqSet) do | for k, req in pairs(reqSet) do | ||
Line 196: | Line 190: | ||
break | break | ||
end | end | ||
end | |||
if canSummon then | |||
break | |||
end | end | ||
end | end | ||
end | end | ||
--Handling for new Cooking method | --Handling for new Cooking method | ||
if item2.recipeRequirements ~= nil and item2.recipeRequirements[1] ~= nil then | if not canCook and item2.recipeRequirements ~= nil and item2.recipeRequirements[1] ~= nil then | ||
for j, reqSet in pairs(item2.recipeRequirements) do | for j, reqSet in pairs(item2.recipeRequirements) do | ||
for k, req in pairs(reqSet) do | for k, req in pairs(reqSet) do | ||
Line 209: | Line 205: | ||
end | end | ||
end | end | ||
if canCook then | |||
break | |||
end | |||
end | |||
end | |||
end | |||
-- Check potions for Herblore | |||
for i, potion in ipairs(SkillData.Herblore.Potions) do | |||
for j, itemCost in ipairs(potion.itemCosts) do | |||
if itemCost.id == item.id then | |||
canHerblore = true | |||
break | |||
end | end | ||
end | |||
if canHerblore then | |||
break | |||
end | |||
end | |||
-- Check recipes for Smithing | |||
for i, recipe in ipairs(SkillData.Smithing.Recipes) do | |||
for j, itemCost in ipairs(recipe.itemCosts) do | |||
if itemCost.id == item.id then | |||
canSmith = true | |||
break | |||
end | |||
end | |||
if canSmith then | |||
break | |||
end | end | ||
end | end | ||
Line 237: | Line 262: | ||
end | end | ||
--Firemaking | --Firemaking | ||
if item. | if (type(item.masteryID) == 'table' and item.masteryID[1] == SkillEnum.Firemaking) or Shared.contains(itemUseArray.Firemaking, item.name) then | ||
table.insert(useArray, chr..Icons.Icon({'Firemaking', type='skill'})) | table.insert(useArray, chr..Icons.Icon({'Firemaking', type='skill'})) | ||
end | end | ||
Line 270: | Line 295: | ||
end | end | ||
--Smithing | --Smithing | ||
if | if canSmith or Shared.contains(itemUseArray.Smithing, item.name) then | ||
table.insert(useArray, chr..Icons.Icon({'Smithing', type='skill'})) | table.insert(useArray, chr..Icons.Icon({'Smithing', type='skill'})) | ||
end | end | ||
Line 399: | Line 424: | ||
end | end | ||
table.insert(useArray, {item = item2, qty = qty, mats = mat, skill = 'Fletching', req = rowReq, xp = xp}) | table.insert(useArray, {item = item2, qty = qty, mats = mat, skill = 'Fletching', req = rowReq, xp = xp}) | ||
break | break | ||
end | end | ||
Line 425: | Line 438: | ||
local qty = item2.cookingQty | local qty = item2.cookingQty | ||
table.insert(useArray, {item = item2, qty = qty, mats = mat, skill = 'Cooking', req = rowReq, xp = xp}) | table.insert(useArray, {item = item2, qty = qty, mats = mat, skill = 'Cooking', req = rowReq, xp = xp}) | ||
if item2.perfectItem ~= nil then | if item2.perfectItem ~= nil then | ||
local perfectItem = Items.getItemByID(item2.perfectItem) | local perfectItem = Items.getItemByID(item2.perfectItem) | ||
Line 446: | Line 459: | ||
end | end | ||
end | end | ||
if item2.summoningReq ~= nil then | if item2.summoningReq ~= nil then | ||
for j, reqSet in pairs(item2.summoningReq) do | for j, reqSet in pairs(item2.summoningReq) do | ||
Line 486: | Line 480: | ||
local qty = (item.tier ~= nil and item.tier == 'Tree' and 35 or 15) | local qty = (item.tier ~= nil and item.tier == 'Tree' and 35 or 15) | ||
table.insert(useArray, {item = item2, qty = qty, mats = mat, skill = 'Farming', req = rowReq, xp = xp}) | table.insert(useArray, {item = item2, qty = qty, mats = mat, skill = 'Farming', req = rowReq, xp = xp}) | ||
end | |||
-- Check potions for Herblore | |||
for i, potion in ipairs(SkillData.Herblore.Potions) do | |||
for j, itemCost in ipairs(potion.itemCosts) do | |||
if itemCost.id == item.id then | |||
local mat = potion.itemCosts | |||
local xp = potion.baseXP | |||
local baseRowReq = Icons._SkillReq('Herblore', potion.level) | |||
-- Iterate over each potion tier | |||
for k, potItemID in ipairs(potion.potionIDs) do | |||
local potItem = Items.getItemByID(potItemID) | |||
if potItem ~= nil then | |||
local rowReq = baseRowReq | |||
local masteryLvl = potTierMastery[potItem.potionTier] | |||
if masteryLvl > 0 then | |||
rowReq = rowReq .. '<br/>' .. Icons._MasteryReq(potItem.name, masteryLvl) | |||
end | |||
local reqVal = potion.level + masteryLvl * 0.01 | |||
table.insert(useArray, {item = potItem, qty = 1, mats = mat, skill = 'Herblore', reqVal = reqVal, req = rowReq, xp = xp}) | |||
end | |||
end | |||
break | |||
end | |||
end | |||
end | |||
-- Check recipes for Smithing | |||
for i, recipe in ipairs(SkillData.Smithing.Recipes) do | |||
for j, itemCost in ipairs(recipe.itemCosts) do | |||
if itemCost.id == item.id then | |||
local smithItem = Items.getItemByID(recipe.itemID) | |||
if smithItem ~= nil then | |||
local mat = recipe.itemCosts | |||
local xp = recipe.baseXP | |||
local rowReq = recipe.level | |||
local qty = recipe.baseQuantity | |||
table.insert(useArray, {item = smithItem, qty = qty, mats = mat, skill = 'Smithing', req = rowReq, xp = xp}) | |||
break | |||
end | |||
end | |||
end | |||
end | end | ||
Line 638: | Line 674: | ||
end | end | ||
-- TODO Doesn't include Alt. Magic spells that use particular classes of items, e.g. Junk/Coal for Rags to Riches | |||
function p._getSpellUseTable(item) | function p._getSpellUseTable(item) | ||
local spellList = Magic.getSpellsForRune(item.id) | local spellList = Magic.getSpellsForRune(item.id) |