more #H4347 - corpse revival

When a stack of N corpses is hit by wand or spell of undead turning,
1 revives and N-1 remain corpses.  If owned by a shop, a fee for
using up all N corpses was charged and if carried at the time, the
extra N-1 became owned by the player but if on the floor, they
remained owned by the shop.  Feedback was schitzophrenic as to
whether the whole stack was involved:
 One of the <foo> corpses glows irridescently.
 You owe <shk> X zormids for them.

Split the stack so that revival explicitly operates on only 1 corpse.
It's done after the revival side of things has already succeeded or
given up, so the split will never need to be undone.
This commit is contained in:
PatR
2016-05-25 01:09:45 -07:00
parent 955c53eba5
commit 656476e409
2 changed files with 24 additions and 11 deletions

View File

@@ -267,6 +267,8 @@ while in shop, undead turning at self causing carried, hero owned corpse to
resurrect claimed it belonged to shopkeeper
while in shop, stone-to-flesh at self causing carried, hero owned figurine
or statue to animate claimed it belonged to shopkeeper
reviving one of a stack of N corpses in a shop charged a usage fee for all N;
remaining N-1 were owned by hero if carried but by shop if on floor
Fixes to Post-3.6.0 Problems that Were Exposed Via git Respository

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 zap.c $NHDT-Date: 1464138044 2016/05/25 01:00:44 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.257 $ */
/* NetHack 3.6 zap.c $NHDT-Date: 1464163779 2016/05/25 08:09:39 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.258 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -673,6 +673,8 @@ int *container_nesting;
/*
* Attempt to revive the given corpse, return the revived monster if
* successful. Note: this does NOT use up the corpse if it fails.
* If corpse->quan is more than 1, only one corpse will be affected
* and only one monster will be resurrected.
*/
struct monst *
revive(corpse, by_hero)
@@ -684,6 +686,7 @@ boolean by_hero;
struct obj *container;
coord xy;
xchar x, y;
boolean one_of;
int montype, container_nesting = 0;
if (corpse->otyp != CORPSE) {
@@ -790,6 +793,10 @@ boolean by_hero;
if (mtmp->m_ap_type)
seemimic(mtmp);
one_of = (corpse->quan > 1L);
if (one_of)
corpse = splitobj(corpse, 1L);
/* if this is caused by the hero there might be a shop charge */
if (by_hero) {
struct monst *shkp = 0;
@@ -803,12 +810,16 @@ boolean by_hero;
char buf[BUFSZ];
unsigned pfx = CXN_PFX_THE;
Strcpy(buf, (corpse->quan > 1L) ? "one of " : "");
Strcpy(buf, one_of ? "one of " : "");
if (carried(corpse) && !corpse->unpaid) {
Strcat(buf, "your ");
pfx = CXN_NO_PFX;
}
if (one_of)
corpse->quan++; /* force plural */
Strcat(buf, corpse_xname(corpse, (const char *) 0, pfx));
if (one_of) /* could be simplified to ''corpse->quan = 1L;'' */
corpse->quan--;
pline("%s glows iridescently.", upstart(buf));
} else if (shkp) {
/* need some prior description of the corpse since
@@ -916,10 +927,11 @@ struct monst *mon;
struct monst *mtmp2;
char owner[BUFSZ], corpse[BUFSZ];
boolean youseeit;
int once = 0, res = 0;
int res = 0;
youseeit = (mon == &youmonst) ? TRUE : canseemon(mon);
otmp2 = (mon == &youmonst) ? invent : mon->minvent;
owner[0] = corpse[0] = '\0'; /* lint suppression */
while ((otmp = otmp2) != 0) {
otmp2 = otmp->nobj;
@@ -928,19 +940,18 @@ struct monst *mon;
if (otmp->otyp != CORPSE)
continue;
/* save the name; the object is liable to go away */
if (youseeit)
if (youseeit) {
Strcpy(corpse,
corpse_xname(otmp, (const char *) 0, CXN_SINGULAR));
Shk_Your(owner, otmp); /* includes a trailing space */
}
/* for a merged group, only one is revived; should this be fixed? */
/* for a stack, only one is revived */
if ((mtmp2 = revive(otmp, !context.mon_moving)) != 0) {
++res;
if (youseeit) {
if (!once++)
Strcpy(owner, (mon == &youmonst) ? "Your"
: s_suffix(Monnam(mon)));
pline("%s %s suddenly comes alive!", owner, corpse);
} else if (canseemon(mtmp2))
if (youseeit)
pline("%s%s suddenly comes alive!", owner, corpse);
else if (canseemon(mtmp2))
pline("%s suddenly appears!", Amonnam(mtmp2));
}
}