]> granicus.if.org Git - nethack/commitdiff
polymorphing into a flyer while in a pit
authorcohrs <cohrs>
Tue, 18 Jan 2005 16:17:27 +0000 (16:17 +0000)
committercohrs <cohrs>
Tue, 18 Jan 2005 16:17:27 +0000 (16:17 +0000)
<Someone> reported that if you polymorph into a flying monster while in a
pit, you must take u.utrap turns to first climb out before you can fly.  Of
course, once you're out, you can swoop down into the pit to pick things up
w/o delay.  Rather that have you automatically fly out (e.g. like quaffing
a potion of levitation), I thought it was better to take a turn to fly out,
so that's what I've implemented.

The code to deal with exiting a pit is moved to a new climb_pit function
and the "up" command now lets you climb from a pit too (something I've
found non-intuitive in the past).

Finally, I noticed that non-moving monsters could still go up/down even
though they couldn't move around.  Added non-moving checks in doup/dodown.

doc/fixes35.0
include/extern.h
src/do.c
src/hack.c
src/trap.c

index c2a04b4a7702e028994ba094e93b79c18ffe6b08..9e9d5026b160169dae71876d226f00b87d1a90d9 100644 (file)
@@ -75,6 +75,8 @@ charge for reviving a shop owned corpse or reanimating a shop owned statue
 filled trap doors on castle can be re-dug
 message order when swapping places with a pet (e.g. into a trap), also use
        different term instead of "displace"
+flyers can get out of pits more easily than non-flyers
+allow use of the < command to try to exit a pit
 
 
 Platform- and/or Interface-Specific Fixes
index 52062d7453f5e1f9f40c85ce8c1cd90135ab142c..dac2fa9bf277d4ffa23a58a4fcee24fdad5c8f59 100644 (file)
@@ -2090,6 +2090,7 @@ E void FDECL(mselftouch, (struct monst *,const char *,BOOLEAN_P));
 E void NDECL(float_up);
 E void FDECL(fill_pit, (int,int));
 E int FDECL(float_down, (long, long));
+E void NDECL(climb_pit);
 E int FDECL(fire_damage, (struct obj *,BOOLEAN_P,BOOLEAN_P,XCHAR_P,XCHAR_P));
 E void FDECL(water_damage, (struct obj *,BOOLEAN_P,BOOLEAN_P));
 E boolean NDECL(drown);
index a59af1dbf7fb7bdc1d2edeb64b902bff5732cd69..b3c4693aed82d86c162721e29ee16371c830f066 100644 (file)
--- a/src/do.c
+++ b/src/do.c
@@ -741,6 +741,14 @@ dodown()
                    (u.ux == sstairs.sx && u.uy == sstairs.sy && !sstairs.up)),
                ladder_down = (u.ux == xdnladder && u.uy == ydnladder);
 
