Keep permanent inventory window up to date when using charged items.
Also a status line bit for the #tip command.
(struct obj *,const char *,const char *,const char *));
E void FDECL(useupall, (struct obj *));
E void FDECL(useup, (struct obj *));
+E void FDECL(consume_obj_charge, (struct obj *,BOOLEAN_P));
E void FDECL(freeinv_core, (struct obj *));
E void FDECL(freeinv, (struct obj *));
E void FDECL(delallobj, (int,int));
-/* SCCS Id: @(#)apply.c 3.4 2003/03/29 */
+/* SCCS Id: @(#)apply.c 3.4 2003/05/25 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
pline(nothing_happens);
return (1);
}
- check_unpaid(obj);
- obj->spe--;
+ consume_obj_charge(obj, TRUE);
+
if (obj->cursed && !rn2(2)) {
(void) zapyourself(obj, TRUE);
} else if (u.uswallow) {
} else {
/* charged Bell of Opening */
- check_unpaid(obj);
- obj->spe--;
+ consume_obj_charge(obj, TRUE);
if (u.uswallow) {
if (!obj->cursed)
pline("That's too insubstantial to tin.");
return;
}
- check_unpaid(obj);
- obj->spe--;
+ consume_obj_charge(obj, TRUE);
+
if ((can = mksobj(TIN, FALSE, FALSE)) != 0) {
static const char you_buy_it[] = "You tin it, you bought it!";
if (obj->spe > 0) {
if ((obj->cursed || Fumbling) && !rn2(2)) {
- check_unpaid(obj);
- obj->spe--;
+ consume_obj_charge(obj, TRUE);
+
pline("%s from your %s.", Tobjnam(obj, "slip"),
makeplural(body_part(FINGER)));
dropx(obj);
return;
}
#endif
- check_unpaid(obj);
- obj->spe--;
+ consume_obj_charge(obj, TRUE);
+
if (otmp != &zeroobj) {
You("cover %s with a thick layer of grease.",
yname(otmp));
struct obj *otmp;
const char *what;
- check_unpaid(obj);
- obj->spe--;
+ consume_obj_charge(obj, TRUE);
if (!rn2(13)) {
otmp = mkobj(POTION_CLASS, FALSE);
if (objects[otmp->otyp].oc_magic) do {
-/* SCCS Id: @(#)detect.c 3.4 1999/12/06 */
+/* SCCS Id: @(#)detect.c 3.4 2003/05/25 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
losehp(rnd(30), "exploding crystal ball", KILLED_BY_AN);
break;
}
- check_unpaid(obj);
- obj->spe--;
+ consume_obj_charge(obj, TRUE);
return;
}
default: pline("Oh wow... like a kaleidoscope!");
break;
}
- check_unpaid(obj);
- obj->spe--;
+ consume_obj_charge(obj, TRUE);
}
return;
}
int ret = 0;
makeknown(CRYSTAL_BALL);
- check_unpaid(obj);
- obj->spe--;
+ consume_obj_charge(obj, TRUE);
if ((class = def_char_to_objclass(ch)) != MAXOCLASSES)
ret = object_detect((struct obj *)0, class);
-/* SCCS Id: @(#)invent.c 3.4 2003/04/02 */
+/* SCCS Id: @(#)invent.c 3.4 2003/05/25 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
}
}
+/* use one charge from an item and possibly incur shop debt for it */
+void
+consume_obj_charge(obj, maybe_unpaid)
+struct obj *obj;
+boolean maybe_unpaid; /* false if caller handles shop billing */
+{
+ if (maybe_unpaid) check_unpaid(obj);
+ obj->spe -= 1;
+ if (obj->known) update_inventory();
+}
+
#endif /* OVLB */
#ifdef OVL3
-/* SCCS Id: @(#)makemon.c 3.4 2003/03/29 */
+/* SCCS Id: @(#)makemon.c 3.4 2003/05/25 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
boolean gotone = FALSE;
int cnt = 1;
- check_unpaid(bag);
- bag->spe--;
+ consume_obj_charge(bag, TRUE);
+
if (!rn2(23)) cnt += rn1(7, 1);
while (cnt-- > 0) {
if (makemon((struct permonst *)0, u.ux, u.uy, NO_MM_FLAGS))
-/* SCCS Id: @(#)music.c 3.4 2003/03/10 */
+/* SCCS Id: @(#)music.c 3.4 2003/05/25 */
/* Copyright (c) 1989 by Jean-Christophe Collet */
/* NetHack may be freely redistributed. See license for details. */
switch (instr->otyp) {
case MAGIC_FLUTE: /* Make monster fall asleep */
if (do_spec && instr->spe > 0) {
- check_unpaid(instr);
- instr->spe--;
+ consume_obj_charge(instr, TRUE);
+
You("produce soft music.");
put_monsters_to_sleep(u.ulevel * 5);
exercise(A_DEX, TRUE);
case FROST_HORN: /* Idem wand of cold */
case FIRE_HORN: /* Idem wand of fire */
if (do_spec && instr->spe > 0) {
- check_unpaid(instr);
- instr->spe--;
+ consume_obj_charge(instr, TRUE);
+
if (!getdir((char *)0)) {
pline("%s.", Tobjnam(instr, "vibrate"));
break;
break;
case MAGIC_HARP: /* Charm monsters */
if (do_spec && instr->spe > 0) {
- check_unpaid(instr);
- instr->spe--;
+ consume_obj_charge(instr, TRUE);
+
pline("%s very attractive music.", Tobjnam(instr, "produce"));
charm_monsters((u.ulevel - 1) / 3 + 1);
exercise(A_DEX, TRUE);
break;
case DRUM_OF_EARTHQUAKE: /* create several pits */
if (do_spec && instr->spe > 0) {
- check_unpaid(instr);
- instr->spe--;
+ consume_obj_charge(instr, TRUE);
+
You("produce a heavy, thunderous rolling!");
pline_The("entire dungeon is shaking around you!");
do_earthquake((u.ulevel - 1) / 3 + 1);
-/* SCCS Id: @(#)pickup.c 3.4 2003/05/08 */
+/* SCCS Id: @(#)pickup.c 3.4 2003/05/25 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
surface(u.ux, u.uy), buf);
/* shop usage message comes after the spill message */
if (cobj->otyp == CAN_OF_GREASE && cobj->spe > 0) {
- check_unpaid(cobj);
- cobj->spe--; /* doesn't affect cobj->owt */
+ consume_obj_charge(cobj, TRUE);
}
/* something [useless] happened */
return 1;
}
if (loss)
You("owe %ld %s for lost merchandise.", loss, currency(loss));
+ if (held) (void)encumber_msg();
}
}
-/* SCCS Id: @(#)trap.c 3.4 2003/05/09 */
+/* SCCS Id: @(#)trap.c 3.4 2003/05/25 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
/* successfully used oil or grease to fix squeaky board */
if (obj->otyp == CAN_OF_GREASE) {
- check_unpaid(obj);
- obj->spe--;
- update_inventory();
+ consume_obj_charge(obj, TRUE);
} else {
useup(obj); /* oil */
makeknown(POT_OIL);