From: PatR Date: Mon, 9 Nov 2020 00:07:42 +0000 (-0800) Subject: fix github issue #408 - stuck to distant mimic X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ea0ef81ecdda7a357823678aa5411f41068bf6f6;p=nethack fix github issue #408 - stuck to distant mimic Attacking a concealed mimic at range by applying a polearm could make the hero be stuck to that mimic in addition to bringing it out of hiding. Only do that when adjacent. This also adds a new sanity check when setting u.ustuck. It may get triggered by other sticking activity since only attacking has been tested. The check must be explicitly enabled by setting the wizard mode 'sanity_check' option. Fixes #408 --- diff --git a/doc/fixes37.0 b/doc/fixes37.0 index 455db9ee2..9774892e7 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -1,4 +1,4 @@ -NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.348 $ $NHDT-Date: 1604620981 2020/11/06 00:03:01 $ +NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.349 $ $NHDT-Date: 1604880453 2020/11/09 00:07:33 $ General Fixes and Modified Features ----------------------------------- @@ -288,6 +288,8 @@ hero poly'd into rust monster could implicitly eat bars when adjacent by can explicitly eat them via 'e' after moving onto their spot monster hiding under an egg that hatched was kept hidden restful sleep regenerates hit points +attacking non-adjacent concealed mimic by applying a polearm would make the + hero be stuck to that mimic Fixes to 3.7.0-x Problems that Were Exposed Via git Repository diff --git a/src/mon.c b/src/mon.c index d6e9e24a0..44097e221 100644 --- a/src/mon.c +++ b/src/mon.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 mon.c $NHDT-Date: 1600933441 2020/09/24 07:44:01 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.348 $ */ +/* NetHack 3.7 mon.c $NHDT-Date: 1604880454 2020/11/09 00:07:34 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.351 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2575,6 +2575,12 @@ void set_ustuck(mtmp) struct monst *mtmp; { + if (iflags.sanity_check || iflags.debug_fuzzer) { + if (mtmp && distu(mtmp->mx, mtmp->my) > 2) + impossible("Sticking to %s at distu %d?", + mon_nam(mtmp), distu(mtmp->mx, mtmp->my)); + } + g.context.botl = 1; u.ustuck = mtmp; } diff --git a/src/uhitm.c b/src/uhitm.c index 53a82d7d3..7ad48d82e 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 uhitm.c $NHDT-Date: 1596498221 2020/08/03 23:43:41 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.240 $ */ +/* NetHack 3.7 uhitm.c $NHDT-Date: 1604880456 2020/11/09 00:07:36 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.242 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -141,10 +141,10 @@ struct obj *wep; /* uwep for attack(), null for kick_monster() */ /* if it was an invisible mimic, treat it as if we stumbled * onto a visible mimic */ - if (M_AP_TYPE(mtmp) && !Protection_from_shape_changers - /* applied pole-arm attack is too far to get stuck */ - && distu(mtmp->mx, mtmp->my) <= 2) { - if (!u.ustuck && !mtmp->mflee && dmgtype(mtmp->data, AD_STCK)) + if (M_AP_TYPE(mtmp) && !Protection_from_shape_changers) { + if (!u.ustuck && !mtmp->mflee && dmgtype(mtmp->data, AD_STCK) + /* applied pole-arm attack is too far to get stuck */ + && distu(mtmp->mx, mtmp->my) <= 2) set_ustuck(mtmp); } /* #H7329 - if hero is on engraved "Elbereth", this will end up @@ -2007,7 +2007,7 @@ int specialdmg; /* blessed and/or silver bonus against various things */ break; } case AD_STCK: - if (!negated && !sticks(pd)) + if (!negated && !sticks(pd) && distu(mdef->mx, mdef->my) <= 2) u.ustuck = mdef; /* it's now stuck to you */ break; case AD_WRAP: @@ -3133,7 +3133,9 @@ struct monst *mtmp; { const char *fmt = "Wait! That's %s!", *generic = "a monster", *what = 0; - if (!u.ustuck && !mtmp->mflee && dmgtype(mtmp->data, AD_STCK)) + if (!u.ustuck && !mtmp->mflee && dmgtype(mtmp->data, AD_STCK) + /* must be adjacent; attack via polearm could be from farther away */ + && distu(mtmp->mx, mtmp->my) <= 2) set_ustuck(mtmp); if (Blind) {