Home | History | Annotate | Line # | Download | only in hack
      1  1.13       mrg /*	$NetBSD: hack.eat.c,v 1.13 2019/02/04 03:33:15 mrg 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.13       mrg __RCSID("$NetBSD: hack.eat.c,v 1.13 2019/02/04 03:33:15 mrg 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.9  dholland static 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.9  dholland static int opentin(void);
     93   1.9  dholland static int Meatdone(void);
     94   1.9  dholland static int unfaint(void);
     95   1.9  dholland static void newuhs(boolean);
     96   1.9  dholland static int eatcorpse(struct obj *);
     97   1.9  dholland 
     98   1.4  christos void
     99   1.7  dholland init_uhunger(void)
    100   1.4  christos {
    101   1.1       cgd 	u.uhunger = 900;
    102   1.1       cgd 	u.uhs = NOT_HUNGRY;
    103   1.1       cgd }
    104   1.1       cgd 
    105   1.1       cgd #define	TTSZ	SIZE(tintxts)
    106   1.9  dholland static const struct {
    107   1.5       jsm 	const char           *txt;
    108   1.4  christos 	int             nut;
    109   1.4  christos }               tintxts[] = {
    110   1.4  christos 	{ "It contains first quality peaches - what a surprise!", 40 },
    111   1.4  christos 	{ "It contains salmon - not bad!", 60 },
    112   1.4  christos 	{ "It contains apple juice - perhaps not what you hoped for.", 20 },
    113   1.4  christos 	{ "It contains some nondescript substance, tasting awfully.", 500 },
    114   1.4  christos 	{ "It contains rotten meat. You vomit.", -50 },
    115   1.4  christos 	{ "It turns out to be empty.", 0 }
    116   1.1       cgd };
    117   1.1       cgd 
    118   1.1       cgd static struct {
    119   1.4  christos 	struct obj     *tin;
    120   1.4  christos 	int             usedtime, reqtime;
    121   1.4  christos }               tin;
    122   1.4  christos 
    123   1.9  dholland static int
    124   1.7  dholland opentin(void)
    125   1.4  christos {
    126   1.4  christos 	int             r;
    127   1.4  christos 
    128   1.4  christos 	if (!carried(tin.tin))	/* perhaps it was stolen? */
    129   1.4  christos 		return (0);	/* %% probably we should use tinoid */
    130   1.4  christos 	if (tin.usedtime++ >= 50) {
    131   1.1       cgd 		pline("You give up your attempt to open the tin.");
    132   1.4  christos 		return (0);
    133   1.1       cgd 	}
    134   1.4  christos 	if (tin.usedtime < tin.reqtime)
    135   1.4  christos 		return (1);	/* still busy */
    136   1.1       cgd 
    137   1.1       cgd 	pline("You succeed in opening the tin.");
    138   1.1       cgd 	useup(tin.tin);
    139   1.4  christos 	r = rn2(2 * TTSZ);
    140   1.4  christos 	if (r < TTSZ) {
    141  1.10     joerg 		pline("%s", tintxts[r].txt);
    142   1.4  christos 		lesshungry(tintxts[r].nut);
    143   1.4  christos 		if (r == 1) {	/* SALMON */
    144   1.4  christos 			Glib = rnd(15);
    145   1.4  christos 			pline("Eating salmon made your fingers very slippery.");
    146   1.4  christos 		}
    147   1.1       cgd 	} else {
    148   1.4  christos 		pline("It contains spinach - this makes you feel like Popeye!");
    149   1.4  christos 		lesshungry(600);
    150   1.4  christos 		if (u.ustr < 118)
    151   1.4  christos 			u.ustr += rnd(((u.ustr < 17) ? 19 : 118) - u.ustr);
    152   1.4  christos 		if (u.ustr > u.ustrmax)
    153   1.4  christos 			u.ustrmax = u.ustr;
    154   1.4  christos 		flags.botl = 1;
    155   1.1       cgd 	}
    156   1.4  christos 	return (0);
    157   1.1       cgd }
    158   1.1       cgd 
    159   1.9  dholland static int
    160   1.7  dholland Meatdone(void)
    161   1.4  christos {
    162   1.1       cgd 	u.usym = '@';
    163   1.1       cgd 	prme();
    164   1.4  christos 	return 0;
    165   1.1       cgd }
    166   1.1       cgd 
    167   1.4  christos int
    168   1.7  dholland doeat(void)
    169   1.4  christos {
    170   1.4  christos 	struct obj     *otmp;
    171   1.4  christos 	struct objclass *ftmp;
    172   1.4  christos 	int tmp;
    173   1.1       cgd 
    174   1.1       cgd 	/* Is there some food (probably a heavy corpse) here on the ground? */
    175   1.4  christos 	if (!Levitation)
    176   1.4  christos 		for (otmp = fobj; otmp; otmp = otmp->nobj) {
    177   1.4  christos 			if (otmp->ox == u.ux && otmp->oy == u.uy &&
    178   1.4  christos 			    otmp->olet == FOOD_SYM) {
    179   1.4  christos 				pline("There %s %s here; eat %s? [ny] ",
    180   1.4  christos 				      (otmp->quan == 1) ? "is" : "are",
    181   1.4  christos 				      doname(otmp),
    182   1.4  christos 				      (otmp->quan == 1) ? "it" : "one");
    183   1.4  christos 				if (readchar() == 'y') {
    184   1.4  christos 					if (otmp->quan != 1)
    185   1.4  christos 						(void) splitobj(otmp, 1);
    186   1.4  christos 					freeobj(otmp);
    187   1.4  christos 					otmp = addinv(otmp);
    188   1.4  christos 					addtobill(otmp);
    189   1.4  christos 					goto gotit;
    190   1.4  christos 				}
    191   1.1       cgd 			}
    192   1.1       cgd 		}
    193   1.1       cgd 	otmp = getobj("%", "eat");
    194   1.4  christos 	if (!otmp)
    195   1.4  christos 		return (0);
    196   1.1       cgd gotit:
    197   1.4  christos 	if (otmp->otyp == TIN) {
    198   1.4  christos 		if (uwep) {
    199   1.4  christos 			switch (uwep->otyp) {
    200   1.1       cgd 			case CAN_OPENER:
    201   1.1       cgd 				tmp = 1;
    202   1.1       cgd 				break;
    203   1.1       cgd 			case DAGGER:
    204   1.1       cgd 			case CRYSKNIFE:
    205   1.1       cgd 				tmp = 3;
    206   1.1       cgd 				break;
    207   1.1       cgd 			case PICK_AXE:
    208   1.1       cgd 			case AXE:
    209   1.1       cgd 				tmp = 6;
    210   1.1       cgd 				break;
    211   1.1       cgd 			default:
    212   1.1       cgd 				goto no_opener;
    213   1.1       cgd 			}
    214   1.1       cgd 			pline("Using your %s you try to open the tin.",
    215  1.11  dholland 			      aobjnam(uwep, NULL));
    216   1.1       cgd 		} else {
    217   1.4  christos 	no_opener:
    218   1.1       cgd 			pline("It is not so easy to open this tin.");
    219   1.4  christos 			if (Glib) {
    220   1.1       cgd 				pline("The tin slips out of your hands.");
    221   1.4  christos 				if (otmp->quan > 1) {
    222   1.4  christos 					struct obj     *obj;
    223   1.1       cgd 
    224   1.1       cgd 					obj = splitobj(otmp, 1);
    225   1.4  christos 					if (otmp == uwep)
    226   1.4  christos 						setuwep(obj);
    227   1.1       cgd 				}
    228   1.1       cgd 				dropx(otmp);
    229   1.4  christos 				return (1);
    230   1.1       cgd 			}
    231   1.4  christos 			tmp = 10 + rn2(1 + 500 / ((int) (u.ulevel + u.ustr)));
    232   1.1       cgd 		}
    233   1.1       cgd 		tin.reqtime = tmp;
    234   1.1       cgd 		tin.usedtime = 0;
    235   1.1       cgd 		tin.tin = otmp;
    236   1.1       cgd 		occupation = opentin;
    237   1.1       cgd 		occtxt = "opening the tin";
    238   1.4  christos 		return (1);
    239   1.1       cgd 	}
    240   1.1       cgd 	ftmp = &objects[otmp->otyp];
    241   1.1       cgd 	multi = -ftmp->oc_delay;
    242   1.4  christos 	if (otmp->otyp >= CORPSE && eatcorpse(otmp))
    243   1.4  christos 		goto eatx;
    244   1.4  christos 	if (!rn2(7) && otmp->otyp != FORTUNE_COOKIE) {
    245   1.1       cgd 		pline("Blecch!  Rotten food!");
    246   1.4  christos 		if (!rn2(4)) {
    247   1.1       cgd 			pline("You feel rather light headed.");
    248   1.4  christos 			Confusion += d(2, 4);
    249   1.4  christos 		} else if (!rn2(4) && !Blind) {
    250   1.1       cgd 			pline("Everything suddenly goes dark.");
    251   1.4  christos 			Blind = d(2, 10);
    252   1.1       cgd 			seeoff(0);
    253   1.4  christos 		} else if (!rn2(3)) {
    254   1.4  christos 			if (Blind)
    255   1.4  christos 				pline("The world spins and you slap against the floor.");
    256   1.1       cgd 			else
    257   1.4  christos 				pline("The world spins and goes dark.");
    258   1.1       cgd 			nomul(-rnd(10));
    259   1.1       cgd 			nomovemsg = "You are conscious again.";
    260   1.1       cgd 		}
    261   1.1       cgd 		lesshungry(ftmp->nutrition / 4);
    262   1.1       cgd 	} else {
    263   1.4  christos 		if (u.uhunger >= 1500) {
    264   1.1       cgd 			pline("You choke over your food.");
    265   1.1       cgd 			pline("You die...");
    266   1.1       cgd 			killer = ftmp->oc_name;
    267   1.1       cgd 			done("choked");
    268   1.1       cgd 		}
    269   1.4  christos 		switch (otmp->otyp) {
    270   1.1       cgd 		case FOOD_RATION:
    271   1.4  christos 			if (u.uhunger <= 200)
    272   1.1       cgd 				pline("That food really hit the spot!");
    273   1.4  christos 			else if (u.uhunger <= 700)
    274   1.1       cgd 				pline("That satiated your stomach!");
    275   1.1       cgd 			else {
    276   1.4  christos 				pline("You're having a hard time getting all that food down.");
    277   1.1       cgd 				multi -= 2;
    278   1.1       cgd 			}
    279   1.1       cgd 			lesshungry(ftmp->nutrition);
    280   1.4  christos 			if (multi < 0)
    281   1.4  christos 				nomovemsg = "You finished your meal.";
    282   1.1       cgd 			break;
    283   1.1       cgd 		case TRIPE_RATION:
    284   1.1       cgd 			pline("Yak - dog food!");
    285   1.4  christos 			more_experienced(1, 0);
    286   1.1       cgd 			flags.botl = 1;
    287   1.4  christos 			if (rn2(2)) {
    288   1.1       cgd 				pline("You vomit.");
    289   1.1       cgd 				morehungry(20);
    290   1.4  christos 				if (Sick) {
    291   1.1       cgd 					Sick = 0;	/* David Neves */
    292   1.1       cgd 					pline("What a relief!");
    293   1.1       cgd 				}
    294   1.4  christos 			} else
    295   1.4  christos 				lesshungry(ftmp->nutrition);
    296   1.1       cgd 			break;
    297   1.1       cgd 		default:
    298   1.4  christos 			if (otmp->otyp >= CORPSE)
    299   1.4  christos 				pline("That %s tasted terrible!", ftmp->oc_name);
    300   1.1       cgd 			else
    301   1.4  christos 				pline("That %s was delicious!", ftmp->oc_name);
    302   1.1       cgd 			lesshungry(ftmp->nutrition);
    303   1.4  christos 			if (otmp->otyp == DEAD_LIZARD && (Confusion > 2))
    304   1.1       cgd 				Confusion = 2;
    305   1.1       cgd 			else
    306   1.1       cgd #ifdef QUEST
    307   1.4  christos 			if (otmp->otyp == CARROT && !Blind) {
    308   1.1       cgd 				u.uhorizon++;
    309   1.1       cgd 				setsee();
    310   1.1       cgd 				pline("Your vision improves.");
    311   1.1       cgd 			} else
    312   1.4  christos #endif	/* QUEST */
    313   1.4  christos 			if (otmp->otyp == FORTUNE_COOKIE) {
    314   1.4  christos 				if (Blind) {
    315   1.4  christos 					pline("This cookie has a scrap of paper inside!");
    316   1.4  christos 					pline("What a pity, that you cannot read it!");
    317   1.4  christos 				} else
    318   1.4  christos 					outrumor();
    319   1.4  christos 			} else if (otmp->otyp == LUMP_OF_ROYAL_JELLY) {
    320   1.1       cgd 				/* This stuff seems to be VERY healthy! */
    321   1.4  christos 				if (u.ustrmax < 118)
    322   1.4  christos 					u.ustrmax++;
    323   1.4  christos 				if (u.ustr < u.ustrmax)
    324   1.4  christos 					u.ustr++;
    325   1.1       cgd 				u.uhp += rnd(20);
    326   1.4  christos 				if (u.uhp > u.uhpmax) {
    327   1.4  christos 					if (!rn2(17))
    328   1.4  christos 						u.uhpmax++;
    329   1.1       cgd 					u.uhp = u.uhpmax;
    330   1.1       cgd 				}
    331   1.1       cgd 				heal_legs();
    332   1.1       cgd 			}
    333   1.1       cgd 			break;
    334   1.1       cgd 		}
    335   1.1       cgd 	}
    336   1.1       cgd eatx:
    337   1.4  christos 	if (multi < 0 && !nomovemsg) {
    338   1.4  christos 		static char     msgbuf[BUFSZ];
    339   1.8  dholland 		(void) snprintf(msgbuf, sizeof(msgbuf),
    340   1.8  dholland 			       "You finished eating the %s.",
    341   1.4  christos 			       ftmp->oc_name);
    342   1.1       cgd 		nomovemsg = msgbuf;
    343   1.1       cgd 	}
    344   1.1       cgd 	useup(otmp);
    345   1.4  christos 	return (1);
    346   1.1       cgd }
    347   1.1       cgd 
    348   1.1       cgd /* called in hack.main.c */
    349   1.4  christos void
    350   1.7  dholland gethungry(void)
    351   1.4  christos {
    352   1.1       cgd 	--u.uhunger;
    353   1.4  christos 	if (moves % 2) {
    354   1.4  christos 		if (Regeneration)
    355   1.4  christos 			u.uhunger--;
    356   1.4  christos 		if (Hunger)
    357   1.4  christos 			u.uhunger--;
    358   1.4  christos 		/*
    359   1.4  christos 		 * a3:  if(Hunger & LEFT_RING) u.uhunger--; if(Hunger &
    360   1.4  christos 		 * RIGHT_RING) u.uhunger--; etc.
    361   1.4  christos 		 */
    362   1.4  christos 	}
    363   1.4  christos 	if (moves % 20 == 0) {	/* jimt@asgb */
    364   1.4  christos 		if (uleft)
    365   1.4  christos 			u.uhunger--;
    366   1.4  christos 		if (uright)
    367   1.4  christos 			u.uhunger--;
    368   1.1       cgd 	}
    369   1.1       cgd 	newuhs(TRUE);
    370   1.1       cgd }
    371   1.1       cgd 
    372   1.1       cgd /* called after vomiting and after performing feats of magic */
    373   1.4  christos void
    374   1.7  dholland morehungry(int num)
    375   1.4  christos {
    376   1.1       cgd 	u.uhunger -= num;
    377   1.1       cgd 	newuhs(TRUE);
    378   1.1       cgd }
    379   1.1       cgd 
    380   1.1       cgd /* called after eating something (and after drinking fruit juice) */
    381   1.4  christos void
    382   1.7  dholland lesshungry(int num)
    383   1.4  christos {
    384   1.1       cgd 	u.uhunger += num;
    385   1.1       cgd 	newuhs(FALSE);
    386   1.1       cgd }
    387   1.1       cgd 
    388   1.9  dholland static int
    389   1.7  dholland unfaint(void)
    390   1.4  christos {
    391   1.1       cgd 	u.uhs = FAINTING;
    392   1.1       cgd 	flags.botl = 1;
    393   1.4  christos 	return 0;
    394   1.1       cgd }
    395   1.1       cgd 
    396   1.9  dholland static void
    397   1.7  dholland newuhs(boolean incr)
    398   1.4  christos {
    399   1.4  christos 	int             newhs, h = u.uhunger;
    400   1.1       cgd 
    401   1.1       cgd 	newhs = (h > 1000) ? SATIATED :
    402   1.1       cgd 		(h > 150) ? NOT_HUNGRY :
    403   1.1       cgd 		(h > 50) ? HUNGRY :
    404   1.1       cgd 		(h > 0) ? WEAK : FAINTING;
    405   1.1       cgd 
    406   1.4  christos 	if (newhs == FAINTING) {
    407   1.4  christos 		if (u.uhs == FAINTED)
    408   1.1       cgd 			newhs = FAINTED;
    409   1.4  christos 		if (u.uhs <= WEAK || rn2(20 - u.uhunger / 10) >= 19) {
    410   1.4  christos 			if (u.uhs != FAINTED && multi >= 0 /* %% */ ) {
    411   1.1       cgd 				pline("You faint from lack of food.");
    412   1.4  christos 				nomul(-10 + (u.uhunger / 10));
    413   1.1       cgd 				nomovemsg = "You regain consciousness.";
    414   1.1       cgd 				afternmv = unfaint;
    415   1.1       cgd 				newhs = FAINTED;
    416   1.1       cgd 			}
    417   1.4  christos 		} else if (u.uhunger < -(int) (200 + 25 * u.ulevel)) {
    418   1.1       cgd 			u.uhs = STARVED;
    419   1.1       cgd 			flags.botl = 1;
    420   1.1       cgd 			bot();
    421   1.1       cgd 			pline("You die from starvation.");
    422   1.1       cgd 			done("starved");
    423   1.1       cgd 		}
    424   1.1       cgd 	}
    425   1.4  christos 	if (newhs != u.uhs) {
    426   1.4  christos 		if (newhs >= WEAK && u.uhs < WEAK)
    427   1.1       cgd 			losestr(1);	/* this may kill you -- see below */
    428   1.4  christos 		else if (newhs < WEAK && u.uhs >= WEAK && u.ustr < u.ustrmax)
    429   1.1       cgd 			losestr(-1);
    430   1.4  christos 		switch (newhs) {
    431   1.1       cgd 		case HUNGRY:
    432   1.1       cgd 			pline((!incr) ? "You only feel hungry now." :
    433   1.1       cgd 			      (u.uhunger < 145) ? "You feel hungry." :
    434   1.4  christos 			      "You are beginning to feel hungry.");
    435   1.1       cgd 			break;
    436   1.1       cgd 		case WEAK:
    437   1.1       cgd 			pline((!incr) ? "You feel weak now." :
    438   1.1       cgd 			      (u.uhunger < 45) ? "You feel weak." :
    439   1.4  christos 			      "You are beginning to feel weak.");
    440   1.1       cgd 			break;
    441   1.1       cgd 		}
    442   1.1       cgd 		u.uhs = newhs;
    443   1.1       cgd 		flags.botl = 1;
    444   1.4  christos 		if (u.uhp < 1) {
    445   1.1       cgd 			pline("You die from hunger and exhaustion.");
    446   1.1       cgd 			killer = "exhaustion";
    447   1.1       cgd 			done("starved");
    448   1.1       cgd 		}
    449   1.1       cgd 	}
    450   1.1       cgd }
    451   1.1       cgd 
    452   1.1       cgd #define	CORPSE_I_TO_C(otyp)	(char) ((otyp >= DEAD_ACID_BLOB)\
    453   1.1       cgd 		     ?  'a' + (otyp - DEAD_ACID_BLOB)\
    454   1.1       cgd 		     :	'@' + (otyp - DEAD_HUMAN))
    455   1.4  christos int
    456   1.7  dholland poisonous(struct obj *otmp)
    457   1.1       cgd {
    458   1.4  christos 	return (strchr(POISONOUS, CORPSE_I_TO_C(otmp->otyp)) != 0);
    459   1.1       cgd }
    460   1.1       cgd 
    461   1.1       cgd /* returns 1 if some text was printed */
    462   1.9  dholland static int
    463   1.7  dholland eatcorpse(struct obj *otmp)
    464   1.4  christos {
    465   1.4  christos 	char            let = CORPSE_I_TO_C(otmp->otyp);
    466   1.4  christos 	int             tp = 0;
    467   1.4  christos 	if (let != 'a' && moves > otmp->age + 50 + rn2(100)) {
    468   1.1       cgd 		tp++;
    469   1.1       cgd 		pline("Ulch -- that meat was tainted!");
    470   1.1       cgd 		pline("You get very sick.");
    471   1.1       cgd 		Sick = 10 + rn2(10);
    472   1.1       cgd 		u.usick_cause = objects[otmp->otyp].oc_name;
    473   1.4  christos 	} else if (strchr(POISONOUS, let) && rn2(5)) {
    474   1.1       cgd 		tp++;
    475   1.1       cgd 		pline("Ecch -- that must have been poisonous!");
    476   1.4  christos 		if (!Poison_resistance) {
    477   1.1       cgd 			losestr(rnd(4));
    478   1.1       cgd 			losehp(rnd(15), "poisonous corpse");
    479   1.1       cgd 		} else
    480   1.1       cgd 			pline("You don't seem affected by the poison.");
    481   1.4  christos 	} else if (strchr("ELNOPQRUuxz", let) && rn2(5)) {
    482   1.1       cgd 		tp++;
    483   1.1       cgd 		pline("You feel sick.");
    484   1.1       cgd 		losehp(rnd(8), "cadaver");
    485   1.1       cgd 	}
    486   1.4  christos 	switch (let) {
    487   1.1       cgd 	case 'L':
    488   1.1       cgd 	case 'N':
    489   1.1       cgd 	case 't':
    490   1.1       cgd 		Teleportation |= INTRINSIC;
    491   1.1       cgd 		break;
    492   1.1       cgd 	case 'W':
    493   1.1       cgd 		pluslvl();
    494   1.1       cgd 		break;
    495   1.1       cgd 	case 'n':
    496   1.1       cgd 		u.uhp = u.uhpmax;
    497   1.1       cgd 		flags.botl = 1;
    498  1.12  dholland 		/* FALLTHROUGH */
    499   1.1       cgd 	case '@':
    500   1.1       cgd 		pline("You cannibal! You will be sorry for this!");
    501   1.1       cgd 		/* not tp++; */
    502  1.12  dholland 		/* FALLTHROUGH */
    503   1.1       cgd 	case 'd':
    504   1.1       cgd 		Aggravate_monster |= INTRINSIC;
    505   1.1       cgd 		break;
    506   1.1       cgd 	case 'I':
    507   1.4  christos 		if (!Invis) {
    508   1.4  christos 			Invis = 50 + rn2(100);
    509   1.4  christos 			if (!See_invisible)
    510   1.1       cgd 				newsym(u.ux, u.uy);
    511   1.1       cgd 		} else {
    512   1.1       cgd 			Invis |= INTRINSIC;
    513   1.1       cgd 			See_invisible |= INTRINSIC;
    514   1.1       cgd 		}
    515  1.12  dholland 		/* FALLTHROUGH */
    516   1.1       cgd 	case 'y':
    517   1.1       cgd #ifdef QUEST
    518   1.1       cgd 		u.uhorizon++;
    519   1.4  christos #endif	/* QUEST */
    520  1.12  dholland 		/* FALLTHROUGH */
    521   1.1       cgd 	case 'B':
    522   1.1       cgd 		Confusion = 50;
    523   1.1       cgd 		break;
    524   1.1       cgd 	case 'D':
    525   1.1       cgd 		Fire_resistance |= INTRINSIC;
    526   1.1       cgd 		break;
    527   1.1       cgd 	case 'E':
    528   1.1       cgd 		Telepat |= INTRINSIC;
    529   1.1       cgd 		break;
    530   1.1       cgd 	case 'F':
    531   1.1       cgd 	case 'Y':
    532   1.1       cgd 		Cold_resistance |= INTRINSIC;
    533   1.1       cgd 		break;
    534   1.1       cgd 	case 'k':
    535   1.1       cgd 	case 's':
    536   1.1       cgd 		Poison_resistance |= INTRINSIC;
    537   1.1       cgd 		break;
    538   1.1       cgd 	case 'c':
    539   1.1       cgd 		pline("You turn to stone.");
    540   1.1       cgd 		killer = "dead cockatrice";
    541   1.1       cgd 		done("died");
    542  1.13       mrg 		break;
    543   1.1       cgd 	case 'a':
    544   1.4  christos 		if (Stoned) {
    545   1.4  christos 			pline("What a pity - you just destroyed a future piece of art!");
    546   1.4  christos 			tp++;
    547   1.4  christos 			Stoned = 0;
    548   1.4  christos 		}
    549   1.4  christos 		break;
    550   1.1       cgd 	case 'M':
    551   1.4  christos 		pline("You cannot resist the temptation to mimic a treasure chest.");
    552   1.4  christos 		tp++;
    553   1.4  christos 		nomul(-30);
    554   1.4  christos 		afternmv = Meatdone;
    555   1.4  christos 		nomovemsg = "You now again prefer mimicking a human.";
    556   1.4  christos 		u.usym = '$';
    557   1.4  christos 		prme();
    558   1.4  christos 		break;
    559   1.1       cgd 	}
    560   1.4  christos 	return (tp);
    561   1.1       cgd }
    562