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
) u
.ustrmax
= u
.ustr
;
102 struct objclass
*ftmp
;
105 /* Is there some food (probably a heavy corpse) here on the ground? */
107 for(otmp
= fobj
; otmp
; otmp
= otmp
->nobj
) {
108 if(otmp
->ox
== u
.ux
&& otmp
->oy
== u
.uy
&&
109 otmp
->olet
== FOOD_SYM
) {
110 pline("There %s %s here; eat %s? [ny] ",
111 (otmp
->quan
== 1) ? "is" : "are",
113 (otmp
->quan
== 1) ? "it" : "one");
114 if(readchar() == 'y') {
124 otmp
= getobj("%", "eat");
127 if(otmp
->otyp
== TIN
){
144 pline("Using your %s you try to open the tin.",
145 aobjnam(uwep
, (char *) 0));
148 pline("It is not so easy to open this tin.");
150 pline("The tin slips out of your hands.");
154 obj
= splitobj(otmp
, 1);
155 if(otmp
== uwep
) setuwep(obj
);
160 tmp
= 10 + rn2(1 + 500/((int)(u
.ulevel
+ u
.ustr
)));
165 occupation
= opentin
;
166 occtxt
= "opening the tin";
169 ftmp
= &objects
[otmp
->otyp
];
170 multi
= -ftmp
->oc_delay
;
171 if(otmp
->otyp
>= CORPSE
&& eatcorpse(otmp
)) goto eatx
;
172 if(!rn2(7) && otmp
->otyp
!= FORTUNE_COOKIE
) {
173 pline("Blecch! Rotten food!");
175 pline("You feel rather light headed.");
177 } else if(!rn2(4)&& !Blind
) {
178 pline("Everything suddenly goes dark.");
183 pline("The world spins and you slap against the floor.");
185 pline("The world spins and goes dark.");
187 nomovemsg
= "You are conscious again.";
189 lesshungry(ftmp
->nutrition
/ 4);
191 if(u
.uhunger
>= 1500) {
192 pline("You choke over your food.");
194 killer
= ftmp
->oc_name
;
200 pline("That food really hit the spot!");
201 else if(u
.uhunger
<= 700)
202 pline("That satiated your stomach!");
204 pline("You're having a hard time getting all that food down.");
207 lesshungry(ftmp
->nutrition
);
208 if(multi
< 0) nomovemsg
= "You finished your meal.";
211 pline("Yak - dog food!");
212 more_experienced(1,0);
218 Sick
= 0; /* David Neves */
219 pline("What a relief!");
221 } else lesshungry(ftmp
->nutrition
);
224 if(otmp
->otyp
>= CORPSE
)
225 pline("That %s tasted terrible!",ftmp
->oc_name
);
227 pline("That %s was delicious!",ftmp
->oc_name
);
228 lesshungry(ftmp
->nutrition
);
229 if(otmp
->otyp
== DEAD_LIZARD
&& (Confusion
> 2))
233 if(otmp
->otyp
== CARROT
&& !Blind
){
236 pline("Your vision improves.");
239 if(otmp
->otyp
== FORTUNE_COOKIE
) {
241 pline("This cookie has a scrap of paper inside!");
242 pline("What a pity, that you cannot read it!");
246 if(otmp
->otyp
== LUMP_OF_ROYAL_JELLY
) {
247 /* This stuff seems to be VERY healthy! */
248 if(u
.ustrmax
< 118) u
.ustrmax
++;
249 if(u
.ustr
< u
.ustrmax
) u
.ustr
++;
251 if(u
.uhp
> u
.uhpmax
) {
252 if(!rn2(17)) u
.uhpmax
++;
261 if(multi
<0 && !nomovemsg
){
262 static char msgbuf
[BUFSZ
];
263 sprintf(msgbuf
, "You finished eating the %s.",
271 /* called in hack.main.c */
277 if(Regeneration
) u
.uhunger
--;
278 if(Hunger
) u
.uhunger
--;
279 /* a3: if(Hunger & LEFT_RING) u.uhunger--;
280 if(Hunger & RIGHT_RING) u.uhunger--;
283 if(moves
% 20 == 0) { /* jimt@asgb */
284 if(uleft
) u
.uhunger
--;
285 if(uright
) u
.uhunger
--;
290 /* called after vomiting and after performing feats of magic */
298 /* called after eating something (and after drinking fruit juice) */
316 int newhs
, h
= u
.uhunger
;
318 newhs
= (h
> 1000) ? SATIATED
:
319 (h
> 150) ? NOT_HUNGRY
:
321 (h
> 0) ? WEAK
: FAINTING
;
323 if(newhs
== FAINTING
) {
326 if(u
.uhs
<= WEAK
|| rn2(20-u
.uhunger
/10) >= 19) {
327 if(u
.uhs
!= FAINTED
&& multi
>= 0 /* %% */) {
328 pline("You faint from lack of food.");
329 nomul(-10+(u
.uhunger
/10));
330 nomovemsg
= "You regain consciousness.";
335 if(u
.uhunger
< -(int)(200 + 25*u
.ulevel
)) {
339 pline("You die from starvation.");
345 if(newhs
>= WEAK
&& u
.uhs
< WEAK
)
346 losestr(1); /* this may kill you -- see below */
348 if(newhs
< WEAK
&& u
.uhs
>= WEAK
&& u
.ustr
< u
.ustrmax
)
352 pline((!incr
) ? "You only feel hungry now." :
353 (u
.uhunger
< 145) ? "You feel hungry." :
354 "You are beginning to feel hungry.");
357 pline((!incr
) ? "You feel weak now." :
358 (u
.uhunger
< 45) ? "You feel weak." :
359 "You are beginning to feel weak.");
365 pline("You die from hunger and exhaustion.");
366 killer
= "exhaustion";
372 #define CORPSE_I_TO_C(otyp) (char) ((otyp >= DEAD_ACID_BLOB)\
373 ? 'a' + (otyp - DEAD_ACID_BLOB)\
374 : '@' + (otyp - DEAD_HUMAN))
376 poisonous(struct obj
*otmp
)
378 return(index(POISONOUS
, CORPSE_I_TO_C(otmp
->otyp
)) != 0);
381 /* returns 1 if some text was printed */
383 eatcorpse(struct obj
*otmp
)
385 char let
= CORPSE_I_TO_C(otmp
->otyp
);
387 if(let
!= 'a' && moves
> otmp
->age
+ 50 + rn2(100)) {
389 pline("Ulch -- that meat was tainted!");
390 pline("You get very sick.");
392 u
.usick_cause
= objects
[otmp
->otyp
].oc_name
;
393 } else if(index(POISONOUS
, let
) && rn2(5)){
395 pline("Ecch -- that must have been poisonous!");
396 if(!Poison_resistance
){
398 losehp(rnd(15), "poisonous corpse");
400 pline("You don't seem affected by the poison.");
401 } else if(index("ELNOPQRUuxz", let
) && rn2(5)){
403 pline("You feel sick.");
404 losehp(rnd(8), "cadaver");
410 Teleportation
|= INTRINSIC
;
418 /* fall into next case */
420 pline("You cannibal! You will be sorry for this!");
422 /* fall into next case */
424 Aggravate_monster
|= INTRINSIC
;
433 See_invisible
|= INTRINSIC
;
435 /* fall into next case */
440 /* fall into next case */
445 Fire_resistance
|= INTRINSIC
;
448 Telepat
|= INTRINSIC
;
452 Cold_resistance
|= INTRINSIC
;
456 Poison_resistance
|= INTRINSIC
;
459 pline("You turn to stone.");
460 killer
= "dead cockatrice";
465 pline("What a pity - you just destroyed a future piece of art!");
471 pline("You cannot resist the temptation to mimic a treasure chest.");
475 nomovemsg
= "You now again prefer mimicking a human.";