Home | History | Annotate | Line # | Download | only in hack
hack.eat.c revision 1.6.26.1
      1  1.6.26.1       snj /*	$NetBSD: hack.eat.c,v 1.6.26.1 2009/06/29 23:43:48 snj Exp $	*/
      2       1.4  christos 
      3       1.2   mycroft /*
      4       1.6       jsm  * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
      5       1.6       jsm  * Amsterdam
      6       1.6       jsm  * All rights reserved.
      7       1.6       jsm  *
      8       1.6       jsm  * Redistribution and use in source and binary forms, with or without
      9       1.6       jsm  * modification, are permitted provided that the following conditions are
     10       1.6       jsm  * met:
     11       1.6       jsm  *
     12       1.6       jsm  * - Redistributions of source code must retain the above copyright notice,
     13       1.6       jsm  * this list of conditions and the following disclaimer.
     14       1.6       jsm  *
     15       1.6       jsm  * - Redistributions in binary form must reproduce the above copyright
     16       1.6       jsm  * notice, this list of conditions and the following disclaimer in the
     17       1.6       jsm  * documentation and/or other materials provided with the distribution.
     18       1.6       jsm  *
     19       1.6       jsm  * - Neither the name of the Stichting Centrum voor Wiskunde en
     20       1.6       jsm  * Informatica, nor the names of its contributors may be used to endorse or
     21       1.6       jsm  * promote products derived from this software without specific prior
     22       1.6       jsm  * written permission.
     23       1.6       jsm  *
     24       1.6       jsm  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
     25       1.6       jsm  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     26       1.6       jsm  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
     27       1.6       jsm  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
     28       1.6       jsm  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     29       1.6       jsm  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     30       1.6       jsm  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
     31       1.6       jsm  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
     32       1.6       jsm  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
     33       1.6       jsm  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     34       1.6       jsm  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     35       1.6       jsm  */
     36       1.6       jsm 
     37       1.6       jsm /*
     38       1.6       jsm  * Copyright (c) 1982 Jay Fenlason <hack (at) gnu.org>
     39       1.6       jsm  * All rights reserved.
     40       1.6       jsm  *
     41       1.6       jsm  * Redistribution and use in source and binary forms, with or without
     42       1.6       jsm  * modification, are permitted provided that the following conditions
     43       1.6       jsm  * are met:
     44       1.6       jsm  * 1. Redistributions of source code must retain the above copyright
     45       1.6       jsm  *    notice, this list of conditions and the following disclaimer.
     46       1.6       jsm  * 2. Redistributions in binary form must reproduce the above copyright
     47       1.6       jsm  *    notice, this list of conditions and the following disclaimer in the
     48       1.6       jsm  *    documentation and/or other materials provided with the distribution.
     49       1.6       jsm  * 3. The name of the author may not be used to endorse or promote products
     50       1.6       jsm  *    derived from this software without specific prior written permission.
     51       1.6       jsm  *
     52       1.6       jsm  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
     53       1.6       jsm  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
     54       1.6       jsm  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
     55       1.6       jsm  * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     56       1.6       jsm  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     57       1.6       jsm  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     58       1.6       jsm  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     59       1.6       jsm  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     60       1.6       jsm  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
     61       1.6       jsm  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     62       1.2   mycroft  */
     63       1.2   mycroft 
     64       1.4  christos #include <sys/cdefs.h>
     65       1.2   mycroft #ifndef lint
     66  1.6.26.1       snj __RCSID("$NetBSD: hack.eat.c,v 1.6.26.1 2009/06/29 23:43:48 snj Exp $");
     67       1.4  christos #endif				/* not lint */
     68       1.1       cgd 
     69       1.4  christos #include "hack.h"
     70       1.4  christos #include "extern.h"
     71       1.4  christos char            POISONOUS[] = "ADKSVabhks";
     72       1.1       cgd 
     73       1.1       cgd /* hunger texts used on bottom line (each 8 chars long) */
     74       1.1       cgd #define	SATIATED	0
     75       1.1       cgd #define NOT_HUNGRY	1
     76       1.1       cgd #define	HUNGRY		2
     77       1.1       cgd #define	WEAK		3
     78       1.1       cgd #define	FAINTING	4
     79       1.1       cgd #define FAINTED		5
     80       1.1       cgd #define STARVED		6
     81       1.1       cgd 
     82       1.5       jsm const char           *const hu_stat[] = {
     83       1.1       cgd 	"Satiated",
     84       1.1       cgd 	"        ",
     85       1.1       cgd 	"Hungry  ",
     86       1.1       cgd 	"Weak    ",
     87       1.1       cgd 	"Fainting",
     88       1.1       cgd 	"Fainted ",
     89       1.1       cgd 	"Starved "
     90       1.1       cgd };
     91       1.1       cgd 
     92       1.4  christos void
     93       1.4  christos init_uhunger()
     94       1.4  christos {
     95       1.1       cgd 	u.uhunger = 900;
     96       1.1       cgd 	u.uhs = NOT_HUNGRY;
     97       1.1       cgd }
     98       1.1       cgd 
     99       1.1       cgd #define	TTSZ	SIZE(tintxts)
    100       1.5       jsm const struct {
    101       1.5       jsm 	const char           *txt;
    102       1.4  christos 	int             nut;
    103       1.4  christos }               tintxts[] = {
    104       1.4  christos 	{ "It contains first quality peaches - what a surprise!", 40 },
    105       1.4  christos 	{ "It contains salmon - not bad!", 60 },
    106       1.4  christos 	{ "It contains apple juice - perhaps not what you hoped for.", 20 },
    107       1.4  christos 	{ "It contains some nondescript substance, tasting awfully.", 500 },
    108       1.4  christos 	{ "It contains rotten meat. You vomit.", -50 },
    109       1.4  christos 	{ "It turns out to be empty.", 0 }
    110       1.1       cgd };
    111       1.1       cgd 
    112       1.1       cgd static struct {
    113       1.4  christos 	struct obj     *tin;
    114       1.4  christos 	int             usedtime, reqtime;
    115       1.4  christos }               tin;
    116       1.4  christos 
    117       1.4  christos int
    118       1.4  christos opentin()
    119       1.4  christos {
    120       1.4  christos 	int             r;
    121       1.4  christos 
    122       1.4  christos 	if (!carried(tin.tin))	/* perhaps it was stolen? */
    123       1.4  christos 		return (0);	/* %% probably we should use tinoid */
    124       1.4  christos 	if (tin.usedtime++ >= 50) {
    125       1.1       cgd 		pline("You give up your attempt to open the tin.");
    126       1.4  christos 		return (0);
    127       1.1       cgd 	}
    128       1.4  christos 	if (tin.usedtime < tin.reqtime)
    129       1.4  christos 		return (1);	/* still busy */
    130       1.1       cgd 
    131       1.1       cgd 	pline("You succeed in opening the tin.");
    132       1.1       cgd 	useup(tin.tin);
    133       1.4  christos 	r = rn2(2 * TTSZ);
    134       1.4  christos 	if (r < TTSZ) {
    135       1.4  christos 		pline(tintxts[r].txt);
    136       1.4  christos 		lesshungry(tintxts[r].nut);
    137       1.4  christos 		if (r == 1) {	/* SALMON */
    138       1.4  christos 			Glib = rnd(15);
    139       1.4  christos 			pline("Eating salmon made your fingers very slippery.");
    140       1.4  christos 		}
    141       1.1       cgd 	} else {
    142       1.4  christos 		pline("It contains spinach - this makes you feel like Popeye!");
    143       1.4  christos 		lesshungry(600);
    144       1.4  christos 		if (u.ustr < 118)
    145       1.4  christos 			u.ustr += rnd(((u.ustr < 17) ? 19 : 118) - u.ustr);
    146       1.4  christos 		if (u.ustr > u.ustrmax)
    147       1.4  christos 			u.ustrmax = u.ustr;
    148       1.4  christos 		flags.botl = 1;
    149       1.1       cgd 	}
    150       1.4  christos 	return (0);
    151       1.1       cgd }
    152       1.1       cgd 
    153       1.4  christos int
    154       1.4  christos Meatdone()
    155       1.4  christos {
    156       1.1       cgd 	u.usym = '@';
    157       1.1       cgd 	prme();
    158       1.4  christos 	return 0;
    159       1.1       cgd }
    160       1.1       cgd 
    161       1.4  christos int
    162       1.4  christos doeat()
    163       1.4  christos {
    164       1.4  christos 	struct obj     *otmp;
    165       1.4  christos 	struct objclass *ftmp;
    166       1.4  christos 	int tmp;
    167       1.1       cgd 
    168       1.1       cgd 	/* Is there some food (probably a heavy corpse) here on the ground? */
    169       1.4  christos 	if (!Levitation)
    170       1.4  christos 		for (otmp = fobj; otmp; otmp = otmp->nobj) {
    171       1.4  christos 			if (otmp->ox == u.ux && otmp->oy == u.uy &&
    172       1.4  christos 			    otmp->olet == FOOD_SYM) {
    173       1.4  christos 				pline("There %s %s here; eat %s? [ny] ",
    174       1.4  christos 				      (otmp->quan == 1) ? "is" : "are",
    175       1.4  christos 				      doname(otmp),
    176       1.4  christos 				      (otmp->quan == 1) ? "it" : "one");
    177       1.4  christos 				if (readchar() == 'y') {
    178       1.4  christos 					if (otmp->quan != 1)
    179       1.4  christos 						(void) splitobj(otmp, 1);
    180       1.4  christos 					freeobj(otmp);
    181       1.4  christos 					otmp = addinv(otmp);
    182       1.4  christos 					addtobill(otmp);
    183       1.4  christos 					goto gotit;
    184       1.4  christos 				}
    185       1.1       cgd 			}
    186       1.1       cgd 		}
    187       1.1       cgd 	otmp = getobj("%", "eat");
    188       1.4  christos 	if (!otmp)
    189       1.4  christos 		return (0);
    190       1.1       cgd gotit:
    191       1.4  christos 	if (otmp->otyp == TIN) {
    192       1.4  christos 		if (uwep) {
    193       1.4  christos 			switch (uwep->otyp) {
    194       1.1       cgd 			case CAN_OPENER:
    195       1.1       cgd 				tmp = 1;
    196       1.1       cgd 				break;
    197       1.1       cgd 			case DAGGER:
    198       1.1       cgd 			case CRYSKNIFE:
    199       1.1       cgd 				tmp = 3;
    200       1.1       cgd 				break;
    201       1.1       cgd 			case PICK_AXE:
    202       1.1       cgd 			case AXE:
    203       1.1       cgd 				tmp = 6;
    204       1.1       cgd 				break;
    205       1.1       cgd 			default:
    206       1.1       cgd 				goto no_opener;
    207       1.1       cgd 			}
    208       1.1       cgd 			pline("Using your %s you try to open the tin.",
    209       1.4  christos 			      aobjnam(uwep, (char *) 0));
    210       1.1       cgd 		} else {
    211       1.4  christos 	no_opener:
    212       1.1       cgd 			pline("It is not so easy to open this tin.");
    213       1.4  christos 			if (Glib) {
    214       1.1       cgd 				pline("The tin slips out of your hands.");
    215       1.4  christos 				if (otmp->quan > 1) {
    216       1.4  christos 					struct obj     *obj;
    217       1.1       cgd 
    218       1.1       cgd 					obj = splitobj(otmp, 1);
    219       1.4  christos 					if (otmp == uwep)
    220       1.4  christos 						setuwep(obj);
    221       1.1       cgd 				}
    222       1.1       cgd 				dropx(otmp);
    223       1.4  christos 				return (1);
    224       1.1       cgd 			}
    225       1.4  christos 			tmp = 10 + rn2(1 + 500 / ((int) (u.ulevel + u.ustr)));
    226       1.1       cgd 		}
    227       1.1       cgd 		tin.reqtime = tmp;
    228       1.1       cgd 		tin.usedtime = 0;
    229       1.1       cgd 		tin.tin = otmp;
    230       1.1       cgd 		occupation = opentin;
    231       1.1       cgd 		occtxt = "opening the tin";
    232       1.4  christos 		return (1);
    233       1.1       cgd 	}
    234       1.1       cgd 	ftmp = &objects[otmp->otyp];
    235       1.1       cgd 	multi = -ftmp->oc_delay;
    236       1.4  christos 	if (otmp->otyp >= CORPSE && eatcorpse(otmp))
    237       1.4  christos 		goto eatx;
    238       1.4  christos 	if (!rn2(7) && otmp->otyp != FORTUNE_COOKIE) {
    239       1.1       cgd 		pline("Blecch!  Rotten food!");
    240       1.4  christos 		if (!rn2(4)) {
    241       1.1       cgd 			pline("You feel rather light headed.");
    242       1.4  christos 			Confusion += d(2, 4);
    243       1.4  christos 		} else if (!rn2(4) && !Blind) {
    244       1.1       cgd 			pline("Everything suddenly goes dark.");
    245       1.4  christos 			Blind = d(2, 10);
    246       1.1       cgd 			seeoff(0);
    247       1.4  christos 		} else if (!rn2(3)) {
    248       1.4  christos 			if (Blind)
    249       1.4  christos 				pline("The world spins and you slap against the floor.");
    250       1.1       cgd 			else
    251       1.4  christos 				pline("The world spins and goes dark.");
    252       1.1       cgd 			nomul(-rnd(10));
    253       1.1       cgd 			nomovemsg = "You are conscious again.";
    254       1.1       cgd 		}
    255       1.1       cgd 		lesshungry(ftmp->nutrition / 4);
    256       1.1       cgd 	} else {
    257       1.4  christos 		if (u.uhunger >= 1500) {
    258       1.1       cgd 			pline("You choke over your food.");
    259       1.1       cgd 			pline("You die...");
    260       1.1       cgd 			killer = ftmp->oc_name;
    261       1.1       cgd 			done("choked");
    262       1.1       cgd 		}
    263       1.4  christos 		switch (otmp->otyp) {
    264       1.1       cgd 		case FOOD_RATION:
    265       1.4  christos 			if (u.uhunger <= 200)
    266       1.1       cgd 				pline("That food really hit the spot!");
    267       1.4  christos 			else if (u.uhunger <= 700)
    268       1.1       cgd 				pline("That satiated your stomach!");
    269       1.1       cgd 			else {
    270       1.4  christos 				pline("You're having a hard time getting all that food down.");
    271       1.1       cgd 				multi -= 2;
    272       1.1       cgd 			}
    273       1.1       cgd 			lesshungry(ftmp->nutrition);
    274       1.4  christos 			if (multi < 0)
    275       1.4  christos 				nomovemsg = "You finished your meal.";
    276       1.1       cgd 			break;
    277       1.1       cgd 		case TRIPE_RATION:
    278       1.1       cgd 			pline("Yak - dog food!");
    279       1.4  christos 			more_experienced(1, 0);
    280       1.1       cgd 			flags.botl = 1;
    281       1.4  christos 			if (rn2(2)) {
    282       1.1       cgd 				pline("You vomit.");
    283       1.1       cgd 				morehungry(20);
    284       1.4  christos 				if (Sick) {
    285       1.1       cgd 					Sick = 0;	/* David Neves */
    286       1.1       cgd 					pline("What a relief!");
    287       1.1       cgd 				}
    288       1.4  christos 			} else
    289       1.4  christos 				lesshungry(ftmp->nutrition);
    290       1.1       cgd 			break;
    291       1.1       cgd 		default:
    292       1.4  christos 			if (otmp->otyp >= CORPSE)
    293       1.4  christos 				pline("That %s tasted terrible!", ftmp->oc_name);
    294       1.1       cgd 			else
    295       1.4  christos 				pline("That %s was delicious!", ftmp->oc_name);
    296       1.1       cgd 			lesshungry(ftmp->nutrition);
    297       1.4  christos 			if (otmp->otyp == DEAD_LIZARD && (Confusion > 2))
    298       1.1       cgd 				Confusion = 2;
    299       1.1       cgd 			else
    300       1.1       cgd #ifdef QUEST
    301       1.4  christos 			if (otmp->otyp == CARROT && !Blind) {
    302       1.1       cgd 				u.uhorizon++;
    303       1.1       cgd 				setsee();
    304       1.1       cgd 				pline("Your vision improves.");
    305       1.1       cgd 			} else
    306       1.4  christos #endif	/* QUEST */
    307       1.4  christos 			if (otmp->otyp == FORTUNE_COOKIE) {
    308       1.4  christos 				if (Blind) {
    309       1.4  christos 					pline("This cookie has a scrap of paper inside!");
    310       1.4  christos 					pline("What a pity, that you cannot read it!");
    311       1.4  christos 				} else
    312       1.4  christos 					outrumor();
    313       1.4  christos 			} else if (otmp->otyp == LUMP_OF_ROYAL_JELLY) {
    314       1.1       cgd 				/* This stuff seems to be VERY healthy! */
    315       1.4  christos 				if (u.ustrmax < 118)
    316       1.4  christos 					u.ustrmax++;
    317       1.4  christos 				if (u.ustr < u.ustrmax)
    318       1.4  christos 					u.ustr++;
    319       1.1       cgd 				u.uhp += rnd(20);
    320       1.4  christos 				if (u.uhp > u.uhpmax) {
    321       1.4  christos 					if (!rn2(17))
    322       1.4  christos 						u.uhpmax++;
    323       1.1       cgd 					u.uhp = u.uhpmax;
    324       1.1       cgd 				}
    325       1.1       cgd 				heal_legs();
    326       1.1       cgd 			}
    327       1.1       cgd 			break;
    328       1.1       cgd 		}
    329       1.1       cgd 	}
    330       1.1       cgd eatx:
    331       1.4  christos 	if (multi < 0 && !nomovemsg) {
    332       1.4  christos 		static char     msgbuf[BUFSZ];
    333  1.6.26.1       snj 		(void) snprintf(msgbuf, sizeof(msgbuf),
    334  1.6.26.1       snj 			       "You finished eating the %s.",
    335       1.4  christos 			       ftmp->oc_name);
    336       1.1       cgd 		nomovemsg = msgbuf;
    337       1.1       cgd 	}
    338       1.1       cgd 	useup(otmp);
    339       1.4  christos 	return (1);
    340       1.1       cgd }
    341       1.1       cgd 
    342       1.1       cgd /* called in hack.main.c */
    343       1.4  christos void
    344       1.4  christos gethungry()
    345       1.4  christos {
    346       1.1       cgd 	--u.uhunger;
    347       1.4  christos 	if (moves % 2) {
    348       1.4  christos 		if (Regeneration)
    349       1.4  christos 			u.uhunger--;
    350       1.4  christos 		if (Hunger)
    351       1.4  christos 			u.uhunger--;
    352       1.4  christos 		/*
    353       1.4  christos 		 * a3:  if(Hunger & LEFT_RING) u.uhunger--; if(Hunger &
    354       1.4  christos 		 * RIGHT_RING) u.uhunger--; etc.
    355       1.4  christos 		 */
    356       1.4  christos 	}
    357       1.4  christos 	if (moves % 20 == 0) {	/* jimt@asgb */
    358       1.4  christos 		if (uleft)
    359       1.4  christos 			u.uhunger--;
    360       1.4  christos 		if (uright)
    361       1.4  christos 			u.uhunger--;
    362       1.1       cgd 	}
    363       1.1       cgd 	newuhs(TRUE);
    364       1.1       cgd }
    365       1.1       cgd 
    366       1.1       cgd /* called after vomiting and after performing feats of magic */
    367       1.4  christos void
    368       1.4  christos morehungry(num)
    369       1.4  christos 	int num;
    370       1.4  christos {
    371       1.1       cgd 	u.uhunger -= num;
    372       1.1       cgd 	newuhs(TRUE);
    373       1.1       cgd }
    374       1.1       cgd 
    375       1.1       cgd /* called after eating something (and after drinking fruit juice) */
    376       1.4  christos void
    377       1.4  christos lesshungry(num)
    378       1.4  christos 	int num;
    379       1.4  christos {
    380       1.1       cgd 	u.uhunger += num;
    381       1.1       cgd 	newuhs(FALSE);
    382       1.1       cgd }
    383       1.1       cgd 
    384       1.4  christos int
    385       1.4  christos unfaint()
    386       1.4  christos {
    387       1.1       cgd 	u.uhs = FAINTING;
    388       1.1       cgd 	flags.botl = 1;
    389       1.4  christos 	return 0;
    390       1.1       cgd }
    391       1.1       cgd 
    392       1.4  christos void
    393       1.4  christos newuhs(incr)
    394       1.4  christos 	boolean         incr;
    395       1.4  christos {
    396       1.4  christos 	int             newhs, h = u.uhunger;
    397       1.1       cgd 
    398       1.1       cgd 	newhs = (h > 1000) ? SATIATED :
    399       1.1       cgd 		(h > 150) ? NOT_HUNGRY :
    400       1.1       cgd 		(h > 50) ? HUNGRY :
    401       1.1       cgd 		(h > 0) ? WEAK : FAINTING;
    402       1.1       cgd 
    403       1.4  christos 	if (newhs == FAINTING) {
    404       1.4  christos 		if (u.uhs == FAINTED)
    405       1.1       cgd 			newhs = FAINTED;
    406       1.4  christos 		if (u.uhs <= WEAK || rn2(20 - u.uhunger / 10) >= 19) {
    407       1.4  christos 			if (u.uhs != FAINTED && multi >= 0 /* %% */ ) {
    408       1.1       cgd 				pline("You faint from lack of food.");
    409       1.4  christos 				nomul(-10 + (u.uhunger / 10));
    410       1.1       cgd 				nomovemsg = "You regain consciousness.";
    411       1.1       cgd 				afternmv = unfaint;
    412       1.1       cgd 				newhs = FAINTED;
    413       1.1       cgd 			}
    414       1.4  christos 		} else if (u.uhunger < -(int) (200 + 25 * u.ulevel)) {
    415       1.1       cgd 			u.uhs = STARVED;
    416       1.1       cgd 			flags.botl = 1;
    417       1.1       cgd 			bot();
    418       1.1       cgd 			pline("You die from starvation.");
    419       1.1       cgd 			done("starved");
    420       1.1       cgd 		}
    421       1.1       cgd 	}
    422       1.4  christos 	if (newhs != u.uhs) {
    423       1.4  christos 		if (newhs >= WEAK && u.uhs < WEAK)
    424       1.1       cgd 			losestr(1);	/* this may kill you -- see below */
    425       1.4  christos 		else if (newhs < WEAK && u.uhs >= WEAK && u.ustr < u.ustrmax)
    426       1.1       cgd 			losestr(-1);
    427       1.4  christos 		switch (newhs) {
    428       1.1       cgd 		case HUNGRY:
    429       1.1       cgd 			pline((!incr) ? "You only feel hungry now." :
    430       1.1       cgd 			      (u.uhunger < 145) ? "You feel hungry." :
    431       1.4  christos 			      "You are beginning to feel hungry.");
    432       1.1       cgd 			break;
    433       1.1       cgd 		case WEAK:
    434       1.1       cgd 			pline((!incr) ? "You feel weak now." :
    435       1.1       cgd 			      (u.uhunger < 45) ? "You feel weak." :
    436       1.4  christos 			      "You are beginning to feel weak.");
    437       1.1       cgd 			break;
    438       1.1       cgd 		}
    439       1.1       cgd 		u.uhs = newhs;
    440       1.1       cgd 		flags.botl = 1;
    441       1.4  christos 		if (u.uhp < 1) {
    442       1.1       cgd 			pline("You die from hunger and exhaustion.");
    443       1.1       cgd 			killer = "exhaustion";
    444       1.1       cgd 			done("starved");
    445       1.1       cgd 		}
    446       1.1       cgd 	}
    447       1.1       cgd }
    448       1.1       cgd 
    449       1.1       cgd #define	CORPSE_I_TO_C(otyp)	(char) ((otyp >= DEAD_ACID_BLOB)\
    450       1.1       cgd 		     ?  'a' + (otyp - DEAD_ACID_BLOB)\
    451       1.1       cgd 		     :	'@' + (otyp - DEAD_HUMAN))
    452       1.4  christos int
    453       1.1       cgd poisonous(otmp)
    454       1.4  christos 	struct obj     *otmp;
    455       1.1       cgd {
    456       1.4  christos 	return (strchr(POISONOUS, CORPSE_I_TO_C(otmp->otyp)) != 0);
    457       1.1       cgd }
    458       1.1       cgd 
    459       1.1       cgd /* returns 1 if some text was printed */
    460       1.4  christos int
    461       1.4  christos eatcorpse(otmp)
    462       1.4  christos 	struct obj     *otmp;
    463       1.4  christos {
    464       1.4  christos 	char            let = CORPSE_I_TO_C(otmp->otyp);
    465       1.4  christos 	int             tp = 0;
    466       1.4  christos 	if (let != 'a' && moves > otmp->age + 50 + rn2(100)) {
    467       1.1       cgd 		tp++;
    468       1.1       cgd 		pline("Ulch -- that meat was tainted!");
    469       1.1       cgd 		pline("You get very sick.");
    470       1.1       cgd 		Sick = 10 + rn2(10);
    471       1.1       cgd 		u.usick_cause = objects[otmp->otyp].oc_name;
    472       1.4  christos 	} else if (strchr(POISONOUS, let) && rn2(5)) {
    473       1.1       cgd 		tp++;
    474       1.1       cgd 		pline("Ecch -- that must have been poisonous!");
    475       1.4  christos 		if (!Poison_resistance) {
    476       1.1       cgd 			losestr(rnd(4));
    477       1.1       cgd 			losehp(rnd(15), "poisonous corpse");
    478       1.1       cgd 		} else
    479       1.1       cgd 			pline("You don't seem affected by the poison.");
    480       1.4  christos 	} else if (strchr("ELNOPQRUuxz", let) && rn2(5)) {
    481       1.1       cgd 		tp++;
    482       1.1       cgd 		pline("You feel sick.");
    483       1.1       cgd 		losehp(rnd(8), "cadaver");
    484       1.1       cgd 	}
    485       1.4  christos 	switch (let) {
    486       1.1       cgd 	case 'L':
    487       1.1       cgd 	case 'N':
    488       1.1       cgd 	case 't':
    489       1.1       cgd 		Teleportation |= INTRINSIC;
    490       1.1       cgd 		break;
    491       1.1       cgd 	case 'W':
    492       1.1       cgd 		pluslvl();
    493       1.1       cgd 		break;
    494       1.1       cgd 	case 'n':
    495       1.1       cgd 		u.uhp = u.uhpmax;
    496       1.1       cgd 		flags.botl = 1;
    497       1.1       cgd 		/* fall into next case */
    498       1.1       cgd 	case '@':
    499       1.1       cgd 		pline("You cannibal! You will be sorry for this!");
    500       1.1       cgd 		/* not tp++; */
    501       1.1       cgd 		/* fall into next case */
    502       1.1       cgd 	case 'd':
    503       1.1       cgd 		Aggravate_monster |= INTRINSIC;
    504       1.1       cgd 		break;
    505       1.1       cgd 	case 'I':
    506       1.4  christos 		if (!Invis) {
    507       1.4  christos 			Invis = 50 + rn2(100);
    508       1.4  christos 			if (!See_invisible)
    509       1.1       cgd 				newsym(u.ux, u.uy);
    510       1.1       cgd 		} else {
    511       1.1       cgd 			Invis |= INTRINSIC;
    512       1.1       cgd 			See_invisible |= INTRINSIC;
    513       1.1       cgd 		}
    514       1.1       cgd 		/* fall into next case */
    515       1.1       cgd 	case 'y':
    516       1.1       cgd #ifdef QUEST
    517       1.1       cgd 		u.uhorizon++;
    518       1.4  christos #endif	/* QUEST */
    519       1.1       cgd 		/* fall into next case */
    520       1.1       cgd 	case 'B':
    521       1.1       cgd 		Confusion = 50;
    522       1.1       cgd 		break;
    523       1.1       cgd 	case 'D':
    524       1.1       cgd 		Fire_resistance |= INTRINSIC;
    525       1.1       cgd 		break;
    526       1.1       cgd 	case 'E':
    527       1.1       cgd 		Telepat |= INTRINSIC;
    528       1.1       cgd 		break;
    529       1.1       cgd 	case 'F':
    530       1.1       cgd 	case 'Y':
    531       1.1       cgd 		Cold_resistance |= INTRINSIC;
    532       1.1       cgd 		break;
    533       1.1       cgd 	case 'k':
    534       1.1       cgd 	case 's':
    535       1.1       cgd 		Poison_resistance |= INTRINSIC;
    536       1.1       cgd 		break;
    537       1.1       cgd 	case 'c':
    538       1.1       cgd 		pline("You turn to stone.");
    539       1.1       cgd 		killer = "dead cockatrice";
    540       1.1       cgd 		done("died");
    541       1.1       cgd 		/* NOTREACHED */
    542       1.1       cgd 	case 'a':
    543       1.4  christos 		if (Stoned) {
    544       1.4  christos 			pline("What a pity - you just destroyed a future piece of art!");
    545       1.4  christos 			tp++;
    546       1.4  christos 			Stoned = 0;
    547       1.4  christos 		}
    548       1.4  christos 		break;
    549       1.1       cgd 	case 'M':
    550       1.4  christos 		pline("You cannot resist the temptation to mimic a treasure chest.");
    551       1.4  christos 		tp++;
    552       1.4  christos 		nomul(-30);
    553       1.4  christos 		afternmv = Meatdone;
    554       1.4  christos 		nomovemsg = "You now again prefer mimicking a human.";
    555       1.4  christos 		u.usym = '$';
    556       1.4  christos 		prme();
    557       1.4  christos 		break;
    558       1.1       cgd 	}
    559       1.4  christos 	return (tp);
    560       1.1       cgd }
    561