]> granicus.if.org Git - nethack/commitdiff
controlling u.ustuck
authorPatR <rankin@nethack.org>
Sun, 16 Feb 2020 21:04:12 +0000 (13:04 -0800)
committerPatR <rankin@nethack.org>
Sun, 16 Feb 2020 21:04:12 +0000 (13:04 -0800)
Setting or clearing u.ustuck now requires that context.botl be set,
so make a new routine to take care of both instead of manipulating
that pointer directly.

15 files changed:
include/extern.h
src/apply.c
src/artifact.c
src/cmd.c
src/do.c
src/hack.c
src/mhitm.c
src/mhitu.c
src/mon.c
src/polyself.c
src/restore.c
src/save.c
src/teleport.c
src/trap.c
src/uhitm.c

index 887fff29a511c053c3d0308857c11bd4079aad85..6a344c9fd836d0b9489076ba90abce0fff5ab4bf 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 extern.h        $NHDT-Date: 1581562570 2020/02/13 02:56:10 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.796 $ */
+/* NetHack 3.6 extern.h        $NHDT-Date: 1581886855 2020/02/16 21:00:55 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.797 $ */
 /* Copyright (c) Steve Creps, 1988.                              */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1468,6 +1468,7 @@ E void FDECL(mondied, (struct monst *));
 E void FDECL(mongone, (struct monst *));
 E void FDECL(monstone, (struct monst *));
 E void FDECL(monkilled, (struct monst *, const char *, int));
+E void FDECL(set_ustuck, (struct monst *));
 E void FDECL(unstuck, (struct monst *));
 E void FDECL(killed, (struct monst *));
 E void FDECL(xkilled, (struct monst *, int));
@@ -1515,8 +1516,8 @@ E boolean FDECL(poly_when_stoned, (struct permonst *));
 E boolean FDECL(resists_drli, (struct monst *));
 E boolean FDECL(resists_magm, (struct monst *));
 E boolean FDECL(resists_blnd, (struct monst *));
-E boolean
-FDECL(can_blnd, (struct monst *, struct monst *, UCHAR_P, struct obj *));
+E boolean FDECL(can_blnd, (struct monst *, struct monst *,
+                           UCHAR_P, struct obj *));
 E boolean FDECL(ranged_attk, (struct permonst *));
 E boolean FDECL(hates_silver, (struct permonst *));
 E boolean FDECL(mon_hates_silver, (struct monst *));
