report ice's thaw state

Classify nearby ice as "solid" (no melt timer), "sturdy" (more than
1000 turns left), "steady" (101 to 1000 turns left), "unsteady" (51
to 100 turns left), "thin" (15 to 50 turns left), or "slushy" (1 to
14 turns left, matching walking on ice with the Warning attribute).
[I'm not thrilled with "steady" and particularly "unsteady".]

I was originally going to do this just for probing downward, but ended
up also doing it for look-here and getpos's autodescribe.  It nearly
got out of hand and touched more files than anticipated.

'mention_decor' ought to treat moving from ice firmer than thin to
thin or slushy, from thin to slushy, from slushy to any other, and
from thin to firmer as if moving onto different terrain but I haven't
attempted to tackle that.

The melt timer could work more like a candle's burn timer, triggering
at intermediate stages and resetting itself, so that ice which changes
to a weaker state under the hero could be reported to the player.  But
this doesn't implement that.
This commit is contained in:
PatR
2023-10-25 13:26:03 -07:00
parent 7bf3888118
commit 04d6789c98
10 changed files with 156 additions and 44 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 pager.c $NHDT-Date: 1655120486 2022/06/13 11:41:26 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.225 $ */
/* NetHack 3.7 pager.c $NHDT-Date: 1698264788 2023/10/25 20:13:08 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.252 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2018. */
/* NetHack may be freely redistributed. See license for details. */
@@ -482,16 +482,12 @@ const char *
waterbody_name(coordxy x, coordxy y)
{
static char pooltype[40];
struct rm *lev;
schar ltyp;
boolean hallucinate = Hallucination && !gp.program_state.gameover;
if (!isok(x, y))
return "drink"; /* should never happen */
lev = &levl[x][y];
ltyp = lev->typ;
if (ltyp == DRAWBRIDGE_UP)
ltyp = db_under_typ(lev->drawbridgemask);
ltyp = SURFACE_AT(x, y);
if (ltyp == LAVAPOOL) {
Snprintf(pooltype, sizeof pooltype, "molten %s", hliquid("lava"));
@@ -535,6 +531,43 @@ waterbody_name(coordxy x, coordxy y)
return "water"; /* don't hallucinate this as some other liquid */
}
const char *
ice_descr(coordxy x, coordxy y, char *outbuf)
{
static const char *const icetyp[] = {
"solid", /* 0: not melting */
"sturdy", /* 1: more than 1000 turns left */
"steady", /* 2: 101..1000 turns left */
"unsteady", /* 3: 51..100 turns left */
"thin", /* 4: 15..50 turns left */
"slushy", /* 5: 1..14 turns left; matches Warning on ice */
};
/* same formula as is used in distant_name() for objects */
int r = (u.xray_range > 2) ? u.xray_range : 2,
neardist = (r * r) * 2 - r; /* same as r*r + r*(r-1) */
iflags.ice_rating = -1; /* secondary output, for ' mention_decor' */
if (levl[x][y].typ != ICE) {
Sprintf(outbuf, "[ice:%d?]", (int) levl[x][y].typ);
} else if ((distu(x, y) > neardist
|| (!cansee(x, y) && (!u_at(x, y) || Levitation)))
&& !gd.decor_levitate_override) { /* probe_decor(pickup.c) */
Strcpy(outbuf, waterbody_name(x, y)); /* "ice" or "frozen <liquid>" */
} else {
long time_left = spot_time_left(x, y, MELT_ICE_AWAY);
iflags.ice_rating = !time_left ? 0 /* solid */
: (time_left > 1000L) ? 1 /* sturdy */
: (time_left > 100L) ? 2 /* steady */
: (time_left > 50L) ? 3 /* unsteady */
: (time_left > 14L) ? 4 /* thin */
: 5; /* slushy */
Sprintf(outbuf, "%s %s", icetyp[(int) iflags.ice_rating],
waterbody_name(x, y));
}
return outbuf;
}
/*
* Return the name of the glyph found at (x,y).
* If not hallucinating and the glyph is a monster, also monster data.
@@ -1442,6 +1475,8 @@ do_screen_description(
pm = lookat(cc.x, cc.y, look_buf, monbuf);
if (pm && for_supplement)
*for_supplement = pm;
if (!strcmp(look_buf, "ice"))
(void) ice_descr(cc.x, cc.y, look_buf);
if (look_buf[0] != '\0')
*firstmatch = look_buf;