From 58583cacf8511625fd805ecbb050481f28de9411 Mon Sep 17 00:00:00 2001 From: PatR Date: Wed, 10 Jul 2019 17:56:33 -0700 Subject: [PATCH] hero-as-nymph: steal items vs steal gold Nymphs won't steal gold from the hero (so that their steal-item damage isn't a superset of lerprechaun's steal-gold damage; straightforward back when gold wasn't kept in inventory), but hero poly'd into a nymph would steal gold from monsters. --- doc/fixes36.3 | 3 ++- src/steal.c | 11 ++++++++--- src/uhitm.c | 37 +++++++++++++++++++++++++++++++------ 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/doc/fixes36.3 b/doc/fixes36.3 index 80002d745..3d8a5ed9e 100644 --- a/doc/fixes36.3 +++ b/doc/fixes36.3 @@ -1,4 +1,4 @@ -$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.91 $ $NHDT-Date: 1562800503 2019/07/10 23:15:03 $ +$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.92 $ $NHDT-Date: 1562806584 2019/07/11 00:56:24 $ This fixes36.3 file is here to capture information about updates in the 3.6.x lineage following the release of 3.6.2 in May 2019. Please note, however, @@ -103,6 +103,7 @@ detect unseen/secret door detection/^E failed to find monsters hiding under objects and failed to find monsters hiding at trap locations when farlook describes a monster at a visible spot as trapped, reveal the trap fix theft when poly'd into nymph form; 3.6.2 change made that anger the victim +hero poly'd into nymph would steal gold along with other items Fixes to Post-3.6.2 Problems that Were Exposed Via git Repository diff --git a/src/steal.c b/src/steal.c index 59421e372..2686a5392 100644 --- a/src/steal.c +++ b/src/steal.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 steal.c $NHDT-Date: 1561588404 2019/06/26 22:33:24 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.73 $ */ +/* NetHack 3.6 steal.c $NHDT-Date: 1562806584 2019/07/11 00:56:24 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.74 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -247,7 +247,8 @@ struct monst *mtmp; char *objnambuf; { struct obj *otmp; - int tmp, could_petrify, armordelay, olddelay, named = 0, retrycnt = 0; + int tmp, could_petrify, armordelay, olddelay, icnt, + named = 0, retrycnt = 0; boolean monkey_business, /* true iff an animal is doing the thievery */ was_doffing, was_punished = Punished; @@ -263,11 +264,15 @@ char *objnambuf; if (occupation) (void) maybe_finished_meal(FALSE); - if (!invent || (inv_cnt(FALSE) == 1 && uskin)) { + icnt = inv_cnt(FALSE); /* don't include gold */ + if (!icnt || (icnt == 1 && uskin)) { nothing_to_steal: /* Not even a thousand men in armor can strip a naked man. */ if (Blind) pline("Somebody tries to rob you, but finds nothing to steal."); + else if (inv_cnt(TRUE) > inv_cnt(FALSE)) /* ('icnt' might be stale) */ + pline("%s tries to rob you, but isn't interested in gold.", + Monnam(mtmp)); else pline("%s tries to rob you, but there is nothing to steal!", Monnam(mtmp)); diff --git a/src/uhitm.c b/src/uhitm.c index f478d0289..c6fc30c2a 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 uhitm.c $NHDT-Date: 1555720104 2019/04/20 00:28:24 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.207 $ */ +/* NetHack 3.6 uhitm.c $NHDT-Date: 1562806586 2019/07/11 00:56:26 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.210 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1498,10 +1498,11 @@ steal_it(mdef, mattk) struct monst *mdef; struct attack *mattk; { - struct obj *otmp, *stealoid, **minvent_ptr; + struct obj *otmp, *gold = 0, *stealoid, **minvent_ptr; long unwornmask; - if (!mdef->minvent) + otmp = mdef->minvent; + if (!otmp || (otmp->oclass == COIN_CLASS && !otmp->nobj)) return; /* nothing to take */ /* look for worn body armor */ @@ -1524,14 +1525,25 @@ struct attack *mattk; if (stealoid) { /* we will be taking everything */ if (gender(mdef) == (int) u.mfemale && youmonst.data->mlet == S_NYMPH) - You("charm %s. She gladly hands over her possessions.", - mon_nam(mdef)); + You("charm %s. She gladly hands over %sher possessions.", + mon_nam(mdef), !gold ? "" : "most of "); else You("seduce %s and %s starts to take off %s clothes.", mon_nam(mdef), mhe(mdef), mhis(mdef)); } + /* prevent gold from being stolen so that steal-item isn't a superset + of steal-gold; shuffling it out of minvent before selecting next + item, and then back in case hero or monster dies (hero touching + stolen c'trice corpse or monster wielding one and having gloves + stolen) is less bookkeeping than skipping it within the loop or + taking it out once and then trying to figure out how to put it back */ + if ((gold = findgold(mdef->minvent)) != 0) + obj_extract_self(gold); + while ((otmp = mdef->minvent) != 0) { + if (gold) /* put 'mdef's gold back */ + mpickobj(mdef, gold), gold = 0; if (!Upolyd) break; /* no longer have ability to steal */ /* take the object away from the monster */ @@ -1564,12 +1576,25 @@ struct attack *mattk; } else if (unwornmask & W_ARMG) { /* stole worn gloves */ mselftouch(mdef, (const char *) 0, TRUE); if (DEADMONSTER(mdef)) /* it's now a statue */ - return; /* can't continue stealing */ + break; /* can't continue stealing */ } if (!stealoid) break; /* only taking one item */ + + /* take gold out of minvent before making next selection; if it + is the only thing left, the loop will terminate and it will be + put back below */ + if ((gold = findgold(mdef->minvent)) != 0) + obj_extract_self(gold); } + + /* put gold back; won't happen if either hero or 'mdef' dies because + gold will be back in monster's inventory at either of those times + (so will be present in mdef's minvent for bones, or in its statue + now if it has just been turned into one) */ + if (gold) + mpickobj(mdef, gold); } int