4,951
edits
Falterfire (talk | contribs) (Formatting tweak) |
Falterfire (talk | contribs) (Added p._getMonsterDrReduction) |
||
Line 53: | Line 53: | ||
elseif statName == 'damageReduction' then | elseif statName == 'damageReduction' then | ||
return p.getEquipmentStat(monster, 'damageReduction') | return p.getEquipmentStat(monster, 'damageReduction') | ||
elseif statName == 'drReduction' then | |||
return p._getMonsterDrReduction(monster) | |||
end | end | ||
Line 558: | Line 560: | ||
return result | return result | ||
end | |||
--Function for pulling how much the monster reduces the player DR | |||
--Goes through the passvies to look for the decreasedPlayerDamageReduction modifier | |||
function p._getMonsterDrReduction(monster) | |||
local totalResult = 0 | |||
if type(monster.passives) == 'table' and not Shared.tableIsEmpty(monster.passives) then | |||
for i, passiveID in ipairs(monster.passives) do | |||
local passive = p.getPassiveByID(passiveID) | |||
if passive.modifiers ~= nil then | |||
if passive.modifiers['decreasedPlayerDamageReduction'] ~= nil then | |||
totalResult = totalResult + passive.modifiers['decreasedPlayerDamageReduction'] | |||
end | |||
end | |||
end | |||
end | |||
return totalResult | |||
end | |||
function p.getMonsterDrReduction(frame) | |||
local MonsterName = frame.args ~= nil and frame.args[1] or frame | |||
local monster = p.getMonster(MonsterName) | |||
if monster == nil then | |||
return "ERROR: No monster with that name found[[Category:Pages with script errors]]" | |||
end | |||
return p._getMonsterDrReduction(monster) | |||
end | end | ||