more steadfast

Make changes similar to the suggested patch from entrez:  support
for 'youmonst' as the monster passed to m_carrying().  This doesn't
change carrying(otyp) to call m_carrying(&g.youmonst,otyp) though.

Also, treat being on the Plane of Air or in an air bubble on the
Plane of Water similar to flying or levitating:  wielded Giantslayer
(or carried loadstone) doesn't prevent knockback there.
This commit is contained in:
PatR
2022-10-26 01:13:01 -07:00
parent 313cf1ccd8
commit 13fb141ddd
3 changed files with 22 additions and 16 deletions

View File

@@ -4611,26 +4611,29 @@ missum(
wakeup(mdef, TRUE);
}
/* check whether equipment protects against knockback */
static boolean
m_is_steadfast(struct monst *mtmp)
{
boolean is_u = (mtmp == &g.youmonst);
struct obj *otmp = is_u ? uwep : MON_WEP(mtmp);
/* must be on the ground */
if (is_u ? (Flying || Levitation)
: (is_flyer(mtmp->data) || is_floater(mtmp->data)))
/* must be on the ground (or in water) */
if ((is_u ? (Flying || Levitation)
: (is_flyer(mtmp->data) || is_floater(mtmp->data)))
|| Is_airlevel(&u.uz) /* air or cloud */
|| (Is_waterlevel(&u.uz) && !is_pool(u.ux, u.uy))) /* air bubble */
return FALSE;
if (is_art(otmp, ART_GIANTSLAYER))
return TRUE;
/* steadfast if carrying any loadstone (and not floating or flying);
when mounted and steed is target of knockback, check the rider
for a loadstone too */
for (otmp = is_u ? g.invent : mtmp->minvent; otmp; otmp = otmp->nobj)
if (otmp->otyp == LOADSTONE)
return TRUE;
'is_u' test not needed here; m_carrying() is 'youmonst' aware */
if (m_carrying(mtmp, LOADSTONE))
return TRUE;
/* when mounted and steed is target of knockback, check the rider for
a loadstone too (Giantslayer's protection doesn't extend to steed) */
if (u.usteed && mtmp == u.usteed && carrying(LOADSTONE))
return TRUE;