Unify impaired movement direction checks
This commit is contained in:
@@ -281,7 +281,7 @@ extern void dtoxy(coord *, int);
|
||||
extern int movecmd(char, int);
|
||||
extern int dxdy_moveok(void);
|
||||
extern int getdir(const char *);
|
||||
extern void confdir(void);
|
||||
extern void confdir(boolean);
|
||||
extern const char *directionname(int);
|
||||
extern int isok(coordxy, coordxy);
|
||||
extern int get_adjacent_loc(const char *, const char *, coordxy, coordxy, coord *);
|
||||
@@ -944,6 +944,7 @@ extern boolean test_move(coordxy, coordxy, coordxy, coordxy, int);
|
||||
extern int wiz_debug_cmd_traveldisplay(void);
|
||||
#endif
|
||||
extern boolean u_rooted(void);
|
||||
extern boolean u_maybe_impaired(void);
|
||||
extern const char *u_locomotion(const char *);
|
||||
extern void domove(void);
|
||||
extern void runmode_delay_output(void);
|
||||
|
||||
@@ -355,8 +355,7 @@ use_stethoscope(struct obj *obj)
|
||||
You_hear("your heart beat.");
|
||||
return res;
|
||||
}
|
||||
if (Stunned || (Confusion && !rn2(5)))
|
||||
confdir();
|
||||
confdir(FALSE);
|
||||
if (!u.dx && !u.dy) {
|
||||
ustatusline();
|
||||
return res;
|
||||
@@ -2850,8 +2849,7 @@ use_whip(struct obj *obj)
|
||||
rx = mtmp->mx;
|
||||
ry = mtmp->my;
|
||||
} else {
|
||||
if (Stunned || (Confusion && !rn2(5)))
|
||||
confdir();
|
||||
confdir(FALSE);
|
||||
rx = u.ux + u.dx;
|
||||
ry = u.uy + u.dy;
|
||||
if (!isok(rx, ry)) {
|
||||
|
||||
16
src/cmd.c
16
src/cmd.c
@@ -4607,8 +4607,8 @@ getdir(const char *s)
|
||||
You_cant("orient yourself that direction.");
|
||||
return 0;
|
||||
}
|
||||
if (!u.dz && (Stunned || (Confusion && !rn2(5))))
|
||||
confdir();
|
||||
if (!u.dz)
|
||||
confdir(FALSE);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -4789,14 +4789,16 @@ help_dir(
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* if hero is impaired, pick random movement direction */
|
||||
void
|
||||
confdir(void)
|
||||
confdir(boolean force_impairment)
|
||||
{
|
||||
register coordxy x = NODIAG(u.umonnum) ? dirs_ord[rn2(4)] : rn2(N_DIRS);
|
||||
if (force_impairment || u_maybe_impaired()) {
|
||||
register coordxy x = NODIAG(u.umonnum) ? dirs_ord[rn2(4)] : rn2(N_DIRS);
|
||||
|
||||
u.dx = xdir[x];
|
||||
u.dy = ydir[x];
|
||||
return;
|
||||
u.dx = xdir[x];
|
||||
u.dy = ydir[x];
|
||||
}
|
||||
}
|
||||
|
||||
const char *
|
||||
|
||||
@@ -1058,8 +1058,7 @@ use_pick_axe2(struct obj *obj)
|
||||
g.context.botl = 1;
|
||||
return ECMD_TIME;
|
||||
} else if (u.dz == 0) {
|
||||
if (Stunned || (Confusion && !rn2(5)))
|
||||
confdir();
|
||||
confdir(FALSE);
|
||||
rx = u.ux + u.dx;
|
||||
ry = u.uy + u.dy;
|
||||
if (!isok(rx, ry)) {
|
||||
|
||||
10
src/hack.c
10
src/hack.c
@@ -2046,11 +2046,17 @@ slippery_ice_fumbling(void)
|
||||
HFumbling &= ~FROMOUTSIDE;
|
||||
}
|
||||
|
||||
boolean
|
||||
u_maybe_impaired(void)
|
||||
{
|
||||
return (Stunned || (Confusion && !rn2(5)));
|
||||
}
|
||||
|
||||
/* change movement dir if impaired. return TRUE if can't move */
|
||||
static boolean
|
||||
impaired_movement(coordxy *x, coordxy *y)
|
||||
{
|
||||
if (Stunned || (Confusion && !rn2(5))) {
|
||||
if (u_maybe_impaired()) {
|
||||
register int tries = 0;
|
||||
|
||||
do {
|
||||
@@ -2058,7 +2064,7 @@ impaired_movement(coordxy *x, coordxy *y)
|
||||
nomul(0);
|
||||
return TRUE;
|
||||
}
|
||||
confdir();
|
||||
confdir(TRUE);
|
||||
*x = u.ux + u.dx;
|
||||
*y = u.uy + u.dy;
|
||||
} while (!isok(*x, *y) || bad_rock(g.youmonst.data, *x, *y));
|
||||
|
||||
Reference in New Issue
Block a user