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.2 2003/06/17 04:25:24 dillon Exp $ */
7 char POISONOUS[] = "ADKSVabhks";
8 extern char *nomovemsg;
9 extern int (*afternmv)();
10 extern int (*occupation)();
12 extern struct obj *splitobj(), *addinv();
14 /* hunger texts used on bottom line (each 8 chars long) */
38 #define TTSZ SIZE(tintxts)
39 struct { char *txt; int nut; } tintxts[] = {
40 "It contains first quality peaches - what a surprise!", 40,
41 "It contains salmon - not bad!", 60,
42 "It contains apple juice - perhaps not what you hoped for.", 20,
43 "It contains some nondescript substance, tasting awfully.", 500,
44 "It contains rotten meat. You vomit.", -50,
45 "It turns out to be empty.", 0
50 int usedtime, reqtime;
56 if(!carried(tin.tin)) /* perhaps it was stolen? */
57 return(0); /* %% probably we should use tinoid */
58 if(tin.usedtime++ >= 50) {
59 pline("You give up your attempt to open the tin.");
62 if(tin.usedtime < tin.reqtime)
63 return(1); /* still busy */
65 pline("You succeed in opening the tin.");
69 pline(tintxts[r].txt);
70 lesshungry(tintxts[r].nut);
71 if(r == 1) /* SALMON */ {
73 pline("Eating salmon made your fingers very slippery.");
76 pline("It contains spinach - this makes you feel like Popeye!");
79 u.ustr += rnd( ((u.ustr < 17) ? 19 : 118) - u.ustr);
80 if(u.ustr > u.ustrmax) u.ustrmax = u.ustr;
93 struct objclass *ftmp;
96 /* Is there some food (probably a heavy corpse) here on the ground? */
98 for(otmp = fobj; otmp; otmp = otmp->nobj) {
99 if(otmp->ox == u.ux && otmp->oy == u.uy &&
100 otmp->olet == FOOD_SYM) {
101 pline("There %s %s here; eat %s? [ny] ",
102 (otmp->quan == 1) ? "is" : "are",
104 (otmp->quan == 1) ? "it" : "one");
105 if(readchar() == 'y') {
107 (void) splitobj(otmp, 1);
115 otmp = getobj("%", "eat");
118 if(otmp->otyp == TIN){
135 pline("Using your %s you try to open the tin.",
136 aobjnam(uwep, (char *) 0));
139 pline("It is not so easy to open this tin.");
141 pline("The tin slips out of your hands.");
144 extern struct obj *splitobj();
146 obj = splitobj(otmp, 1);
147 if(otmp == uwep) setuwep(obj);
152 tmp = 10 + rn2(1 + 500/((int)(u.ulevel + u.ustr)));
157 occupation = opentin;
158 occtxt = "opening the tin";
161 ftmp = &objects[otmp->otyp];
162 multi = -ftmp->oc_delay;
163 if(otmp->otyp >= CORPSE && eatcorpse(otmp)) goto eatx;
164 if(!rn2(7) && otmp->otyp != FORTUNE_COOKIE) {
165 pline("Blecch! Rotten food!");
167 pline("You feel rather light headed.");
169 } else if(!rn2(4)&& !Blind) {
170 pline("Everything suddenly goes dark.");
175 pline("The world spins and you slap against the floor.");
177 pline("The world spins and goes dark.");
179 nomovemsg = "You are conscious again.";
181 lesshungry(ftmp->nutrition / 4);
183 if(u.uhunger >= 1500) {
184 pline("You choke over your food.");
186 killer = ftmp->oc_name;
192 pline("That food really hit the spot!");
193 else if(u.uhunger <= 700)
194 pline("That satiated your stomach!");
196 pline("You're having a hard time getting all that food down.");
199 lesshungry(ftmp->nutrition);
200 if(multi < 0) nomovemsg = "You finished your meal.";
203 pline("Yak - dog food!");
204 more_experienced(1,0);
210 Sick = 0; /* David Neves */
211 pline("What a relief!");
213 } else lesshungry(ftmp->nutrition);
216 if(otmp->otyp >= CORPSE)
217 pline("That %s tasted terrible!",ftmp->oc_name);
219 pline("That %s was delicious!",ftmp->oc_name);
220 lesshungry(ftmp->nutrition);
221 if(otmp->otyp == DEAD_LIZARD && (Confusion > 2))
225 if(otmp->otyp == CARROT && !Blind){
228 pline("Your vision improves.");
231 if(otmp->otyp == FORTUNE_COOKIE) {
233 pline("This cookie has a scrap of paper inside!");
234 pline("What a pity, that you cannot read it!");
238 if(otmp->otyp == LUMP_OF_ROYAL_JELLY) {
239 /* This stuff seems to be VERY healthy! */
240 if(u.ustrmax < 118) u.ustrmax++;
241 if(u.ustr < u.ustrmax) u.ustr++;
243 if(u.uhp > u.uhpmax) {
244 if(!rn2(17)) u.uhpmax++;
253 if(multi<0 && !nomovemsg){
254 static char msgbuf[BUFSZ];
255 (void) sprintf(msgbuf, "You finished eating the %s.",
263 /* called in hack.main.c */
267 if(Regeneration) u.uhunger--;
268 if(Hunger) u.uhunger--;
269 /* a3: if(Hunger & LEFT_RING) u.uhunger--;
270 if(Hunger & RIGHT_RING) u.uhunger--;
273 if(moves % 20 == 0) { /* jimt@asgb */
274 if(uleft) u.uhunger--;
275 if(uright) u.uhunger--;
280 /* called after vomiting and after performing feats of magic */
281 morehungry(num) int num; {
286 /* called after eating something (and after drinking fruit juice) */
287 lesshungry(num) int num; {
297 newuhs(incr) boolean incr; {
298 int newhs, h = u.uhunger;
300 newhs = (h > 1000) ? SATIATED :
301 (h > 150) ? NOT_HUNGRY :
303 (h > 0) ? WEAK : FAINTING;
305 if(newhs == FAINTING) {
308 if(u.uhs <= WEAK || rn2(20-u.uhunger/10) >= 19) {
309 if(u.uhs != FAINTED && multi >= 0 /* %% */) {
310 pline("You faint from lack of food.");
311 nomul(-10+(u.uhunger/10));
312 nomovemsg = "You regain consciousness.";
317 if(u.uhunger < -(int)(200 + 25*u.ulevel)) {
321 pline("You die from starvation.");
327 if(newhs >= WEAK && u.uhs < WEAK)
328 losestr(1); /* this may kill you -- see below */
330 if(newhs < WEAK && u.uhs >= WEAK && u.ustr < u.ustrmax)
334 pline((!incr) ? "You only feel hungry now." :
335 (u.uhunger < 145) ? "You feel hungry." :
336 "You are beginning to feel hungry.");
339 pline((!incr) ? "You feel weak now." :
340 (u.uhunger < 45) ? "You feel weak." :
341 "You are beginning to feel weak.");
347 pline("You die from hunger and exhaustion.");
348 killer = "exhaustion";
354 #define CORPSE_I_TO_C(otyp) (char) ((otyp >= DEAD_ACID_BLOB)\
355 ? 'a' + (otyp - DEAD_ACID_BLOB)\
356 : '@' + (otyp - DEAD_HUMAN))
360 return(index(POISONOUS, CORPSE_I_TO_C(otmp->otyp)) != 0);
363 /* returns 1 if some text was printed */
364 eatcorpse(otmp) struct obj *otmp; {
365 char let = CORPSE_I_TO_C(otmp->otyp);
367 if(let != 'a' && moves > otmp->age + 50 + rn2(100)) {
369 pline("Ulch -- that meat was tainted!");
370 pline("You get very sick.");
372 u.usick_cause = objects[otmp->otyp].oc_name;
373 } else if(index(POISONOUS, let) && rn2(5)){
375 pline("Ecch -- that must have been poisonous!");
376 if(!Poison_resistance){
378 losehp(rnd(15), "poisonous corpse");
380 pline("You don't seem affected by the poison.");
381 } else if(index("ELNOPQRUuxz", let) && rn2(5)){
383 pline("You feel sick.");
384 losehp(rnd(8), "cadaver");
390 Teleportation |= INTRINSIC;
398 /* fall into next case */
400 pline("You cannibal! You will be sorry for this!");
402 /* fall into next case */
404 Aggravate_monster |= INTRINSIC;
413 See_invisible |= INTRINSIC;
415 /* fall into next case */
420 /* fall into next case */
425 Fire_resistance |= INTRINSIC;
428 Telepat |= INTRINSIC;
432 Cold_resistance |= INTRINSIC;
436 Poison_resistance |= INTRINSIC;
439 pline("You turn to stone.");
440 killer = "dead cockatrice";
445 pline("What a pity - you just destroyed a future piece of art!");
451 pline("You cannot resist the temptation to mimic a treasure chest.");
455 nomovemsg = "You now again prefer mimicking a human.";