17,101
edits
(_getMonsterStyleIcon: Revert change to use adjusted Icon override instead) |
(Update for v1.1) |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local Constants = require('Module:Constants') | local Constants = require('Module:Constants') | ||
local Shared = require('Module:Shared') | |||
local GameData = require('Module:GameData') | |||
local Areas = require('Module:CombatAreas') | local Areas = require('Module:CombatAreas') | ||
local Magic = require('Module:Magic') | local Magic = require('Module:Magic') | ||
local Icons = require('Module:Icons') | local Icons = require('Module:Icons') | ||
local Items = require('Module:Items') | local Items = require('Module:Items') | ||
function p.getMonster(name) | function p.getMonster(name) | ||
return GameData.getEntityByName('monsters', name) | |||
end | end | ||
function p.getMonsterByID(ID) | function p.getMonsterByID(ID) | ||
return GameData.getEntityByID('monsters', ID) | |||
end | end | ||
function p.getPassive(name) | function p.getPassive(name) | ||
return GameData.getEntityByName('combatPassives', name) | |||
end | end | ||
function p.getPassiveByID(ID) | function p.getPassiveByID(ID) | ||
return GameData.getEntityByID('combatPassives', ID) | |||
end | end | ||
Line 179: | Line 147: | ||
function p.getEquipmentStat(monster, statName) | function p.getEquipmentStat(monster, statName) | ||
return monster.equipmentStats[statName] or 0 | |||
end | end | ||
Line 303: | Line 264: | ||
-- item if so, or nil otherwise | -- item if so, or nil otherwise | ||
function p._getMonsterBones(monster) | function p._getMonsterBones(monster) | ||
if monster.bones ~= nil | if monster.bones ~= nil then | ||
local boneItem = Items.getItemByID(monster.bones) | local boneItem = Items.getItemByID(monster.bones.itemID) | ||
local boneObj = { ["item"] = boneItem, ["quantity"] = monster.bones.quantity } | |||
if boneItem.prayerPoints == nil then | if boneItem.prayerPoints == nil then | ||
-- Assume bones without prayer points are shards (from God dungeons), | -- Assume bones without prayer points are shards (from God dungeons), | ||
-- and drop unconditionally | -- and drop unconditionally | ||
return | return boneObj | ||
elseif not monster.isBoss and not p._isDungeonOnlyMonster(monster) then | elseif not monster.isBoss and not p._isDungeonOnlyMonster(monster) then | ||
-- Otherwise, bones drop when the monster isn't dungeon exclusive | -- Otherwise, bones drop when the monster isn't dungeon exclusive | ||
return | return boneObj | ||
end | end | ||
end | end | ||
Line 331: | Line 293: | ||
function p.isDungeonOnlyMonster(frame) | function p.isDungeonOnlyMonster(frame) | ||
local | local monsterName = frame.args ~= nil and frame.args[1] or frame | ||
local monster = p.getMonster( | local monster = p.getMonster(monsterName) | ||
if monster == nil then | if monster == nil then | ||
Line 354: | Line 316: | ||
function p.getMonsterAreas(frame) | function p.getMonsterAreas(frame) | ||
local | local monsterName = frame.args ~= nil and frame.args[1] or frame | ||
local hideDungeons = frame.args ~= nil and frame.args[2] or nil | local hideDungeons = frame.args ~= nil and frame.args[2] or nil | ||
local monster = p.getMonster( | local monster = p.getMonster(monsterName) | ||
if monster == nil then | if monster == nil then | ||
Line 387: | Line 349: | ||
function p.canSpecAttackApplyEffect(specAttack, effectType) | function p.canSpecAttackApplyEffect(specAttack, effectType) | ||
for i, effect in pairs(specAttack.prehitEffects) do | for i, effect in pairs(specAttack.prehitEffects) do | ||
if effect.type == effectType then | if effect.type == effectType then | ||
return true | |||
end | end | ||
end | end | ||
Line 397: | Line 357: | ||
for i, effect in pairs(specAttack.onhitEffects) do | for i, effect in pairs(specAttack.onhitEffects) do | ||
if effect.type == effectType then | if effect.type == effectType then | ||
return true | |||
end | end | ||
end | end | ||
return | return false | ||
end | end | ||
Line 418: | Line 377: | ||
local hasActiveBuffSpec = false | local hasActiveBuffSpec = false | ||
local damageMultiplier = 1 | local damageMultiplier = 1 | ||
if monster.specialAttacks | if monster.specialAttacks ~= nil then | ||
local canStun, canSleep = false, false | local canStun, canSleep = false, false | ||
for i, | for i, specAttackID in pairs(monster.specialAttacks) do | ||
local specAttack = GameData.getEntityByID('attacks', specAttackID) | |||
if monster.overrideSpecialChances ~= nil then | if monster.overrideSpecialChances ~= nil then | ||
normalChance = normalChance - monster.overrideSpecialChances[i] | normalChance = normalChance - monster.overrideSpecialChances[i] | ||
Line 470: | Line 430: | ||
result = p.calculateStandardMaxHit(baseLevel, bonus) | result = p.calculateStandardMaxHit(baseLevel, bonus) | ||
elseif monster.attackType == 'magic' then | elseif monster.attackType == 'magic' then | ||
if monster.selectedSpell == nil then | |||
result = 0 | |||
else | |||
local mSpell = Magic.getSpellByID('Spells', monster.selectedSpell) | |||
if mSpell == nil then | |||
result = 0 | |||
else | |||
baseLevel = p._getMonsterLevel(monster, 'Magic') | |||
bonus = p.getEquipmentStat(monster, 'magicDamageBonus') | |||
result = math.floor(10 * mSpell.maxHit * (1 + bonus / 100) * (1 + (baseLevel + 1) / 200)) | |||
end | |||
end | |||
elseif monster.attackType == 'random' then | elseif monster.attackType == 'random' then | ||
local hitArray = {} | local hitArray = {} | ||
Line 490: | Line 455: | ||
iconText = Icons.Icon({'Magic', type='skill', notext=true}) | iconText = Icons.Icon({'Magic', type='skill', notext=true}) | ||
local magicDmg = 0 | |||
if monster.selectedSpell ~= nil then | |||
local mSpell = Magic.getSpellByID('Spells', monster.selectedSpell) | |||
if mSpell ~= nil then | |||
baseLevel = p._getMonsterLevel(monster, 'Magic') | |||
bonus = p.getEquipmentStat(monster, 'magicDamageBonus') | |||
magicDmg = math.floor(10 * mSpell.maxHit * (1 + bonus / 100) * (1 + (baseLevel + 1) / 200)) | |||
end | |||
end | |||
table.insert(hitArray, magicDmg) | table.insert(hitArray, magicDmg) | ||
Line 545: | Line 514: | ||
local normalAttackChance = 100 | local normalAttackChance = 100 | ||
if monster.specialAttacks | if monster.specialAttacks ~= nil then | ||
for i, | for i, specAttackID in pairs(monster.specialAttacks) do | ||
local specAttack = GameData.getEntityByID('attacks', specAttackID) | |||
local attChance = 0 | local attChance = 0 | ||
if monster.overrideSpecialChances ~= nil then | if monster.overrideSpecialChances ~= nil then | ||
Line 585: | Line 555: | ||
local result = '' | local result = '' | ||
if type(monster.passives) == 'table' and not Shared.tableIsEmpty(monster.passives) then | |||
result = result .. '===Passives===' | result = result .. '===Passives===' | ||
for i, passiveID in | for i, passiveID in ipairs(monster.passives) do | ||
local passive = p.getPassiveByID(passiveID) | local passive = p.getPassiveByID(passiveID) | ||
result = result .. '\r\n* ' .. passive.name .. '\r\n** ' .. passive. | result = result .. '\r\n* ' .. passive.name .. '\r\n** ' .. passive.customDescription | ||
end | end | ||
end | end | ||
Line 613: | Line 583: | ||
end | end | ||
if monster. | if type(monster.passives) == 'table' and not Shared.tableIsEmpty(monster.passives) then | ||
result = result..'[[Category:Monsters with Special Attacks]]' | result = result..'[[Category:Monsters with Special Attacks]]' | ||
end | end | ||
Line 640: | Line 610: | ||
local areaList = Areas.getMonsterAreas(monster.id) | local areaList = Areas.getMonsterAreas(monster.id) | ||
local counts = {combat = 0, slayer = 0, dungeon = 0} | local counts = {combat = 0, slayer = 0, dungeon = 0} | ||
for i, area in | for i, area in ipairs(areaList) do | ||
counts[area.type] = counts[area.type] + 1 | counts[area.type] = counts[area.type] + 1 | ||
end | end | ||
Line 679: | Line 649: | ||
--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 = ( | local boneQty = (bones.quantity ~= nil and bones.quantity 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.item.name, type='item'}) | ||
result = result..'||'..boneQty..'\r\n'..'|}' | result = result..'||'..boneQty..'\r\n'..'|}' | ||
boneVal = boneQty * bones.sellsFor | boneVal = boneQty * bones.item.sellsFor | ||
end | end | ||
Line 696: | Line 666: | ||
local avgGp = 0 | local avgGp = 0 | ||
if monster. | if monster.gpDrops ~= nil then | ||
avgGp = (monster. | avgGp = (monster.gpDrops.min + monster.gpDrops.max) / 2 | ||
local gpTxt = Icons.GP(monster. | local gpTxt = Icons.GP(monster.gpDrops.min, monster.gpDrops.max) | ||
result = result.."\r\nIn addition to loot, the monster will also drop "..gpTxt..'.' | result = result.."\r\nIn addition to loot, the monster will also drop "..gpTxt..'.' | ||
end | end | ||
Line 704: | Line 674: | ||
local multiDrop = Shared.tableCount(monster.lootTable) > 1 | local multiDrop = Shared.tableCount(monster.lootTable) > 1 | ||
local totalWt = 0 | local totalWt = 0 | ||
for i, row in | for i, row in ipairs(monster.lootTable) do | ||
totalWt = totalWt + row | totalWt = totalWt + row.weight | ||
end | end | ||
result = result..'\r\n{|class="wikitable sortable" id="itemdrops"' | result = result..'\r\n{|class="wikitable sortable" id="itemdrops"' | ||
Line 712: | Line 682: | ||
--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 | table.sort(monster.lootTable, function(a, b) return a.weight > b.weight end) | ||
for i, row in ipairs(monster.lootTable) do | for i, row in ipairs(monster.lootTable) do | ||
local thisItem = Items.getItemByID(row | local thisItem = Items.getItemByID(row.itemID) | ||
if thisItem ~= nil then | if thisItem ~= nil then | ||
result = result..'\r\n|-\r\n|'..Icons.Icon({thisItem.name, type='item'}) | result = result..'\r\n|-\r\n|'..Icons.Icon({thisItem.name, type='item'}) | ||
Line 722: | Line 691: | ||
result = result..'\r\n|-\r\n|Unknown Item[[Category:Pages with script errors]]' | result = result..'\r\n|-\r\n|Unknown Item[[Category:Pages with script errors]]' | ||
end | end | ||
result = result..'||style="text-align:right" data-sort-value="'.. | result = result..'||style="text-align:right" data-sort-value="'..row.maxQuantity..'"|' | ||
if | if row.maxQuantity > row.minQuantity then | ||
result = result.. ' | result = result .. Shared.formatnum(row.minQuantity) .. ' - ' | ||
end | end | ||
result = result..Shared.formatnum(row | result = result .. Shared.formatnum(row.maxQuantity) | ||
--Adding price columns | --Adding price columns | ||
Line 735: | Line 704: | ||
else | else | ||
itemPrice = thisItem.sellsFor ~= nil and thisItem.sellsFor or 0 | itemPrice = thisItem.sellsFor ~= nil and thisItem.sellsFor or 0 | ||
if itemPrice == 0 or | if itemPrice == 0 or row.maxQuantity == row.minQuantity then | ||
result = result..'||'..Icons.GP(itemPrice) | result = result..'||'..Icons.GP(itemPrice * row.minQuantity) | ||
else | else | ||
result = result..'||'..Icons.GP(itemPrice, itemPrice * | result = result..'||'..Icons.GP(itemPrice * row.minQuantity, itemPrice * row.maxQuantity) | ||
end | end | ||
end | end | ||
--Getting the drop chance | --Getting the drop chance | ||
local dropChance = (row | local dropChance = (row.weight / totalWt * lootChance) | ||
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 | ||
result = result..'||style="text-align:right" data-sort-value="'..row | result = result..'||style="text-align:right" data-sort-value="'..row.weight..'"' | ||
result = result..'|'..Shared.fraction(row | result = result..'|'..Shared.fraction(row.weight * lootChance, totalWt * 100) | ||
result = result..'||' | result = result..'||' | ||
else | else | ||
result = result..'||colspan="2" data-sort-value="'..row | result = result..'||colspan="2" data-sort-value="'..row.weight..'"' | ||
end | end | ||
-- If chance is less than 0.10% then show 2 significant figures, otherwise 2 decimal places | -- If chance is less than 0.10% then show 2 significant figures, otherwise 2 decimal places | ||
Line 757: | Line 726: | ||
--Adding to the average loot value based on price & dropchance | --Adding to the average loot value based on price & dropchance | ||
lootValue = lootValue + (dropChance * 0.01 * itemPrice * (( | lootValue = lootValue + (dropChance * 0.01 * itemPrice * ((row.minQuantity + row.maxQuantity) / 2)) | ||
end | end | ||
if multiDrop then | if multiDrop then | ||
Line 795: | Line 764: | ||
--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 = | local boneQty = (bones.quantity ~= nil and bones.quantity) or 1 | ||
boneVal = bones.sellsFor * boneQty | boneVal = bones.item.sellsFor * boneQty | ||
result = result + boneVal | result = result + boneVal | ||
end | end | ||
Line 807: | Line 776: | ||
local avgGp = 0 | local avgGp = 0 | ||
if monster. | if monster.gpDrops ~= nil then | ||
avgGp = (monster. | avgGp = (monster.gpDrops.min + monster.gpDrops.max) / 2 | ||
end | end | ||
Line 814: | Line 783: | ||
local totalWt = 0 | local totalWt = 0 | ||
for i, row in pairs(monster.lootTable) do | for i, row in pairs(monster.lootTable) do | ||
totalWt = totalWt + row | totalWt = totalWt + row.weight | ||
end | end | ||
for i, row in ipairs(monster.lootTable) do | for i, row in ipairs(monster.lootTable) do | ||
local thisItem = Items.getItemByID(row | local thisItem = Items.getItemByID(row.itemID) | ||
--Adding price columns | --Adding price columns | ||
Line 829: | Line 796: | ||
--Getting the drop chance | --Getting the drop chance | ||
local dropChance = (row | local dropChance = (row.weight / totalWt * lootChance) | ||
--Adding to the average loot value based on price & dropchance | --Adding to the average loot value based on price & dropchance | ||
lootValue = lootValue + (dropChance * 0.01 * itemPrice * (( | lootValue = lootValue + (dropChance * 0.01 * itemPrice * ((row.minQuantity + row.maxQuantity) / 2)) | ||
end | end | ||
if avgGp > 0 then | if avgGp > 0 then | ||
Line 868: | Line 835: | ||
local dropWt = 0 | local dropWt = 0 | ||
for i, row in ipairs(monster.lootTable) do | for i, row in ipairs(monster.lootTable) do | ||
totalWt = totalWt + row | totalWt = totalWt + row.weight | ||
if item.id == row | if item.id == row.itemID then | ||
dropWt = row | dropWt = row.weight | ||
end | end | ||
end | end | ||
Line 879: | Line 846: | ||
function p.getChestDrops(frame) | function p.getChestDrops(frame) | ||
local | local chestName = frame.args ~= nil and frame.args[1] or frame | ||
local chest = Items.getItem( | local chest = Items.getItem(chestName) | ||
if chest == nil then | if chest == nil then | ||
return "ERROR: No item named ".. | return "ERROR: No item named "..chestName..' found[[Category:Pages with script errors]]' | ||
end | end | ||
local result = '' | local result = '' | ||
if chest.dropTable == nil then | if chest.dropTable == nil then | ||
return "ERROR: ".. | return "ERROR: "..chestName.." does not have a drop table[[Category:Pages with script errors]]" | ||
else | else | ||
local lootValue = 0 | local lootValue = 0 | ||
local totalWt = 0 | local totalWt = 0 | ||
for i, row in pairs(chest.dropTable) do | for i, row in pairs(chest.dropTable) do | ||
totalWt = totalWt + row | totalWt = totalWt + row.weight | ||
end | end | ||
result = result..'\r\n{|class="wikitable sortable"' | result = result..'\r\n{|class="wikitable sortable"' | ||
Line 903: | Line 867: | ||
--Sort the loot table by weight in descending order | --Sort the loot table by weight in descending order | ||
local chestDrops | local chestDrops = {} | ||
for i, row in ipairs(chest.dropTable) do | |||
for i, row in | table.insert(chestDrops, row) | ||
end | end | ||
table.sort(chestDrops, function(a, b) return a | table.sort(chestDrops, function(a, b) return a.weight > b.weight end) | ||
for i, row in ipairs(chestDrops) do | for i, row in ipairs(chestDrops) do | ||
local thisItem = Items.getItemByID(row | local thisItem = Items.getItemByID(row.itemID) | ||
result = result..'\r\n|-\r\n|'..Icons.Icon({thisItem.name, type='item'}) | result = result..'\r\n|-\r\n|'..Icons.Icon({thisItem.name, type='item'}) | ||
result = result..'||style="text-align:right" data-sort-value="'.. | result = result..'||style="text-align:right" data-sort-value="'..(row.minQuantity + row.maxQuantity)..'"|' | ||
if | if row.minQuantity < row.maxQuantity then | ||
result = result.. ' | result = result .. Shared.formatnum(row.minQuantity) .. ' - ' .. Shared.formatnum(row.maxQuantity) | ||
else | |||
result = result .. Shared.formatnum(row.minQuantity) | |||
end | end | ||
local dropChance = (row | local dropChance = (row.weight / totalWt) * 100 | ||
result = result..'||style="text-align:right" data-sort-value="'..row | result = result..'||style="text-align:right" data-sort-value="'..row.weight..'"' | ||
result = result..'|'..Shared.fraction(row | result = result..'|'..Shared.fraction(row.weight, totalWt) | ||
result = result..'||style="text-align:right"|'..Shared.round(dropChance, 2, 2)..'%' | result = result..'||style="text-align:right"|'..Shared.round(dropChance, 2, 2)..'%' | ||
result = result..'||style="text-align:left" data-sort-value="'..thisItem.sellsFor..'"' | result = result..'||style="text-align:left" data-sort-value="'..thisItem.sellsFor..'"' | ||
result = result..'|'..Icons.GP(thisItem.sellsFor * row.minQuantity, thisItem.sellsFor * row.maxQuantity) | |||
lootValue = lootValue + (dropChance * 0.01 * thisItem.sellsFor * ((row.minQuantity + row.maxQuantity)/ 2)) | |||
lootValue = lootValue + (dropChance * 0.01 * thisItem.sellsFor * (( | |||
end | end | ||
result = result..'\r\n|}' | result = result..'\r\n|}' | ||
Line 1,088: | Line 1,045: | ||
local totalHP = 0 | local totalHP = 0 | ||
for i, monsterID in | for i, monsterID in ipairs(area.monsters) do | ||
local monster = p.getMonsterByID(monsterID) | |||
totalHP = totalHP + p._getMonsterHP(monster) | |||
end | end | ||
return totalHP | return totalHP | ||
Line 1,164: | Line 1,119: | ||
function p.getFoxyTable(frame) | function p.getFoxyTable(frame) | ||
local result = 'Monster,Min GP,Max GP,Average GP' | local result = 'Monster,Min GP,Max GP,Average GP' | ||
for i, monster in | for i, monster in ipairs(GameData.rawData.monsters) do | ||
if not p._isDungeonOnlyMonster(monster) then | if not p._isDungeonOnlyMonster(monster) then | ||
if monster. | if monster.gpDrops ~= nil and monster.gpDrops.max > 0 then | ||
local avgGp = (monster. | local avgGp = (monster.gpDrops.min + monster.gpDrops.max) / 2 | ||
result = result..'<br/>'..monster.name..','..monster. | result = result .. '<br/>' .. monster.name .. ',' .. monster.gpDrops.min .. ',' .. monster.gpDrops.max .. ',' .. avgGp | ||
end | end | ||
end | end | ||
Line 1,181: | Line 1,136: | ||
local bones = p._getMonsterBones(monster) | local bones = p._getMonsterBones(monster) | ||
if bones ~= nil then | if bones ~= nil then | ||
totalGP = totalGP + bones.sellsFor * | totalGP = totalGP + bones.item.sellsFor * bones.quantity | ||
end | end | ||
Line 1,191: | Line 1,146: | ||
local avgGp = 0 | local avgGp = 0 | ||
if monster. | if monster.gpDrops ~= nil then | ||
avgGp = (monster. | avgGp = (monster.gpDrops.min + monster.gpDrops.max) / 2 | ||
end | end | ||
totalGP = totalGP + avgGp | totalGP = totalGP + avgGp | ||
local totalWt = 0 | local totalWt = 0 | ||
for i, row in | for i, row in ipairs(monster.lootTable) do | ||
totalWt = totalWt + row | totalWt = totalWt + row.weight | ||
end | end | ||
for i, row in | for i, row in ipairs(monster.lootTable) do | ||
local thisItem = Items.getItemByID(row | local thisItem = Items.getItemByID(row.itemID) | ||
local itemPrice = thisItem.sellsFor ~= nil and thisItem.sellsFor or 0 | local itemPrice = thisItem.sellsFor ~= nil and thisItem.sellsFor or 0 | ||
--Getting the drop chance | --Getting the drop chance | ||
local dropChance = (row | local dropChance = (row.weight / totalWt * lootChance) | ||
--Adding to the average loot value based on price & dropchance | --Adding to the average loot value based on price & dropchance | ||
lootValue = lootValue + (dropChance * 0.01 * itemPrice * (( | lootValue = lootValue + (dropChance * 0.01 * itemPrice * ((row.minQuantity + row.maxQuantity) / 2)) | ||
end | end | ||
Line 1,236: | Line 1,189: | ||
local result = '{| class="wikitable sortable"' | local result = '{| class="wikitable sortable"' | ||
result = result..'\r\n!Monster!!Combat Level!!Average GP' | result = result..'\r\n!Monster!!Combat Level!!Average GP' | ||
for i, | for i, monster in ipairs(GameData.rawData.monsters) do | ||
if not p._isDungeonOnlyMonster(monster) then | if not p._isDungeonOnlyMonster(monster) then | ||
local monsterGP = p._getMonsterAverageGP(monster) | local monsterGP = p._getMonsterAverageGP(monster) | ||
local combatLevel = p._getMonsterCombatLevel(monster | local combatLevel = p._getMonsterCombatLevel(monster) | ||
result = result..'\r\n|-\r\n|'..Icons.Icon({monster.name, type='monster', noicon=true})..'||'..combatLevel..'||'..monsterGP | result = result..'\r\n|-\r\n|'..Icons.Icon({monster.name, type='monster', noicon=true})..'||'..combatLevel..'||'..monsterGP | ||
end | end | ||
Line 1,274: | Line 1,225: | ||
-- Right now hiddenMonsterIDs is empty | -- Right now hiddenMonsterIDs is empty | ||
local hiddenMonsterIDs = {} | local hiddenMonsterIDs = {} | ||
local | local monsterList = GameData.getEntities('monsters', | ||
function(monster) | |||
if monster.canSlayer and not Shared.contains(hiddenMonsterIDs, monster.id) then | |||
local cmbLevel = p._getMonsterCombatLevel(monster) | |||
return cmbLevel >= minLevel and (maxLevel == nil or cmbLevel <= maxLevel) | |||
end | |||
return false | |||
end) | |||
if Shared. | if Shared.tableIsEmpty(monsterList) then | ||
-- Somehow no monsters are in the tier, return nothing | -- Somehow no monsters are in the tier, return nothing | ||
return '' | return '' | ||
else | else | ||
return p._getMonsterTable( | return p._getMonsterTable(monsterList, true) | ||
end | end | ||
end | end | ||
function p.getFullMonsterTable(frame) | function p.getFullMonsterTable(frame) | ||
return p._getMonsterTable(GameData.rawData.monsters, false) | |||
return p._getMonsterTable( | |||
end | end | ||
function p._getMonsterTable( | function p._getMonsterTable(monsters, excludeDungeons) | ||
--Making a single function for getting a table of monsters given a list of IDs. | --Making a single function for getting a table of monsters given a list of IDs. | ||
local hideDungeons = excludeDungeons ~= nil and excludeDungeons or false | local hideDungeons = excludeDungeons ~= nil and excludeDungeons or false | ||
Line 1,318: | Line 1,263: | ||
-- Generate row per monster | -- Generate row per monster | ||
for i, | for i, monster in ipairs(monsters) do | ||
local cmbLevel = p._getMonsterCombatLevel(monster) | local cmbLevel = p._getMonsterCombatLevel(monster) | ||
local atkSpeed = p._getMonsterAttackSpeed(monster) | local atkSpeed = p._getMonsterAttackSpeed(monster) | ||
Line 1,326: | Line 1,270: | ||
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 gpTxt = nil | local gpTxt = nil | ||
if | if monster.gpDrops.min >= monster.gpDrops.max then | ||
gpTxt = Shared.formatnum( | gpTxt = Shared.formatnum(monster.gpDrops.min) | ||
else | else | ||
gpTxt = Shared.formatnum( | gpTxt = Shared.formatnum(monster.gpDrops.min) .. ' - ' .. Shared.formatnum(monster.gpDrops.max) | ||
end | end | ||
local bones = p._getMonsterBones(monster) | 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.item.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|-\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:left" |' .. Icons.Icon({monster.name, type='monster', noicon=true})) | ||
table.insert(tableParts, '\r\n|style="text-align:right" |' .. | 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="' .. 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))) | ||
Line 1,351: | Line 1,291: | ||
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[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="' .. ( | table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. (monster.gpDrops.min + monster.gpDrops.max) / 2 .. '" |' .. gpTxt) | ||
table.insert(tableParts, '\r\n|style="text-align:center" |' .. boneTxt) | 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)) | table.insert(tableParts, '\r\n|style="text-align:right;width:190px" |' .. p._getMonsterAreas(monster, hideDungeons)) | ||
Line 1,370: | Line 1,310: | ||
-- Generate row per monster | -- Generate row per monster | ||
for i, monster in | for i, monster in ipairs(GameData.rawData.monsters) do | ||
local cmbLevel = p._getMonsterCombatLevel(monster) | local cmbLevel = p._getMonsterCombatLevel(monster) | ||
local gpTxt = nil | local gpTxt = nil | ||
if | if monster.gpDrops.min >= monster.gpDrops.max then | ||
gpTxt = Shared.formatnum( | gpTxt = Shared.formatnum(monster.gpDrops.min) | ||
else | else | ||
gpTxt = Shared.formatnum( | gpTxt = Shared.formatnum(monster.gpDrops.min) .. ' - ' .. Shared.formatnum(monster.gpDrops.max) | ||
end | end | ||
Line 1,396: | Line 1,332: | ||
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="' .. ( | table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. (monster.gpDrops.min + monster.gpDrops.max) / 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) | ||
table.insert(tableParts, '\r\n|style="text-align:right;width:190px" |' .. p._getMonsterAreas(monster, | table.insert(tableParts, '\r\n|style="text-align:right;width:190px" |' .. p._getMonsterAreas(monster, false)) | ||
end | end | ||
Line 1,420: | Line 1,356: | ||
-- Generate row per monster | -- Generate row per monster | ||
for i, monster in | for i, monster in ipairs(GameData.rawData.monsters) do | ||
local cmbLevel = p._getMonsterCombatLevel(monster) | local cmbLevel = p._getMonsterCombatLevel(monster) | ||
local gpTxt = nil | local gpTxt = nil | ||
if | if monster.gpDrops.min >= monster.gpDrops.max then | ||
gpTxt = Shared.formatnum( | gpTxt = Shared.formatnum(monster.gpDrops.min) | ||
else | else | ||
gpTxt = Shared.formatnum( | gpTxt = Shared.formatnum(monster.gpDrops.min) .. ' - ' .. Shared.formatnum(monster.gpDrops.max) | ||
end | end | ||
Line 1,446: | Line 1,378: | ||
local bones = p._getMonsterBones(monster) | 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.item.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|-\r\n|style="text-align: center;" |' .. Icons.Icon({monster.name, type='monster', size=50, notext=true})) | ||
Line 1,461: | Line 1,393: | ||
--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[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="' .. ( | table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. (monster.gpDrops.min + monster.gpDrops.max) / 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) | ||
table.insert(tableParts, '\r\n|style="text-align:center" |' .. boneTxt) | table.insert(tableParts, '\r\n|style="text-align:center" |' .. boneTxt) | ||
Line 1,474: | Line 1,406: | ||
local spAttTable = {} | local spAttTable = {} | ||
for i, monster in ipairs( | for i, monster in ipairs(GameData.rawData.monsters) do | ||
if monster.specialAttacks ~= nil and Shared. | if monster.specialAttacks ~= nil and not Shared.tableIsEmpty(monster.specialAttacks) then | ||
local overrideChance = (monster.overrideSpecialChances ~= nil and Shared.tableCount(monster.overrideSpecialChances) > 0) | local overrideChance = (monster.overrideSpecialChances ~= nil and Shared.tableCount(monster.overrideSpecialChances) > 0) | ||
for j, | for j, spAttID in ipairs(monster.specialAttacks) do | ||
local spAtt = GameData.getEntityByID('attacks', spAttID) | |||
local attChance = (overrideChance and monster.overrideSpecialChances[j] or spAtt.defaultChance) | local attChance = (overrideChance and monster.overrideSpecialChances[j] or spAtt.defaultChance) | ||
if spAttTable[spAtt.id] == nil then | if spAttTable[spAtt.id] == nil then | ||
Line 1,511: | Line 1,444: | ||
table.insert(resultPart, '\r\n|data-sort-value="' .. chance .. '"| ' .. Shared.round(chance, 2, 0) .. '%') | table.insert(resultPart, '\r\n|data-sort-value="' .. chance .. '"| ' .. Shared.round(chance, 2, 0) .. '%') | ||
if firstRow then | if firstRow then | ||
table.insert(resultPart, '\r\n' .. rowSuffix .. '| ' .. spAtt. | table.insert(resultPart, '\r\n' .. rowSuffix .. '| ' .. spAtt.customDescription) | ||
firstRow = false | firstRow = false | ||
end | end |