]> granicus.if.org Git - nethack/commitdiff
rest/search refinement
authorPatR <rankin@nethack.org>
Mon, 13 Apr 2020 21:58:12 +0000 (14:58 -0700)
committerPatR <rankin@nethack.org>
Mon, 13 Apr 2020 21:58:12 +0000 (14:58 -0700)
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.

include/decl.h
src/decl.c
src/detect.c
src/do.c

index 615d26e4efdf00527928fc5d3f625d75c5e00999..f9d57e774e83486215131885d1bd84d8961c5744 100644 (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;
index 112ba9549fbd92c7a42f1e198f102b9ed58905d3..28b501d348bc716db451230225dc39eb13ac5678 100644 (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 */
index bc5c6e9e0a248dc3479eb85c75d35963dc9e763a..3c5d87f43cfc6fa36871e144e4a3b7a9a4f8958f 100644 (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);
 }
 
index d8075f790cf305abe70da960d9e0c81d1eadbd26..15b43397e922f47d6703cd0bcb71e45184bf1f3a 100644 (file)
--- a/src/do.c
+++ b/src/do.c
@@ -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 */
 }