12,721
edits
No edit summary |
(Use printError function) |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 68: | Line 68: | ||
local npc = p.getThievingNPC(npcName) | local npc = p.getThievingNPC(npcName) | ||
if npc == nil then | if npc == nil then | ||
return | return Shared.printError('Invalid Thieving NPC ' .. npcName) | ||
end | end | ||
Line 104: | Line 104: | ||
end | end | ||
if dropWt > 0 then | if dropWt > 0 then | ||
table.insert(resultArray, {npc = npc.name, minQty = dropQty.min, maxQty = dropQty.max, wt = dropWt * SkillData.Thieving.itemChance, totalWt = totalWt * 100, level = npc.level}) | table.insert(resultArray, {npc = npc.name, minQty = dropQty.min, maxQty = dropQty.max, wt = dropWt * SkillData.Thieving.itemChance, totalWt = totalWt * 100, level = npc.level, npcID = npc.id}) | ||
end | end | ||
--Chance of -1 on unique drops is to indicate variable chance | --Chance of -1 on unique drops is to indicate variable chance | ||
if npc.uniqueDrop ~= nil and npc.uniqueDrop.id == itemID then | if npc.uniqueDrop ~= nil and npc.uniqueDrop.id == itemID then | ||
table.insert(resultArray, {npc = npc.name, minQty = npc.uniqueDrop.quantity, maxQty = npc.uniqueDrop.quantity, wt = -1, totalWt = -1, level = npc.level}) | table.insert(resultArray, {npc = npc.name, minQty = npc.uniqueDrop.quantity, maxQty = npc.uniqueDrop.quantity, wt = -1, totalWt = -1, level = npc.level, npcID = npc.id}) | ||
end | end | ||
if areaNPCs[npc.id] ~= nil then | if areaNPCs[npc.id] ~= nil then | ||
table.insert(resultArray, {npc = npc.name, minQty = areaNPCs[npc.id], maxQty = areaNPCs[npc.id], wt = SkillData.Thieving.baseAreaUniqueChance, totalWt = 100, level = npc.level}) | table.insert(resultArray, {npc = npc.name, minQty = areaNPCs[npc.id], maxQty = areaNPCs[npc.id], wt = SkillData.Thieving.baseAreaUniqueChance, totalWt = 100, level = npc.level, npcID = npc.id}) | ||
end | end | ||
end | end | ||
Line 120: | Line 120: | ||
if drop.itemID == itemID then | if drop.itemID == itemID then | ||
if drop.npcs == nil then | if drop.npcs == nil then | ||
table.insert(resultArray, {npc = 'all', minQty = 1, maxQty = 1, wt = 1, totalWt = Shared.round2(1/(drop.chance/100), 0), level = 1}) | table.insert(resultArray, {npc = 'all', minQty = 1, maxQty = 1, wt = 1, totalWt = Shared.round2(1/(drop.chance/100), 0), level = 1, npcID = itemID}) | ||
else | else | ||
for j, npcID in ipairs(drop.npcs) do | for j, npcID in ipairs(drop.npcs) do | ||
local npc = p.getThievingNPCByID(npcID) | local npc = p.getThievingNPCByID(npcID) | ||
if npc ~= nil then | if npc ~= nil then | ||
table.insert(resultArray, {npc = npc.name, minQty = 1, maxQty = 1, wt = 1, totalWt = Shared.round2(1/(drop.chance/100), 0), level = npc.level}) | table.insert(resultArray, {npc = npc.name, minQty = 1, maxQty = 1, wt = 1, totalWt = Shared.round2(1/(drop.chance/100), 0), level = npc.level, npcID = npc.id}) | ||
end | end | ||
end | end | ||
Line 188: | Line 188: | ||
local modArray = {} | local modArray = {} | ||
local isSkillMod = {} | local isSkillMod = {} | ||
--Adding a Group Number to hold together different bonuses from the same modifier [Falterfire 22/10/27] | |||
local groupNum = 0 | |||
for _, modType in ipairs(modTypes) do | for _, modType in ipairs(modTypes) do | ||
for i, modTypeData in ipairs(cons[modType]) do | for i, modTypeData in ipairs(cons[modType]) do | ||
groupNum = groupNum + 1 | |||
local modVal = nil | local modVal = nil | ||
if modValue ~= nil then | if modValue ~= nil then | ||
Line 199: | Line 202: | ||
for j, modifier in ipairs(modTypeData.modifiers) do | for j, modifier in ipairs(modTypeData.modifiers) do | ||
local modEntry = (modifier.skill ~= nil and { skillID = modifier.skill, value = modVal }) or modVal | local modEntry = (modifier.skill ~= nil and { skillID = modifier.skill, value = modVal }) or modVal | ||
addToArray(modArray, {modifier.key, modEntry}) | addToArray(modArray, {modifier.key, modEntry, group = groupNum}) | ||
end | end | ||
end | end | ||
Line 228: | Line 231: | ||
local skillID = Constants.getSkillID(skillName) | local skillID = Constants.getSkillID(skillName) | ||
if skillID == nil then | if skillID == nil then | ||
return | return Shared.printError('Failed to find a skill ID for ' .. skillName) | ||
end | end | ||
local _, localSkillID = GameData.getLocalID(skillID) | local _, localSkillID = GameData.getLocalID(skillID) | ||
local unlockTable = SkillData[localSkillID].masteryLevelUnlocks | -- Clone so that we can sort by level | ||
local unlockTable = Shared.clone(SkillData[localSkillID].masteryLevelUnlocks) | |||
if unlockTable == nil then | if unlockTable == nil then | ||
return ' | return Shared.printError('Failed to find Mastery Unlock data for ' .. skillName) | ||
end | end | ||
table.sort(unlockTable, function(a, b) return (a.level == b.level and a.descriptionID < b.descriptionID) or a.level < b.level end) | |||
local result = '{|class="wikitable"\r\n!Level!!Unlock' | local result = '{|class="wikitable"\r\n!Level!!Unlock' | ||
Line 250: | Line 255: | ||
local skillID = Constants.getSkillID(skillName) | local skillID = Constants.getSkillID(skillName) | ||
if skillID == nil then | if skillID == nil then | ||
return | return Shared.printError('Failed to find a skill ID for ' .. skillName) | ||
end | end | ||
Line 256: | Line 261: | ||
local checkpoints = SkillData[localSkillID].masteryCheckpoints | local checkpoints = SkillData[localSkillID].masteryCheckpoints | ||
if checkpoints == nil then | if checkpoints == nil then | ||
return ' | return Shared.printError('Failed to find Mastery Unlock data for ' .. skillName) | ||
end | end | ||
Line 322: | Line 327: | ||
local advMode = GameData.getEntityByID('gamemodes', 'melvorF:Adventure') | local advMode = GameData.getEntityByID('gamemodes', 'melvorF:Adventure') | ||
if advMode ~= nil then | if advMode ~= nil then | ||
local unlockCount = Shared.tableCount(GameData.skillData) - Shared.tableCount(advMode.startingSkills) | |||
local costLength = Shared.tableCount(advMode.skillUnlockCost) | |||
local returnPart = {} | local returnPart = {} | ||
table.insert(returnPart, '{| class="wikitable stickyHeader"\r\n|- class="headerRow-0"\r\n!Unlock!!Cost!!Cumulative Cost') | table.insert(returnPart, '{| class="wikitable stickyHeader"\r\n|- class="headerRow-0"\r\n!Unlock!!Cost!!Cumulative Cost') | ||
local accCost = 0 | local accCost = 0 | ||
for i, cost | for i = 1, unlockCount, 1 do | ||
local cost = advMode.skillUnlockCost[math.min(i, costLength)] | |||
accCost = accCost + cost | accCost = accCost + cost | ||
table.insert(returnPart, '|-') | table.insert(returnPart, '|-') | ||
Line 346: | Line 354: | ||
local category = GameData.getEntityByName(SkillData.Smithing.categories, tableType) | local category = GameData.getEntityByName(SkillData.Smithing.categories, tableType) | ||
if category == nil then | if category == nil then | ||
return ' | return Shared.printError('Invalid Smithing category: "' .. tableType .. '"') | ||
end | end | ||
Line 356: | Line 364: | ||
local recipeItem = Items.getItemByID(recipe.productID) | local recipeItem = Items.getItemByID(recipe.productID) | ||
if recipeItem ~= nil then | if recipeItem ~= nil then | ||
table.insert(recipeList, { id = i, level = recipe.level, itemName = recipeItem.name, itemValue = recipeItem.sellsFor }) | table.insert(recipeList, { id = i, level = recipe.level, itemName = recipeItem.name, itemValue = recipeItem.sellsFor, expIcon = Icons.getExpansionIcon(recipeItem.id) }) | ||
end | end | ||
elseif recipe.categoryID == 'melvorD:Bars' then | elseif recipe.categoryID == 'melvorD:Bars' then | ||
Line 399: | Line 407: | ||
table.insert(resultPart, '\r\n| ' .. Icons.Icon({recipeDef.itemName, type='item', size=50, notext=true})) | table.insert(resultPart, '\r\n| ' .. Icons.Icon({recipeDef.itemName, type='item', size=50, notext=true})) | ||
table.insert(resultPart, '\r\n| ') | table.insert(resultPart, '\r\n| ') | ||
table.insert(resultPart, recipeDef.expIcon) | |||
if recipe.baseQuantity > 1 then | if recipe.baseQuantity > 1 then | ||
table.insert(resultPart, recipe.baseQuantity .. 'x ') | table.insert(resultPart, recipe.baseQuantity .. 'x ') | ||
Line 444: | Line 453: | ||
table.insert(resultPart, '\r\n|-') | table.insert(resultPart, '\r\n|-') | ||
table.insert(resultPart, '\r\n|data-sort-value="'..name..'"|'..Icons.Icon({name, type='item', size='50', notext=true})) | table.insert(resultPart, '\r\n|data-sort-value="'..name..'"|'..Icons.Icon({name, type='item', size='50', notext=true})) | ||
table.insert(resultPart, '|| | table.insert(resultPart, '||'..Icons.getExpansionIcon(logs.id)..Icons.Icon({name, type='item', noicon=true})) | ||
table.insert(resultPart, '||style ="text-align: right;"|'..logData.level) | table.insert(resultPart, '||style ="text-align: right;"|'..logData.level) | ||
table.insert(resultPart, '||style ="text-align: right;" data-sort-value="'..burnTime..'"|'..Shared.timeString(burnTime, true)) | table.insert(resultPart, '||style ="text-align: right;" data-sort-value="'..burnTime..'"|'..Shared.timeString(burnTime, true)) |