Anonymous

Module:Items/SourceTables: Difference between revisions

From Melvor Idle
Use Monsters.getMonsterBones to centralise bone drop logic
(_getItemSources: Add event items)
(Use Monsters.getMonsterBones to centralise bone drop logic)
Line 326: Line 326:
   local dungeonStrPart = {}
   local dungeonStrPart = {}
   for i, monster in ipairs(MonsterData.Monsters) do
   for i, monster in ipairs(MonsterData.Monsters) do
  local isDrop = false
  local isDrop, isBones = false, false
  if monster.bones == item.id and ((monster.lootTable ~= nil and not monster.isBoss) or Shared.contains(item.name, 'Shard')) then
  if monster.bones == item.id and Monsters.getMonsterBones(monster) ~= nil then
  -- Item is a bone, and is either a shard from God dungeons or dropped by a non-boss monster with a loot table
  -- Item is a bone, and is either a shard from God dungeons or dropped by a non-boss monster with a loot table
  isDrop = true
  isDrop = true
  isBones = true
       elseif monster.lootTable ~= nil then
       elseif monster.lootTable ~= nil then
      -- If the monster has a loot table, check if the item we are looking for is in there
      -- If the monster has a loot table, check if the item we are looking for is in there
Line 339: Line 340:
         end
         end
       end
       end
  if isDrop then
  if isDrop and not isBones then
  if not Shared.contains(item.name, 'Shard') and Monsters._isDungeonOnlyMonster(monster) then
  if Monsters._isDungeonOnlyMonster(monster) then
  -- For dungeon exclusive monsters, loot is only rolled when they are the last
  -- For dungeon exclusive monsters, loot is only rolled when they are the last
  -- monster within that dungeon (unless it is a shard)
  -- monster within that dungeon (unless it is a shard)
Line 659: Line 660:
     --Only add bones if this monster has loot (ie appears outside a dungeon) and isn't a boss
     --Only add bones if this monster has loot (ie appears outside a dungeon) and isn't a boss
     --... unless we're looking for Shards of course, at which point we'll take any monster with the right bones
     --... unless we're looking for Shards of course, at which point we'll take any monster with the right bones
     if monster.bones == item.id and ((monster.lootTable ~= nil and not monster.isBoss) or Shared.contains(item.name, 'Shard')) then
     if monster.bones == item.id and Monsters.getMonsterBones(monster) ~= nil then
       qty = monster.boneQty ~= nil and monster.boneQty or 1
       qty = monster.boneQty ~= nil and monster.boneQty or 1
       minqty = qty
       minqty = qty