fix #H6489 - explosion double damage to ustuck

Report asked why u.ustuck takes double explosion damage, and concocting
a reason uncovered several inconsistencies.  Grabber takes double damage
for reaching into hero's spot, but only when that spot is within the
explosion's radius and only if hero isn't engulfed.  Poly'd hero takes
double damage if holding a monster which is hit by the explosion.

There are still multiple bugs here:  if the hero is grabbing a monster
which gets killed by the explosion, the fact that one was held is
forgotten by the time damage is inflicted upon the hero.  Just a messy
detail that I opted not to get bogged down in.  But much messier is
that grabber might be outside the explosion radius reaching into that
to hold grabbee, in which case no damage is inflicted.  Handling that
for out-of-range monster holding exploded hero shouldn't be very tough,
but handling it for out-of-range hero holding exploded monster could be
hard.  Anyway, it's more headache than I intend to tackle.
This commit is contained in:
PatR
2017-11-23 16:37:20 -08:00
parent 59c357de9a
commit 4dbfb4abeb
2 changed files with 24 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 explode.c $NHDT-Date: 1503355817 2017/08/21 22:50:17 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.50 $ */
/* NetHack 3.6 explode.c $NHDT-Date: 1511483825 2017/11/24 00:37:05 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.53 $ */
/* Copyright (C) 1990 by Ken Arromdee */
/* NetHack may be freely redistributed. See license for details. */
@@ -401,8 +401,18 @@ int expltype;
pline("%s resists the %s!", Monnam(mtmp), str);
mdam = (dam + 1) / 2;
}
if (mtmp == u.ustuck)
/* if grabber is reaching into hero's spot and
hero's spot is within explosion radius, grabber
gets hit by double damage */
if (mtmp == u.ustuck && !u.uswallow
&& !(Upolyd && sticks(youmonst.data))
&& distu(x, y) <= 2)
mdam *= 2;
/* being resistant to opposite type of damage makes
target more vulnerable to current type of damage
(being resistant to current type has already cut
damage in half, so this effectively restores it
to full for targets who resist both types) */
if (resists_cold(mtmp) && adtyp == AD_FIRE)
mdam *= 2;
else if (resists_fire(mtmp) && adtyp == AD_COLD)
@@ -468,6 +478,13 @@ int expltype;
ugolemeffects((int) adtyp, damu);
if (uhurt == 2) {
/* if poly'd hero is grabbing another victim, do double damage */
/* [FIXME: if u.ustuck was killed above, we'll miss it here.] */
if (u.ustuck && !u.uswallow && (Upolyd && sticks(youmonst.data))
&& dist2((int) u.ustuck->mx, (int) u.ustuck->my, x, y) <= 2)
damu *= 2;
/* [FIXME too: hero ought to get same fire-resistant vs cold
* and cold-resistant vs fire double damage as monsters.] */
if (Upolyd)
u.mh -= damu;
else