]> granicus.if.org Git - nethack/commitdiff
Displace a pet rather than stop travel
authorPasi Kallinen <paxed@alt.org>
Mon, 21 Dec 2015 17:12:02 +0000 (19:12 +0200)
committerPasi Kallinen <paxed@alt.org>
Mon, 21 Dec 2015 17:13:45 +0000 (19:13 +0200)
... and stop travel if you take damage from any source.

Original patch via Acehack by Alex Smith

doc/fixes36.1
src/hack.c
src/uhitm.c

index 41c8359975e4c57f06be758c64781f3ad7a5a804..c71710f43cf5f6a5c6747083a18b52f0c1e9333e 100644 (file)
@@ -52,6 +52,7 @@ stack splitting for dipping large quantities of potions was done poorly
 dipping fruit juice into enlightenment gave different result than the inverse
 make travel walk up to a trap and stop when the trap blocks the only
        way forward, instead of trying to go straight line
+travel will displace pets rather than stop
 
 
 Platform- and/or Interface-Specific Fixes
index 2f45d10fde66765137bbad418e53ecba6f82c441..3f651467890605ccbc3ae6c663ab2412c850396b 100644 (file)
@@ -1370,8 +1370,9 @@ domove()
         }
 
         mtmp = m_at(x, y);
-        if (mtmp) {
+        if (mtmp && !is_safepet(mtmp)) {
             /* Don't attack if you're running, and can see it */
+            /* It's fine to displace pets, though */
             /* We should never get here if forcefight */
             if (context.run && ((!Blind && mon_visible(mtmp)
                                  && ((mtmp->m_ap_type != M_AP_FURNITURE
@@ -1393,7 +1394,10 @@ domove()
 
     /* attack monster */
     if (mtmp) {
-        nomul(0);
+        /* don't stop travel when displacing pets; if the
+           displace fails for some reason, attack() in uhitm.c
+           will stop travel rather than domove */
+        if (!is_safepet(mtmp) || context.forcefight) nomul(0);
         /* only attack if we know it's there */
         /* or if we used the 'F' command to fight blindly */
         /* or if it hides_under, in which case we call attack() to print
@@ -1409,7 +1413,7 @@ domove()
          * attack_check(), which still wastes a turn, but prints a
          * different message and makes the player remember the monster.
          */
-        if (context.nopick
+        if (context.nopick && !context.travel
             && (canspotmon(mtmp) || glyph_is_invisible(levl[x][y].glyph))) {
             if (mtmp->m_ap_type && !Protection_from_shape_changers
                 && !sensemon(mtmp))
@@ -2415,7 +2419,7 @@ lookaround()
                 && mtmp->m_ap_type != M_AP_OBJECT
                 && (!mtmp->minvis || See_invisible) && !mtmp->mundetected) {
                 if ((context.run != 1 && !mtmp->mtame)
-                    || (x == u.ux + u.dx && y == u.uy + u.dy))
+                    || (x == u.ux + u.dx && y == u.uy + u.dy && !context.travel))
                     goto stop;
             }
 
@@ -2678,6 +2682,8 @@ boolean k_format;
     u.uhp -= n;
     if (u.uhp > u.uhpmax)
         u.uhpmax = u.uhp; /* perhaps n was negative */
+    else
+        context.travel = context.travel1 = context.mv = context.run = 0;
     context.botl = 1;
     if (u.uhp < 1) {
         killer.format = k_format;
index d41f71669c244f2a9a1e4ac8ab391ad60237a680..24c6fd870886cacc60d37ae05d083e5cc50bd987 100644 (file)
@@ -350,10 +350,12 @@ register struct monst *mtmp;
                 Strcpy(buf, y_monnam(mtmp));
                 buf[0] = highc(buf[0]);
                 You("stop.  %s is in the way!", buf);
+                context.travel = context.travel1 = context.mv = context.run = 0;
                 return TRUE;
             } else if ((mtmp->mfrozen || (!mtmp->mcanmove)
                         || (mtmp->data->mmove == 0)) && rn2(6)) {
                 pline("%s doesn't seem to move!", Monnam(mtmp));
+                context.travel = context.travel1 = context.mv = context.run = 0;
                 return TRUE;
             } else
                 return FALSE;