17,101
edits
(_getCreationTable: Fix generation of various farming produce) |
(Update for v1.0.3) |
||
Line 4: | Line 4: | ||
local ItemData = mw.loadData('Module:Items/data') | local ItemData = mw.loadData('Module:Items/data') | ||
local SkillData = mw.loadData('Module:Skills/data') | local SkillData = mw.loadData('Module:Skills/data') | ||
local MagicData = mw.loadData('Module:Magic/data') | |||
local Constants = require('Module:Constants') | local Constants = require('Module:Constants') | ||
Line 15: | Line 16: | ||
local GatheringSkills = require('Module:Skills/Gathering') | local GatheringSkills = require('Module:Skills/Gathering') | ||
local SkillEnum = mw.loadData('Module:Constants/data').skill | |||
-- Implements overrides for sources which cannot be obtained from game data | -- Implements overrides for sources which cannot be obtained from game data | ||
-- Currently only overrides for dungeon sources are implemented here | -- Currently only overrides for dungeon sources are implemented here | ||
Line 24: | Line 26: | ||
} | } | ||
} | } | ||
function p._getCreationTable(item) | function p._getCreationTable(item) | ||
Line 47: | Line 44: | ||
if skillID == SkillEnum.Fishing then | if skillID == SkillEnum.Fishing then | ||
-- Fishing | -- Fishing | ||
local fish = SkillData.Fishing.Fish[masteryID + 1] | |||
if fish ~= nil and fish.itemID == item.id then | |||
lvl = fish.level | |||
xp = fish.baseXP | |||
qty = 1 | |||
time = fish.baseMinInterval / 1000 | |||
maxTime = fish.baseMaxInterval / 1000 | |||
table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time, maxTime)) | |||
lvl = | |||
xp = | |||
table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time)) | |||
end | end | ||
elseif skillID == SkillEnum.Mining then | elseif skillID == SkillEnum.Mining then | ||
Line 76: | Line 66: | ||
table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time, nil, specialReq)) | table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time, nil, specialReq)) | ||
end | end | ||
elseif | elseif Shared.contains({SkillEnum.Smithing, SkillEnum.Fletching, SkillEnum.Crafting, | ||
-- Smithing | SkillEnum.Runecrafting, SkillEnum.Herblore}, skillID) then | ||
local recipe = SkillData | -- Smithing, Fletching, Crafting, Runecrafting, Herblore | ||
-- All have somewhat consistent recipe data structures | |||
local recipeKey = (skillID == SkillEnum.Herblore and 'Potions') or 'Recipes' | |||
local recipe = SkillData[skill][recipeKey][masteryID + 1] | |||
if recipe ~= nil then | if recipe ~= nil then | ||
local masteryReq = nil | |||
local itemMatch = (recipe.itemID == item.id) | |||
if skillID == SkillEnum.Herblore then | |||
-- For Herblore, we need to check a table of potion IDs & determine the mastery requirement | |||
for i, potionID in ipairs(recipe.potionIDs) do | |||
if potionID == item.id then | |||
itemMatch = true | |||
masteryReq = SkillData.Herblore.TierMasteryLevels[i] | |||
break | |||
end | |||
end | |||
end | |||
if itemMatch then | |||
local baseTime = { | |||
[SkillEnum.Smithing] = 2, | |||
[SkillEnum.Fletching] = 2, | |||
[SkillEnum.Crafting] = 3, | |||
[SkillEnum.Runecrafting] = 2, | |||
[SkillEnum.Herblore] = 2 | |||
} | |||
local baseQty = recipe.baseQuantity or 1 | |||
lvl = recipe.level | |||
xp = recipe.baseXP | |||
time = baseTime[skillID] | |||
if masteryReq ~= nil and masteryReq > 1 then | |||
specialReq = Icons._MasteryReq(item.name, masteryReq, false) | |||
end | |||
-- Some items (such as Arrow shafts) have multiple recipes | |||
if type(recipe.alternativeCosts) == 'table' then | |||
local reqPart, qtyPart = {}, {} | |||
for i, altCost in ipairs(recipe.alternativeCosts) do | |||
local reqSubPart = {} | |||
for j, itemCost in ipairs(altCost.itemCosts) do | |||
local reqItem = Items.getItemByID(itemCost.id) | |||
if reqItem == nil then | |||
table.insert(reqSubPart, itemCost.qty .. 'x ?????') | |||
else | |||
table.insert(reqSubPart, Icons.Icon({reqItem.name, type='item', qty=altCost.itemCosts.qty})) | |||
end | |||
end | |||
table.insert(reqPart, table.concat(reqSubPart, ', ')) | |||
table.insert(qtyPart, Shared.formatnum(baseQty * altCost.quantityMultiplier)) | |||
end | |||
local sep = "<br/>'''OR''' " | |||
req = table.concat(reqPart, sep) | |||
qty = table.concat(qtyPart, sep) | |||
table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time, maxTime, specialReq)) | |||
elseif type(recipe.itemCosts) == 'table' and Shared.tableCount(recipe.itemCosts) > 0 then | |||
req = recipe.itemCosts | |||
table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, baseQty, time, maxTime, specialReq)) | |||
end | |||
end | |||
end | |||
elseif skillID == SkillEnum.Summoning then | |||
-- Summoning | |||
local recipe = SkillData.Summoning.Marks[masteryID + 1] | |||
if recipe ~= nil and recipe.itemID == item.id then | |||
lvl = recipe.level | lvl = recipe.level | ||
xp = recipe.baseXP | xp = recipe.baseXP | ||
qty = recipe.baseQuantity | qty = recipe.baseQuantity | ||
time = | time = 5 | ||
-- Create item requirements text | |||
local ShardCostArray, OtherCostArray = {}, {} | |||
-- Shards | |||
for j, cost in ipairs(recipe.itemCosts) do | |||
local shard = Items.getItemByID(cost.id) | |||
if shard ~= nil then | |||
table.insert(ShardCostArray, Icons.Icon({shard.name, type='item', notext=true, qty=cost.qty})) | |||
local | |||
if | |||
table.insert(ShardCostArray, Icons.Icon({ | |||
end | end | ||
end | end | ||
-- Other costs | |||
local recipeGPCost = SkillData.Summoning.RecipeGPCost | |||
if recipe.gpCost > 0 then | |||
table.insert(OtherCostArray, Icons.GP(recipe.gpCost)) | |||
end | |||
if recipe.scCost > 0 then | |||
table.insert(OtherCostArray, Icons.SC(recipe.scCost)) | |||
for | end | ||
for j, nonShardID in ipairs(recipe.nonShardItemCosts) do | |||
local nonShard = Items.getItemByID(nonShardID) | |||
if nonShard ~= nil then | |||
local itemValue = math.max(item.sellsFor, 20) | |||
local nonShardQty = math.max(1, math.floor(recipeGPCost / itemValue)) | |||
table.insert(OtherCostArray, Icons.Icon({nonShard.name, type='item', notext=true, qty=nonShardQty})) | |||
table.insert( | |||
end | end | ||
end | end | ||
table. | req = table.concat(ShardCostArray, ', ') | ||
if #OtherCostArray > 0 then | |||
req = req .. '<br/>and one of the following:<br/>' .. table.concat(OtherCostArray, "<br/>'''OR''' ") | |||
end | |||
table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time)) | |||
end | end | ||
end | end | ||
end | end | ||
-- Woodcutting | -- Woodcutting | ||
if item.type == | if item.type == 'Logs' then | ||
-- Determine which tree (if any) the log is from | -- Determine which tree (if any) the log is from | ||
for i, tree in ipairs(SkillData.Woodcutting.Trees) do | for i, tree in ipairs(SkillData.Woodcutting.Trees) do | ||
Line 184: | Line 182: | ||
end | end | ||
end | end | ||
-- Cooking | |||
-- | if item.canEat then | ||
if item.type == 'Herb' or item.type == 'Logs' or (item.type == 'Food' and item.category ~= 'Cooking | for i, recipe in ipairs(SkillData.Cooking.Recipes) do | ||
if recipe.itemID == item.id or recipe.perfectCookID == item.id then | |||
skill = 'Cooking' | |||
lvl = recipe.level | |||
xp = recipe.baseXP | |||
req = recipe.itemCosts | |||
qty = recipe.baseQuantity | |||
time = recipe.baseInterval / 1000 | |||
table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time)) | |||
break | |||
end | |||
end | |||
end | |||
-- Farming | |||
if item.type == 'Herb' or item.type == 'Logs' or (item.type == 'Food' and item.category ~= 'Cooking') then | |||
-- Herb means farming | -- Herb means farming | ||
-- Logs/Food might mean farming or might not. Depends on the item | -- Logs/Food might mean farming or might not. Depends on the item | ||
for i, | for i, seed in ipairs(ItemData.Items) do | ||
if | if seed.grownItemID ~= nil and seed.grownItemID == item.id then | ||
skill = 'Farming' | skill = 'Farming' | ||
lvl = | lvl = seed.farmingLevel | ||
xp = | xp = seed.farmingXP | ||
time = | time = seed.timeToGrow | ||
if item.type == 'Logs' then | if item.type == 'Logs' then | ||
qty = 35 | qty = 35 | ||
Line 200: | Line 212: | ||
qty = 15 | qty = 15 | ||
end | end | ||
req = {{id = | req = {{id = seed.id, qty = (seed.seedsRequired ~= nil and seed.seedsRequired or 1)}} | ||
table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time)) | table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time)) | ||
break | break | ||
end | end | ||
end | end | ||
Line 223: | Line 222: | ||
-- Bars are handled by getItemSuperheatTable() | -- Bars are handled by getItemSuperheatTable() | ||
-- Gems are handled by _getItemLootSourceTable() | -- Gems are handled by _getItemLootSourceTable() | ||
for i, altSpell in ipairs(MagicData.AltMagic) do | |||
if type(altSpell.produces) == 'number' and altSpell.produces == item.id then | |||
table.insert(tables, p._buildAltMagicTable(altSpell)) | |||
end | |||
end | end | ||
Line 241: | Line 237: | ||
function p.getAltMagicTable(frame) | function p.getAltMagicTable(frame) | ||
local spellName = frame.args ~= nil and frame.args[1] or frame | local spellName = frame.args ~= nil and frame.args[1] or frame | ||
return p. | local spell = Magic.getSpell(spellName, 'AltMagic') | ||
if spell == nil then | |||
return 'ERROR: Could not find Alt Magic spell "' .. spellName .. '"[[Category:Pages with script errors]]' | |||
else | |||
return p._buildAltMagicTable(spell) | |||
end | |||
end | end | ||
function p. | function p._buildAltMagicTable(spell) | ||
local resultPart = {} | local resultPart = {} | ||
table.insert(resultPart, '{|class="wikitable"\r\n|-') | table.insert(resultPart, '{|class="wikitable"\r\n|-') | ||
Line 268: | Line 268: | ||
-- 5 = Coal ore | -- 5 = Coal ore | ||
-- Superheat (2, 3) is handled by _getItemSuperheatTable() | -- Superheat (2, 3) is handled by _getItemSuperheatTable() | ||
if spell.consumes ~= nil then | if spell.consumes ~= nil then | ||
local consumeText = { | local consumeText = { | ||
Line 286: | Line 285: | ||
--Add runes | --Add runes | ||
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Runes\r\n| ' .. Magic._getSpellRunes(spell)) | 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.productionRatio) | 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.baseExperience) | 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 346: | Line 334: | ||
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Base Creation Time') | table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Base Creation Time') | ||
table.insert(resultPart, '\r\n|'..Shared.formatnum(Shared.round(time, 2, 0))..'s') | table.insert(resultPart, '\r\n|'..Shared.formatnum(Shared.round(time, 2, 0))..'s') | ||
if maxTime ~= nil then table.insert(resultPart, ' - '..Shared.formatnum(Shared.round(maxTime, 2, 0))..'s') end | if maxTime ~= nil and maxTime > time then table.insert(resultPart, ' - '..Shared.formatnum(Shared.round(maxTime, 2, 0))..'s') end | ||
table.insert(resultPart, '\r\n|}') | table.insert(resultPart, '\r\n|}') | ||
Line 420: | Line 408: | ||
--Next: Can we find it in a box? | --Next: Can we find it in a box? | ||
--While we're here, check for upgrades | --While we're here, check for upgrades, and growing | ||
local | local lootPart, upgradePart, growPart = {}, {}, {} | ||
for i, item2 in pairs(ItemData.Items) do | for i, item2 in pairs(ItemData.Items) do | ||
if item2.dropTable ~= nil then | if item2.dropTable ~= nil then | ||
for j, loot in | for j, loot in ipairs(item2.dropTable) do | ||
if loot[1] == item.id then | if loot[1] == item.id then | ||
table.insert(lootPart, Icons.Icon({item2.name, type='item', notext=true})) | |||
break | |||
end | end | ||
end | end | ||
end | end | ||
if item2.trimmedItemID == item.id then | if item2.trimmedItemID ~= nil and item2.trimmedItemID == item.id then | ||
table.insert(upgradePart, Icons.Icon({item2.name, type='item', notext=true})) | |||
end | end | ||
if item2.grownItemID == item.id then | if item2.grownItemID == item.id then | ||
-- Farming | -- Farming | ||
table.insert(growPart, Icons.Icon({item2.name, type='item', notext=true})) | |||
end | end | ||
end | end | ||
if | if #lootPart > 0 then | ||
if | table.insert(lineArray, 'Opening: ' .. table.concat(lootPart, ',')) | ||
if | end | ||
if #upgradePart > 0 then | |||
table.insert(categoryArray, '[[Category:Upgraded Items]]') | |||
table.insert(lineArray, 'Upgrading: ' .. table.concat(upgradePart, ',')) | |||
end | |||
if #growPart > 0 then | |||
table.insert(categoryArray, '[[Category:Harvestable Items]]') | |||
table.insert(lineArray, 'Growing: ' .. table.concat(growPart, ',')) | |||
end | |||
--Next: Can we take it from somebody else -without- killing them? | --Next: Can we take it from somebody else -without- killing them? | ||
local thiefItems = GatheringSkills.getThievingSourcesForItem(item.id) | local thiefItems = GatheringSkills.getThievingSourcesForItem(item.id) | ||
if type(thiefItems) == 'table' then | |||
if | local thiefPart = {} | ||
for i, thiefRow in ipairs(thiefItems) do | |||
for i, thiefRow in | |||
if thiefRow.npc == 'all' then | if thiefRow.npc == 'all' then | ||
--if ' | --if 'all' is the npc, this is a rare item so just say 'Thieving level 1' | ||
table.insert(lineArray, Icons._SkillReq('Thieving', 1)) | |||
else | else | ||
table.insert(thiefPart, Icons.Icon({thiefRow.npc, type='thieving', notext=true})) | |||
end | end | ||
end | |||
if #thiefPart > 0 then | |||
table.insert(lineArray, 'Pickpocketing: ' .. table.concat(thiefPart, ',')) | |||
end | end | ||
end | end | ||
-- | --Check if we can make it ourselves | ||
--AstrologyCheck | --AstrologyCheck (Just a brute force for now because only two items) | ||
if Shared.contains({'Stardust', 'Golden Stardust'}, item.name) then | |||
if | table.insert(lineArray, Icons.Icon({'Astrology', type='skill'})) | ||
table.insert(lineArray, Icons.Icon({ | |||
end | end | ||
-- Sources discoverable through mastery IDs | -- Sources discoverable through mastery IDs | ||
-- Does _not_ handle: | |||
-- Fishing: Junk, special items | |||
-- Cooking: perfect items | |||
if type(item.masteryID) == 'table' then | if type(item.masteryID) == 'table' then | ||
local skillID, masteryID = item.masteryID[1], item.masteryID[2] | local skillID, masteryID = item.masteryID[1], item.masteryID[2] | ||
local skill | local skill = Constants.getSkillName(skillID) | ||
local keyData = { | |||
[SkillEnum.Fishing] = { ["recipe"] = 'Fish' }, | |||
[SkillEnum.Mining] = { ["recipe"] = 'Rocks', ["level"] = 'levelRequired' }, | |||
[SkillEnum.Smithing] = {}, | |||
[SkillEnum.Fletching] = {}, | |||
[SkillEnum.Crafting] = {}, | |||
[SkillEnum.Runecrafting] = {}, | |||
[SkillEnum.Herblore] = { ["recipe"] = 'Potions' }, | |||
[SkillEnum.Summoning] = { ["recipe"] = 'Marks' } | |||
if | } | ||
local keys = keyData[skillID] | |||
if type(keys) == 'table' then | |||
if keys.recipe == nil then | |||
keys.recipe = 'Recipes' | |||
end | end | ||
if keys.level == nil then | |||
keys.level = 'level' | |||
end | end | ||
local recipe = SkillData[skill][keys.recipe][masteryID + 1] | |||
if recipe ~= nil and recipe.itemID == item.id then | |||
local levelReq = recipe[keys.level] | |||
if levelReq ~= nil then | |||
table.insert(lineArray, Icons._SkillReq(skill, levelReq)) | |||
end | |||
end | end | ||
end | end | ||
end | end | ||
Line 550: | Line 506: | ||
end | end | ||
-- Woodcutting | -- Woodcutting: Nests | ||
if item.name == 'Bird Nest' then | if item.name == 'Bird Nest' then | ||
table.insert(lineArray, Icons._SkillReq('Woodcutting', 1)) | table.insert(lineArray, Icons._SkillReq('Woodcutting', 1)) | ||
end | end | ||
-- Fishing | -- Fishing: Junk & Specials | ||
if (item. | if Shared.contains(SkillData.Fishing.JunkItems, item.id) then | ||
table.insert(lineArray, Icons.Icon({'Fishing', type='skill', notext=true}) .. ' [[Fishing#Junk|Junk]]') | |||
else | |||
for i, specialItem in ipairs(SkillData.Fishing.SpecialItems) do | |||
if specialItem[1] == item.id then | |||
table.insert(lineArray, Icons.Icon({'Fishing', type='skill', notext=true}) .. ' [[Fishing#Special|Special]]') | |||
break | |||
end | |||
end | |||
end | |||
-- Cooking | |||
if item.canEat then | |||
for i, recipe in ipairs(SkillData.Cooking.Recipes) do | |||
if recipe.itemID == item.id or recipe.perfectCookID == item.id then | |||
table.insert(lineArray, Icons._SkillReq('Cooking', recipe.level)) | |||
break | |||
end | |||
end | |||
end | |||
-- Alt. Magic | |||
for i, altSpell in ipairs(MagicData.AltMagic) do | |||
if type(altSpell.produces) == 'number' and | |||
((altSpell.produces == -3 and item.type == 'Gem' and item.name ~= 'Jadestone') | |||
or (altSpell.produces == -2 and item.type == 'Bar') | |||
or (altSpell.produces > 0 and altSpell.produces == item.id)) then | |||
table.insert(lineArray, Icons.Icon({"Alt. Magic", type='skill'})) | |||
break | |||
end | |||
end | end | ||
Line 566: | Line 550: | ||
end | end | ||
--Gems can be acquired from | --Gems can be acquired from Mining | ||
if item.type == 'Gem' and item.name ~= 'Jadestone' then | if item.type == 'Gem' and item.name ~= 'Jadestone' then | ||
table.insert(lineArray, Icons.Icon({"Mining", type='skill', notext=true})..' [[Mining#Gems|Gem]]') | table.insert(lineArray, Icons.Icon({"Mining", type='skill', notext=true})..' [[Mining#Gems|Gem]]') | ||
end | end | ||
Line 584: | Line 561: | ||
Jewel = {'Firemaking', 'Cooking', 'Smithing', 'Fletching', 'Crafting', 'Runecrafting', 'Herblore', 'Summoning'} | Jewel = {'Firemaking', 'Cooking', 'Smithing', 'Fletching', 'Crafting', 'Runecrafting', 'Herblore', 'Summoning'} | ||
} | } | ||
local rhaSkList = | local rhaSkList, subText = nil, '' | ||
if item.name == 'Circlet of Rhaelyx' then | if item.name == 'Circlet of Rhaelyx' then | ||
rhaSkList = rhaSkills.Circlet | rhaSkList = {rhaSkills.Circlet} | ||
elseif item.name == 'Jewel of Rhaelyx' then | elseif item.name == 'Jewel of Rhaelyx' then | ||
rhaSkList = rhaSkills.Jewel | rhaSkList = {rhaSkills.Jewel} | ||
elseif item.name == 'Mysterious Stone' then | elseif item.name == 'Mysterious Stone' then | ||
rhaSkList = rhaSkills.Jewel | rhaSkList = {rhaSkills.Jewel, rhaSkills.Circlet} | ||
subText = '<br/>after finding ' .. Icons.Icon({'Crown of Rhaelyx', type='item'}) | |||
end | end | ||
local rhaStrPart = {} | local rhaStrPart = {} | ||
for i, | for i, skillList in ipairs(rhaSkList) do | ||
table.insert(rhaStrPart, Icons.Icon({skillName, type='skill', notext=true})) | for j, skillName in ipairs(skillList) do | ||
table.insert(rhaStrPart, Icons.Icon({skillName, type='skill', notext=true})) | |||
end | |||
end | end | ||
table.insert(lineArray, 'Any action in: ' .. table.concat(rhaStrPart, ', ') .. subText) | |||
end | end | ||
Line 609: | Line 584: | ||
table.insert(lineArray, Icons._SkillReq(Constants.getSkillName(item.skill), 1)) | table.insert(lineArray, Icons._SkillReq(Constants.getSkillName(item.skill), 1)) | ||
end | end | ||
-- Golbin Raid exclusive items | -- Golbin Raid exclusive items | ||
if item.golbinRaidExclusive then | if item.golbinRaidExclusive then | ||
Line 681: | Line 656: | ||
table.insert(rowPart, '\r\n|style="text-align: left;"|'..type) | table.insert(rowPart, '\r\n|style="text-align: left;"|'..type) | ||
table.insert(rowPart, '\r\n|style="text-align: right;" data-sort-value="'..qty..'"|'..minqty) | table.insert(rowPart, '\r\n|style="text-align: right;" data-sort-value="'..qty..'"|'..Shared.formatnum(minqty)) | ||
if qty ~= minqty then table.insert(rowPart, ' - '..qty) end | if qty ~= minqty then table.insert(rowPart, ' - '..Shared.formatnum(qty)) end | ||
local chance = weight / totalWeight * 100 | local chance = weight / totalWeight * 100 | ||
-- If chance is less than 0.10% then show 2 significant figures, otherwise 2 decimal places | -- If chance is less than 0.10% then show 2 significant figures, otherwise 2 decimal places | ||
Line 767: | Line 742: | ||
--Next: Can we find it by rummaging around in another item? | --Next: Can we find it by rummaging around in another item? | ||
for i, item2 in | for i, item2 in ipairs(ItemData.Items) do | ||
if item2.dropTable ~= nil then | if item2.dropTable ~= nil then | ||
local qty = 1 | local qty = 1 | ||
Line 790: | Line 765: | ||
local thiefType = Icons.Icon({"Thieving", type='skill'}) | local thiefType = Icons.Icon({"Thieving", type='skill'}) | ||
local thiefItems = GatheringSkills.getThievingSourcesForItem(item.id) | local thiefItems = GatheringSkills.getThievingSourcesForItem(item.id) | ||
for i, thiefRow in | for i, thiefRow in ipairs(thiefItems) do | ||
local sourceTxt = '' | local sourceTxt = '' | ||
if thiefRow.npc == 'all' then | if thiefRow.npc == 'all' then | ||
Line 801: | Line 776: | ||
--Bonus overtime: Special Fishing table & mining gem table. Also Rags to Riches | --Bonus overtime: Special Fishing table & mining gem table. Also Rags to Riches | ||
if Shared.contains(SkillData.Fishing.JunkItems, item.id) then | |||
local fishSource = '[[Fishing#Junk|Junk]]' | |||
local fishType = Icons.Icon({'Fishing', type='skill'}) | |||
local fishTotWeight = Shared.tableCount(SkillData.Fishing.JunkItems) | |||
table.insert(dropRows, {source = fishSource, type = fishType, minqty = 1, qty = 1, weight = 1, totalWeight = fishTotWeight}) | |||
else | |||
local fishTotWeight, fishItem = 0, nil | |||
for i, specialItem in ipairs(SkillData.Fishing.SpecialItems) do | |||
if specialItem[1] == item.id then | |||
fishItem = specialItem | |||
end | |||
fishTotWeight = fishTotWeight + specialItem[2] | |||
end | |||
if fishItem ~= nil then | |||
local fishSource = '[[Fishing#Special|Special]]' | |||
local fishType = Icons.Icon({'Fishing', type='skill'}) | |||
table.insert(dropRows, {source = fishSource, type = fishType, minqty = fishItem[3], qty = fishItem[3], weight = fishItem[2], totalWeight = fishTotWeight}) | |||
end | |||
end | |||
--Jadestone is special and doesn't count | --Jadestone is special and doesn't count | ||
if item.type == 'Gem' and item.name ~= 'Jadestone' then | if item.type == 'Gem' and item.name ~= 'Jadestone' then | ||
Line 811: | Line 805: | ||
table.insert(dropRows, {source = '[[Mining#Gems|Gem]]', type = mineType, minqty = 1, qty = 1, weight = thisGemChance, totalWeight = totalGemChance}) | table.insert(dropRows, {source = '[[Mining#Gems|Gem]]', type = mineType, minqty = 1, qty = 1, weight = thisGemChance, totalWeight = totalGemChance}) | ||
local magicType = Icons.Icon({'Magic', type = 'skill'}) | local magicType = Icons.Icon({'Magic', type = 'skill'}) | ||
for i, altSpell in ipairs(MagicData.AltMagic) do | |||
if type(altSpell.produces) == 'number' and altSpell.produces == -3 then | |||
table.insert(dropRows, {source = Icons.Icon({altSpell.name, type='spell'}), type = magicType, minqty = 1, qty = 1, weight = thisGemChance, totalWeight = totalGemChance}) | |||
end | |||
end | |||
end | end | ||
Line 832: | Line 817: | ||
table.sort(dropRows, function(a, b) | table.sort(dropRows, function(a, b) | ||
if a.weight / a.totalWeight == b.weight / b.totalWeight then | if a.weight / a.totalWeight == b.weight / b.totalWeight then | ||
return a.minqty + a.qty > b.minqty + b.qty | if a.minqty + a.qty == b.minqty + b.qty then | ||
return (a.type == b.type and a.source < b.source) or a.type < b.type | |||
else | |||
return a.minqty + a.qty > b.minqty + b.qty | |||
end | |||
else | else | ||
return a.weight / a.totalWeight > b.weight / b.totalWeight | return a.weight / a.totalWeight > b.weight / b.totalWeight | ||
Line 936: | Line 925: | ||
table.insert(superheatTable, '||style="text-align:right;"|'..spell.productionRatio) | table.insert(superheatTable, '||style="text-align:right;"|'..spell.productionRatio) | ||
table.insert(superheatTable, '|| '..table.concat(oreStringPart, ', ')) | table.insert(superheatTable, '|| '..table.concat(oreStringPart, ', ')) | ||
if spell.consumes == 2 then | if spell.consumes == 2 and coalString ~= '' then | ||
-- 2 = Superheat with coal, 3 = Superheat without coal | -- 2 = Superheat with coal, 3 = Superheat without coal | ||
table.insert(superheatTable, (Shared.tableCount(oreStringPart) > 0 and ', ' or '') .. coalString) | table.insert(superheatTable, (Shared.tableCount(oreStringPart) > 0 and ', ' or '') .. coalString) | ||
Line 1,043: | Line 1,032: | ||
-- - A monster before the boss, which doesn't drop anything except shards (checked above) | -- - A monster before the boss, which doesn't drop anything except shards (checked above) | ||
-- - A boss monster, whose drops are accounted for in data from Areas instead | -- - A boss monster, whose drops are accounted for in data from Areas instead | ||
for j, loot in ipairs(monster.lootTable) do | for j, loot in ipairs(monster.lootTable) do | ||
weight = weight + loot[2] | weight = weight + loot[2] | ||
Line 1,068: | Line 1,056: | ||
return p._getItemMonsterSources(item) | return p._getItemMonsterSources(item) | ||
end | end | ||
--[==[ | |||
-- Uncomment this block and execute 'p.test()' within the debug console | |||
-- to test after making changes | |||
function p.test() | |||
local checkItems = { | |||
'Gold Bar', | |||
'Raw Shrimp', | |||
'Coal Ore', | |||
'Rune Platebody', | |||
'Arrow Shafts', | |||
'Yew Longbow', | |||
'Water Rune', | |||
'Steam Rune', | |||
'Controlled Heat Potion II', | |||
'Wolf', | |||
'Cyclops', | |||
'Leprechaun', | |||
'Redwood Logs', | |||
'Carrot Cake', | |||
'Carrot Cake (Perfect)', | |||
'Mantalyme Herb', | |||
'Carrot', | |||
'Topaz', | |||
'Rune Essence', | |||
'Sanguine Blade', | |||
'Ring of Power', | |||
'Infernal Claw', | |||
'Chapeau Noir', | |||
'Stardust', | |||
'Rope', | |||
'Ancient Ring of Mastery', | |||
'Mysterious Stone', | |||
'Mastery Token (Cooking)', | |||
'Gem Gloves' | |||
} | |||
local checkFuncs = { | |||
p.getItemSourceTables, | |||
--p.getCreationTable, | |||
p.getItemSources, | |||
--p.getItemLootSourceTable, | |||
} | |||
local errCount = 0 | |||
for i, item in ipairs(checkItems) do | |||
local param = {args={item}} | |||
mw.log('==' .. item .. '==') | |||
for j, func in ipairs(checkFuncs) do | |||
local callSuccess, retVal = pcall(func, param) | |||
if not callSuccess then | |||
errCount = errCount + 1 | |||
mw.log('Error with item "' .. item .. '": ' .. retVal) | |||
else | |||
mw.log(retVal) | |||
end | |||
end | |||
end | |||
if errCount == 0 then | |||
mw.log('Test successful') | |||
else | |||
mw.log('Test failed with ' .. errCount .. ' failures') | |||
end | |||
end | |||
--]==] | |||
return p | return p |