grid bugs vs diagonal movement (trunk only)
From a bug report, attempting to move
diagonally when poly'd into grid bug form doesn't give any useful
feedback in the general case, and in the specific case of using 'u' to
try to move northeast with vi-style keys, it performs #untrap instead.
Diagonal directions were being classified as non-movement when in grid
bug form, so the feedback was usually just "unknown command". But 'u'
is bound to untrap as a a convenience to players who use num_pad-style
movement keys. (Move commands don't actually reach the assigned key
part of command handling, so for forms other than grid bug, !num_pad 'u'
moves NE despite the untrap function given to that key.)
Split the diagonal handling out from movement command recognition.
It now gives "you can't get there from here..." if player tries to move
diagonally as a grid bug. For direction prompts, it now gives "you can't
orient yourself that direction" instead of popping up the command assist
display. (In the prompt string showing likely candidate directions for
digging, diagonal handling for grid bugs is academic because they aren't
strong enough to wield pick-axes.)
This commit is contained in:
@@ -302,6 +302,8 @@ when dipping something in holy/unholy water, only learn its new bless/curse
|
||||
state if hero sees it glow
|
||||
describe lit Sunsword as shining rather than glowing
|
||||
prevent poly'd shopkeepers from taking on forms that can't handle objects
|
||||
attempting to move direction 'u' as a grid bug performed #untrap command;
|
||||
the other diagonals reported "unknown command" instead of "you can't"
|
||||
|
||||
|
||||
Platform- and/or Interface-Specific Fixes
|
||||
|
||||
@@ -200,6 +200,7 @@ E void FDECL(show_conduct, (int));
|
||||
E int FDECL(xytod, (SCHAR_P,SCHAR_P));
|
||||
E void FDECL(dtoxy, (coord *,int));
|
||||
E int FDECL(movecmd, (CHAR_P));
|
||||
E int NDECL(dxdy_moveok);
|
||||
E int FDECL(getdir, (const char *));
|
||||
E void NDECL(confdir);
|
||||
E const char *FDECL(directionname, (int));
|
||||
|
||||
32
src/cmd.c
32
src/cmd.c
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)cmd.c 3.5 2008/05/25 */
|
||||
/* SCCS Id: @(#)cmd.c 3.5 2009/01/28 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -2855,6 +2855,20 @@ register char *cmd;
|
||||
}
|
||||
}
|
||||
|
||||
if ((do_walk || do_rush) && !context.travel && !dxdy_moveok()) {
|
||||
/* trying to move diagonally as a grid bug;
|
||||
this used to be treated by movecmd() as not being
|
||||
a movement attempt, but that didn't provide for any
|
||||
feedback and led to strangeness if the key pressed
|
||||
('u' in particular) was overloaded for num_pad use */
|
||||
You_cant("get there from here...");
|
||||
context.run = 0;
|
||||
context.nopick = context.forcefight = FALSE;
|
||||
context.move = context.mv = FALSE;
|
||||
multi = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (do_walk) {
|
||||
if (multi) context.mv = TRUE;
|
||||
domove();
|
||||
@@ -2968,13 +2982,23 @@ char sym;
|
||||
u.dx = xdir[dp - Cmd.dirchars];
|
||||
u.dy = ydir[dp - Cmd.dirchars];
|
||||
u.dz = zdir[dp - Cmd.dirchars];
|
||||
#if 0 /* now handled elsewhere */
|
||||
if (u.dx && u.dy && NODIAG(u.umonnum)) {
|
||||
u.dx = u.dy = 0;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
return !u.dz;
|
||||
}
|
||||
|
||||
/* grid bug handling which used to be in movecmd() */
|
||||
int
|
||||
dxdy_moveok()
|
||||
{
|
||||
if (u.dx && u.dy && NODIAG(u.umonnum)) u.dx = u.dy = 0;
|
||||
return u.dx || u.dy;
|
||||
}
|
||||
|
||||
/* decide whether a character (user input keystroke) requests screen repaint */
|
||||
boolean
|
||||
redraw_cmd(c)
|
||||
@@ -3020,6 +3044,7 @@ getdir(s)
|
||||
const char *s;
|
||||
{
|
||||
char dirsym;
|
||||
int is_mov;
|
||||
|
||||
retry:
|
||||
#ifdef REDO
|
||||
@@ -3042,7 +3067,7 @@ const char *s;
|
||||
|
||||
if (dirsym == '.' || dirsym == 's') {
|
||||
u.dx = u.dy = u.dz = 0;
|
||||
} else if (!movecmd(dirsym) && !u.dz) {
|
||||
} else if (!(is_mov = movecmd(dirsym)) && !u.dz) {
|
||||
boolean did_help = FALSE, help_requested;
|
||||
|
||||
if (!index(quitchars, dirsym)) {
|
||||
@@ -3056,6 +3081,9 @@ const char *s;
|
||||
if (!did_help) pline("What a strange direction!");
|
||||
}
|
||||
return 0;
|
||||
} else if (is_mov && !dxdy_moveok()) {
|
||||
You_cant("orient yourself that direction.");
|
||||
return 0;
|
||||
}
|
||||
if (!u.dz && (Stunned || (Confusion && !rn2(5)))) confdir();
|
||||
return 1;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)dig.c 3.5 2007/04/02 */
|
||||
/* SCCS Id: @(#)dig.c 3.5 2009/01/28 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -916,7 +916,7 @@ struct obj *obj;
|
||||
register char *dsp = dirsyms;
|
||||
register int rx, ry;
|
||||
int res = 0;
|
||||
const char *sdp = Cmd.dirchars, *verb;
|
||||
const char *sdp, *verb;
|
||||
|
||||
/* Check tool */
|
||||
if (obj != uwep) {
|
||||
@@ -934,8 +934,9 @@ struct obj *obj;
|
||||
return res;
|
||||
}
|
||||
|
||||
while(*sdp) {
|
||||
for (sdp = Cmd.dirchars; *sdp; ++sdp) {
|
||||
(void) movecmd(*sdp); /* sets u.dx and u.dy and u.dz */
|
||||
if (!u.dz && !dxdy_moveok()) continue; /* handle NODIAG */
|
||||
rx = u.ux + u.dx;
|
||||
ry = u.uy + u.dy;
|
||||
/* Include down even with axe, so we have at least one direction */
|
||||
@@ -943,7 +944,6 @@ struct obj *obj;
|
||||
(u.dz == 0 && isok(rx, ry) &&
|
||||
dig_typ(obj, rx, ry) != DIGTYP_UNDIGGABLE))
|
||||
*dsp++ = *sdp;
|
||||
sdp++;
|
||||
}
|
||||
*dsp = 0;
|
||||
Sprintf(qbuf, "In what direction do you want to %s? [%s]", verb, dirsyms);
|
||||
|
||||
Reference in New Issue
Block a user