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.
This commit is contained in:
PatR
2023-06-27 08:51:29 -07:00
parent e1bae750de
commit ab0de251cd
2 changed files with 15 additions and 3 deletions

View File

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

View File

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