more trap feedback

When trapped in lava, change the text from "stuck in the lava" to
"sinking into lava" to describe the situation much more accurately.
Instead of doing that twice, move the u.utraptype feedback into a
separate routine that both enlightenment and self-lookat can use.
This commit is contained in:
PatR
2020-01-10 06:53:48 -08:00
parent 3a6e2a9802
commit a4e80fa9b4
3 changed files with 46 additions and 30 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 extern.h $NHDT-Date: 1578297243 2020/01/06 07:54:03 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.781 $ */
/* NetHack 3.6 extern.h $NHDT-Date: 1578668018 2020/01/10 14:53:38 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.782 $ */
/* Copyright (c) Steve Creps, 1988. */
/* NetHack may be freely redistributed. See license for details. */
@@ -231,6 +231,7 @@ E void FDECL(rhack, (char *));
E int NDECL(doextlist);
E int NDECL(extcmd_via_menu);
E int NDECL(enter_explore_mode);
E char *FDECL(trap_predicament, (char *, BOOLEAN_P));
E void FDECL(enlightenment, (int, int));
E void FDECL(youhiding, (BOOLEAN_P, int));
E void FDECL(show_conduct, (int));

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 cmd.c $NHDT-Date: 1576201761 2019/12/13 01:49:21 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.383 $ */
/* NetHack 3.6 cmd.c $NHDT-Date: 1578668021 2020/01/10 14:53:41 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.390 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2013. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1811,6 +1811,42 @@ walking_on_water()
&& (is_pool(u.ux, u.uy) || is_lava(u.ux, u.uy)));
}
/* describe u.utraptype; used by status_enlightenment() and self_lookat() */
char *
trap_predicament(outbuf, wizxtra)
char *outbuf;
boolean wizxtra;
{
struct trap *t;
/* caller has verified u.utrap */
*outbuf = '\0';
switch (u.utraptype) {
case TT_BURIEDBALL:
Strcpy(outbuf, "tethered to something buried");
break;
case TT_LAVA:
/* surface() should always yield "lava" here unless hallucinatory
surfaces get added someday [please don't...] */
Sprintf(outbuf, "sinking into %s", surface(u.ux, u.uy));
break;
case TT_INFLOOR:
Sprintf(outbuf, "stuck in %s", the(surface(u.ux, u.uy)));
break;
default: /* TT_BEARTRAP, TT_PIT, or TT_WEB */
Strcpy(outbuf, "trapped");
if ((t = t_at(u.ux, u.uy)) != 0) /* should never be null */
Sprintf(eos(outbuf), " in %s", an(trapname(t->ttyp, FALSE)));
break;
}
if (wizxtra) { /* give extra information for wizard mode enlightenment */
/* curly braces: u.utrap is an escape attempt counter rather than a
turn timer so use different ornamentation than usual parentheses */
Sprintf(eos(outbuf), " {%u}", u.utrap);
}
return outbuf;
}
/* check whether hero is wearing something that player definitely knows
confers the target property; item must have been seen and its type
discovered but it doesn't necessarily have to be fully identified */
@@ -1921,7 +1957,8 @@ int final;
/* note that if poly'd, we need to use u.mfemale instead of flags.female
to access hero's saved gender-as-human/elf/&c rather than current one */
innategend = (Upolyd ? u.mfemale : flags.female) ? 1 : 0;
role_titl = (innategend && g.urole.name.f) ? g.urole.name.f : g.urole.name.m;
role_titl = (innategend && g.urole.name.f) ? g.urole.name.f
: g.urole.name.m;
rank_titl = rank_of(u.ulevel, Role_switch, innategend);
enlght_out(""); /* separator after title */
@@ -2508,19 +2545,9 @@ int final;
}
if (u.utrap) {
char predicament[BUFSZ];
struct trap *t;
boolean anchored = (u.utraptype == TT_BURIEDBALL);
if (anchored) {
Strcpy(predicament, "tethered to something buried");
} else if (u.utraptype == TT_INFLOOR || u.utraptype == TT_LAVA) {
Sprintf(predicament, "stuck in %s", the(surface(u.ux, u.uy)));
} else {
Strcpy(predicament, "trapped");
if ((t = t_at(u.ux, u.uy)) != 0)
Sprintf(eos(predicament), " in %s",
an(trapname(t->ttyp, FALSE)));
}
(void) trap_predicament(predicament, wizard);
if (u.usteed) { /* not `Riding' here */
Sprintf(buf, "%s%s ", anchored ? "you and " : "", steedname);
*buf = highc(*buf);

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 pager.c $NHDT-Date: 1578617964 2020/01/10 00:59:24 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.180 $ */
/* NetHack 3.6 pager.c $NHDT-Date: 1578668022 2020/01/10 14:53:42 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.181 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2018. */
/* NetHack may be freely redistributed. See license for details. */
@@ -77,7 +77,7 @@ char *
self_lookat(outbuf)
char *outbuf;
{
char race[QBUFSZ];
char race[QBUFSZ], trapbuf[QBUFSZ];
/* include race with role unless polymorphed */
race[0] = '\0';
@@ -94,20 +94,8 @@ char *outbuf;
if (Punished)
Sprintf(eos(outbuf), ", chained to %s",
uball ? ansimpleoname(uball) : "nothing?");
if (u.utrap) {
if (u.utraptype == TT_BURIEDBALL) {
Strcat(outbuf, ", tethered to something buried");
} else if (u.utraptype == TT_INFLOOR || u.utraptype == TT_LAVA) {
Sprintf(eos(outbuf), ", stuck in %s", the(surface(u.ux, u.uy)));
} else { /* bear trap, [spiked] pit, or web */
struct trap *t = t_at(u.ux, u.uy);
Strcat(outbuf, ", trapped");
if (t)
Sprintf(eos(outbuf), " in %s",
an(trapname(t->ttyp, FALSE)));
}
}
if (u.utrap) /* bear trap, pit, web, in-floor, in-lava, tethered */
Sprintf(eos(outbuf), ", %s", trap_predicament(trapbuf, FALSE));
return outbuf;
}