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

Function can_be_strangled

src/mondata.c:590–619  ·  view source on GitHub ↗

True if mon is vulnerable to strangulation */

Source from the content-addressed store, hash-verified

588
589/* True if mon is vulnerable to strangulation */
590boolean
591can_be_strangled(struct monst *mon)
592{
593 struct obj *mamul;
594 boolean nonbreathing, nobrainer;
595
596 /* For amulet of strangulation support: here we're considering
597 strangulation to be loss of blood flow to the brain due to
598 constriction of the arteries in the neck, so all headless
599 creatures are immune (no neck) as are mindless creatures
600 who don't need to breathe (brain, if any, doesn't care).
601 Mindless creatures who do need to breath are vulnerable, as
602 are non-breathing creatures which have higher brain function. */
603 if (!has_head(mon->data))
604 return FALSE;
605 if (mon == &gy.youmonst) {
606 /* hero can't be mindless but poly'ing into mindless form can
607 confer strangulation protection */
608 nobrainer = mindless(gy.youmonst.data);
609 nonbreathing = Breathless;
610 } else {
611 nobrainer = mindless(mon->data);
612 /* monsters don't wear amulets of magical breathing,
613 so second part doesn't achieve anything useful... */
614 nonbreathing = (breathless(mon->data)
615 || ((mamul = which_armor(mon, W_AMUL)) != 0
616 && (mamul->otyp == AMULET_OF_MAGICAL_BREATHING)));
617 }
618 return (boolean) (!nobrainer || !nonbreathing);
619}
620
621/* returns True if monster can track well */
622boolean

Callers 3

Amulet_onFunction · 0.85
hmonasFunction · 0.85
check_stranglingFunction · 0.85

Calls 1

which_armorFunction · 0.85

Tested by

no test coverage detected