rest/search refinement

When rest and search refuse to operate because a hostile monster is
adjacent, include a reminder of how to force them to operate.  Every
time if 'cmdassist' is On, or just once until after some subsequent
try actually does something.

This new rest and search behavior probably needs to be optional and
default to the old behavior.  It isn't uncommon to deliberately rest
while adjacent to a hostile monster if also adjacent to a peaceful
one and trying to wait for Stun or Confusion to time out, or maybe
search while next to such a monster hoping to find a secret door to
run away through.  A count prefix won't work and needing an extra
keystroke each time is going to be an annoyance.
This commit is contained in:
PatR
2020-04-13 14:58:12 -07:00
parent 124d39f4c5
commit caac70c5ec
4 changed files with 32 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 decl.h $NHDT-Date: 1583608809 2020/03/07 19:20:09 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.228 $ */
/* NetHack 3.6 decl.h $NHDT-Date: 1586815081 2020/04/13 21:58:01 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.230 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2007. */
/* NetHack may be freely redistributed. See license for details. */
@@ -814,6 +814,10 @@ struct instance_globals {
#endif
struct sinfo program_state;
/* detect.c */
int already_found_flag; /* used to augment first "already found a monster"
* message if 'cmdassist' is Off */
/* dig.c */
boolean did_dig_msg;
@@ -828,7 +832,8 @@ struct instance_globals {
boolean at_ladder;
char *dfr_pre_msg; /* pline() before level change */
char *dfr_post_msg; /* pline() after level change */
d_level save_dlevel;
int did_nothing_flag; /* to augment the no-rest-next-to-monster message */
d_level save_dlevel; /* ? [even back in 3.4.3, only used in bones.c] */
/* do_name.c */
struct selectionvar *gloc_filter_map;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 decl.c $NHDT-Date: 1583608833 2020/03/07 19:20:33 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.208 $ */
/* NetHack 3.6 decl.c $NHDT-Date: 1586815084 2020/04/13 21:58:04 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.209 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2009. */
/* NetHack may be freely redistributed. See license for details. */
@@ -357,6 +357,9 @@ const struct instance_globals g_init = {
#endif
UNDEFINED_VALUES, /* program_state */
/* detect.c */
0, /* already_found_flag */
/* dig.c */
UNDEFINED_VALUE, /* did_dig_msg */
@@ -369,6 +372,7 @@ const struct instance_globals g_init = {
FALSE, /* at_ladder */
NULL, /* dfr_pre_msg */
NULL, /* dfr_post_msg */
0, /* did_nothing_flag */
{ 0, 0 }, /* save_dlevel */
/* do_name.c */

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 detect.c $NHDT-Date: 1578252630 2020/01/05 19:30:30 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.114 $ */
/* NetHack 3.6 detect.c $NHDT-Date: 1586815085 2020/04/13 21:58:05 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.118 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2018. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1783,9 +1783,16 @@ int
dosearch()
{
if (!iflags.menu_requested && !g.multi && monster_nearby()) {
Norep("You already found a monster.");
char buf[QBUFSZ];
buf[0] = '\0';
if (iflags.cmdassist || !g.already_found_flag++)
Sprintf(buf, " Use '%s' prefix to force another search.",
visctrl(g.Cmd.spkeys[NHKF_REQMENU])); /* default is "m" */
Norep("You already found a monster.%s", buf);
return 0;
}
g.already_found_flag = 0; /* start over */
return dosearch0(0);
}

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 do.c $NHDT-Date: 1586285681 2020/04/07 18:54:41 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.235 $ */
/* NetHack 3.6 do.c $NHDT-Date: 1586815086 2020/04/13 21:58:06 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.237 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1967,14 +1967,22 @@ long timeout UNUSED;
}
}
/* '.' command: do nothing == rest; also the
' ' command iff 'rest_on_space' option is On */
int
donull()
{
if (!iflags.menu_requested && !g.multi && monster_nearby()) {
Norep("Are you waiting to get hit?");
char buf[QBUFSZ];
buf[0] = '\0';
if (iflags.cmdassist || !g.did_nothing_flag++)
Sprintf(buf, " Use '%s' prefix to force a no-op (to rest).",
visctrl(g.Cmd.spkeys[NHKF_REQMENU])); /* default is "m" */
Norep("Are you waiting to get hit?%s", buf);
return 0;
}
g.did_nothing_flag = 0; /* reset */
return 1; /* Do nothing, but let other things happen */
}