From dccedb99ba2bebb8a411ee973d1981872a19207e Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Wed, 3 Jan 2007 03:58:31 +0000 Subject: [PATCH] breaking lock of shop chest (trunk only) From the newsgroup: you weren't charged anything if you broke the lock of a box or chest which was owned by a shop. Force the hero to pay for the damaged container; any contents remain owned by the shop and don't affect the cost of the forced purchase. This existing entry in fixes35.0 is adequate to cover the fix: various actions--such as enchanting--performed on an unpaid shop object either force the hero to buy the item (when its value is lowered) or increase the current bill (when its value is raised) --- include/extern.h | 1 + include/hack.h | 3 +- src/dokick.c | 6 +-- src/lock.c | 96 ++++++++++++++++++++++++++---------------------- src/mkobj.c | 3 +- 5 files changed, 60 insertions(+), 49 deletions(-) diff --git a/include/extern.h b/include/extern.h index e5370436a..b9cb954d4 100644 --- a/include/extern.h +++ b/include/extern.h @@ -958,6 +958,7 @@ E int NDECL(picklock); #endif E boolean FDECL(picking_lock, (int *,int *)); E boolean FDECL(picking_at, (int,int)); +E void FDECL(breakchestlock, (struct obj *,BOOLEAN_P)); E void NDECL(reset_pick); E int FDECL(pick_lock, (struct obj *)); E int NDECL(doforce); diff --git a/include/hack.h b/include/hack.h index 680b42374..9c0221d38 100644 --- a/include/hack.h +++ b/include/hack.h @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)hack.h 3.5 2006/04/07 */ +/* SCCS Id: @(#)hack.h 3.5 2007/01/02 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -76,6 +76,7 @@ #define COST_SPLAT 12 /* cream pie to own face (ditto) */ #define COST_BITE 13 /* start eating food */ #define COST_OPEN 14 /* open tin */ +#define COST_BRKLCK 15 /* break box/chest's lock */ /* bitmask flags for corpse_xname(); PFX_THE takes precedence over ARTICLE, NO_PFX takes precedence over both */ diff --git a/src/dokick.c b/src/dokick.c index 0dfea5e19..7790b5b35 100644 --- a/src/dokick.c +++ b/src/dokick.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)dokick.c 3.5 2006/06/21 */ +/* SCCS Id: @(#)dokick.c 3.5 2007/01/02 */ /* Copyright (c) Izchak Miller, Mike Stephenson, Steve Linhart, 1989. */ /* NetHack may be freely redistributed. See license for details. */ @@ -516,9 +516,7 @@ xchar x, y; if (kickobj->olocked) { if (!rn2(5) || (martial() && !rn2(2))) { You("break open the lock!"); - kickobj->olocked = 0; - kickobj->obroken = 1; - kickobj->lknown = 1; + breakchestlock(kickobj, FALSE); if (otrp) (void) chest_trap(kickobj, LEG, FALSE); return(1); } diff --git a/src/lock.c b/src/lock.c index 1fcd4c228..444383047 100644 --- a/src/lock.c +++ b/src/lock.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)lock.c 3.5 2006/06/25 */ +/* SCCS Id: @(#)lock.c 3.5 2007/01/02 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -126,11 +126,61 @@ picklock(VOID_ARGS) /* try to open/close a lock */ return((xlock.usedtime = 0)); } +void +breakchestlock(box, destroyit) +struct obj *box; +boolean destroyit; +{ + box->olocked = 0; + box->obroken = 1; + box->lknown = 1; + if (!destroyit) { /* bill for the box but not for its contents */ + struct obj *hide_contents = box->cobj; + + box->cobj = 0; + costly_alteration(box, COST_BRKLCK); + box->cobj = hide_contents; + } else { /* #force has destroyed this box (at ) */ + struct obj *otmp; + struct monst *shkp = (*u.ushops && costly_spot(u.ux, u.uy)) ? + shop_keeper(*u.ushops) : 0; + boolean costly = (boolean)(shkp != 0), + peaceful_shk = costly && (boolean)shkp->mpeaceful; + long loss = 0L; + + pline("In fact, you've totally destroyed %s.", the(xname(box))); + /* Put the contents on ground at the hero's feet. */ + while ((otmp = box->cobj) != 0) { + obj_extract_self(otmp); + if (!rn2(3) || otmp->oclass == POTION_CLASS) { + chest_shatter_msg(otmp); + if (costly) + loss += stolen_value(otmp, u.ux, u.uy, peaceful_shk, TRUE); + if (otmp->quan == 1L) { + obfree(otmp, (struct obj *) 0); + continue; + } + useup(otmp); + } + if (box->otyp == ICE_BOX && otmp->otyp == CORPSE) { + otmp->age = monstermoves - otmp->age; /* actual age */ + start_corpse_timeout(otmp); + } + place_object(otmp, u.ux, u.uy); + stackobj(otmp); + } + if (costly) + loss += stolen_value(box, u.ux, u.uy, peaceful_shk, TRUE); + if (loss) + You("owe %ld %s for objects destroyed.", loss, currency(loss)); + delobj(box); + } +} + STATIC_PTR int forcelock(VOID_ARGS) /* try to force a locked chest */ { - register struct obj *otmp; if((xlock.box->ox != u.ux) || (xlock.box->oy != u.uy)) @@ -163,48 +213,8 @@ forcelock(VOID_ARGS) /* try to force a locked chest */ if(rn2(100) >= xlock.chance) return(1); /* still busy */ You("succeed in forcing the lock."); - xlock.box->olocked = 0; - xlock.box->obroken = 1; - xlock.box->lknown = 1; - if(!xlock.picktyp && !rn2(3)) { - struct monst *shkp; - boolean costly; - long loss = 0L; - - costly = (*u.ushops && costly_spot(u.ux, u.uy)); - shkp = costly ? shop_keeper(*u.ushops) : 0; - - pline("In fact, you've totally destroyed %s.", - the(xname(xlock.box))); - - /* Put the contents on ground at the hero's feet. */ - while ((otmp = xlock.box->cobj) != 0) { - obj_extract_self(otmp); - if(!rn2(3) || otmp->oclass == POTION_CLASS) { - chest_shatter_msg(otmp); - if (costly) - loss += stolen_value(otmp, u.ux, u.uy, - (boolean)shkp->mpeaceful, TRUE); - if (otmp->quan == 1L) { - obfree(otmp, (struct obj *) 0); - continue; - } - useup(otmp); - } - if (xlock.box->otyp == ICE_BOX && otmp->otyp == CORPSE) { - otmp->age = monstermoves - otmp->age; /* actual age */ - start_corpse_timeout(otmp); - } - place_object(otmp, u.ux, u.uy); - stackobj(otmp); - } + breakchestlock(xlock.box, (boolean)(!xlock.picktyp && !rn2(3))); - if (costly) - loss += stolen_value(xlock.box, u.ux, u.uy, - (boolean)shkp->mpeaceful, TRUE); - if(loss) You("owe %ld %s for objects destroyed.", loss, currency(loss)); - delobj(xlock.box); - } exercise((xlock.picktyp) ? A_DEX : A_STR, TRUE); return((xlock.usedtime = 0)); } diff --git a/src/mkobj.c b/src/mkobj.c index 418190209..7bc7e3947 100644 --- a/src/mkobj.c +++ b/src/mkobj.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)mkobj.c 3.5 2006/08/23 */ +/* SCCS Id: @(#)mkobj.c 3.5 2007/01/02 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -506,6 +506,7 @@ static const char * const alteration_verbs[] = { "cancel", "drain", "uncharge", "unbless", "uncurse", "disenchant", "degrade", "dilute", "erase", "burn", "neutralize", "destroy", "splatter", "bite", "open", + "break the lock on", }; /* possibly bill for an object which the player has just modified */ -- 2.40.0