Anonymous

Module:Monsters: Difference between revisions

From Melvor Idle
getAreaMonsterTable: Swap to use functions accepting monster object as a parameter; getMonsterBones: Rename to _getMonsterBones
(getMonsterDrops: Amend display of very small chances)
(getAreaMonsterTable: Swap to use functions accepting monster object as a parameter; getMonsterBones: Rename to _getMonsterBones)
Line 298: Line 298:
-- Determines if the monster is capable of dropping bones, and returns the bones
-- Determines if the monster is capable of dropping bones, and returns the bones
-- item if so, or nil otherwise
-- item if so, or nil otherwise
function p.getMonsterBones(monster)
function p._getMonsterBones(monster)
if monster.bones ~= nil and monster.bones >= 0 then
if monster.bones ~= nil and monster.bones >= 0 then
local boneItem = Items.getItemByID(monster.bones)
local boneItem = Items.getItemByID(monster.bones)
Line 671: Line 671:
local result = ''
local result = ''


local bones = p.getMonsterBones(monster)
local bones = p._getMonsterBones(monster)
--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
Line 894: Line 894:
tableTxt = tableTxt..'\r\n|-\r\n|'..Icons.Icon({monster.name, type='monster'})
tableTxt = tableTxt..'\r\n|-\r\n|'..Icons.Icon({monster.name, type='monster'})
tableTxt = tableTxt..'||'..p._getMonsterCombatLevel(monster)
tableTxt = tableTxt..'||'..p._getMonsterCombatLevel(monster)
tableTxt = tableTxt..'||'..Shared.formatnum(p.getMonsterHP(monster.name))
tableTxt = tableTxt..'||'..Shared.formatnum(p._getMonsterHP(monster))
tableTxt = tableTxt..'||'..Shared.formatnum(p.getMonsterMaxHit(monster.name))
tableTxt = tableTxt..'||'..Shared.formatnum(p._getMonsterMaxHit(monster))
tableTxt = tableTxt..'||'..p.getMonsterStyleIcon({monster.name, nolink=true})
tableTxt = tableTxt..'||'..p._getMonsterStyleIcon({monster, nolink=true})
end
end
tableTxt = tableTxt..'\r\n|}'
tableTxt = tableTxt..'\r\n|}'
Line 1,113: Line 1,113:
local totalGP = 0
local totalGP = 0


local bones = p.getMonsterBones(monster)
local bones = p._getMonsterBones(monster)
if bones ~= nil then
if bones ~= nil then
totalGP = totalGP + bones.sellsFor * (type(monster.boneQty) == 'number' and monster.boneQty or 1)
totalGP = totalGP + bones.sellsFor * (type(monster.boneQty) == 'number' and monster.boneQty or 1)
Line 1,270: Line 1,270:
gpTxt = Shared.formatnum(gpRange[1]) .. ' - ' .. Shared.formatnum(gpRange[2])
gpTxt = Shared.formatnum(gpRange[1]) .. ' - ' .. Shared.formatnum(gpRange[2])
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.name, type='item', notext=true})) or 'None'