From c28a4aece8d066e3d9d9ab2970d0899b354259de Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Thu, 1 Dec 2005 04:19:15 +0000 Subject: [PATCH] grammar bit: fatal cockatrice corpse theft (trunk only) From a bug report, stealing a cockatrice corpse from a monster while polymorphed into a nymph and not wearing any gloves, the cause of death ended up being "petrified by cockatrice corpse". It would also have said the same thing if a stack of multiple corpses was involved. This fixes both cases, and also hypothetical unique monsters with petrifying touch. (Last bit tested by temporarily adding Medusa to touch_petrifies().) --- doc/fixes35.0 | 1 + src/uhitm.c | 43 ++++++++++++++++++++++++++++++++++--------- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/doc/fixes35.0 b/doc/fixes35.0 index 8177df7e2..015d8a6a6 100644 --- a/doc/fixes35.0 +++ b/doc/fixes35.0 @@ -99,6 +99,7 @@ assigning an artifact name is rejected on objects with similar description to adjust feedback for gas spore explosion when hallucinating traps detected by scroll or crystal ball overlooked carried or buried chests can't wish for a trapped box/chest/tin by specifying "poisoned" +grammar bit if killed by stealing a cockatrice corpse from a monster Platform- and/or Interface-Specific Fixes diff --git a/src/uhitm.c b/src/uhitm.c index 5503fd555..5c716a19d 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)uhitm.c 3.5 2005/09/27 */ +/* SCCS Id: @(#)uhitm.c 3.5 2005/11/30 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -6,6 +6,7 @@ STATIC_DCL boolean FDECL(known_hitum, (struct monst *,struct obj *, int *,int,int,struct attack *)); +STATIC_DCL boolean FDECL(theft_petrifies, (struct obj *)); STATIC_DCL void FDECL(steal_it, (struct monst *, struct attack *)); STATIC_DCL boolean FDECL(hitum, (struct monst *,struct attack *)); STATIC_DCL boolean FDECL(hmon_hitmon, (struct monst *,struct obj *,int)); @@ -1210,6 +1211,36 @@ demonpet() exercise(A_WIS, TRUE); } +STATIC_OVL boolean +theft_petrifies(otmp) +struct obj *otmp; +{ + const char *fmt; + char *p, cbuf[BUFSZ], kbuf[BUFSZ]; + + if (uarmg || otmp->otyp != CORPSE || + !touch_petrifies(&mons[otmp->corpsenm])) return FALSE; + + /* stealing this corpse is fatal... */ + Strcpy(cbuf, cxname(otmp)); /* "cockatrice corpse" */ + fmt = "a stolen %s"; + if (otmp->quan > 1L) { + /* stack of multiple cockatrice corpses; no article for plural */ + fmt += 2; /* skip "a ", leaving "stolen %s" */ + } else if ((p = strstri(cbuf, "'s corpse")) != 0 || + (p = strstri(cbuf, "s' corpse")) != 0) { + /* in case a unique monster with petrifying touch and + a personal name ever gets introduced: we want to use + "Foo's stolen corpse" instead of "a stolen Foo's corpse" */ + *(p + 2) = '\0'; /* chop " corpse" off of cbuf */ + fmt = "%s stolen corpse"; + } + Sprintf(kbuf, fmt, cbuf); + instapetrify(kbuf); + /* apparently wasn't fatal after all... */ + return TRUE; +} + /* * Player uses theft attack against monster. * @@ -1280,14 +1311,8 @@ struct attack *mattk; otmp = hold_another_object(otmp, "You snatched but dropped %s.", doname(otmp), "You steal: "); if (otmp->where != OBJ_INVENT) continue; - if (otmp->otyp == CORPSE && - touch_petrifies(&mons[otmp->corpsenm]) && !uarmg) { - char kbuf[BUFSZ]; - - Sprintf(kbuf, "stolen %s corpse", mons[otmp->corpsenm].mname); - instapetrify(kbuf); - break; /* stop the theft even if hero survives */ - } + if (theft_petrifies(otmp)) + break; /* stop thieving even though hero survived */ /* more take-away handling, after theft message */ if (unwornmask & W_WEP) { /* stole wielded weapon */ possibly_unwield(mdef, FALSE); -- 2.40.0