]> granicus.if.org Git - nethack/commitdiff
Allow using #wiztelekinesis on yourself
authorPasi Kallinen <paxed@alt.org>
Thu, 24 Feb 2022 13:10:39 +0000 (15:10 +0200)
committerPasi Kallinen <paxed@alt.org>
Thu, 24 Feb 2022 13:10:39 +0000 (15:10 +0200)
src/cmd.c

index fc6cab1d1c0af591fab93d52b3088a0692124237..e94c6cd8d4eae70c8e74ec1fea5103cd55cce662 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -1236,20 +1236,25 @@ wiz_telekinesis(void)
 
     pline("Pick a monster to hurtle.");
     do {
-        if (mtmp && !DEADMONSTER(mtmp) && canspotmon(mtmp)) {
-            cc.x = mtmp->mx;
-            cc.y = mtmp->my;
-        }
-
         ans = getpos(&cc, TRUE, "a monster");
         if (ans < 0 || cc.x < 0)
             return ECMD_CANCEL;
 
-        if (((mtmp = m_at(cc.x, cc.y)) != 0) && canspotmon(mtmp)) {
+        if ((((mtmp = m_at(cc.x, cc.y)) != 0) && canspotmon(mtmp))
+            || u_at(cc.x, cc.y)) {
             if (!getdir("which direction?"))
                 return ECMD_CANCEL;
 
-            mhurtle(mtmp, u.dx, u.dy, 6);
+            if (mtmp) {
+                mhurtle(mtmp, u.dx, u.dy, 6);
+                if (!DEADMONSTER(mtmp) && canspotmon(mtmp)) {
+                    cc.x = mtmp->mx;
+                    cc.y = mtmp->my;
+                }
+            } else {
+                hurtle(u.dx, u.dy, 6, FALSE);
+                cc.x = u.ux, cc.y = u.uy;
+            }
         }
 
     } while (TRUE);