From: Pasi Kallinen Date: Fri, 2 Oct 2020 15:50:19 +0000 (+0300) Subject: Add safe_wait to toggle search and wait prevention X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=396b819988c1bf2af9be8a16596c0d28f6f98eb4;p=nethack Add safe_wait to toggle search and wait prevention --- diff --git a/doc/Guidebook.mn b/doc/Guidebook.mn index a73b5dc8e..5dc432bd2 100644 --- a/doc/Guidebook.mn +++ b/doc/Guidebook.mn @@ -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. diff --git a/doc/Guidebook.tex b/doc/Guidebook.tex index 16b662884..689266954 100644 --- a/doc/Guidebook.tex +++ b/doc/Guidebook.tex @@ -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). diff --git a/doc/fixes37.0 b/doc/fixes37.0 index d5b868888..b5dae5e94 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -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 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 diff --git a/include/extern.h b/include/extern.h index 7e4af0781..101293ab7 100644 --- a/include/extern.h +++ b/include/extern.h @@ -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)); diff --git a/include/flag.h b/include/flag.h index ddb86720d..5a0f0213e 100644 --- a/include/flag.h +++ b/include/flag.h @@ -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 */ diff --git a/include/optlist.h b/include/optlist.h index 085b527b1..c8d4f28e8 100644 --- a/include/optlist.h +++ b/include/optlist.h @@ -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, diff --git a/src/detect.c b/src/detect.c index 3fa2ae9ca..29acd7a18 100644 --- a/src/detect.c +++ b/src/detect.c @@ -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); } diff --git a/src/do.c b/src/do.c index 6aaee1407..3156e5132 100644 --- 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 */ }