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.4 2005/05/22 03:37:05 y0netan1 Exp $ */
7 char POISONOUS[] = "ADKSVabhks";
8 extern int (*afternmv)();
9 extern int (*occupation)();
10 extern struct obj *splitobj(), *addinv();
12 /* hunger texts used on bottom line (each 8 chars long) */
21 const char *hu_stat[] = {
36 #define TTSZ SIZE(tintxts)
37 struct { const char *txt; int nut; } tintxts[] = {
38 "It contains first quality peaches - what a surprise!", 40,
39 "It contains salmon - not bad!", 60,
40 "It contains apple juice - perhaps not what you hoped for.", 20,
41 "It contains some nondescript substance, tasting awfully.", 500,
42 "It contains rotten meat. You vomit.", -50,
43 "It turns out to be empty.", 0
48 int usedtime, reqtime;
54 if(!carried(tin.tin)) /* perhaps it was stolen? */
55 return(0); /* %% probably we should use tinoid */
56 if(tin.usedtime++ >= 50) {
57 pline("You give up your attempt to open the tin.");
60 if(tin.usedtime < tin.reqtime)
61 return(1); /* still busy */
63 pline("You succeed in opening the tin.");
67 pline(tintxts[r].txt);
68 lesshungry(tintxts[r].nut);
69 if(r == 1) /* SALMON */ {
71 pline("Eating salmon made your fingers very slippery.");
74 pline("It contains spinach - this makes you feel like Popeye!");
77 u.ustr += rnd( ((u.ustr < 17) ? 19 : 118) - u.ustr);
78 if(u.ustr > u.ustrmax) u.ustrmax = u.ustr;
91 struct objclass *ftmp;
94 /* Is there some food (probably a heavy corpse) here on the ground? */
96 for(otmp = fobj; otmp; otmp = otmp->nobj) {
97 if(otmp->ox == u.ux && otmp->oy == u.uy &&
98 otmp->olet == FOOD_SYM) {
99 pline("There %s %s here; eat %s? [ny] ",
100 (otmp->quan == 1) ? "is" : "are",
102 (otmp->quan == 1) ? "it" : "one");
103 if(readchar() == 'y') {
105 (void) splitobj(otmp, 1);
113 otmp = getobj("%", "eat");
116 if(otmp->otyp == TIN){
133 pline("Using your %s you try to open the tin.",
134 aobjnam(uwep, (char *) 0));
137 pline("It is not so easy to open this tin.");
139 pline("The tin slips out of your hands.");
142 extern struct obj *splitobj();
144 obj = splitobj(otmp, 1);
145 if(otmp == uwep) setuwep(obj);
150 tmp = 10 + rn2(1 + 500/((int)(u.ulevel + u.ustr)));
155 occupation = opentin;
156 occtxt = "opening the tin";
159 ftmp = &objects[otmp->otyp];
160 multi = -ftmp->oc_delay;
161 if(otmp->otyp >= CORPSE && eatcorpse(otmp)) goto eatx;
162 if(!rn2(7) && otmp->otyp != FORTUNE_COOKIE) {
163 pline("Blecch! Rotten food!");
165 pline("You feel rather light headed.");
167 } else if(!rn2(4)&& !Blind) {
168 pline("Everything suddenly goes dark.");
173 pline("The world spins and you slap against the floor.");
175 pline("The world spins and goes dark.");
177 nomovemsg = "You are conscious again.";
179 lesshungry(ftmp->nutrition / 4);
181 if(u.uhunger >= 1500) {
182 pline("You choke over your food.");
184 killer = ftmp->oc_name;
190 pline("That food really hit the spot!");
191 else if(u.uhunger <= 700)
192 pline("That satiated your stomach!");
194 pline("You're having a hard time getting all that food down.");
197 lesshungry(ftmp->nutrition);
198 if(multi < 0) nomovemsg = "You finished your meal.";
201 pline("Yak - dog food!");
202 more_experienced(1,0);
208 Sick = 0; /* David Neves */
209 pline("What a relief!");
211 } else lesshungry(ftmp->nutrition);
214 if(otmp->otyp >= CORPSE)
215 pline("That %s tasted terrible!",ftmp->oc_name);
217 pline("That %s was delicious!",ftmp->oc_name);
218 lesshungry(ftmp->nutrition);
219 if(otmp->otyp == DEAD_LIZARD && (Confusion > 2))
223 if(otmp->otyp == CARROT && !Blind){
226 pline("Your vision improves.");
229 if(otmp->otyp == FORTUNE_COOKIE) {
231 pline("This cookie has a scrap of paper inside!");
232 pline("What a pity, that you cannot read it!");
236 if(otmp->otyp == LUMP_OF_ROYAL_JELLY) {
237 /* This stuff seems to be VERY healthy! */
238 if(u.ustrmax < 118) u.ustrmax++;
239 if(u.ustr < u.ustrmax) u.ustr++;
241 if(u.uhp > u.uhpmax) {
242 if(!rn2(17)) u.uhpmax++;
251 if(multi<0 && !nomovemsg){
252 static char msgbuf[BUFSZ];
253 (void) sprintf(msgbuf, "You finished eating the %s.",
261 /* called in hack.main.c */
265 if(Regeneration) u.uhunger--;
266 if(Hunger) u.uhunger--;
267 /* a3: if(Hunger & LEFT_RING) u.uhunger--;
268 if(Hunger & RIGHT_RING) u.uhunger--;
271 if(moves % 20 == 0) { /* jimt@asgb */
272 if(uleft) u.uhunger--;
273 if(uright) u.uhunger--;
278 /* called after vomiting and after performing feats of magic */
279 morehungry(num) int num; {
284 /* called after eating something (and after drinking fruit juice) */
285 lesshungry(num) int num; {
295 newuhs(incr) boolean incr; {
296 int newhs, h = u.uhunger;
298 newhs = (h > 1000) ? SATIATED :
299 (h > 150) ? NOT_HUNGRY :
301 (h > 0) ? WEAK : FAINTING;
303 if(newhs == FAINTING) {
306 if(u.uhs <= WEAK || rn2(20-u.uhunger/10) >= 19) {
307 if(u.uhs != FAINTED && multi >= 0 /* %% */) {
308 pline("You faint from lack of food.");
309 nomul(-10+(u.uhunger/10));
310 nomovemsg = "You regain consciousness.";
315 if(u.uhunger < -(int)(200 + 25*u.ulevel)) {
319 pline("You die from starvation.");
325 if(newhs >= WEAK && u.uhs < WEAK)
326 losestr(1); /* this may kill you -- see below */
328 if(newhs < WEAK && u.uhs >= WEAK && u.ustr < u.ustrmax)
332 pline((!incr) ? "You only feel hungry now." :
333 (u.uhunger < 145) ? "You feel hungry." :
334 "You are beginning to feel hungry.");
337 pline((!incr) ? "You feel weak now." :
338 (u.uhunger < 45) ? "You feel weak." :
339 "You are beginning to feel weak.");
345 pline("You die from hunger and exhaustion.");
346 killer = "exhaustion";
352 #define CORPSE_I_TO_C(otyp) (char) ((otyp >= DEAD_ACID_BLOB)\
353 ? 'a' + (otyp - DEAD_ACID_BLOB)\
354 : '@' + (otyp - DEAD_HUMAN))
358 return(index(POISONOUS, CORPSE_I_TO_C(otmp->otyp)) != 0);
361 /* returns 1 if some text was printed */
362 eatcorpse(otmp) struct obj *otmp; {
363 char let = CORPSE_I_TO_C(otmp->otyp);
365 if(let != 'a' && moves > otmp->age + 50 + rn2(100)) {
367 pline("Ulch -- that meat was tainted!");
368 pline("You get very sick.");
370 u.usick_cause = objects[otmp->otyp].oc_name;
371 } else if(index(POISONOUS, let) && rn2(5)){
373 pline("Ecch -- that must have been poisonous!");
374 if(!Poison_resistance){
376 losehp(rnd(15), "poisonous corpse");
378 pline("You don't seem affected by the poison.");
379 } else if(index("ELNOPQRUuxz", let) && rn2(5)){
381 pline("You feel sick.");
382 losehp(rnd(8), "cadaver");
388 Teleportation |= INTRINSIC;
396 /* fall into next case */
398 pline("You cannibal! You will be sorry for this!");
400 /* fall into next case */
402 Aggravate_monster |= INTRINSIC;
411 See_invisible |= INTRINSIC;
413 /* fall into next case */
418 /* fall into next case */
423 Fire_resistance |= INTRINSIC;
426 Telepat |= INTRINSIC;
430 Cold_resistance |= INTRINSIC;
434 Poison_resistance |= INTRINSIC;
437 pline("You turn to stone.");
438 killer = "dead cockatrice";
443 pline("What a pity - you just destroyed a future piece of art!");
449 pline("You cannot resist the temptation to mimic a treasure chest.");
453 nomovemsg = "You now again prefer mimicking a human.";