17,101
edits
(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 | |||
if isNormalAttackRelevant or normalAttackChance > 0 then | |||
local normalDmgText = iconText..' 1 - '..Shared.formatnum(p._getMonsterBaseMaxHit(monster))..' '..typeText..' Damage' | |||
if normalAttackChance > 0 and normalAttackChance < 100 then | |||
normalDmgText = normalAttackChance .. '% ' .. normalDmgText | |||
elseif hasActiveBuffSpec and normalAttackChance == 0 then | |||
--If the monster normally has a 0% chance of doing a normal attack but some special attacks can't be repeated, include it | |||
--(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 | ||