]> granicus.if.org Git - nethack/commitdiff
breaking lock of shop chest (trunk only)
authornethack.rankin <nethack.rankin>
Wed, 3 Jan 2007 03:58:31 +0000 (03:58 +0000)
committernethack.rankin <nethack.rankin>
Wed, 3 Jan 2007 03:58:31 +0000 (03:58 +0000)
     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
include/hack.h
src/dokick.c
src/lock.c
src/mkobj.c

index e5370436a0b39f7702f6f7446dd45e83bdca63f9..b9cb954d48293d4a4bf5b5ba54563eb64a3ae53e 100644 (file)
@@ -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);
index 680b42374882bd182e402c81038d77fbc12c3fec..9c0221d388f6799d51dd1a8385176e429c55e894 100644 (file)
@@ -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 */
index 0dfea5e19e1d007ca8ca02d2a0f6545de208cc59..7790b5b358714c4165e3b4624171888594806c41 100644 (file)
@@ -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);
                    }
index 1fcd4c2281ee62698c2e4e3428de85e5f56bdd05..44438304708accb6f1efd0f6fd0eaedd7500b5a6 100644 (file)
@@ -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 <u.ux,u.uy>) */
+       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));
 }
index 41819020945d7e68aa94921c259dbf7ff2881d49..7bc7e39477e52ec537a76e2269964a5d08541c81 100644 (file)
@@ -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 */