Make hostile monsters with launcher and ammo keep away

If a hostile monster is wielding a ranged weapon, and is carrying
appropriate ammo for it, make the monster try to stay away,
outside the melee range.
This commit is contained in:
Pasi Kallinen
2020-04-14 15:19:26 +03:00
parent ffb9540295
commit bddb80f13c
4 changed files with 24 additions and 0 deletions

View File

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

View File

@@ -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 *));

View File

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

View File

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