12,727
edits
No edit summary |
(_getAfflictedMonsterIdList: Remove in favour of game data (AreaData.itm.monsters)) |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 713: | Line 713: | ||
--Sort the loot table by weight in descending order | --Sort the loot table by weight in descending order | ||
table.sort(monster.lootTable, function(a, b) return a[2] > b[2] end) | table.sort(monster.lootTable, function(a, b) return a[2] > b[2] end) | ||
for i, row in | for i, row in ipairs(monster.lootTable) do | ||
local thisItem = Items.getItemByID(row[1]) | local thisItem = Items.getItemByID(row[1]) | ||
Line 817: | Line 817: | ||
end | end | ||
for i, row in | for i, row in ipairs(monster.lootTable) do | ||
local thisItem = Items.getItemByID(row[1]) | local thisItem = Items.getItemByID(row[1]) | ||
Line 867: | Line 867: | ||
local dropChance = 0 | local dropChance = 0 | ||
local dropWt = 0 | local dropWt = 0 | ||
for i, row in | for i, row in ipairs(monster.lootTable) do | ||
totalWt = totalWt + row[2] | totalWt = totalWt + row[2] | ||
if item | if item.id == row[1] then | ||
dropWt = row[2] | dropWt = row[2] | ||
end | end | ||
Line 886: | Line 885: | ||
return "ERROR: No item named "..ChestName..' found[[Category:Pages with script errors]]' | return "ERROR: No item named "..ChestName..' found[[Category:Pages with script errors]]' | ||
end | end | ||
local result = '' | local result = '' | ||
Line 905: | Line 903: | ||
--Sort the loot table by weight in descending order | --Sort the loot table by weight in descending order | ||
local chestDrops, dropIdx = {}, 0 | |||
local hasQty = type(chest.dropQty) == 'table' | |||
for i, row in pairs(chest.dropTable) do | for i, row in pairs(chest.dropTable) do | ||
local qty = hasQty and chest.dropQty[i] or 1 | |||
dropIdx = dropIdx + 1 | |||
chestDrops[dropIdx] = {row[1], row[2], qty} | |||
end | end | ||
table.sort( | table.sort(chestDrops, function(a, b) return a[2] > b[2] end) | ||
for i, row in | for i, row in ipairs(chestDrops) do | ||
local thisItem = Items.getItemByID(row[1]) | local thisItem = Items.getItemByID(row[1]) | ||
local qty = row[3] | local qty = row[3] | ||
Line 1,414: | Line 1,412: | ||
table.insert(tableParts, '\r\n|- class="headerRow-1"\r\n!Monster !!Name !!Combat Level ') | table.insert(tableParts, '\r\n|- class="headerRow-1"\r\n!Monster !!Name !!Combat Level ') | ||
table.insert(tableParts, '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Hitpoints', type='skill'})) | table.insert(tableParts, '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Hitpoints', type='skill'})) | ||
table.insert(tableParts, '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Defence', type='skill', notext=true})) | |||
table.insert(tableParts, '!!Attack Speed (s) !!colspan="2"|Max Hit !!Accuracy ') | table.insert(tableParts, '!!Attack Speed (s) !!colspan="2"|Max Hit !!Accuracy ') | ||
-- table.insert(tableParts, '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Ranged', type='skill', notext=true})) | |||
-- table.insert(tableParts, '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Magic', type='skill', notext=true})) | |||
table.insert(tableParts, '!!' .. Icons.Icon({'Coins', notext=true, nolink=true}) .. ' Coins !!Avg. Kill Value !!Bones') | table.insert(tableParts, '!!' .. Icons.Icon({'Coins', notext=true, nolink=true}) .. ' Coins !!Avg. Kill Value !!Bones') | ||
Line 1,446: | Line 1,445: | ||
local evaR = {p._getMonsterER(monster, "Melee"), p._getMonsterER(monster, "Ranged"), p._getMonsterER(monster, "Magic")} | local evaR = {p._getMonsterER(monster, "Melee"), p._getMonsterER(monster, "Ranged"), p._getMonsterER(monster, "Magic")} | ||
local bones = p._getMonsterBones(monster) | |||
local boneTxt = (bones ~= nil and Icons.Icon({bones.name, type='item', notext=true})) or 'None' | local boneTxt = (bones ~= nil and Icons.Icon({bones.name, type='item', notext=true})) or 'None' | ||
Line 1,453: | Line 1,453: | ||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. cmbLevel .. '" |' .. Shared.formatnum(cmbLevel)) | table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. cmbLevel .. '" |' .. Shared.formatnum(cmbLevel)) | ||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. p._getMonsterHP(monster) .. '" |' .. Shared.formatnum(p._getMonsterHP(monster))) | table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. p._getMonsterHP(monster) .. '" |' .. Shared.formatnum(p._getMonsterHP(monster))) | ||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. evaR[1] .. '" |' .. Shared.formatnum(evaR[1])) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. atkSpeed .. '" |' .. Shared.round(atkSpeed, 1, 1)) | table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. atkSpeed .. '" |' .. Shared.round(atkSpeed, 1, 1)) | ||
table.insert(tableParts, '\r\n|style="text-align:center;border-right:hidden" |' .. p._getMonsterStyleIcon({monster, notext=true})) | table.insert(tableParts, '\r\n|style="text-align:center;border-right:hidden" |' .. p._getMonsterStyleIcon({monster, notext=true})) | ||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. maxHit .. '" |' .. Shared.formatnum(maxHit)) | table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. maxHit .. '" |' .. Shared.formatnum(maxHit)) | ||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. accR .. '" |' .. Shared.formatnum(accR)) | table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. accR .. '" |' .. Shared.formatnum(accR)) | ||
--table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. evaR[2] .. '" |' .. Shared.formatnum(evaR[2])) | |||
--table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. evaR[3] .. '" |' .. Shared.formatnum(evaR[3])) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. evaR[3] .. '" |' .. Shared.formatnum(evaR[3])) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. (gpRange[1] + gpRange[2]) / 2 .. '" |' .. gpTxt) | table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. (gpRange[1] + gpRange[2]) / 2 .. '" |' .. gpTxt) | ||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. lootVal .. '" |' .. lootTxt) | table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. lootVal .. '" |' .. lootTxt) |