]> granicus.if.org Git - nethack/commitdiff
github issue #716 - teleporting onto pits
authorPatR <rankin@nethack.org>
Wed, 30 Mar 2022 21:41:53 +0000 (14:41 -0700)
committerPatR <rankin@nethack.org>
Wed, 30 Mar 2022 21:41:53 +0000 (14:41 -0700)
Implement the suggestion by NetSysFire that a levitating of flying
hero won't treat pits and holes as off limits when testing potential
destinations during teleport.

Closes #716

doc/fixes3-7-0.txt
src/teleport.c

index bba43c658c0630796cdb9d4417e83a20c9b7320c..bafbbfe096e06c5e677a3aec00e42c9d87a050e6 100644 (file)
@@ -854,6 +854,8 @@ kicking a trapped chest and getting the exploding chest result destroyed items
        at the hero's location rather than the chest's location; because of
        that it left the exploded chest intact
 it was possible to destroy a Rider corpse with an exploding chest
+when teleporting, don't consider pits/spiked pits/trap doors/holes as unsafe
+       destination locations if hero is levitating or flying
 
 
 Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
index 158bd9778c71b9288ac21d98545ff4c3019d3dbb..83652908e6998f23f4069dd06e5eb02eb15ce1bf 100644 (file)
@@ -284,10 +284,19 @@ static boolean
 teleok(register int x, register int y, boolean trapok)
 {
     if (!trapok) {
-        /* allow teleportation onto vibrating square, it's not a real trap */
+        /* allow teleportation onto vibrating square, it's not a real trap;
+           also allow pits and holes if levitating or flying */
         struct trap *trap = t_at(x, y);
 
-        if (trap && trap->ttyp != VIBRATING_SQUARE)
+        if (!trap)
+            trapok = TRUE;
+        else if (trap->ttyp == VIBRATING_SQUARE)
+            trapok = TRUE;
+        else if ((is_pit(trap->ttyp) || is_hole(trap->ttyp))
+                 && (Levitation || Flying))
+            trapok = TRUE;
+
+        if (!trapok)
             return FALSE;
     }
     if (!goodpos(x, y, &g.youmonst, 0))