]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.eat.c
1 /* $NetBSD: hack.eat.c,v 1.5 2001/03/25 20:44:00 jsm Exp $ */
4 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
9 __RCSID("$NetBSD: hack.eat.c,v 1.5 2001/03/25 20:44:00 jsm Exp $");
14 char POISONOUS
[] = "ADKSVabhks";
16 /* hunger texts used on bottom line (each 8 chars long) */
25 const char *const hu_stat
[] = {
42 #define TTSZ SIZE(tintxts)
47 { "It contains first quality peaches - what a surprise!", 40 },
48 { "It contains salmon - not bad!", 60 },
49 { "It contains apple juice - perhaps not what you hoped for.", 20 },
50 { "It contains some nondescript substance, tasting awfully.", 500 },
51 { "It contains rotten meat. You vomit.", -50 },
52 { "It turns out to be empty.", 0 }
57 int usedtime
, reqtime
;
65 if (!carried(tin
.tin
)) /* perhaps it was stolen? */
66 return (0); /* %% probably we should use tinoid */
67 if (tin
.usedtime
++ >= 50) {
68 pline("You give up your attempt to open the tin.");
71 if (tin
.usedtime
< tin
.reqtime
)
72 return (1); /* still busy */
74 pline("You succeed in opening the tin.");
78 pline(tintxts
[r
].txt
);
79 lesshungry(tintxts
[r
].nut
);
80 if (r
== 1) { /* SALMON */
82 pline("Eating salmon made your fingers very slippery.");
85 pline("It contains spinach - this makes you feel like Popeye!");
88 u
.ustr
+= rnd(((u
.ustr
< 17) ? 19 : 118) - u
.ustr
);
89 if (u
.ustr
> u
.ustrmax
)
108 struct objclass
*ftmp
;
111 /* Is there some food (probably a heavy corpse) here on the ground? */
113 for (otmp
= fobj
; otmp
; otmp
= otmp
->nobj
) {
114 if (otmp
->ox
== u
.ux
&& otmp
->oy
== u
.uy
&&
115 otmp
->olet
== FOOD_SYM
) {
116 pline("There %s %s here; eat %s? [ny] ",
117 (otmp
->quan
== 1) ? "is" : "are",
119 (otmp
->quan
== 1) ? "it" : "one");
120 if (readchar() == 'y') {
122 (void) splitobj(otmp
, 1);
130 otmp
= getobj("%", "eat");
134 if (otmp
->otyp
== TIN
) {
136 switch (uwep
->otyp
) {
151 pline("Using your %s you try to open the tin.",
152 aobjnam(uwep
, (char *) 0));
155 pline("It is not so easy to open this tin.");
157 pline("The tin slips out of your hands.");
158 if (otmp
->quan
> 1) {
161 obj
= splitobj(otmp
, 1);
168 tmp
= 10 + rn2(1 + 500 / ((int) (u
.ulevel
+ u
.ustr
)));
173 occupation
= opentin
;
174 occtxt
= "opening the tin";
177 ftmp
= &objects
[otmp
->otyp
];
178 multi
= -ftmp
->oc_delay
;
179 if (otmp
->otyp
>= CORPSE
&& eatcorpse(otmp
))
181 if (!rn2(7) && otmp
->otyp
!= FORTUNE_COOKIE
) {
182 pline("Blecch! Rotten food!");
184 pline("You feel rather light headed.");
185 Confusion
+= d(2, 4);
186 } else if (!rn2(4) && !Blind
) {
187 pline("Everything suddenly goes dark.");
190 } else if (!rn2(3)) {
192 pline("The world spins and you slap against the floor.");
194 pline("The world spins and goes dark.");
196 nomovemsg
= "You are conscious again.";
198 lesshungry(ftmp
->nutrition
/ 4);
200 if (u
.uhunger
>= 1500) {
201 pline("You choke over your food.");
203 killer
= ftmp
->oc_name
;
206 switch (otmp
->otyp
) {
208 if (u
.uhunger
<= 200)
209 pline("That food really hit the spot!");
210 else if (u
.uhunger
<= 700)
211 pline("That satiated your stomach!");
213 pline("You're having a hard time getting all that food down.");
216 lesshungry(ftmp
->nutrition
);
218 nomovemsg
= "You finished your meal.";
221 pline("Yak - dog food!");
222 more_experienced(1, 0);
228 Sick
= 0; /* David Neves */
229 pline("What a relief!");
232 lesshungry(ftmp
->nutrition
);
235 if (otmp
->otyp
>= CORPSE
)
236 pline("That %s tasted terrible!", ftmp
->oc_name
);
238 pline("That %s was delicious!", ftmp
->oc_name
);
239 lesshungry(ftmp
->nutrition
);
240 if (otmp
->otyp
== DEAD_LIZARD
&& (Confusion
> 2))
244 if (otmp
->otyp
== CARROT
&& !Blind
) {
247 pline("Your vision improves.");
250 if (otmp
->otyp
== FORTUNE_COOKIE
) {
252 pline("This cookie has a scrap of paper inside!");
253 pline("What a pity, that you cannot read it!");
256 } else if (otmp
->otyp
== LUMP_OF_ROYAL_JELLY
) {
257 /* This stuff seems to be VERY healthy! */
260 if (u
.ustr
< u
.ustrmax
)
263 if (u
.uhp
> u
.uhpmax
) {
274 if (multi
< 0 && !nomovemsg
) {
275 static char msgbuf
[BUFSZ
];
276 (void) sprintf(msgbuf
, "You finished eating the %s.",
284 /* called in hack.main.c */
295 * a3: if(Hunger & LEFT_RING) u.uhunger--; if(Hunger &
296 * RIGHT_RING) u.uhunger--; etc.
299 if (moves
% 20 == 0) { /* jimt@asgb */
308 /* called after vomiting and after performing feats of magic */
317 /* called after eating something (and after drinking fruit juice) */
338 int newhs
, h
= u
.uhunger
;
340 newhs
= (h
> 1000) ? SATIATED
:
341 (h
> 150) ? NOT_HUNGRY
:
343 (h
> 0) ? WEAK
: FAINTING
;
345 if (newhs
== FAINTING
) {
346 if (u
.uhs
== FAINTED
)
348 if (u
.uhs
<= WEAK
|| rn2(20 - u
.uhunger
/ 10) >= 19) {
349 if (u
.uhs
!= FAINTED
&& multi
>= 0 /* %% */ ) {
350 pline("You faint from lack of food.");
351 nomul(-10 + (u
.uhunger
/ 10));
352 nomovemsg
= "You regain consciousness.";
356 } else if (u
.uhunger
< -(int) (200 + 25 * u
.ulevel
)) {
360 pline("You die from starvation.");
364 if (newhs
!= u
.uhs
) {
365 if (newhs
>= WEAK
&& u
.uhs
< WEAK
)
366 losestr(1); /* this may kill you -- see below */
367 else if (newhs
< WEAK
&& u
.uhs
>= WEAK
&& u
.ustr
< u
.ustrmax
)
371 pline((!incr
) ? "You only feel hungry now." :
372 (u
.uhunger
< 145) ? "You feel hungry." :
373 "You are beginning to feel hungry.");
376 pline((!incr
) ? "You feel weak now." :
377 (u
.uhunger
< 45) ? "You feel weak." :
378 "You are beginning to feel weak.");
384 pline("You die from hunger and exhaustion.");
385 killer
= "exhaustion";
391 #define CORPSE_I_TO_C(otyp) (char) ((otyp >= DEAD_ACID_BLOB)\
392 ? 'a' + (otyp - DEAD_ACID_BLOB)\
393 : '@' + (otyp - DEAD_HUMAN))
398 return (strchr(POISONOUS
, CORPSE_I_TO_C(otmp
->otyp
)) != 0);
401 /* returns 1 if some text was printed */
406 char let
= CORPSE_I_TO_C(otmp
->otyp
);
408 if (let
!= 'a' && moves
> otmp
->age
+ 50 + rn2(100)) {
410 pline("Ulch -- that meat was tainted!");
411 pline("You get very sick.");
413 u
.usick_cause
= objects
[otmp
->otyp
].oc_name
;
414 } else if (strchr(POISONOUS
, let
) && rn2(5)) {
416 pline("Ecch -- that must have been poisonous!");
417 if (!Poison_resistance
) {
419 losehp(rnd(15), "poisonous corpse");
421 pline("You don't seem affected by the poison.");
422 } else if (strchr("ELNOPQRUuxz", let
) && rn2(5)) {
424 pline("You feel sick.");
425 losehp(rnd(8), "cadaver");
431 Teleportation
|= INTRINSIC
;
439 /* fall into next case */
441 pline("You cannibal! You will be sorry for this!");
443 /* fall into next case */
445 Aggravate_monster
|= INTRINSIC
;
449 Invis
= 50 + rn2(100);
454 See_invisible
|= INTRINSIC
;
456 /* fall into next case */
461 /* fall into next case */
466 Fire_resistance
|= INTRINSIC
;
469 Telepat
|= INTRINSIC
;
473 Cold_resistance
|= INTRINSIC
;
477 Poison_resistance
|= INTRINSIC
;
480 pline("You turn to stone.");
481 killer
= "dead cockatrice";
486 pline("What a pity - you just destroyed a future piece of art!");
492 pline("You cannot resist the temptation to mimic a treasure chest.");
496 nomovemsg
= "You now again prefer mimicking a human.";