Module:Monsters: Difference between revisions

Added p.getOtherMonsterBoxText
(Tweaked Dungeon Rewards to account for Miolite Caves not rewarding any GP)
(Added p.getOtherMonsterBoxText)
Line 76: Line 76:
   local monster = p.getMonster(MonsterName)
   local monster = p.getMonster(MonsterName)
   if monster == nil then
   if monster == nil then
     return "ERROR: No monster with that name found"
     return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
   end
   end


Line 120: Line 120:


   if monster == nil then
   if monster == nil then
     return "ERROR: No monster with that name found"
     return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
   end
   end


Line 137: Line 137:
     return p._getMonsterHP(monster)
     return p._getMonsterHP(monster)
   else
   else
     return "ERROR: No monster with that name found"
     return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
   end
   end
end
end
Line 151: Line 151:
     return p._getMonsterAttackSpeed(monster)
     return p._getMonsterAttackSpeed(monster)
   else
   else
     return "ERROR: No monster with that name found"
     return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
   end
   end
end
end
Line 174: Line 174:


   if monster == nil then
   if monster == nil then
     return "ERROR: No monster with that name found"
     return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
   end
   end


Line 193: Line 193:
     attBonus = monster.attackBonusMagic + 64
     attBonus = monster.attackBonusMagic + 64
   else
   else
     return "ERROR: This monster has an invalid attack type somehow"
     return "ERROR: This monster has an invalid attack type somehow[[Category:Pages with script errors]]"
   end
   end


Line 204: Line 204:


   if monster == nil then
   if monster == nil then
     return "ERROR: No monster with that name found"
     return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
   end
   end


Line 227: Line 227:
     defBonus = monster.defenceBonusMagic + 64
     defBonus = monster.defenceBonusMagic + 64
   else
   else
     return "ERROR: Must choose Melee, Ranged, or Magic"
     return "ERROR: Must choose Melee, Ranged, or Magic[[Category:Pages with script errors]]"
   end
   end
   return effDefLvl * defBonus
   return effDefLvl * defBonus
Line 239: Line 239:


   if monster == nil then
   if monster == nil then
     return "ERROR: No monster with that name found"
     return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
   end
   end


Line 265: Line 265:


   if monster == nil then
   if monster == nil then
     return "ERROR: No monster with name "..monsterName.." found"
     return "ERROR: No monster with name "..monsterName.." found[[Category:Pages with script errors]]"
   end
   end


Line 290: Line 290:


   if monster == nil then
   if monster == nil then
     return "ERROR: No monster with name "..monsterName.." found"
     return "ERROR: No monster with name "..monsterName.." found[[Category:Pages with script errors]]"
   end
   end


Line 333: Line 333:


   if monster == nil then
   if monster == nil then
     return "ERROR: No monster with that name found"
     return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
   end
   end


Line 357: Line 357:
     end
     end
   else
   else
     return "ERROR: This monster has an invalid attack type somehow"
     return "ERROR: This monster has an invalid attack type somehow[[Category:Pages with script errors]]"
   end
   end


Line 369: Line 369:


   if monster == nil then
   if monster == nil then
     return "ERROR: No monster with that name found"
     return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
   end
   end


Line 380: Line 380:


   if monster == nil then
   if monster == nil then
     return "ERROR: No monster with that name found"
     return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
   end
   end


Line 426: Line 426:


   if monster == nil then
   if monster == nil then
     return "ERROR: No monster with that name found"
     return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
   end
   end


Line 451: Line 451:


   if monster == nil then
   if monster == nil then
     return "ERROR: No monster with that name found"
     return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
   end
   end


Line 471: Line 471:
     result = result..'[[Category:Bosses]]'
     result = result..'[[Category:Bosses]]'
   end
   end
  return result
end
function p.getOtherMonsterBoxText(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 that name found[[Category:Pages with script errors]]"
  end
  local result = ''
  --Going through and finding out which damage bonuses will apply to this monster
  local monsterTypes = {}
  if monster.isBoss then table.insert(monsterTypes, 'Boss') end
  local areaList = Areas.getMonsterAreas(monster.id)
  local counts = {combat = 0, slayer = 0, dungeon = 0}
  for i, area in Shared.skpairs(areaList) do
    counts[area.type] = counts[area.type] + 1
  end
  if counts.combat > 0 then table.insert(monsterTypes, 'Combat Area') end
  if counts.slayer > 0 then table.insert(monsterTypes, 'Slayer Area') end
  if counts.dungeon > 0 then table.insert(monsterTypes, 'Dungeon') end
  result = result.."\r\n|-\r\n|'''Monster Types:''' "..table.concat(monsterTypes, ", ")


   return result
   return result
Line 480: Line 509:


   if monster == nil then
   if monster == nil then
     return "ERROR: No monster with that name found"
     return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
   end
   end


Line 580: Line 609:


   if chest == nil then
   if chest == nil then
     return "ERROR: No item named "..ChestName..' found'
     return "ERROR: No item named "..ChestName..' found[[Category:Pages with script errors]]'
   end
   end


Line 586: Line 615:


   if chest.dropTable == nil then
   if chest.dropTable == nil then
     return "ERROR: "..ChestName.." does not have a drop table"
     return "ERROR: "..ChestName.." does not have a drop table[[Category:Pages with script errors]]"
   else
   else
     local lootChance = 100
     local lootChance = 100
Line 645: Line 674:
   local area = Areas.getArea(areaName)
   local area = Areas.getArea(areaName)
   if area == nil then
   if area == nil then
     return "ERROR: Could not find an area named "..areaName
     return "ERROR: Could not find an area named "..areaName..'[[Category:Pages with script errors]]'
   end
   end


Line 670: Line 699:
   local area = Areas.getArea(areaName)
   local area = Areas.getArea(areaName)
   if area == nil then
   if area == nil then
     return "ERROR: Could not find a dungeon named "..areaName
     return "ERROR: Could not find a dungeon named "..areaName..'[[Category:Pages with script errors]]'
   end
   end


Line 761: Line 790:
   local area = Areas.getArea(areaName)
   local area = Areas.getArea(areaName)
   if area == nil then
   if area == nil then
     return "ERROR: Could not find an area named "..areaName
     return "ERROR: Could not find an area named "..areaName..'[[Category:Pages with script errors]]'
   end
   end


Line 795: Line 824:
   local area = Areas.getArea(areaName)
   local area = Areas.getArea(areaName)
   if area == nil then
   if area == nil then
     return "ERROR: Could not find an area named "..areaName
     return "ERROR: Could not find an area named "..areaName..'[[Category:Pages with script errors]]'
   end
   end


Line 801: Line 830:
     return p._getDungeonRewards(area)
     return p._getDungeonRewards(area)
   else
   else
     return "ERROR: "..areaName.." is not a dungeon"
     return "ERROR: "..areaName.." is not a dungeon[[Category:Pages with script errors]]"
   end
   end
end
end
Line 873: Line 902:


   if monster == nil then
   if monster == nil then
     return "ERROR: No monster with that name found"
     return "ERROR: No monster with that name found[[Category:Pages with script errors]]"
   end
   end


Line 900: Line 929:
   local SlayerTiers = Constants.Slayer.Tiers
   local SlayerTiers = Constants.Slayer.Tiers
   if tier == nil then
   if tier == nil then
     return "ERROR: No tier specified"
     return "ERROR: No tier specified[[Category:Pages with script errors]]"
   elseif tonumber(tier) == nil then
   elseif tonumber(tier) == nil then
     return "ERROR: Tier must be an integer"
     return "ERROR: Tier must be an integer[[Category:Pages with script errors]]"
   else
   else
     tier = math.floor(tonumber(tier))
     tier = math.floor(tonumber(tier))
     local tierCount = Shared.tableCount(SlayerTiers) - 1
     local tierCount = Shared.tableCount(SlayerTiers) - 1
     if tier < 0 or tier > tierCount then
     if tier < 0 or tier > tierCount then
       return "ERROR: Tier must be between 0 and " .. tierCount
       return "ERROR: Tier must be between 0 and " .. tierCount..'[[Category:Pages with script errors]]'
     end
     end
     tier = tier + 1
     tier = tier + 1