17,097
edits
(getMonsterBones -> _getMonsterBones) |
(Update for v1.0.2) |
||
Line 24: | Line 24: | ||
} | } | ||
} | } | ||
local SkillEnum = {} | |||
for i, skill in pairs(SkillData.Skills) do | |||
SkillEnum[skill.name] = Constants.getSkillID(skill.name) | |||
end | |||
function p._getCreationTable(item) | function p._getCreationTable(item) | ||
Line 37: | Line 42: | ||
local tables = {} | local tables = {} | ||
--First figure out what skill is used to make this... | --First figure out what skill is used to make this... | ||
if item. | if type(item.masteryID) == 'table' then | ||
skill = | local skillID, masteryID = item.masteryID[1], item.masteryID[2] | ||
lvl = item. | skill = Constants.getSkillName(skillID) | ||
if skillID == SkillEnum.Fishing then | |||
-- Fishing | |||
lvl = item.fishingLevel | |||
xp = item.fishingXP | |||
qty = 1 | |||
time = item.minFishingInterval / 1000 | |||
maxTime = item.maxFishingInterval / 1000 | |||
table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time, maxTime)) | |||
elseif skillID == SkillEnum.Cooking then | |||
-- Cooking | |||
for i, reqSet in pairs(item.recipeRequirements) do | |||
lvl = item.cookingLevel | |||
xp = item.cookingXP | |||
req = reqSet | |||
qty = item.cookingQty | |||
time = item.cookingInterval / 1000 | |||
table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time)) | |||
end | |||
elseif skillID == SkillEnum.Mining then | |||
-- Mining | |||
local rock = SkillData.Mining.Rocks[masteryID + 1] | |||
if rock ~= nil then | |||
lvl = rock.levelRequired | |||
xp = rock.baseExperience | |||
qty = rock.baseQuantity | |||
time = 3 | |||
if item.name == 'Dragonite Ore' then | |||
specialReq = Icons.Icon({"Mastery", notext='true'})..' 271 total [[Mining]] [[Mastery]]' | |||
end | |||
table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time, nil, specialReq)) | |||
end | |||
elseif skillID == SkillEnum.Smithing then | |||
-- Smithing | |||
local recipe = SkillData.Smithing.Recipes[masteryID + 1] | |||
if recipe ~= nil then | |||
lvl = recipe.level | |||
table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time)) | xp = recipe.baseXP | ||
req = recipe.itemCosts | |||
qty = recipe.baseQuantity | |||
for | time = 2 | ||
table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time)) | |||
end | |||
elseif skillID == SkillEnum.Fletching then | |||
req = | -- Fletching | ||
qty = item. | lvl = item.fletchingLevel | ||
time = | xp = item.fletchingXP | ||
if item.name == 'Arrow Shafts' then | |||
--Arrow Shafts get special (weird) treatment | |||
req = '1 of any [[Log]]' | |||
qty = '15 - 135' | |||
else | |||
req = item.fletchReq | |||
qty = item.fletchQty | |||
end | |||
time = 2 | |||
table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time)) | |||
elseif skillID == SkillEnum.Crafting then | |||
-- Crafting | |||
lvl = item.craftingLevel | |||
xp = item.craftingXP | |||
req = item.craftReq | |||
qty = item.craftQty | |||
time = 3 | |||
table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time)) | |||
elseif skillID == SkillEnum.Runecrafting then | |||
-- Runecrafting | |||
lvl = item.runecraftingLevel | |||
xp = item.runecraftingXP | |||
req = item.runecraftReq | |||
qty = item.runecraftQty | |||
time = 2 | |||
table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time)) | |||
elseif skillID == SkillEnum.Herblore then | |||
-- Herblore | |||
local potion = SkillData.Herblore.Potions[masteryID + 1] | |||
if potion ~= nil then | |||
lvl = potion.level | |||
xp = potion.baseXP | |||
req = potion.itemCosts | |||
qty = 1 | |||
time = 2 | |||
table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time)) | |||
end | |||
elseif skillID == SkillEnum.Summoning then | |||
-- Summoning | |||
lvl = item.summoningLevel | |||
--Summoning uses a formula to calculate XP for creation instead of referring to the item's XP data directly | |||
xp = (5 + 2 * math.floor(item.summoningLevel / 5)) | |||
local ShardCostArray = {} | |||
for j, cost in Shared.skpairs(item.summoningReq[1]) do | |||
if cost.id >= 0 then | |||
local item = Items.getItemByID(cost.id) | |||
if item.type == 'Shard' then | |||
table.insert(ShardCostArray, Icons.Icon({item.name, type='item', notext=true, qty=cost.qty})) | |||
end | |||
end | |||
end | |||
req = table.concat(ShardCostArray, ', ') | |||
req = req..'<br/>\r\nand one of the following<br/>\r\n' | |||
local OtherCostArray = {} | |||
local recipeGPCost = SkillData.Summoning.Settings.recipeGPCost | |||
for j, altCost in Shared.skpairs(item.summoningReq) do | |||
local nonShardArray = {} | |||
for k, cost in Shared.skpairs(altCost) do | |||
if cost.id >= 0 then | |||
local item = Items.getItemByID(cost.id) | |||
if item.type ~= 'Shard' then | |||
local sellPrice = math.max(item.sellsFor, 20) | |||
table.insert(nonShardArray, Icons.Icon({item.name, type='item', notext=true, qty=math.max(1, math.floor(recipeGPCost / sellPrice))})) | |||
end | |||
elseif cost.id == -4 then | |||
table.insert(nonShardArray, Icons.GP(recipeGPCost)) | |||
elseif cost.id == -5 then | |||
table.insert(nonShardArray, Icons.SC(recipeGPCost)) | |||
end | |||
end | |||
table.insert(OtherCostArray, table.concat(nonShardArray, ', ')) | |||
end | |||
req = req..table.concat(OtherCostArray, "<br/>'''OR''' ") | |||
qty = item.summoningQty | |||
time = 5 | |||
table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time)) | table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time)) | ||
end | end | ||
end | end | ||
-- Woodcutting | |||
if item.type == "Logs" then | |||
-- Determine which tree (if any) the log is from | |||
for i, tree in ipairs(SkillData.Woodcutting.Trees) do | |||
if tree.logID == item.id then | |||
skill = 'Woodcutting' | |||
lvl = tree.levelRequired | |||
time = tree.baseInterval / 1000 | |||
xp = tree.baseExperience | |||
table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time)) | |||
break | |||
end | |||
end | end | ||
end | end | ||
--had to add cooking to the list of valid categories here to account for cherries/apples | --had to add cooking to the list of valid categories here to account for cherries/apples | ||
if item.category == 'Cooking' or item.type == "Harvest" or item.type == "Herb" or item.type == "Logs" or Shared.contains(item.name, '(Perfect)') then | if item.category == 'Cooking' or item.type == "Harvest" or item.type == "Herb" or item.type == "Logs" or Shared.contains(item.name, '(Perfect)') then | ||
Line 164: | Line 219: | ||
end | end | ||
end | end | ||
-- Alt. Magic, excludes Gems and Bars | |||
-- Bars are handled by getItemSuperheatTable() | |||
-- Gems are handled by _getItemLootSourceTable() | |||
-- TODO Should be able to iterate AltMagic.spells, checking the produces property | |||
-- | |||
-- | |||
if item.name == 'Rune Essence' then | if item.name == 'Rune Essence' then | ||
table.insert(tables, p.buildAltMagicTable('Just Learning')) | table.insert(tables, p.buildAltMagicTable('Just Learning')) | ||
Line 230: | Line 246: | ||
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Requirements') | table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Requirements') | ||
table.insert(resultPart, '\r\n|'..Icons._SkillReq('Magic', spell.level)) | table.insert(resultPart, '\r\n|'..Icons._SkillReq('Magic', spell.level)) | ||
-- 1 | |||
-- | -- The produces property of Alt magic spells is as follows: | ||
-- -3 = A random gem, using the same weights as Mining | |||
-- -2 = A bar of the type being created (Superheat) | |||
-- -1 = GP (Alchemy) | |||
-- 0 = Undefined | |||
-- >0 = Item ID of the item being produced | |||
-- The amount produced is determined by the productionRatio property | |||
-- The consumes property of Alt Magic spells is as follows: | |||
-- 0 = Any item | |||
-- 1 = Junk item | |||
-- 2 = Superheat/ores with Coal | |||
-- 3 = Superheat/ores without Coal | |||
-- 4 = Nothing | |||
-- 5 = Coal ore | |||
-- Superheat (2, 3) is handled by _getItemSuperheatTable() | |||
-- | |||
if spell.consumes ~= nil then | |||
local consumeText = { | |||
'1 of any item', | |||
'1 of any [[Fishing#Junk|Junk]] item', | |||
'1 x required ores for the chosen bar', | |||
'1 x required ores (except ' .. Icons.Icon({'Coal Ore', type='item'}) .. ') for the chosen bar', | |||
nil, | |||
Icons.Icon({'Coal Ore', type='item', qty=1}) | |||
} | |||
local consumeStr = consumeText[spell.consumes + 1] | |||
if consumeStr ~= nil then | |||
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Materials') | |||
table.insert(resultPart, '\r\n| ' .. consumeStr) | |||
end | |||
end | end | ||
--Add runes | --Add runes | ||
local formatRuneList = function(runes) | |||
local runeList = {} | |||
for i, req in ipairs(runes) do | |||
local rune = Items.getItemByID(req.id) | |||
if rune ~= nil then | |||
table.insert(runeList, Icons.Icon({rune.name, type='item', notext=true, qty=req.qty})) | |||
end | |||
end | |||
return table.concat(runeList, ', ') | |||
end | end | ||
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Runes\r\n| ' .. Magic._getSpellRunes(spell)) | |||
--Now just need the output quantity, xp, and casting time (which is always 2) | --Now just need the output quantity, xp, and casting time (which is always 2) | ||
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Base Quantity\r\n|'..spell. | table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Base Quantity\r\n|'..spell.productionRatio) | ||
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Base XP\r\n|'..spell. | table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Base XP\r\n|'..spell.baseExperience) | ||
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Cast Time\r\n|2s') | table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Cast Time\r\n|2s') | ||
table.insert(resultPart, '\r\n|}') | table.insert(resultPart, '\r\n|}') | ||
Line 360: | Line 402: | ||
end | end | ||
end | end | ||
-- Special exceptions for | -- Special exceptions for lore books | ||
if sourceOverrides['Dungeon'][item.id] ~= nil then | if sourceOverrides['Dungeon'][item.id] ~= nil then | ||
table.insert(dungeonStrPart, Icons.Icon({sourceOverrides['Dungeon'][item.id], type='dungeon', notext=true})) | table.insert(dungeonStrPart, Icons.Icon({sourceOverrides['Dungeon'][item.id], type='dungeon', notext=true})) | ||
Line 407: | Line 449: | ||
end | end | ||
if item2.grownItemID == item.id then | if item2.grownItemID == item.id then | ||
-- Farming | |||
if string.len(growStr) > 0 then | if string.len(growStr) > 0 then | ||
growStr = growStr..','..Icons.Icon({item2.name, type="item", notext="true"}) | growStr = growStr..','..Icons.Icon({item2.name, type="item", notext="true"}) | ||
Line 415: | Line 458: | ||
end | end | ||
if item2.perfectItem == item.id and item2.cookingLevel ~= nil then | if item2.perfectItem == item.id and item2.cookingLevel ~= nil then | ||
-- Cooking (Perfect items) | |||
table.insert(lineArray, Icons._SkillReq('Cooking', item2.cookingLevel)) | table.insert(lineArray, Icons._SkillReq('Cooking', item2.cookingLevel)) | ||
end | end | ||
Line 447: | Line 491: | ||
end | end | ||
-- | -- Sources discoverable through mastery IDs | ||
if item. | if type(item.masteryID) == 'table' then | ||
table.insert(lineArray, Icons._SkillReq( | local skillID, masteryID = item.masteryID[1], item.masteryID[2] | ||
local skill, levelReq = Constants.getSkillName(skillID), nil | |||
if skillID == SkillEnum.Fishing then | |||
-- Fishing (less Junk & Special items) | |||
levelReq = item.fishingLevel | |||
elseif skillID == SkillEnum.Cooking then | |||
-- Cooking (less Perfect items) | |||
levelReq = item.cookingLevel | |||
elseif skillID == SkillEnum.Mining then | |||
-- Mining | |||
local rock = SkillData.Mining.Rocks[masteryID + 1] | |||
if rock ~= nil then | |||
levelReq = rock.levelRequired | |||
end | |||
elseif skillID == SkillEnum.Smithing then | |||
-- Smithing | |||
local recipe = SkillData.Smithing.Recipes[masteryID + 1] | |||
if recipe ~= nil then | |||
levelReq = recipe.level | |||
end | |||
elseif skillID == SkillEnum.Fletching then | |||
-- Fletching | |||
levelReq = item.fletchingLevel | |||
elseif skillID == SkillEnum.Crafting then | |||
-- Crafting | |||
levelReq = item.craftingLevel | |||
elseif skillID == SkillEnum.Runecrafting then | |||
-- Runecrafting | |||
levelReq = item.runecraftingLevel | |||
elseif skillID == SkillEnum.Herblore then | |||
-- Herblore | |||
local potion = SkillData.Herblore.Potions[masteryID + 1] | |||
if potion ~= nil then | |||
levelReq = potion.level | |||
end | |||
elseif skillID == SkillEnum.Summoning then | |||
-- Summoning | |||
levelReq = item.summoningLevel | |||
end | |||
if levelReq ~= nil then | |||
table.insert(lineArray, Icons._SkillReq(skill, levelReq)) | |||
end | |||
end | end | ||
-- | -- Woodcutting | ||
for i, tree in ipairs(SkillData.Woodcutting.Trees) do | |||
if tree.logID == item.id then | |||
table.insert(lineArray, Icons._SkillReq('Woodcutting', tree.levelRequired)) | |||
break | |||
end | |||
end | end | ||
-- | -- Woodcutting (Nests) | ||
if item. | if item.name == 'Bird Nest' then | ||
table.insert(lineArray, Icons._SkillReq( | table.insert(lineArray, Icons._SkillReq('Woodcutting', 1)) | ||
end | end | ||
-- | -- Fishing (Junk & Special items) | ||
if (item.category == "Fishing" and (item.type == "Junk" or item.type == "Special")) then | if (item.category == "Fishing" and (item.type == "Junk" or item.type == "Special")) then | ||
table.insert(lineArray, Icons.Icon({"Fishing", type='skill', notext=true})..' [[Fishing#'..item.type..'|'..item.type..']]') | table.insert(lineArray, Icons.Icon({"Fishing", type='skill', notext=true})..' [[Fishing#'..item.type..'|'..item.type..']]') | ||
end | end | ||
Line 831: | Line 884: | ||
function p._getItemSuperheatTable(item) | function p._getItemSuperheatTable(item) | ||
--Manually build the Superheat Item table | --Manually build the Superheat Item table | ||
local | -- Validate that the item can be superheated | ||
local coalString = '' | local canSuperheat, smithRecipe = true, nil | ||
for i, mat in | if type(item.masteryID) ~= 'table' then | ||
canSuperheat = false | |||
elseif item.masteryID[1] ~= SkillEnum.Smithing then | |||
canSuperheat = false | |||
else | |||
smithRecipe = SkillData.Smithing.Recipes[item.masteryID[2] + 1] | |||
if smithRecipe == nil or smithRecipe.category ~= 0 then | |||
canSuperheat = false | |||
end | |||
end | |||
if not canSuperheat then | |||
return 'ERROR: The item "' .. item.name .. '" cannot be superheated[[Category:Pages with script errors]]' | |||
end | |||
local oreStringPart, coalString = {}, '' | |||
for i, mat in ipairs(item.smithReq) do | |||
local thisMat = Items.getItemByID(mat.id) | local thisMat = Items.getItemByID(mat.id) | ||
if thisMat.name == 'Coal Ore' then | if thisMat.name == 'Coal Ore' then | ||
coalString = | coalString = Icons.Icon({thisMat.name, type='item', notext='true', qty=mat.qty}) | ||
else | else | ||
table.insert(oreStringPart, Icons.Icon({thisMat.name, type='item', notext='true', qty=mat.qty})) | |||
end | end | ||
end | end | ||
Line 854: | Line 921: | ||
for i, sName in pairs(spellNames) do | for i, sName in pairs(spellNames) do | ||
local spell = Magic.getSpell(sName, 'AltMagic') | local spell = Magic.getSpell(sName, 'AltMagic') | ||
table.insert(superheatTable, '\r\n|-\r\n|'..Icons.Icon({spell.name, type='spell', notext=true, size=50})) | |||
table.insert( | table.insert(superheatTable, '||'..Icons.Icon({spell.name, type='spell', noicon=true})..'||style="text-align:right;"|'..smithRecipe.level) | ||
table.insert( | table.insert(superheatTable, '||style="text-align:right;"|'..spell.level..'||style="text-align:right;"|'..spell.baseExperience) | ||
table.insert( | table.insert(superheatTable, '||style="text-align:right;"|'..spell.productionRatio) | ||
table.insert( | table.insert(superheatTable, '|| '..table.concat(oreStringPart, ', ')) | ||
if spell.consumes == 2 then | |||
-- 2 = Superheat with coal, 3 = Superheat without coal | |||
table.insert(superheatTable, (Shared.tableCount(oreStringPart) > 0 and ', ' or '') .. coalString) | |||
end | end | ||
table.insert( | table.insert(superheatTable, '||style="text-align:center"| ' .. Magic._getSpellRunes(spell)) | ||
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 | ||
Line 909: | Line 967: | ||
end | end | ||
if item. | if type(item.masteryID) == 'table' and item.masteryID[1] == SkillEnum.Smithing then | ||
table.insert(resultPart, '\r\n==='..Icons.Icon({'Alt Magic', type='skill'})..'===\r\n'..p._getItemSuperheatTable(item)) | local recipe = SkillData.Smithing.Recipes[item.masteryID[2] + 1] | ||
if recipe ~= nil and recipe.category == 0 then | |||
table.insert(resultPart, '\r\n==='..Icons.Icon({'Alt Magic', type='skill'})..'===\r\n'..p._getItemSuperheatTable(item)) | |||
end | |||
end | end | ||