terminate eating if pet falls asleep or becomes paralyzed (trunk only)

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.
This commit is contained in:
nethack.rankin
2005-12-06 04:48:27 +00:00
parent c394330208
commit 6a40b203ed
9 changed files with 33 additions and 32 deletions
+1
View 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 grammar bit if killed by stealing a cockatrice corpse from a monster
being petrified by swallowing a cockatrice violates foodless conduct being petrified by swallowing a cockatrice violates foodless conduct
devouring Medusa whole is fatal devouring Medusa whole is fatal
eating pet won't continue eating after becoming paralyzed or falling asleep
Platform- and/or Interface-Specific Fixes Platform- and/or Interface-Specific Fixes
+1
View File
@@ -1002,6 +1002,7 @@ E int FDECL(mattackm, (struct monst *,struct monst *));
#ifdef BARGETHROUGH #ifdef BARGETHROUGH
E int FDECL(mdisplacem, (struct monst *,struct monst *,BOOLEAN_P)); E int FDECL(mdisplacem, (struct monst *,struct monst *,BOOLEAN_P));
#endif #endif
E void FDECL(paralyze_monst, (struct monst *,int));
E int FDECL(sleep_monst, (struct monst *,int,int)); E int FDECL(sleep_monst, (struct monst *,int,int));
E void FDECL(slept_monst, (struct monst *)); E void FDECL(slept_monst, (struct monst *));
E long FDECL(attk_protection, (int)); E long FDECL(attk_protection, (int));
+2 -5
View 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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* 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)); pline("%s is frozen by its reflection.", Monnam(mtmp));
else else
You_hear("%s stop moving.", something); You_hear("%s stop moving.", something);
mtmp->mcanmove = 0; paralyze_monst(mtmp, (int)mtmp->mfrozen + tmp);
if ( (int) mtmp->mfrozen + tmp > 127)
mtmp->mfrozen = 127;
else mtmp->mfrozen += tmp;
} else if(!mtmp->mcan && !mtmp->minvis && } else if(!mtmp->mcan && !mtmp->minvis &&
mtmp->data == &mons[PM_UMBER_HULK]) { mtmp->data == &mons[PM_UMBER_HULK]) {
if (vis) if (vis)
+17 -7
View File
@@ -987,9 +987,7 @@ mdamagem(magr, mdef, mattk)
Strcpy(buf, Monnam(mdef)); Strcpy(buf, Monnam(mdef));
pline("%s is frozen by %s.", buf, mon_nam(magr)); pline("%s is frozen by %s.", buf, mon_nam(magr));
} }
mdef->mcanmove = 0; paralyze_monst(mdef, rnd(10));
mdef->mfrozen = rnd(10);
mdef->mstrategy &= ~STRAT_WAITFORU;
} }
break; break;
case AD_SLOW: case AD_SLOW:
@@ -1258,6 +1256,19 @@ mdamagem(magr, mdef, mattk)
return (res == MM_AGR_DIED) ? MM_AGR_DIED : MM_HIT; 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 */ /* `mon' is hit by a sleep attack; return 1 if it's affected, 0 otherwise */
int int
sleep_monst(mon, amt, how) sleep_monst(mon, amt, how)
@@ -1268,6 +1279,7 @@ int amt, how;
(how >= 0 && resist(mon, (char)how, 0, NOTELL))) { (how >= 0 && resist(mon, (char)how, 0, NOTELL))) {
shieldeff(mon->mx, mon->my); shieldeff(mon->mx, mon->my);
} else if (mon->mcanmove) { } else if (mon->mcanmove) {
mon->meating = 0; /* terminate any meal-in-progress */
amt += (int) mon->mfrozen; amt += (int) mon->mfrozen;
if (amt > 0) { /* sleep for N turns */ if (amt > 0) { /* sleep for N turns */
mon->mcanmove = 0; mon->mcanmove = 0;
@@ -1392,16 +1404,14 @@ int mdead;
if(canseemon(magr)) if(canseemon(magr))
pline("%s is frozen by %s gaze!", pline("%s is frozen by %s gaze!",
buf, s_suffix(mon_nam(mdef))); buf, s_suffix(mon_nam(mdef)));
magr->mcanmove = 0; paralyze_monst(magr, tmp);
magr->mfrozen = tmp;
return (mdead|mhit); return (mdead|mhit);
} }
} else { /* gelatinous cube */ } else { /* gelatinous cube */
Strcpy(buf, Monnam(magr)); Strcpy(buf, Monnam(magr));
if(canseemon(magr)) if(canseemon(magr))
pline("%s is frozen by %s.", buf, mon_nam(mdef)); pline("%s is frozen by %s.", buf, mon_nam(mdef));
magr->mcanmove = 0; paralyze_monst(magr, tmp);
magr->mfrozen = tmp;
return (mdead|mhit); return (mdead|mhit);
} }
return 1; return 1;
+3 -5
View 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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -2493,15 +2493,13 @@ register struct attack *mattk;
"Your gaze is reflected by %s %s.")) "Your gaze is reflected by %s %s."))
return 1; return 1;
pline("%s is frozen by your gaze!", Monnam(mtmp)); pline("%s is frozen by your gaze!", Monnam(mtmp));
mtmp->mcanmove = 0; paralyze_monst(mtmp, tmp);
mtmp->mfrozen = tmp;
return 3; return 3;
} }
} }
} else { /* gelatinous cube */ } else { /* gelatinous cube */
pline("%s is frozen by you.", Monnam(mtmp)); pline("%s is frozen by you.", Monnam(mtmp));
mtmp->mcanmove = 0; paralyze_monst(mtmp, tmp);
mtmp->mfrozen = tmp;
return 3; return 3;
} }
return 1; return 1;
+2 -3
View 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 */ /* Copyright (C) 1990 by Ken Arromdee */
/* NetHack may be freely redistributed. See license for details. */ /* 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.", pline("%s is frightened to death, and unable to move.",
Monnam(mon)); Monnam(mon));
} }
mon->mcanmove = 0; paralyze_monst(mon, 3);
mon->mfrozen = 3;
} }
return 2; return 2;
} }
+2 -3
View 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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -1219,11 +1219,10 @@ boolean your_fault;
break; break;
case POT_PARALYSIS: case POT_PARALYSIS:
if (mon->mcanmove) { if (mon->mcanmove) {
mon->mcanmove = 0;
/* really should be rnd(5) for consistency with players /* really should be rnd(5) for consistency with players
* breathing potions, but... * breathing potions, but...
*/ */
mon->mfrozen = rnd(25); paralyze_monst(mon, rnd(25));
} }
break; break;
case POT_SPEED: case POT_SPEED:
+4 -7
View 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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -1272,9 +1272,8 @@ struct obj *otmp;
case SLP_GAS_TRAP: case SLP_GAS_TRAP:
if (!resists_sleep(steed) && !breathless(steed->data) && if (!resists_sleep(steed) && !breathless(steed->data) &&
!steed->msleeping && steed->mcanmove) { !steed->msleeping && steed->mcanmove) {
steed->mcanmove = 0; if (sleep_monst(steed, rnd(25), -1))
steed->mfrozen = rnd(25); /* no in_sight check here; you can feel it even if blind */
if (in_sight)
pline("%s suddenly falls asleep!", Monnam(steed)); pline("%s suddenly falls asleep!", Monnam(steed));
} }
steedhit = TRUE; steedhit = TRUE;
@@ -1920,9 +1919,7 @@ register struct monst *mtmp;
case SLP_GAS_TRAP: case SLP_GAS_TRAP:
if (!resists_sleep(mtmp) && !breathless(mptr) && if (!resists_sleep(mtmp) && !breathless(mptr) &&
!mtmp->msleeping && mtmp->mcanmove) { !mtmp->msleeping && mtmp->mcanmove) {
mtmp->mcanmove = 0; if (sleep_monst(mtmp, rnd(25), -1) && in_sight) {
mtmp->mfrozen = rnd(25);
if (in_sight) {
pline("%s suddenly falls asleep!", pline("%s suddenly falls asleep!",
Monnam(mtmp)); Monnam(mtmp));
seetrap(trap); seetrap(trap);
+1 -2
View File
@@ -1629,8 +1629,7 @@ register struct attack *mattk;
case AD_PLYS: case AD_PLYS:
if (!negated && mdef->mcanmove && !rn2(3) && tmp < mdef->mhp) { if (!negated && mdef->mcanmove && !rn2(3) && tmp < mdef->mhp) {
if (!Blind) pline("%s is frozen by you!", Monnam(mdef)); if (!Blind) pline("%s is frozen by you!", Monnam(mdef));
mdef->mcanmove = 0; paralyze_monst(mdef, rnd(10));
mdef->mfrozen = rnd(10);
} }
break; break;
case AD_SLEE: case AD_SLEE: