]> granicus.if.org Git - nethack/commitdiff
Add safe_wait to toggle search and wait prevention
authorPasi Kallinen <paxed@alt.org>
Fri, 2 Oct 2020 15:50:19 +0000 (18:50 +0300)
committerPasi Kallinen <paxed@alt.org>
Fri, 2 Oct 2020 16:00:40 +0000 (19:00 +0300)
doc/Guidebook.mn
doc/Guidebook.tex
doc/fixes37.0
include/extern.h
include/flag.h
include/optlist.h
src/detect.c
src/do.c

index a73b5dc8e501321f1f351e66330307a44d1fa4d1..5dc432bd2462bd223e18831a0d74e2f869e59dfe 100644 (file)
@@ -675,7 +675,9 @@ support, the command is also invoked when a mouse-click takes place on a
 location other than the current position.
 .lp .
 Wait or rest, do nothing for one turn. Precede with the \(oqm\(cq prefix
-to wait for a turn even next to a hostile monster.
+to wait for a turn even next to a hostile monster, if
+.op safe_wait
+is on.
 .lp a
 Apply (use) a tool (pick-axe, key, lamp...).
 .lp ""
@@ -884,7 +886,9 @@ Redraw the screen.
 Search for secret doors and traps around you.
 It usually takes several tries to find something.
 Precede with the \(oqm\(cq prefix to search for a turn
-even next to a hostile monster.
+even next to a hostile monster, if
+.op safe_wait
+is on.
 .lp ""
 Can also be used to figure out whether there is still a monster at
 an adjacent \(lqremembered, unseen monster\(rq marker.
@@ -3987,6 +3991,9 @@ Persistent.
 .lp safe_pet
 Prevent you from (knowingly) attacking your pets (default on).
 Persistent.
+.lp safe_wait
+Prevents you from waiting or searching when next to a hostile monster
+(default on). Persistent.
 .lp sanity_check
 Evaluate monsters, objects, and map prior to each turn (default off).
 Debug mode only.
index 16b6628846101fe8db327e481dc8bb89687a3ef2..689266954dd80f9dd06e6211d37b0e4e22fa3888 100644 (file)
@@ -769,7 +769,8 @@ location other than the current position.
 %.lp
 \item[\tb{.}]
 Wait or rest, do nothing for one turn. Precede with the `{\tt m}' prefix
-to wait for a turn even next to a hostile monster.
+to wait for a turn even next to a hostile monster, if {\it safe\verb+_+wait\/}
+is on.
 %.lp
 \item[\tb{a}]
 Apply (use) a tool (pick-axe, key, lamp \ldots).\\
@@ -968,7 +969,8 @@ Redraw the screen.
 Search for secret doors and traps around you.
 It usually takes several tries to find something.
 Precede with the `{\tt m}' prefix to wait for a turn
-even next to a hostile monster.\\
+even next to a hostile monster, if {\it safe\verb+_+wait\/}
+is on.\\
 %.lp ""
 Can also be used to figure out whether there is still a monster at
 an adjacent ``remembered, unseen monster'' marker.
@@ -4307,6 +4309,10 @@ depend upon the window port used or on the type of terminal.  Persistent.
 %.lp
 \item[\ib{safe\verb+_+pet}]
 Prevent you from (knowingly) attacking your pets (default on).  Persistent.
+%.lp
+\item[\ib{safe\verb+_+wait}]
+Prevents you from waiting or searching when next to a hostile monster
+(default on).  Persistent.
 %+.lp
 \item[\ib{sanity\verb+_+check}]
 Evaluate monsters, objects, and map prior to each turn (default off).
index d5b86888802c960944152a47d5a18e427bcbf72d..b5dae5e94ab95721dc5c8b3b019b6a63efdc0207 100644 (file)
@@ -126,7 +126,8 @@ it's possible to wish for tins of the Riders in wizard mode; eating one is
        fatal but if you're life-saved or decline to die, the game crashed
 revival via undead turning of corpse carried by hero said "your <mon> corpse
        comes alive" even when revived monster was undead
-prevent searching or waiting next to a hostile monster - override with 'm'
+prevent searching or waiting next to a hostile monster if boolean option
+       safe_wait is on - override with 'm'
 allow random mimics to show up mimicing more furniture than just stairs
 scatter exploding bag of holding contents instead of outright deleting them
 male hero poly'd into nymph chooses charm vs seduce message based on being
index 7e4af0781d528f99f4124c5a33b0416b4da0b227..101293ab794420517ce1396d4f50fcb28dc3bb1e 100644 (file)
@@ -424,6 +424,7 @@ E void FDECL(schedule_goto, (d_level *, BOOLEAN_P, BOOLEAN_P, int,
 E void NDECL(deferred_goto);
 E boolean FDECL(revive_corpse, (struct obj *));
 E void FDECL(revive_mon, (ANY_P *, long));
+E boolean FDECL(cmd_safety_prevention, (char *, char *, int *));
 E int NDECL(donull);
 E int NDECL(dowipe);
 E void FDECL(legs_in_no_shape, (const char *, BOOLEAN_P));
index ddb86720d4709cdf96569929bc14f5dc015c0e02..5a0f0213e0fad116a668bd2f2b0f9c492999b549 100644 (file)
@@ -52,6 +52,7 @@ struct flag {
                               * clairvoyance */
     boolean rest_on_space;   /* space means rest */
     boolean safe_dog;        /* give complete protection to the dog */
+    boolean safe_wait;       /* prevent wait or search next to hostile */
     boolean showexp;         /* show experience points */
     boolean showscore;       /* show score */
     boolean silent;          /* whether the bell rings or not */
index 085b527b1d7544ba53e939004f08947d499578eb..c8d4f28e8c3261d886d37b6ab2cc02c0efc42991 100644 (file)
@@ -379,6 +379,8 @@ pfx_##a,
                 NoAlias, "display frequency when `running' or `travelling'")
     NHOPTB(safe_pet, 0, opt_out, set_in_game, On, Yes, No, No, NoAlias,
                 &flags.safe_dog)
+    NHOPTB(safe_wait, 0, opt_out, set_in_game, On, Yes, No, No, NoAlias,
+                &flags.safe_wait)
     NHOPTB(sanity_check, 0, opt_in, set_wizonly, Off, Yes, No, No, NoAlias,
                 &iflags.sanity_check)
     NHOPTC(scores, 32, opt_in, set_in_game, No, Yes, No, No, NoAlias,
index 3fa2ae9ca008a5e5d3f1ab553758377ea7a8f191..29acd7a18676f2360ab4595179e61fe2a7909d6b 100644 (file)
@@ -1868,17 +1868,10 @@ register int aflag; /* intrinsic autosearch vs explicit searching */
 int
 dosearch()
 {
-    if (!iflags.menu_requested && !g.multi && monster_nearby()) {
-        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);
+    if (cmd_safety_prevention("another search",
+                          "You already found a monster.",
+                          &g.already_found_flag))
         return 0;
-    }
-    g.already_found_flag = 0; /* start over */
     return dosearch0(0);
 }
 
index 6aaee14074f21f2bee2110ca7be82396a3da3d3e..3156e5132c9105595ea20c4e9cab4d9e731d820c 100644 (file)
--- a/src/do.c
+++ b/src/do.c
@@ -1982,22 +1982,36 @@ long timeout UNUSED;
     }
 }
 
+boolean
+cmd_safety_prevention(cmddesc, act, flagcounter)
+char *cmddesc;
+char *act;
+int *flagcounter;
+{
+    if (flags.safe_wait && !iflags.menu_requested
+        && !g.multi && monster_nearby()) {
+        char buf[QBUFSZ];
+
+        buf[0] = '\0';
+        if (iflags.cmdassist || !*flagcounter++)
+            Sprintf(buf, "  Use '%s' prefix to force %s.",
+                    visctrl(g.Cmd.spkeys[NHKF_REQMENU]), cmddesc);
+        Norep("%s%s", act, buf);
+        return TRUE;
+    }
+    *flagcounter = 0;
+    return FALSE;
+}
+
 /* '.' command: do nothing == rest; also the
    ' ' command iff 'rest_on_space' option is On */
 int
 donull()
 {
-    if (!iflags.menu_requested && !g.multi && monster_nearby()) {
-        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);
+    if (cmd_safety_prevention("a no-op (to rest)",
+                          "Are you waiting to get hit?",
+                          &g.did_nothing_flag))
         return 0;
-    }
-    g.did_nothing_flag = 0; /* reset */
     return 1; /* Do nothing, but let other things happen */
 }