From: nethack.rankin Date: Tue, 10 Sep 2002 08:01:18 +0000 (+0000) Subject: cursed levitation prayers X-Git-Tag: MOVE2GIT~2427 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ce71bfb59300c03bd6ff80e96571e5562499930d;p=nethack cursed levitation prayers 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. --- diff --git a/doc/fixes34.1 b/doc/fixes34.1 index e8ed3f6e4..04d9ea10b 100644 --- a/doc/fixes34.1 +++ b/doc/fixes34.1 @@ -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 diff --git a/include/extern.h b/include/extern.h index f0b82a86f..f016746d9 100644 --- a/include/extern.h +++ b/include/extern.h @@ -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 *)); diff --git a/src/do_wear.c b/src/do_wear.c index 6f94f5b80..186ce077b 100644 --- a/src/do_wear.c +++ b/src/do_wear.c @@ -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) diff --git a/src/pray.c b/src/pray.c index 7af5961b4..fda0853e5 100644 --- a/src/pray.c +++ b/src/pray.c @@ -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: