Anonymous

Module:Monsters: Difference between revisions

From Melvor Idle
_getDungeonMonsterList: Fix
(Amend/correct handling for random ITM and random spider lair monsters)
(_getDungeonMonsterList: Fix)
Line 1,073: Line 1,073:
function p._getDungeonMonsterList(area)
function p._getDungeonMonsterList(area)
local monsterList = {}
local monsterList = {}
local lastMonster = nil
local lastID = ''
local lastID = -2
local count = 0
local count = 0
-- Special handing for Impending Darkness event
-- Special handing for Impending Darkness event
Line 1,085: Line 1,084:
-- 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.monsterIDs) do
if monsterID ~= lastID then
local monsterCounts = {}
if monsterID == 'melvorF:RandomITM' then
for i, monsterID in ipairs(area.monsterIDs) do
--Special handling for Afflicted Monsters
if lastID == '' then
table.insert(monsterList, Icons.Icon({'Affliction', 'Afflicted Monster', img='Question', qty=count}))
elseif monsterID == 'melvorTotH:RandomSpiderLair' then
table.insert(monsterList, Icons.Icon({'Spider', img='Question', nolink=true, qty=count}))
else
local monster = p.getMonsterByID(monsterID)
table.insert(monsterList, Icons.Icon({monster.name, type='monster', qty=count}))
end
lastMonster = monster
lastID = monsterID
lastID = monsterID
count = 1
count = 1
elseif lastID == monsterID then
count = count + 1
else
else
count = count + 1
table.insert(monsterCounts, { id = lastID, count = count })
lastID = monsterID
count = 1
end
end
--Make sure the final monster in the dungeon gets counted
end
if i == Shared.tableCount(area.monsterIDs) then
table.insert(monsterCounts, { id = lastID, count = count })
local name = lastMonster.name
 
table.insert(monsterList, Icons.Icon({lastMonster.name, type='monster', qty=count}))
for i, monster in ipairs(monsterCounts) do
if monster.id == 'melvorF:RandomITM' then
--Special handling for Afflicted Monsters
table.insert(monsterList, Icons.Icon({'Affliction', 'Afflicted Monster', img='Question', qty=monster.count}))
elseif monster.id == 'melvorTotH:RandomSpiderLair' then
table.insert(monsterList, Icons.Icon({'Spider', img='Question', nolink=true, qty=monster.count}))
else
local monsterObj = p.getMonsterByID(monster.id)
table.insert(monsterList, Icons.Icon({monsterObj.name, type='monster', qty=monster.count}))
end
end
end
end
return table.concat(monsterList, '<br/>')
return table.concat(monsterList, '<br/>')
end
end