index 20128409a432a6e22b469b3a01177bad6a2dc929..50967cebe0836d9a66f462d7fbb7d72af02c1fe5 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 apply.c $NHDT-Date: 1580476196 2020/01/31 13:09:56 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.316 $ */
+/* NetHack 3.6 apply.c $NHDT-Date: 1581886857 2020/02/16 21:00:57 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.317 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2012. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -1721,8 +1721,10 @@ int magic; /* 0=Physical, otherwise skill level */
         return 0;
     } else if (u.ustuck) {
         if (u.ustuck->mtame && !Conflict && !u.ustuck->mconf) {
-            You("pull free from %s.", mon_nam(u.ustuck));
-            u.ustuck = 0;
+            struct monst *mtmp = u.ustuck;
+
+            set_ustuck((struct monst *) 0);
+            You("pull free from %s.", mon_nam(mtmp));
             return 1;
         }
         if (magic) {
index df2e0c65ef89344fce7fe2f91119bc0663bfc10c..75998ec8846bb441d5945dc8c7d5e810a463585c 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 artifact.c      $NHDT-Date: 1577662239 2019/12/29 23:30:39 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.152 $ */
+/* NetHack 3.6 artifact.c      $NHDT-Date: 1581886858 2020/02/16 21:00:58 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.153 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2013. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -1061,7 +1061,7 @@ char *hittee;              /* target's name: "you" or mon_nam(mdef) */
                 g.multi_reason = "being scared stiff";
                 g.nomovemsg = "";
                 if (magr && magr == u.ustuck && sticks(g.youmonst.data)) {
-                    u.ustuck = (struct monst *) 0;
+                    set_ustuck((struct monst *) 0);
                     You("release %s!", mon_nam(magr));
                 }
             }
index 379054f44200f2bd207f0b3f1f63a58f1da6f078..91a93a452f13e46443b120d263926836994badb9 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -1,4 +1,4 @@
-/* NetHack 3.6 cmd.c   $NHDT-Date: 1581322659 2020/02/10 08:17:39 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.398 $ */
+/* NetHack 3.6 cmd.c   $NHDT-Date: 1581886858 2020/02/16 21:00:58 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.400 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2013. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -824,7 +824,7 @@ boolean pre, wiztower;
         reset_utrap(FALSE);
         check_special_room(TRUE); /* room exit */
         u.ustuck = (struct monst *) 0;
-        u.uswallow = 0;
+        u.uswallow = u.uswldtim = 0;
         u.uinwater = 0;
         u.uundetected = 0; /* not hidden, even if means are available */
         dmonsfree(); /* purge dead monsters from 'fmon' */
index 4028d76d3bdfa91c6088695cfb6705b0e5e0e5de..5ea2e2c6a8e8721df92e608a2244a9d54685a6fb 100644 (file)
--- a/src/do.c
+++ b/src/do.c
@@ -1,4 +1,4 @@
-/* NetHack 3.6 do.c    $NHDT-Date: 1581810044 2020/02/15 23:40:44 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.226 $ */
+/* NetHack 3.6 do.c    $NHDT-Date: 1581886859 2020/02/16 21:00:59 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.227 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Derek S. Ray, 2015. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -1373,12 +1373,11 @@ boolean at_stairs, falling, portal;
         unplacebc();
     reset_utrap(FALSE); /* needed in level_tele */
     fill_pit(u.ux, u.uy);
-    u.ustuck = 0; /* idem */
+    set_ustuck((struct monst *) 0); /* idem */
+    u.uswallow = u.uswldtim = 0;
     u.uinwater = 0;
     u.uundetected = 0; /* not hidden, even if means are available */
     keepdogs(FALSE);
-    if (u.uswallow) /* idem */
-        u.uswldtim = u.uswallow = 0;
     recalc_mapseen(); /* recalculate map overview before we leave the level */
     /*
      *  We no longer see anything on the level.  Make sure that this
index ac61723158d453e1185afb222c85f99ed29073d1..09b62b55f90269838283756e58dd76dae3f11bd2 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 hack.c  $NHDT-Date: 1581810065 2020/02/15 23:41:05 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.247 $ */
+/* NetHack 3.6 hack.c  $NHDT-Date: 1581886860 2020/02/16 21:01:00 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.248 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Derek S. Ray, 2015. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -1537,13 +1537,14 @@ domove_core()
         if (u.ustuck && (x != u.ustuck->mx || y != u.ustuck->my)) {
             if (distu(u.ustuck->mx, u.ustuck->my) > 2) {
                 /* perhaps it fled (or was teleported or ... ) */
-                u.ustuck = 0;
+                set_ustuck((struct monst *) 0);
             } else if (sticks(g.youmonst.data)) {
                 /* When polymorphed into a sticking monster,
                  * u.ustuck means it's stuck to you, not you to it.
                  */
-                You("release %s.", mon_nam(u.ustuck));
-                u.ustuck = 0;
+                mtmp = u.ustuck;
+                set_ustuck((struct monst *) 0);
+                You("release %s.", mon_nam(mtmp));
             } else {
                 /* If holder is asleep or paralyzed:
                  *      37.5% chance of getting away,
@@ -1559,8 +1560,9 @@ domove_core()
                 case 1:
                 case 2:
  pull_free:
-                    You("pull free from %s.", mon_nam(u.ustuck));
-                    u.ustuck = 0;
+                    mtmp = u.ustuck;
+                    set_ustuck((struct monst *) 0);
+                    You("pull free from %s.", mon_nam(mtmp));
                     break;
                 case 3:
                     if (!u.ustuck->mcanmove) {
index 65f23c82a1c36d80f9d6ad570e2c7d57a3df128b..181dd848344b1fc138df94879fee9ddc0075c242 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 mhitm.c $NHDT-Date: 1573773926 2019/11/14 23:25:26 $  $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.118 $ */
+/* NetHack 3.6 mhitm.c $NHDT-Date: 1581886861 2020/02/16 21:01:01 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.130 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2011. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -146,8 +146,8 @@ register struct monst *mtmp;
             if (monnear(mtmp, mon->mx, mon->my)) {
                 if (!u.uswallow && (mtmp == u.ustuck)) {
                     if (!rn2(4)) {
+                        set_ustuck((struct monst *) 0);
                         pline("%s releases you!", Monnam(mtmp));
-                        u.ustuck = 0;
                     } else
                         break;
                 }
index fd9786262053af089c89574c94eed698d085a65d..4f36b325f6b0a0470a9dce64b16549f5a7214ba8 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 mhitu.c $NHDT-Date: 1581810070 2020/02/15 23:41:10 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.182 $ */
+/* NetHack 3.6 mhitu.c $NHDT-Date: 1581886862 2020/02/16 21:01:02 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.183 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2012. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -534,7 +534,7 @@ register struct monst *mtmp;
             pline("Wait, %s!  That's a %s named %s!", m_monnam(mtmp),
                   g.youmonst.data->mname, g.plname);
         if (sticky)
-            u.ustuck = mtmp;
+            set_ustuck(mtmp);
         g.youmonst.m_ap_type = M_AP_NOTHING;
         g.youmonst.mappearance = 0;
         newsym(u.ux, u.uy);
@@ -973,7 +973,7 @@ register struct attack *mattk;
                 if (u_slip_free(mtmp, mattk)) {
                     dmg = 0;
                 } else {
-                    u.ustuck = mtmp;
+                    set_ustuck(mtmp);
                     pline("%s grabs you!", Monnam(mtmp));
                 }
             } else if (u.ustuck == mtmp) {
@@ -1269,8 +1269,7 @@ register struct attack *mattk;
     case AD_STCK:
         hitmsg(mtmp, mattk);
         if (uncancelled && !u.ustuck && !sticks(g.youmonst.data)) {
-            g.context.botl = 1;
-            u.ustuck = mtmp;
+            set_ustuck(mtmp);
         }
         break;
     case AD_WRAP:
@@ -1279,9 +1278,8 @@ register struct attack *mattk;
                 if (u_slip_free(mtmp, mattk)) {
                     dmg = 0;
                 } else {
-                    g.context.botl = 1;
+                    set_ustuck(mtmp); /* before message, for botl update */
                     pline("%s swings itself around you!", Monnam(mtmp));
-                    u.ustuck = mtmp;
                 }
             } else if (u.ustuck == mtmp) {
                 if (is_pool(mtmp->mx, mtmp->my) && !Swimming && !Amphibious) {
@@ -1296,8 +1294,9 @@ register struct attack *mattk;
                             moat ? "moat" : "pool of water",
                             an(mtmp->data->mname));
                     done(DROWNING);
-                } else if (mattk->aatyp == AT_HUGS)
+                } else if (mattk->aatyp == AT_HUGS) {
                     You("are being crushed.");
+                }
             } else {
                 dmg = 0;
                 if (flags.verbose)
@@ -1801,7 +1800,7 @@ struct attack *mattk;
         remove_monster(omx, omy);
         mtmp->mtrapped = 0; /* no longer on old trap */
         place_monster(mtmp, u.ux, u.uy);
-        u.ustuck = mtmp;
+        set_ustuck(mtmp);
         newsym(mtmp->mx, mtmp->my);
         if (is_animal(mtmp->data) && u.usteed) {
             char buf[BUFSZ];
@@ -1814,8 +1813,9 @@ struct attack *mattk;
             pline("%s lunges forward and plucks you off %s!", Monnam(mtmp),
                   buf);
             dismount_steed(DISMOUNT_ENGULFED);
-        } else
+        } else {
             pline("%s engulfs you!", Monnam(mtmp));
+        }
         stop_occupation();
         reset_occupations(); /* behave as if you had moved */
 
@@ -1843,7 +1843,7 @@ struct attack *mattk;
                fully swallowed yet so that won't work here */
             if (Punished)
                 placebc();
-            u.ustuck = 0;
+            set_ustuck((struct monst *) 0);
             return (!DEADMONSTER(mtmp)) ? 0 : 2;
         }
 
@@ -1869,7 +1869,7 @@ struct attack *mattk;
         }
         /* u.uswldtim always set > 1 */
         u.uswldtim = (unsigned) ((tim_tmp < 2) ? 2 : tim_tmp);
-        swallowed(1);
+        swallowed(1); /* update the map display, shows hero swallowed */
         for (otmp2 = g.invent; otmp2; otmp2 = otmp2->nobj)
             (void) snuff_lit(otmp2);
     }
index 24f7cd7faf028fb58eb7eb4f42c3128d1deef883..8532d89f070940346d873af39ff18c429308fdf9 100644 (file)
--- a/src/mon.c
+++ b/src/mon.c
@@ -1,4 +1,4 @@
-/* NetHack 3.6 mon.c   $NHDT-Date: 1581810072 2020/02/15 23:41:12 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.323 $ */
+/* NetHack 3.6 mon.c   $NHDT-Date: 1581886863 2020/02/16 21:01:03 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.324 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Derek S. Ray, 2015. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -1683,7 +1683,7 @@ struct monst *mtmp, *mtmp2;
     mtmp2->nmon = fmon;
     fmon = mtmp2;
     if (u.ustuck == mtmp)
-        u.ustuck = mtmp2;
+        set_ustuck(mtmp2);
     if (u.usteed == mtmp)
         u.usteed = mtmp2;
     if (mtmp2->isshk)
@@ -2314,15 +2314,23 @@ int how;
         mondied(mdef);
 }
 
+void
+set_ustuck(mtmp)
+struct monst *mtmp;
+{
+    g.context.botl = 1;
+    u.ustuck = mtmp;
+}
+
 void
 unstuck(mtmp)
 struct monst *mtmp;
 {
     if (u.ustuck == mtmp) {
-        g.context.botl = 1;
         /* do this first so that docrt()'s botl update is accurate;
            safe to do as long as u.uswallow is also cleared before docrt() */
