Add paranoid:swim to prevent typoing into water or lava
In the name of accessibility: Prevent moving into dangerous liquids. Now with themed rooms, water and lava are more common, and it's unreasonable to expect blind players to check every step for those. With paranoid:swim, just prevent normal walking into those liquids, unless you prefix the movement with 'm', or if the liquid would not harm you. Doesn't completely prevent an accidental dunking - for example if the hero is impaired or couldn't see the liquid. This comes from xNetHack by copperwater <aosdict@gmail.com> with some changes to the code.
This commit is contained in:
48
src/hack.c
48
src/hack.c
@@ -13,6 +13,7 @@ static void dosinkfall(void);
|
||||
static boolean findtravelpath(int);
|
||||
static boolean trapmove(int, int, struct trap *);
|
||||
static void check_buried_zombies(xchar, xchar);
|
||||
static boolean swim_move_danger(xchar x, xchar y);
|
||||
static void domove_core(void);
|
||||
static void maybe_smudge_engr(int, int, int, int);
|
||||
static struct monst *monstinroom(struct permonst *, int);
|
||||
@@ -1519,6 +1520,46 @@ check_buried_zombies(xchar x, xchar y)
|
||||
}
|
||||
}
|
||||
|
||||
/* Is it dangerous for hero to move to x,y due to water or lava? */
|
||||
static boolean
|
||||
swim_move_danger(xchar x, xchar y)
|
||||
{
|
||||
if (!Levitation && !Flying && grounded(g.youmonst.data) && !Stunned
|
||||
&& !Confusion && levl[x][y].seenv
|
||||
&& ((is_pool(x, y) && !is_pool(u.ux, u.uy))
|
||||
|| (is_lava(x, y) && !is_lava(u.ux, u.uy)))) {
|
||||
boolean known_wwalking, known_lwalking;
|
||||
|
||||
known_wwalking = (uarmf && uarmf->otyp == WATER_WALKING_BOOTS
|
||||
&& objects[WATER_WALKING_BOOTS].oc_name_known
|
||||
&& !u.usteed);
|
||||
known_lwalking = (known_wwalking && Fire_resistance &&
|
||||
uarmf->oerodeproof && uarmf->rknown);
|
||||
/* FIXME: This can be exploited to identify the ring of fire resistance
|
||||
* if the player is wearing it unidentified and has identified
|
||||
* fireproof boots of water walking and is walking over lava. However,
|
||||
* this is such a marginal case that it may not be worth fixing. */
|
||||
if ((is_pool(x, y) && !known_wwalking)
|
||||
|| (is_lava(x, y) && !known_lwalking)) {
|
||||
if (g.context.nopick) {
|
||||
/* moving with m-prefix */
|
||||
g.context.swim_tip = TRUE;
|
||||
return FALSE;
|
||||
} else if (ParanoidSwim) {
|
||||
You("avoid stepping into the %s.",
|
||||
waterbody_name(x, y));
|
||||
if (!g.context.swim_tip) {
|
||||
pline("(Use '%s' prefix to step in if you really want to.)",
|
||||
visctrl(cmd_from_func(do_reqmenu)));
|
||||
g.context.swim_tip = TRUE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
domove(void)
|
||||
{
|
||||
@@ -1946,6 +1987,13 @@ domove_core(void)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Is it dangerous to swim in water or lava? */
|
||||
if (swim_move_danger(x, y)) {
|
||||
g.context.move = 0;
|
||||
nomul(0);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Move ball and chain. */
|
||||
if (Punished)
|
||||
if (!drag_ball(x, y, &bc_control, &ballx, &bally, &chainx, &chainy,
|
||||
|
||||
Reference in New Issue
Block a user