Anonymous

Module:Monsters: Difference between revisions

From Melvor Idle
Added new function for explicitly determining whether a monster is found only in dungeons and adjusting drop tables accordingly.
(Added sleepDamageMultiplier to the things the MaxHit calculation takes into account)
(Added new function for explicitly determining whether a monster is found only in dungeons and adjusting drop tables accordingly.)
Line 193: Line 193:
end
end


function p.getMonsterAreas(frame)
function p._isDungeonOnlyMonster(monster)
  local areaList = Areas.getMonsterAreas(monster.id)
  local dunCount = 0
  local nonDunCount = 0
  for i, area in Shared.skpairs(areaList) do
    if area.type == 'dungeon' then
      dunCount = dunCount + 1
    else
      nonDunCount = nonDunCount + 1
    end
  end
  return dunCount > 0 and nonDunCount == 0
end
 
function p.isDungeonOnlyMonster(frame)
   local MonsterName = frame.args ~= nil and frame.args[1] or frame
   local MonsterName = frame.args ~= nil and frame.args[1] or frame
   local monster = p.getMonster(MonsterName)
   local monster = p.getMonster(MonsterName)
Line 201: Line 215:
   end
   end


  return p._isDungeonOnlyMonster(monster)
end
function p._getMonsterAreas(monster)
   local result = ''
   local result = ''
   local areaList = Areas.getMonsterAreas(monster.id)
   local areaList = Areas.getMonsterAreas(monster.id)
Line 208: Line 226:
   end
   end
   return result
   return result
end
function p.getMonsterAreas(frame)
  local MonsterName = frame.args ~= nil and frame.args[1] or frame
  local monster = p.getMonster(MonsterName)
  if monster == nil then
    return "ERROR: No monster with name "..monsterName.." found"
  end
  return p._getMonsterAreas(monster)
end
end


Line 369: Line 398:
     local bones = Items.getItemByID(monster.bones)
     local bones = Items.getItemByID(monster.bones)
     --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 (monster.lootTable ~= nil and not monster.isBoss) or Shared.contains(bones.name, 'Shard') then
     if not p._isDungeonOnlyMonster(monster) or Shared.contains(bones.name, 'Shard') then
       result = result.."'''Always Drops:'''"
       result = result.."'''Always Drops:'''"
       result = result..'\r\n{|class="wikitable"'
       result = result..'\r\n{|class="wikitable"'
Line 378: Line 407:
   end
   end


   if monster.lootTable ~= nil and not monster.isBoss then
  --Likewise, seeing the loot table is tied to the monster appearing outside of dungeons
   if not p._isDungeonOnlyMonster(monster) then
     local lootChance = monster.lootChance ~= nil and monster.lootChance or 100
     local lootChance = monster.lootChance ~= nil and monster.lootChance or 100
     local lootValue = 0
     local lootValue = 0