Module:Monsters: Difference between revisions

Created getMonsterAttacks
(Added a getMaxHit function)
(Created getMonsterAttacks)
Line 273: Line 273:
   --Should only get here for Melee/Ranged, which use functionally the same damage formula
   --Should only get here for Melee/Ranged, which use functionally the same damage formula
   return math.floor(10 * (1.3 + (effStrLvl/10) + (strBonus / 80) + ((effStrLvl * strBonus) / 640)))
   return math.floor(10 * (1.3 + (effStrLvl/10) + (strBonus / 80) + ((effStrLvl * strBonus) / 640)))
end
function p.getMonsterAttacks(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 = ''
  local iconText = ''
  local typeText = ''
  if  monster.attackType == Constants.attackType.Melee then
    iconText = Icons.Icon({'Melee', notext=true})
    typeText = 'Melee'
  elseif monster.attackType == Constants.attackType.Ranged then
    iconText = Icons.Icon({'Ranged', type='skill', notext=true})
    typeText = 'Ranged'
  else
    iconText = Icons.Icon({'Magic', type='skill', notext=true})
    typeText = 'Magic'
  end
  local normalAttackChance = 100
  if monster.hasSpecialAttack then
    for i, specID in pairs(monster.specialAttackID) do
      local specAttack = p.getSpecialAttackByID(specID)
      local attChance = 0
      if monster.overrideSpecialChances ~= nil then
      else
        attChance = specAttack.chance
      end
      normalAttackChance = normalAttackChance - attChance
      result = result..'\r\n* '..attChance..'% '..iconText..' '..specAttack.name..'\r\n** '..specAttack.description
    end
  end
  if normalAttackChance == 100 then
    result = iconText..'1-'..p.getMonsterBaseMaxHit(frame)..' '..typeText..' Damage'
  elseif normalAttackChance > 0 then
    result = '* '..normalAttackChance..'% '..iconText..'1-'..p.getMonsterBaseMaxHit(frame)..' '..typeText..' Damage'..result
  end
  return result
end
end


return p
return p