Pets avoid a location hero just kicked

If hero kicks a location, pets and peacefuls will avoid moving
into that location for that turn.
This commit is contained in:
Pasi Kallinen
2024-04-11 18:05:12 +03:00
parent 62b78ba037
commit f1c77aa2fd
9 changed files with 37 additions and 1 deletions

View File

@@ -1215,6 +1215,21 @@ maybe_spin_web(struct monst *mtmp)
}
}
/* monster avoids a location nx, ny, if hero kicked that location */
boolean
m_avoid_kicked_loc(struct monst *mtmp, coordxy nx, coordxy ny)
{
if ((mtmp->mpeaceful || mtmp->mtame)
&& mtmp->mcansee
&& !mtmp->mconf && !mtmp->mstun
&& !Conflict
&& isok(gk.kickedloc.x, gk.kickedloc.y)
&& nx == gk.kickedloc.x && ny == gk.kickedloc.y
&& next2u(nx, ny))
return TRUE;
return FALSE;
}
/* max distmin() distance for monster to look for items */
#define SQSRCHRADIUS 5
@@ -1831,6 +1846,9 @@ m_move(struct monst *mtmp, int after)
nx = poss[i].x;
ny = poss[i].y;
if (m_avoid_kicked_loc(mtmp, nx, ny))
continue;
if (MON_AT(nx, ny) && (info[i] & ALLOW_MDISP)
&& !(info[i] & ALLOW_M) && !better_with_displacing)
continue;