]> granicus.if.org Git - nethack/commitdiff
hiding monsters vs traps (trunk only)
authornethack.rankin <nethack.rankin>
Sat, 27 May 2006 03:46:03 +0000 (03:46 +0000)
committernethack.rankin <nethack.rankin>
Sat, 27 May 2006 03:46:03 +0000 (03:46 +0000)
     From a bug report, the game gave feedback
about a monster becoming stuck in a web but there seemed to be no monster
around because it immediately began hiding under an object at the web's
location.  Prevent monsters--or poly'd hero--from hiding when trapped in
anything other than a pit or spiked pit.  Also, prevent them from hiding if
they're holding you or you're poly'd and holding them.  I'm not sure whether
either of those cases ever actually happened but big mimics are capable of
both hiding and grabbing on.

doc/fixes35.0
src/mon.c
src/polyself.c

index 4d1c28bd46742e8deb94dffffbd3aaa3cc89d2ba..cbc8589ddf9809bbe3c30063d61fb993dfd9aec0 100644 (file)
@@ -142,6 +142,7 @@ don't give attribute adjustment messages ("you feel wise") unless the current
        value actually changes
 meditating monsters stop meditating when affected by something which wakes
        sleeping mosnters
+monsters capable of hiding can't do so when trapped or while holding you
 
 
 Platform- and/or Interface-Specific Fixes
index 13973578333a5e776a78acca96e8c3a534107e9c..2931bacbbb142aeede8e0a30055454d2856f4100 100644 (file)
--- a/src/mon.c
+++ b/src/mon.c
@@ -2366,11 +2366,19 @@ boolean
 hideunder(mtmp)
 struct monst *mtmp;
 {
-       boolean undetected = FALSE;
-       xchar x = (mtmp == &youmonst) ? u.ux : mtmp->mx;
-       xchar y = (mtmp == &youmonst) ? u.uy : mtmp->my;
-
-       if (mtmp->data->mlet == S_EEL) {
+       struct trap *t;
+       boolean undetected = FALSE,
+               is_u = (mtmp == &youmonst);
+       xchar x = is_u ? u.ux : mtmp->mx,
+             y = is_u ? u.uy : mtmp->my;
+
+       if (mtmp == u.ustuck) {
+           ;   /* can't hide if holding you or held by you */
+       } else if (is_u ? (u.utrap && u.utraptype != TT_PIT) :
+                         (mtmp->mtrapped && (t = t_at(x, y)) != 0 &&
+                               !(t->ttyp == PIT || t->ttyp == SPIKED_PIT))) {
+           ;   /* can't hide while stuck in a non-pit trap */
+       } else if (mtmp->data->mlet == S_EEL) {
            undetected = (is_pool(x, y) && !Is_waterlevel(&u.uz));
        } else if (hides_under(mtmp->data) && OBJ_AT(x, y)) {
            struct obj *otmp = level.objects[x][y];
@@ -2382,7 +2390,7 @@ struct monst *mtmp;
                undetected = TRUE;
        }
 
-       if (mtmp == &youmonst) u.uundetected = undetected;
+       if (is_u) u.uundetected = undetected;
        else mtmp->mundetected = undetected;
        return undetected;
 }
index 454a09380a5fc8b6233870ae054033a5c9343d12..6cc410d5ad8da5a29ea8b2b9295fa9c4e2058b61 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)polyself.c 3.5     2005/09/19      */
+/*     SCCS Id: @(#)polyself.c 3.5     2006/05/26      */
 /*     Copyright (C) 1987, 1988, 1989 by Ken Arromdee */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1096,6 +1096,20 @@ dohide()
 {
        boolean ismimic = youmonst.data->mlet == S_MIMIC;
 
+       if ((u.utrap && u.utraptype != TT_PIT) || u.ustuck) {
+               You_cant("hide while you're %s.",
+                        !u.ustuck ? "trapped" :
+                          !sticks(youmonst.data) ? "being held" :
+                            humanoid(u.ustuck->data) ? "holding someone" :
+                              "holding that creature");
+               if (u.uundetected ||
+                           (ismimic && youmonst.m_ap_type != M_AP_NOTHING)) {
+                       u.uundetected = 0;
+                       youmonst.m_ap_type = M_AP_NOTHING;
+                       newsym(u.ux, u.uy);
+               }
+               return 0;
+       }
        if (u.uundetected || (ismimic && youmonst.m_ap_type != M_AP_NOTHING)) {
                You("are already hiding.");
                return(0);