From 4dbfb4abeb08670719b9d1cdec7257c9de4bf2ad Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 23 Nov 2017 16:37:20 -0800 Subject: [PATCH] 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. --- doc/fixes36.1 | 5 +++++ src/explode.c | 21 +++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/doc/fixes36.1 b/doc/fixes36.1 index af1de2a6c..403940916 100644 --- a/doc/fixes36.1 +++ b/doc/fixes36.1 @@ -473,6 +473,11 @@ make Vlad slightly tougher reduce the amount of gold laying on the floor locked chests and large boxes contain more stuff make shopkeepers bill hero for burying merchandise +monster holding hero takes double damage from an explosion for reaching into + adjacent spot, but it was being inflicted even when hero was swallowed + or beyond the explosion radius +poly'd hero holding monster now takes double damage (if monster is within + explosion radious) instead of inflicting that upon the monster Fixes to Post-3.6.0 Problems that Were Exposed Via git Repository diff --git a/src/explode.c b/src/explode.c index cc6477c4a..8720c48a4 100644 --- a/src/explode.c +++ b/src/explode.c @@ -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