Monsters try to escape from boulder forts

If a monster cannot move, for example because it's being
blocked off by boulders or walls, it will try to escape by some
method - such as a wand or scroll of teleportation.
This commit is contained in:
Pasi Kallinen
2022-08-20 21:49:55 +03:00
parent 54bff58598
commit b0f3371147
4 changed files with 21 additions and 14 deletions
+1
View File
@@ -1012,6 +1012,7 @@ if a pet gelatinous cube eats a container, treat it the same as when a hostile
when breaking a wand of sleep hits the hero with the explosion, don't describe when breaking a wand of sleep hits the hero with the explosion, don't describe
that as "the sleep ray hits you" that as "the sleep ray hits you"
expose fuz tester to wizard-mode as #fuzzer extended command expose fuz tester to wizard-mode as #fuzzer extended command
monsters which cannot move due to boulders or walls try to escape
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
+1 -1
View File
@@ -1766,7 +1766,7 @@ extern boolean hits_bars(struct obj **, coordxy, coordxy, coordxy, coordxy, int,
/* ### muse.c ### */ /* ### muse.c ### */
extern boolean find_defensive(struct monst *); extern boolean find_defensive(struct monst *, boolean);
extern int use_defensive(struct monst *); extern int use_defensive(struct monst *);
extern int rnd_defensive_item(struct monst *); extern int rnd_defensive_item(struct monst *);
extern boolean find_offensive(struct monst *); extern boolean find_offensive(struct monst *);
+5 -2
View File
@@ -645,7 +645,7 @@ dochug(register struct monst* mtmp)
distfleeck(mtmp, &inrange, &nearby, &scared); distfleeck(mtmp, &inrange, &nearby, &scared);
/* search for and potentially use defensive or miscellaneous items. */ /* search for and potentially use defensive or miscellaneous items. */
if (find_defensive(mtmp)) { if (find_defensive(mtmp, FALSE)) {
if (use_defensive(mtmp) != 0) if (use_defensive(mtmp) != 0)
return 1; return 1;
} else if (find_misc(mtmp)) { } else if (find_misc(mtmp)) {
@@ -1391,8 +1391,11 @@ m_move(register struct monst* mtmp, register int after)
coord poss[9]; coord poss[9];
cnt = mfndpos(mtmp, poss, info, flag); cnt = mfndpos(mtmp, poss, info, flag);
if (cnt == 0) if (cnt == 0) {
if (find_defensive(mtmp, TRUE))
(void) use_defensive(mtmp);
return MMOVE_NOMOVES; return MMOVE_NOMOVES;
}
chcnt = 0; chcnt = 0;
jcnt = min(MTSZ, cnt - 1); jcnt = min(MTSZ, cnt - 1);
chi = -1; chi = -1;
+14 -11
View File
@@ -350,7 +350,7 @@ m_sees_sleepy_soldier(struct monst *mtmp)
/* Select a defensive item/action for a monster. Returns TRUE iff one is /* Select a defensive item/action for a monster. Returns TRUE iff one is
found. */ found. */
boolean boolean
find_defensive(struct monst* mtmp) find_defensive(struct monst* mtmp, boolean tryescape)
{ {
struct obj *obj; struct obj *obj;
struct trap *t; struct trap *t;
@@ -365,7 +365,7 @@ find_defensive(struct monst* mtmp)
if (is_animal(mtmp->data) || mindless(mtmp->data)) if (is_animal(mtmp->data) || mindless(mtmp->data))
return FALSE; return FALSE;
if (dist2(x, y, mtmp->mux, mtmp->muy) > 25) if (!tryescape && dist2(x, y, mtmp->mux, mtmp->muy) > 25)
return FALSE; return FALSE;
if (u.uswallow && stuck) if (u.uswallow && stuck)
return FALSE; return FALSE;
@@ -448,17 +448,20 @@ find_defensive(struct monst* mtmp)
} }
} }
fraction = u.ulevel < 10 ? 5 : u.ulevel < 14 ? 4 : 3; if (!tryescape) {
if (mtmp->mhp >= mtmp->mhpmax /* do we try to heal? */
|| (mtmp->mhp >= 10 && mtmp->mhp * fraction >= mtmp->mhpmax)) fraction = u.ulevel < 10 ? 5 : u.ulevel < 14 ? 4 : 3;
return FALSE; if (mtmp->mhp >= mtmp->mhpmax
|| (mtmp->mhp >= 10 && mtmp->mhp * fraction >= mtmp->mhpmax))
return FALSE;
if (mtmp->mpeaceful) { if (mtmp->mpeaceful) {
if (!nohands(mtmp->data)) { if (!nohands(mtmp->data)) {
if (m_use_healing(mtmp)) if (m_use_healing(mtmp))
return TRUE; return TRUE;
}
return FALSE;
} }
return FALSE;
} }
if (stuck || immobile) { if (stuck || immobile) {