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:
nethack.rankin
2007-05-18 02:10:39 +00:00
parent 78d9a4186a
commit 4be43239a8
6 changed files with 78 additions and 6 deletions

View File

@@ -21,6 +21,7 @@
#include "hack.h"
STATIC_DCL void FDECL(check_strangling, (BOOLEAN_P));
STATIC_DCL void FDECL(polyman, (const char *,const char *));
STATIC_DCL void NDECL(break_armor);
STATIC_DCL void FDECL(drop_weapon,(int));
@@ -46,6 +47,30 @@ set_uasmon()
#endif
}
/* for changing into form that's immune to strangulation */
STATIC_OVL void
check_strangling(on)
boolean on;
{
if (on) { /* on -- maybe resume strangling */
/* when Strangled is already set, polymorphing from one
vulnerable form into another causes the counter to be reset */
if (uamul && uamul->otyp == AMULET_OF_STRANGULATION &&
can_be_strangled(&youmonst)) {
Your("%s %s your %s!", simpleonames(uamul),
Strangled ? "still constricts" : "begins constricting",
body_part(NECK)); /* "throat" */
Strangled = 6L;
makeknown(AMULET_OF_STRANGULATION);
}
} else { /* off -- maybe block strangling */
if (Strangled && !can_be_strangled(&youmonst)) {
Strangled = 0L;
You("are no longer being strangled.");
}
}
}
/* make a (new) human out of the player */
STATIC_OVL void
polyman(fmt, arg)
@@ -109,6 +134,7 @@ const char *fmt, *arg;
Blinded = 1L;
make_blinded(0L, TRUE); /* remove blindness */
}
check_strangling(TRUE);
if(!Levitation && !u.ustuck &&
(is_pool(u.ux,u.uy) || is_lava(u.ux,u.uy)))
@@ -491,6 +517,7 @@ int mntmp;
make_slimed(0L, (char*) 0);
}
}
check_strangling(FALSE); /* maybe stop strangling */
if (nohands(youmonst.data)) Glib = 0;
/*
@@ -631,6 +658,7 @@ int mntmp;
You("orient yourself on the web.");
u.utrap = 0;
}
check_strangling(TRUE); /* maybe start strangling */
(void) polysense(youmonst.data);
context.botl = 1;