]> granicus.if.org Git - nethack/commitdiff
Illiterate hero will learn spells directly from deity
authorPasi Kallinen <paxed@alt.org>
Sun, 20 Feb 2022 20:05:30 +0000 (22:05 +0200)
committerPasi Kallinen <paxed@alt.org>
Sun, 20 Feb 2022 20:05:33 +0000 (22:05 +0200)
... instead of receiving a spellbook.

doc/fixes3-7-0.txt
include/extern.h
src/pray.c
src/spell.c

index bd3b26c629981cfff188f7a5f1174fb253e04bff..35b33bd3288e8159530172e9eaf616f77002c721 100644 (file)
@@ -798,6 +798,8 @@ engraving with Fire Brand burns the text on the floor and does not
 make looting less tedious by getting rid of a y/n prompt making the command
        go directly into the loot-in-out -menu
 always give a message when monster changes form via polytrap if seen
+illiterate hero receiving a spellbook from their deity gets the spell shoved
+       directly into their mind instead
 
 
 Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
index a8327b1bf9a0dcd4812087f7edba09f239266306..cb3432deaf223a05935591588ba1d8c2ff356e14 100644 (file)
@@ -2538,6 +2538,7 @@ extern int dovspell(void);
 extern void initialspell(struct obj *);
 extern boolean known_spell(short);
 extern int spell_idx(short);
+extern boolean force_learn_spell(short);
 
 /* ### steal.c ### */
 
index 9eb97f36afccdb10efc1fa23e9e5143ecff41a19..11557abb6c8016fca08c6a001ceeeb0e3f519601 100644 (file)
@@ -1201,10 +1201,17 @@ pleased(aligntyp g_align)
                 }
                 otmp->otyp = rnd_class(g.bases[SPBOOK_CLASS], SPE_BLANK_PAPER);
             }
-            bless(otmp);
-            at_your_feet("A spellbook");
-            place_object(otmp, u.ux, u.uy);
-            newsym(u.ux, u.uy);
+            if (!u.uconduct.literate && !known_spell(otmp->otyp)) {
+                if (force_learn_spell(otmp->otyp))
+                    pline("Divine knowledge of %s fills your mind!",
+                          OBJ_NAME(objects[otmp->otyp]));
+                obfree(otmp, (struct obj *) 0);
+            } else {
+                bless(otmp);
+                at_your_feet("A spellbook");
+                place_object(otmp, u.ux, u.uy);
+                newsym(u.ux, u.uy);
+            }
             break;
         }
         default:
index 6f05278ae881e63935acebc57a3cbcde21485710..457405d4cef89355b05bf04fcb78085e1f30576c 100644 (file)
@@ -1947,4 +1947,27 @@ spell_idx(short otyp)
     return -1;
 }
 
+/* forcibly learn spell otyp, if possible */
+boolean
+force_learn_spell(short otyp)
+{
+    int i;
+
+    if (known_spell(otyp))
+        return FALSE;
+
+    for (i = 0; i < MAXSPELL; i++)
+        if (spellid(i) == NO_SPELL)
+            break;
+    if (i == MAXSPELL)
+        impossible("Too many spells memorized");
+    else {
+        g.spl_book[i].sp_id = otyp;
+        g.spl_book[i].sp_lev = objects[otyp].oc_level;
+        incrnknow(i, 1);
+        return TRUE;
+    }
+    return FALSE;
+}
+
 /*spell.c*/