Module:Monsters: Difference between revisions

_getMonsterMaxHit: Modify for v0.20 stun/sleep logic
m (getChestDrops: Added punctuation)
(_getMonsterMaxHit: Modify for v0.20 stun/sleep logic)
Line 297: Line 297:


function p._getMonsterMaxHit(monster)
function p._getMonsterMaxHit(monster)
  -- 2021-06-11 Adjusted for v0.20 stun/sleep changes, where damage multiplier now applies
  -- to all enemy attacks if stun/sleep is present on at least one special attack
   local normalChance = 100
   local normalChance = 100
   local specialMaxHit = 0
   local specialMaxHit = 0
   local normalMaxHit = p._getMonsterBaseMaxHit(monster)
   local normalMaxHit = p._getMonsterBaseMaxHit(monster)
   local hasActiveBuffSpec = false
   local hasActiveBuffSpec = false
  local damageMultiplier = 1
   if monster.hasSpecialAttack then
   if monster.hasSpecialAttack then
    local canStun = false
    local canSleep = false
     for i, specID in pairs(monster.specialAttackID) do
     for i, specID in pairs(monster.specialAttackID) do
       local specAttack = p.getSpecialAttackByID(specID)
       local specAttack = p.getSpecialAttackByID(specID)
Line 315: Line 320:
         thisMax = normalMaxHit
         thisMax = normalMaxHit
       end
       end
       if specAttack.stunDamageMultiplier ~= nil and specAttack.stunDamageMultiplier > 1 then
       if specAttack.canStun ~= nil and specAttack.canStun then canStun = true end
        thisMax = thisMax * specAttack.stunDamageMultiplier
       if specAttack.canSleep ~= nil and specAttack.canSleep then canSleep = true end
      end
 
       if specAttack.sleepDamageMultiplier ~= nil and specAttack.sleepDamageMultiplier > 1 then
        thisMax = thisMax * specAttack.sleepDamageMultiplier
      end
       if thisMax > specialMaxHit then specialMaxHit = thisMax end
       if thisMax > specialMaxHit then specialMaxHit = thisMax end
       if specAttack.activeBuffs then hasActiveBuffSpec = true end
       if specAttack.activeBuffs then hasActiveBuffSpec = true end
     end
     end
    if canStun then damageMultiplier = damageMultiplier * 1.3 end
    if canSleep then damageMultiplier = damageMultiplier * 1.2 end
   end
   end
   --Ensure that if the monster never does a normal attack, the normal max hit is irrelevant
   --Ensure that if the monster never does a normal attack, the normal max hit is irrelevant
   if normalChance == 0 and not hasActiveBuffSpec then normalMaxHit = 0 end
   if normalChance == 0 and not hasActiveBuffSpec then normalMaxHit = 0 end
   return math.max(specialMaxHit, normalMaxHit)
   return math.floor(math.max(specialMaxHit, normalMaxHit) * damageMultiplier)
end
end


Line 359: Line 364:
     end
     end
   else
   else
    error('blah')
     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]]"
   end
   end