From: Pasi Kallinen Date: Fri, 25 Feb 2022 14:43:09 +0000 (+0200) Subject: Split ice fumbling code out of domove X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7a29110514eaec3d79775ee5a09d29bed7570b68;p=nethack Split ice fumbling code out of domove --- diff --git a/src/hack.c b/src/hack.c index 41c4dd654..bd5a6ea45 100644 --- a/src/hack.c +++ b/src/hack.c @@ -21,6 +21,7 @@ static boolean domove_fight_ironbars(xchar, xchar); static boolean domove_swap_with_pet(struct monst *, xchar, xchar); static boolean domove_fight_empty(xchar, xchar); static boolean air_turbulence(void); +static void slippery_ice_fumbling(void); static void domove_core(void); static void maybe_smudge_engr(int, int, int, int); static struct monst *monstinroom(struct permonst *, int); @@ -1917,6 +1918,30 @@ air_turbulence(void) return FALSE; } +static void +slippery_ice_fumbling(void) +{ + boolean on_ice = !Levitation && is_ice(u.ux, u.uy); + + if (on_ice) { + static int skates = 0; + + if (!skates) + skates = find_skates(); + if ((uarmf && uarmf->otyp == skates) || resists_cold(&g.youmonst) + || Flying || is_floater(g.youmonst.data) + || is_clinger(g.youmonst.data) || is_whirly(g.youmonst.data)) { + on_ice = FALSE; + } else if (!rn2(Cold_resistance ? 3 : 2)) { + HFumbling |= FROMOUTSIDE; + HFumbling &= ~TIMEOUT; + HFumbling += 1; /* slip on next move */ + } + } + if (!on_ice && (HFumbling & FROMOUTSIDE)) + HFumbling &= ~FROMOUTSIDE; +} + void domove(void) { @@ -1938,7 +1963,6 @@ domove_core(void) register xchar x, y; struct trap *trap = NULL; int wtcap, glyph; - boolean on_ice; xchar chainx = 0, chainy = 0, ballx = 0, bally = 0; /* ball&chain new positions */ int bc_control = 0; /* control for ball&chain */ @@ -1974,24 +1998,7 @@ domove_core(void) return; /* check slippery ice */ - on_ice = !Levitation && is_ice(u.ux, u.uy); - if (on_ice) { - static int skates = 0; - - if (!skates) - skates = find_skates(); - if ((uarmf && uarmf->otyp == skates) || resists_cold(&g.youmonst) - || Flying || is_floater(g.youmonst.data) - || is_clinger(g.youmonst.data) || is_whirly(g.youmonst.data)) { - on_ice = FALSE; - } else if (!rn2(Cold_resistance ? 3 : 2)) { - HFumbling |= FROMOUTSIDE; - HFumbling &= ~TIMEOUT; - HFumbling += 1; /* slip on next move */ - } - } - if (!on_ice && (HFumbling & FROMOUTSIDE)) - HFumbling &= ~FROMOUTSIDE; + slippery_ice_fumbling(); x = u.ux + u.dx; y = u.uy + u.dy;