]> granicus.if.org Git - nethack/commitdiff
terminate eating if pet falls asleep or becomes paralyzed (trunk only)
authornethack.rankin <nethack.rankin>
Tue, 6 Dec 2005 04:48:27 +0000 (04:48 +0000)
committernethack.rankin <nethack.rankin>
Tue, 6 Dec 2005 04:48:27 +0000 (04:48 +0000)
     From a bug report:  sleeping pet could
be shown as "eating" by stethoscope.  Fixing that is a one-liner since all
(or should be all; sleeping gas trap wasn't utilizing it) cases of monster
being forced into sleep go through one routine.  That wasn't the situation
for paralysis, but now it is.  Paralyzed pets won't continue eating either.

doc/fixes35.0
include/extern.h
src/apply.c
src/mhitm.c
src/mhitu.c
src/muse.c
src/potion.c
src/trap.c
src/uhitm.c

index 4716ff969046f60b046e1df20da95a92415c72ee..c8ffe572bce5dfba5b4a2b91815e879f3316eaac 100644 (file)
@@ -102,6 +102,7 @@ can't wish for a trapped box/chest/tin by specifying "poisoned"
 grammar bit if killed by stealing a cockatrice corpse from a monster
 being petrified by swallowing a cockatrice violates foodless conduct
 devouring Medusa whole is fatal
+eating pet won't continue eating after becoming paralyzed or falling asleep
 
 
 Platform- and/or Interface-Specific Fixes
index cbca118d0db014989a18d706419dece23ca9c5a7..ae343d82d047b1599a46d80f209a50215c2af642 100644 (file)
@@ -1002,6 +1002,7 @@ E int FDECL(mattackm, (struct monst *,struct monst *));
 #ifdef BARGETHROUGH
 E int FDECL(mdisplacem, (struct monst *,struct monst *,BOOLEAN_P));
 #endif
+E void FDECL(paralyze_monst, (struct monst *,int));
 E int FDECL(sleep_monst, (struct monst *,int,int));
 E void FDECL(slept_monst, (struct monst *));
 E long FDECL(attk_protection, (int));
index 907037765d36f894814a200c2a15956b54f88284..ceef3750c9c585a894ac4f726da934c785ec5a50 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)apply.c    3.5     2005/09/20      */
+/*     SCCS Id: @(#)apply.c    3.5     2005/12/05      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -786,10 +786,7 @@ struct obj *obj;
                    pline("%s is frozen by its reflection.", Monnam(mtmp));
                else
                    You_hear("%s stop moving.", something);
-               mtmp->mcanmove = 0;
-               if ( (int) mtmp->mfrozen + tmp > 127)
-                       mtmp->mfrozen = 127;
-               else mtmp->mfrozen += tmp;
+               paralyze_monst(mtmp, (int)mtmp->mfrozen + tmp);
        } else if(!mtmp->mcan && !mtmp->minvis &&
                                        mtmp->data == &mons[PM_UMBER_HULK]) {
                if (vis)
index e70325a4986471d1f6eaad6e0aa12e70e9b3ce01..f28f011f83f27a8c067b305174d101d72a01e414 100644 (file)
@@ -987,9 +987,7 @@ mdamagem(magr, mdef, mattk)
                        Strcpy(buf, Monnam(mdef));
                        pline("%s is frozen by %s.", buf, mon_nam(magr));
                    }
-                   mdef->mcanmove = 0;
-                   mdef->mfrozen = rnd(10);
-                   mdef->mstrategy &= ~STRAT_WAITFORU;
+                   paralyze_monst(mdef, rnd(10));
                }
                break;
            case AD_SLOW:
@@ -1258,6 +1256,19 @@ mdamagem(magr, mdef, mattk)
        return (res == MM_AGR_DIED) ? MM_AGR_DIED : MM_HIT;
 }
 
+void
+paralyze_monst(mon, amt)
+struct monst *mon;
+int amt;
+{
+       if (amt > 127) amt = 127;
+
+       mon->mcanmove = 0;
+       mon->mfrozen = amt;
+       mon->meating = 0;       /* terminate any meal-in-progress */
+       mon->mstrategy &= ~STRAT_WAITFORU;
+}
+
 /* `mon' is hit by a sleep attack; return 1 if it's affected, 0 otherwise */
 int
 sleep_monst(mon, amt, how)
@@ -1268,6 +1279,7 @@ int amt, how;
                (how >= 0 && resist(mon, (char)how, 0, NOTELL))) {
            shieldeff(mon->mx, mon->my);
        } else if (mon->mcanmove) {
+           mon->meating = 0;   /* terminate any meal-in-progress */
            amt += (int) mon->mfrozen;
            if (amt > 0) {      /* sleep for N turns */
                mon->mcanmove = 0;
@@ -1392,16 +1404,14 @@ int mdead;
                        if(canseemon(magr))
                            pline("%s is frozen by %s gaze!",
                                  buf, s_suffix(mon_nam(mdef)));
-                       magr->mcanmove = 0;
-                       magr->mfrozen = tmp;
+                       paralyze_monst(magr, tmp);
                        return (mdead|mhit);
                    }
                } else { /* gelatinous cube */
                    Strcpy(buf, Monnam(magr));
                    if(canseemon(magr))
                        pline("%s is frozen by %s.", buf, mon_nam(mdef));
-                   magr->mcanmove = 0;
-                   magr->mfrozen = tmp;
+                   paralyze_monst(magr, tmp);
                    return (mdead|mhit);
                }
                return 1;
