OSDN Git Service

update year to 2023
[jnethack/source.git] / src / wizard.c
index 63bab45..1fa3e63 100644 (file)
@@ -1,11 +1,11 @@
-/* NetHack 3.6 wizard.c        $NHDT-Date: 1539804905 2018/10/17 19:35:05 $  $NHDT-Branch: keni-makedefsm $:$NHDT-Revision: 1.53 $ */
+/* NetHack 3.6 wizard.c        $NHDT-Date: 1561336025 2019/06/24 00:27:05 $  $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.56 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2016. */
 /* NetHack may be freely redistributed.  See license for details. */
 
 /* JNetHack Copyright */
 /* (c) Issei Numata, Naoki Hamada, Shigehiro Miyashita, 1994-2000  */
-/* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2019            */
+/* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2023            */
 /* JNetHack may be freely redistributed.  See license for details. */
 
 /* wizard code - inspired by rogue code from Merlyn Leroy (digi-g!brian) */
@@ -373,7 +373,6 @@ xchar *sy;
         *sx = x;
         *sy = y;
     }
-
 }
 
 int
@@ -381,28 +380,33 @@ tactics(mtmp)
 register struct monst *mtmp;
 {
     unsigned long strat = strategy(mtmp);
-    xchar sx = 0, sy = 0;
+    xchar sx = 0, sy = 0, mx, my;
 
     mtmp->mstrategy =
         (mtmp->mstrategy & (STRAT_WAITMASK | STRAT_APPEARMSG)) | strat;
 
     switch (strat) {
     case STRAT_HEAL: /* hide and recover */
+        mx = mtmp->mx, my = mtmp->my;
         /* if wounded, hole up on or near the stairs (to block them) */
         choose_stairs(&sx, &sy);
         mtmp->mavenge = 1; /* covetous monsters attack while fleeing */
-        if (In_W_tower(mtmp->mx, mtmp->my, &u.uz)
+        if (In_W_tower(mx, my, &u.uz)
             || (mtmp->iswiz && !sx && !mon_has_amulet(mtmp))) {
             if (!rn2(3 + mtmp->mhp / 10))
                 (void) rloc(mtmp, TRUE);
-        } else if (sx && (mtmp->mx != sx || mtmp->my != sy)) {
+        } else if (sx && (mx != sx || my != sy)) {
             if (!mnearto(mtmp, sx, sy, TRUE)) {
-                m_into_limbo(mtmp);
+                /* couldn't move to the target spot for some reason,
+                   so stay where we are (don't actually need rloc_to()
+                   because mtmp is still on the map at <mx,my>... */
+                rloc_to(mtmp, mx, my);
                 return 0;
             }
+            mx = mtmp->mx, my = mtmp->my; /* update cached location */
         }
         /* if you're not around, cast healing spells */
-        if (distu(mtmp->mx, mtmp->my) > (BOLT_LIM * BOLT_LIM))
+        if (distu(mx, my) > (BOLT_LIM * BOLT_LIM))
             if (mtmp->mhp <= mtmp->mhpmax - 8) {
                 mtmp->mhp += rnd(8);
                 return 1;
@@ -436,7 +440,7 @@ register struct monst *mtmp;
 
                 if ((otmp = on_ground(which_arti(targ))) != 0) {
                     if (cansee(mtmp->mx, mtmp->my))
-#if 0 /*JP*/
+#if 0 /*JP:T*/
                         pline("%s picks up %s.", Monnam(mtmp),
                               (distu(mtmp->mx, mtmp->my) <= 5)
                                   ? doname(otmp)
@@ -459,12 +463,13 @@ register struct monst *mtmp;
                 return 0;
             }
         } else { /* a monster has it - 'port beside it. */
+            mx = mtmp->mx, my = mtmp->my;
             if (!mnearto(mtmp, tx, ty, FALSE))
-                m_into_limbo(mtmp);
+                rloc_to(mtmp, mx, my); /* no room? stay put */
             return 0;
         }
-    }
-    }
+    } /* default case */
+    } /* switch */
     /*NOTREACHED*/
     return 0;
 }
@@ -755,7 +760,7 @@ wizdead()
 }
 
 const char *const random_insult[] = {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
     "antic",      "blackguard",   "caitiff",    "chucklehead",
     "coistrel",   "craven",       "cretin",     "cur",
     "dastard",    "demon fodder", "dimwit",     "dolt",
@@ -777,7 +782,7 @@ const char *const random_insult[] = {
 };
 
 const char *const random_malediction[] = {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
     "Hell shall soon claim thy remains,", "I chortle at thee, thou pathetic",
     "Prepare to die, thou", "Resistance is useless,",
     "Surrender or die, thou", "There shall be no mercy, thou",
@@ -819,7 +824,7 @@ register struct monst *mtmp;
             verbalize("\96\82\82æ\82¯\82ð\8eè\95ú\82¹\81C%s\81I",
                       random_insult[rn2(SIZE(random_insult))]);
         else if (u.uhp < 5 && !rn2(2)) /* Panic */
-#if 0 /*JP*/
+#if 0 /*JP:T*/
             verbalize(rn2(2) ? "Even now thy life force ebbs, %s!"
                              : "Savor thy breath, %s, it be thy last!",
                       random_insult[rn2(SIZE(random_insult))]);
@@ -834,7 +839,7 @@ register struct monst *mtmp;
 */
             verbalize(rn2(2) ? "\97]\82Í\95K\82¸\8bA\82Á\82Ä\82­\82é\81D" : "\97]\82Í\96ß\82Á\82Ä\82­\82é\81D");
         else
-#if 0 /*JP*/
+#if 0 /*JP:T*/
             verbalize("%s %s!",
                       random_malediction[rn2(SIZE(random_malediction))],
                       random_insult[rn2(SIZE(random_insult))]);