Anonymous

Module:Monsters: Difference between revisions

From Melvor Idle
Updated getSpecAttackMaxHit to properly account for multi-hit attacks
(Fix (another) user export table)
(Updated getSpecAttackMaxHit to properly account for multi-hit attacks)
Line 344: Line 344:


function p.getSpecAttackMaxHit(specAttack, normalMaxHit, monsterDR)
function p.getSpecAttackMaxHit(specAttack, normalMaxHit, monsterDR)
local result = 0
local bestHit = 0
for i, dmg in pairs(specAttack.damage) do
for i, dmg in pairs(specAttack.damage) do
if dmg.damageType == 'Normal' then
if dmg.damageType == 'Normal' then
--Account for special attacks that include a normal attack hit
--Account for special attacks that include a normal attack hit
local result = normalMaxHit
thisHit = normalMaxHit
if dmg.amplitude ~= nil then
if dmg.amplitude ~= nil then
result = result * (dmg.amplitude / 100)
thisHit = thisHit * (dmg.amplitude / 100)
end
end
return result
elseif dmg.maxRoll == 'Fixed' then
elseif dmg.maxRoll == 'Fixed' then
result = dmg.maxPercent * 10
thisHit = dmg.maxPercent * 10
elseif dmg.maxRoll == 'MaxHit' then
elseif dmg.maxRoll == 'MaxHit' then
if dmg.character == 'Target' then
if dmg.character == 'Target' then
--Confusion applied damage based on the player's max hit. Gonna just ignore that one
--Confusion applied damage based on the player's max hit. Gonna just ignore that one
result = 0
thisHit = 0
else
else
result = dmg.maxPercent * normalMaxHit * 0.01
thisHit = dmg.maxPercent * normalMaxHit * 0.01
end
end
elseif Shared.contains(dmg.maxRoll, "Fixed100") then
elseif Shared.contains(dmg.maxRoll, "Fixed100") then
--Handles attacks that are doubled when conditions are met like Trogark's double damage if the player is burning
--Handles attacks that are doubled when conditions are met like Trogark's double damage if the player is burning
result = dmg.maxPercent * 20
thisHit = dmg.maxPercent * 20
elseif dmg.maxRoll == 'MaxHitScaledByHP2x' then
elseif dmg.maxRoll == 'MaxHitScaledByHP2x' then
result = normalMaxHit * 2
thisHit = normalMaxHit * 2
elseif dmg.maxRoll == 'PoisonMax35' then
elseif dmg.maxRoll == 'PoisonMax35' then
result = normalMaxHit * 1.35
thisHit = normalMaxHit * 1.35
elseif dmg.maxRoll == "MaxHitDR" then
elseif dmg.maxRoll == "MaxHitDR" then
result = normalMaxHit * dmg.maxPercent * 0.01 * (1 + monsterDR * 0.01)
thisHit = normalMaxHit * dmg.maxPercent * 0.01 * (1 + monsterDR * 0.01)
elseif Shared.contains({'Bleeding', 'Poisoned'}, dmg.maxRoll) then
elseif Shared.contains({'Bleeding', 'Poisoned'}, dmg.maxRoll) then
-- TODO: This is limited in that there is no verification that bleed/poison
-- TODO: This is limited in that there is no verification that bleed/poison
-- can be applied to the target, it is assumed that it can and so this applies
-- can be applied to the target, it is assumed that it can and so this applies
result = result + dmg.maxPercent * 10
thisHit = thisHit + dmg.maxPercent * 10
end
if thisHit > bestHit then
bestHit = thisHit
end
end
end
end
return result
return bestHit
end
end