fix github issue #1230 - sleeping orc catches gold

Issue reported by Ryton:  a sleeping orc caught a thrown gold piece.
Throwing one at some other sleeping monster woke it up.

That is actually intentional.  Sleeping monsters with the 'greedy'
attribute will wake up without becoming angry and catch thrown or
kicked gold that is aimed at hit them.  The fix here is to augment
the catch message to say so.  Non-greedy monsters wake up and treat
it as an attack, but the gold always misses.

Both cases only happen for monsters who are asleep for an indefinite
period of time.  Any monster that is asleep (or paralyzed, or busy
putting on armor) for N turns effectively doesn't notice.  If it can
be seen, the gold "harmlessly hits" (if it can't be seen, the gold
misses), and the target continues doing--or not doing--whatever it
is doing.  That's suboptimal; another case where lumping multiple
can't-move situations into a single monst->mfrozen countdown timer
causes timed sleep to be indistinguishable from timed paralysis.

Closes #1230
This commit is contained in:
PatR
2024-04-06 18:39:11 -07:00
parent 7ecc778173
commit 2b6b056f0e
2 changed files with 11 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1407 $ $NHDT-Date: 1711484961 2024/03/26 20:29:21 $
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1416 $ $NHDT-Date: 1712453344 2024/04/07 01:29:04 $
General Fixes and Modified Features
-----------------------------------
@@ -1393,6 +1393,9 @@ Excalibur is much harder to get if hero is not a knight
pets considered any noise made by hero made as whistling
silent monsters in stinking clouds don't cough
unblind telepathy range depends on number of telepathy granting items worn
gold thrown or kicked at a sleeping monster with the 'greedy' attribute gets
caught instead of being treated as an attack but the catch message
neglected to report that target monster was awakened in the process
Fixes to 3.7.0-x General Problems Exposed Via git Repository

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 dokick.c $NHDT-Date: 1625963851 2021/07/11 00:37:31 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.167 $ */
/* NetHack 3.7 dokick.c $NHDT-Date: 1712453347 2024/04/07 01:29:07 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.223 $ */
/* Copyright (c) Izchak Miller, Mike Stephenson, Steve Linhart, 1989. */
/* NetHack may be freely redistributed. See license for details. */
@@ -306,15 +306,19 @@ ghitm(struct monst *mtmp, struct obj *gold)
msg_given = TRUE;
}
} else {
unsigned was_sleeping = mtmp->msleeping;
long umoney, value = gold->quan * objects[gold->otyp].oc_cost;
mtmp->msleeping = 0;
mtmp->msleeping = 0; /* end indeterminate sleep (won't get here
* for temporary--counted--sleep since that
* uses mfrozen and mfrozen implies !mcanmove) */
finish_meating(mtmp);
if (!mtmp->isgd && !rn2(4)) /* not always pleasing */
setmangry(mtmp, TRUE);
/* greedy monsters catch gold */
if (cansee(mtmp->mx, mtmp->my))
pline("%s catches the gold.", Monnam(mtmp));
pline("%s %scatches the gold.", Monnam(mtmp),
was_sleeping ? "awakens and " : "");
(void) mpickobj(mtmp, gold);
gold = (struct obj *) 0; /* obj has been freed */
if (mtmp->isshk) {