From ab0de251cd5d2645c6dfcb34878a4e7ef742326e Mon Sep 17 00:00:00 2001 From: PatR Date: Tue, 27 Jun 2023 08:51:29 -0700 Subject: [PATCH] fix #K3938 - sleeping monster tamed by thrown food Player reported that a cat which was asleep in a treasure zoo would catch and eat thrown food, becoming tamed in the process, without waking up. Temporary sleep was handled (via checking for !mon->mcanmove) but indefinite sleep wasn't. Make a monster hit by taming effect (either magic or thrown food) wake up from indefinite sleep. For temporary sleep, the remaining duration is cut in half. The timeout isn't dropped all the way to 0 because a monster with mon->mfrozen set isn't necessarily asleep. That timeout is shared by timed sleep, timed paralysis, and busy time when donning armor. --- doc/fixes3-7-0.txt | 3 +++ src/dog.c | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 2e83436a0..6f845b803 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1210,6 +1210,9 @@ add a level arrival region to the Gnone King's Wine Cellar variation of the Mines' End level so that hero can't end up in the treature chamber make potion of water become discovered if dipping a carried container into an uncursed one reports that water gets inside or slides right off +a monster which was temporarily asleep wouldn't be affected by taming (either + food or magic), but one that was indefinitely asleep would be; when + tamable via food, it even caught and ate the food without waking up Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/src/dog.c b/src/dog.c index 5773dcfa6..0794be3d8 100644 --- a/src/dog.c +++ b/src/dog.c @@ -1049,13 +1049,22 @@ dogfood(struct monst *mon, struct obj *obj) } /* - * With the separate mextra structure added in 3.6.x this always - * operates on the original mtmp. It now returns TRUE if the taming - * succeeded. + * tamedog() used to return the monster, which might have changed address + * if a new one was created in order to allocate the edog extension. + * With the separate mextra structure added in 3.6.x it always operates + * on the original mtmp. It now returns TRUE if the taming succeeded. */ boolean tamedog(struct monst *mtmp, struct obj *obj) { + /* reduce timed sleep or paralysis, leaving mtmp->mcanmove as-is + (note: if mtmp is donning armor, this will reduce its busy time) */ + if (mtmp->mfrozen) + mtmp->mfrozen = (mtmp->mfrozen + 1) / 2; + /* end indefinite sleep; using distance==1 limits the waking to mtmp */ + if (mtmp->msleeping) + wake_nearto(mtmp->mx, mtmp->my, 1); /* [different from wakeup()] */ + /* The Wiz, Medusa and the quest nemeses aren't even made peaceful. */ if (mtmp->iswiz || mtmp->data == &mons[PM_MEDUSA] || (mtmp->data->mflags3 & M3_WANTSARTI))