'showscore' vs containers

When SCORE_ON_BOTL is enabled, you could tell how much gold is
inside a container with unknown contents by having 'showsore' On
and watching how much the score changed on the status line when
picking the container up.
This commit is contained in:
PatR
2020-11-21 17:37:01 -08:00
parent d48e730700
commit 3e9d8f9aa5
10 changed files with 47 additions and 41 deletions

View File

@@ -1,4 +1,4 @@
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.358 $ $NHDT-Date: 1605959203 2020/11/21 11:46:43 $
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.359 $ $NHDT-Date: 1606008997 2020/11/22 01:36:37 $
General Fixes and Modified Features
-----------------------------------
@@ -303,6 +303,8 @@ since ki-rin look quite a bit like unicorns, make them be more like one:
wand or scroll of create monster that makes a new monster which can be seen
or sensed becomes discovered but was doing so even for a concealed
mimic seen as furniture or an object
'showscore' could be used to determine how much gold was inside a container
whose contents were unknown
Fixes to 3.7.0-x Problems that Were Exposed Via git Repository

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 extern.h $NHDT-Date: 1605493683 2020/11/16 02:28:03 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.878 $ */
/* NetHack 3.7 extern.h $NHDT-Date: 1606008997 2020/11/22 01:36:37 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.880 $ */
/* Copyright (c) Steve Creps, 1988. */
/* NetHack may be freely redistributed. See license for details. */
@@ -2396,7 +2396,7 @@ E void NDECL(finish_paybill);
E struct obj *FDECL(find_oid, (unsigned));
E long FDECL(contained_cost,
(struct obj *, struct monst *, long, BOOLEAN_P, BOOLEAN_P));
E long FDECL(contained_gold, (struct obj *));
E long FDECL(contained_gold, (struct obj *, BOOLEAN_P));
E void FDECL(picked_container, (struct obj *));
E void FDECL(gem_learned, (int));
E void FDECL(alter_cost, (struct obj *, long));
@@ -2823,7 +2823,7 @@ E void FDECL(uleftvault, (struct monst *));
E void NDECL(invault);
E int FDECL(gd_move, (struct monst *));
E void FDECL(paygd, (BOOLEAN_P));
E long NDECL(hidden_gold);
E long FDECL(hidden_gold, (BOOLEAN_P));
E boolean NDECL(gd_sound);
E void FDECL(vault_gd_watching, (unsigned int));

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 botl.c $NHDT-Date: 1596498152 2020/08/03 23:42:32 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.191 $ */
/* NetHack 3.7 botl.c $NHDT-Date: 1606008998 2020/11/22 01:36:38 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.192 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2006. */
/* NetHack may be freely redistributed. See license for details. */
@@ -398,7 +398,8 @@ botl_score()
long deepest = deepest_lev_reached(FALSE);
long utotal;
utotal = money_cnt(g.invent) + hidden_gold();
/* hidden_gold(False): only gold in containers whose contents are known */
utotal = money_cnt(g.invent) + hidden_gold(FALSE);
if ((utotal -= u.umoney0) < 0L)
utotal = 0L;
utotal += u.urexp + (50 * (deepest - 1))

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 detect.c $NHDT-Date: 1596498155 2020/08/03 23:42:35 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.121 $ */
/* NetHack 3.7 detect.c $NHDT-Date: 1606009000 2020/11/22 01:36:40 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.123 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2018. */
/* NetHack may be freely redistributed. See license for details. */
@@ -357,7 +357,7 @@ register struct obj *sobj;
if (g.youmonst.data == &mons[PM_GOLD_GOLEM])
Sprintf(buf, "You feel like a million %s!", currency(2L));
else if (money_cnt(g.invent) || hidden_gold())
else if (money_cnt(g.invent) || hidden_gold(TRUE))
Strcpy(buf,
"You feel worried about your future financial situation.");
else if (steedgold)

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 dokick.c $NHDT-Date: 1596498160 2020/08/03 23:42:40 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.155 $ */
/* NetHack 3.7 dokick.c $NHDT-Date: 1606009001 2020/11/22 01:36:41 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.159 $ */
/* Copyright (c) Izchak Miller, Mike Stephenson, Steve Linhart, 1989. */
/* NetHack may be freely redistributed. See license for details. */
@@ -341,14 +341,12 @@ register struct obj *gold;
out of the vault. If he did do that, player
could try fighting, then weasle out of being
killed by throwing his/her gold when losing. */
verbalize(
umoney
? "Drop the rest and follow me."
: hidden_gold()
? "You still have hidden gold. Drop it now."
: mtmp->mpeaceful
? "I'll take care of that; please move along."
: "I'll take that; now get moving.");
verbalize(umoney ? "Drop the rest and follow me."
: hidden_gold(TRUE)
? "You still have hidden gold. Drop it now."
: mtmp->mpeaceful
? "I'll take care of that; please move along."
: "I'll take that; now get moving.");
} else if (is_mercenary(mtmp->data)) {
long goldreqd = 0L;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 end.c $NHDT-Date: 1603534633 2020/10/24 10:17:13 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.214 $ */
/* NetHack 3.7 end.c $NHDT-Date: 1606009001 2020/11/22 01:36:41 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.215 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1382,8 +1382,8 @@ int how;
umoney = money_cnt(g.invent);
tmp = u.umoney0;
umoney += hidden_gold(); /* accumulate gold from containers */
tmp = umoney - tmp; /* net gain */
umoney += hidden_gold(TRUE); /* accumulate gold from containers */
tmp = umoney - tmp; /* net gain */
if (tmp < 0L)
tmp = 0L;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 shk.c $NHDT-Date: 1596498208 2020/08/03 23:43:28 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.189 $ */
/* NetHack 3.7 shk.c $NHDT-Date: 1606009003 2020/11/22 01:36:43 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.191 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1245,7 +1245,7 @@ dopay()
long ltmp;
long umoney;
int pass, tmp, sk = 0, seensk = 0;
boolean paid = FALSE, stashed_gold = (hidden_gold() > 0L);
boolean paid = FALSE, stashed_gold = (hidden_gold(TRUE) > 0L);
g.multi = 0;
@@ -1595,7 +1595,8 @@ boolean itemize;
long ltmp, quan, save_quan;
long umoney = money_cnt(g.invent);
int buy;
boolean stashed_gold = (hidden_gold() > 0L), consumed = (which == 0);
boolean stashed_gold = (hidden_gold(TRUE) > 0L),
consumed = (which == 0);
if (!obj->unpaid && !bp->useup) {
impossible("Paid object on bill??");
@@ -2226,8 +2227,9 @@ boolean unpaid_only;
/* count amount of gold inside container 'obj' and any nested containers */
long
contained_gold(obj)
contained_gold(obj, even_if_unknown)
struct obj *obj;
boolean even_if_unknown; /* True: all gold; False: limit to known contents */
{
register struct obj *otmp;
register long value = 0L;
@@ -2236,8 +2238,8 @@ struct obj *obj;
for (otmp = obj->cobj; otmp; otmp = otmp->nobj)
if (otmp->oclass == COIN_CLASS)
value += otmp->quan;
else if (Has_contents(otmp))
value += contained_gold(otmp);
else if (Has_contents(otmp) && (otmp->cknown || even_if_unknown))
value += contained_gold(otmp, even_if_unknown);
return value;
}
@@ -2611,7 +2613,7 @@ boolean reset_nocharge;
/* outer container might be marked no_charge but still have contents
which should be charged for; clear no_charge when picking things up */
if (obj->no_charge) {
if (!Has_contents(obj) || (contained_gold(obj) == 0L
if (!Has_contents(obj) || (contained_gold(obj, TRUE) == 0L
&& contained_cost(obj, shkp, 0L, FALSE,
!reset_nocharge) == 0L))
shkp = 0; /* not billable */
@@ -2661,7 +2663,7 @@ boolean ininv, dummy, silent;
if (container) {
cltmp = contained_cost(obj, shkp, cltmp, FALSE, FALSE);
gltmp = contained_gold(obj);
gltmp = contained_gold(obj, TRUE);
if (ltmp)
add_one_tobill(obj, dummy, shkp);
@@ -2936,7 +2938,7 @@ boolean peaceful, silent;
value += stolen_container(obj, shkp, 0L, ininv);
if (!ininv)
gvalue += contained_gold(obj);
gvalue += contained_gold(obj, TRUE);
}
}
@@ -3043,7 +3045,7 @@ xchar x, y;
/* find the price of content before subfrombill */
cltmp = contained_cost(obj, shkp, cltmp, TRUE, FALSE);
/* find the value of contained gold */
gltmp += contained_gold(obj);
gltmp += contained_gold(obj, TRUE);
cgold = (gltmp > 0L);
}

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 topten.c $NHDT-Date: 1596498218 2020/08/03 23:43:38 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.73 $ */
/* NetHack 3.7 topten.c $NHDT-Date: 1606009004 2020/11/22 01:36:44 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.74 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
@@ -374,7 +374,8 @@ int how;
genders[flags.initgend].filecode, XLOG_SEP,
aligns[1 - u.ualignbase[A_ORIGINAL]].filecode);
Fprintf(rfile, "%cflags=0x%lx", XLOG_SEP, encodexlogflags());
Fprintf(rfile, "%cgold=%ld", XLOG_SEP, money_cnt(g.invent) + hidden_gold());
Fprintf(rfile, "%cgold=%ld", XLOG_SEP,
money_cnt(g.invent) + hidden_gold(TRUE));
Fprintf(rfile, "%cwish_cnt=%ld", XLOG_SEP, u.uconduct.wishes);
Fprintf(rfile, "%carti_wish_cnt=%ld", XLOG_SEP, u.uconduct.wisharti);
Fprintf(rfile, "\n");

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 u_init.c $NHDT-Date: 1596498222 2020/08/03 23:43:42 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.70 $ */
/* NetHack 3.7 u_init.c $NHDT-Date: 1606009005 2020/11/22 01:36:45 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.72 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2017. */
/* NetHack may be freely redistributed. See license for details. */
@@ -876,7 +876,7 @@ u_init()
if (u.umoney0)
ini_inv(Money);
u.umoney0 += hidden_gold(); /* in case sack has gold in it */
u.umoney0 += hidden_gold(TRUE); /* in case sack has gold in it */
find_ac(); /* get initial ac value */
init_attr(75); /* init attribute values */

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 vault.c $NHDT-Date: 1596498223 2020/08/03 23:43:43 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.76 $ */
/* NetHack 3.7 vault.c $NHDT-Date: 1606009006 2020/11/22 01:36:46 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.77 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2011. */
/* NetHack may be freely redistributed. See license for details. */
@@ -249,7 +249,7 @@ struct monst *grd;
}
/* if carrying gold and arriving anywhere other than next to the guard,
set the guard loose */
if ((money_cnt(g.invent) || hidden_gold())
if ((money_cnt(g.invent) || hidden_gold(TRUE))
&& um_dist(grd->mx, grd->my, 1)) {
if (grd->mpeaceful) {
if (canspotmon(grd)) /* see or sense via telepathy */
@@ -487,7 +487,7 @@ invault()
else
verbalize("I don't know you.");
umoney = money_cnt(g.invent);
if (!umoney && !hidden_gold()) {
if (!umoney && !hidden_gold(TRUE)) {
if (Deaf)
pline("%s stomps%s.", noit_Monnam(guard),
(Blind) ? "" : " and beckons");
@@ -795,7 +795,7 @@ register struct monst *grd;
}
umoney = money_cnt(g.invent);
u_carry_gold = umoney > 0L || hidden_gold() > 0L;
u_carry_gold = (umoney > 0L || hidden_gold(TRUE) > 0L);
if (egrd->fcend == 1) {
if (u_in_vault && (u_carry_gold || um_dist(grd->mx, grd->my, 1))) {
if (egrd->warncnt == 3 && !Deaf)
@@ -1107,15 +1107,17 @@ boolean silently;
return;
}
/* amount of gold in carried containers */
long
hidden_gold()
hidden_gold(even_if_unknown)
boolean even_if_unknown; /* True: all gold; False: limit to known contents */
{
long value = 0L;
struct obj *obj;
for (obj = g.invent; obj; obj = obj->nobj)
if (Has_contents(obj))
value += contained_gold(obj);
if (Has_contents(obj) && (obj->cknown || even_if_unknown))
value += contained_gold(obj, even_if_unknown);
/* unknown gold stuck inside statues may cause some consternation... */
return value;