fix github issue #972 - moving while trapped

Reported by elunna:  a monster trapped in a pit or web that was
adjacent to a polymorph trap could enter that trap to change shape.
It would remain flagged as trapped but there's no way to escape
from a polymorph trap so it would be stuck.

Fix supplied by entrez:  when a monster is picking MUSE strategy,
don't allow it choose "enter polymorph trap" if it is currently
trapped.

I entered the changes from the diff manually and added a bunch of
minor formatting bits.

Fixes #972
This commit is contained in:
PatR
2023-02-06 15:50:39 -08:00
parent 1d06fa62a9
commit 5d5445d85b
2 changed files with 31 additions and 29 deletions
+4 -1
View File
@@ -1,4 +1,4 @@
HDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1051 $ $NHDT-Date: 1665130022 2022/10/07 08:07:02 $ DT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1051 $ $NHDT-Date: 1665130022 2022/10/07 08:07:02 $
General Fixes and Modified Features General Fixes and Modified Features
----------------------------------- -----------------------------------
@@ -1107,6 +1107,9 @@ fix a case where punished iron ball yanked hero on top of a monster
slightly randomize amount of items and monsters in the mines slightly randomize amount of items and monsters in the mines
dying in a wall spot (temporary gap or via Passes_walls) shared by two shops dying in a wall spot (temporary gap or via Passes_walls) shared by two shops
could result in "place_object: \"<item>\" [0] off map <0,0>" warnings could result in "place_object: \"<item>\" [0] off map <0,0>" warnings
a monster capable of using a polymorph trap to deliberately change form could
do so when trapped in an adjacent web or pit; if that happened, the
monster remained flagged as 'trapped' and wouldn't be able to move
Fixes to 3.7.0-x Problems that Were Exposed Via git Repository Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
+5 -6
View File
@@ -470,7 +470,7 @@ find_defensive(struct monst* mtmp, boolean tryescape)
} }
} }
if (stuck || immobile) { if (stuck || immobile || mtmp->mtrapped) {
; /* fleeing by stairs or traps is not possible */ ; /* fleeing by stairs or traps is not possible */
} else if (levl[x][y].typ == STAIRS) { } else if (levl[x][y].typ == STAIRS) {
stway = stairway_at(x,y); stway = stairway_at(x,y);
@@ -1436,9 +1436,8 @@ find_offensive(struct monst* mtmp)
#undef nomore #undef nomore
} }
static static int
int mbhitm(struct monst *mtmp, struct obj *otmp)
mbhitm(register struct monst* mtmp, register struct obj* otmp)
{ {
int tmp; int tmp;
boolean reveal_invis = FALSE, hits_you = (mtmp == &gy.youmonst); boolean reveal_invis = FALSE, hits_you = (mtmp == &gy.youmonst);
@@ -1907,7 +1906,7 @@ find_misc(struct monst* mtmp)
if (dist2(x, y, mtmp->mux, mtmp->muy) > 36) if (dist2(x, y, mtmp->mux, mtmp->muy) > 36)
return FALSE; return FALSE;
if (!stuck && !immobile && (mtmp->cham == NON_PM) if (!stuck && !immobile && !mtmp->mtrapped && (mtmp->cham == NON_PM)
&& mons[(pmidx = monsndx(mdat))].difficulty < 6) { && mons[(pmidx = monsndx(mdat))].difficulty < 6) {
boolean ignore_boulders = (verysmall(mdat) || throws_rocks(mdat) boolean ignore_boulders = (verysmall(mdat) || throws_rocks(mdat)
|| passes_walls(mdat)), || passes_walls(mdat)),
@@ -1915,7 +1914,7 @@ find_misc(struct monst* mtmp)
for (xx = x - 1; xx <= x + 1; xx++) for (xx = x - 1; xx <= x + 1; xx++)
for (yy = y - 1; yy <= y + 1; yy++) for (yy = y - 1; yy <= y + 1; yy++)
if (isok(xx, yy) && (xx != u.ux || yy != u.uy) if (isok(xx, yy) && !u_at(xx, yy)
&& (diag_ok || xx == x || yy == y) && (diag_ok || xx == x || yy == y)
&& ((xx == x && yy == y) || !gl.level.monsters[xx][yy])) && ((xx == x && yy == y) || !gl.level.monsters[xx][yy]))
if ((t = t_at(xx, yy)) != 0 if ((t = t_at(xx, yy)) != 0