This is a bugfix for the vanilla 1.06 and earlier Mana Shield logic. In 1.07 Blizzard North "fixed" the Mana Shield logic since the damage reduction would decrease in effectiveness with increased spell level instead of increase. As a fix, they set the damage reduction to a flat value regardless of spell level. Originally, damage reduction started at 1/3 and capped at 1/21 at spell level 7. This fix reverses the order and gives 1/21 damage reduction at spell level 1, and caps at 1/3 damage reduction at spell level 7.
This does introduce a slight behaviour difference for some callers. It was possible to read out of bounds due to the bounds check only guarding against negative indexes (e.g. Theme_Library uses 1, MAXDUN - 1 as the bounds, but Theme_ArmorStand includes boundary tiles so could read off the right/bottom edge). Given the way vanilla levels are generated with a border this has no impact in practice.
Fixes collision detection for the fire/lightning sprite that causes element base damage on collision with players and monsters, and removed Damage Mod on items from changing elemental damage.
Monster damage values from melee/missile hits could potentially add or subtract up to 63/64ths of damage over and above a monster's usual damage range
Co-authored-by: Stephen C. Wills <staphen@gmail.com>
This is very similar to the code used when casting heal other, except for how the amount to heal is chosen. Could potentially reuse it there as well with a bit of work.
clang-tidy warns about the unnecessary copy for these params
Could also potentially use std::make_unique if the Action constructor wasn't declared private?
1. Switches to 32-bit based calculation throughout. This is faster and
less error-prone as we only byte-swap once when reading and writing.
2. Removes global state from Diablo-SHA implementation.