tin variety (trunk only)

- 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
This commit is contained in:
nethack.allison
2003-10-28 03:45:49 +00:00
parent f66a750562
commit d08dcbc3fb
6 changed files with 97 additions and 16 deletions

View 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

View 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 ### */

View 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

View File

@@ -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();

View 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;
}
}

View 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;