Anonymous

Module:Monsters: Difference between revisions

From Melvor Idle
added some handling to random style to fix issues caused by Bane, who is a jerk.
mNo edit summary
(added some handling to random style to fix issues caused by Bane, who is a jerk.)
Line 90: Line 90:
   local nolink = args.nolink
   local nolink = args.nolink


  local iconText = ''
local iconText = ''
  if  monster.attackType == 'melee' then
if  monster.attackType == 'melee' then
    iconText = Icons.Icon({'Melee', notext=notext, nolink=nolink})
iconText = Icons.Icon({'Melee', notext=notext, nolink=nolink})
  elseif monster.attackType == 'ranged' then
elseif monster.attackType == 'ranged' then
    iconText = Icons.Icon({'Ranged', type='skill', notext=notext, nolink=nolink})
iconText = Icons.Icon({'Ranged', type='skill', notext=notext, nolink=nolink})
  elseif monster.attackType == 'magic' then
elseif monster.attackType == 'magic' then
    iconText = Icons.Icon({'Magic', type='skill', notext=notext, nolink=nolink})
iconText = Icons.Icon({'Magic', type='skill', notext=notext, nolink=nolink})
  end
elseif monster.attackType == 'random' then
iconText = Icons.Icon({'Bane', 'Bane', nolink=true, img='Question'})
end


  return iconText
return iconText
end
end


Line 222: Line 224:
     baseLevel = p._getMonsterLevel(monster, 'Magic')
     baseLevel = p._getMonsterLevel(monster, 'Magic')
     bonus = p.getEquipmentStat(monster, 'magicAttackBonus')
     bonus = p.getEquipmentStat(monster, 'magicAttackBonus')
  elseif monster.attackType == 'random' then
  local arArray = {}
  local iconText = Icons.Icon({'Melee', notext=true})
    baseLevel = p._getMonsterLevel(monster, 'Attack')
    bonus = p.getEquipmentStat(monster, 'stabAttackBonus')
    table.insert(arArray, iconText..' '..p.calculateStandardStat(baseLevel, bonus))
    iconText = Icons.Icon({'Ranged', type='skill', notext=true})
    baseLevel = p._getMonsterLevel(monster, 'Ranged')
    bonus = p.getEquipmentStat(monster, 'rangedAttackBonus')
    table.insert(arArray, iconText..' '..p.calculateStandardStat(baseLevel, bonus))
    iconText = Icons.Icon({'Magic', type='skill', notext=true})
    baseLevel = p._getMonsterLevel(monster, 'Magic')
    bonus = p.getEquipmentStat(monster, 'magicAttackBonus')
    table.insert(arArray, iconText..' '..p.calculateStandardStat(baseLevel, bonus))
    return table.concat(arArray, '<br/>')
   else
   else
     return "ERROR: This monster has an invalid attack type somehow[[Category:Pages with script errors]]"
     return "ERROR: This monster has an invalid attack type somehow[[Category:Pages with script errors]]"
Line 391: Line 408:
       end
       end
     end
     end
    mw.log(canStun)


     if canSleep and doStuns then damageMultiplier = damageMultiplier * 1.2 end
     if canSleep and doStuns then damageMultiplier = damageMultiplier * 1.2 end
Line 416: Line 432:
   --8/27/21 - Now references p.calculateStandardMaxHit for Melee & Ranged
   --8/27/21 - Now references p.calculateStandardMaxHit for Melee & Ranged
   local result = 0
   local result = 0
  local baseLevel = 0
  local bonus = 0
   if monster.attackType == 'melee' then
   if monster.attackType == 'melee' then
     local baseLevel = p._getMonsterLevel(monster, 'Strength')
     baseLevel = p._getMonsterLevel(monster, 'Strength')
     local bonus = p.getEquipmentStat(monster, 'meleeStrengthBonus')
     bonus = p.getEquipmentStat(monster, 'meleeStrengthBonus')
     result = p.calculateStandardMaxHit(baseLevel, bonus)
     result = p.calculateStandardMaxHit(baseLevel, bonus)
   elseif monster.attackType == 'ranged' then
   elseif monster.attackType == 'ranged' then
     local baseLevel = p._getMonsterLevel(monster, 'Ranged')
     baseLevel = p._getMonsterLevel(monster, 'Ranged')
     local bonus = p.getEquipmentStat(monster, 'rangedStrengthBonus')
     bonus = p.getEquipmentStat(monster, 'rangedStrengthBonus')
     result = p.calculateStandardMaxHit(baseLevel, bonus)
     result = p.calculateStandardMaxHit(baseLevel, bonus)
   elseif monster.attackType == 'magic' then
   elseif monster.attackType == 'magic' then
