914
edits
mNo edit summary |
m (Add custom separator for ItemSources) |
||
(5 intermediate revisions by 4 users not shown) | |||
Line 11: | Line 11: | ||
local Monsters = require('Module:Monsters') | local Monsters = require('Module:Monsters') | ||
local Skills = require('Module:Skills') | local Skills = require('Module:Skills') | ||
local SourceOverrides = { | |||
['melvorAoD:EarthGolem'] = 'Earth Golem (AoD)' | |||
} | |||
function p._getCreationTable(item) | function p._getCreationTable(item) | ||
Line 59: | Line 63: | ||
local category = GameData.getEntityByID(skillData.categories, recipe.categoryID) | local category = GameData.getEntityByID(skillData.categories, recipe.categoryID) | ||
qty = 5 * category.harvestMultiplier | qty = 5 * category.harvestMultiplier | ||
end | end | ||
-- Action time | -- Action time | ||
Line 291: | Line 292: | ||
end | end | ||
function p._getItemSources(item, asList, addCategories) | function p._getItemSources(item, asList, addCategories, separator) | ||
local lineArray = {} | local lineArray = {} | ||
local categoryArray = {} | local categoryArray = {} | ||
local sep = separator or ',' | |||
--Alright, time to go through all the ways you can get an item... | --Alright, time to go through all the ways you can get an item... | ||
Line 302: | Line 304: | ||
if monster.bones ~= nil and monster.bones.itemID == item.id and Monsters._getMonsterBones(monster) ~= nil then | if monster.bones ~= nil and monster.bones.itemID == item.id and Monsters._getMonsterBones(monster) ~= nil then | ||
-- Item is a bone, and is either a shard from God dungeons or dropped by a non-boss monster with a loot table | -- Item is a bone, and is either a shard from God dungeons or dropped by a non-boss monster with a loot table | ||
isDrop = true | |||
elseif monster.barrierPercent ~= nil and 'melvorAoD:Barrier_Dust' == item.id and not Monsters._isDungeonOnlyMonster(monster) then | |||
-- Item is Barrier Dust and is not a dungeon exclusive monster | |||
isDrop = true | isDrop = true | ||
elseif monster.lootTable ~= nil then | elseif monster.lootTable ~= nil then | ||
Line 317: | Line 322: | ||
if isDrop then | if isDrop then | ||
-- Item drops when the monster is killed | -- Item drops when the monster is killed | ||
table.insert(killStrPart, Icons.Icon({ | local iconName = monster.name | ||
if SourceOverrides[monster.id] ~= nil then | |||
iconName = SourceOverrides[monster.id] | |||
end | |||
table.insert(killStrPart, Icons.Icon({iconName, type='monster', notext=true})) | |||
end | end | ||
end | end | ||
Line 342: | Line 351: | ||
if not Shared.tableIsEmpty(dungeonStrPart) then | if not Shared.tableIsEmpty(dungeonStrPart) then | ||
table.insert(lineArray, 'Completing: ' .. table.concat(dungeonStrPart, | table.insert(lineArray, 'Completing: ' .. table.concat(dungeonStrPart, sep)) | ||
end | end | ||
if not Shared.tableIsEmpty(killStrPart) then | if not Shared.tableIsEmpty(killStrPart) then | ||
table.insert(lineArray, 'Killing: ' .. table.concat(killStrPart, | table.insert(lineArray, 'Killing: ' .. table.concat(killStrPart, sep)) | ||
end | end | ||
Line 362: | Line 371: | ||
if not Shared.tableIsEmpty(lootPart) then | if not Shared.tableIsEmpty(lootPart) then | ||
table.insert(lineArray, 'Opening: ' .. table.concat(lootPart, | table.insert(lineArray, 'Opening: ' .. table.concat(lootPart, sep)) | ||
end | end | ||
Line 387: | Line 396: | ||
end | end | ||
local typeText = (catName == 'up' and 'Upgrading') or 'Downgrading' | local typeText = (catName == 'up' and 'Upgrading') or 'Downgrading' | ||
table.insert(lineArray, typeText .. ': ' .. table.concat(parts, | table.insert(lineArray, typeText .. ': ' .. table.concat(parts, sep)) | ||
end | end | ||
end | end | ||
Line 406: | Line 415: | ||
end | end | ||
if not Shared.tableIsEmpty(thiefPart) then | if not Shared.tableIsEmpty(thiefPart) then | ||
table.insert(lineArray, 'Pickpocketing: ' .. table.concat(thiefPart, | table.insert(lineArray, 'Pickpocketing: ' .. table.concat(thiefPart, sep)) | ||
end | end | ||
end | end | ||
Line 416: | Line 425: | ||
end | end | ||
if not Shared.tableIsEmpty(castPart) then | if not Shared.tableIsEmpty(castPart) then | ||
table.insert(lineArray, 'Casting: ' .. table.concat(castPart, | table.insert(lineArray, 'Casting: ' .. table.concat(castPart, sep)) | ||
end | end | ||
Line 653: | Line 662: | ||
for i, skillDataAll in ipairs(GameData.rawData.skillData) do | for i, skillDataAll in ipairs(GameData.rawData.skillData) do | ||
local skillData = skillDataAll.data | local skillData = skillDataAll.data | ||
local skillName, displaySkillName = skillData.name, false | |||
-- All general rare drops within the Magic are for Alt. Magic | |||
if skillDataAll.skillID == 'melvorD:Magic' then | |||
skillName, displaySkillName = 'Alt. Magic', true | |||
end | |||
if type(skillData.rareDrops) == 'table' then | if type(skillData.rareDrops) == 'table' then | ||
for j, rareDrop in ipairs(skillData.rareDrops) do | for j, rareDrop in ipairs(skillData.rareDrops) do | ||
Line 683: | Line 697: | ||
end | end | ||
end | end | ||
local skillText = Icons.Icon({skillName, type='skill', notext=true}) | |||
if displaySkillName then | |||
skillText = skillText .. ' (' .. Icons.Icon({skillName, type='skill', noicon=true}) .. ')' | |||
end | |||
table.insert(skillIconList, skillText) | |||
end | end | ||
end | end | ||
Line 772: | Line 790: | ||
table.insert(resultPart, '{| class="wikitable sortable stickyHeader"') | table.insert(resultPart, '{| class="wikitable sortable stickyHeader"') | ||
table.insert(resultPart, '\r\n|- class="headerRow-0"') | table.insert(resultPart, '\r\n|- class="headerRow-0"') | ||
table.insert(resultPart, '\r\n!Source!! | table.insert(resultPart, '\r\n!Source!!Level!!Quantity!!colspan="2"|Chance') | ||
--Set up function for adding rows | --Set up function for adding rows | ||
local buildRow = function(source, | local buildRow = function(source, level, levelNum, minqty, qty, weight, totalWeight, expIcon) | ||
if minqty == nil then minqty = 1 end | if minqty == nil then minqty = 1 end | ||
if expIcon == nil then expIcon = '' end | if expIcon == nil then expIcon = '' end | ||
if level == nil then level = 'N/A' end | |||
local rowPart = {} | local rowPart = {} | ||
table.insert(rowPart, '\r\n|-') | table.insert(rowPart, '\r\n|-') | ||
table.insert(rowPart, '\r\n|style="text-align: left;"|'..source) | table.insert(rowPart, '\r\n|style="text-align: left;"|'..source) | ||
-- | -- Retrieve numeric level value for sorting, or remove anything between [[]] | ||
local | local levelValue = '' | ||
if | if levelNum ~= nil then | ||
levelValue = tostring(levelNum) | |||
table.insert(rowPart, '\r\n|style="text-align: left;" data-sort-value="'.. | else | ||
levelValue = level:match('%[%[.-%]%]%s*(%w+)$') or '' | |||
end | |||
table.insert(rowPart, '\r\n|style="text-align: left;" data-sort-value="'..levelValue..'"|'..expIcon.. level) | |||
table.insert(rowPart, '\r\n|style="text-align: right;" data-sort-value="'..qty..'"|'..Shared.formatnum(minqty)) | table.insert(rowPart, '\r\n|style="text-align: right;" data-sort-value="'..qty..'"|'..Shared.formatnum(minqty)) | ||
if qty ~= minqty then table.insert(rowPart, ' - '..Shared.formatnum(qty)) end | if qty ~= minqty then table.insert(rowPart, ' - '..Shared.formatnum(qty)) end | ||
Line 821: | Line 842: | ||
for i, drop in ipairs(p._getItemMonsterSources(item)) do | for i, drop in ipairs(p._getItemMonsterSources(item)) do | ||
local monster = GameData.getEntityByID('monsters', drop.id) | local monster = GameData.getEntityByID('monsters', drop.id) | ||
local iconName = monster.name | |||
if SourceOverrides[drop.id] ~= nil then | |||
iconName = SourceOverrides[drop.id] | |||
end | |||
if monster ~= nil then | if monster ~= nil then | ||
table.insert(dropRows, {source = Icons.Icon({ | local monsterLevel = Monsters._getMonsterCombatLevel(monster) | ||
table.insert(dropRows, { | |||
source = Icons.Icon({iconName, type='monster'}), | |||
level = Icons.Icon({'Monsters', img='Combat', notext=true}) .. ' Level ' .. Shared.formatnum(monsterLevel), | |||
levelNum = monsterLevel, | |||
minqty = drop.minQty, | |||
qty = drop.maxQty, | |||
weight = drop.dropWt, | |||
totalWeight = drop.totalWt, | |||
expIcon = Icons.getExpansionIcon(drop.id)}) | |||
end | end | ||
end | end | ||
Line 830: | Line 865: | ||
for i, drop in ipairs(p._getItemArchSources(item)) do | for i, drop in ipairs(p._getItemArchSources(item)) do | ||
if drop.name ~= nil then | if drop.name ~= nil then | ||
table.insert(dropRows, {source = Icons.Icon({drop.name, type='poi'}), | table.insert(dropRows, { | ||
source = Icons.Icon({drop.name, type='poi'}), | |||
level = Icons._SkillReq('Archaeology', drop.level) .. ' ('..drop.size..')', | |||
levelNum = drop.level, | |||
minqty = drop.minQty, | |||
qty = drop.maxQty, | |||
weight = drop.dropWt, | |||
totalWeight = drop.totalWt, | |||
expIcon = Icons.getExpansionIcon(drop.id)}) | |||
end | end | ||
end | end | ||
Line 838: | Line 881: | ||
if (dungeon.oneTimeRewardID ~= nil and item.id == dungeon.oneTimeRewardID) or | if (dungeon.oneTimeRewardID ~= nil and item.id == dungeon.oneTimeRewardID) or | ||
(type(dungeon.rewardItemIDs) == 'table' and Shared.contains(dungeon.rewardItemIDs, item.id)) then | (type(dungeon.rewardItemIDs) == 'table' and Shared.contains(dungeon.rewardItemIDs, item.id)) then | ||
table.insert(dropRows, {source = Icons.Icon({dungeon.name, type='dungeon'}), | table.insert(dropRows, { | ||
source = Icons.Icon({dungeon.name, type='dungeon'}), | |||
level = '[[Dungeon]]', | |||
minqty = 1, | |||
qty = 1, | |||
weight = 1, | |||
totalWeight = 1, | |||
expIcon = Icons.getExpansionIcon(dungeon.id)}) | |||
elseif dungeon.eventID ~= nil then | elseif dungeon.eventID ~= nil then | ||
-- Is the item dropped from a combat event (e.g. Impending Darkness event)? | -- Is the item dropped from a combat event (e.g. Impending Darkness event)? | ||
Line 846: | Line 896: | ||
if item.id == itemRewardID then | if item.id == itemRewardID then | ||
local sourceTxt = Icons.Icon({dungeon.name, type='dungeon'}) .. (eventCycle == Shared.tableCount(event.itemRewardIDs) and '' or ', Cycle ' .. eventCycle) | local sourceTxt = Icons.Icon({dungeon.name, type='dungeon'}) .. (eventCycle == Shared.tableCount(event.itemRewardIDs) and '' or ', Cycle ' .. eventCycle) | ||
table.insert(dropRows, {source = sourceTxt, | table.insert(dropRows, { | ||
source = sourceTxt, | |||
level = '[[Dungeon]]', | |||
minqty = 1, | |||
qty = 1, | |||
weight = 1, | |||
totalWeight = 1}) | |||
break | break | ||
end | end | ||
Line 869: | Line 925: | ||
if wt > 0 then | if wt > 0 then | ||
local sourceTxt = Icons.Icon({item2.name, type='item'}) | local sourceTxt = Icons.Icon({item2.name, type='item'}) | ||
table.insert(dropRows, {source = sourceTxt, | table.insert(dropRows, { | ||
source = sourceTxt, | |||
level = '[[Chest]]', | |||
minqty = minQty, | |||
qty = maxQty, | |||
weight = wt, | |||
totalWeight = totalWt, | |||
expIcon = Icons.getExpansionIcon(item2.id)}) | |||
end | end | ||
end | end | ||
Line 883: | Line 946: | ||
sourceTxt = Icons.Icon({thiefRow.npc, type='thieving'}) | sourceTxt = Icons.Icon({thiefRow.npc, type='thieving'}) | ||
end | end | ||
table.insert(dropRows, {source = sourceTxt, | table.insert(dropRows, { | ||
source = sourceTxt, | |||
level = Icons._SkillReq("Thieving", thiefRow.level), | |||
levelNum = thiefRow.level, | |||
minqty = thiefRow.minQty, | |||
qty = thiefRow.maxQty, | |||
weight = thiefRow.wt, | |||
totalWeight = thiefRow.totalWt, | |||
expIcon = Icons.getExpansionIcon(thiefRow.npcID)}) | |||
end | end | ||
Line 891: | Line 962: | ||
local fishType = Icons.Icon({'Fishing', type='skill'}) | local fishType = Icons.Icon({'Fishing', type='skill'}) | ||
local fishTotWeight = Shared.tableCount(SkillData.Fishing.JunkItems) | local fishTotWeight = Shared.tableCount(SkillData.Fishing.JunkItems) | ||
table.insert(dropRows, {source = fishSource, | table.insert(dropRows, { | ||
source = fishSource, | |||
level = Icons._SkillReq("Fishing", 1), | |||
levelNum = 1, | |||
minqty = 1, | |||
qty = 1, | |||
weight = 1, | |||
totalWeight = fishTotWeight}) | |||
else | else | ||
local fishTotWeight, fishItem = 0, nil | local fishTotWeight, fishItem = 0, nil | ||
Line 903: | Line 981: | ||
local fishSource = '[[Fishing#Special|Special]]' | local fishSource = '[[Fishing#Special|Special]]' | ||
local fishType = Icons.Icon({SkillData.Fishing.name, type='skill'}) | local fishType = Icons.Icon({SkillData.Fishing.name, type='skill'}) | ||
table.insert(dropRows, {source = fishSource, | table.insert(dropRows, { | ||
source = fishSource, | |||
level = Icons._SkillReq("Fishing", 1), | |||
levelNum = 1, | |||
minqty = fishItem.minQuantity, | |||
qty = fishItem.maxQuantity, | |||
weight = fishItem.weight, | |||
totalWeight = fishTotWeight}) | |||
end | end | ||
end | end | ||
Line 919: | Line 1,004: | ||
end | end | ||
if thisGem ~= nil then | if thisGem ~= nil then | ||
local expIcon = '' | local expIcon = '' | ||
local sourceTxt | local sourceTxt | ||
local lv = nil | |||
if item.type == 'Superior Gem' then | if item.type == 'Superior Gem' then | ||
expIcon = Icons.TotH() | expIcon = Icons.TotH() | ||
sourceTxt = '[[Mining#Superior Gems|Superior Gem]]' | sourceTxt = '[[Mining#Superior Gems|Superior Gem]]' | ||
-- Superior gems can only be found with Mining 100 or above | |||
lv = 100 | |||
else | else | ||
sourceTxt = '[[Mining#Gems|Gem]]' | sourceTxt = '[[Mining#Gems|Gem]]' | ||
-- Gems can only be found with any Mining level | |||
lv = 1 | |||
end | end | ||
table.insert(dropRows, {source = sourceTxt, | table.insert(dropRows, { | ||
source = sourceTxt, | |||
level = Icons._SkillReq('Mining', lv), | |||
levelNum = lv, | |||
minqty = thisGem.minQuantity, | |||
qty = thisGem.maxQuantity, | |||
weight = thisGem.weight, | |||
totalWeight = totalGemWeight, | |||
expIcon = expIcon}) | |||
-- Check for Alt. Magic spells also | -- Check for Alt. Magic spells also | ||
local producesKey = (gemKey == 'randomGems' and 'RandomGem') or 'RandomSuperiorGem' | local producesKey = (gemKey == 'randomGems' and 'RandomGem') or 'RandomSuperiorGem' | ||
for j, spell in ipairs(Magic.getSpellsBySpellBook('altMagic')) do | for j, spell in ipairs(Magic.getSpellsBySpellBook('altMagic')) do | ||
if spell.produces ~= nil and spell.produces == producesKey then | if spell.produces ~= nil and spell.produces == producesKey then | ||
table.insert(dropRows, {source = Icons.Icon({spell.name, type=Magic._getSpellIconType(spell)}), type = | table.insert(dropRows, { | ||
source = Icons.Icon({spell.name, type=Magic._getSpellIconType(spell)}), | |||
level = Icons.Icon({'Alternative Magic', type='skill', img='Magic', notext=true}) .. ' Level ' .. spell.level, | |||
levelNum = spell.level, | |||
minqty = thisGem.minQuantity, | |||
qty = thisGem.maxQuantity, | |||
weight = thisGem.weight, | |||
totalWeight = totalGemWeight, | |||
expIcon = Icons.getExpansionIcon(spell.id)}) | |||
end | end | ||
end | end | ||
Line 948: | Line 1,052: | ||
if a.weight / a.totalWeight == b.weight / b.totalWeight then | if a.weight / a.totalWeight == b.weight / b.totalWeight then | ||
if a.minqty + a.qty == b.minqty + b.qty then | if a.minqty + a.qty == b.minqty + b.qty then | ||
return (a. | return (a.level == b.level and a.source < b.source) or a.level < b.level | ||
else | else | ||
return a.minqty + a.qty > b.minqty + b.qty | return a.minqty + a.qty > b.minqty + b.qty | ||
Line 957: | Line 1,061: | ||
end) | end) | ||
for i, data in ipairs(dropRows) do | for i, data in ipairs(dropRows) do | ||
table.insert(resultPart, buildRow(data.source, data. | table.insert(resultPart, buildRow(data.source, data.level, data.levelNum, data.minqty, data.qty, data.weight, data.totalWeight, data.expIcon)) | ||
end | end | ||
Line 1,181: | Line 1,285: | ||
chance = 1 | chance = 1 | ||
weight = 1 | weight = 1 | ||
elseif monster.barrierPercent ~= nil and 'melvorAoD:Barrier_Dust' == item.id and not Monsters._isDungeonOnlyMonster(monster) then | |||
-- Item is Barrier Dust and is not a dungeon exclusive monster | |||
maxQty = math.max(math.floor(Monsters._getMonsterStat(monster, 'Barrier') / 10 / 20), 1) | |||
minQty = maxQty | |||
chance = 1 | |||
elseif monster.lootTable ~= nil and not Monsters._isDungeonOnlyMonster(monster) then | elseif monster.lootTable ~= nil and not Monsters._isDungeonOnlyMonster(monster) then | ||
-- If the monster has a loot table, check if the item we are looking for is in there | -- If the monster has a loot table, check if the item we are looking for is in there | ||
Line 1,232: | Line 1,341: | ||
local min = found.minQuantity | local min = found.minQuantity | ||
local max = found.maxQuantity | local max = found.maxQuantity | ||
table.insert(resultArray, {id = digSite.id, name = digSite.name, size = sizeName, minQty = min, maxQty = max, dropWt = found.weight, totalWt = sizeWeight}) | table.insert(resultArray, { | ||
id = digSite.id, | |||
name = digSite.name, | |||
level = digSite.level, | |||
size = sizeName, | |||
minQty = min, | |||
maxQty = max, | |||
dropWt = found.weight, | |||
totalWt = sizeWeight}) | |||
end | end | ||
end | end | ||
Line 1,291: | Line 1,408: | ||
"Paper", | "Paper", | ||
"Lemon", | "Lemon", | ||
"Aranite Brush" | "Aranite Brush", | ||
"Barrier Dust" | |||
} | } | ||
local checkFuncs = { | local checkFuncs = { |
edits