Skip to content

Commit

Permalink
shop statues & boulders
Browse files Browse the repository at this point in the history
     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.
  • Loading branch information
nethack.rankin committed Mar 19, 2005
1 parent 7cb4b9d commit fe10f99
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 10 deletions.
2 changes: 2 additions & 0 deletions include/extern.h
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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 *));
Expand Down
18 changes: 14 additions & 4 deletions src/dothrow.c
Original file line number Diff line number Diff line change
@@ -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. */

Expand All @@ -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 *));
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -1632,7 +1642,7 @@ boolean from_invent;
}
}
}
delobj(obj);
if (!fracture) delobj(obj);
}

/*
Expand Down
4 changes: 1 addition & 3 deletions src/shk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 *));
Expand Down Expand Up @@ -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;
Expand Down
22 changes: 19 additions & 3 deletions src/zap.c
Original file line number Diff line number Diff line change
@@ -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. */

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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))
Expand All @@ -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);
}
Expand Down

0 comments on commit fe10f99

Please sign in to comment.