]> granicus.if.org Git - nethack/commitdiff
levitation timeout vs traps (trunk only)
authornethack.rankin <nethack.rankin>
Thu, 23 Nov 2006 03:06:19 +0000 (03:06 +0000)
committernethack.rankin <nethack.rankin>
Thu, 23 Nov 2006 03:06:19 +0000 (03:06 +0000)
<email deleted>:
> If you enter a magic trap on the same turn that you lose your levitation
> and "float gently to the floor", you are hit by the trap twice.

     I don't think this is actually a bug, but it does look fairly strange
if there aren't any monsters attacking (after you move on to the trap,
monsters get a chance to move too before timeouts are run, but if there
aren't any messages triggered by monster activity then it feels like the
timeout and second activation happens immediately).  To prevent this, if
levitation is due to time out on the same turn that a trap is being
entered, either extend the duration by an extra move or make it end
immediately instead of waiting until end of current turn.  Deferring
timeout is a lot easier but doing that unconditionally would allow player
to move back and forth between adjacent traps without ever descending.
The early timeout might lead to anomalous behavior in obscure cases; it
seems to be working ok so far though.

doc/fixes35.0
src/hack.c

index a90bfd2b7f90047c741d2ebc29541b88f2f6b14b..1648c5f2a762f67ead905f4d2008ddd9cd0c92da 100644 (file)
@@ -170,6 +170,7 @@ for inventory display, include cost info on hero-owned containers holding
        shop goods
 shops now claim ownership of items created by using an unpaid horn of plenty
 shopkeepers shouldn't refer to non-male character as "cad"
+tweak levitation timeout if trap is being triggered on same turn it is to end
 
 
 Platform- and/or Interface-Specific Fixes
index 826be5e065be56043a3634e3972ca1b999a04c56..010abee8c0096a4664fb701b7d454a643f7d59f5 100644 (file)
@@ -1638,6 +1638,22 @@ stillinwater:;
        if (!in_steed_dismounting) { /* if dismounting, we'll check again later */
                boolean pit;
 
+               /* if levitation is due to time out at the end of this
+                  turn, allowing it to do so could give the perception
+                  that a trap here is being triggered twice, so adjust
+                  the timeout to prevent that */
+               if (trap && (HLevitation & TIMEOUT) == 1L) {
+                   if (rn2(2)) {       /* defer timeout */
+                       HLevitation += 1L;
+                   } else {            /* timeout early */
+                       if (float_down(I_SPECIAL|TIMEOUT, 0L)) {
+                           /* levitation has ended; we've already triggered
+                              any trap and [usually] performed autopickup */
+                           trap = 0;
+                           pick = FALSE;
+                       }
+                   }
+               }
               /*
                * If not a pit, pickup before triggering trap.
                * If pit, trigger trap before pickup.