]> granicus.if.org Git - nethack/commitdiff
cursed levitation prayers
authornethack.rankin <nethack.rankin>
Tue, 10 Sep 2002 08:01:18 +0000 (08:01 +0000)
committernethack.rankin <nethack.rankin>
Tue, 10 Sep 2002 08:01:18 +0000 (08:01 +0000)
     Noticed while testing something recently:  if you're wearing
a non-cursed ring of levitation but can't remove it because of
some other cursed item, you'll never get the high priority result
of TROUBLE_LEVITATION when praying.  This remedies that.

doc/fixes34.1
include/extern.h
src/do_wear.c
src/pray.c

index e8ed3f6e436703ecff0705dd44e4d5e067e175a9..04d9ea10b33f9d14d2e421453c707f8a077554c6 100644 (file)
@@ -240,6 +240,8 @@ effects of purple worms consuming special monsters is now more consistent
 avoid "you finish disrobing" when disarming via the 'A' command
 make sure corpses and statues which remember monster attributes don't keep
        ones that were conferred by no longer worn items (mainly speed boots)
+elevate the trouble priority of any cursed item which is preventing removal
+       of a ring of levitation
 
 
 Platform- and/or Interface-Specific Fixes
index f0b82a86fa32cc736a87215a5145afae192159fa..f016746d9f531f8cec47489f2a9ca5ceefc37135 100644 (file)
@@ -382,6 +382,7 @@ E void NDECL(find_ac);
 E void NDECL(glibr);
 E struct obj *FDECL(some_armor,(struct monst *));
 E void FDECL(erode_armor, (struct monst *,BOOLEAN_P));
+E struct obj *FDECL(stuck_ring, (struct obj *,int));
 E void NDECL(reset_remarm);
 E int NDECL(doddoremarm);
 E int FDECL(destroy_arm, (struct obj *));
index 6f94f5b80dac0a84d292766470e1610d49a1397f..186ce077bb1ab2cce991a9cf244a8d592e9d6517 100644 (file)
@@ -1620,6 +1620,31 @@ boolean acid_dmg;
        }
 }
 
+/* used for praying to check and fix levitation trouble */
+struct obj *
+stuck_ring(ring, otyp)
+struct obj *ring;
+int otyp;
+{
+    if (ring != uleft && ring != uright) {
+       impossible("stuck_ring: neither left nor right?");
+       return (struct obj *)0;
+    }
+
+    if (ring && ring->otyp == otyp) {
+       /* reasons ring can't be removed match those checked by select_off();
+          limbless case has extra checks because ordinarily it's temporary */
+       if (nolimbs(youmonst.data) &&
+               uamul && uamul->otyp == AMULET_OF_UNCHANGING && uamul->cursed)
+           return uamul;
+       if (welded(uwep) && (ring == uright || bimanual(uwep))) return uwep;
+       if (uarmg && uarmg->cursed) return uarmg;
+       if (ring->cursed) return ring;
+    }
+    /* either no ring or not right type or nothing prevents its removal */
+    return (struct obj *)0;
+}
+
 STATIC_PTR
 int
 select_off(otmp)
index 7af5961b40cbb133cb64a0857bc4712a7321390e..fda0853e53e175f88778fc68505e10b0fe512c69 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)pray.c     3.4     2002/03/02      */
+/*     SCCS Id: @(#)pray.c     3.4     2002/09/09      */
 /* Copyright (c) Benson I. Margulies, Mike Stephenson, Steve Linhart, 1989. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -137,8 +137,8 @@ in_trouble()
                return(TROUBLE_STUCK_IN_WALL);
 
        if((uarmf && uarmf->otyp==LEVITATION_BOOTS && uarmf->cursed) ||
-               (uleft && uleft->otyp==RIN_LEVITATION && uleft->cursed) ||
-               (uright && uright->otyp==RIN_LEVITATION && uright->cursed))
+               stuck_ring(uleft, RIN_LEVITATION) ||
+               stuck_ring(uright, RIN_LEVITATION))
                return(TROUBLE_CURSED_LEVITATION);
        if(Blindfolded && ublindf->cursed) return(TROUBLE_CURSED_BLINDFOLD);
 
@@ -189,7 +189,7 @@ fix_worst_trouble(trouble)
 register int trouble;
 {
        int i;
-       struct obj *otmp;
+       struct obj *otmp = 0;
        const char *what = (const char *)0;
 
        switch (trouble) {
@@ -259,16 +259,13 @@ register int trouble;
                    (void) safe_teleds(FALSE);
                    break;
            case TROUBLE_CURSED_LEVITATION:
-                   if (uarmf && uarmf->otyp==LEVITATION_BOOTS
-                                               && uarmf->cursed)
+                   if (uarmf && uarmf->otyp == LEVITATION_BOOTS &&
+                           uarmf->cursed) {
                        otmp = uarmf;
-                   else if (uleft && uleft->otyp==RIN_LEVITATION
-                                               && uleft->cursed) {
-                       otmp = uleft;
-                       what = leftglow;
-                   } else {
-                       otmp = uright;
-                       what = rightglow;
+                   } else if ((otmp = stuck_ring(uleft,RIN_LEVITATION)) !=0) {
+                       if (otmp == uleft) what = leftglow;
+                   } else if ((otmp = stuck_ring(uright,RIN_LEVITATION))!=0) {
+                       if (otmp == uright) what = rightglow;
                    }
                    goto decurse;
            case TROUBLE_CURSED_BLINDFOLD: