Charge hero for making off with shop-owned boulder

Pushing a shop-owned boulder out of the shop wouldn't charge the hero
anything.  Remedy this (and remove the boulder from the bill if the hero
then pushes it back in).  Also tried to handle a couple other uncharged
boulder "theft" scenarios: pushing a boulder into lava or water, into a
trapdoor or hole, or into a level teleporter (various other traps
already charged for the boulder -- it was pretty inconsistent).

I externified onbill() for this, since relying on otmp->unpaid by itself
impossibles if you push a boulder through a gap in a wall between two
adjoining shops.
This commit is contained in:
Michael Meyer
2022-11-14 14:59:29 -05:00
committed by PatR
parent fa0cc01ae7
commit b8472af927
4 changed files with 19 additions and 7 deletions

View File

@@ -2481,6 +2481,7 @@ extern void shopper_financial_report(void);
extern int inhishop(struct monst *);
extern struct monst *shop_keeper(char);
extern boolean tended_shop(struct mkroom *);
struct bill_x *onbill(struct obj *, struct monst *, boolean);
extern boolean is_unpaid(struct obj *);
extern void delete_contents(struct obj *);
extern void obfree(struct obj *, struct obj *);

View File

@@ -134,7 +134,7 @@ boulder_hits_pool(
/* boulder is now gone */
if (pushing)
delobj(otmp);
useupf(otmp, otmp->quan);
else
obfree(otmp, (struct obj *) 0);
return TRUE;

View File

@@ -154,9 +154,9 @@ moverock(void)
register coordxy rx, ry, sx, sy;
struct obj *otmp;
struct trap *ttmp;
struct monst *mtmp;
struct monst *mtmp, *shkp;
const char *what;
boolean firstboulder = TRUE;
boolean costly, firstboulder = TRUE;
int res = 0;
sx = u.ux + u.dx, sy = u.uy + u.dy; /* boulder starting position */
@@ -243,6 +243,8 @@ moverock(void)
|| doorless_door(rx, ry)) && !sobj_at(BOULDER, rx, ry)) {
ttmp = t_at(rx, ry);
mtmp = m_at(rx, ry);
costly = (!otmp->no_charge && costly_spot(sx, sy)
&& shop_keeper(*in_rooms(sx, sy, SHOPBASE)));
/* KMH -- Sokoban doesn't let you push boulders diagonally */
if (Sokoban && u.dx && u.dy) {
@@ -353,7 +355,7 @@ moverock(void)
(ttmp->ttyp == TRAPDOOR) ? "trap door" : "hole",
surface(rx, ry));
deltrap(ttmp);
delobj(otmp);
useupf(otmp, 1L);
bury_objs(rx, ry);
levl[rx][ry].wall_info &= ~W_NONDIGGABLE;
levl[rx][ry].candig = 1;
@@ -380,6 +382,8 @@ moverock(void)
if (ttmp->ttyp == TELEP_TRAP) {
(void) rloco(otmp);
} else {
if (costly)
addtobill(otmp, FALSE, FALSE, FALSE);
obj_extract_self(otmp);
add_to_migration(otmp);
get_level(&dest, newlev);
@@ -444,6 +448,14 @@ moverock(void)
} else {
newsym(sx, sy);
}
/* maybe adjust bill if boulder was pushed across shop boundary */
if (costly && !costly_spot(rx, ry)) {
addtobill(otmp, FALSE, FALSE, FALSE);
} else if (!costly && costly_spot(rx, ry) && otmp->unpaid
&& (shkp = shop_keeper(*in_rooms(rx, ry, SHOPBASE)))
&& onbill(otmp, shkp, TRUE)) {
subfrombill(otmp, shkp);
}
} else {
nopushmsg:
what = the(xname(otmp));

View File

@@ -29,7 +29,6 @@ static const char the_contents_of[] = "the contents of ";
static void append_honorific(char *);
static long addupbill(struct monst *);
static void pacify_shk(struct monst *, boolean);
static struct bill_x *onbill(struct obj *, struct monst *, boolean);
static struct monst *next_shkp(struct monst *, boolean);
static long shop_debt(struct eshk *);
static char *shk_owns(char *, struct obj *);
@@ -868,8 +867,8 @@ tended_shop(struct mkroom* sroom)
return !mtmp ? FALSE : (boolean) inhishop(mtmp);
}
static struct bill_x *
onbill(struct obj* obj, struct monst* shkp, boolean silent)
struct bill_x *
onbill(struct obj *obj, struct monst *shkp, boolean silent)
{
if (shkp) {
register struct bill_x *bp = ESHK(shkp)->bill_p;