From 3d3088554c09884525e11f0c564e89e7c62688d4 Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Sun, 6 Mar 2005 06:42:41 +0000 Subject: [PATCH] selling health food (trunk only) I didn't remember a new shop type of "health food store" being added. While trying to test some shop changes, it sure threw me for a loop when a shopkeeper who sold lots of food refused to buy any. This patch teaches such shks to buy vegetarian food. (No fixes entry included since the relevant code hasn't been released yet.) Shouldn't such shops sometimes carry tins and eggs in their initial stock? They currently don't because those items fail the material==VEGGY test. Adding eggs would be easy; tins are messier since you can't decide whether they're vegetarian until after they've been created. --- src/shknam.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/shknam.c b/src/shknam.c index 20ae230dd..77996e924 100644 --- a/src/shknam.c +++ b/src/shknam.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)shknam.c 3.5 2003/01/09 */ +/* SCCS Id: @(#)shknam.c 3.5 2005/03/05 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -559,11 +559,25 @@ struct obj *obj; int i, shp_indx = ESHK(shkp)->shoptype - SHOPBASE; const struct shclass *shp = &shtypes[shp_indx]; - if (shp->symb == RANDOM_CLASS) return TRUE; - else for (i = 0; i < SIZE(shtypes[0].iprobs) && shp->iprobs[i].iprob; i++) - if (shp->iprobs[i].itype < 0 ? + if (shp->symb == RANDOM_CLASS) + return TRUE; + 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; + } else if ((shp->iprobs[i].itype < 0) ? shp->iprobs[i].itype == - obj->otyp : - shp->iprobs[i].itype == obj->oclass) return TRUE; + shp->iprobs[i].itype == obj->oclass) + return TRUE; + } /* not found */ return FALSE; } -- 2.40.0