]> granicus.if.org Git - nethack/commitdiff
shop statues & boulders
authornethack.rankin <nethack.rankin>
Sat, 19 Mar 2005 05:26:02 +0000 (05:26 +0000)
committernethack.rankin <nethack.rankin>
Sat, 19 Mar 2005 05:26:02 +0000 (05:26 +0000)
     Fix a buglist entry:  fracturing a boulder or statue owned by a shop
was ignored by the shopkeeper.  The existing vague fixes entry of "some
shop thefts weren't charged" covers this.

include/extern.h
src/dothrow.c
src/shk.c
src/zap.c

index 37fc884033bb7d5648c670f238d55327af0b6dac..2ac036e9ccf58e3ddc48c22163e95edc1e460072 100644 (file)
@@ -469,6 +469,7 @@ E int FDECL(omon_adj, (struct monst *,struct obj *,BOOLEAN_P));
 E int FDECL(thitmonst, (struct monst *,struct obj *));
 E int FDECL(hero_breaks, (struct obj *,XCHAR_P,XCHAR_P,BOOLEAN_P));
 E int FDECL(breaks, (struct obj *,XCHAR_P,XCHAR_P));
+E void FDECL(breakobj, (struct obj *,XCHAR_P,XCHAR_P,BOOLEAN_P,BOOLEAN_P));
 E boolean FDECL(breaktest, (struct obj *));
 E boolean FDECL(walk_path, (coord *, coord *, boolean (*)(genericptr_t,int,int), genericptr_t));
 E boolean FDECL(hurtle_step, (genericptr_t, int, int));
@@ -1881,6 +1882,7 @@ E long FDECL(contained_cost, (struct obj *,struct monst *,long,BOOLEAN_P, BOOLEA
 E long FDECL(contained_gold, (struct obj *));
 E void FDECL(picked_container, (struct obj *));
 E long FDECL(unpaid_cost, (struct obj *));
+E boolean FDECL(billable, (struct monst **,struct obj *,CHAR_P,BOOLEAN_P));
 E void FDECL(addtobill, (struct obj *,BOOLEAN_P,BOOLEAN_P,BOOLEAN_P));
 E void FDECL(splitbill, (struct obj *,struct obj *));
 E void FDECL(subfrombill, (struct obj *,struct monst *));
index d992603ad5e8ce31432440999a81537b81659981..c35c82963653f910bfd516994373621eb3dcc6f9 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)dothrow.c  3.5     2004/12/21      */
+/*     SCCS Id: @(#)dothrow.c  3.5     2005/03/18      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -13,7 +13,6 @@ STATIC_DCL int FDECL(gem_accept, (struct monst *, struct obj *));
 STATIC_DCL void FDECL(tmiss, (struct obj *, struct monst *));
 STATIC_DCL int FDECL(throw_gold, (struct obj *));
 STATIC_DCL void FDECL(check_shop_obj, (struct obj *,XCHAR_P,XCHAR_P,BOOLEAN_P));
-STATIC_DCL void FDECL(breakobj, (struct obj *,XCHAR_P,XCHAR_P,BOOLEAN_P,BOOLEAN_P));
 STATIC_DCL void FDECL(breakmsg, (struct obj *,BOOLEAN_P));
 STATIC_DCL boolean FDECL(toss_up,(struct obj *, BOOLEAN_P));
 STATIC_DCL boolean FDECL(throwing_weapon, (struct obj *));
@@ -1567,13 +1566,15 @@ xchar x, y;             /* object location (ox, oy may not be right) */
  * Unconditionally break an object. Assumes all resistance checks
  * and break messages have been delivered prior to getting here.
  */
-STATIC_OVL void
+void
 breakobj(obj, x, y, hero_caused, from_invent)
 struct obj *obj;
 xchar x, y;            /* object location (ox, oy may not be right) */
 boolean hero_caused;   /* is this the hero's fault? */
 boolean from_invent;
 {
+       boolean fracture = FALSE;
+
        switch (obj->oclass == POTION_CLASS ? POT_WATER : obj->otyp) {
                case MIRROR:
                        if (hero_caused)
@@ -1606,7 +1607,16 @@ boolean from_invent;
                        if (hero_caused && obj->spe && obj->corpsenm >= LOW_PM)
                            change_luck((schar) -min(obj->quan, 5L));
                        break;
+               case BOULDER:
+               case STATUE:
+                       /* caller will handle object disposition;
+                          we're just doing the shop theft handling */
+                       fracture = TRUE;
+                       break;
+               default:
+                       break;
        }
+
        if (hero_caused) {
            if (from_invent) {
                if (*u.ushops)
@@ -1632,7 +1642,7 @@ boolean from_invent;
                }
            }
        }
-       delobj(obj);
+       if (!fracture) delobj(obj);
 }
 
 /*
index e9c3e58043df77c639d1df9956fad8043bc04e75..b7509bcd3e7081b3b38a465663be07e5b69777c7 100644 (file)
--- a/src/shk.c
+++ b/src/shk.c
@@ -58,8 +58,6 @@ STATIC_DCL void FDECL(rouse_shk, (struct monst *,BOOLEAN_P));
 STATIC_DCL void FDECL(remove_damage, (struct monst *, BOOLEAN_P));
 STATIC_DCL void FDECL(sub_one_frombill, (struct obj *, struct monst *));
 STATIC_DCL void FDECL(add_one_tobill, (struct obj *, BOOLEAN_P));
-STATIC_DCL boolean FDECL(billable, (struct monst **,struct obj *,
-                                   CHAR_P,BOOLEAN_P));
 STATIC_DCL void FDECL(dropped_container, (struct obj *, struct monst *,
                                      BOOLEAN_P));
 STATIC_DCL void FDECL(add_to_billobjs, (struct obj *));
@@ -2140,7 +2138,7 @@ const char *arg;
 }
 
 /* decide whether a shopkeeper thinks an item belongs to her */
