]> granicus.if.org Git - nethack/commitdiff
more health food shops (trunk only)
authornethack.rankin <nethack.rankin>
Sun, 13 Mar 2005 05:29:01 +0000 (05:29 +0000)
committernethack.rankin <nethack.rankin>
Sun, 13 Mar 2005 05:29:01 +0000 (05:29 +0000)
     Allow health food stores to carry eggs and tins of veggy contents in
their stock.  The tins will almost always contain spinach because random
tins containing meat are converted into that.

     Also, allow health food stores to be placed with the level compiler
(not tested) and to be forcibly placed in wizard mode via SHOPTYPE setting
of "V".  Increments EDITLEVEL in patchlevel.h because lighting store in
Minetown got renumbered and the special level for it needs to be rebuilt.

include/mkroom.h
include/patchlevel.h
src/mkroom.c
src/shknam.c
util/lev_main.c

index a2da67cbb270c2ab08970a59d6962c3ce6a125f1..a67f349ecd4a97fd1d29e3bf17745928ab6bc985 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)mkroom.h   3.5     1992/11/14      */
+/*     SCCS Id: @(#)mkroom.h   3.5     2005/03/12      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -71,9 +71,10 @@ extern NEARDATA coord doors[DOORMAX];
 #define WANDSHOP       21
 #define TOOLSHOP       22
 #define BOOKSHOP       23
-#define UNIQUESHOP     24      /* shops here & above not randomly gen'd. */
-#define CANDLESHOP     24
-#define MAXRTYPE       24      /* maximum valid room type */
+#define FODDERSHOP     24      /* health food store */
+#define UNIQUESHOP     25      /* shops here & below not randomly gen'd. */
+#define CANDLESHOP     25
+#define MAXRTYPE       25      /* maximum valid room type */
 
 /* Special type for search_special() */
 #define ANY_TYPE       (-1)
index 1be0e6e0517a8d05e64ef3e3a4f7050eba969203..af645b65e27320f503c7c0aa0c453f617e769624 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)patchlevel.h       3.5     2005/01/22      */
+/*     SCCS Id: @(#)patchlevel.h       3.5     2005/03/12      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -13,7 +13,7 @@
  * Incrementing EDITLEVEL can be used to force invalidation of old bones
  * and save files.
  */
-#define EDITLEVEL      20
+#define EDITLEVEL      21
 
 #define COPYRIGHT_BANNER_A \
 "NetHack, Copyright 1985-2005"
index d78c16023247d9073f8aa6af81c3aca2cfe054cc..8683611bed46aeb91c52c079e7cc52005f8db9b2 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)mkroom.c   3.5     2004/06/10      */
+/*     SCCS Id: @(#)mkroom.c   3.5     2005/03/12      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -119,6 +119,8 @@ mkshop()
                                    goto gottype;
                        if(*ep == 'g' || *ep == 'G')
                                i = 0;
+                       else if (*ep == 'v' || *ep == 'V')
+                               i = FODDERSHOP - SHOPBASE;  /* veggy food */
                        else
                                i = -1;
                }
index 77996e924c6c39a0c909d27d891aa5ddb5607115..1d875956ff17bd73cbe92139af43e2130e38465f 100644 (file)
@@ -7,6 +7,9 @@
 #include "hack.h"
 #include "eshk.h"
 
+STATIC_DCL boolean FDECL(veggy_item, (struct obj *obj,int));
+STATIC_DCL int NDECL(shkveg);
+STATIC_DCL void FDECL(mkveggy_at, (int,int));
 STATIC_DCL void FDECL(mkshobj_at, (const struct shclass *,int,int));
 STATIC_DCL void FDECL(nameshk, (struct monst *,const char * const *));
 STATIC_DCL int  FDECL(shkinit, (const struct shclass *,struct mkroom *));
@@ -267,6 +270,38 @@ init_shop_selection()
 }
 #endif /*0*/
 
