DRY overflow-aware short addition

This commit is contained in:
2025-05-08 17:51:23 -05:00
parent 98a7109060
commit 01608064f2
3 changed files with 9 additions and 6 deletions

View File

@@ -1483,9 +1483,7 @@ short damage_monst(cCreature& victim, short who_hit, short how_much, eDamageType
// Absorb damage?
if((dam_type == eDamageType::FIRE || dam_type == eDamageType::MAGIC || dam_type == eDamageType::COLD)
&& victim.abil[eMonstAbil::ABSORB_SPELLS].active && get_ran(1,1,1000) <= victim.abil[eMonstAbil::ABSORB_SPELLS].special.extra1) {
if(32767 - victim.health > how_much)
victim.health = 32767;
else victim.health += how_much;
add_check_overflow(victim.health, how_much);
ASB(" Magic absorbed.");
return false;
}