]> granicus.if.org Git - nethack/commitdiff
Split air turbulence code out of domove
authorPasi Kallinen <paxed@alt.org>
Fri, 25 Feb 2022 14:13:27 +0000 (16:13 +0200)
committerPasi Kallinen <paxed@alt.org>
Fri, 25 Feb 2022 14:13:27 +0000 (16:13 +0200)
src/hack.c

index 2b21430e6f29e1eb983672bd77a5a1d2ee6e1747..41c4dd654960168bca25560fdb366b4154c4d429 100644 (file)
@@ -20,6 +20,7 @@ static boolean domove_attackmon_at(struct monst *, xchar, xchar, boolean *);
 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 domove_core(void);
 static void maybe_smudge_engr(int, int, int, int);
 static struct monst *monstinroom(struct permonst *, int);
@@ -1893,6 +1894,29 @@ domove_fight_empty(xchar x, xchar y)
     return FALSE;
 }
 
+/* does the plane of air disturb movement? */
+static boolean
+air_turbulence(void)
+{
+    if (Is_airlevel(&u.uz) && rn2(4) && !Levitation && !Flying) {
+        switch (rn2(3)) {
+        case 0:
+            You("tumble in place.");
+            exercise(A_DEX, FALSE);
+            break;
+        case 1:
+            You_cant("control your movements very well.");
+            break;
+        case 2:
+            pline("It's hard to walk in thin air.");
+            exercise(A_DEX, TRUE);
+            break;
+        }
+        return TRUE;
+    }
+    return FALSE;
+}
+
 void
 domove(void)
 {
@@ -1946,22 +1970,8 @@ domove_core(void)
         u_on_newpos(x, y); /* set u.ux,uy and handle CLIPPING */
         mtmp = u.ustuck;
     } else {
-        if (Is_airlevel(&u.uz) && rn2(4) && !Levitation && !Flying) {
-            switch (rn2(3)) {
-            case 0:
-                You("tumble in place.");
-                exercise(A_DEX, FALSE);
-                break;
-            case 1:
-                You_cant("control your movements very well.");
-                break;
-            case 2:
-                pline("It's hard to walk in thin air.");
-                exercise(A_DEX, TRUE);
-                break;
-            }
+        if (air_turbulence())
             return;
-        }
 
         /* check slippery ice */
         on_ice = !Levitation && is_ice(u.ux, u.uy);