1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.eat.c - version 1.0.3 */
3 /* $FreeBSD: src/games/hack/hack.eat.c,v 1.4 1999/11/16 10:26:36 marcel Exp $ */
6 char POISONOUS[] = "ADKSVabhks";
8 static bool opentin(void);
9 static void Meatdone(void);
10 static void unfaint(void);
11 static void newuhs(bool);
12 static int eatcorpse(struct obj *);
14 /* hunger texts used on bottom line (each 8 chars long) */
23 const char *hu_stat[] = {
40 #define TTSZ SIZE(tintxts)
41 struct { const char *txt; int nut; } tintxts[] = {
42 { "It contains first quality peaches - what a surprise!", 40 },
43 { "It contains salmon - not bad!", 60 },
44 { "It contains apple juice - perhaps not what you hoped for.", 20 },
45 { "It contains some nondescript substance, tasting awfully.", 500 },
46 { "It contains rotten meat. You vomit.", -50 },
47 { "It turns out to be empty.", 0 }
52 int usedtime, reqtime;
60 if (!carried(tin.tin)) /* perhaps it was stolen? */
61 return (0); /* %% probably we should use tinoid */
62 if (tin.usedtime++ >= 50) {
63 pline("You give up your attempt to open the tin.");
66 if (tin.usedtime < tin.reqtime)
67 return (1); /* still busy */
69 pline("You succeed in opening the tin.");
73 pline("%s", tintxts[r].txt);
74 lesshungry(tintxts[r].nut);
75 if (r == 1) { /* SALMON */
77 pline("Eating salmon made your fingers very slippery.");
80 pline("It contains spinach - this makes you feel like Popeye!");
83 u.ustr += rnd(((u.ustr < 17) ? 19 : 118) - u.ustr);
84 if (u.ustr > u.ustrmax)
102 struct objclass *ftmp;
105 /* Is there some food (probably a heavy corpse) here on the ground? */
107 for (otmp = fobj; otmp; otmp = otmp->nobj) {
108 if (otmp->ox == u.ux && otmp->oy == u.uy &&
109 otmp->olet == FOOD_SYM) {
110 pline("There %s %s here; eat %s? [ny] ",
111 (otmp->quan == 1) ? "is" : "are",
113 (otmp->quan == 1) ? "it" : "one");
114 if (readchar() == 'y') {
125 otmp = getobj("%", "eat");
129 if (otmp->otyp == TIN) {
131 switch (uwep->otyp) {
146 pline("Using your %s you try to open the tin.",
147 aobjnam(uwep, NULL));
150 pline("It is not so easy to open this tin.");
152 pline("The tin slips out of your hands.");
153 if (otmp->quan > 1) {
156 obj = splitobj(otmp, 1);
163 tmp = 10 + rn2(1 + 500 / ((int)(u.ulevel + u.ustr)));
168 occupation = opentin;
169 occtxt = "opening the tin";
172 ftmp = &objects[otmp->otyp];
173 multi = -ftmp->oc_delay;
174 if (otmp->otyp >= CORPSE && eatcorpse(otmp))
176 if (!rn2(7) && otmp->otyp != FORTUNE_COOKIE) {
177 pline("Blecch! Rotten food!");
179 pline("You feel rather light headed.");
180 Confusion += d(2, 4);
181 } else if (!rn2(4) && !Blind) {
182 pline("Everything suddenly goes dark.");
185 } else if (!rn2(3)) {
187 pline("The world spins and you slap against the floor.");
189 pline("The world spins and goes dark.");
191 nomovemsg = "You are conscious again.";
193 lesshungry(ftmp->nutrition / 4);
195 if (u.uhunger >= 1500) {
196 pline("You choke over your food.");
198 killer = ftmp->oc_name;
201 switch (otmp->otyp) {
203 if (u.uhunger <= 200)
204 pline("That food really hit the spot!");
205 else if (u.uhunger <= 700)
206 pline("That satiated your stomach!");
208 pline("You're having a hard time getting all that food down.");
211 lesshungry(ftmp->nutrition);
213 nomovemsg = "You finished your meal.";
216 pline("Yak - dog food!");
217 more_experienced(1, 0);
223 Sick = 0; /* David Neves */
224 pline("What a relief!");
227 lesshungry(ftmp->nutrition);
230 if (otmp->otyp >= CORPSE)
231 pline("That %s tasted terrible!", ftmp->oc_name);
233 pline("That %s was delicious!", ftmp->oc_name);
234 lesshungry(ftmp->nutrition);
235 if (otmp->otyp == DEAD_LIZARD && (Confusion > 2))
239 if (otmp->otyp == CARROT && !Blind) {
242 pline("Your vision improves.");
245 if (otmp->otyp == FORTUNE_COOKIE) {
247 pline("This cookie has a scrap of paper inside!");
248 pline("What a pity, that you cannot read it!");
251 } else if (otmp->otyp == LUMP_OF_ROYAL_JELLY) {
252 /* This stuff seems to be VERY healthy! */
255 if (u.ustr < u.ustrmax)
258 if (u.uhp > u.uhpmax) {
269 if (multi < 0 && !nomovemsg) {
270 static char msgbuf[BUFSZ];
271 sprintf(msgbuf, "You finished eating the %s.", ftmp->oc_name);
278 /* called in hack.main.c */
288 /* a3: if (Hunger & LEFT_RING) u.uhunger--;
289 * if (Hunger & RIGHT_RING) u.uhunger--;
293 if (moves % 20 == 0) { /* jimt@asgb */
302 /* called after vomiting and after performing feats of magic */
310 /* called after eating something (and after drinking fruit juice) */
328 int newhs, h = u.uhunger;
330 newhs = (h > 1000) ? SATIATED :
331 (h > 150) ? NOT_HUNGRY :
333 (h > 0) ? WEAK : FAINTING;
335 if (newhs == FAINTING) {
336 if (u.uhs == FAINTED)
338 if (u.uhs <= WEAK || rn2(20 - u.uhunger / 10) >= 19) {
339 if (u.uhs != FAINTED && multi >= 0 /* %% */) {
340 pline("You faint from lack of food.");
341 nomul(-10 + (u.uhunger / 10));
342 nomovemsg = "You regain consciousness.";
346 } else if (u.uhunger < -(int)(200 + 25 * u.ulevel)) {
350 pline("You die from starvation.");
355 if (newhs != u.uhs) {
356 if (newhs >= WEAK && u.uhs < WEAK)
357 losestr(1); /* this may kill you -- see below */
358 else if (newhs < WEAK && u.uhs >= WEAK && u.ustr < u.ustrmax)
362 pline((!incr) ? "You only feel hungry now." :
363 (u.uhunger < 145) ? "You feel hungry." :
364 "You are beginning to feel hungry.");
367 pline((!incr) ? "You feel weak now." :
368 (u.uhunger < 45) ? "You feel weak." :
369 "You are beginning to feel weak.");
375 pline("You die from hunger and exhaustion.");
376 killer = "exhaustion";
382 #define CORPSE_I_TO_C(otyp) (char)((otyp >= DEAD_ACID_BLOB)\
383 ? 'a' + (otyp - DEAD_ACID_BLOB)\
384 : '@' + (otyp - DEAD_HUMAN))
386 poisonous(struct obj *otmp)
388 return (strchr(POISONOUS, CORPSE_I_TO_C(otmp->otyp)) != 0);
391 /* returns 1 if some text was printed */
393 eatcorpse(struct obj *otmp)
395 char let = CORPSE_I_TO_C(otmp->otyp);
398 if (let != 'a' && moves > otmp->age + 50 + rn2(100)) {
400 pline("Ulch -- that meat was tainted!");
401 pline("You get very sick.");
403 u.usick_cause = objects[otmp->otyp].oc_name;
404 } else if (strchr(POISONOUS, let) && rn2(5)) {
406 pline("Ecch -- that must have been poisonous!");
407 if (!Poison_resistance) {
409 losehp(rnd(15), "poisonous corpse");
411 pline("You don't seem affected by the poison.");
412 } else if (strchr("ELNOPQRUuxz", let) && rn2(5)) {
414 pline("You feel sick.");
415 losehp(rnd(8), "cadaver");
421 Teleportation |= INTRINSIC;
431 pline("You cannibal! You will be sorry for this!");
435 Aggravate_monster |= INTRINSIC;
439 Invis = 50 + rn2(100);
444 See_invisible |= INTRINSIC;
456 Fire_resistance |= INTRINSIC;
459 Telepat |= INTRINSIC;
463 Cold_resistance |= INTRINSIC;
467 Poison_resistance |= INTRINSIC;
470 pline("You turn to stone.");
471 killer = "dead cockatrice";
474 exit(1); /* hint for a compiler */
477 pline("What a pity - you just destroyed a future piece of art!");
483 pline("You cannot resist the temptation to mimic a treasure chest.");
487 nomovemsg = "You now again prefer mimicking a human.";