Code: Select all
local ignore_direct_crits = target:attr 'ignore_direct_crits'
if crit_power > 1 and ignore_direct_crits then -- Reduce the post crit damage, we have to do this here since most crits are calculated before knowing their target
-- Add crit bonus power for being unseen (direct damage only, diminished with range)
local unseen_crit = src.__is_actor and target.__is_actor and not src.__project_source and src.unseen_critical_power
if unseen_crit and not target:canSee(src) and src:canSee(target) then
local d, reduc = core.fov.distance(src.x, src.y, x, y), 0
if d > 3 then
reduc = math.scale(d, 3, 10, 0, 1)
unseen_crit = math.max(0, unseen_crit*(1 - reduc))
end
if unseen_crit > 0 then
if target.unseen_crit_defense and target.unseen_crit_defense > 0 then
unseen_crit = math.max(0, unseen_crit*(1 - target.unseen_crit_defense))
end
crit_power = crit_power + unseen_crit
print("[PROJECTOR] after unseen_critical_power type/dam/range/power", type, dam, d, unseen_crit, "::", crit_power - unseen_crit, "=>", crit_power)
end
end
dam = dam / crit_power
local reduce = (crit_power - 1) * (util.bound(ignore_direct_crits, 0, 100) / 100)
crit_power = math.max(1, crit_power - reduce)
dam = dam * crit_power
print("[PROJECTOR] crit power reduce dam", dam)
end
should be executed before calculating unssen crit powerdam = dam / crit_power