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 $ */
4 /* $DragonFly: src/games/hack/hack.eat.c,v 1.5 2006/08/21 19:45:32 pavalos Exp $ */
7 char POISONOUS[] = "ADKSVabhks";
9 static bool opentin(void);
10 static void Meatdone(void);
11 static void unfaint(void);
12 static void newuhs(bool);
13 static int eatcorpse(struct obj *);
15 /* hunger texts used on bottom line (each 8 chars long) */
24 const char *hu_stat[] = {
41 #define TTSZ SIZE(tintxts)
42 struct { const char *txt; int nut; } tintxts[] = {
43 { "It contains first quality peaches - what a surprise!", 40 },
44 { "It contains salmon - not bad!", 60 },
45 { "It contains apple juice - perhaps not what you hoped for.", 20 },
46 { "It contains some nondescript substance, tasting awfully.", 500 },
47 { "It contains rotten meat. You vomit.", -50 },
48 { "It turns out to be empty.", 0 }
53 int usedtime, reqtime;
61 if (!carried(tin.tin)) /* perhaps it was stolen? */
62 return (0); /* %% probably we should use tinoid */
63 if (tin.usedtime++ >= 50) {
64 pline("You give up your attempt to open the tin.");
67 if (tin.usedtime < tin.reqtime)
68 return (1); /* still busy */
70 pline("You succeed in opening the tin.");
74 pline(tintxts[r].txt);
75 lesshungry(tintxts[r].nut);
76 if (r == 1) { /* SALMON */
78 pline("Eating salmon made your fingers very slippery.");
81 pline("It contains spinach - this makes you feel like Popeye!");
84 u.ustr += rnd(((u.ustr < 17) ? 19 : 118) - u.ustr);
85 if (u.ustr > u.ustrmax)
103 struct objclass *ftmp;
106 /* Is there some food (probably a heavy corpse) here on the ground? */
108 for (otmp = fobj; otmp; otmp = otmp->nobj) {
109 if (otmp->ox == u.ux && otmp->oy == u.uy &&
110 otmp->olet == FOOD_SYM) {
111 pline("There %s %s here; eat %s? [ny] ",
112 (otmp->quan == 1) ? "is" : "are",
114 (otmp->quan == 1) ? "it" : "one");
115 if (readchar() == 'y') {
126 otmp = getobj("%", "eat");
130 if (otmp->otyp == TIN) {
132 switch (uwep->otyp) {
147 pline("Using your %s you try to open the tin.",
148 aobjnam(uwep, NULL));
151 pline("It is not so easy to open this tin.");
153 pline("The tin slips out of your hands.");
154 if (otmp->quan > 1) {
157 obj = splitobj(otmp, 1);
164 tmp = 10 + rn2(1 + 500 / ((int)(u.ulevel + u.ustr)));
169 occupation = opentin;
170 occtxt = "opening the tin";
173 ftmp = &objects[otmp->otyp];
174 multi = -ftmp->oc_delay;
175 if (otmp->otyp >= CORPSE && eatcorpse(otmp))
177 if (!rn2(7) && otmp->otyp != FORTUNE_COOKIE) {
178 pline("Blecch! Rotten food!");
180 pline("You feel rather light headed.");
181 Confusion += d(2, 4);
182 } else if (!rn2(4) && !Blind) {
183 pline("Everything suddenly goes dark.");
186 } else if (!rn2(3)) {
188 pline("The world spins and you slap against the floor.");
190 pline("The world spins and goes dark.");
192 nomovemsg = "You are conscious again.";
194 lesshungry(ftmp->nutrition / 4);
196 if (u.uhunger >= 1500) {
197 pline("You choke over your food.");
199 killer = ftmp->oc_name;
202 switch (otmp->otyp) {
204 if (u.uhunger <= 200)
205 pline("That food really hit the spot!");
206 else if (u.uhunger <= 700)
207 pline("That satiated your stomach!");
209 pline("You're having a hard time getting all that food down.");
212 lesshungry(ftmp->nutrition);
214 nomovemsg = "You finished your meal.";
217 pline("Yak - dog food!");
218 more_experienced(1, 0);
224 Sick = 0; /* David Neves */
225 pline("What a relief!");
228 lesshungry(ftmp->nutrition);
231 if (otmp->otyp >= CORPSE)
232 pline("That %s tasted terrible!", ftmp->oc_name);
234 pline("That %s was delicious!", ftmp->oc_name);
235 lesshungry(ftmp->nutrition);
236 if (otmp->otyp == DEAD_LIZARD && (Confusion > 2))
240 if (otmp->otyp == CARROT && !Blind) {
243 pline("Your vision improves.");
246 if (otmp->otyp == FORTUNE_COOKIE) {
248 pline("This cookie has a scrap of paper inside!");
249 pline("What a pity, that you cannot read it!");
252 } else if (otmp->otyp == LUMP_OF_ROYAL_JELLY) {
253 /* This stuff seems to be VERY healthy! */
256 if (u.ustr < u.ustrmax)
259 if (u.uhp > u.uhpmax) {
270 if (multi < 0 && !nomovemsg) {
271 static char msgbuf[BUFSZ];
272 sprintf(msgbuf, "You finished eating the %s.", ftmp->oc_name);
279 /* called in hack.main.c */
289 /* a3: if (Hunger & LEFT_RING) u.uhunger--;
290 * if (Hunger & RIGHT_RING) u.uhunger--;
294 if (moves % 20 == 0) { /* jimt@asgb */
303 /* called after vomiting and after performing feats of magic */
311 /* called after eating something (and after drinking fruit juice) */
329 int newhs, h = u.uhunger;
331 newhs = (h > 1000) ? SATIATED :
332 (h > 150) ? NOT_HUNGRY :
334 (h > 0) ? WEAK : FAINTING;
336 if (newhs == FAINTING) {
337 if (u.uhs == FAINTED)
339 if (u.uhs <= WEAK || rn2(20 - u.uhunger / 10) >= 19) {
340 if (u.uhs != FAINTED && multi >= 0 /* %% */) {
341 pline("You faint from lack of food.");
342 nomul(-10 + (u.uhunger / 10));
343 nomovemsg = "You regain consciousness.";
347 } else if (u.uhunger < -(int)(200 + 25 * u.ulevel)) {
351 pline("You die from starvation.");
356 if (newhs != u.uhs) {
357 if (newhs >= WEAK && u.uhs < WEAK)
358 losestr(1); /* this may kill you -- see below */
359 else if (newhs < WEAK && u.uhs >= WEAK && u.ustr < u.ustrmax)
363 pline((!incr) ? "You only feel hungry now." :
364 (u.uhunger < 145) ? "You feel hungry." :
365 "You are beginning to feel hungry.");
368 pline((!incr) ? "You feel weak now." :
369 (u.uhunger < 45) ? "You feel weak." :
370 "You are beginning to feel weak.");
376 pline("You die from hunger and exhaustion.");
377 killer = "exhaustion";
383 #define CORPSE_I_TO_C(otyp) (char)((otyp >= DEAD_ACID_BLOB)\
384 ? 'a' + (otyp - DEAD_ACID_BLOB)\
385 : '@' + (otyp - DEAD_HUMAN))
387 poisonous(struct obj *otmp)
389 return (strchr(POISONOUS, CORPSE_I_TO_C(otmp->otyp)) != 0);
392 /* returns 1 if some text was printed */
394 eatcorpse(struct obj *otmp)
396 char let = CORPSE_I_TO_C(otmp->otyp);
399 if (let != 'a' && moves > otmp->age + 50 + rn2(100)) {
401 pline("Ulch -- that meat was tainted!");
402 pline("You get very sick.");
404 u.usick_cause = objects[otmp->otyp].oc_name;
405 } else if (strchr(POISONOUS, let) && rn2(5)) {
407 pline("Ecch -- that must have been poisonous!");
408 if (!Poison_resistance) {
410 losehp(rnd(15), "poisonous corpse");
412 pline("You don't seem affected by the poison.");
413 } else if (strchr("ELNOPQRUuxz", let) && rn2(5)) {
415 pline("You feel sick.");
416 losehp(rnd(8), "cadaver");
422 Teleportation |= INTRINSIC;
430 /* fall into next case */
432 pline("You cannibal! You will be sorry for this!");
434 /* fall into next case */
436 Aggravate_monster |= INTRINSIC;
440 Invis = 50 + rn2(100);
445 See_invisible |= INTRINSIC;
447 /* fall into next case */
452 /* fall into next case */
457 Fire_resistance |= INTRINSIC;
460 Telepat |= INTRINSIC;
464 Cold_resistance |= INTRINSIC;
468 Poison_resistance |= INTRINSIC;
471 pline("You turn to stone.");
472 killer = "dead cockatrice";
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.";