Code: Select all
local adjusted_value = value
if src and src.attr and src:attr("damage_shield_penetrate") then
adjusted_value = value * (1 - (util.bound(src.damage_shield_penetrate, 0, 100) / 100))
end
...
if adjusted_value <= self.damage_shield_absorb then
self.damage_shield_absorb = self.damage_shield_absorb - adjusted_value
if reflection > 0 then reflect_damage = adjusted_value end
value = value - adjusted_value
else
if reflection > 0 then reflect_damage = self.damage_shield_absorb end
--- value = adjusted_value - self.damage_shield_absorb
+++ value = value - self.damage_shield_absorb
adjusted_value = self.damage_shield_absorb
self.damage_shield_absorb = 0
end
For example, let's say the damage is 100 with 25% damage penetration. This means 25 damage bypasses the shield and 75 hits the shield. Let's say then the shield is 60. The current code says that after the shield is used up the damage remaining is 15 (75 - 60). But this omits the 25 which bypasses, so the total damage remaining is 40 (25 + 15). Which is simply the original damage value minus the shield.
I studied this for about 2 hours using the log, to finally work out why the numbers never made sense.
So I'm fairly confident my proposal is the correct one. (But happy to be corrected if I'm wrong, too!).