+       if(!youmonst.data->mmove) {
+           You("are rooted %s.",
+               Levitation || Is_airlevel(&u.uz) || Is_waterlevel(&u.uz) ?
+               "in place" : "to the ground");
+           nomul(0);
+           return 1;
+       }
+
 #ifdef STEED
        if (u.usteed && !u.usteed->mcanmove) {
                pline("%s won't move!", Monnam(u.usteed));
@@ -839,6 +847,20 @@ dodown()
 int
 doup()
 {
+       if(!youmonst.data->mmove) {
+           You("are rooted %s.",
+               Levitation || Is_airlevel(&u.uz) || Is_waterlevel(&u.uz) ?
+               "in place" : "to the ground");
+           nomul(0);
+           return 1;
+       }
+
+       /* "up" to get out of a pit... */
+       if (u.utrap && u.utraptype == TT_PIT) {
+           climb_pit();
+           return 1;
+       }
+
        if( (u.ux != xupstair || u.uy != yupstair)
             && (!xupladder || u.ux != xupladder || u.uy != yupladder)
             && (!sstairs.sx || u.ux != sstairs.sx || u.uy != sstairs.sy
index e0732b756f20a0aeba0818188c2228301b56bcc5..b53f23f58b639d28e94a2b0c03ff7a064ace7cbe 100644 (file)
@@ -1171,38 +1171,7 @@ domove()
        }
        if(u.utrap) {
                if(u.utraptype == TT_PIT) {
-                   if (Passes_walls) {
-                       /* marked as trapped so they can pick things up */
-                       You("ascend from the pit.");
-                       u.utrap = 0;
-                       fill_pit(u.ux, u.uy);
-                       vision_full_recalc = 1; /* vision limits change */
-                   } else if (!rn2(2) && sobj_at(BOULDER, u.ux, u.uy)) {
-                       Your("%s gets stuck in a crevice.", body_part(LEG));
-                       display_nhwindow(WIN_MESSAGE, FALSE);
-                       clear_nhwindow(WIN_MESSAGE);
-                       You("free your %s.", body_part(LEG));
-                   } else if (!(--u.utrap)) {
-                       You("%s to the edge of the pit.",
-                               (In_sokoban(&u.uz) && Levitation) ?
-                               "struggle against the air currents and float" :
-#ifdef STEED
-                               u.usteed ? "ride" :
-#endif
-                               "crawl");
-                       fill_pit(u.ux, u.uy);
-                       vision_full_recalc = 1; /* vision limits change */
-                   } else if (flags.verbose) {
-#ifdef STEED
-                       if (u.usteed)
-                           Norep("%s is still in a pit.",
-                                 upstart(y_monnam(u.usteed)));
-                       else
-#endif
-                       Norep( (Hallucination && !rn2(5)) ?
-                               "You've fallen, and you can't get up." :
-                               "You are still in a pit." );
-                   }
+                   climb_pit();
                } else if (u.utraptype == TT_LAVA) {
                    if(flags.verbose) {
                        predicament = "stuck in the lava";
index 37bdb76ae7d4ec9c7d37e18e5f0e65b654e59d80..eba7888e26da87fe96a5632b26945aa8a28a58d8 100644 (file)
@@ -2503,6 +2503,52 @@ long hmask, emask;     /* might cancel timeout */
        return 1;
 }
 
+/* shared code for climbing out of a pit */
+void
+climb_pit()
+{
+       if (!u.utrap || u.utraptype != TT_PIT) return;
+
+       if (Passes_walls) {
+           /* marked as trapped so they can pick things up */
+           You("ascend from the pit.");
+           u.utrap = 0;
+           fill_pit(u.ux, u.uy);
+           vision_full_recalc = 1;     /* vision limits change */
+       } else if (!rn2(2) && sobj_at(BOULDER, u.ux, u.uy)) {
+           Your("%s gets stuck in a crevice.", body_part(LEG));
+           display_nhwindow(WIN_MESSAGE, FALSE);
+           clear_nhwindow(WIN_MESSAGE);
+           You("free your %s.", body_part(LEG));
+       } else if (Flying && !In_sokoban(&u.uz)) {
+           /* eg fell in pit, poly'd to a flying monster */
+           You("fly from the pit.");
+           u.utrap = 0;
+           fill_pit(u.ux, u.uy);
+           vision_full_recalc = 1;     /* vision limits change */
+       } else if (!(--u.utrap)) {
+           You("%s to the edge of the pit.",
+               (In_sokoban(&u.uz) && Levitation) ?
+               "struggle against the air currents and float" :
+#ifdef STEED
+               u.usteed ? "ride" :
+#endif
+               "crawl");
+           fill_pit(u.ux, u.uy);
+           vision_full_recalc = 1;     /* vision limits change */
+       } else if (flags.verbose) {
+#ifdef STEED
+           if (u.usteed)
+               Norep("%s is still in a pit.",
+                     upstart(y_monnam(u.usteed)));
+           else
+#endif
+               Norep( (Hallucination && !rn2(5)) ?
+                      "You've fallen, and you can't get up." :
+                      "You are still in a pit." );
+       }
+}
+
 STATIC_OVL void
 dofiretrap(box)
 struct obj *box;       /* null for floor trap */