Module:Monsters: Difference between revisions

getMonsterAttacks: Include normal attack damage when a special attack deals normal damage, even if the normal attack chance is 0%
(Use printError function)
(getMonsterAttacks: Include normal attack damage when a special attack deals normal damage, even if the normal attack chance is 0%)
Line 547: Line 547:
local buffAttacks = {}
local buffAttacks = {}
local hasActiveBuffSpec = false
local hasActiveBuffSpec = false
local isNormalAttackRelevant = false


local normalAttackChance = 100
local normalAttackChance = 100
Line 574: Line 575:
if Shared.contains(string.upper(specAttack.description), 'NORMAL ATTACK INSTEAD') then
if Shared.contains(string.upper(specAttack.description), 'NORMAL ATTACK INSTEAD') then
table.insert(buffAttacks, specAttack.name)
table.insert(buffAttacks, specAttack.name)
hasActiveBuffSpec = true  
hasActiveBuffSpec = true
isNormalAttackRelevant = true
end
if not isNormalAttackRelevant and type(specAttack.damage) == 'table' then
-- Determine if the special attack uses normal damage in some form
for j, dmgData in ipairs(specAttack.damage) do
if dmgData.damageType == 'Normal' then
isNormalAttackRelevant = true
break
end
end
end
end
end
end
end
end
if normalAttackChance == 100 then
result = iconText..' 1 - '..p._getMonsterBaseMaxHit(monster)..' '..typeText..' Damage'
if isNormalAttackRelevant or normalAttackChance > 0 then
elseif normalAttackChance > 0 then
local normalDmgText = iconText..' 1 - '..Shared.formatnum(p._getMonsterBaseMaxHit(monster))..' '..typeText..' Damage'
result = '* '..normalAttackChance..'% '..iconText..' 1 - '..p.getMonsterBaseMaxHit(frame)..' '..typeText..' Damage'..result
if normalAttackChance > 0 and normalAttackChance < 100 then
elseif hasActiveBuffSpec then
normalDmgText = normalAttackChance .. '% ' .. normalDmgText
--If the monster normally has a 0% chance of doing a normal attack but some special attacks can't be repeated, include it
elseif hasActiveBuffSpec and normalAttackChance == 0 then
--(With a note about when it does it)
--If the monster normally has a 0% chance of doing a normal attack but some special attacks can't be repeated, include it
result = '* '..iconText..' 1 - '..p._getMonsterBaseMaxHit(monster)..' '..typeText..' Damage (Instead of repeating '..table.concat(buffAttacks, ' or ')..' while the effect is already active)'..result
--(With a note about when it does it)
normalDmgText = normalDmgText .. ' (Instead of repeating '..table.concat(buffAttacks, ' or ')..' while the effect is already active)'
end
result = '* ' .. normalDmgText .. result
end
end