+/* decide whether an object or object type is considered vegetarian;
+   for types, items which might go either way are assumed to be veggy */
+STATIC_OVL boolean
+veggy_item(obj, otyp)
+struct obj *obj;
+int otyp;              /* used iff obj is null */
+{
+    int corpsenm;
+    char oclass;
+
+    if (obj) {
+       /* actual object; will check tin content and corpse species */
+       otyp = (int) obj->otyp;
+       oclass = obj->oclass;
+       corpsenm = obj->corpsenm;
+    } else {
+       /* just a type; caller will have to handle tins and corpses */
+       oclass = objects[otyp].oc_class;
+       corpsenm = PM_LICHEN;           /* veggy standin */
+    }
+
+    if (oclass == FOOD_CLASS) {
+       if (objects[otyp].oc_material == VEGGY || otyp == EGG)
+           return TRUE;
+       if (otyp == TIN && corpsenm == NON_PM)  /* implies obj is non-null */
+           return (obj->spe == 1);             /* 0 = empty, 1 = spinach */
+       if (otyp == TIN || otyp == CORPSE)
+           return (corpsenm >= LOW_PM && vegetarian(&mons[corpsenm]));
+    }
+    return FALSE;
+}
+
 STATIC_OVL int
 shkveg()
 {
@@ -276,11 +311,14 @@ shkveg()
 
        j = maxprob = 0;
        for (i = bases[(int)oclass]; i < NUM_OBJECTS; ++i) {
-               if (objects[i].oc_material == VEGGY) {
+               if (objects[i].oc_class != oclass) break;
+
+               if (veggy_item((struct obj *)0, i)) {
                        ok[j++] = i;
                        maxprob += objects[i].oc_prob;
                }
        }
+       if (maxprob < 1) panic("shkveg no veggy objects");
        prob = rnd(maxprob);
 
        j = 0;
@@ -295,6 +333,18 @@ shkveg()
        return i;
 }
 
+/* make a random item for health food store */
+STATIC_OVL void
+mkveggy_at(sx, sy)
+int sx, sy;
+{
+    struct obj *obj = mksobj_at(shkveg(), sx, sy, TRUE, TRUE);
+
+    if (obj && obj->otyp == TIN)
+       set_tin_variety(obj, HEALTHY_TIN);
+    return;
+}
+
 STATIC_OVL void
 mkshobj_at(shp, sx, sy)
 /* make an object of the appropriate type for a shop square */
@@ -316,7 +366,7 @@ int sx, sy;
        } else {
            atype = get_shop_item(shp - shtypes);
            if (atype == VEGETARIAN_CLASS)
-               (void) mksobj_at(shkveg(), sx, sy, TRUE, TRUE);
+               mkveggy_at(sx, sy);
            else if (atype < 0)
                (void) mksobj_at(-atype, sx, sy, TRUE, TRUE);
            else
@@ -564,15 +614,7 @@ struct obj *obj;
     for (i = 0; i < SIZE(shtypes[0].iprobs) && shp->iprobs[i].iprob; i++) {
        /* pseudo-class needs special handling */
        if (shp->iprobs[i].itype == VEGETARIAN_CLASS) {
-           if ((obj->otyp == TIN || obj->otyp == CORPSE) &&
-                   ((obj->corpsenm >= LOW_PM &&
-                       vegetarian(&mons[obj->corpsenm])) ||
-                    (obj->otyp == TIN && obj->spe == 1)))      /* spinach */
-               return TRUE;
-           if (obj->oclass == FOOD_CLASS &&
-                   (objects[obj->otyp].oc_material == VEGGY ||
-                       obj->otyp == EGG))
-               return TRUE;
+           if (veggy_item(obj, 0)) return TRUE;
        } else if ((shp->iprobs[i].itype < 0) ?
                        shp->iprobs[i].itype == - obj->otyp :
                        shp->iprobs[i].itype == obj->oclass)
index a6c3bb119720ff7b1365e605c41a99df9adf065a..e39d19929a9b4df04015abe7fd9e42fa7eb55341 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)lev_main.c 3.5     2002/03/27      */
+/*     SCCS Id: @(#)lev_main.c 3.5     2005/03/12      */
 /*     Copyright (c) 1989 by Jean-Christophe Collet */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -162,6 +162,7 @@ static struct {
        { "wand shop",   WANDSHOP },
        { "tool shop",   TOOLSHOP },
        { "book shop",   BOOKSHOP },
+       { "health food shop", FODDERSHOP },
        { "candle shop", CANDLESHOP },
        { 0, 0 }
 };