12,883
edits
(Update for v0.21) |
(_getItemUses: Classify items with special attacks as used in combat) |
||
(17 intermediate revisions by 2 users not shown) | |||
Line 18: | Line 18: | ||
local itemUseArray = { | local itemUseArray = { | ||
Agility = {}, | Agility = {}, | ||
Astrology = {'Stardust', 'Golden Stardust'}, | |||
Attack = {}, | Attack = {}, | ||
Combat = {'Gold Emerald Ring'}, | Combat = {'Gold Emerald Ring'}, | ||
Line 67: | Line 68: | ||
[23] = 'Combat', | [23] = 'Combat', | ||
[24] = 'Agility', | [24] = 'Agility', | ||
[25] = 'Summoning' | [25] = 'Summoning', | ||
[26] = 'Combat', | |||
[27] = 'Combat', | |||
[28] = 'Combat', | |||
[29] = 'Astrology' | |||
} | } | ||
Line 78: | Line 83: | ||
--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] == 19 then | if item.masteryID ~= nil and item.masteryID[1] == 19 then | ||
if potionUseArray[item.masteryID[2]] ~= nil then | |||
table.insert(itemUseArray[potionUseArray[item.masteryID[2]]], item.name) | |||
else | |||
table.insert(itemUseArray["Combat"], item.name) | |||
end | |||
end | end | ||
--If the item has any modifiers that affect a given skill, add it to those lists | --If the item has any modifiers that affect a given skill, add it to those lists | ||
if item.modifiers ~= nil then | --Added an exception for Mastery Tokens since they were being incorrectly flagged as usable for all skills | ||
if item.modifiers ~= nil and (item.isToken == nil or not item.isToken) then | |||
local skillArray = Constants.getModifierSkills(item.modifiers) | local skillArray = Constants.getModifierSkills(item.modifiers) | ||
for i, skillName in Shared.skpairs(skillArray) do | for i, skillName in Shared.skpairs(skillArray) do | ||
Line 90: | Line 100: | ||
--First things added to the list are non-skill things that are easy to check | --First things added to the list are non-skill things that are easy to check | ||
if Items.hasCombatStats(item) or Shared.contains(itemUseArray.Combat, item.name) then | if Items.hasCombatStats(item) or item.specialAttacks ~= nil or Shared.contains(itemUseArray.Combat, item.name) then | ||
table.insert(useArray, chr..Icons.Icon({'Combat'})) | table.insert(useArray, chr..Icons.Icon({'Combat'})) | ||
end | end | ||
Line 106: | Line 116: | ||
-- Check if the item is an entry requirement for any Slayer area | -- Check if the item is an entry requirement for any Slayer area | ||
local isSlayerAreaReq = false | local isSlayerAreaReq = false | ||
local slayerAreas = Areas.getAreas(function(area) return area.type == 'slayer' end) | if item.isEquipment then | ||
local slayerAreas = Areas.getAreas(function(area) return area.type == 'slayer' end) | |||
for i, area in pairs(slayerAreas) do | |||
if area.entryRequirements ~= nil and type(area.entryRequirements) == 'table' then | |||
for j, req in pairs(area.entryRequirements) do | |||
if req.type == "SlayerItem" and req.itemID == item.id then | |||
isSlayerAreaReq = true | |||
break | |||
end | |||
end | end | ||
if isSlayerAreaReq then break end | |||
end | end | ||
end | end | ||
end | end | ||
Line 127: | Line 139: | ||
local canAgile = false | local canAgile = false | ||
local canSummon = false | local canSummon = false | ||
local canCook = false | |||
if item.trimmedItemID ~= nil then | if item.trimmedItemID ~= nil then | ||
Line 185: | Line 198: | ||
end | end | ||
end | end | ||
end | |||
--Handling for new Cooking method | |||
if item2.recipeRequirements ~= nil and item2.recipeRequirements[1] ~= nil then | |||
for j, reqSet in pairs(item2.recipeRequirements) do | |||
for k, req in pairs(reqSet) do | |||
if req.id == item.id then | |||
canCook = true | |||
break | |||
end | |||
end | |||
end | |||
end | end | ||
end | end | ||
Line 194: | Line 219: | ||
if canAgile or Shared.contains(itemUseArray.Agility, item.name) then | if canAgile or Shared.contains(itemUseArray.Agility, item.name) then | ||
table.insert(useArray, chr..Icons.Icon({'Agility', type='skill'})) | table.insert(useArray, chr..Icons.Icon({'Agility', type='skill'})) | ||
end | |||
--Astrology | |||
if Shared.contains(itemUseArray.Astrology, item.name) then | |||
table.insert(useArray, chr..Icons.Icon({'Astrology', type='skill'})) | |||
end | end | ||
--Cooking | --Cooking | ||
if | if canCook or Shared.contains(itemUseArray.Cooking, item.name) then | ||
table.insert(useArray, chr..Icons.Icon({'Cooking', type='skill'})) | table.insert(useArray, chr..Icons.Icon({'Cooking', type='skill'})) | ||
end | end | ||
Line 265: | Line 294: | ||
--Skillcapes are tied to the appropriate skill | --Skillcapes are tied to the appropriate skill | ||
--Except | --Except Maximum Skillcape, which is tied to all skills. (And so is the Signet Ring) | ||
--And combat skillcapes, since combat skills don't get special treatment | --And combat skillcapes, since combat skills don't get special treatment | ||
local ignoreCapes = {'Ranged Skillcape', 'Attack Skillcape', 'Strength Skillcape', ' | local ignoreCapes = {'Ranged Skillcape', 'Attack Skillcape', 'Strength Skillcape', 'HP Skillcape', 'Defence Skillcape'} | ||
if Shared.contains({' | if Shared.contains({'Maximum Skillcape', 'Aorpheat's Signet Ring', 'Cape of Completion'}, item.name) then | ||
table.insert(useArray, chr..'All skills') | table.insert(useArray, chr..'All skills') | ||
elseif item.name == 'Magic Skillcape' then | elseif item.name == 'Magic Skillcape' then | ||
Line 302: | Line 331: | ||
end | end | ||
local | local resultPart = {} | ||
if addCategories then | table.insert(resultPart, asList and table.concat(useArray,'\r\n') or table.concat(useArray, '<br/>')) | ||
return | if addCategories then table.insert(resultPart, table.concat(categoryArray, '')) end | ||
return table.concat(resultPart) | |||
end | end | ||
Line 351: | Line 381: | ||
local rowReq = item2.craftingLevel | local rowReq = item2.craftingLevel | ||
local qty = item2.craftQty | local qty = item2.craftQty | ||
table.insert(useArray, {item = item2, qty = qty, mats = mat, skill = 'Crafting', req = rowReq, xp = xp}) | table.insert(useArray, {item = item2, qty = qty, mats = mat, skill = 'Crafting', req = rowReq, xp = xp, gp = item2.craftGPCost}) | ||
break | break | ||
end | end | ||
Line 384: | Line 414: | ||
end | end | ||
end | end | ||
end | |||
--Handling for new Cooking method | |||
if item2.recipeRequirements ~= nil then | |||
for j, reqSet in pairs(item2.recipeRequirements) do | |||
for k, req in pairs(reqSet) do | |||
if req.id == item.id then | |||
local mat = reqSet | |||
local xp = item2.cookingXP | |||
local rowReq = item2.cookingLevel | |||
local qty = item2.cookingQty | |||
table.insert(useArray, {item = item2, qty = qty, mats = mat, skill = 'Cooking', req = rowReq, xp = xp}) | |||
if item2.perfectItem ~= nil then | |||
local perfectItem = Items.getItemByID(item2.perfectItem) | |||
table.insert(useArray, {item = perfectItem, qty = qty, mats = mat, skill = 'Cooking', req = rowReq, xp = xp}) | |||
end | |||
end | |||
end | |||
end | |||
end | end | ||
if item2.runecraftReq ~= nil then | if item2.runecraftReq ~= nil then | ||
Line 404: | Line 453: | ||
local xp = potionData.herbloreXP | local xp = potionData.herbloreXP | ||
--Potions do have upgrade requirements though | --Potions do have upgrade requirements though | ||
local rowReq = Icons._SkillReq('Herblore', potionData. | local rowReq = Icons._SkillReq('Herblore', potionData.level) | ||
local masteryLvl = potTierMastery[item2.potionTier] | local masteryLvl = potTierMastery[item2.potionTier] | ||
if masteryLvl > 0 then | if masteryLvl > 0 then | ||
rowReq = rowReq..'<br/>'..Icons._MasteryReq(item2.name, masteryLvl) | rowReq = rowReq..'<br/>'..Icons._MasteryReq(item2.name, masteryLvl) | ||
end | end | ||
local reqVal = potionData. | local reqVal = potionData.level + (masteryLvl * 0.01) | ||
table.insert(useArray, {item = item2, qty = 1, mats = mat, skill = 'Herblore', reqVal = reqVal, req = rowReq, xp = xp}) | table.insert(useArray, {item = item2, qty = 1, mats = mat, skill = 'Herblore', reqVal = reqVal, req = rowReq, xp = xp}) | ||
break | break | ||
Line 429: | Line 478: | ||
end | end | ||
end | end | ||
end | end | ||
if item.grownItemID ~= nil then | if item.grownItemID ~= nil then | ||
Line 436: | Line 484: | ||
local xp = item.farmingXP | local xp = item.farmingXP | ||
local rowReq = item.farmingLevel | local rowReq = item.farmingLevel | ||
local qty = | 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 | end | ||
Line 481: | Line 513: | ||
local spellUseTable = p._getSpellUseTable(item) | local spellUseTable = p._getSpellUseTable(item) | ||
local | local resultPart = {} | ||
if Shared.tableCount(useArray) == 0 and Shared.tableCount(obstacles) == 0 then | if Shared.tableCount(useArray) == 0 and Shared.tableCount(obstacles) == 0 then | ||
if string.len(spellUseTable) > 0 then | if string.len(spellUseTable) > 0 then | ||
Line 489: | Line 521: | ||
end | end | ||
end | end | ||
table.insert(resultPart, '{| class="wikitable sortable"') | |||
table.insert(resultPart, '\r\n!colspan=2|Item Created!!Type!!Requirements!!XP!!Ingredients') | |||
for i, row in pairs(useArray) do | for i, row in pairs(useArray) do | ||
local qty = row.qty ~= nil and row.qty or 1 | local qty = row.qty ~= nil and row.qty or 1 | ||
local iconType = row.type ~= nil and row.type or 'item' | local iconType = row.type ~= nil and row.type or 'item' | ||
table.insert(resultPart, '\r\n|-\r\n|data-sort-value="'..row.item.name..'"|') | |||
table.insert(resultPart, Icons.Icon({row.item.name, type=iconType, notext=true, size=50})..'||') | |||
if qty > 1 then | if qty > 1 then table.insert(resultPart, "'''"..qty.."x''' ") end | ||
table.insert(resultPart, Icons.Icon({row.item.name, type='item', noicon=true})) | |||
if row.skill == 'Upgrade' then | if row.skill == 'Upgrade' then | ||
table.insert(resultPart, '||data-sort-value="Upgrade"|[[Upgrading Items|Upgrade]]') | |||
elseif row.skill == 'Shop' then | elseif row.skill == 'Shop' then | ||
table.insert(resultPart, '||data-sort-value="Shop"|'..Icons.Icon({'Shop'})) | |||
else | else | ||
table.insert(resultPart, '||data-sort-value="'..row.skill..'"|'..Icons.Icon({row.skill, type='skill'})) | |||
end | end | ||
if type(row.req) == 'number' then | if type(row.req) == 'number' then | ||
table.insert(resultPart, '|| style="text-align:right" data-sort-value="'..row.req..'"|'..Icons._SkillReq(row.skill, row.req)) | |||
elseif row.reqVal ~= nil then | elseif row.reqVal ~= nil then | ||
table.insert(resultPart, '|| style="text-align:right" data-sort-value="'..row.reqVal..'"|'..row.req) | |||
else | else | ||
table.insert(resultPart, '||'..row.req) | |||
end | end | ||
if type(row.xp) == 'string' then | if type(row.xp) == 'string' then | ||
table.insert(resultPart, '||style="text-align:right" data-sort-value="0"|'..row.xp) | |||
else | else | ||
table.insert(resultPart, '||style="text-align:right" data-sort-value="'..row.xp..'"|'..row.xp..' '..Icons.Icon({row.skill, type='skill', notext=true})..' XP') | |||
end | end | ||
table.insert(resultPart, '||') | |||
for i, mat in Shared.skpairs(row.mats) do | for i, mat in Shared.skpairs(row.mats) do | ||
local matID = mat.id ~= nil and mat.id or mat[1] | local matID = mat.id ~= nil and mat.id or mat[1] | ||
Line 523: | Line 555: | ||
local matText = '' | local matText = '' | ||
if i > 1 then | if i > 1 then table.insert(resultPart, '<br/>') end | ||
if matID >= 0 then | if matID >= 0 then | ||
-- Item | -- Item | ||
Line 541: | Line 573: | ||
matText = 'ERROR: Unknown item ID: ' .. matID .. ' [[Category:Pages with Script Errors]]' | matText = 'ERROR: Unknown item ID: ' .. matID .. ' [[Category:Pages with Script Errors]]' | ||
end | end | ||
table.insert(resultPart, matText) | |||
end | end | ||
if row.gp ~= nil then | if row.gp ~= nil then table.insert(resultPart, '<br/>'..Icons.GP(row.gp)) end | ||
end | end | ||
--Agility obstacles are weird and get their own section | --Agility obstacles are weird and get their own section | ||
for i, obst in Shared.skpairs(obstacles) do | for i, obst in Shared.skpairs(obstacles) do | ||
table.insert(resultPart, '\r\n|-\r\n|') | |||
table.insert(resultPart, Icons.Icon({"Agility", type="skill", size="50", notext=true})) | |||
table.insert(resultPart, '||[[Agility#Obstacles|'..obst.name..']]') | |||
table.insert(resultPart, '||'..Icons.Icon({"Agility", type="skill"})) | |||
--Adding the requirements for the Agility Obstacle | --Adding the requirements for the Agility Obstacle | ||
Line 566: | Line 598: | ||
end | end | ||
end | end | ||
table.insert(resultPart, '||style="text-align:right"|'..table.concat(reqArray, '<br/>')) | |||
--Just including 'N/A' for XP since it doesn't really apply for Agility Obstacles | --Just including 'N/A' for XP since it doesn't really apply for Agility Obstacles | ||
table.insert(resultPart, '||style="text-align:right"|N/A') | |||
--Finally the cost | --Finally the cost | ||
Line 585: | Line 617: | ||
end | end | ||
table.insert(resultPart, '||'..table.concat(costArray, '<br/>')) | |||
end | end | ||
table.insert(resultPart, '\r\n|}') | |||
if string.len(spellUseTable) > 0 then | if string.len(spellUseTable) > 0 then | ||
table.insert(resultPart, '\r\n==='..Icons.Icon({'Magic', type='skill', size='30'})..'===\r\n'..spellUseTable) | |||
end | end | ||
return '==Uses==\r\n'.. | return '==Uses==\r\n'..table.concat(resultPart) | ||
end | end | ||
Line 613: | Line 645: | ||
end | end | ||
local | local resultPart = {} | ||
table.insert(resultPart, '{|class="wikitable sortable"\r\n!colspan="2"|Spell') | |||
table.insert(resultPart, '!!Requirements') | |||
table.insert(resultPart, '!!Type!!style="width:275px"|Description') | |||
table.insert(resultPart, '!!Runes') | |||
for i, spell in pairs(spellList) do | for i, spell in pairs(spellList) do | ||
local | local rowPart = {} | ||
table.insert(rowPart, '\r\n|-\r\n|data-sort-value="'..spell.name..'"|') | |||
local iconType = (spell.type == 'Auroras' and 'aurora') or (spell.type == 'Curses' and 'curse') or 'spell' | |||
table.insert(rowPart, Icons.Icon({spell.name, type=iconType, notext=true, size=50})) | |||
table.insert(rowPart, '||'..Icons.Icon({spell.name, type=iconType, noicon=true})) | |||
table.insert(rowPart, '||data-sort-value="'..spell.level..'"|'..Icons._SkillReq('Magic', spell.level)) | |||
--Handle required items/dungeon clears | --Handle required items/dungeon clears | ||
if spell.requiredItem ~= nil and spell.requiredItem >= 0 then | if spell.requiredItem ~= nil and spell.requiredItem >= 0 then | ||
local reqItem = Items.getItemByID(spell.requiredItem) | local reqItem = Items.getItemByID(spell.requiredItem) | ||
table.insert(rowPart, '<br/>'..Icons.Icon({reqItem.name, type='item', notext=true})..' equipped') | |||
end | end | ||
if spell.requiredDungeonCompletion ~= nil then | if spell.requiredDungeonCompletion ~= nil then | ||
local dung = Areas.getAreaByID('dungeon', spell.requiredDungeonCompletion[1]) | local dung = Areas.getAreaByID('dungeon', spell.requiredDungeonCompletion[1]) | ||
table.insert(rowPart, '<br/>'..Icons.Icon({dung.name, type='dungeon', notext=true, qty=spell.requiredDungeonCompletion[2]})..' Clears') | |||
end | end | ||
table.insert(rowPart, '||data-sort-value="'..Magic.getSpellTypeIndex(spell.type)..'"|') | |||
table.insert(rowPart, Magic.getSpellTypeLink(spell.type)) | |||
table.insert(rowPart, '||'..Magic._getSpellStat(spell, 'description')) | |||
table.insert(rowPart, '||style="text-align:center"|') | |||
table.insert(rowPart, Magic._getSpellRunes(spell)) | |||
table.insert(resultPart, table.concat(rowPart)) | |||
end | end | ||
--Add the table end and add the table to the result string | --Add the table end and add the table to the result string | ||
table.insert(resultPart, '\r\n|}') | |||
return | return table.concat(resultPart) | ||
end | end | ||