diff --git a/doc/fixes37.0 b/doc/fixes37.0 index 4ce5d660f..b792552dd 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -133,6 +133,7 @@ male hero poly'd into nymph chooses charm vs seduce message based on being male rather than on all nymphs being female but charm message was using hardcoded pronouns She,her for target monster--wrong for male target and noticable if " finishes taking off his suit" is given +hostile monsters with launcher and ammo try to stay away from melee range Fixes to 3.7.0-x Problems that Were Exposed Via git Repository diff --git a/include/extern.h b/include/extern.h index fb6fb5ad5..9383638d5 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1660,6 +1660,7 @@ E void FDECL(Delay, (int)); /* ### mthrowu.c ### */ +E boolean FDECL(m_has_launcher_and_ammo, (struct monst *)); E int FDECL(thitu, (int, int, struct obj **, const char *)); E int FDECL(ohitmon, (struct monst *, struct obj *, int, BOOLEAN_P)); E void FDECL(thrwmu, (struct monst *)); diff --git a/src/monmove.c b/src/monmove.c index 26e848c8e..ef8b5b672 100644 --- a/src/monmove.c +++ b/src/monmove.c @@ -999,6 +999,12 @@ register int after; > ((ygold = findgold(g.invent)) ? ygold->quan : 0L)))) appr = -1; + /* hostile monsters with ranged thrown weapons try to stay away */ + if (!mtmp->mpeaceful + && (dist2(mtmp->mx, mtmp->my, mtmp->mux, mtmp->muy) < 5*5) + && m_canseeu(mtmp) && m_has_launcher_and_ammo(mtmp)) + appr = -1; + if (!should_see && can_track(ptr)) { register coord *cp; diff --git a/src/mthrowu.c b/src/mthrowu.c index 211a3e7ae..e7340a04b 100644 --- a/src/mthrowu.c +++ b/src/mthrowu.c @@ -26,6 +26,22 @@ static NEARDATA const char *breathwep[] = { "strange breath #9" }; +boolean +m_has_launcher_and_ammo(mtmp) +struct monst *mtmp; +{ + struct obj *mwep = MON_WEP(mtmp); + + if (mwep && is_launcher(mwep)) { + struct obj *otmp; + + for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj) + if (ammo_and_launcher(otmp, mwep)) + return TRUE; + } + return FALSE; +} + /* hero is hit by something other than a monster */ int thitu(tlev, dam, objp, name)