-        u.ustuck = (struct monst *) 0;
+        set_ustuck((struct monst *) 0);
+
         if (u.uswallow) {
             u.ux = mtmp->mx;
             u.uy = mtmp->my;
index 691e70c8640fff24ee40610eb8e5851a72f3a81f..a3c80d6483095a3ca5bb8825ebd498c46d3b6dd4 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 polyself.c      $NHDT-Date: 1579660157 2020/01/22 02:29:17 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.149 $ */
+/* NetHack 3.6 polyself.c      $NHDT-Date: 1581886864 2020/02/16 21:01:04 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.150 $ */
 /*      Copyright (C) 1987, 1988, 1989 by Ken Arromdee */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -767,7 +767,7 @@ int mntmp;
        grabber to engulfer or vice versa because engulfing by poly'd hero
        always ends immediately so won't be in effect during a polymorph] */
     if (!sticky && !u.uswallow && u.ustuck && sticks(g.youmonst.data))
-        u.ustuck = 0;
+        set_ustuck((struct monst *) 0);
     else if (sticky && !sticks(g.youmonst.data))
         uunstick();
 
@@ -1622,12 +1622,14 @@ domindblast()
 void
 uunstick()
 {
-    if (!u.ustuck) {
+    struct monst *mtmp = u.ustuck;
+
+    if (!mtmp) {
         impossible("uunstick: no ustuck?");
         return;
     }
-    pline("%s is no longer in your clutches.", Monnam(u.ustuck));
-    u.ustuck = 0;
+    set_ustuck((struct monst *) 0); /* before pline() */
+    pline("%s is no longer in your clutches.", Monnam(mtmp));
 }
 
 void
index d2ca2177758317b19d7d0bff400a84bd0fb4e276..3c9d85bccbee7a09bec4f0057c905e25d40fafee 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 restore.c       $NHDT-Date: 1575245087 2019/12/02 00:04:47 $  $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.136 $ */
+/* NetHack 3.7 restore.c       $NHDT-Date: 1581886865 2020/02/16 21:01:05 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.163 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Michael Allison, 2009. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -775,7 +775,7 @@ unsigned int stuckid, steedid;
                 break;
         if (!mtmp)
             panic("Cannot find the monster ustuck.");
-        u.ustuck = mtmp;
+        set_ustuck(mtmp);
     }
     if (steedid) {
         for (mtmp = fmon; mtmp; mtmp = mtmp->nmon)
index a026fc17262829f5d78dd511932005e4985546e9..1bde782137c3abcf72aab181988a7ebdebf620af 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 save.c  $NHDT-Date: 1559994625 2019/06/08 11:50:25 $  $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.121 $ */
+/* NetHack 3.6 save.c  $NHDT-Date: 1581886866 2020/02/16 21:01:06 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.153 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Michael Allison, 2009. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -216,7 +216,7 @@ dosave0()
     /* these pointers are no longer valid, and at least u.usteed
      * may mislead place_monster() on other levels
      */
-    u.ustuck = (struct monst *) 0;
+    set_ustuck((struct monst *) 0);
     u.usteed = (struct monst *) 0;
 
     for (ltmp = (xchar) 1; ltmp <= maxledgerno(); ltmp++) {
index 427c3bb7a4507db925a6be4d6bbab9c41b681fe6..ecb597dfb9746b0d0ea6cbd67c4945ead6365c3f 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 teleport.c      $NHDT-Date: 1581210886 2020/02/09 01:14:46 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.112 $ */
+/* NetHack 3.6 teleport.c      $NHDT-Date: 1581886867 2020/02/16 21:01:07 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.113 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2011. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -323,7 +323,7 @@ int teleds_flags;
         }
     }
     reset_utrap(FALSE);
-    u.ustuck = 0;
+    set_ustuck((struct monst *) 0);
     u.ux0 = u.ux;
     u.uy0 = u.uy;
 
index 9b56ea0bf8fec470cdfd2e90662a7d41ac8c6610..e0c2a1026dc526bdab93a976afc5961e45ce2a98 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 trap.c  $NHDT-Date: 1578624299 2020/01/10 02:44:59 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.349 $ */
+/* NetHack 3.6 trap.c  $NHDT-Date: 1581886868 2020/02/16 21:01:08 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.351 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2013. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -2987,7 +2987,7 @@ long hmask, emask; /* might cancel timeout */
             else
                 pline("Startled, %s can no longer hold you!",
                       mon_nam(u.ustuck));
-            u.ustuck = 0;
+            set_ustuck((struct monst *) 0);
         }
         /* kludge alert:
          * drown() and lava_effects() print various messages almost
index 9f2b1236a6683c52dc1759d0965623c46a7dcb5e..71f393a14761b1ad49a3c9b67263fd97a81755fe 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 uhitm.c $NHDT-Date: 1573764936 2019/11/14 20:55:36 $  $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.215 $ */
+/* NetHack 3.6 uhitm.c $NHDT-Date: 1581886869 2020/02/16 21:01:09 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.227 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2012. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -145,7 +145,7 @@ struct obj *wep; /* uwep for attack(), null for kick_monster() */
             /* applied pole-arm attack is too far to get stuck */
             && distu(mtmp->mx, mtmp->my) <= 2) {
             if (!u.ustuck && !mtmp->mflee && dmgtype(mtmp->data, AD_STCK))
-                u.ustuck = mtmp;
+                set_ustuck(mtmp);
         }
         /* #H7329 - if hero is on engraved "Elbereth", this will end up
          * assessing an alignment penalty and removing the engraving
@@ -495,7 +495,7 @@ int dieroll;
                 monflee(mon, !rn2(3) ? rnd(100) : 0, FALSE, TRUE);
 
                 if (u.ustuck == mon && !u.uswallow && !sticks(g.youmonst.data))
-                    u.ustuck = 0;
+                    set_ustuck((struct monst *) 0);
             }
             /* Vorpal Blade hit converted to miss */
             /* could be headless monster or worm tail */
@@ -1933,7 +1933,7 @@ int specialdmg; /* blessed and/or silver bonus against various things */
                     tmp = 0;
                 } else {
                     You("swing yourself around %s!", mon_nam(mdef));
-                    u.ustuck = mdef;
+                    set_ustuck(mdef);
                 }
             } else if (u.ustuck == mdef) {
                 /* Monsters don't wear amulets of magical breathing */
@@ -2631,7 +2631,7 @@ register struct monst *mon;
                 if (u.ustuck && u.ustuck != mon)
                     uunstick();
                 You("grab %s!", mon_nam(mon));
-                u.ustuck = mon;
+                set_ustuck(mon);
                 if (silverhit && flags.verbose)
                     silver_sears(&g.youmonst, mon, silverhit);
                 sum[i] = damageum(mon, mattk, specialdmg);
@@ -3042,7 +3042,7 @@ struct monst *mtmp;
     const char *fmt = "Wait!  That's %s!", *generic = "a monster", *what = 0;
 
     if (!u.ustuck && !mtmp->mflee && dmgtype(mtmp->data, AD_STCK))
-        u.ustuck = mtmp;
+        set_ustuck(mtmp);
 
     if (Blind) {
         if (!Blind_telepat)