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

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
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

View 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));

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. */
/* 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)

View 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;

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. */
/* 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;

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 */
/* 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;
}

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. */
/* 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:

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. */
/* 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);

View 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: