Module:Monsters: Difference between revisions

Added passive ability related functions
(Added new function for explicitly determining whether a monster is found only in dungeons and adjusting drop tables accordingly.)
(Added passive ability related functions)
Line 40: Line 40:
     if(attack.name == name) then
     if(attack.name == name) then
       result = Shared.clone(attack)
       result = Shared.clone(attack)
       --Make sure every monster has an ID, and account for the 1-based indexing of Lua
       --Make sure every attack has an ID, and account for the 1-based indexing of Lua
       result.id = i - 1
       result.id = i - 1
     end
     end
Line 49: Line 49:
function p.getSpecialAttackByID(ID)
function p.getSpecialAttackByID(ID)
   return MonsterData.SpecialAttacks[ID + 1]
   return MonsterData.SpecialAttacks[ID + 1]
end
function p.getPassive(name)
  local result = nil
  for i, passive in pairs(MonsterData.Passives) do
    if passive.name == name then
      result = Shared.clone(passive)
      --Make sure every passive has an ID, and account for the 1-based indexing of Lua
      result.id = i - 1
    end
  end
  return result
end
function p.getPassiveByID(ID)
  return MonsterData.Passives[ID + 1]
end
end


Line 352: Line 369:
   elseif normalAttackChance > 0 then
   elseif normalAttackChance > 0 then
     result = '* '..normalAttackChance..'% '..iconText..'1-'..p.getMonsterBaseMaxHit(frame)..' '..typeText..' Damage'..result
     result = '* '..normalAttackChance..'% '..iconText..'1-'..p.getMonsterBaseMaxHit(frame)..' '..typeText..' Damage'..result
  end
  return result
end
function p.getMonsterPassives(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"
  end
  local result = ''
  if monster.hasPassive then
    result = result .. '===Passives==='
    for i, passiveID in pairs(monster.passiveID) do
      local passive = p.getPassiveByID(passiveID)
      local passiveChance = 0
      if passive.chance ~= nil then
        passiveChance = passive.chance
      end
      result = result .. '\r\n* ' .. Shared.round(passiveChance, 2, 0) .. '% ' .. passive.name .. '\r\n** ' .. passive.description
    end
   end
   end
   return result
   return result