Anonymous

Module:Monsters: Difference between revisions

From Melvor Idle
monsters -> monsterIDs to match game data
(_getMonsterBaseMaxHit: Fix calculation for Magic attacks)
(monsters -> monsterIDs to match game data)
Line 918: Line 918:
local tableTxt = '{| class="wikitable sortable"'
local tableTxt = '{| class="wikitable sortable"'
tableTxt = tableTxt..'\r\n! Name !! Combat Level !! Hitpoints !! Max Hit !! [[Combat Triangle|Combat Style]]'
tableTxt = tableTxt..'\r\n! Name !! Combat Level !! Hitpoints !! Max Hit !! [[Combat Triangle|Combat Style]]'
for i, monsterID in pairs(area.monsters) do
for i, monsterID in ipairs(area.monsterIDs) do
local monster = p.getMonsterByID(monsterID)
local monster = p.getMonsterByID(monsterID)
tableTxt = tableTxt..'\r\n|-\r\n|'..Icons.Icon({monster.name, type='monster'})
tableTxt = tableTxt..'\r\n|-\r\n|'..Icons.Icon({monster.name, type='monster'})
Line 939: Line 939:
--For Dungeons, go through and count how many of each monster are in the dungeon first
--For Dungeons, go through and count how many of each monster are in the dungeon first
local monsterCounts = {}
local monsterCounts = {}
for i, monsterID in pairs(area.monsters) do
for i, monsterID in pairs(area.monsterIDs) do
if monsterCounts[monsterID] == nil then
if monsterCounts[monsterID] == nil then
monsterCounts[monsterID] = 1
monsterCounts[monsterID] = 1
Line 963: Line 963:
local area = Areas.getAreaByID('slayer', entityID)
local area = Areas.getAreaByID('slayer', entityID)
monIcon = Icons.Icon({area.name, type='combatArea'}) .. ' Monsters'
monIcon = Icons.Icon({area.name, type='combatArea'}) .. ' Monsters'
monLevel = {p.getLowHighStat(area.monsters, function(monster) return p._getMonsterCombatLevel(monster) end)}
monLevel = {p.getLowHighStat(area.monsterIDs, function(monster) return p._getMonsterCombatLevel(monster) end)}
monHP = {p.getLowHighStat(area.monsters, function(monster) return p._getMonsterHP(monster) end)}
monHP = {p.getLowHighStat(area.monsterIDs, function(monster) return p._getMonsterHP(monster) end)}
local lowMaxHit, highMaxHit = p.getLowHighStat(area.monsters, function(monster) return p._getMonsterMaxHit(monster) end)
local lowMaxHit, highMaxHit = p.getLowHighStat(area.monsterIDs, function(monster) return p._getMonsterMaxHit(monster) end)
monMaxHit = highMaxHit
monMaxHit = highMaxHit
monStyle = Icons.Icon({area.name, area.name, notext=true, nolink=true, img='Question'})
monStyle = Icons.Icon({area.name, area.name, notext=true, nolink=true, img='Question'})
Line 1,027: Line 1,027:
--  table.insert(returnPart, buildRow(152, 4))
--  table.insert(returnPart, buildRow(152, 4))
--end
--end
for i, monsterID in pairs(area.monsters) do
for i, monsterID in pairs(area.monsterIDs) do
if not Shared.contains(usedMonsters, monsterID) then
if not Shared.contains(usedMonsters, monsterID) then
if monsterID >= 0 then
if monsterID >= 0 then
Line 1,050: Line 1,050:
local totalHP = 0
local totalHP = 0


for i, monsterID in ipairs(area.monsters) do
for i, monsterID in ipairs(area.monsterIDs) do
         local monster = p.getMonsterByID(monsterID)
         local monster = p.getMonsterByID(monsterID)
         totalHP = totalHP + p._getMonsterHP(monster)
         totalHP = totalHP + p._getMonsterHP(monster)
Line 1,059: Line 1,059:
function p._getAreaMonsterList(area)
function p._getAreaMonsterList(area)
local monsterList = {}
local monsterList = {}
for i, monsterID in pairs(area.monsters) do
for i, monsterID in pairs(area.monsterIDs) do
local monster = p.getMonsterByID(monsterID)
local monster = p.getMonsterByID(monsterID)
table.insert(monsterList, Icons.Icon({monster.name, type='monster'}))
table.insert(monsterList, Icons.Icon({monster.name, type='monster'}))
Line 1,080: Line 1,080:
-- table.insert(monsterList, '4 ' .. Icons.Icon({'Bane', type='monster'}))
-- table.insert(monsterList, '4 ' .. Icons.Icon({'Bane', type='monster'}))
--end
--end
for i, monsterID in Shared.skpairs(area.monsters) do
for i, monsterID in Shared.skpairs(area.monsterIDs) do
if monsterID ~= lastID then
if monsterID ~= lastID then
local monster = nil  
local monster = nil  
Line 1,100: Line 1,100:
end
end
--Make sure the final monster in the dungeon gets counted
--Make sure the final monster in the dungeon gets counted
if i == Shared.tableCount(area.monsters) then
if i == Shared.tableCount(area.monsterIDs) then
local name = lastMonster.name
local name = lastMonster.name
table.insert(monsterList, Icons.Icon({lastMonster.name, type='monster', qty=count}))
table.insert(monsterList, Icons.Icon({lastMonster.name, type='monster', qty=count}))