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

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