From caaf1b375a29360acba1a4e4dd64ed0b4be17bd5 Mon Sep 17 00:00:00 2001 From: PatR Date: Sun, 12 Jan 2020 11:00:38 -0800 Subject: [PATCH] randonly occurring Discworld novels Give 'novel' a 1 in 1000 chance of being created in place of each random spellbook (except for hero's initial inventory and NPC priests' monster inventory and divine reward for prayer--those all force regular spellbooks; statue contents aren't among the exceptions--those books can now be novels). Shop inventory (where first book or scroll shop created is guaranteed one novel) hasn't been touched. If there is any other special spellbook handling somewhere, I've overlooked it. --- doc/fixes37.0 | 6 +++++- src/mkobj.c | 3 ++- src/objects.c | 6 +++--- src/pray.c | 13 ++++++++----- src/priest.c | 7 +++++-- src/u_init.c | 5 +++-- 6 files changed, 26 insertions(+), 14 deletions(-) diff --git a/doc/fixes37.0 b/doc/fixes37.0 index b409e26bd..ce0da6cef 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -1,4 +1,4 @@ -$NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.63 $ $NHDT-Date: 1578834315 2020/01/12 13:05:15 $ +$NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.64 $ $NHDT-Date: 1578855619 2020/01/12 19:00:19 $ General Fixes and Modified Features ----------------------------------- @@ -106,6 +106,10 @@ applying a spellbook hints about read charges left wizard mode wishing for level topology can now create hidden doors (ask for "secret door" when at a door or wall location) and hidden corridor spots ("secret corridor" at a corridor location) +tiny chance for randomly created spellbooks to be Discworld novels instead + of having only one in the first book or scroll shop created (won't + occur in hero's initial inventory or NPC priest inventory or be + bestowed as a prayer boon; might occur inside statues) Platform- and/or Interface-Specific New Features diff --git a/src/mkobj.c b/src/mkobj.c index 53eacdf1c..15fd1f90c 100644 --- a/src/mkobj.c +++ b/src/mkobj.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mkobj.c $NHDT-Date: 1571531889 2019/10/20 00:38:09 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.157 $ */ +/* NetHack 3.6 mkobj.c $NHDT-Date: 1578855620 2020/01/12 19:00:20 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.173 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1054,6 +1054,7 @@ boolean artif; case STATUE: /* possibly overridden by mkcorpstat() */ otmp->corpsenm = rndmonnum(); + /* note: might produce a novel rather than a spellbook */ if (!verysmall(&mons[otmp->corpsenm]) && rn2(level_difficulty() / 2 + 10) > 10) (void) add_to_container(otmp, mkobj(SPBOOK_CLASS, FALSE)); diff --git a/src/objects.c b/src/objects.c index 449a13d09..b9215a7ba 100644 --- a/src/objects.c +++ b/src/objects.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 objects.c $NHDT-Date: 1577184069 2019/12/24 10:41:09 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.59 $ */ +/* NetHack 3.6 objects.c $NHDT-Date: 1578855624 2020/01/12 19:00:24 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.61 $ */ /* Copyright (c) Mike Threepoint, 1989. */ /* NetHack may be freely redistributed. See license for details. */ @@ -918,7 +918,7 @@ SPELL("fireball", "ragged", SPELL("cone of cold", "dog eared", P_ATTACK_SPELL, 10, 7, 4, 1, RAY, HI_PAPER), SPELL("sleep", "mottled", - P_ENCHANTMENT_SPELL, 50, 1, 1, 1, RAY, HI_PAPER), + P_ENCHANTMENT_SPELL, 49, 1, 1, 1, RAY, HI_PAPER), SPELL("finger of death", "stained", P_ATTACK_SPELL, 5, 10, 7, 1, RAY, HI_PAPER), SPELL("light", "cloth", @@ -1003,7 +1003,7 @@ SPELL("blank paper", "plain", P_NONE, 18, 0, 0, 0, 0, HI_PAPER), /* tribute book for 3.6 */ OBJECT(OBJ("novel", "paperback"), BITS(0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, P_NONE, PAPER), - 0, SPBOOK_CLASS, 0, 0, 0, 20, 0, 0, 0, 1, 20, CLR_BRIGHT_BLUE), + 0, SPBOOK_CLASS, 1, 0, 0, 20, 0, 0, 0, 1, 20, CLR_BRIGHT_BLUE), /* a special, one of a kind, spellbook */ OBJECT(OBJ("Book of the Dead", "papyrus"), BITS(0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, P_NONE, PAPER), diff --git a/src/pray.c b/src/pray.c index f8f7e7d9e..b028ea109 100644 --- a/src/pray.c +++ b/src/pray.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 pray.c $NHDT-Date: 1575830189 2019/12/08 18:36:29 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.134 $ */ +/* NetHack 3.6 pray.c $NHDT-Date: 1578855625 2020/01/12 19:00:25 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.137 $ */ /* Copyright (c) Benson I. Margulies, Mike Stephenson, Steve Linhart, 1989. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1181,10 +1181,13 @@ aligntyp g_align; struct obj *otmp; int sp_no, trycnt = u.ulevel + 1; - /* not yet known spells given preference over already known ones - */ - /* Also, try to grant a spell for which there is a skill slot */ - otmp = mkobj(SPBOOK_CLASS, TRUE); + /* not yet known spells given preference over already known ones; + also, try to grant a spell for which there is a skill slot; + make sure that it's a spellbook and not a novel */ + /* otmp = mkobj(SPBOOK_CLASS, TRUE); --might yield NOVEL */ + otmp = mksobj(rnd_class(g.bases[SPBOOK_CLASS], + SPE_BLANK_PAPER), + TRUE, FALSE); while (--trycnt > 0) { if (otmp->otyp != SPE_BLANK_PAPER) { for (sp_no = 0; sp_no < MAXSPELL; sp_no++) diff --git a/src/priest.c b/src/priest.c index 6c73e208b..6521df407 100644 --- a/src/priest.c +++ b/src/priest.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 priest.c $NHDT-Date: 1545131519 2018/12/18 11:11:59 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.45 $ */ +/* NetHack 3.6 priest.c $NHDT-Date: 1578855626 2020/01/12 19:00:26 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.56 $ */ /* Copyright (c) Izchak Miller, Steve Linhart, 1989. */ /* NetHack may be freely redistributed. See license for details. */ @@ -258,7 +258,10 @@ boolean sanctum; /* is it the seat of the high priest? */ } /* 2 to 4 spellbooks */ for (cnt = rn1(3, 2); cnt > 0; --cnt) { - (void) mpickobj(priest, mkobj(SPBOOK_CLASS, FALSE)); + /* avoid novel (used to be mkobj(SPBOOK_CLASS, FALSE) here) */ + (void) mpickobj(priest, mksobj(rnd_class(g.bases[SPBOOK_CLASS], + SPE_BLANK_PAPER), + TRUE, FALSE)); } /* robe [via makemon()] */ if (rn2(2) && (otmp = which_armor(priest, W_ARMC)) != 0) { diff --git a/src/u_init.c b/src/u_init.c index 0ae46c13a..5bc109f86 100644 --- a/src/u_init.c +++ b/src/u_init.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 u_init.c $NHDT-Date: 1575245094 2019/12/02 00:04:54 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.60 $ */ +/* NetHack 3.6 u_init.c $NHDT-Date: 1578855627 2020/01/12 19:00:27 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.67 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2017. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1016,7 +1016,8 @@ register struct trobj *trop; spells in restricted skill categories */ || (obj->oclass == SPBOOK_CLASS && (objects[otyp].oc_level > 3 - || restricted_spell_discipline(otyp)))) { + || restricted_spell_discipline(otyp))) + || otyp == SPE_NOVEL) { dealloc_obj(obj); obj = mkobj(trop->trclass, FALSE); otyp = obj->otyp;