From d4ac146c5f8bf28d5553300e08e5addf13a96405 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Sat, 6 Jul 2024 23:12:19 +0300 Subject: [PATCH] Pets avoid a possible boulder pushing location in Sokoban --- doc/fixes3-7-0.txt | 1 + include/extern.h | 1 + src/dogmove.c | 2 ++ src/monmove.c | 15 +++++++++++++++ 4 files changed, 19 insertions(+) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index ec2ef2923..eef59eac7 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1401,6 +1401,7 @@ gold thrown or kicked at a sleeping monster with the 'greedy' attribute gets neglected to report that target monster was awakened in the process hero movement affects the water bubble movement direction pets and peacefuls avoid a location hero just kicked +pets avoid a possible boulder pushing location in sokoban shopkeepers bill you for using their bear trap or land mine when engraving with a stack of eligible weapons, split one off the stack and dull it rather than dull the whole stack diff --git a/include/extern.h b/include/extern.h index 58774113f..8476b017b 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1850,6 +1850,7 @@ extern void m_break_boulder(struct monst *, coordxy, coordxy) NONNULLARG1; extern int dochug(struct monst *) NONNULLARG1; extern boolean m_digweapon_check(struct monst *, coordxy, coordxy) NONNULLARG1; extern boolean m_avoid_kicked_loc(struct monst *, coordxy, coordxy) NONNULLARG1; +extern boolean m_avoid_soko_push_loc(struct monst *, coordxy, coordxy) NONNULLARG1; extern int m_move(struct monst *, int) NONNULLARG1; extern int m_move_aggress(struct monst *, coordxy, coordxy) NONNULLARG1; extern void dissolve_bars(coordxy, coordxy); diff --git a/src/dogmove.c b/src/dogmove.c index 567ab9808..90171c6f8 100644 --- a/src/dogmove.c +++ b/src/dogmove.c @@ -1148,6 +1148,8 @@ dog_move( /* avoid a location hero just kicked */ if (m_avoid_kicked_loc(mtmp, nx, ny)) continue; + if (m_avoid_soko_push_loc(mtmp, nx, ny)) + continue; { /* Dog avoids harmful traps, but perhaps it has to pass one diff --git a/src/monmove.c b/src/monmove.c index c461fb46e..18d573f4a 100644 --- a/src/monmove.c +++ b/src/monmove.c @@ -1240,6 +1240,21 @@ m_avoid_kicked_loc(struct monst *mtmp, coordxy nx, coordxy ny) return FALSE; } +/* monster avoids a location nx, ny, if we're in sokoban, and + there's a boulder between the location and hero */ +boolean +m_avoid_soko_push_loc(struct monst *mtmp, coordxy nx, coordxy ny) +{ + if (Sokoban + && (mtmp->mpeaceful || mtmp->mtame) + && !mtmp->mconf && !mtmp->mstun + && !Conflict + && (dist2(nx, ny, u.ux, u.uy) == 4) + && sobj_at(BOULDER, nx + sgn(u.ux - nx), ny + sgn(u.uy - ny))) + return TRUE; + return FALSE; +} + /* max distmin() distance for monster to look for items */ #define SQSRCHRADIUS 5