17,101
edits
(getThievingNPCTable: Add sort order to level column) |
(_getThievingNPCLootTables: Add average GP values at end of common drops section) |
||
Line 367: | Line 367: | ||
--(Skip if no loot) | --(Skip if no loot) | ||
if npc.lootTable ~= nil and Shared.tableCount(npc.lootTable) > 0 then | if npc.lootTable ~= nil and Shared.tableCount(npc.lootTable) > 0 then | ||
local normalTxt = '===Possible Common Drops:===\r\nUp to one of these will be received on a successful pickpocket:' | local normalTxt = {} | ||
table.insert(normalTxt, '===Possible Common Drops:===\r\nUp to one of these will be received on a successful pickpocket:') | |||
local totalWt = 0 | local totalWt = 0 | ||
local lootChance = SkillData.Thieving.ItemChance | local lootChance = SkillData.Thieving.ItemChance | ||
Line 377: | Line 378: | ||
end | end | ||
normalTxt | table.insert(normalTxt, '\r\n{|class="wikitable sortable"') | ||
normalTxt | table.insert(normalTxt, '\r\n!Item!!Qty') | ||
normalTxt | table.insert(normalTxt, '!!Price!!colspan="2"|Chance') | ||
--Then sort the loot table by weight | --Then sort the loot table by weight | ||
Line 387: | Line 388: | ||
local maxQty = row[3] | local maxQty = row[3] | ||
if thisItem ~= nil then | if thisItem ~= nil then | ||
normalTxt | table.insert(normalTxt, '\r\n|-\r\n|'..Icons.Icon({thisItem.name, type='item'})) | ||
else | else | ||
normalTxt | table.insert(normalTxt, '\r\n|-\r\n|Unknown Item[[Category:Pages with script errors]]') | ||
end | end | ||
normalTxt | table.insert(normalTxt, '||style="text-align:right" data-sort-value="'..maxQty..'"|') | ||
if maxQty > 1 then | if maxQty > 1 then | ||
normalTxt | table.insert(normalTxt, '1 - ') | ||
end | end | ||
normalTxt | table.insert(normalTxt, Shared.formatnum(row[3])) | ||
--Adding price columns | --Adding price columns | ||
local itemPrice = 0 | local itemPrice = 0 | ||
if thisItem == nil then | if thisItem == nil then | ||
normalTxt | table.insert(normalTxt, '||data-sort-value="0"|???') | ||
else | else | ||
itemPrice = thisItem.sellsFor ~= nil and thisItem.sellsFor or 0 | itemPrice = thisItem.sellsFor ~= nil and thisItem.sellsFor or 0 | ||
if itemPrice == 0 or maxQty == 1 then | if itemPrice == 0 or maxQty == 1 then | ||
normalTxt | table.insert(normalTxt, '||'..Icons.GP(itemPrice)) | ||
else | else | ||
normalTxt | table.insert(normalTxt, '||'..Icons.GP(itemPrice, itemPrice * maxQty)) | ||
end | end | ||
end | end | ||
Line 415: | Line 416: | ||
if dropChance ~= 100 then | if dropChance ~= 100 then | ||
--Show fraction as long as it isn't going to be 1/1 | --Show fraction as long as it isn't going to be 1/1 | ||
normalTxt | table.insert(normalTxt, '||style="text-align:right" data-sort-value="'..row[2]..'"') | ||
normalTxt | table.insert(normalTxt, '|'..Shared.fraction(row[2] * lootChance, totalWt * 100)) | ||
normalTxt | table.insert(normalTxt, '||') | ||
else | else | ||
normalTxt | table.insert(normalTxt, '||colspan="2" data-sort-value="'..row[2]..'"') | ||
end | end | ||
normalTxt | table.insert(normalTxt, 'style="text-align:right"|'..Shared.round(dropChance, 2, 2)..'%') | ||
--Adding to the average loot value based on price & dropchance | --Adding to the average loot value based on price & dropchance | ||
Line 427: | Line 428: | ||
end | end | ||
if Shared.tableCount(npc.lootTable) > 1 then | if Shared.tableCount(npc.lootTable) > 1 then | ||
normalTxt | table.insert(normalTxt, '\r\n|-class="sortbottom" \r\n!colspan="3"|Total:') | ||
if lootChance < 100 then | if lootChance < 100 then | ||
normalTxt | table.insert(normalTxt, '\r\n|style="text-align:right"|'..Shared.fraction(lootChance, 100)..'||') | ||
else | else | ||
normalTxt | table.insert(normalTxt, '\r\n|colspan="2" ') | ||
end | end | ||
normalTxt | table.insert(normalTxt, 'style="text-align:right"|'..Shared.round(lootChance, 2, 2)..'%') | ||
end | end | ||
normalTxt | table.insert(normalTxt, '\r\n|}') | ||
table.insert(sectionTxt, normalTxt) | table.insert(normalTxt, '\r\nThe loot obtained from the average successful pickocket is worth ' .. Icons.GP(Shared.round(lootValue, 2, 2)) .. ' if sold.') | ||
table.insert(normalTxt, '\r\nIncluding GP, the average successful pickocket is worth ' .. Icons.GP(Shared.round(lootValue + (1 + npc.maxGP) / 2, 2, 2)) .. '.') | |||
table.insert(sectionTxt, table.concat(normalTxt)) | |||
end | end | ||