From fe10f991a657d172e5966c6e4ea63f22ee11ea02 Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Sat, 19 Mar 2005 05:26:02 +0000 Subject: [PATCH] shop statues & boulders 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 | 2 ++ src/dothrow.c | 18 ++++++++++++++---- src/shk.c | 4 +--- src/zap.c | 22 +++++++++++++++++++--- 4 files changed, 36 insertions(+), 10 deletions(-) diff --git a/include/extern.h b/include/extern.h index 37fc88403..2ac036e9c 100644 --- a/include/extern.h +++ b/include/extern.h @@ -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 *)); diff --git a/src/dothrow.c b/src/dothrow.c index d992603ad..c35c82963 100644 --- a/src/dothrow.c +++ b/src/dothrow.c @@ -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); } /* diff --git a/src/shk.c b/src/shk.c index e9c3e5804..b7509bcd3 100644 --- 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; diff --git a/src/zap.c b/src/zap.c index 174f36527..f49568ad2 100644 --- 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 <$> 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); } -- 2.40.0