]> granicus.if.org Git - nethack/commitdiff
tin variety (trunk only)
authornethack.allison <nethack.allison>
Tue, 28 Oct 2003 03:45:49 +0000 (03:45 +0000)
committernethack.allison <nethack.allison>
Tue, 28 Oct 2003 03:45:49 +0000 (03:45 +0000)
- store the variety of tin at tin creation time
  rather than at tin-opening time (as a negative
  value in spe just as homemade was; spinach
   is still spe 1)

Allow wishing for a particular variety of tin
from the tin variety list:
"deep fried", "boiled","broiled","candied"
"dried", "french fried", "homemade"
"pickled", "pureed", "rotten", "sauteed"
"smoked", "soup made from", "stir fried",
"szechuan"
Example: "tin of soup made from orc"

non-debug player could randomly fail on the
variety specification 1 in 4 times

doc/fixes35.0
include/extern.h
include/hack.h
src/eat.c
src/mkobj.c
src/objnam.c

index 2fe8885bc2ded7d761dd14480d9cf286dd8ac8ca..223ef539daa1e8359f88ef930101040e5f344507 100644 (file)
@@ -78,6 +78,7 @@ the following actions can now be continued after save/restore: digging,
        eating, studying, removing armor
 hero-created and monster-created ice will eventually melt away
 extend Warning to include ice danger
+wishing for particular variety of tin contents (deep fried, broiled, etc.)
 
 
 Platform- and/or Interface-Specific New Features
index 4bf999483792e17cbe94aa69205ba5c9dc913340..cf75f6a6b21096783a61afef30023373899309e1 100644 (file)
@@ -541,6 +541,8 @@ E void FDECL(food_substitution, (struct obj *,struct obj *));
 E void NDECL(fix_petrification);
 E void FDECL(consume_oeaten, (struct obj *,int));
 E boolean FDECL(maybe_finished_meal, (BOOLEAN_P));
+E void FDECL(set_tin_variety, (struct obj *,int));
+E int FDECL(tin_variety_txt, (char *,int *));
 
 /* ### end.c ### */
 
index cd9fac8e58be4ae124a28d13696963f1c86fa358..784568a80a380f7beb183383aef4d2a84ee37d3f 100644 (file)
@@ -252,6 +252,12 @@ NEARDATA extern coord bhitpos;     /* place where throw or zap hits or stops */
 #define NOSE 17
 #define STOMACH 18
 
+/* indexes for some special tin types */
+#define ROTTEN_TIN 4
+#define HOMEMADE_TIN 5
+#define FRENCH_FRIED_TIN 11
+#define SPINACH_TIN (-1)
+
 /* Flags to control menus */
 #define MENUTYPELEN sizeof("traditional ")
 #define MENU_TRADITIONAL 0
index 453ac7f74eb1b358e642650d7ea8cd1a4ed26e80..7bfa30d7d5b27bdd3194cdc1835e859ea425dbe5 100644 (file)
--- a/src/eat.c
+++ b/src/eat.c
@@ -42,6 +42,7 @@ STATIC_DCL int FDECL(rottenfood, (struct obj *));
 STATIC_DCL void NDECL(eatspecial);
 STATIC_DCL void FDECL(eataccessory, (struct obj *));
 STATIC_DCL const char *FDECL(foodword, (struct obj *));
+STATIC_DCL int FDECL(tin_variety, (struct obj *));
 
 char msgbuf[BUFSZ];
 
@@ -117,17 +118,14 @@ static const struct { const char *txt; int nut; } tintxts[] = {
        {"pickled",      40},
        {"soup made from", 20},
        {"pureed",      500},
-#define ROTTEN_TIN 4
-       {"rotten",      -50},
-#define HOMEMADE_TIN 5
-       {"homemade",     50},
+       {"rotten",      -50},   /* ROTTEN_TIN = 4 */
+       {"homemade",     50},   /* HOMEMADE_TIN = 5 */
        {"stir fried",   80},
        {"candied",      100},
        {"boiled",       50},
        {"dried",        55},
        {"szechuan",     70},
-#define FRENCH_FRIED_TIN 11
-       {"french fried", 40},
+       {"french fried", 40},   /* FRENCH_FRIED_TIN = 11 */
        {"sauteed",      95},
        {"broiled",      80},
        {"smoked",       50},
@@ -979,6 +977,70 @@ costly_tin(verb)
        }
 }
 
