Unify checking if monster is ok in poison gas
This commit is contained in:
37
src/mon.c
37
src/mon.c
@@ -140,6 +140,40 @@ mon_sanity_check()
|
||||
}
|
||||
}
|
||||
|
||||
/* Would monster be OK with poison gas? */
|
||||
/* Does not check for actual poison gas at the location. */
|
||||
/* Returns one of M_POISONGAS_foo */
|
||||
int
|
||||
m_poisongas_ok(mtmp)
|
||||
struct monst *mtmp;
|
||||
{
|
||||
int px, py;
|
||||
|
||||
/* Non living and non breathing monsters are not concerned */
|
||||
if (nonliving(mtmp->data) || is_vampshifter(mtmp)
|
||||
|| breathless(mtmp->data))
|
||||
return M_POISONGAS_OK;
|
||||
/* not is_swimmer(); assume that non-fish are swimming on
|
||||
the surface and breathing the air above it periodically
|
||||
unless located at water spot on plane of water */
|
||||
px = (mtmp == &g.youmonst) ? u.ux : mtmp->mx;
|
||||
py = (mtmp == &g.youmonst) ? u.uy : mtmp->my;
|
||||
if ((mtmp->data->mlet == S_EEL || Is_waterlevel(&u.uz))
|
||||
&& isok(px, py) && is_pool(px, py))
|
||||
return M_POISONGAS_OK;
|
||||
/* exclude monsters with poison gas breath attack:
|
||||
adult green dragon and Chromatic Dragon (and iron golem,
|
||||
but nonliving() and breathless() tests also catch that) */
|
||||
if (attacktype_fordmg(mtmp->data, AT_BREA, AD_DRST)
|
||||
|| attacktype_fordmg(mtmp->data, AT_BREA, AD_RBRE))
|
||||
return M_POISONGAS_OK;
|
||||
if ((mtmp == &g.youmonst)
|
||||
&& (u.uinvulnerable || Breathless || Underwater))
|
||||
return M_POISONGAS_OK;
|
||||
if (resists_poison(mtmp) || (mtmp == &g.youmonst) && Poison_resistance)
|
||||
return M_POISONGAS_MINOR;
|
||||
return M_POISONGAS_BAD;
|
||||
}
|
||||
|
||||
/* convert the monster index of an undead to its living counterpart */
|
||||
int
|
||||
@@ -1354,8 +1388,7 @@ long flag;
|
||||
if (mdat == &mons[PM_FLOATING_EYE]) /* prefers to avoid heat */
|
||||
lavaok = FALSE;
|
||||
thrudoor = ((flag & (ALLOW_WALL | BUSTDOOR)) != 0L);
|
||||
poisongas_ok = ((nonliving(mdat) || is_vampshifter(mon)
|
||||
|| breathless(mdat)) || resists_poison(mon));
|
||||
poisongas_ok = (m_poisongas_ok(mon) == M_POISONGAS_OK);
|
||||
in_poisongas = ((gas_reg = visible_region_at(x,y)) != 0
|
||||
&& gas_reg->glyph == gas_glyph);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user