]> granicus.if.org Git - nethack/commitdiff
Change logic for immobilized displacement, fixing a bug
authorcopperwater <aosdict@gmail.com>
Mon, 28 May 2018 23:36:23 +0000 (19:36 -0400)
committerPasi Kallinen <paxed@alt.org>
Wed, 15 Apr 2020 05:46:47 +0000 (08:46 +0300)
The bug was that you could easily displace peaceful sleeping monsters.
The source of this was that there was no check for sleeping in the
attack() function that checks for immobilization.

As well as adding the sleeping check, this logic is modified so that it
makes more sense: if a monster is immobilized at all (sleeping, frozen,
or mcanmove = 0) it always "doesn't seem to move!" You can't randomly
displace it anyway 1/6 of the time.

Sessile monsters who are otherwise not immobilized don't move 5/6 of the
time, but can be displaced with the other 1/6.

src/uhitm.c

index 8059ce748d56d759e8d29e77acfdd4056673f268..5c9b9a62a5fd3ebdf6494fc37f7a85db3a3ef63a 100644 (file)
@@ -368,8 +368,8 @@ register struct monst *mtmp;
                 You("stop.  %s is in the way!", buf);
                 end_running(TRUE);
                 return TRUE;
-            } else if ((mtmp->mfrozen || (!mtmp->mcanmove)
-                        || (mtmp->data->mmove == 0)) && rn2(6)) {
+            } else if (mtmp->mfrozen || mtmp->msleeping || (!mtmp->mcanmove)
+                       || (mtmp->data->mmove == 0 && rn2(6))) {
                 pline("%s doesn't seem to move!", Monnam(mtmp));
                 end_running(TRUE);
                 return TRUE;