]> granicus.if.org Git - nethack/commitdiff
more knockback induced dismount
authorPatR <rankin@nethack.org>
Thu, 27 Oct 2022 22:55:57 +0000 (15:55 -0700)
committerPatR <rankin@nethack.org>
Thu, 27 Oct 2022 22:55:57 +0000 (15:55 -0700)
When looking at the previous commit, I realized that my comment about
radius 1 was wrong.  The original code prefers dismounting to spots
that are orthogonal to the steed's position over diagonal ones.  It
doesn't say why.

src/steed.c

index 72114dc18e5d16ca05a702101de85c56903d0558..4c352802956b9400a8b4b4726f35e8772af7b4d1 100644 (file)
@@ -512,11 +512,11 @@ landing_spot(
                 ++viable;
                 distance = distu(x, y);
                 if (min_distance < 0 /* no viable candidate yet */
-                    /* or better than pending candidate (note: distance
-                       is never less than min_distance because we're
-                       limiting search to radius 1; j==0 won't get here
-                       because 'min_distance < 0' will always pass for it) */
-                    || (distance < min_distance || (best_j != -1 && j == 0))
+                    /* or better than pending candidate (note: orthogonal
+                       spots are distance 1 and diagonal ones distance 2;
+                       treating one as better than the other is arbitary
+                       and not wanted for DISMOUNT_KNOCKED) */
+                    || (best_j == -1) ? (distance < min_distance) : (j < 3)
                     /* or equally good, maybe substitute this one */
                     || (distance == min_distance && !rn2(viable))) {
                     /* traps avoided on pass 0; boulders avoided on 0 and 1 */