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";
7 extern char *nomovemsg;
8 extern int (*afternmv)();
9 extern int (*occupation)();
11 extern struct obj *splitobj(), *addinv();
13 /* hunger texts used on bottom line (each 8 chars long) */
37 #define TTSZ SIZE(tintxts)
38 struct { char *txt; int nut; } tintxts[] = {
39 "It contains first quality peaches - what a surprise!", 40,
40 "It contains salmon - not bad!", 60,
41 "It contains apple juice - perhaps not what you hoped for.", 20,
42 "It contains some nondescript substance, tasting awfully.", 500,
43 "It contains rotten meat. You vomit.", -50,
44 "It turns out to be empty.", 0
49 int usedtime, reqtime;
55 if(!carried(tin.tin)) /* perhaps it was stolen? */
56 return(0); /* %% probably we should use tinoid */
57 if(tin.usedtime++ >= 50) {
58 pline("You give up your attempt to open the tin.");
61 if(tin.usedtime < tin.reqtime)
62 return(1); /* still busy */
64 pline("You succeed in opening the tin.");
68 pline(tintxts[r].txt);
69 lesshungry(tintxts[r].nut);
70 if(r == 1) /* SALMON */ {
72 pline("Eating salmon made your fingers very slippery.");
75 pline("It contains spinach - this makes you feel like Popeye!");
78 u.ustr += rnd( ((u.ustr < 17) ? 19 : 118) - u.ustr);
79 if(u.ustr > u.ustrmax) u.ustrmax = u.ustr;
92 struct objclass *ftmp;
95 /* Is there some food (probably a heavy corpse) here on the ground? */
97 for(otmp = fobj; otmp; otmp = otmp->nobj) {
98 if(otmp->ox == u.ux && otmp->oy == u.uy &&
99 otmp->olet == FOOD_SYM) {
100 pline("There %s %s here; eat %s? [ny] ",
101 (otmp->quan == 1) ? "is" : "are",
103 (otmp->quan == 1) ? "it" : "one");
104 if(readchar() == 'y') {
106 (void) splitobj(otmp, 1);
114 otmp = getobj("%", "eat");
117 if(otmp->otyp == TIN){
134 pline("Using your %s you try to open the tin.",
135 aobjnam(uwep, (char *) 0));
138 pline("It is not so easy to open this tin.");
140 pline("The tin slips out of your hands.");
143 extern struct obj *splitobj();
145 obj = splitobj(otmp, 1);
146 if(otmp == uwep) setuwep(obj);
151 tmp = 10 + rn2(1 + 500/((int)(u.ulevel + u.ustr)));
156 occupation = opentin;
157 occtxt = "opening the tin";
160 ftmp = &objects[otmp->otyp];
161 multi = -ftmp->oc_delay;
162 if(otmp->otyp >= CORPSE && eatcorpse(otmp)) goto eatx;
163 if(!rn2(7) && otmp->otyp != FORTUNE_COOKIE) {
164 pline("Blecch! Rotten food!");
166 pline("You feel rather light headed.");
168 } else if(!rn2(4)&& !Blind) {
169 pline("Everything suddenly goes dark.");
174 pline("The world spins and you slap against the floor.");
176 pline("The world spins and goes dark.");
178 nomovemsg = "You are conscious again.";
180 lesshungry(ftmp->nutrition / 4);
182 if(u.uhunger >= 1500) {
183 pline("You choke over your food.");
185 killer = ftmp->oc_name;
191 pline("That food really hit the spot!");
192 else if(u.uhunger <= 700)
193 pline("That satiated your stomach!");
195 pline("You're having a hard time getting all that food down.");
198 lesshungry(ftmp->nutrition);
199 if(multi < 0) nomovemsg = "You finished your meal.";
202 pline("Yak - dog food!");
203 more_experienced(1,0);
209 Sick = 0; /* David Neves */
210 pline("What a relief!");
212 } else lesshungry(ftmp->nutrition);
215 if(otmp->otyp >= CORPSE)
216 pline("That %s tasted terrible!",ftmp->oc_name);
218 pline("That %s was delicious!",ftmp->oc_name);
219 lesshungry(ftmp->nutrition);
220 if(otmp->otyp == DEAD_LIZARD && (Confusion > 2))
224 if(otmp->otyp == CARROT && !Blind){
227 pline("Your vision improves.");
230 if(otmp->otyp == FORTUNE_COOKIE) {
232 pline("This cookie has a scrap of paper inside!");
233 pline("What a pity, that you cannot read it!");
237 if(otmp->otyp == LUMP_OF_ROYAL_JELLY) {
238 /* This stuff seems to be VERY healthy! */
239 if(u.ustrmax < 118) u.ustrmax++;
240 if(u.ustr < u.ustrmax) u.ustr++;
242 if(u.uhp > u.uhpmax) {
243 if(!rn2(17)) u.uhpmax++;
252 if(multi<0 && !nomovemsg){
253 static char msgbuf[BUFSZ];
254 (void) sprintf(msgbuf, "You finished eating the %s.",
262 /* called in hack.main.c */
266 if(Regeneration) u.uhunger--;
267 if(Hunger) u.uhunger--;
268 /* a3: if(Hunger & LEFT_RING) u.uhunger--;
269 if(Hunger & RIGHT_RING) u.uhunger--;
272 if(moves % 20 == 0) { /* jimt@asgb */
273 if(uleft) u.uhunger--;
274 if(uright) u.uhunger--;
279 /* called after vomiting and after performing feats of magic */
280 morehungry(num) int num; {
285 /* called after eating something (and after drinking fruit juice) */
286 lesshungry(num) int num; {
296 newuhs(incr) boolean incr; {
297 int newhs, h = u.uhunger;
299 newhs = (h > 1000) ? SATIATED :
300 (h > 150) ? NOT_HUNGRY :
302 (h > 0) ? WEAK : FAINTING;
304 if(newhs == FAINTING) {
307 if(u.uhs <= WEAK || rn2(20-u.uhunger/10) >= 19) {
308 if(u.uhs != FAINTED && multi >= 0 /* %% */) {
309 pline("You faint from lack of food.");
310 nomul(-10+(u.uhunger/10));
311 nomovemsg = "You regain consciousness.";
316 if(u.uhunger < -(int)(200 + 25*u.ulevel)) {
320 pline("You die from starvation.");
326 if(newhs >= WEAK && u.uhs < WEAK)
327 losestr(1); /* this may kill you -- see below */
329 if(newhs < WEAK && u.uhs >= WEAK && u.ustr < u.ustrmax)
333 pline((!incr) ? "You only feel hungry now." :
334 (u.uhunger < 145) ? "You feel hungry." :
335 "You are beginning to feel hungry.");
338 pline((!incr) ? "You feel weak now." :
339 (u.uhunger < 45) ? "You feel weak." :
340 "You are beginning to feel weak.");
346 pline("You die from hunger and exhaustion.");
347 killer = "exhaustion";
353 #define CORPSE_I_TO_C(otyp) (char) ((otyp >= DEAD_ACID_BLOB)\
354 ? 'a' + (otyp - DEAD_ACID_BLOB)\
355 : '@' + (otyp - DEAD_HUMAN))
359 return(index(POISONOUS, CORPSE_I_TO_C(otmp->otyp)) != 0);
362 /* returns 1 if some text was printed */
363 eatcorpse(otmp) struct obj *otmp; {
364 char let = CORPSE_I_TO_C(otmp->otyp);
366 if(let != 'a' && moves > otmp->age + 50 + rn2(100)) {
368 pline("Ulch -- that meat was tainted!");
369 pline("You get very sick.");
371 u.usick_cause = objects[otmp->otyp].oc_name;
372 } else if(index(POISONOUS, let) && rn2(5)){
374 pline("Ecch -- that must have been poisonous!");
375 if(!Poison_resistance){
377 losehp(rnd(15), "poisonous corpse");
379 pline("You don't seem affected by the poison.");
380 } else if(index("ELNOPQRUuxz", let) && rn2(5)){
382 pline("You feel sick.");
383 losehp(rnd(8), "cadaver");
389 Teleportation |= INTRINSIC;
397 /* fall into next case */
399 pline("You cannibal! You will be sorry for this!");
401 /* fall into next case */
403 Aggravate_monster |= INTRINSIC;
412 See_invisible |= INTRINSIC;
414 /* fall into next case */
419 /* fall into next case */
424 Fire_resistance |= INTRINSIC;
427 Telepat |= INTRINSIC;
431 Cold_resistance |= INTRINSIC;
435 Poison_resistance |= INTRINSIC;
438 pline("You turn to stone.");
439 killer = "dead cockatrice";
444 pline("What a pity - you just destroyed a future piece of art!");
450 pline("You cannot resist the temptation to mimic a treasure chest.");
454 nomovemsg = "You now again prefer mimicking a human.";