+int
+tin_variety_txt(s,tinvariety)
+char *s;
+int *tinvariety;
+{
+       int k, l;
+       if (s && tinvariety) {
+           *tinvariety = -1;
+           for (k = 0; k < TTSZ-1; ++k) {
+               l = (int)strlen(tintxts[k].txt);
+               if (!strncmpi(s, tintxts[k].txt, l) &&
+                       ((int)strlen(s) > l) && s[l] == ' ') {
+                       *tinvariety = k;
+                       return (l + 1);
+               }
+           }
+       }
+       return 0;
+}
+
+void
+set_tin_variety(obj, forcetype)
+struct obj *obj;
+int forcetype;
+{
+       register int r;
+       if (forcetype == SPINACH_TIN) {
+               obj->spe = 1;
+               return;
+       } else if (forcetype >= 0 && forcetype < TTSZ-1) {
+               r = forcetype;
+       } else {
+               r = rn2(TTSZ-1);                /* take your pick */
+               if (r == ROTTEN_TIN && (obj->corpsenm == PM_LIZARD ||
+                                       obj->corpsenm == PM_LICHEN))
+                       r = HOMEMADE_TIN;       /* lizards don't rot */
+       }
+       obj->spe = -(r+1);
+}
+
+STATIC_OVL int
+tin_variety(obj)
+struct obj *obj;
+{
+       register int r;
+
+       if (obj->spe != 1 && obj->cursed) {
+               r = ROTTEN_TIN;                 /* always rotten if cursed */
+       } else if (obj->spe < 0) {
+               r = -(obj->spe);
+               --r;
+       } else 
+               r = rn2(TTSZ-1);
+
+       if (r == HOMEMADE_TIN &&
+                !obj->blessed && !rn2(7))
+               r = ROTTEN_TIN;                 /* some homemade tins go bad */ 
+
+       if (r == ROTTEN_TIN && (obj->corpsenm == PM_LIZARD ||
+                               obj->corpsenm == PM_LICHEN))
+               r = HOMEMADE_TIN;               /* lizards don't rot */
+       return r;
+}
+
 STATIC_PTR
 int
 opentin()              /* called during each move whilst opening a tin */
@@ -1010,14 +1072,7 @@ opentin()                /* called during each move whilst opening a tin */
                costly_tin((const char*)0);
                goto use_me;
            }
-           r = context.tin.tin->cursed ? ROTTEN_TIN :  /* always rotten if cursed */
-                   (context.tin.tin->spe == -1) ? HOMEMADE_TIN :  /* player made it */
-                       rn2(TTSZ-1);            /* else take your pick */
-           if (r == ROTTEN_TIN && (context.tin.tin->corpsenm == PM_LIZARD ||
-                       context.tin.tin->corpsenm == PM_LICHEN))
-               r = HOMEMADE_TIN;               /* lizards don't rot */
-           else if (context.tin.tin->spe == -1 && !context.tin.tin->blessed && !rn2(7))
-               r = ROTTEN_TIN;                 /* some homemade tins go bad */
+           r = tin_variety(context.tin.tin);
            which = 0;  /* 0=>plural, 1=>as-is, 2=>"the" prefix */
            if (Hallucination) {
                what = rndmonnam();
index cb5102b6a4755db576223ff600010bdd000435a1..b245828299185d67796a11bdfd13384848a77816 100644 (file)
@@ -425,12 +425,13 @@ boolean artif;
            case TIN:
                otmp->corpsenm = NON_PM;        /* empty (so far) */
                if (!rn2(6))
-                   otmp->spe = 1;              /* spinach */
+                   set_tin_variety(otmp, SPINACH_TIN);
                else for (tryct = 200; tryct > 0; --tryct) {
                    mndx = undead_to_corpse(rndmonnum());
                    if (mons[mndx].cnutrit &&
                            !(mvitals[mndx].mvflags & G_NOCORPSE)) {
                        otmp->corpsenm = mndx;
+                       set_tin_variety(otmp, 0);
                        break;
                    }
                }
index 8462d811058de9e7d30445c6e50cf6526db9d8d0..3f5cf20a0c2c31657926eac7bf0b43326f87b77b 100644 (file)
@@ -1772,6 +1772,7 @@ boolean from_user;
 #endif
        int halfeaten, mntmp, contents;
        int islit, unlabeled, ishistoric, isdiluted;
+       int tmp, tinv, tvariety;
        struct fruit *f;
        int ftype = current_fruit;
        char fruitbuf[BUFSZ];
@@ -1801,6 +1802,7 @@ boolean from_user;
 #endif
                ispoisoned = isgreased = eroded = eroded2 = erodeproof =
                halfeaten = islit = unlabeled = ishistoric = isdiluted = 0;
+       tvariety = -1;
        mntmp = NON_PM;
 #define UNDEFINED 0
 #define EMPTY 1
@@ -2013,7 +2015,12 @@ boolean from_user;
        if (!strstri(bp, "wand ")
         && !strstri(bp, "spellbook ")
         && !strstri(bp, "finger ")) {
-           if ((p = strstri(bp, " of ")) != 0
+           if (((p = strstri(bp, "tin of ")) != 0) &&
+               (tmp = tin_variety_txt(p+7, &tinv)) &&
+               (mntmp = name_to_mon(p+7+tmp)) >= LOW_PM) {
+               *(p+3) = 0;
+               tvariety = tinv;
+           } else if ((p = strstri(bp, " of ")) != 0
                && (mntmp = name_to_mon(p+4)) >= LOW_PM)
                *p = 0;
        }
@@ -2683,6 +2690,15 @@ typfnd:
                        otmp->otyp != POT_WATER)
                otmp->odiluted = 1;
 
+       /* set tin variety */
+       if (otmp->otyp == TIN && tvariety >= 0 && 
+               (rn2(4)
+#ifdef WIZARD
+                       || wizard
+#endif
+                                       ))
+               set_tin_variety(otmp, tvariety);
+
        if (name) {
                const char *aname;
                short objtyp;