fix #332 - strangulation affects headless monsters (trunk only)
From a bug report: amulet of strangulation
continues to kill hero if he polymorphs into a creature which doesn't
need to breathe or doesn't have a head or even a circulatory system.
Currently, the messages are different when the hero doesn't need to
breathe, but that doesn't seem good enough. This makes strangulation
stop when you polymorph into something which shouldn't be vulnerable and
restart if you poly into something vulnerable while still wearing the
bad amulet.
can_be_strangled() is doing more checks that necessary, in case the
strangulation property ever gets conferred by something other than an
amulet. Its criteria for protection from strangling might need tweaking.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)mondata.c 3.5 2007/03/02 */
|
||||
/* SCCS Id: @(#)mondata.c 3.5 2007/05/16 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -299,6 +299,37 @@ register struct monst *mtmp;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
boolean
|
||||
can_be_strangled(mon) /* TRUE if mon is vulnerable to strangulation */
|
||||
struct monst *mon;
|
||||
{
|
||||
struct obj *mamul;
|
||||
boolean nonbreathing, nobrainer;
|
||||
|
||||
/* For amulet of strangulation support: here we're considering
|
||||
strangulation to be loss of blood flow to the brain due to
|
||||
constriction of the arteries in the neck, so all headless
|
||||
creatures are immune (no neck) as are mindless creatures
|
||||
who don't need to breathe (brain, if any, doesn't care).
|
||||
Mindless creatures who do need to breath are vulnerable, as
|
||||
are non-breathing creatures which have higher brain function. */
|
||||
if (!has_head(mon->data)) return FALSE;
|
||||
if (mon == &youmonst) {
|
||||
/* hero can't be mindless but poly'ing into mindless form can
|
||||
confer strangulation protection */
|
||||
nobrainer = mindless(youmonst.data);
|
||||
nonbreathing = Breathless;
|
||||
} else {
|
||||
nobrainer = mindless(mon->data);
|
||||
/* monsters don't wear amulets of magical breathing,
|
||||
so second part doesn't achieve anything useful... */
|
||||
nonbreathing = (breathless(mon->data) ||
|
||||
((mamul = which_armor(mon, W_AMUL)) != 0 &&
|
||||
(mamul->otyp == AMULET_OF_MAGICAL_BREATHING)));
|
||||
}
|
||||
return (boolean)(!nobrainer || !nonbreathing);
|
||||
}
|
||||
|
||||
boolean
|
||||
can_track(ptr) /* returns TRUE if monster can track well */
|
||||
register struct permonst *ptr;
|
||||
|
||||
Reference in New Issue
Block a user