-STATIC_OVL boolean
+boolean
 billable(shkpp, obj, roomno, reset_nocharge)
 struct monst **shkpp;  /* in: non-null if shk has been validated; out: shk */
 struct obj *obj;
index 174f36527ce9eab09e1b60e25052cbb76934b381..f49568ad24fcee02c5c21ba6923f4b4240c94d6d 100644 (file)
--- a/src/zap.c
+++ b/src/zap.c
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)zap.c      3.5     2004/12/21      */
+/*     SCCS Id: @(#)zap.c      3.5     2005/03/18      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -3891,8 +3891,23 @@ void
 fracture_rock(obj)     /* fractured by pick-axe or wand of striking */
 register struct obj *obj;                 /* no texts here! */
 {
+       xchar x, y;
+       boolean by_you = !context.mon_moving;
+
+       if (by_you && get_obj_location(obj, &x, &y, 0) && costly_spot(x, y)) {
+           struct monst *shkp = 0;
+           char objroom = *in_rooms(x, y, SHOPBASE);
+
+           if (billable(&shkp, obj, objroom, FALSE)) {
+               /* shop message says "you owe <shk> <$> for it!" so we need
+                  to precede that with a message explaining what "it" is */
+               You("fracture %s %s.", s_suffix(shkname(shkp)), xname(obj));
+               breakobj(obj, x, y, TRUE, FALSE); /* charges for shop goods */
+           }
+       }
+
        /* A little Sokoban guilt... */
-       if (obj->otyp == BOULDER && In_sokoban(&u.uz) && !context.mon_moving)
+       if (by_you && obj->otyp == BOULDER && In_sokoban(&u.uz))
            change_luck(-1);
 
        obj->otyp = ROCK;
@@ -3922,6 +3937,7 @@ register struct obj *obj;
        /* [obj is assumed to be on floor, so no get_obj_location() needed] */
        struct trap *trap = t_at(obj->ox, obj->oy);
        struct obj *item;
+       boolean by_you = !context.mon_moving;
 
        if (trap && trap->ttyp == STATUE_TRAP &&
                activate_statue_trap(trap, obj->ox, obj->oy, TRUE))
@@ -3931,7 +3947,7 @@ register struct obj *obj;
            obj_extract_self(item);
            place_object(item, obj->ox, obj->oy);
        }
-       if (Role_if(PM_ARCHEOLOGIST) && !context.mon_moving && (obj->spe & STATUE_HISTORIC)) {
+       if (by_you && Role_if(PM_ARCHEOLOGIST) && (obj->spe & STATUE_HISTORIC)) {
            You_feel("guilty about damaging such a historic statue.");
            adjalign(-1);
        }