Pets avoid a possible boulder pushing location in Sokoban

This commit is contained in:
Pasi Kallinen
2024-07-06 23:12:19 +03:00
parent a33f1edd24
commit d4ac146c5f
4 changed files with 19 additions and 0 deletions

View File

@@ -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

View File

@@ -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