Line 428: Line 446:
     if monster.selectedSpell ~= nil then mSpell = Magic.getSpellByID('Spells', monster.selectedSpell) end
     if monster.selectedSpell ~= nil then mSpell = Magic.getSpellByID('Spells', monster.selectedSpell) end
        
        
     local bonus = p.getEquipmentStat(monster, 'magicDamageBonus')
     bonus = p.getEquipmentStat(monster, 'magicDamageBonus')
     local baseLevel = p._getMonsterLevel(monster, 'Magic')
     baseLevel = p._getMonsterLevel(monster, 'Magic')


     result = math.floor(10 * mSpell.maxHit * (1 + bonus / 100) * (1 + (baseLevel + 1) / 200))
     result = math.floor(10 * mSpell.maxHit * (1 + bonus / 100) * (1 + (baseLevel + 1) / 200))
  elseif monster.attackType == 'random' then
  local hitArray = {}
  local iconText = Icons.Icon({'Melee', notext=true})
    baseLevel = p._getMonsterLevel(monster, 'Strength')
    bonus = p.getEquipmentStat(monster, 'meleeStrengthBonus')
    table.insert(hitArray, p.calculateStandardMaxHit(baseLevel, bonus))
   
    iconText = Icons.Icon({'Ranged', type='skill', notext=true})
    baseLevel = p._getMonsterLevel(monster, 'Ranged')
    bonus = p.getEquipmentStat(monster, 'rangedStrengthBonus')
    table.insert(hitArray, p.calculateStandardMaxHit(baseLevel, bonus))
   
    iconText = Icons.Icon({'Magic', type='skill', notext=true})
    local mSpell = nil
    if monster.selectedSpell ~= nil then mSpell = Magic.getSpellByID('Spells', monster.selectedSpell) end
    bonus = p.getEquipmentStat(monster, 'magicDamageBonus')
    baseLevel = p._getMonsterLevel(monster, 'Magic')
    local magicDmg = math.floor(10 * mSpell.maxHit * (1 + bonus / 100) * (1 + (baseLevel + 1) / 200))
    table.insert(hitArray, magicDmg)
   
    local max = 0
    for i, val in pairs(hitArray) do
    if val > max then max = val end
    end
    result = max
   else
   else
     return "ERROR: This monster has an invalid attack type somehow[[Category:Pages with script errors]]"
     return "ERROR: This monster has an invalid attack type somehow[[Category:Pages with script errors]]"
Line 459: Line 502:


   local result = ''
   local result = ''
 
   local iconText = p._getMonsterStyleIcon({monster})
   local iconText = ''
   local typeText = ''
   local typeText = ''
   if  monster.attackType == 'melee' then
   if  monster.attackType == 'melee' then
    iconText = Icons.Icon({'Melee', notext=true})
     typeText = 'Melee'
     typeText = 'Melee'
   elseif monster.attackType == 'ranged' then
   elseif monster.attackType == 'ranged' then
    iconText = Icons.Icon({'Ranged', type='skill', notext=true})
     typeText = 'Ranged'
     typeText = 'Ranged'
   elseif monster.attackType == 'magic' then
   elseif monster.attackType == 'magic' then
    iconText = Icons.Icon({'Magic', type='skill', notext=true})
     typeText = 'Magic'
     typeText = 'Magic'
  elseif monster.attackType == 'random' then
  typeText = "Random"
   end
   end