MCPcopy Create free account
hub / github.com/NetHack/NetHack / m_is_steadfast

Function m_is_steadfast

src/uhitm.c:5217–5243  ·  view source on GitHub ↗

check whether equipment protects against knockback */

Source from the content-addressed store, hash-verified

5215
5216/* check whether equipment protects against knockback */
5217boolean
5218m_is_steadfast(struct monst *mtmp)
5219{
5220 boolean is_u = (mtmp == &gy.youmonst);
5221 struct obj *otmp = is_u ? uwep : MON_WEP(mtmp);
5222
5223 /* must be on the ground (or in water) */
5224 if ((is_u ? (Flying || Levitation)
5225 : (is_flyer(mtmp->data) || is_floater(mtmp->data)))
5226 || Is_airlevel(&u.uz) /* air or cloud */
5227 || (Is_waterlevel(&u.uz) && !is_pool(u.ux, u.uy))) /* air bubble */
5228 return FALSE;
5229
5230 if (is_art(otmp, ART_GIANTSLAYER))
5231 return TRUE;
5232
5233 /* steadfast if carrying any loadstone (and not floating or flying);
5234 'is_u' test not needed here; m_carrying() is 'youmonst' aware */
5235 if (m_carrying(mtmp, LOADSTONE))
5236 return TRUE;
5237 /* when mounted and steed is target of knockback, check the rider for
5238 a loadstone too (Giantslayer's protection doesn't extend to steed) */
5239 if (u.usteed && mtmp == u.usteed && carrying(LOADSTONE))
5240 return TRUE;
5241
5242 return FALSE;
5243}
5244
5245/* monster hits another monster hard enough to knock it back? */
5246boolean

Callers 2

mhitm_knockbackFunction · 0.85
bhitmFunction · 0.85

Calls 4

is_poolFunction · 0.85
is_artFunction · 0.85
m_carryingFunction · 0.85
carryingFunction · 0.85

Tested by

no test coverage detected