]> granicus.if.org Git - nethack/commitdiff
Pet displacement improvements
authorcopperwater <aosdict@gmail.com>
Tue, 20 Mar 2018 16:17:38 +0000 (12:17 -0400)
committerPasi Kallinen <paxed@alt.org>
Wed, 15 Apr 2020 05:46:47 +0000 (08:46 +0300)
Pets can no longer be displaced out of a trap, because that was
inconsistent with peaceful monsters refusing to be displaced out of a
trap. The untaming-via-displacement-out-of-trap code is removed.

Pets also now have a better survival instinct: they follow the code for
peaceful displacement into a bad position, and refuse to swap places.
This means it's no longer possible to accidentally kill a pet by
levitating/walking over water and displacing it.

src/hack.c

index 103901ac5ec6300275e6f7d89bb75dab57a35663..b3120ebe92446a91339570b34fe752122a004490 100644 (file)
@@ -1793,10 +1793,7 @@ domove_core()
      * previous location using the same conditions as in attack().
      * there are special extenuating circumstances:
      * (1) if the pet dies then your god angers,
-     * (2) if the pet gets trapped then your god may disapprove,
-     * (3) if the pet was already trapped and you attempt to free it
-     * not only do you encounter the trap but you may frighten your
-     * pet causing it to go wild!  moral: don't abuse this privilege.
+     * (2) if the pet gets trapped then your god may disapprove.
      *
      * Ceiling-hiding pets are skipped by this section of code, to
      * be caught by the normal falling-monster code.
@@ -1836,15 +1833,14 @@ domove_core()
             /* can't swap places when pet won't fit thru the opening */
             You("stop.  %s won't fit through.", upstart(y_monnam(mtmp)));
             didnt_move = TRUE;
-        } else if (mtmp->mpeaceful && !mtmp->mtame && mtmp->mtrapped) {
-            /* TODO: pets can get angered when displaced out of a trap.
-             * Having peaceful monsters simply refuse is inconsistent.
-             * Probably, pets should not be able to be displaced out of a
-             * trap like a pit or bear trap at all. */
+        } else if ((mtmp->mpeaceful || mtmp->mtame) && mtmp->mtrapped) {
+            /* Since peaceful monsters simply being unable to move out of traps
+             * was inconsistent with pets being able to but being untamed in the
+             * process, apply this logic equally to pets and peacefuls. */
             You("stop.  %s can't move out of that trap.",
                 upstart(y_monnam(mtmp)));
             didnt_move = TRUE;
-        } else if (mtmp->mpeaceful && !mtmp->mtame
+        } else if (mtmp->mpeaceful
                    && (!goodpos(u.ux0, u.uy0, mtmp, 0)
                        || t_at(u.ux0, u.uy0) != NULL
                        || mtmp->ispriest
@@ -1857,17 +1853,6 @@ domove_core()
                 upstart(y_monnam(mtmp)));
             didnt_move = TRUE;
         } else {
-            /* if trapped, there's a chance the pet goes wild */
-            if (mtmp->mtrapped) {
-                if (!rn2(mtmp->mtame)) {
-                    mtmp->mtame = mtmp->mpeaceful = mtmp->msleeping = 0;
-                    if (mtmp->mleashed)
-                        m_unleash(mtmp, TRUE);
-                    growl(mtmp);
-                } else {
-                    yelp(mtmp);
-                }
-            }
             char pnambuf[BUFSZ];
 
             /* save its current description in case of polymorph */