index 41aa0c1c137b7b966b7633d245ad93ff18e06b16..bd34b6161d9728036a220bfee6a01fceb6952bc8 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)mhitu.c    3.5     2005/09/27      */
+/*     SCCS Id: @(#)mhitu.c    3.5     2005/12/05      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -2493,15 +2493,13 @@ register struct attack *mattk;
                                            "Your gaze is reflected by %s %s."))
                                return 1;
                            pline("%s is frozen by your gaze!", Monnam(mtmp));
-                           mtmp->mcanmove = 0;
-                           mtmp->mfrozen = tmp;
+                           paralyze_monst(mtmp, tmp);
                            return 3;
                        }
                    }
                } else { /* gelatinous cube */
                    pline("%s is frozen by you.", Monnam(mtmp));
-                   mtmp->mcanmove = 0;
-                   mtmp->mfrozen = tmp;
+                   paralyze_monst(mtmp, tmp);
                    return 3;
                }
                return 1;
index 30bada89de543cccfe24314790bee939855393ea..29677214a22301398bc1b607c25b78f1e52ec4a7 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)muse.c     3.5     2004/06/12      */
+/*     SCCS Id: @(#)muse.c     3.5     2005/12/05      */
 /*     Copyright (C) 1990 by Ken Arromdee                         */
 /* NetHack may be freely redistributed.  See license for details.  */
 
@@ -88,8 +88,7 @@ struct obj *obj;
                            pline("%s is frightened to death, and unable to move.",
                                    Monnam(mon));
                        }
-                       mon->mcanmove = 0;
-                       mon->mfrozen = 3;
+                       paralyze_monst(mon, 3);
                    }
                    return 2;
                }
index 7e4b3eae4d025e4c6429a63410477b2e6f55f5ae..ee5fbfe8b66d7c18ef2c8fecfcea3142399b5477 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)potion.c   3.5     2005/06/21      */
+/*     SCCS Id: @(#)potion.c   3.5     2005/12/05      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1219,11 +1219,10 @@ boolean your_fault;
                break;
        case POT_PARALYSIS:
                if (mon->mcanmove) {
-                       mon->mcanmove = 0;
                        /* really should be rnd(5) for consistency with players
                         * breathing potions, but...
                         */
-                       mon->mfrozen = rnd(25);
+                       paralyze_monst(mon, rnd(25));
                }
                break;
        case POT_SPEED:
index 213e3914684717787ca405d90834a4c06a1af342..b3c530a23f7232d62a654e7c2aa2f1ccc9ebe970 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)trap.c     3.5     2005/11/01      */
+/*     SCCS Id: @(#)trap.c     3.5     2005/12/05      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1272,9 +1272,8 @@ struct obj *otmp;
        case SLP_GAS_TRAP:
            if (!resists_sleep(steed) && !breathless(steed->data) &&
                    !steed->msleeping && steed->mcanmove) {
-               steed->mcanmove = 0;
-               steed->mfrozen = rnd(25);
-               if (in_sight)
+               if (sleep_monst(steed, rnd(25), -1))
+                   /* no in_sight check here; you can feel it even if blind */
                    pline("%s suddenly falls asleep!", Monnam(steed));
            }
            steedhit = TRUE;
@@ -1920,9 +1919,7 @@ register struct monst *mtmp;
                case SLP_GAS_TRAP:
                    if (!resists_sleep(mtmp) && !breathless(mptr) &&
                                !mtmp->msleeping && mtmp->mcanmove) {
-                           mtmp->mcanmove = 0;
-                           mtmp->mfrozen = rnd(25);
-                           if (in_sight) {
+                           if (sleep_monst(mtmp, rnd(25), -1) && in_sight) {
                                pline("%s suddenly falls asleep!",
                                      Monnam(mtmp));
                                seetrap(trap);
index 7767f8114a36e80219913f436856c94420e40cc4..db7262598e1808a22290f4886a11330cc21d60f3 100644 (file)
@@ -1629,8 +1629,7 @@ register struct attack *mattk;
            case AD_PLYS:
                if (!negated && mdef->mcanmove && !rn2(3) && tmp < mdef->mhp) {
                    if (!Blind) pline("%s is frozen by you!", Monnam(mdef));
-                   mdef->mcanmove = 0;
-                   mdef->mfrozen = rnd(10);
+                   paralyze_monst(mdef, rnd(10));
                }
                break;
            case AD_SLEE: