]> granicus.if.org Git - nethack/commitdiff
B14010 - nausia and reading spellbooks
authorcohrs <cohrs>
Mon, 4 Nov 2002 22:07:23 +0000 (22:07 +0000)
committercohrs <cohrs>
Mon, 4 Nov 2002 22:07:23 +0000 (22:07 +0000)
Pulled out the code that handles reading spellbooks while confused into a
new function that can be called from learn() to handle the timed onset of
confusion starting while you're reading.

doc/fixes34.1
src/spell.c

index 0059b15f1110b761bbab650f716998e74a5ce860..537e04e725b2b5e2b5d757f6fc27034540a23c3e 100644 (file)
@@ -292,6 +292,8 @@ non-lawful angels don't chat using lawful messages and shouldn't summon
        lawful help
 cancelled yellow lights should not explode against other monsters, as well as
        not exploding against you
+becoming confused, eg from nausia, while reading a spellbook should result
+       in the usual confusion effects
 
 
 Platform- and/or Interface-Specific Fixes
index 350233bd2a3b1112672ef1f64ad3ac616185d0ab..37e7c0e6769e65cbab60af372902db5890200984 100644 (file)
@@ -22,6 +22,7 @@ static NEARDATA struct obj *book;     /* last/current book being xscribed */
 
 STATIC_DCL int FDECL(spell_let_to_idx, (CHAR_P));
 STATIC_DCL boolean FDECL(cursed_book, (struct obj *bp));
+STATIC_DCL boolean FDECL(confused_book, (struct obj *));
 STATIC_DCL void FDECL(deadbook, (struct obj *));
 STATIC_PTR int NDECL(learn);
 STATIC_DCL boolean FDECL(getspell, (int *));
@@ -172,6 +173,31 @@ cursed_book(bp)
        return FALSE;
 }
 
+/* study while confused: returns TRUE if the book is destroyed */
+STATIC_OVL boolean
+confused_book(spellbook)
+struct obj *spellbook;
+{
+       boolean gone = FALSE;
+
+       if (!rn2(3) && spellbook->otyp != SPE_BOOK_OF_THE_DEAD) {
+           spellbook->in_use = TRUE;   /* in case called from learn */
+           pline(
+       "Being confused you have difficulties in controlling your actions.");
+           display_nhwindow(WIN_MESSAGE, FALSE);
+           You("accidentally tear the spellbook to pieces.");
+           if (!objects[spellbook->otyp].oc_name_known &&
+               !objects[spellbook->otyp].oc_uname)
+               docall(spellbook);
+           useup(spellbook);
+           gone = TRUE;
+       } else {
+           You("find yourself reading the %s line over and over again.",
+               spellbook == book ? "next" : "first");
+       }
+       return gone;
+}
+
 /* special effects for The Book of the Dead */
 STATIC_OVL void
 deadbook(book2)
@@ -295,9 +321,16 @@ learn()
 
        /* JDS: lenses give 50% faster reading; 33% smaller read time */
        if (delay && ublindf && ublindf->otyp == LENSES && rn2(2)) delay++;
+       if (Confusion) {                /* became confused while learning */
+           (void) confused_book(book);
+           book = 0;                   /* no longer studying */
+           nomul(delay);               /* remaining delay is uninterrupted */
+           delay = 0;
+           return(0);
+       }
        if (delay) {    /* not if (delay++), so at end delay == 0 */
-               delay++;
-               return(1); /* still busy */
+           delay++;
+           return(1); /* still busy */
        }
        exercise(A_WIS, TRUE);          /* you're studying. */
        booktype = book->otyp;
@@ -441,24 +474,12 @@ register struct obj *spellbook;
                        spellbook->in_use = FALSE;
                    return(1);
                } else if (confused) {
-                       if (!rn2(3) &&
-                               spellbook->otyp != SPE_BOOK_OF_THE_DEAD) {
-                           pline(
-         "Being confused you have difficulties in controlling your actions.");
-                           display_nhwindow(WIN_MESSAGE, FALSE);
-                           You("accidentally tear the spellbook to pieces.");
-                           if (!objects[spellbook->otyp].oc_name_known &&
-                                  !objects[spellbook->otyp].oc_uname)
-                               docall(spellbook);
-                           useup(spellbook);
-                       } else {
-                           You(
-                 "find yourself reading the first line over and over again.");
-                           spellbook->in_use = FALSE;
-                       }
-                       nomul(delay);
-                       delay = 0;
-                       return(1);
+                   if (!confused_book(spellbook)) {
+                       spellbook->in_use = FALSE;
+                   }
+                   nomul(delay);
+                   delay = 0;
+                   return(1);
                }
                spellbook->in_use = FALSE;