]> granicus.if.org Git - nethack/commitdiff
more random novels
authorPatR <rankin@nethack.org>
Mon, 13 Jan 2020 06:02:36 +0000 (22:02 -0800)
committerPatR <rankin@nethack.org>
Mon, 13 Jan 2020 06:02:36 +0000 (22:02 -0800)
Give statues 'real' spellbooks only.

Provide mkobj() a way to accomplish that instead of resorting to
mksobj(rnd_class()).

include/extern.h
include/objclass.h
src/mkobj.c
src/pray.c
src/priest.c

index d2c251c1113902ed7bbec1939333467974d80c33..a21b76988157e49b1ab2834011591904bef9d1fd 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 extern.h        $NHDT-Date: 1578764033 2020/01/11 17:33:53 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.783 $ */
+/* NetHack 3.6 extern.h        $NHDT-Date: 1578895332 2020/01/13 06:02:12 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.785 $ */
 /* Copyright (c) Steve Creps, 1988.                              */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1342,8 +1342,9 @@ E void FDECL(new_omailcmd, (struct obj *, const char *));
 E void FDECL(free_omailcmd, (struct obj *));
 E struct obj *FDECL(mkobj_at, (CHAR_P, int, int, BOOLEAN_P));
 E struct obj *FDECL(mksobj_at, (int, int, int, BOOLEAN_P, BOOLEAN_P));
-E struct obj *FDECL(mksobj_migr_to_species, (int, unsigned, BOOLEAN_P, BOOLEAN_P));
-E struct obj *FDECL(mkobj, (CHAR_P, BOOLEAN_P));
+E struct obj *FDECL(mksobj_migr_to_species, (int, unsigned,
+                                             BOOLEAN_P, BOOLEAN_P));
+E struct obj *FDECL(mkobj, (int, BOOLEAN_P));
 E int NDECL(rndmonnum);
 E boolean FDECL(bogon_is_pname, (CHAR_P));
 E struct obj *FDECL(splitobj, (struct obj *, long));
index a74526c78737aae42b789e36cd414147b656a7ba..031d8595ed2543f2c0b0ceae2bef178f0dbbe7bc 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 objclass.h      $NHDT-Date: 1547255901 2019/01/12 01:18:21 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.20 $ */
+/* NetHack 3.6 objclass.h      $NHDT-Date: 1578895344 2020/01/13 06:02:24 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.21 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Pasi Kallinen, 2018. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -163,6 +163,8 @@ enum obj_class_types {
 
     MAXOCLASSES  = 18
 };
+/* for mkobj() use ONLY! odd '-SPBOOK_CLASS' is in case of unsigned enums */
+#define SPBOOK_no_NOVEL (0 - (int) SPBOOK_CLASS)
 
 #define ALLOW_COUNT (MAXOCLASSES + 1) /* Can be used in the object class    */
 #define ALL_CLASSES (MAXOCLASSES + 2) /* input to getobj().                 */
index 15fd1f90c54e05062f806282252f15f3605bed4d..91e12b88282f523677666128d130357bc83d4803 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 mkobj.c $NHDT-Date: 1578855620 2020/01/12 19:00:20 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.173 $ */
+/* NetHack 3.6 mkobj.c $NHDT-Date: 1578895344 2020/01/13 06:02:24 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.174 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Derek S. Ray, 2015. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -245,7 +245,7 @@ boolean init, artif;
    result is always non-Null */
 struct obj *
 mkobj(oclass, artif)
-char oclass;
+int oclass;
 boolean artif;
 {
     int tprob, i, prob = rnd(1000);
@@ -257,13 +257,18 @@ boolean artif;
                                             : (const struct icp *) mkobjprobs;
 
         for (tprob = rnd(100); (tprob -= iprobs->iprob) > 0; iprobs++)
-            ;
+            continue;
         oclass = iprobs->iclass;
     }
 
-    i = g.bases[(int) oclass];
-    while ((prob -= objects[i].oc_prob) > 0)
-        i++;
+    if (oclass == SPBOOK_no_NOVEL) {
+        i = rnd_class(g.bases[SPBOOK_CLASS], SPE_BLANK_PAPER);
+        oclass = SPBOOK_CLASS; /* for sanity check below */
+    } else {
+        i = g.bases[oclass];
+        while ((prob -= objects[i].oc_prob) > 0)
+            ++i;
+    }
 
     if (objects[i].oc_class != oclass || !OBJ_NAME(objects[i]))
         panic("probtype error, oclass=%d i=%d", (int) oclass, i);
@@ -1054,10 +1059,10 @@ 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));
+                    (void) add_to_container(otmp,
+                                            mkobj(SPBOOK_no_NOVEL, FALSE));
             }
             break;
         case COIN_CLASS:
index b028ea10961e5d4803823942eadaf740ec516ab0..173996c09c42e82609992a73de2b1b3e4edee790 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 pray.c  $NHDT-Date: 1578855625 2020/01/12 19:00:25 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.137 $ */
+/* NetHack 3.6 pray.c  $NHDT-Date: 1578895347 2020/01/13 06:02:27 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.138 $ */
 /* Copyright (c) Benson I. Margulies, Mike Stephenson, Steve Linhart, 1989. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1182,12 +1182,8 @@ aligntyp g_align;
             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;
-               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);
+               also, try to grant a spell for which there is a skill slot */
+            otmp = mkobj(SPBOOK_no_NOVEL, TRUE);
             while (--trycnt > 0) {
                 if (otmp->otyp != SPE_BLANK_PAPER) {
                     for (sp_no = 0; sp_no < MAXSPELL; sp_no++)
index 6521df407444fbdedf71316e43e7ae7fb9b2cc3a..ad17c0b8b00b1277b1eb3a78d08ae59857a69467 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 priest.c        $NHDT-Date: 1578855626 2020/01/12 19:00:26 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.56 $ */
+/* NetHack 3.6 priest.c        $NHDT-Date: 1578895348 2020/01/13 06:02:28 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.57 $ */
 /* Copyright (c) Izchak Miller, Steve Linhart, 1989.              */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -258,10 +258,7 @@ boolean sanctum; /* is it the seat of the high priest? */
         }
         /* 2 to 4 spellbooks */
         for (cnt = rn1(3, 2); cnt > 0; --cnt) {
-            /* 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));
+            (void) mpickobj(priest, mkobj(SPBOOK_no_NOVEL, FALSE));
         }
         /* robe [via makemon()] */
         if (rn2(2) && (otmp = which_armor(priest, W_ARMC)) != 0) {