12,704
edits
Falterfire (talk | contribs) (Fixed MattMonsterTable) |
(_getMonsterStyleIcon: Revert change to use adjusted Icon override instead) |
||
(16 intermediate revisions by 4 users not shown) | |||
Line 676: | Line 676: | ||
local bones = p._getMonsterBones(monster) | local bones = p._getMonsterBones(monster) | ||
local boneVal = 0 | |||
--Show the bones only if either the monster shows up outside of dungeons _or_ the monster drops shards | --Show the bones only if either the monster shows up outside of dungeons _or_ the monster drops shards | ||
if bones ~= nil then | if bones ~= nil then | ||
local boneQty = (monster.boneQty ~= nil and monster.boneQty or 1) | |||
result = result.."'''Always Drops:'''" | result = result.."'''Always Drops:'''" | ||
result = result..'\r\n{|class="wikitable" id="bonedrops"' | result = result..'\r\n{|class="wikitable" id="bonedrops"' | ||
result = result..'\r\n!Item !! Qty' | result = result..'\r\n!Item !! Qty' | ||
result = result..'\r\n|-\r\n|'..Icons.Icon({bones.name, type='item'}) | result = result..'\r\n|-\r\n|'..Icons.Icon({bones.name, type='item'}) | ||
result = result..'||'. | result = result..'||'..boneQty..'\r\n'..'|}' | ||
boneVal = boneQty * bones.sellsFor | |||
end | end | ||
Line 710: | 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 768: | Line 771: | ||
result = result..'\r\nThe loot dropped by the average kill is worth '..Icons.GP(Shared.round(lootValue, 2, 0)).." if sold." | result = result..'\r\nThe loot dropped by the average kill is worth '..Icons.GP(Shared.round(lootValue, 2, 0)).." if sold." | ||
if avgGp > 0 then | if avgGp > 0 then | ||
result = result.. | result = result.."<br/>Including GP" | ||
if boneVal > 0 then | |||
result = result..' and bones' | |||
end | |||
result = result..', the average kill is worth '..Icons.GP(Shared.round(avgGp + lootValue + boneVal, 2, 0))..'.' | |||
end | end | ||
end | end | ||
Line 790: | Line 797: | ||
local boneQty = monster.boneQty ~= nil and monster.boneQty or 1 | local boneQty = monster.boneQty ~= nil and monster.boneQty or 1 | ||
boneVal = bones.sellsFor * boneQty | boneVal = bones.sellsFor * boneQty | ||
result = result + boneVal | |||
end | end | ||
Line 809: | 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]) | ||
local maxQty = row[3] | local maxQty = row[3] | ||
--Adding price columns | --Adding price columns | ||
Line 827: | Line 834: | ||
end | end | ||
if avgGp > 0 then | if avgGp > 0 then | ||
result = avgGp + lootValue | result = result + avgGp + lootValue | ||
end | end | ||
end | end | ||
Line 860: | 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 879: | 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 898: | 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,382: | Line 1,387: | ||
local lootTxt = '0' | local lootTxt = '0' | ||
if lootVal ~= 0 then | if lootVal ~= 0 then | ||
lootTxt = Shared.formatnum(lootVal) | lootTxt = Shared.formatnum(Shared.round(lootVal, 2, 2)) | ||
end | end | ||
Line 1,394: | Line 1,399: | ||
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) | ||
table.insert(tableParts, '\r\n|style="text-align:right;width:190px" |' .. p._getMonsterAreas(monster, hideDungeons)) | table.insert(tableParts, '\r\n|style="text-align:right;width:190px" |' .. p._getMonsterAreas(monster, hideDungeons)) | ||
end | |||
table.insert(tableParts, '\r\n|}') | |||
return table.concat(tableParts) | |||
end | |||
function p.getMattMonsterTableV2(frame) | |||
--Making a single function for getting a table of monsters given a list of IDs. | |||
local tableParts = {} | |||
table.insert(tableParts, '{| class="wikitable sortable stickyHeader"') | |||
-- Second header row | |||
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({'Defence', type='skill', notext=true})) | |||
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') | |||
-- Generate row per monster | |||
for i, monster in Shared.skpairs(MonsterData.Monsters) do | |||
local cmbLevel = p._getMonsterCombatLevel(monster) | |||
local gpRange = {0, 0} | |||
if monster.dropCoins ~= nil and monster.dropCoins[2] > 1 then | |||
gpRange = {monster.dropCoins[1], monster.dropCoins[2]} | |||
end | |||
local gpTxt = nil | |||
if gpRange[1] >= gpRange[2] then | |||
gpTxt = Shared.formatnum(gpRange[1]) | |||
else | |||
gpTxt = Shared.formatnum(gpRange[1]) .. ' - ' .. Shared.formatnum(gpRange[2]) | |||
end | |||
local lootVal = p._getMonsterLootValue(monster) | |||
local lootTxt = '0' | |||
if lootVal ~= 0 then | |||
lootTxt = Shared.formatnum(Shared.round(lootVal, 2, 2)) | |||
end | |||
local atkSpeed = p._getMonsterAttackSpeed(monster) | |||
local maxHit = p._getMonsterMaxHit(monster) | |||
local accR = p._getMonsterAR(monster) | |||
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' | |||
table.insert(tableParts, '\r\n|-\r\n|style="text-align: center;" |' .. Icons.Icon({monster.name, type='monster', size=50, notext=true})) | |||
table.insert(tableParts, '\r\n|style="text-align:left" |' .. Icons.Icon({monster.name, type='monster', noicon=true})) | |||
-- table.insert(tableParts, '\r\n|style="text-align:right" |' .. monster.id) | |||
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="' .. 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: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="' .. 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="' .. (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:center" |' .. boneTxt) | |||
-- table.insert(tableParts, '\r\n|style="text-align:right;width:190px" |' .. p._getMonsterAreas(monster, hideDungeons)) | |||
end | end | ||