refine walking on ice might slip in random dirctn

If moving on ice causes the hero to hurtle an extra step in a random
direction, don't allow that to be backward to where hero started.

Also, if hero is in grid bug form, only allow hurtling forward.
It was allowing slips in a diagonal direction, which seems wrong
for grid bug, and even when it slipped in an orthogonal direction,
buffered screen updating made the combined step+hurtle appear to be
a single diagonal step.

I'm not a fan of this seemingly simple change.  The hurtle/second
step comes after the "you slip on the ice" vs "you slip off the ice"
messaging and might put the hero in a location which contradicts it.
This commit is contained in:
PatR
2024-03-09 16:05:11 -08:00
parent 6e6c8a7208
commit 3e2999d3e6
2 changed files with 18 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 cmd.c $NHDT-Date: 1709675219 2024/03/05 21:46:59 $ $NHDT-Branch: keni-mdlib-followup $:$NHDT-Revision: 1.711 $ */
/* NetHack 3.7 cmd.c $NHDT-Date: 1710029089 2024/03/10 00:04:49 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.712 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2013. */
/* NetHack may be freely redistributed. See license for details. */
@@ -3882,11 +3882,13 @@ void
confdir(boolean force_impairment)
{
if (force_impairment || u_maybe_impaired()) {
int x = NODIAG(u.umonnum) ? (int) dirs_ord[rn2(4)] : rn2(N_DIRS);
int kmax = NODIAG(u.umonnum) ? (N_DIRS / 2) : N_DIRS,
k = (int) dirs_ord[rn2(kmax)];
u.dx = xdir[x];
u.dy = ydir[x];
u.dx = xdir[k];
u.dy = ydir[k];
}
return;
}
const char *

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 timeout.c $NHDT-Date: 1703294874 2023/12/23 01:27:54 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.167 $ */
/* NetHack 3.7 timeout.c $NHDT-Date: 1710029105 2024/03/10 00:05:05 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.182 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2018. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1236,9 +1236,17 @@ slip_or_trip(void)
You("lose your balance.");
dismount_steed(DISMOUNT_FELL);
} else if (!rn2(10 + ACURR(A_DEX))) {
int dir = rn2(N_DIRS);
hurtle(xdir[dir], ydir[dir], 1, FALSE);
/* Maybe slip in a random direction. This takes place after
the hero has already changed location. If the hero is
in grid bug form, only allow forward hurtle, otherwise a
90 degree orthogonal one after the step would make the
combined move appear to be a single diagonal step. */
if (!NODIAG(u.umonnum))
confdir(TRUE); /* sets u.dx and u.dy */
/* Only hurtle if the random directon won't move hero back
to same spot where this move started. */
if (u.ux + u.dx != u.ux0 || u.uy + u.dy != u.uy0)
hurtle(u.dx, u.dy, 1, FALSE);
}
} else {
if (on_foot) {