Unify impaired movement direction checks
This commit is contained in:
@@ -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