Anonymous

Module:Monsters: Difference between revisions

From Melvor Idle
Fix lua errors caused by gameData update
(Amended for gameData updates)
(Fix lua errors caused by gameData update)
Line 144: Line 144:
local monster = p.getMonster(MonsterName)
local monster = p.getMonster(MonsterName)
if monster ~= nil then
if monster ~= nil then
if monster.damageType == nil or monster.damageType == 'melvorD:Normal' then
return math.floor((p._getMonsterHP(monster)/(1 - p._getMonsterResistance(monster)/100)) + 0.5)
return math.floor((p._getMonsterHP(monster)/(1 - p._getMonsterStat(monster, 'damageReduction')/100)) + 0.5)
elseif monster.damageType == 'melvorItA:Abyssal' then
return math.floor((p._getMonsterHP(monster)/(1 - p._getMonsterStat(monster, 'resistance')/100)) + 0.5)
else
return Shared.printError('Monster with damage type: ' .. monster.damageType .. ' is not supported')
end
else
else
return Shared.printError('No monster with that name found')
return Shared.printError('No monster with that name found')
Line 160: Line 154:
local monster = p.getMonster(MonsterName)
local monster = p.getMonster(MonsterName)
if monster ~= nil then
if monster ~= nil then
return math.floor((p._getMonsterBarrier(monster)/(1 - p._getMonsterStat(monster, 'damageReduction')/100)) + 0.5)
return math.floor((p._getMonsterBarrier(monster)/(1 - p._getMonsterResistance(monster)/100)) + 0.5)
else
else
return Shared.printError('No monster with that name found')
return Shared.printError('No monster with that name found')
Line 363: Line 357:


function p._getMonsterResistance(monster)
function p._getMonsterResistance(monster)
local amount, text = nil, nil
-- Currently all Eternal damage monsters have Abyssal Resistance
-- Currently all Eternal damage monsters have Abyssal Resistance
-- This may change in the future. If so, uncomment the below and delete this.
-- This may change in the future. If so, uncomment the below and delete this.
if monster.damageType == 'melvorItA:Abyssal' or monster.damageType == 'melvorItA:Eternal' then
if monster.damageType == 'melvorItA:Abyssal' or monster.damageType == 'melvorItA:Eternal' then
amount = p._getMonsterStat(monster, 'resistanceAbyssal')
return p._getMonsterStat(monster, 'resistanceAbyssal'), 'Abyssal Resistance'
text = 'Abyssal Resistance'
--elseif monster.damageType == 'melvorItA:Eternal' then
--elseif monster.damageType == 'melvorItA:Eternal' then
-- amount = p._getMonsterStat(monster, 'resistanceEternal')
-- return p._getMonsterStat(monster, 'resistanceEternal'), 'Eternal Resistance'
-- text = 'Eternal Resistance'
else
else
amount = p._getMonsterStat(monster, 'damageReduction')
return p._getMonsterStat(monster, 'damageReduction'), 'Damage Reduction'
text = 'Damage Reduction'
end
end
return amount, text
end
end


Line 468: Line 457:
local monsterDR = 0
local monsterDR = 0
if monster ~= nil then
if monster ~= nil then
monsterDR = p._getMonsterStat(monster, 'damageReduction')
monsterDR = p._getMonsterResistance(monster)
end
end
thisHit = normalMaxHit * dmg.maxPercent * 0.01 * (1 + monsterDR * 0.01)
thisHit = normalMaxHit * dmg.maxPercent * 0.01 * (1 + monsterDR * 0.01)