From: PatR Date: Mon, 12 Nov 2018 00:04:45 +0000 (-0800) Subject: prayer vs blocked by boulder X-Git-Tag: NetHack-3.6.2_Released~168^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a22175cd99fda232786835b88f9589f11f143c8f;p=nethack prayer vs blocked by boulder Salvaged from an old, unfinished patch. When checking whether the hero is trapped by walls and solid rock, adjacent boulders are evaluated on whether they can be pushed out of the way. Extend that evaluation: (1) two boulders on a spot are pushable if there is a pool beyond that spot, and (2) boulders can't be pushed diagonally in Sokoban. --- diff --git a/src/pray.c b/src/pray.c index 7ad09455a..5569c33f0 100644 --- a/src/pray.c +++ b/src/pray.c @@ -2181,6 +2181,7 @@ blocked_boulder(dx, dy) int dx, dy; { register struct obj *otmp; + int nx, ny; long count = 0L; for (otmp = level.objects[u.ux + dx][u.uy + dy]; otmp; @@ -2189,6 +2190,7 @@ int dx, dy; count += otmp->quan; } + nx = u.ux + 2 * dx, ny = u.uy + 2 * dy; /* next spot beyond boulder(s) */ switch (count) { case 0: /* no boulders--not blocked */ @@ -2196,17 +2198,24 @@ int dx, dy; case 1: /* possibly blocked depending on if it's pushable */ break; + case 2: + /* this is only approximate since multiple boulders might sink */ + if (is_pool_or_lava(nx, ny)) /* does its own isok() check */ + break; /* still need Sokoban check below */ + /*FALLTHRU*/ default: /* more than one boulder--blocked after they push the top one; don't force them to push it first to find out */ return TRUE; } - if (!isok(u.ux + 2 * dx, u.uy + 2 * dy)) + if (dx && dy && Sokoban) /* can't push boulder diagonally in Sokoban */ + return TRUE; + if (!isok(nx, ny)) return TRUE; - if (IS_ROCK(levl[u.ux + 2 * dx][u.uy + 2 * dy].typ)) + if (IS_ROCK(levl[nx][ny].typ)) return TRUE; - if (sobj_at(BOULDER, u.ux + 2 * dx, u.uy + 2 * dy)) + if (sobj_at(BOULDER, nx, ny)) return TRUE; return FALSE;