From: Pasi Kallinen Date: Mon, 31 Jul 2017 16:10:26 +0000 (+0300) Subject: Add way to cycle through valid locations for polearm or jump target X-Git-Tag: NetHack-3.6.1_RC01~443 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b13bae91dc14157d6a38f7d09250c973389bceb5;p=nethack Add way to cycle through valid locations for polearm or jump target --- diff --git a/doc/Guidebook.mn b/doc/Guidebook.mn index 0de4d48e2..7b70d6dfa 100644 --- a/doc/Guidebook.mn +++ b/doc/Guidebook.mn @@ -3279,6 +3279,10 @@ When asked for a location, the key to go to next closest unexplored location. De When asked for a location, the key to go to previous closest unexplored location. Default is 'X'. .lp getpos.valid When asked for a location, the key to go to show valid target locations. Default is '$'. +.lp getpos.valid.next +When asked for a location, the key to go to next closest valid location. Default is 'z'. +.lp getpos.valid.prev +When asked for a location, the key to go to previous closest valid location. Default is 'Z'. .lp nopickup Prefix key to move without picking up items. Default is 'm'. .lp redraw diff --git a/doc/Guidebook.tex b/doc/Guidebook.tex index c33e5b095..7162b909c 100644 --- a/doc/Guidebook.tex +++ b/doc/Guidebook.tex @@ -4018,6 +4018,12 @@ When asked for a location, the key to go to previous closest unexplored location \item{\bb{getpos.valid}} When asked for a location, the key to go to show valid target locations. Default is ``{\tt \$}''. %.lp +\item{\bb{getpos.valid.next}} +When asked for a location, the key to go to next closest valid location. Default is ``{\tt z}''. +%.lp +\item{\bb{getpos.valid.prev}} +When asked for a location, the key to go to previous closest valid location. Default is ``{\tt Z}''. +%.lp \item{\bb{nopickup}} Prefix key to move without picking up items. Default is ``{\tt m}''. %.lp diff --git a/doc/fixes36.1 b/doc/fixes36.1 index 518d16b33..73803752a 100644 --- a/doc/fixes36.1 +++ b/doc/fixes36.1 @@ -592,6 +592,10 @@ random horses have a tiny chance of being generated saddled give feedback just before timed levitation runs out travel accepts 'm' (request menu) prefix pressing a or A when cursor positioning shows menu of "interesting" features +pressing z or Z when cursor positioning cycles through valid locations for + jumping, hitting with polearm, or casting a stinking cloud +when moving a cursor for a jump, polearm, or stinking cloud targeting, show + if the location is illegal, if "autodescribe" is on wizard-mode command #wizmakemap to recreate the current level 'goldX' boolean option to treat gold pieces as X (vs U) during BUCX filtering (should be persistent but is reset each save/restore cycle in order diff --git a/include/extern.h b/include/extern.h index c92f34106..36252bf46 100644 --- a/include/extern.h +++ b/include/extern.h @@ -386,7 +386,7 @@ E void NDECL(heal_legs); E char *FDECL(coord_desc, (int, int, char *, CHAR_P)); E boolean FDECL(getpos_menu, (coord *, int)); E int FDECL(getpos, (coord *, BOOLEAN_P, const char *)); -E void FDECL(getpos_sethilite, (void (*f)(int))); +E void FDECL(getpos_sethilite, (void (*f)(int), boolean (*d)(int,int))); E void FDECL(new_mname, (struct monst *, int)); E void FDECL(free_mname, (struct monst *)); E void FDECL(new_oname, (struct obj *, int)); diff --git a/include/flag.h b/include/flag.h index f4f4ac69e..6d5e438b5 100644 --- a/include/flag.h +++ b/include/flag.h @@ -491,6 +491,8 @@ enum nh_keyfunc { NHKF_GETPOS_UNEX_PREV, NHKF_GETPOS_INTERESTING_NEXT, NHKF_GETPOS_INTERESTING_PREV, + NHKF_GETPOS_VALID_NEXT, + NHKF_GETPOS_VALID_PREV, NHKF_GETPOS_HELP, NHKF_GETPOS_MENU, NHKF_GETPOS_LIMITVIEW, @@ -504,6 +506,7 @@ enum gloctypes { GLOC_DOOR, GLOC_EXPLORE, GLOC_INTERESTING, + GLOC_VALID, NUM_GLOCS }; diff --git a/src/apply.c b/src/apply.c index 546d2cefd..fca3f8e36 100644 --- a/src/apply.c +++ b/src/apply.c @@ -1564,6 +1564,15 @@ boolean showmsg; static int jumping_is_magic; +boolean +get_valid_jump_position(x,y) +int x,y; +{ + return (isok(x, y) + && (ACCESSIBLE(levl[x][y].typ) || Passes_walls) + && is_valid_jump_pos(x, y, jumping_is_magic, FALSE)); +} + void display_jump_positions(state) int state; @@ -1577,9 +1586,7 @@ int state; for (dy = -4; dy <= 4; dy++) { x = dx + (int) u.ux; y = dy + (int) u.uy; - if (isok(x, y) - && (ACCESSIBLE(levl[x][y].typ) || Passes_walls) - && is_valid_jump_pos(x, y, jumping_is_magic, FALSE)) + if (get_valid_jump_position(x, y)) tmp_at(x, y); } } else { @@ -1678,7 +1685,7 @@ int magic; /* 0=Physical, otherwise skill level */ cc.x = u.ux; cc.y = u.uy; jumping_is_magic = magic; - getpos_sethilite(display_jump_positions); + getpos_sethilite(display_jump_positions, get_valid_jump_position); if (getpos(&cc, TRUE, "the desired position") < 0) return 0; /* user pressed ESC */ if (!is_valid_jump_pos(cc.x, cc.y, magic, TRUE)) { @@ -2851,6 +2858,15 @@ int min_range, max_range; static int polearm_range_min = -1; static int polearm_range_max = -1; +boolean +get_valid_polearm_position(x,y) +int x,y; +{ + return (isok(x, y) && ACCESSIBLE(levl[x][y].typ) + && distu(x, y) >= polearm_range_min + && distu(x, y) <= polearm_range_max); +} + void display_polearm_positions(state) int state; @@ -2864,9 +2880,7 @@ int state; for (dy = -4; dy <= 4; dy++) { x = dx + (int) u.ux; y = dy + (int) u.uy; - if (isok(x, y) && ACCESSIBLE(levl[x][y].typ) - && distu(x, y) >= polearm_range_min - && distu(x, y) <= polearm_range_max) { + if (get_valid_polearm_position(x, y)) { tmp_at(x, y); } } @@ -2936,7 +2950,7 @@ struct obj *obj; cc.x = hitm->mx; cc.y = hitm->my; } - getpos_sethilite(display_polearm_positions); + getpos_sethilite(display_polearm_positions, get_valid_polearm_position); if (getpos(&cc, TRUE, "the spot to hit") < 0) return res; /* ESC; uses turn iff polearm became wielded */ diff --git a/src/cmd.c b/src/cmd.c index 415c77f3a..719c4902e 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -3738,6 +3738,8 @@ struct { { NHKF_GETPOS_DOOR_PREV, 'D', "getpos.door.prev" }, { NHKF_GETPOS_UNEX_NEXT, 'x', "getpos.unexplored.next" }, { NHKF_GETPOS_UNEX_PREV, 'X', "getpos.unexplored.prev" }, + { NHKF_GETPOS_VALID_NEXT, 'z', "getpos.valid.next" }, + { NHKF_GETPOS_VALID_PREV, 'Z', "getpos.valid.prev" }, { NHKF_GETPOS_INTERESTING_NEXT, 'a', "getpos.all.next" }, { NHKF_GETPOS_INTERESTING_PREV, 'A', "getpos.all.prev" }, { NHKF_GETPOS_HELP, '?', "getpos.help" }, diff --git a/src/do_name.c b/src/do_name.c index d79968778..16818c0d9 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -36,12 +36,15 @@ nextmbuf() * parameter value 0 = initialize, 1 = highlight, 2 = done */ static void FDECL((*getpos_hilitefunc), (int)) = (void FDECL((*), (int))) 0; +static boolean FDECL((*getpos_getvalid), (int,int)) = (boolean FDECL((*), (int,int))) 0; void -getpos_sethilite(f) +getpos_sethilite(f, d) void FDECL((*f), (int)); +boolean FDECL((*d), (int,int)); { getpos_hilitefunc = f; + getpos_getvalid = d; } const char *const gloc_descr[NUM_GLOCS][4] = { @@ -135,6 +138,12 @@ const char *goal; putstr(tmpwin, 0, sbuf); if (!iflags.terrainmode) { char kbuf[BUFSZ]; + if (getpos_getvalid) { + Sprintf(sbuf, "Use '%s' or '%s' to move to valid locations.", + visctrl(Cmd.spkeys[NHKF_GETPOS_VALID_NEXT]), + visctrl(Cmd.spkeys[NHKF_GETPOS_VALID_PREV])); + putstr(tmpwin, 0, sbuf); + } if (getpos_hilitefunc) { Sprintf(sbuf, "Use '%s' to display valid locations.", visctrl(Cmd.spkeys[NHKF_GETPOS_SHOWVALID])); @@ -376,6 +385,8 @@ int x,y, gloc; || glyph_to_cmap(glyph) == S_darkroom || glyph_to_cmap(glyph) == S_corr || glyph_to_cmap(glyph) == S_litcorr)); + case GLOC_VALID: + return (getpos_getvalid && getpos_getvalid(x,y)); } /*NOTREACHED*/ return FALSE; @@ -522,7 +533,9 @@ int cx, cy; if (do_screen_description(cc, TRUE, sym, tmpbuf, &firstmatch)) { (void) coord_desc(cx, cy, tmpbuf, iflags.getpos_coords); custompline(SUPPRESS_HISTORY, - "%s%s%s%s", firstmatch, *tmpbuf ? " " : "", tmpbuf, + "%s%s%s%s%s", firstmatch, *tmpbuf ? " " : "", tmpbuf, + (iflags.autodescribe && getpos_getvalid && !getpos_getvalid(cx,cy)) + ? " (illegal)" : "", (iflags.getloc_travelmode && !is_valid_travelpt(cx, cy)) ? " (no travel path)" : ""); curs(WIN_MAP, cx, cy); @@ -615,10 +628,12 @@ const char *goal; NHKF_GETPOS_UNEX_NEXT, NHKF_GETPOS_UNEX_PREV, NHKF_GETPOS_INTERESTING_NEXT, - NHKF_GETPOS_INTERESTING_PREV + NHKF_GETPOS_INTERESTING_PREV, + NHKF_GETPOS_VALID_NEXT, + NHKF_GETPOS_VALID_PREV }; char pick_chars[6]; - char mMoOdDxX[11]; + char mMoOdDxX[13]; int result = 0; int cx, cy, i, c; int sidx, tx, ty; @@ -922,6 +937,7 @@ const char *goal; if (garr[i]) free((genericptr_t) garr[i]); getpos_hilitefunc = (void FDECL((*), (int))) 0; + getpos_getvalid = (boolean FDECL((*), (int,int))) 0; return result; } diff --git a/src/read.c b/src/read.c index efc36e3cb..46f838426 100644 --- a/src/read.c +++ b/src/read.c @@ -915,12 +915,21 @@ struct obj *sobj; return 0; } +boolean +get_valid_stinking_cloud_pos(x,y) +int x,y; +{ + return (!(!isok(x,y) || !cansee(x, y) + || !ACCESSIBLE(levl[x][y].typ) + || distu(x, y) >= 32)); +} + boolean is_valid_stinking_cloud_pos(x, y, showmsg) int x, y; boolean showmsg; { - if (!cansee(x, y) || !ACCESSIBLE(levl[x][y].typ) || distu(x, y) >= 32) { + if (get_valid_stinking_cloud_pos(x,y)) { if (showmsg) You("smell rotten eggs."); return FALSE; @@ -942,7 +951,7 @@ int state; for (dy = -dist; dy <= dist; dy++) { x = u.ux + dx; y = u.uy + dy; - if (isok(x, y) && is_valid_stinking_cloud_pos(x, y, FALSE)) + if (get_valid_stinking_cloud_pos(x,y)) tmp_at(x, y); } } else { @@ -1633,7 +1642,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */ already_known ? "stinking " : ""); cc.x = u.ux; cc.y = u.uy; - getpos_sethilite(display_stinking_cloud_positions); + getpos_sethilite(display_stinking_cloud_positions, get_valid_stinking_cloud_pos); if (getpos(&cc, TRUE, "the desired position") < 0) { pline1(Never_mind); break;