# Source:NetHack 3.6.1/src/eat.c
Below is the full text to eat.c from the source code of NetHack 3.6.1. To link to a particular line, write [[Source:NetHack 3.6.1/src/eat.c#line123]], for example.

Contents

1 Top of file
2 is_edible
3 init_uhunger
4 eatmdone
5 eatmupdate
6 food_xname
7 choke
8 recalc_wt
9 reset_eat
10 obj_nutrition
11 touchfood
12 food_disappears
13 food_substitution
14 do_reset_eat
15 eatfood
16 done_eating
17 eating_conducts
18 eat_brains
19 maybe_cannibal
20 cprefx
21 fix_petrification
22 intrinsic_possible
23 givit
24 cpostfx
25 violated_vegetarian
26 costly_tin
27 tin_variety_txt
28 tin_details
29 set_tin_variety
30 tin_variety
31 consume_tin
32 opentin
33 start_tin
34 Hear_again
35 rottenfood
36 eatcorpse
37 start_eating
38 fprefx
39 bounded_increase
40 accessory_has_effect
41 eataccessory
42 eatspecial
43 foodword
44 fpostfx
45 leather_cover
46 edibility_prompts
47 doeat
48 use_tin_opener
49 bite
50 gethungry
51 morehungry
52 lesshungry
53 unfaint
54 is_fainted
55 reset_faint
56 newuhs
57 floorfood
58 vomit
59 eaten_stat
60 consume_oeaten
61 maybe_finished_meal
62 Popeye

Top of file
&nbsp;/* NetHack 3.6	eat.c	$NHDT-Date: 1502754159 2017/08/14 23:42:39 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.179 $ */
&nbsp;/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
&nbsp;/*-Copyright (c) Robert Patrick Rankin, 2012. */
&nbsp;/* NetHack may be freely redistributed.  See license for details. */

The NetHack General Public License applies to screenshots, source code and other content from NetHack.
This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

&nbsp;
&nbsp;#include "hack.h"
&nbsp;
&nbsp;STATIC_PTR int NDECL(eatmdone);
&nbsp;STATIC_PTR int NDECL(eatfood);
&nbsp;STATIC_PTR struct obj *FDECL(costly_tin, (int));
&nbsp;STATIC_PTR int NDECL(opentin);
&nbsp;STATIC_PTR int NDECL(unfaint);
&nbsp;
&nbsp;STATIC_DCL const char *FDECL(food_xname, (struct obj *, BOOLEAN_P));
&nbsp;STATIC_DCL void FDECL(choke, (struct obj *));
&nbsp;STATIC_DCL void NDECL(recalc_wt);
&nbsp;STATIC_DCL unsigned FDECL(obj_nutrition, (struct obj *));
&nbsp;STATIC_DCL struct obj *FDECL(touchfood, (struct obj *));
&nbsp;STATIC_DCL void NDECL(do_reset_eat);
&nbsp;STATIC_DCL void FDECL(done_eating, (BOOLEAN_P));
&nbsp;STATIC_DCL void FDECL(cprefx, (int));
&nbsp;STATIC_DCL int FDECL(intrinsic_possible, (int, struct permonst *));
&nbsp;STATIC_DCL void FDECL(givit, (int, struct permonst *));
&nbsp;STATIC_DCL void FDECL(cpostfx, (int));
&nbsp;STATIC_DCL void FDECL(consume_tin, (const char *));
&nbsp;STATIC_DCL void FDECL(start_tin, (struct obj *));
&nbsp;STATIC_DCL int FDECL(eatcorpse, (struct obj *));
&nbsp;STATIC_DCL void FDECL(start_eating, (struct obj *));
&nbsp;STATIC_DCL void FDECL(fprefx, (struct obj *));
&nbsp;STATIC_DCL void FDECL(fpostfx, (struct obj *));
&nbsp;STATIC_DCL int NDECL(bite);
&nbsp;STATIC_DCL int FDECL(edibility_prompts, (struct obj *));
&nbsp;STATIC_DCL int FDECL(rottenfood, (struct obj *));
&nbsp;STATIC_DCL void NDECL(eatspecial);
&nbsp;STATIC_DCL int FDECL(bounded_increase, (int, int, int));
&nbsp;STATIC_DCL void FDECL(accessory_has_effect, (struct obj *));
&nbsp;STATIC_DCL void FDECL(eataccessory, (struct obj *));
&nbsp;STATIC_DCL const char *FDECL(foodword, (struct obj *));
&nbsp;STATIC_DCL int FDECL(tin_variety, (struct obj *, BOOLEAN_P));
&nbsp;STATIC_DCL boolean FDECL(maybe_cannibal, (int, BOOLEAN_P));
&nbsp;
&nbsp;char msgbuf[BUFSZ];
&nbsp;
&nbsp;/* also used to see if you're allowed to eat cats and dogs */
&nbsp;#define CANNIBAL_ALLOWED() (Role_if(PM_CAVEMAN) || Race_if(PM_ORC))
&nbsp;
&nbsp;/* monster types that cause hero to be turned into stone if eaten */
&nbsp;#define flesh_petrifies(pm) (touch_petrifies(pm) || (pm) == &amp;mons[PM_MEDUSA])
&nbsp;
&nbsp;/* Rider corpses are treated as non-rotting so that attempting to eat one
&nbsp;   will be sure to reach the stage of eating where that meal is fatal */
&nbsp;#define nonrotting_corpse(mnum) \
&nbsp;    ((mnum) == PM_LIZARD || (mnum) == PM_LICHEN || is_rider(&amp;mons[mnum]))
&nbsp;
&nbsp;/* non-rotting non-corpses; unlike lizard corpses, these items will behave
&nbsp;   as if rotten if they are cursed (fortune cookies handled elsewhere) */
&nbsp;#define nonrotting_food(otyp) \
&nbsp;    ((otyp) == LEMBAS_WAFER || (otyp) == CRAM_RATION)
&nbsp;
&nbsp;STATIC_OVL NEARDATA const char comestibles[] = { FOOD_CLASS, 0 };
&nbsp;STATIC_OVL NEARDATA const char offerfodder[] = { FOOD_CLASS, AMULET_CLASS,
&nbsp;                                                 0 };
&nbsp;
&nbsp;/* Gold must come first for getobj(). */
&nbsp;STATIC_OVL NEARDATA const char allobj[] = {
&nbsp;    COIN_CLASS,   WEAPON_CLASS, ARMOR_CLASS,  POTION_CLASS,
&nbsp;    SCROLL_CLASS, WAND_CLASS,   RING_CLASS,   AMULET_CLASS,
&nbsp;    FOOD_CLASS,   TOOL_CLASS,   GEM_CLASS,    ROCK_CLASS,
&nbsp;    BALL_CLASS,   CHAIN_CLASS,  SPBOOK_CLASS, 0
&nbsp;};
&nbsp;
&nbsp;STATIC_OVL boolean force_save_hs = FALSE;
&nbsp;
&nbsp;/* see hunger states in hack.h - texts used on bottom line */
&nbsp;const char *hu_stat[] = { "Satiated", "        ", "Hungry  ", "Weak    ",
&nbsp;                          "Fainting", "Fainted ", "Starved " };
&nbsp;
is_edible
&nbsp;/*
&nbsp; * Decide whether a particular object can be eaten by the possibly
&nbsp; * polymorphed character.  Not used for monster checks.
&nbsp; */
&nbsp;boolean
&nbsp;is_edible(obj)
&nbsp;register struct obj *obj;
&nbsp;{
&nbsp;    /* protect invocation tools but not Rider corpses (handled elsewhere)*/
&nbsp;    /* if (obj-&gt;oclass != FOOD_CLASS &amp;&amp; obj_resists(obj, 0, 0)) */
&nbsp;    if (objects[obj-&gt;otyp].oc_unique)
&nbsp;        return FALSE;
&nbsp;    /* above also prevents the Amulet from being eaten, so we must never
&nbsp;       allow fake amulets to be eaten either [which is already the case] */
&nbsp;
&nbsp;    if (metallivorous(youmonst.data) &amp;&amp; is_metallic(obj)
&nbsp;        &amp;&amp; (youmonst.data != &amp;mons[PM_RUST_MONSTER] || is_rustprone(obj)))
&nbsp;        return TRUE;
&nbsp;
&nbsp;    /* Ghouls only eat non-veggy corpses or eggs (see dogfood()) */
&nbsp;    if (u.umonnum == PM_GHOUL)
&nbsp;        return (boolean)((obj-&gt;otyp == CORPSE
&nbsp;                          &amp;&amp; !vegan(&amp;mons[obj-&gt;corpsenm]))
&nbsp;                         || (obj-&gt;otyp == EGG));
&nbsp;
&nbsp;    if (u.umonnum == PM_GELATINOUS_CUBE &amp;&amp; is_organic(obj)
&nbsp;        /* [g.cubes can eat containers and retain all contents
&nbsp;            as engulfed items, but poly'd player can't do that] */
&nbsp;        &amp;&amp; !Has_contents(obj))
&nbsp;        return TRUE;
&nbsp;
&nbsp;    /* return (boolean) !!index(comestibles, obj-&gt;oclass); */
&nbsp;    return (boolean) (obj-&gt;oclass == FOOD_CLASS);
&nbsp;}
&nbsp;
init_uhunger
&nbsp;void
&nbsp;init_uhunger()
&nbsp;{
&nbsp;    context.botl = (u.uhs != NOT_HUNGRY || ATEMP(A_STR) &lt; 0);
&nbsp;    u.uhunger = 900;
&nbsp;    u.uhs = NOT_HUNGRY;
&nbsp;    if (ATEMP(A_STR) &lt; 0)
&nbsp;        ATEMP(A_STR) = 0;
&nbsp;}
&nbsp;
&nbsp;/* tin types [SPINACH_TIN = -1, overrides corpsenm, nut==600] */
&nbsp;static const struct {
&nbsp;    const char *txt;                      /* description */
&nbsp;    int nut;                              /* nutrition */
&nbsp;    Bitfield(fodder, 1);                  /* stocked by health food shops */
&nbsp;    Bitfield(greasy, 1);                  /* causes slippery fingers */
&nbsp;} tintxts[] = { { "rotten", -50, 0, 0 },  /* ROTTEN_TIN = 0 */
&nbsp;                { "homemade", 50, 1, 0 }, /* HOMEMADE_TIN = 1 */
&nbsp;                { "soup made from", 20, 1, 0 },
&nbsp;                { "french fried", 40, 0, 1 },
&nbsp;                { "pickled", 40, 1, 0 },
&nbsp;                { "boiled", 50, 1, 0 },
&nbsp;                { "smoked", 50, 1, 0 },
&nbsp;                { "dried", 55, 1, 0 },
&nbsp;                { "deep fried", 60, 0, 1 },
&nbsp;                { "szechuan", 70, 1, 0 },
&nbsp;                { "broiled", 80, 0, 0 },
&nbsp;                { "stir fried", 80, 0, 1 },
&nbsp;                { "sauteed", 95, 0, 0 },
&nbsp;                { "candied", 100, 1, 0 },
&nbsp;                { "pureed", 500, 1, 0 },
&nbsp;                { "", 0, 0, 0 } };
&nbsp;#define TTSZ SIZE(tintxts)
&nbsp;
&nbsp;static char *eatmbuf = 0; /* set by cpostfx() */
&nbsp;
eatmdone
&nbsp;/* called after mimicing is over */
&nbsp;STATIC_PTR int
&nbsp;eatmdone(VOID_ARGS)
&nbsp;{
&nbsp;    /* release `eatmbuf' */
&nbsp;    if (eatmbuf) {
&nbsp;        if (nomovemsg == eatmbuf)
&nbsp;            nomovemsg = 0;
&nbsp;        free((genericptr_t) eatmbuf), eatmbuf = 0;
&nbsp;    }
&nbsp;    /* update display */
&nbsp;    if (youmonst.m_ap_type) {
&nbsp;        youmonst.m_ap_type = M_AP_NOTHING;
&nbsp;        newsym(u.ux, u.uy);
&nbsp;    }
&nbsp;    return 0;
&nbsp;}
&nbsp;
eatmupdate
&nbsp;/* called when hallucination is toggled */
&nbsp;void
&nbsp;eatmupdate()
&nbsp;{
&nbsp;    const char *altmsg = 0;
&nbsp;    int altapp = 0; /* lint suppression */
&nbsp;
&nbsp;    if (!eatmbuf || nomovemsg != eatmbuf)
&nbsp;        return;
&nbsp;
&nbsp;    if (is_obj_mappear(&amp;youmonst,ORANGE) &amp;&amp; !Hallucination) {
&nbsp;        /* revert from hallucinatory to "normal" mimicking */
&nbsp;        altmsg = "You now prefer mimicking yourself.";
&nbsp;        altapp = GOLD_PIECE;
&nbsp;    } else if (is_obj_mappear(&amp;youmonst,GOLD_PIECE) &amp;&amp; Hallucination) {
&nbsp;        /* won't happen; anything which might make immobilized
&nbsp;           hero begin hallucinating (black light attack, theft
&nbsp;           of Grayswandir) will terminate the mimicry first */
&nbsp;        altmsg = "Your rind escaped intact.";
&nbsp;        altapp = ORANGE;
&nbsp;    }
&nbsp;
&nbsp;    if (altmsg) {
&nbsp;        /* replace end-of-mimicking message */
&nbsp;        if (strlen(altmsg) &gt; strlen(eatmbuf)) {
&nbsp;            free((genericptr_t) eatmbuf);
&nbsp;            eatmbuf = (char *) alloc(strlen(altmsg) + 1);
&nbsp;        }
&nbsp;        nomovemsg = strcpy(eatmbuf, altmsg);
&nbsp;        /* update current image */
&nbsp;        youmonst.mappearance = altapp;
&nbsp;        newsym(u.ux, u.uy);
&nbsp;    }
&nbsp;}
&nbsp;
food_xname
&nbsp;/* ``[the(] singular(food, xname) [)]'' */
&nbsp;STATIC_OVL const char *
&nbsp;food_xname(food, the_pfx)
&nbsp;struct obj *food;
&nbsp;boolean the_pfx;
&nbsp;{
&nbsp;    const char *result;
&nbsp;
&nbsp;    if (food-&gt;otyp == CORPSE) {
&nbsp;        result = corpse_xname(food, (const char *) 0,
&nbsp;                              CXN_SINGULAR | (the_pfx ? CXN_PFX_THE : 0));
&nbsp;        /* not strictly needed since pname values are capitalized
&nbsp;           and the() is a no-op for them */
&nbsp;        if (type_is_pname(&amp;mons[food-&gt;corpsenm]))
&nbsp;            the_pfx = FALSE;
&nbsp;    } else {
&nbsp;        /* the ordinary case */
&nbsp;        result = singular(food, xname);
&nbsp;    }
&nbsp;    if (the_pfx)
&nbsp;        result = the(result);
&nbsp;    return result;
&nbsp;}
&nbsp;
choke
&nbsp;/* Created by GAN 01/28/87
&nbsp; * Amended by AKP 09/22/87: if not hard, don't choke, just vomit.
&nbsp; * Amended by 3.  06/12/89: if not hard, sometimes choke anyway, to keep risk.
&nbsp; *                11/10/89: if hard, rarely vomit anyway, for slim chance.
&nbsp; *
&nbsp; * To a full belly all food is bad. (It.)
&nbsp; */
&nbsp;STATIC_OVL void
&nbsp;choke(food)
&nbsp;struct obj *food;
&nbsp;{
&nbsp;    /* only happens if you were satiated */
&nbsp;    if (u.uhs != SATIATED) {
&nbsp;        if (!food || food-&gt;otyp != AMULET_OF_STRANGULATION)
&nbsp;            return;
&nbsp;    } else if (Role_if(PM_KNIGHT) &amp;&amp; u.ualign.type == A_LAWFUL) {
&nbsp;        adjalign(-1); /* gluttony is unchivalrous */
&nbsp;        You_feel("like a glutton!");
&nbsp;    }
&nbsp;
&nbsp;    exercise(A_CON, FALSE);
&nbsp;
&nbsp;    if (Breathless || (!Strangled &amp;&amp; !rn2(20))) {
&nbsp;        /* choking by eating AoS doesn't involve stuffing yourself */
&nbsp;        if (food &amp;&amp; food-&gt;otyp == AMULET_OF_STRANGULATION) {
&nbsp;            You("choke, but recover your composure.");
&nbsp;            return;
&nbsp;        }
&nbsp;        You("stuff yourself and then vomit voluminously.");
&nbsp;        morehungry(1000); /* you just got *very* sick! */
&nbsp;        vomit();
&nbsp;    } else {
&nbsp;        killer.format = KILLED_BY_AN;
&nbsp;        /*
&nbsp;         * Note all "killer"s below read "Choked on %s" on the
&nbsp;         * high score list &amp; tombstone.  So plan accordingly.
&nbsp;         */
&nbsp;        if (food) {
&nbsp;            You("choke over your %s.", foodword(food));
&nbsp;            if (food-&gt;oclass == COIN_CLASS) {
&nbsp;                Strcpy(killer.name, "very rich meal");
&nbsp;            } else {
&nbsp;                killer.format = KILLED_BY;
&nbsp;                Strcpy(killer.name, killer_xname(food));
&nbsp;            }
&nbsp;        } else {
&nbsp;            You("choke over it.");
&nbsp;            Strcpy(killer.name, "quick snack");
&nbsp;        }
&nbsp;        You("die...");
&nbsp;        done(CHOKING);
&nbsp;    }
&nbsp;}
&nbsp;
recalc_wt
&nbsp;/* modify object wt. depending on time spent consuming it */
&nbsp;STATIC_OVL void
&nbsp;recalc_wt()
&nbsp;{
&nbsp;    struct obj *piece = context.victual.piece;
&nbsp;    if (!piece) {
&nbsp;        impossible("recalc_wt without piece");
&nbsp;        return;
&nbsp;    }
&nbsp;    debugpline1("Old weight = %d", piece-&gt;owt);
&nbsp;    debugpline2("Used time = %d, Req'd time = %d", context.victual.usedtime,
&nbsp;                context.victual.reqtime);
&nbsp;    piece-&gt;owt = weight(piece);
&nbsp;    debugpline1("New weight = %d", piece-&gt;owt);
&nbsp;}
&nbsp;
reset_eat
&nbsp;/* called when eating interrupted by an event */
&nbsp;void
&nbsp;reset_eat()
&nbsp;{
&nbsp;    /* we only set a flag here - the actual reset process is done after
&nbsp;     * the round is spent eating.
&nbsp;     */
&nbsp;    if (context.victual.eating &amp;&amp; !context.victual.doreset) {
&nbsp;        debugpline0("reset_eat...");
&nbsp;        context.victual.doreset = TRUE;
&nbsp;    }
&nbsp;    return;
&nbsp;}
&nbsp;
obj_nutrition
&nbsp;/* base nutrition of a food-class object */
&nbsp;STATIC_OVL unsigned
&nbsp;obj_nutrition(otmp)
&nbsp;struct obj *otmp;
&nbsp;{
&nbsp;    unsigned nut = (otmp-&gt;otyp == CORPSE) ? mons[otmp-&gt;corpsenm].cnutrit
&nbsp;                      : otmp-&gt;globby ? otmp-&gt;owt
&nbsp;                         : (unsigned) objects[otmp-&gt;otyp].oc_nutrition;
&nbsp;
&nbsp;    if (otmp-&gt;otyp == LEMBAS_WAFER) {
&nbsp;        if (maybe_polyd(is_elf(youmonst.data), Race_if(PM_ELF)))
&nbsp;            nut += nut / 4; /* 800 -&gt; 1000 */
&nbsp;        else if (maybe_polyd(is_orc(youmonst.data), Race_if(PM_ORC)))
&nbsp;            nut -= nut / 4; /* 800 -&gt; 600 */
&nbsp;        /* prevent polymorph making a partly eaten wafer
&nbsp;           become more nutritious than an untouched one */
&nbsp;        if (otmp-&gt;oeaten &gt;= nut)
&nbsp;            otmp-&gt;oeaten = (otmp-&gt;oeaten &lt; objects[LEMBAS_WAFER].oc_nutrition)
&nbsp;                              ? (nut - 1) : nut;
&nbsp;    } else if (otmp-&gt;otyp == CRAM_RATION) {
&nbsp;        if (maybe_polyd(is_dwarf(youmonst.data), Race_if(PM_DWARF)))
&nbsp;            nut += nut / 6; /* 600 -&gt; 700 */
&nbsp;    }
&nbsp;    return nut;
&nbsp;}
&nbsp;
touchfood
&nbsp;STATIC_OVL struct obj *
&nbsp;touchfood(otmp)
&nbsp;struct obj *otmp;
&nbsp;{
&nbsp;    if (otmp-&gt;quan &gt; 1L) {
&nbsp;        if (!carried(otmp))
&nbsp;            (void) splitobj(otmp, otmp-&gt;quan - 1L);
&nbsp;        else
&nbsp;            otmp = splitobj(otmp, 1L);
&nbsp;        debugpline0("split object,");
&nbsp;    }
&nbsp;
&nbsp;    if (!otmp-&gt;oeaten) {
&nbsp;        costly_alteration(otmp, COST_BITE);
&nbsp;        otmp-&gt;oeaten = obj_nutrition(otmp);
&nbsp;    }
&nbsp;
&nbsp;    if (carried(otmp)) {
&nbsp;        freeinv(otmp);
&nbsp;        if (inv_cnt(FALSE) &gt;= 52) {
&nbsp;            sellobj_state(SELL_DONTSELL);
&nbsp;            dropy(otmp);
&nbsp;            sellobj_state(SELL_NORMAL);
&nbsp;        } else {
&nbsp;            otmp-&gt;nomerge = 1; /* used to prevent merge */
&nbsp;            otmp = addinv(otmp);
&nbsp;            otmp-&gt;nomerge = 0;
&nbsp;        }
&nbsp;    }
&nbsp;    return otmp;
&nbsp;}
&nbsp;
food_disappears
&nbsp;/* When food decays, in the middle of your meal, we don't want to dereference
&nbsp; * any dangling pointers, so set it to null (which should still trigger
&nbsp; * do_reset_eat() at the beginning of eatfood()) and check for null pointers
&nbsp; * in do_reset_eat().
&nbsp; */
&nbsp;void
&nbsp;food_disappears(obj)
&nbsp;struct obj *obj;
&nbsp;{
&nbsp;    if (obj == context.victual.piece) {
&nbsp;        context.victual.piece = (struct obj *) 0;
&nbsp;        context.victual.o_id = 0;
&nbsp;    }
&nbsp;    if (obj-&gt;timed)
&nbsp;        obj_stop_timers(obj);
&nbsp;}
&nbsp;
food_substitution
&nbsp;/* renaming an object used to result in it having a different address,
&nbsp;   so the sequence start eating/opening, get interrupted, name the food,
&nbsp;   resume eating/opening would restart from scratch */
&nbsp;void
&nbsp;food_substitution(old_obj, new_obj)
&nbsp;struct obj *old_obj, *new_obj;
&nbsp;{
&nbsp;    if (old_obj == context.victual.piece) {
&nbsp;        context.victual.piece = new_obj;
&nbsp;        context.victual.o_id = new_obj-&gt;o_id;
&nbsp;    }
&nbsp;    if (old_obj == context.tin.tin) {
&nbsp;        context.tin.tin = new_obj;
&nbsp;        context.tin.o_id = new_obj-&gt;o_id;
&nbsp;    }
&nbsp;}
&nbsp;
do_reset_eat
&nbsp;STATIC_OVL void
&nbsp;do_reset_eat()
&nbsp;{
&nbsp;    debugpline0("do_reset_eat...");
&nbsp;    if (context.victual.piece) {
&nbsp;        context.victual.o_id = 0;
&nbsp;        context.victual.piece = touchfood(context.victual.piece);
&nbsp;        if (context.victual.piece)
&nbsp;            context.victual.o_id = context.victual.piece-&gt;o_id;
&nbsp;        recalc_wt();
&nbsp;    }
&nbsp;    context.victual.fullwarn = context.victual.eating =
&nbsp;        context.victual.doreset = FALSE;
&nbsp;    /* Do not set canchoke to FALSE; if we continue eating the same object
&nbsp;     * we need to know if canchoke was set when they started eating it the
&nbsp;     * previous time.  And if we don't continue eating the same object
&nbsp;     * canchoke always gets recalculated anyway.
&nbsp;     */
&nbsp;    stop_occupation();
&nbsp;    newuhs(FALSE);
&nbsp;}
&nbsp;
eatfood
&nbsp;/* called each move during eating process */
&nbsp;STATIC_PTR int
&nbsp;eatfood(VOID_ARGS)
&nbsp;{
&nbsp;    if (!context.victual.piece
&nbsp;        || (!carried(context.victual.piece)
&nbsp;            &amp;&amp; !obj_here(context.victual.piece, u.ux, u.uy))) {
&nbsp;        /* maybe it was stolen? */
&nbsp;        do_reset_eat();
&nbsp;        return 0;
&nbsp;    }
&nbsp;    if (!context.victual.eating)
&nbsp;        return 0;
&nbsp;
&nbsp;    if (++context.victual.usedtime &lt;= context.victual.reqtime) {
&nbsp;        if (bite())
&nbsp;            return 0;
&nbsp;        return 1; /* still busy */
&nbsp;    } else {        /* done */
&nbsp;        done_eating(TRUE);
&nbsp;        return 0;
&nbsp;    }
&nbsp;}
&nbsp;
done_eating
&nbsp;STATIC_OVL void
&nbsp;done_eating(message)
&nbsp;boolean message;
&nbsp;{
&nbsp;    struct obj *piece = context.victual.piece;
&nbsp;
&nbsp;    piece-&gt;in_use = TRUE;
&nbsp;    occupation = 0; /* do this early, so newuhs() knows we're done */
&nbsp;    newuhs(FALSE);
&nbsp;    if (nomovemsg) {
&nbsp;        if (message)
&nbsp;            pline1(nomovemsg);
&nbsp;        nomovemsg = 0;
&nbsp;    } else if (message)
&nbsp;        You("finish eating %s.", food_xname(piece, TRUE));
&nbsp;
&nbsp;    if (piece-&gt;otyp == CORPSE || piece-&gt;globby)
&nbsp;        cpostfx(piece-&gt;corpsenm);
&nbsp;    else
&nbsp;        fpostfx(piece);
&nbsp;
&nbsp;    if (carried(piece))
&nbsp;        useup(piece);
&nbsp;    else
&nbsp;        useupf(piece, 1L);
&nbsp;    context.victual.piece = (struct obj *) 0;
&nbsp;    context.victual.o_id = 0;
&nbsp;    context.victual.fullwarn = context.victual.eating =
&nbsp;        context.victual.doreset = FALSE;
&nbsp;}
&nbsp;
eating_conducts
&nbsp;void
&nbsp;eating_conducts(pd)
&nbsp;struct permonst *pd;
&nbsp;{
&nbsp;    u.uconduct.food++;
&nbsp;    if (!vegan(pd))
&nbsp;        u.uconduct.unvegan++;
&nbsp;    if (!vegetarian(pd))
&nbsp;        violated_vegetarian();
&nbsp;}
&nbsp;
eat_brains
&nbsp;/* handle side-effects of mind flayer's tentacle attack */
&nbsp;int
&nbsp;eat_brains(magr, mdef, visflag, dmg_p)
&nbsp;struct monst *magr, *mdef;
&nbsp;boolean visflag;
&nbsp;int *dmg_p; /* for dishing out extra damage in lieu of Int loss */
&nbsp;{
&nbsp;    struct permonst *pd = mdef-&gt;data;
&nbsp;    boolean give_nutrit = FALSE;
&nbsp;    int result = MM_HIT, xtra_dmg = rnd(10);
&nbsp;
&nbsp;    if (noncorporeal(pd)) {
&nbsp;        if (visflag)
&nbsp;            pline("%s brain is unharmed.",
&nbsp;                  (mdef == &amp;youmonst) ? "Your" : s_suffix(Monnam(mdef)));
&nbsp;        return MM_MISS; /* side-effects can't occur */
&nbsp;    } else if (magr == &amp;youmonst) {
&nbsp;        You("eat %s brain!", s_suffix(mon_nam(mdef)));
&nbsp;    } else if (mdef == &amp;youmonst) {
&nbsp;        Your("brain is eaten!");
&nbsp;    } else { /* monster against monster */
&nbsp;        if (visflag &amp;&amp; canspotmon(mdef))
&nbsp;            pline("%s brain is eaten!", s_suffix(Monnam(mdef)));
&nbsp;    }
&nbsp;
&nbsp;    if (flesh_petrifies(pd)) {
&nbsp;        /* mind flayer has attempted to eat the brains of a petrification
&nbsp;           inducing critter (most likely Medusa; attacking a cockatrice via
&nbsp;           tentacle-touch should have been caught before reaching this far) */
&nbsp;        if (magr == &amp;youmonst) {
&nbsp;            if (!Stone_resistance &amp;&amp; !Stoned)
&nbsp;                make_stoned(5L, (char *) 0, KILLED_BY_AN, pd-&gt;mname);
&nbsp;        } else {
&nbsp;            /* no need to check for poly_when_stoned or Stone_resistance;
&nbsp;               mind flayers don't have those capabilities */
&nbsp;            if (visflag &amp;&amp; canseemon(magr))
&nbsp;                pline("%s turns to stone!", Monnam(magr));
&nbsp;            monstone(magr);
&nbsp;            if (magr-&gt;mhp &gt; 0) {
&nbsp;                /* life-saved; don't continue eating the brains */
&nbsp;                return MM_MISS;
&nbsp;            } else {
&nbsp;                if (magr-&gt;mtame &amp;&amp; !visflag)
&nbsp;                    /* parallels mhitm.c's brief_feeling */
&nbsp;                    You("have a sad thought for a moment, then it passes.");
&nbsp;                return MM_AGR_DIED;
&nbsp;            }
&nbsp;        }
&nbsp;    }
&nbsp;
&nbsp;    if (magr == &amp;youmonst) {
&nbsp;        /*
&nbsp;         * player mind flayer is eating something's brain
&nbsp;         */
&nbsp;        eating_conducts(pd);
&nbsp;        if (mindless(pd)) { /* (cannibalism not possible here) */
&nbsp;            pline("%s doesn't notice.", Monnam(mdef));
&nbsp;            /* all done; no extra harm inflicted upon target */
&nbsp;            return MM_MISS;
&nbsp;        } else if (is_rider(pd)) {
&nbsp;            pline("Ingesting that is fatal.");
&nbsp;            Sprintf(killer.name, "unwisely ate the brain of %s", pd-&gt;mname);
&nbsp;            killer.format = NO_KILLER_PREFIX;
&nbsp;            done(DIED);
&nbsp;            /* life-saving needed to reach here */
&nbsp;            exercise(A_WIS, FALSE);
&nbsp;            *dmg_p += xtra_dmg; /* Rider takes extra damage */
&nbsp;        } else {
&nbsp;            morehungry(-rnd(30)); /* cannot choke */
&nbsp;            if (ABASE(A_INT) &lt; AMAX(A_INT)) {
&nbsp;                /* recover lost Int; won't increase current max */
&nbsp;                ABASE(A_INT) += rnd(4);
&nbsp;                if (ABASE(A_INT) &gt; AMAX(A_INT))
&nbsp;                    ABASE(A_INT) = AMAX(A_INT);
&nbsp;                context.botl = 1;
&nbsp;            }
&nbsp;            exercise(A_WIS, TRUE);
&nbsp;            *dmg_p += xtra_dmg;
&nbsp;        }
&nbsp;        /* targetting another mind flayer or your own underlying species
&nbsp;           is cannibalism */
&nbsp;        (void) maybe_cannibal(monsndx(pd), TRUE);
&nbsp;
&nbsp;    } else if (mdef == &amp;youmonst) {
&nbsp;        /*
&nbsp;         * monster mind flayer is eating hero's brain
&nbsp;         */
&nbsp;        /* no such thing as mindless players */
&nbsp;        if (ABASE(A_INT) &lt;= ATTRMIN(A_INT)) {
&nbsp;            static NEARDATA const char brainlessness[] = "brainlessness";
&nbsp;
&nbsp;            if (Lifesaved) {
&nbsp;                Strcpy(killer.name, brainlessness);
&nbsp;                killer.format = KILLED_BY;
&nbsp;                done(DIED);
&nbsp;                /* amulet of life saving has now been used up */
&nbsp;                pline("Unfortunately your brain is still gone.");
&nbsp;                /* sanity check against adding other forms of life-saving */
&nbsp;                u.uprops[LIFESAVED].extrinsic =
&nbsp;                    u.uprops[LIFESAVED].intrinsic = 0L;
&nbsp;            } else {
&nbsp;                Your("last thought fades away.");
&nbsp;            }
&nbsp;            Strcpy(killer.name, brainlessness);
&nbsp;            killer.format = KILLED_BY;
&nbsp;            done(DIED);
&nbsp;            /* can only get here when in wizard or explore mode and user has
&nbsp;               explicitly chosen not to die; arbitrarily boost intelligence */
&nbsp;            ABASE(A_INT) = ATTRMIN(A_INT) + 2;
&nbsp;            You_feel("like a scarecrow.");
&nbsp;        }
&nbsp;        give_nutrit = TRUE; /* in case a conflicted pet is doing this */
&nbsp;        exercise(A_WIS, FALSE);
&nbsp;        /* caller handles Int and memory loss */
&nbsp;
&nbsp;    } else { /* mhitm */
&nbsp;        /*
&nbsp;         * monster mind flayer is eating another monster's brain
&nbsp;         */
&nbsp;        if (mindless(pd)) {
&nbsp;            if (visflag &amp;&amp; canspotmon(mdef))
&nbsp;                pline("%s doesn't notice.", Monnam(mdef));
&nbsp;            return MM_MISS;
&nbsp;        } else if (is_rider(pd)) {
&nbsp;            mondied(magr);
&nbsp;            if (magr-&gt;mhp &lt;= 0)
&nbsp;                result = MM_AGR_DIED;
&nbsp;            /* Rider takes extra damage regardless of whether attacker dies */
&nbsp;            *dmg_p += xtra_dmg;
&nbsp;        } else {
&nbsp;            *dmg_p += xtra_dmg;
&nbsp;            give_nutrit = TRUE;
&nbsp;            if (*dmg_p &gt;= mdef-&gt;mhp &amp;&amp; visflag &amp;&amp; canspotmon(mdef))
&nbsp;                pline("%s last thought fades away...",
&nbsp;                      s_suffix(Monnam(mdef)));
&nbsp;        }
&nbsp;    }
&nbsp;
&nbsp;    if (give_nutrit &amp;&amp; magr-&gt;mtame &amp;&amp; !magr-&gt;isminion) {
&nbsp;        EDOG(magr)-&gt;hungrytime += rnd(60);
&nbsp;        magr-&gt;mconf = 0;
&nbsp;    }
&nbsp;
&nbsp;    return result;
&nbsp;}
&nbsp;
maybe_cannibal
&nbsp;/* eating a corpse or egg of one's own species is usually naughty */
&nbsp;STATIC_OVL boolean
&nbsp;maybe_cannibal(pm, allowmsg)
&nbsp;int pm;
&nbsp;boolean allowmsg;
&nbsp;{
&nbsp;    static NEARDATA long ate_brains = 0L;
&nbsp;    struct permonst *fptr = &amp;mons[pm]; /* food type */
&nbsp;
&nbsp;    /* when poly'd into a mind flayer, multiple tentacle hits in one
&nbsp;       turn cause multiple digestion checks to occur; avoid giving
&nbsp;       multiple luck penalties for the same attack */
&nbsp;    if (moves == ate_brains)
&nbsp;        return FALSE;
&nbsp;    ate_brains = moves; /* ate_anything, not just brains... */
&nbsp;
&nbsp;    if (!CANNIBAL_ALLOWED()
&nbsp;        /* non-cannibalistic heroes shouldn't eat own species ever
&nbsp;           and also shouldn't eat current species when polymorphed
&nbsp;           (even if having the form of something which doesn't care
&nbsp;           about cannibalism--hero's innate traits aren't altered) */
&nbsp;        &amp;&amp; (your_race(fptr)
&nbsp;            || (Upolyd &amp;&amp; same_race(youmonst.data, fptr))
&nbsp;            || (u.ulycn &gt;= LOW_PM &amp;&amp; were_beastie(pm) == u.ulycn))) {
&nbsp;        if (allowmsg) {
&nbsp;            if (Upolyd &amp;&amp; your_race(fptr))
&nbsp;                You("have a bad feeling deep inside.");
&nbsp;            You("cannibal!  You will regret this!");
&nbsp;        }
&nbsp;        HAggravate_monster |= FROMOUTSIDE;
&nbsp;        change_luck(-rn1(4, 2)); /* -5..-2 */
&nbsp;        return TRUE;
&nbsp;    }
&nbsp;    return FALSE;
&nbsp;}
&nbsp;
cprefx
&nbsp;STATIC_OVL void
&nbsp;cprefx(pm)
&nbsp;register int pm;
&nbsp;{
&nbsp;    (void) maybe_cannibal(pm, TRUE);
&nbsp;    if (flesh_petrifies(&amp;mons[pm])) {
&nbsp;        if (!Stone_resistance
&nbsp;            &amp;&amp; !(poly_when_stoned(youmonst.data)
&nbsp;                 &amp;&amp; polymon(PM_STONE_GOLEM))) {
&nbsp;            Sprintf(killer.name, "tasting %s meat", mons[pm].mname);
&nbsp;            killer.format = KILLED_BY;
&nbsp;            You("turn to stone.");
&nbsp;            done(STONING);
&nbsp;            if (context.victual.piece)
&nbsp;                context.victual.eating = FALSE;
&nbsp;            return; /* lifesaved */
&nbsp;        }
&nbsp;    }
&nbsp;
&nbsp;    switch (pm) {
&nbsp;    case PM_LITTLE_DOG:
&nbsp;    case PM_DOG:
&nbsp;    case PM_LARGE_DOG:
&nbsp;    case PM_KITTEN:
&nbsp;    case PM_HOUSECAT:
&nbsp;    case PM_LARGE_CAT:
&nbsp;        /* cannibals are allowed to eat domestic animals without penalty */
&nbsp;        if (!CANNIBAL_ALLOWED()) {
&nbsp;            You_feel("that eating the %s was a bad idea.", mons[pm].mname);
&nbsp;            HAggravate_monster |= FROMOUTSIDE;
&nbsp;        }
&nbsp;        break;
&nbsp;    case PM_LIZARD:
&nbsp;        if (Stoned)
&nbsp;            fix_petrification();
&nbsp;        break;
&nbsp;    case PM_DEATH:
&nbsp;    case PM_PESTILENCE:
&nbsp;    case PM_FAMINE: {
&nbsp;        pline("Eating that is instantly fatal.");
&nbsp;        Sprintf(killer.name, "unwisely ate the body of %s", mons[pm].mname);
&nbsp;        killer.format = NO_KILLER_PREFIX;
&nbsp;        done(DIED);
&nbsp;        /* life-saving needed to reach here */
&nbsp;        exercise(A_WIS, FALSE);
&nbsp;        /* It so happens that since we know these monsters */
&nbsp;        /* cannot appear in tins, context.victual.piece will always */
&nbsp;        /* be what we want, which is not generally true. */
&nbsp;        if (revive_corpse(context.victual.piece)) {
&nbsp;            context.victual.piece = (struct obj *) 0;
&nbsp;            context.victual.o_id = 0;
&nbsp;        }
&nbsp;        return;
&nbsp;    }
&nbsp;    case PM_GREEN_SLIME:
&nbsp;        if (!Slimed &amp;&amp; !Unchanging &amp;&amp; !slimeproof(youmonst.data)) {
&nbsp;            You("don't feel very well.");
&nbsp;            make_slimed(10L, (char *) 0);
&nbsp;            delayed_killer(SLIMED, KILLED_BY_AN, "");
&nbsp;        }
&nbsp;    /* Fall through */
&nbsp;    default:
&nbsp;        if (acidic(&amp;mons[pm]) &amp;&amp; Stoned)
&nbsp;            fix_petrification();
&nbsp;        break;
&nbsp;    }
&nbsp;}
&nbsp;
fix_petrification
&nbsp;void
&nbsp;fix_petrification()
&nbsp;{
&nbsp;    char buf[BUFSZ];
&nbsp;
&nbsp;    if (Hallucination)
&nbsp;        Sprintf(buf, "What a pity--you just ruined a future piece of %sart!",
&nbsp;                ACURR(A_CHA) &gt; 15 ? "fine " : "");
&nbsp;    else
&nbsp;        Strcpy(buf, "You feel limber!");
&nbsp;    make_stoned(0L, buf, 0, (char *) 0);
&nbsp;}
&nbsp;
&nbsp;/*
&nbsp; * If you add an intrinsic that can be gotten by eating a monster, add it
&nbsp; * to intrinsic_possible() and givit().  (It must already be in prop.h to
&nbsp; * be an intrinsic property.)
&nbsp; * It would be very easy to make the intrinsics not try to give you one
&nbsp; * that you already had by checking to see if you have it in
&nbsp; * intrinsic_possible() instead of givit(), but we're not that nice.
&nbsp; */
&nbsp;
intrinsic_possible
&nbsp;/* intrinsic_possible() returns TRUE iff a monster can give an intrinsic. */
&nbsp;STATIC_OVL int
&nbsp;intrinsic_possible(type, ptr)
&nbsp;int type;
&nbsp;register struct permonst *ptr;
&nbsp;{
&nbsp;    int res = 0;
&nbsp;
&nbsp;#ifdef DEBUG
&nbsp;#define ifdebugresist(Msg)      \
&nbsp;    do {                        \
&nbsp;        if (res)                \
&nbsp;            debugpline0(Msg);   \
&nbsp;    } while (0)
&nbsp;#else
&nbsp;#define ifdebugresist(Msg) /*empty*/
&nbsp;#endif
&nbsp;    switch (type) {
&nbsp;    case FIRE_RES:
&nbsp;        res = (ptr-&gt;mconveys &amp; MR_FIRE) != 0;
&nbsp;        ifdebugresist("can get fire resistance");
&nbsp;        break;
&nbsp;    case SLEEP_RES:
&nbsp;        res = (ptr-&gt;mconveys &amp; MR_SLEEP) != 0;
&nbsp;        ifdebugresist("can get sleep resistance");
&nbsp;        break;
&nbsp;    case COLD_RES:
&nbsp;        res = (ptr-&gt;mconveys &amp; MR_COLD) != 0;
&nbsp;        ifdebugresist("can get cold resistance");
&nbsp;        break;
&nbsp;    case DISINT_RES:
&nbsp;        res = (ptr-&gt;mconveys &amp; MR_DISINT) != 0;
&nbsp;        ifdebugresist("can get disintegration resistance");
&nbsp;        break;
&nbsp;    case SHOCK_RES: /* shock (electricity) resistance */
&nbsp;        res = (ptr-&gt;mconveys &amp; MR_ELEC) != 0;
&nbsp;        ifdebugresist("can get shock resistance");
&nbsp;        break;
&nbsp;    case POISON_RES:
&nbsp;        res = (ptr-&gt;mconveys &amp; MR_POISON) != 0;
&nbsp;        ifdebugresist("can get poison resistance");
&nbsp;        break;
&nbsp;    case TELEPORT:
&nbsp;        res = can_teleport(ptr);
&nbsp;        ifdebugresist("can get teleport");
&nbsp;        break;
&nbsp;    case TELEPORT_CONTROL:
&nbsp;        res = control_teleport(ptr);
&nbsp;        ifdebugresist("can get teleport control");
&nbsp;        break;
&nbsp;    case TELEPAT:
&nbsp;        res = telepathic(ptr);
&nbsp;        ifdebugresist("can get telepathy");
&nbsp;        break;
&nbsp;    default:
&nbsp;        /* res stays 0 */
&nbsp;        break;
&nbsp;    }
&nbsp;#undef ifdebugresist
&nbsp;    return res;
&nbsp;}
&nbsp;
givit
&nbsp;/* givit() tries to give you an intrinsic based on the monster's level
&nbsp; * and what type of intrinsic it is trying to give you.
&nbsp; */
&nbsp;STATIC_OVL void
&nbsp;givit(type, ptr)
&nbsp;int type;
&nbsp;register struct permonst *ptr;
&nbsp;{
&nbsp;    register int chance;
&nbsp;
&nbsp;    debugpline1("Attempting to give intrinsic %d", type);
&nbsp;    /* some intrinsics are easier to get than others */
&nbsp;    switch (type) {
&nbsp;    case POISON_RES:
&nbsp;        if ((ptr == &amp;mons[PM_KILLER_BEE] || ptr == &amp;mons[PM_SCORPION])
&nbsp;            &amp;&amp; !rn2(4))
&nbsp;            chance = 1;
&nbsp;        else
&nbsp;            chance = 15;
&nbsp;        break;
&nbsp;    case TELEPORT:
&nbsp;        chance = 10;
&nbsp;        break;
&nbsp;    case TELEPORT_CONTROL:
&nbsp;        chance = 12;
&nbsp;        break;
&nbsp;    case TELEPAT:
&nbsp;        chance = 1;
&nbsp;        break;
&nbsp;    default:
&nbsp;        chance = 15;
&nbsp;        break;
&nbsp;    }
&nbsp;
&nbsp;    if (ptr-&gt;mlevel &lt;= rn2(chance))
&nbsp;        return; /* failed die roll */
&nbsp;
&nbsp;    switch (type) {
&nbsp;    case FIRE_RES:
&nbsp;        debugpline0("Trying to give fire resistance");
&nbsp;        if (!(HFire_resistance &amp; FROMOUTSIDE)) {
&nbsp;            You(Hallucination ? "be chillin'." : "feel a momentary chill.");
&nbsp;            HFire_resistance |= FROMOUTSIDE;
&nbsp;        }
&nbsp;        break;
&nbsp;    case SLEEP_RES:
&nbsp;        debugpline0("Trying to give sleep resistance");
&nbsp;        if (!(HSleep_resistance &amp; FROMOUTSIDE)) {
&nbsp;            You_feel("wide awake.");
&nbsp;            HSleep_resistance |= FROMOUTSIDE;
&nbsp;        }
&nbsp;        break;
&nbsp;    case COLD_RES:
&nbsp;        debugpline0("Trying to give cold resistance");
&nbsp;        if (!(HCold_resistance &amp; FROMOUTSIDE)) {
&nbsp;            You_feel("full of hot air.");
&nbsp;            HCold_resistance |= FROMOUTSIDE;
&nbsp;        }
&nbsp;        break;
&nbsp;    case DISINT_RES:
&nbsp;        debugpline0("Trying to give disintegration resistance");
&nbsp;        if (!(HDisint_resistance &amp; FROMOUTSIDE)) {
&nbsp;            You_feel(Hallucination ? "totally together, man." : "very firm.");
&nbsp;            HDisint_resistance |= FROMOUTSIDE;
&nbsp;        }
&nbsp;        break;
&nbsp;    case SHOCK_RES: /* shock (electricity) resistance */
&nbsp;        debugpline0("Trying to give shock resistance");
&nbsp;        if (!(HShock_resistance &amp; FROMOUTSIDE)) {
&nbsp;            if (Hallucination)
&nbsp;                You_feel("grounded in reality.");
&nbsp;            else
&nbsp;                Your("health currently feels amplified!");
&nbsp;            HShock_resistance |= FROMOUTSIDE;
&nbsp;        }
&nbsp;        break;
&nbsp;    case POISON_RES:
&nbsp;        debugpline0("Trying to give poison resistance");
&nbsp;        if (!(HPoison_resistance &amp; FROMOUTSIDE)) {
&nbsp;            You_feel(Poison_resistance ? "especially healthy." : "healthy.");
&nbsp;            HPoison_resistance |= FROMOUTSIDE;
&nbsp;        }
&nbsp;        break;
&nbsp;    case TELEPORT:
&nbsp;        debugpline0("Trying to give teleport");
&nbsp;        if (!(HTeleportation &amp; FROMOUTSIDE)) {
&nbsp;            You_feel(Hallucination ? "diffuse." : "very jumpy.");
&nbsp;            HTeleportation |= FROMOUTSIDE;
&nbsp;        }
&nbsp;        break;
&nbsp;    case TELEPORT_CONTROL:
&nbsp;        debugpline0("Trying to give teleport control");
&nbsp;        if (!(HTeleport_control &amp; FROMOUTSIDE)) {
&nbsp;            You_feel(Hallucination ? "centered in your personal space."
&nbsp;                                   : "in control of yourself.");
&nbsp;            HTeleport_control |= FROMOUTSIDE;
&nbsp;        }
&nbsp;        break;
&nbsp;    case TELEPAT:
&nbsp;        debugpline0("Trying to give telepathy");
&nbsp;        if (!(HTelepat &amp; FROMOUTSIDE)) {
&nbsp;            You_feel(Hallucination ? "in touch with the cosmos."
&nbsp;                                   : "a strange mental acuity.");
&nbsp;            HTelepat |= FROMOUTSIDE;
&nbsp;            /* If blind, make sure monsters show up. */
&nbsp;            if (Blind)
&nbsp;                see_monsters();
&nbsp;        }
&nbsp;        break;
&nbsp;    default:
&nbsp;        debugpline0("Tried to give an impossible intrinsic");
&nbsp;        break;
&nbsp;    }
&nbsp;}
&nbsp;
cpostfx
&nbsp;/* called after completely consuming a corpse */
&nbsp;STATIC_OVL void
&nbsp;cpostfx(pm)
&nbsp;register int pm;
&nbsp;{
&nbsp;    register int tmp = 0;
&nbsp;    int catch_lycanthropy = NON_PM;
&nbsp;
&nbsp;    /* in case `afternmv' didn't get called for previously mimicking
&nbsp;       gold, clean up now to avoid `eatmbuf' memory leak */
&nbsp;    if (eatmbuf)
&nbsp;        (void) eatmdone();
&nbsp;
&nbsp;    switch (pm) {
&nbsp;    case PM_NEWT:
&nbsp;        /* MRKR: "eye of newt" may give small magical energy boost */
&nbsp;        if (rn2(3) || 3 * u.uen &lt;= 2 * u.uenmax) {
&nbsp;            int old_uen = u.uen;
&nbsp;            u.uen += rnd(3);
&nbsp;            if (u.uen &gt; u.uenmax) {
&nbsp;                if (!rn2(3))
&nbsp;                    u.uenmax++;
&nbsp;                u.uen = u.uenmax;
&nbsp;            }
&nbsp;            if (old_uen != u.uen) {
&nbsp;                You_feel("a mild buzz.");
&nbsp;                context.botl = 1;
&nbsp;            }
&nbsp;        }
&nbsp;        break;
&nbsp;    case PM_WRAITH:
&nbsp;        pluslvl(FALSE);
&nbsp;        break;
&nbsp;    case PM_HUMAN_WERERAT:
&nbsp;        catch_lycanthropy = PM_WERERAT;
&nbsp;        break;
&nbsp;    case PM_HUMAN_WEREJACKAL:
&nbsp;        catch_lycanthropy = PM_WEREJACKAL;
&nbsp;        break;
&nbsp;    case PM_HUMAN_WEREWOLF:
&nbsp;        catch_lycanthropy = PM_WEREWOLF;
&nbsp;        break;
&nbsp;    case PM_NURSE:
&nbsp;        if (Upolyd)
&nbsp;            u.mh = u.mhmax;
&nbsp;        else
&nbsp;            u.uhp = u.uhpmax;
&nbsp;        make_blinded(0L, !u.ucreamed);
&nbsp;        context.botl = 1;
&nbsp;        break;
&nbsp;    case PM_STALKER:
&nbsp;        if (!Invis) {
&nbsp;            set_itimeout(&amp;HInvis, (long) rn1(100, 50));
&nbsp;            if (!Blind &amp;&amp; !BInvis)
&nbsp;                self_invis_message();
&nbsp;        } else {
&nbsp;            if (!(HInvis &amp; INTRINSIC))
&nbsp;                You_feel("hidden!");
&nbsp;            HInvis |= FROMOUTSIDE;
&nbsp;            HSee_invisible |= FROMOUTSIDE;
&nbsp;        }
&nbsp;        newsym(u.ux, u.uy);
&nbsp;        /*FALLTHRU*/
&nbsp;    case PM_YELLOW_LIGHT:
&nbsp;    case PM_GIANT_BAT:
&nbsp;        make_stunned((HStun &amp; TIMEOUT) + 30L, FALSE);
&nbsp;        /*FALLTHRU*/
&nbsp;    case PM_BAT:
&nbsp;        make_stunned((HStun &amp; TIMEOUT) + 30L, FALSE);
&nbsp;        break;
&nbsp;    case PM_GIANT_MIMIC:
&nbsp;        tmp += 10;
&nbsp;        /*FALLTHRU*/
&nbsp;    case PM_LARGE_MIMIC:
&nbsp;        tmp += 20;
&nbsp;        /*FALLTHRU*/
&nbsp;    case PM_SMALL_MIMIC:
&nbsp;        tmp += 20;
&nbsp;        if (youmonst.data-&gt;mlet != S_MIMIC &amp;&amp; !Unchanging) {
&nbsp;            char buf[BUFSZ];
&nbsp;
&nbsp;            u.uconduct.polyselfs++; /* you're changing form */
&nbsp;            You_cant("resist the temptation to mimic %s.",
&nbsp;                     Hallucination ? "an orange" : "a pile of gold");
&nbsp;            /* A pile of gold can't ride. */
&nbsp;            if (u.usteed)
&nbsp;                dismount_steed(DISMOUNT_FELL);
&nbsp;            nomul(-tmp);
&nbsp;            multi_reason = "pretending to be a pile of gold";
&nbsp;            Sprintf(buf,
&nbsp;                    Hallucination
&nbsp;                       ? "You suddenly dread being peeled and mimic %s again!"
&nbsp;                       : "You now prefer mimicking %s again.",
&nbsp;                    an(Upolyd ? youmonst.data-&gt;mname : urace.noun));
&nbsp;            eatmbuf = dupstr(buf);
&nbsp;            nomovemsg = eatmbuf;
&nbsp;            afternmv = eatmdone;
&nbsp;            /* ??? what if this was set before? */
&nbsp;            youmonst.m_ap_type = M_AP_OBJECT;
&nbsp;            youmonst.mappearance = Hallucination ? ORANGE : GOLD_PIECE;
&nbsp;            newsym(u.ux, u.uy);
&nbsp;            curs_on_u();
&nbsp;            /* make gold symbol show up now */
&nbsp;            display_nhwindow(WIN_MAP, TRUE);
&nbsp;        }
&nbsp;        break;
&nbsp;    case PM_QUANTUM_MECHANIC:
&nbsp;        Your("velocity suddenly seems very uncertain!");
&nbsp;        if (HFast &amp; INTRINSIC) {
&nbsp;            HFast &amp;= ~INTRINSIC;
&nbsp;            You("seem slower.");
&nbsp;        } else {
&nbsp;            HFast |= FROMOUTSIDE;
&nbsp;            You("seem faster.");
&nbsp;        }
&nbsp;        break;
&nbsp;    case PM_LIZARD:
&nbsp;        if ((HStun &amp; TIMEOUT) &gt; 2)
&nbsp;            make_stunned(2L, FALSE);
&nbsp;        if ((HConfusion &amp; TIMEOUT) &gt; 2)
&nbsp;            make_confused(2L, FALSE);
&nbsp;        break;
&nbsp;    case PM_CHAMELEON:
&nbsp;    case PM_DOPPELGANGER:
&nbsp;    case PM_SANDESTIN: /* moot--they don't leave corpses */
&nbsp;        if (Unchanging) {
&nbsp;            You_feel("momentarily different."); /* same as poly trap */
&nbsp;        } else {
&nbsp;            You_feel("a change coming over you.");
&nbsp;            polyself(0);
&nbsp;        }
&nbsp;        break;
&nbsp;    case PM_DISENCHANTER:
&nbsp;        /* picks an intrinsic at random and removes it; there's
&nbsp;           no feedback if hero already lacks the chosen ability */
&nbsp;        debugpline0("using attrcurse to strip an intrinsic");
&nbsp;        attrcurse();
&nbsp;        break;
&nbsp;    case PM_MIND_FLAYER:
&nbsp;    case PM_MASTER_MIND_FLAYER:
&nbsp;        if (ABASE(A_INT) &lt; ATTRMAX(A_INT)) {
&nbsp;            if (!rn2(2)) {
&nbsp;                pline("Yum! That was real brain food!");
&nbsp;                (void) adjattrib(A_INT, 1, FALSE);
&nbsp;                break; /* don't give them telepathy, too */
&nbsp;            }
&nbsp;        } else {
&nbsp;            pline("For some reason, that tasted bland.");
&nbsp;        }
&nbsp;    /*FALLTHRU*/
&nbsp;    default: {
&nbsp;        struct permonst *ptr = &amp;mons[pm];
&nbsp;        boolean conveys_STR = is_giant(ptr);
&nbsp;        int i, count;
&nbsp;
&nbsp;        if (dmgtype(ptr, AD_STUN) || dmgtype(ptr, AD_HALU)
&nbsp;            || pm == PM_VIOLET_FUNGUS) {
&nbsp;            pline("Oh wow!  Great stuff!");
&nbsp;            (void) make_hallucinated((HHallucination &amp; TIMEOUT) + 200L, FALSE,
&nbsp;                                     0L);
&nbsp;        }
&nbsp;
&nbsp;        /* Check the monster for all of the intrinsics.  If this
&nbsp;         * monster can give more than one, pick one to try to give
&nbsp;         * from among all it can give.
&nbsp;         *
&nbsp;         * Strength from giants is now treated like an intrinsic
&nbsp;         * rather than being given unconditionally.
&nbsp;         */
&nbsp;        count = 0; /* number of possible intrinsics */
&nbsp;        tmp = 0;   /* which one we will try to give */
&nbsp;        if (conveys_STR) {
&nbsp;            count = 1;
&nbsp;            tmp = -1; /* use -1 as fake prop index for STR */
&nbsp;            debugpline1("\"Intrinsic\" strength, %d", tmp);
&nbsp;        }
&nbsp;        for (i = 1; i &lt;= LAST_PROP; i++) {
&nbsp;            if (!intrinsic_possible(i, ptr))
&nbsp;                continue;
&nbsp;            ++count;
&nbsp;            /* a 1 in count chance of replacing the old choice
&nbsp;               with this one, and a count-1 in count chance
&nbsp;               of keeping the old choice (note that 1 in 1 and
&nbsp;               0 in 1 are what we want for the first candidate) */
&nbsp;            if (!rn2(count)) {
&nbsp;                debugpline2("Intrinsic %d replacing %d", i, tmp);
&nbsp;                tmp = i;
&nbsp;            }
&nbsp;        }
&nbsp;        /* if strength is the only candidate, give it 50% chance */
&nbsp;        if (conveys_STR &amp;&amp; count == 1 &amp;&amp; !rn2(2))
&nbsp;            tmp = 0;
&nbsp;        /* if something was chosen, give it now (givit() might fail) */
&nbsp;        if (tmp == -1)
&nbsp;            gainstr((struct obj *) 0, 0, TRUE);
&nbsp;        else if (tmp &gt; 0)
&nbsp;            givit(tmp, ptr);
&nbsp;        break;
&nbsp;    } /* default case */
&nbsp;    } /* switch */
&nbsp;
&nbsp;    if (catch_lycanthropy &gt;= LOW_PM) {
&nbsp;        set_ulycn(catch_lycanthropy);
&nbsp;        retouch_equipment(2);
&nbsp;    }
&nbsp;    return;
&nbsp;}
&nbsp;
violated_vegetarian
&nbsp;void
&nbsp;violated_vegetarian()
&nbsp;{
&nbsp;    u.uconduct.unvegetarian++;
&nbsp;    if (Role_if(PM_MONK)) {
&nbsp;        You_feel("guilty.");
&nbsp;        adjalign(-1);
&nbsp;    }
&nbsp;    return;
&nbsp;}
&nbsp;
costly_tin
&nbsp;/* common code to check and possibly charge for 1 context.tin.tin,
&nbsp; * will split() context.tin.tin if necessary */
&nbsp;STATIC_PTR struct obj *
&nbsp;costly_tin(alter_type)
&nbsp;int alter_type; /* COST_xxx */
&nbsp;{
&nbsp;    struct obj *tin = context.tin.tin;
&nbsp;
&nbsp;    if (carried(tin) ? tin-&gt;unpaid
&nbsp;                     : (costly_spot(tin-&gt;ox, tin-&gt;oy) &amp;&amp; !tin-&gt;no_charge)) {
&nbsp;        if (tin-&gt;quan &gt; 1L) {
&nbsp;            tin = context.tin.tin = splitobj(tin, 1L);
&nbsp;            context.tin.o_id = tin-&gt;o_id;
&nbsp;        }
&nbsp;        costly_alteration(tin, alter_type);
&nbsp;    }
&nbsp;    return tin;
&nbsp;}
&nbsp;
tin_variety_txt
&nbsp;int
&nbsp;tin_variety_txt(s, tinvariety)
&nbsp;char *s;
&nbsp;int *tinvariety;
&nbsp;{
&nbsp;    int k, l;
&nbsp;
&nbsp;    if (s &amp;&amp; tinvariety) {
&nbsp;        *tinvariety = -1;
&nbsp;        for (k = 0; k &lt; TTSZ - 1; ++k) {
&nbsp;            l = (int) strlen(tintxts[k].txt);
&nbsp;            if (!strncmpi(s, tintxts[k].txt, l) &amp;&amp; ((int) strlen(s) &gt; l)
&nbsp;                &amp;&amp; s[l] == ' ') {
&nbsp;                *tinvariety = k;
&nbsp;                return (l + 1);
&nbsp;            }
&nbsp;        }
&nbsp;    }
&nbsp;    return 0;
&nbsp;}
&nbsp;
tin_details
&nbsp;/*
&nbsp; * This assumes that buf already contains the word "tin",
&nbsp; * as is the case with caller xname().
&nbsp; */
&nbsp;void
&nbsp;tin_details(obj, mnum, buf)
&nbsp;struct obj *obj;
&nbsp;int mnum;
&nbsp;char *buf;
&nbsp;{
&nbsp;    char buf2[BUFSZ];
&nbsp;    int r = tin_variety(obj, TRUE);
&nbsp;
&nbsp;    if (obj &amp;&amp; buf) {
&nbsp;        if (r == SPINACH_TIN)
&nbsp;            Strcat(buf, " of spinach");
&nbsp;        else if (mnum == NON_PM)
&nbsp;            Strcpy(buf, "empty tin");
&nbsp;        else {
&nbsp;            if ((obj-&gt;cknown || iflags.override_ID) &amp;&amp; obj-&gt;spe &lt; 0) {
&nbsp;                if (r == ROTTEN_TIN || r == HOMEMADE_TIN) {
&nbsp;                    /* put these before the word tin */
&nbsp;                    Sprintf(buf2, "%s %s of ", tintxts[r].txt, buf);
&nbsp;                    Strcpy(buf, buf2);
&nbsp;                } else {
&nbsp;                    Sprintf(eos(buf), " of %s ", tintxts[r].txt);
&nbsp;                }
&nbsp;            } else {
&nbsp;                Strcpy(eos(buf), " of ");
&nbsp;            }
&nbsp;            if (vegetarian(&amp;mons[mnum]))
&nbsp;                Sprintf(eos(buf), "%s", mons[mnum].mname);
&nbsp;            else
&nbsp;                Sprintf(eos(buf), "%s meat", mons[mnum].mname);
&nbsp;        }
&nbsp;    }
&nbsp;}
&nbsp;
set_tin_variety
&nbsp;void
&nbsp;set_tin_variety(obj, forcetype)
&nbsp;struct obj *obj;
&nbsp;int forcetype;
&nbsp;{
&nbsp;    register int r;
&nbsp;
&nbsp;    if (forcetype == SPINACH_TIN
&nbsp;        || (forcetype == HEALTHY_TIN
&nbsp;            &amp;&amp; (obj-&gt;corpsenm == NON_PM /* empty or already spinach */
&nbsp;                || !vegetarian(&amp;mons[obj-&gt;corpsenm])))) { /* replace meat */
&nbsp;        obj-&gt;corpsenm = NON_PM; /* not based on any monster */
&nbsp;        obj-&gt;spe = 1;           /* spinach */
&nbsp;        return;
&nbsp;    } else if (forcetype == HEALTHY_TIN) {
&nbsp;        r = tin_variety(obj, FALSE);
&nbsp;        if (r &lt; 0 || r &gt;= TTSZ)
&nbsp;            r = ROTTEN_TIN; /* shouldn't happen */
&nbsp;        while ((r == ROTTEN_TIN &amp;&amp; !obj-&gt;cursed) || !tintxts[r].fodder)
&nbsp;            r = rn2(TTSZ - 1);
&nbsp;    } else if (forcetype &gt;= 0 &amp;&amp; forcetype &lt; TTSZ - 1) {
&nbsp;        r = forcetype;
&nbsp;    } else {               /* RANDOM_TIN */
&nbsp;        r = rn2(TTSZ - 1); /* take your pick */
&nbsp;        if (r == ROTTEN_TIN &amp;&amp; nonrotting_corpse(obj-&gt;corpsenm))
&nbsp;            r = HOMEMADE_TIN; /* lizards don't rot */
&nbsp;    }
&nbsp;    obj-&gt;spe = -(r + 1); /* offset by 1 to allow index 0 */
&nbsp;}
&nbsp;
tin_variety
&nbsp;STATIC_OVL int
&nbsp;tin_variety(obj, disp)
&nbsp;struct obj *obj;
&nbsp;boolean disp; /* we're just displaying so leave things alone */
&nbsp;{
&nbsp;    register int r;
&nbsp;
&nbsp;    if (obj-&gt;spe == 1) {
&nbsp;        r = SPINACH_TIN;
&nbsp;    } else if (obj-&gt;cursed) {
&nbsp;        r = ROTTEN_TIN; /* always rotten if cursed */
&nbsp;    } else if (obj-&gt;spe &lt; 0) {
&nbsp;        r = -(obj-&gt;spe);
&nbsp;        --r; /* get rid of the offset */
&nbsp;    } else
&nbsp;        r = rn2(TTSZ - 1);
&nbsp;
&nbsp;    if (!disp &amp;&amp; r == HOMEMADE_TIN &amp;&amp; !obj-&gt;blessed &amp;&amp; !rn2(7))
&nbsp;        r = ROTTEN_TIN; /* some homemade tins go bad */
&nbsp;
&nbsp;    if (r == ROTTEN_TIN &amp;&amp; nonrotting_corpse(obj-&gt;corpsenm))
&nbsp;        r = HOMEMADE_TIN; /* lizards don't rot */
&nbsp;    return r;
&nbsp;}
&nbsp;
consume_tin
&nbsp;STATIC_OVL void
&nbsp;consume_tin(mesg)
&nbsp;const char *mesg;
&nbsp;{
&nbsp;    const char *what;
&nbsp;    int which, mnum, r;
&nbsp;    struct obj *tin = context.tin.tin;
&nbsp;
&nbsp;    r = tin_variety(tin, FALSE);
&nbsp;    if (tin-&gt;otrapped || (tin-&gt;cursed &amp;&amp; r != HOMEMADE_TIN &amp;&amp; !rn2(8))) {
&nbsp;        b_trapped("tin", 0);
&nbsp;        tin = costly_tin(COST_DSTROY);
&nbsp;        goto use_up_tin;
&nbsp;    }
&nbsp;
&nbsp;    pline1(mesg); /* "You succeed in opening the tin." */
&nbsp;
&nbsp;    if (r != SPINACH_TIN) {
&nbsp;        mnum = tin-&gt;corpsenm;
&nbsp;        if (mnum == NON_PM) {
&nbsp;            pline("It turns out to be empty.");
&nbsp;            tin-&gt;dknown = tin-&gt;known = 1;
&nbsp;            tin = costly_tin(COST_OPEN);
&nbsp;            goto use_up_tin;
&nbsp;        }
&nbsp;
&nbsp;        which = 0; /* 0=&gt;plural, 1=&gt;as-is, 2=&gt;"the" prefix */
&nbsp;        if ((mnum == PM_COCKATRICE || mnum == PM_CHICKATRICE)
&nbsp;            &amp;&amp; (Stone_resistance || Hallucination)) {
&nbsp;            what = "chicken";
&nbsp;            which = 1; /* suppress pluralization */
&nbsp;        } else if (Hallucination) {
&nbsp;            what = rndmonnam(NULL);
&nbsp;        } else {
&nbsp;            what = mons[mnum].mname;
&nbsp;            if (the_unique_pm(&amp;mons[mnum]))
&nbsp;                which = 2;
&nbsp;            else if (type_is_pname(&amp;mons[mnum]))
&nbsp;                which = 1;
&nbsp;        }
&nbsp;        if (which == 0)
&nbsp;            what = makeplural(what);
&nbsp;        else if (which == 2)
&nbsp;            what = the(what);
&nbsp;
&nbsp;        pline("It smells like %s.", what);
&nbsp;        if (yn("Eat it?") == 'n') {
&nbsp;            if (flags.verbose)
&nbsp;                You("discard the open tin.");
&nbsp;            if (!Hallucination)
&nbsp;                tin-&gt;dknown = tin-&gt;known = 1;
&nbsp;            tin = costly_tin(COST_OPEN);
&nbsp;            goto use_up_tin;
&nbsp;        }
&nbsp;
&nbsp;        /* in case stop_occupation() was called on previous meal */
&nbsp;        context.victual.piece = (struct obj *) 0;
&nbsp;        context.victual.o_id = 0;
&nbsp;        context.victual.fullwarn = context.victual.eating =
&nbsp;            context.victual.doreset = FALSE;
&nbsp;
&nbsp;        You("consume %s %s.", tintxts[r].txt, mons[mnum].mname);
&nbsp;
&nbsp;        eating_conducts(&amp;mons[mnum]);
&nbsp;
&nbsp;        tin-&gt;dknown = tin-&gt;known = 1;
&nbsp;        cprefx(mnum);
&nbsp;        cpostfx(mnum);
&nbsp;
&nbsp;        /* charge for one at pre-eating cost */
&nbsp;        tin = costly_tin(COST_OPEN);
&nbsp;
&nbsp;        if (tintxts[r].nut &lt; 0) /* rotten */
&nbsp;            make_vomiting((long) rn1(15, 10), FALSE);
&nbsp;        else
&nbsp;            lesshungry(tintxts[r].nut);
&nbsp;
&nbsp;        if (tintxts[r].greasy) {
&nbsp;            /* Assume !Glib, because you can't open tins when Glib. */
&nbsp;            incr_itimeout(&amp;Glib, rnd(15));
&nbsp;            pline("Eating %s food made your %s very slippery.",
&nbsp;                  tintxts[r].txt, makeplural(body_part(FINGER)));
&nbsp;        }
&nbsp;
&nbsp;    } else { /* spinach... */
&nbsp;        if (tin-&gt;cursed) {
&nbsp;            pline("It contains some decaying%s%s substance.",
&nbsp;                  Blind ? "" : " ", Blind ? "" : hcolor(NH_GREEN));
&nbsp;        } else {
&nbsp;            pline("It contains spinach.");
&nbsp;            tin-&gt;dknown = tin-&gt;known = 1;
&nbsp;        }
&nbsp;
&nbsp;        if (yn("Eat it?") == 'n') {
&nbsp;            if (flags.verbose)
&nbsp;                You("discard the open tin.");
&nbsp;            tin = costly_tin(COST_OPEN);
&nbsp;            goto use_up_tin;
&nbsp;        }
&nbsp;
&nbsp;        /*
&nbsp;         * Same order as with non-spinach above:
&nbsp;         * conduct update, side-effects, shop handling, and nutrition.
&nbsp;         */
&nbsp;        u.uconduct.food++; /* don't need vegetarian checks for spinach */
&nbsp;        if (!tin-&gt;cursed)
&nbsp;            pline("This makes you feel like %s!",
&nbsp;                  Hallucination ? "Swee'pea" : "Popeye");
&nbsp;        gainstr(tin, 0, FALSE);
&nbsp;
&nbsp;        tin = costly_tin(COST_OPEN);
&nbsp;
&nbsp;        lesshungry(tin-&gt;blessed
&nbsp;                      ? 600                   /* blessed */
&nbsp;                      : !tin-&gt;cursed
&nbsp;                         ? (400 + rnd(200))   /* uncursed */
&nbsp;                         : (200 + rnd(400))); /* cursed */
&nbsp;    }
&nbsp;
&nbsp;use_up_tin:
&nbsp;    if (carried(tin))
&nbsp;        useup(tin);
&nbsp;    else
&nbsp;        useupf(tin, 1L);
&nbsp;    context.tin.tin = (struct obj *) 0;
&nbsp;    context.tin.o_id = 0;
&nbsp;}
&nbsp;
opentin
&nbsp;/* called during each move whilst opening a tin */
&nbsp;STATIC_PTR int
&nbsp;opentin(VOID_ARGS)
&nbsp;{
&nbsp;    /* perhaps it was stolen (although that should cause interruption) */
&nbsp;    if (!carried(context.tin.tin)
&nbsp;        &amp;&amp; (!obj_here(context.tin.tin, u.ux, u.uy) || !can_reach_floor(TRUE)))
&nbsp;        return 0; /* %% probably we should use tinoid */
&nbsp;    if (context.tin.usedtime++ &gt;= 50) {
&nbsp;        You("give up your attempt to open the tin.");
&nbsp;        return 0;
&nbsp;    }
&nbsp;    if (context.tin.usedtime &lt; context.tin.reqtime)
&nbsp;        return 1; /* still busy */
&nbsp;
&nbsp;    consume_tin("You succeed in opening the tin.");
&nbsp;    return 0;
&nbsp;}
&nbsp;
start_tin
&nbsp;/* called when starting to open a tin */
&nbsp;STATIC_OVL void
&nbsp;start_tin(otmp)
&nbsp;struct obj *otmp;
&nbsp;{
&nbsp;    const char *mesg = 0;
&nbsp;    register int tmp;
&nbsp;
&nbsp;    if (metallivorous(youmonst.data)) {
&nbsp;        mesg = "You bite right into the metal tin...";
&nbsp;        tmp = 0;
&nbsp;    } else if (cantwield(youmonst.data)) { /* nohands || verysmall */
&nbsp;        You("cannot handle the tin properly to open it.");
&nbsp;        return;
&nbsp;    } else if (otmp-&gt;blessed) {
&nbsp;        /* 50/50 chance for immediate access vs 1 turn delay (unless
&nbsp;           wielding blessed tin opener which always yields immediate
&nbsp;           access); 1 turn delay case is non-deterministic:  getting
&nbsp;           interrupted and retrying might yield another 1 turn delay
&nbsp;           or might open immediately on 2nd (or 3rd, 4th, ...) try */
&nbsp;        tmp = (uwep &amp;&amp; uwep-&gt;blessed &amp;&amp; uwep-&gt;otyp == TIN_OPENER) ? 0 : rn2(2);
&nbsp;        if (!tmp)
&nbsp;            mesg = "The tin opens like magic!";
&nbsp;        else
&nbsp;            pline_The("tin seems easy to open.");
&nbsp;    } else if (uwep) {
&nbsp;        switch (uwep-&gt;otyp) {
&nbsp;        case TIN_OPENER:
&nbsp;            mesg = "You easily open the tin."; /* iff tmp==0 */
&nbsp;            tmp = rn2(uwep-&gt;cursed ? 3 : !uwep-&gt;blessed ? 2 : 1);
&nbsp;            break;
&nbsp;        case DAGGER:
&nbsp;        case SILVER_DAGGER:
&nbsp;        case ELVEN_DAGGER:
&nbsp;        case ORCISH_DAGGER:
&nbsp;        case ATHAME:
&nbsp;        case KNIFE:
&nbsp;        case STILETTO:
&nbsp;        case CRYSKNIFE:
&nbsp;            tmp = 3;
&nbsp;            break;
&nbsp;        case PICK_AXE:
&nbsp;        case AXE:
&nbsp;            tmp = 6;
&nbsp;            break;
&nbsp;        default:
&nbsp;            goto no_opener;
&nbsp;        }
&nbsp;        pline("Using %s you try to open the tin.", yobjnam(uwep, (char *) 0));
&nbsp;    } else {
&nbsp;    no_opener:
&nbsp;        pline("It is not so easy to open this tin.");
&nbsp;        if (Glib) {
&nbsp;            pline_The("tin slips from your %s.",
&nbsp;                      makeplural(body_part(FINGER)));
&nbsp;            if (otmp-&gt;quan &gt; 1L) {
&nbsp;                otmp = splitobj(otmp, 1L);
&nbsp;            }
&nbsp;            if (carried(otmp))
&nbsp;                dropx(otmp);
&nbsp;            else
&nbsp;                stackobj(otmp);
&nbsp;            return;
&nbsp;        }
&nbsp;        tmp = rn1(1 + 500 / ((int) (ACURR(A_DEX) + ACURRSTR)), 10);
&nbsp;    }
&nbsp;
&nbsp;    context.tin.tin = otmp;
&nbsp;    context.tin.o_id = otmp-&gt;o_id;
&nbsp;    if (!tmp) {
&nbsp;        consume_tin(mesg); /* begin immediately */
&nbsp;    } else {
&nbsp;        context.tin.reqtime = tmp;
&nbsp;        context.tin.usedtime = 0;
&nbsp;        set_occupation(opentin, "opening the tin", 0);
&nbsp;    }
&nbsp;    return;
&nbsp;}
&nbsp;
Hear_again
&nbsp;/* called when waking up after fainting */
&nbsp;int
&nbsp;Hear_again(VOID_ARGS)
&nbsp;{
&nbsp;    /* Chance of deafness going away while fainted/sleeping/etc. */
&nbsp;    if (!rn2(2)) {
&nbsp;        make_deaf(0L, FALSE);
&nbsp;        context.botl = TRUE;
&nbsp;    }
&nbsp;    return 0;
&nbsp;}
&nbsp;
rottenfood
&nbsp;/* called on the "first bite" of rotten food */
&nbsp;STATIC_OVL int
&nbsp;rottenfood(obj)
&nbsp;struct obj *obj;
&nbsp;{
&nbsp;    pline("Blecch!  Rotten %s!", foodword(obj));
&nbsp;    if (!rn2(4)) {
&nbsp;        if (Hallucination)
&nbsp;            You_feel("rather trippy.");
&nbsp;        else
&nbsp;            You_feel("rather %s.", body_part(LIGHT_HEADED));
&nbsp;        make_confused(HConfusion + d(2, 4), FALSE);
&nbsp;    } else if (!rn2(4) &amp;&amp; !Blind) {
&nbsp;        pline("Everything suddenly goes dark.");
&nbsp;        /* hero is not Blind, but Blinded timer might be nonzero if
&nbsp;           blindness is being overridden by the Eyes of the Overworld */
&nbsp;        make_blinded((Blinded &amp; TIMEOUT) + (long) d(2, 10), FALSE);
&nbsp;        if (!Blind)
&nbsp;            Your1(vision_clears);
&nbsp;    } else if (!rn2(3)) {
&nbsp;        const char *what, *where;
&nbsp;        int duration = rnd(10);
&nbsp;
&nbsp;        if (!Blind)
&nbsp;            what = "goes", where = "dark";
&nbsp;        else if (Levitation || Is_airlevel(&amp;u.uz) || Is_waterlevel(&amp;u.uz))
&nbsp;            what = "you lose control of", where = "yourself";
&nbsp;        else
&nbsp;            what = "you slap against the",
&nbsp;            where = (u.usteed) ? "saddle" : surface(u.ux, u.uy);
&nbsp;        pline_The("world spins and %s %s.", what, where);
&nbsp;        incr_itimeout(&amp;HDeaf, duration);
&nbsp;        context.botl = TRUE;
&nbsp;        nomul(-duration);
&nbsp;        multi_reason = "unconscious from rotten food";
&nbsp;        nomovemsg = "You are conscious again.";
&nbsp;        afternmv = Hear_again;
&nbsp;        return 1;
&nbsp;    }
&nbsp;    return 0;
&nbsp;}
&nbsp;
eatcorpse
&nbsp;/* called when a corpse is selected as food */
&nbsp;STATIC_OVL int
&nbsp;eatcorpse(otmp)
&nbsp;struct obj *otmp;
&nbsp;{
&nbsp;    int retcode = 0, tp = 0, mnum = otmp-&gt;corpsenm;
&nbsp;    long rotted = 0L;
&nbsp;    boolean stoneable = (flesh_petrifies(&amp;mons[mnum]) &amp;&amp; !Stone_resistance
&nbsp;                         &amp;&amp; !poly_when_stoned(youmonst.data)),
&nbsp;            slimeable = (mnum == PM_GREEN_SLIME &amp;&amp; !Slimed &amp;&amp; !Unchanging
&nbsp;                         &amp;&amp; !slimeproof(youmonst.data)),
&nbsp;            glob = otmp-&gt;globby ? TRUE : FALSE;
&nbsp;
&nbsp;    /* KMH, conduct */
&nbsp;    if (!vegan(&amp;mons[mnum]))
&nbsp;        u.uconduct.unvegan++;
&nbsp;    if (!vegetarian(&amp;mons[mnum]))
&nbsp;        violated_vegetarian();
&nbsp;
&nbsp;    if (!nonrotting_corpse(mnum)) {
&nbsp;        long age = peek_at_iced_corpse_age(otmp);
&nbsp;
&nbsp;        rotted = (monstermoves - age) / (10L + rn2(20));
&nbsp;        if (otmp-&gt;cursed)
&nbsp;            rotted += 2L;
&nbsp;        else if (otmp-&gt;blessed)
&nbsp;            rotted -= 2L;
&nbsp;    }
&nbsp;
&nbsp;    if (mnum != PM_ACID_BLOB &amp;&amp; !stoneable &amp;&amp; !slimeable &amp;&amp; rotted &gt; 5L) {
&nbsp;        boolean cannibal = maybe_cannibal(mnum, FALSE);
&nbsp;
&nbsp;        pline("Ulch - that %s was tainted%s!",
&nbsp;              (mons[mnum].mlet == S_FUNGUS) ? "fungoid vegetation"
&nbsp;                  : glob ? "glob"
&nbsp;                      : vegetarian(&amp;mons[mnum]) ? "protoplasm"
&nbsp;                          : "meat",
&nbsp;              cannibal ? ", you cannibal" : "");
&nbsp;        if (Sick_resistance) {
&nbsp;            pline("It doesn't seem at all sickening, though...");
&nbsp;        } else {
&nbsp;            long sick_time;
&nbsp;
&nbsp;            sick_time = (long) rn1(10, 10);
&nbsp;            /* make sure new ill doesn't result in improvement */
&nbsp;            if (Sick &amp;&amp; (sick_time &gt; Sick))
&nbsp;                sick_time = (Sick &gt; 1L) ? Sick - 1L : 1L;
&nbsp;            make_sick(sick_time, corpse_xname(otmp, "rotted", CXN_NORMAL),
&nbsp;                      TRUE, SICK_VOMITABLE);
&nbsp;
&nbsp;            pline("(It must have died too long ago to be safe to eat.)");
&nbsp;        }
&nbsp;        if (carried(otmp))
&nbsp;            useup(otmp);
&nbsp;        else
&nbsp;            useupf(otmp, 1L);
&nbsp;        return 2;
&nbsp;    } else if (acidic(&amp;mons[mnum]) &amp;&amp; !Acid_resistance) {
&nbsp;        tp++;
&nbsp;        You("have a very bad case of stomach acid.");   /* not body_part() */
&nbsp;        losehp(rnd(15), !glob ? "acidic corpse" : "acidic glob",
&nbsp;               KILLED_BY_AN); /* acid damage */
&nbsp;    } else if (poisonous(&amp;mons[mnum]) &amp;&amp; rn2(5)) {
&nbsp;        tp++;
&nbsp;        pline("Ecch - that must have been poisonous!");
&nbsp;        if (!Poison_resistance) {
&nbsp;            losestr(rnd(4));
&nbsp;            losehp(rnd(15), !glob ? "poisonous corpse" : "poisonous glob",
&nbsp;                   KILLED_BY_AN);
&nbsp;        } else
&nbsp;            You("seem unaffected by the poison.");
&nbsp;    /* now any corpse left too long will make you mildly ill */
&nbsp;    } else if ((rotted &gt; 5L || (rotted &gt; 3L &amp;&amp; rn2(5))) &amp;&amp; !Sick_resistance) {
&nbsp;        tp++;
&nbsp;        You_feel("%ssick.", (Sick) ? "very " : "");
&nbsp;        losehp(rnd(8), !glob ? "cadaver" : "rotted glob", KILLED_BY_AN);
&nbsp;    }
&nbsp;
&nbsp;    /* delay is weight dependent */
&nbsp;    context.victual.reqtime = 3 + ((!glob ? mons[mnum].cwt : otmp-&gt;owt) &gt;&gt; 6);
&nbsp;
&nbsp;    if (!tp &amp;&amp; !nonrotting_corpse(mnum) &amp;&amp; (otmp-&gt;orotten || !rn2(7))) {
&nbsp;        if (rottenfood(otmp)) {
&nbsp;            otmp-&gt;orotten = TRUE;
&nbsp;            (void) touchfood(otmp);
&nbsp;            retcode = 1;
&nbsp;        }
&nbsp;
&nbsp;        if (!mons[otmp-&gt;corpsenm].cnutrit) {
&nbsp;            /* no nutrition: rots away, no message if you passed out */
&nbsp;            if (!retcode)
&nbsp;                pline_The("corpse rots away completely.");
&nbsp;            if (carried(otmp))
&nbsp;                useup(otmp);
&nbsp;            else
&nbsp;                useupf(otmp, 1L);
&nbsp;            retcode = 2;
&nbsp;        }
&nbsp;
&nbsp;        if (!retcode)
&nbsp;            consume_oeaten(otmp, 2); /* oeaten &gt;&gt;= 2 */
&nbsp;    } else if ((mnum == PM_COCKATRICE || mnum == PM_CHICKATRICE)
&nbsp;               &amp;&amp; (Stone_resistance || Hallucination)) {
&nbsp;        pline("This tastes just like chicken!");
&nbsp;    } else if (mnum == PM_FLOATING_EYE &amp;&amp; u.umonnum == PM_RAVEN) {
&nbsp;        You("peck the eyeball with delight.");
&nbsp;    } else {
&nbsp;        /* yummy is always False for omnivores, palatable always True */
&nbsp;        boolean yummy = (vegan(&amp;mons[mnum])
&nbsp;                            ? (!carnivorous(youmonst.data)
&nbsp;                               &amp;&amp; herbivorous(youmonst.data))
&nbsp;                            : (carnivorous(youmonst.data)
&nbsp;                               &amp;&amp; !herbivorous(youmonst.data))),
&nbsp;            palatable = ((vegetarian(&amp;mons[mnum])
&nbsp;                          ? herbivorous(youmonst.data)
&nbsp;                          : carnivorous(youmonst.data))
&nbsp;                         &amp;&amp; rn2(10)
&nbsp;                         &amp;&amp; ((rotted &lt; 1) ? TRUE : !rn2(rotted+1)));
&nbsp;        const char *pmxnam = food_xname(otmp, FALSE);
&nbsp;
&nbsp;        if (!strncmpi(pmxnam, "the ", 4))
&nbsp;            pmxnam += 4;
&nbsp;        pline("%s%s %s %s%c",
&nbsp;              type_is_pname(&amp;mons[mnum])
&nbsp;                 ? "" : the_unique_pm(&amp;mons[mnum]) ? "The " : "This ",
&nbsp;              pmxnam,
&nbsp;              Hallucination ? "is" : "tastes",
&nbsp;                  /* tiger reference is to TV ads for "Frosted Flakes",
&nbsp;                     breakfast cereal targeted at kids by "Tony the tiger" */
&nbsp;              Hallucination
&nbsp;                 ? (yummy ? ((u.umonnum == PM_TIGER) ? "gr-r-reat" : "gnarly")
&nbsp;                          : palatable ? "copacetic" : "grody")
&nbsp;                 : (yummy ? "delicious" : palatable ? "okay" : "terrible"),
&nbsp;              (yummy || !palatable) ? '!' : '.');
&nbsp;    }
&nbsp;
&nbsp;    return retcode;
&nbsp;}
&nbsp;
start_eating
&nbsp;/* called as you start to eat */
&nbsp;STATIC_OVL void
&nbsp;start_eating(otmp)
&nbsp;struct obj *otmp;
&nbsp;{
&nbsp;    const char *old_nomovemsg, *save_nomovemsg;
&nbsp;
&nbsp;    debugpline2("start_eating: %s (victual = %s)",
&nbsp;                /* note: fmt_ptr() returns a static buffer but supports
&nbsp;                   several such so we don't need to copy the first result
&nbsp;                   before calling it a second time */
&nbsp;                fmt_ptr((genericptr_t) otmp),
&nbsp;                fmt_ptr((genericptr_t) context.victual.piece));
&nbsp;    debugpline1("reqtime = %d", context.victual.reqtime);
&nbsp;    debugpline1("(original reqtime = %d)", objects[otmp-&gt;otyp].oc_delay);
&nbsp;    debugpline1("nmod = %d", context.victual.nmod);
&nbsp;    debugpline1("oeaten = %d", otmp-&gt;oeaten);
&nbsp;    context.victual.fullwarn = context.victual.doreset = FALSE;
&nbsp;    context.victual.eating = TRUE;
&nbsp;
&nbsp;    if (otmp-&gt;otyp == CORPSE || otmp-&gt;globby) {
&nbsp;        cprefx(context.victual.piece-&gt;corpsenm);
&nbsp;        if (!context.victual.piece || !context.victual.eating) {
&nbsp;            /* rider revived, or died and lifesaved */
&nbsp;            return;
&nbsp;        }
&nbsp;    }
&nbsp;
&nbsp;    old_nomovemsg = nomovemsg;
&nbsp;    if (bite()) {
&nbsp;        /* survived choking, finish off food that's nearly done;
&nbsp;           need this to handle cockatrice eggs, fortune cookies, etc */
&nbsp;        if (++context.victual.usedtime &gt;= context.victual.reqtime) {
&nbsp;            /* don't want done_eating() to issue nomovemsg if it
&nbsp;               is due to vomit() called by bite() */
&nbsp;            save_nomovemsg = nomovemsg;
&nbsp;            if (!old_nomovemsg)
&nbsp;                nomovemsg = 0;
&nbsp;            done_eating(FALSE);
&nbsp;            if (!old_nomovemsg)
&nbsp;                nomovemsg = save_nomovemsg;
&nbsp;        }
&nbsp;        return;
&nbsp;    }
&nbsp;
&nbsp;    if (++context.victual.usedtime &gt;= context.victual.reqtime) {
&nbsp;        /* print "finish eating" message if they just resumed -dlc */
&nbsp;        done_eating(context.victual.reqtime &gt; 1 ? TRUE : FALSE);
&nbsp;        return;
&nbsp;    }
&nbsp;
&nbsp;    Sprintf(msgbuf, "eating %s", food_xname(otmp, TRUE));
&nbsp;    set_occupation(eatfood, msgbuf, 0);
&nbsp;}
&nbsp;
fprefx
&nbsp;/*
&nbsp; * called on "first bite" of (non-corpse) food.
&nbsp; * used for non-rotten non-tin non-corpse food
&nbsp; */
&nbsp;STATIC_OVL void
&nbsp;fprefx(otmp)
&nbsp;struct obj *otmp;
&nbsp;{
&nbsp;    switch (otmp-&gt;otyp) {
&nbsp;    case FOOD_RATION:
&nbsp;        if (u.uhunger &lt;= 200)
&nbsp;            pline(Hallucination ? "Oh wow, like, superior, man!"
&nbsp;                                : "That food really hit the spot!");
&nbsp;        else if (u.uhunger &lt;= 700)
&nbsp;            pline("That satiated your %s!", body_part(STOMACH));
&nbsp;        break;
&nbsp;    case TRIPE_RATION:
&nbsp;        if (carnivorous(youmonst.data) &amp;&amp; !humanoid(youmonst.data))
&nbsp;            pline("That tripe ration was surprisingly good!");
&nbsp;        else if (maybe_polyd(is_orc(youmonst.data), Race_if(PM_ORC)))
&nbsp;            pline(Hallucination ? "Tastes great! Less filling!"
&nbsp;                                : "Mmm, tripe... not bad!");
&nbsp;        else {
&nbsp;            pline("Yak - dog food!");
&nbsp;            more_experienced(1, 0);
&nbsp;            newexplevel();
&nbsp;            /* not cannibalism, but we use similar criteria
&nbsp;               for deciding whether to be sickened by this meal */
&nbsp;            if (rn2(2) &amp;&amp; !CANNIBAL_ALLOWED())
&nbsp;                make_vomiting((long) rn1(context.victual.reqtime, 14), FALSE);
&nbsp;        }
&nbsp;        break;
&nbsp;    case LEMBAS_WAFER:
&nbsp;        if (maybe_polyd(is_orc(youmonst.data), Race_if(PM_ORC))) {
&nbsp;            pline("%s", "!#?&amp;* elf kibble!");
&nbsp;            break;
&nbsp;        } else if (maybe_polyd(is_elf(youmonst.data), Race_if(PM_ELF))) {
&nbsp;            pline("A little goes a long way.");
&nbsp;            break;
&nbsp;        }
&nbsp;        goto give_feedback;
&nbsp;    case MEATBALL:
&nbsp;    case MEAT_STICK:
&nbsp;    case HUGE_CHUNK_OF_MEAT:
&nbsp;    case MEAT_RING:
&nbsp;        goto give_feedback;
&nbsp;    case CLOVE_OF_GARLIC:
&nbsp;        if (is_undead(youmonst.data)) {
&nbsp;            make_vomiting((long) rn1(context.victual.reqtime, 5), FALSE);
&nbsp;            break;
&nbsp;        }
&nbsp;        /*FALLTHRU*/
&nbsp;    default:
&nbsp;        if (otmp-&gt;otyp == SLIME_MOLD &amp;&amp; !otmp-&gt;cursed
&nbsp;            &amp;&amp; otmp-&gt;spe == context.current_fruit) {
&nbsp;            pline("My, that was a %s %s!",
&nbsp;                  Hallucination ? "primo" : "yummy",
&nbsp;                  singular(otmp, xname));
&nbsp;        } else if (otmp-&gt;otyp == APPLE &amp;&amp; otmp-&gt;cursed &amp;&amp; !Sleep_resistance) {
&nbsp;            ; /* skip core joke; feedback deferred til fpostfx() */
&nbsp;
&nbsp;#if defined(MAC) || defined(MACOSX)
&nbsp;        /* KMH -- Why should Unix have all the fun?
&nbsp;           We check MACOSX before UNIX to get the Apple-specific apple
&nbsp;           message; the '#if UNIX' code will still kick in for pear. */
&nbsp;        } else if (otmp-&gt;otyp == APPLE) {
&nbsp;            pline("Delicious!  Must be a Macintosh!");
&nbsp;#endif
&nbsp;
&nbsp;#ifdef UNIX
&nbsp;        } else if (otmp-&gt;otyp == APPLE || otmp-&gt;otyp == PEAR) {
&nbsp;            if (!Hallucination) {
&nbsp;                pline("Core dumped.");
&nbsp;            } else {
&nbsp;                /* This is based on an old Usenet joke, a fake a.out manual
&nbsp;                 * page
&nbsp;                 */
&nbsp;                int x = rnd(100);
&nbsp;
&nbsp;                pline("%s -- core dumped.",
&nbsp;                      (x &lt;= 75)
&nbsp;                         ? "Segmentation fault"
&nbsp;                         : (x &lt;= 99)
&nbsp;                            ? "Bus error"
&nbsp;                            : "Yo' mama");
&nbsp;            }
&nbsp;#endif
&nbsp;        } else if (otmp-&gt;otyp == EGG &amp;&amp; stale_egg(otmp)) {
&nbsp;            pline("Ugh.  Rotten egg."); /* perhaps others like it */
&nbsp;            /* increasing existing nausea means that it will take longer
&nbsp;               before eventual vomit, but also means that constitution
&nbsp;               will be abused more times before illness completes */
&nbsp;            make_vomiting((Vomiting &amp; TIMEOUT) + (long) d(10, 4), TRUE);
&nbsp;        } else {
&nbsp;        give_feedback:
&nbsp;            pline("This %s is %s", singular(otmp, xname),
&nbsp;                  otmp-&gt;cursed
&nbsp;                     ? (Hallucination ? "grody!" : "terrible!")
&nbsp;                     : (otmp-&gt;otyp == CRAM_RATION
&nbsp;                        || otmp-&gt;otyp == K_RATION
&nbsp;                        || otmp-&gt;otyp == C_RATION)
&nbsp;                        ? "bland."
&nbsp;                        : Hallucination ? "gnarly!" : "delicious!");
&nbsp;        }
&nbsp;        break; /* default */
&nbsp;    } /* switch */
&nbsp;}
&nbsp;
bounded_increase
&nbsp;/* increment a combat intrinsic with limits on its growth */
&nbsp;STATIC_OVL int
&nbsp;bounded_increase(old, inc, typ)
&nbsp;int old, inc, typ;
&nbsp;{
&nbsp;    int absold, absinc, sgnold, sgninc;
&nbsp;
&nbsp;    /* don't include any amount coming from worn rings */
&nbsp;    if (uright &amp;&amp; uright-&gt;otyp == typ)
&nbsp;        old -= uright-&gt;spe;
&nbsp;    if (uleft &amp;&amp; uleft-&gt;otyp == typ)
&nbsp;        old -= uleft-&gt;spe;
&nbsp;    absold = abs(old), absinc = abs(inc);
&nbsp;    sgnold = sgn(old), sgninc = sgn(inc);
&nbsp;
&nbsp;    if (absinc == 0 || sgnold != sgninc || absold + absinc &lt; 10) {
&nbsp;        ; /* use inc as-is */
&nbsp;    } else if (absold + absinc &lt; 20) {
&nbsp;        absinc = rnd(absinc); /* 1..n */
&nbsp;        if (absold + absinc &lt; 10)
&nbsp;            absinc = 10 - absold;
&nbsp;        inc = sgninc * absinc;
&nbsp;    } else if (absold + absinc &lt; 40) {
&nbsp;        absinc = rn2(absinc) ? 1 : 0;
&nbsp;        if (absold + absinc &lt; 20)
&nbsp;            absinc = rnd(20 - absold);
&nbsp;        inc = sgninc * absinc;
&nbsp;    } else {
&nbsp;        inc = 0; /* no further increase allowed via this method */
&nbsp;    }
&nbsp;    return old + inc;
&nbsp;}
&nbsp;
accessory_has_effect
&nbsp;STATIC_OVL void
&nbsp;accessory_has_effect(otmp)
&nbsp;struct obj *otmp;
&nbsp;{
&nbsp;    pline("Magic spreads through your body as you digest the %s.",
&nbsp;          otmp-&gt;oclass == RING_CLASS ? "ring" : "amulet");
&nbsp;}
&nbsp;
eataccessory
&nbsp;STATIC_OVL void
&nbsp;eataccessory(otmp)
&nbsp;struct obj *otmp;
&nbsp;{
&nbsp;    int typ = otmp-&gt;otyp;
&nbsp;    long oldprop;
&nbsp;
&nbsp;    /* Note: rings are not so common that this is unbalancing. */
&nbsp;    /* (How often do you even _find_ 3 rings of polymorph in a game?) */
&nbsp;    oldprop = u.uprops[objects[typ].oc_oprop].intrinsic;
&nbsp;    if (otmp == uleft || otmp == uright) {
&nbsp;        Ring_gone(otmp);
&nbsp;        if (u.uhp &lt;= 0)
&nbsp;            return; /* died from sink fall */
&nbsp;    }
&nbsp;    otmp-&gt;known = otmp-&gt;dknown = 1; /* by taste */
&nbsp;    if (!rn2(otmp-&gt;oclass == RING_CLASS ? 3 : 5)) {
&nbsp;        switch (otmp-&gt;otyp) {
&nbsp;        default:
&nbsp;            if (!objects[typ].oc_oprop)
&nbsp;                break; /* should never happen */
&nbsp;
&nbsp;            if (!(u.uprops[objects[typ].oc_oprop].intrinsic &amp; FROMOUTSIDE))
&nbsp;                accessory_has_effect(otmp);
&nbsp;
&nbsp;            u.uprops[objects[typ].oc_oprop].intrinsic |= FROMOUTSIDE;
&nbsp;
&nbsp;            switch (typ) {
&nbsp;            case RIN_SEE_INVISIBLE:
&nbsp;                set_mimic_blocking();
&nbsp;                see_monsters();
&nbsp;                if (Invis &amp;&amp; !oldprop &amp;&amp; !ESee_invisible
&nbsp;                    &amp;&amp; !perceives(youmonst.data) &amp;&amp; !Blind) {
&nbsp;                    newsym(u.ux, u.uy);
&nbsp;                    pline("Suddenly you can see yourself.");
&nbsp;                    makeknown(typ);
&nbsp;                }
&nbsp;                break;
&nbsp;            case RIN_INVISIBILITY:
&nbsp;                if (!oldprop &amp;&amp; !EInvis &amp;&amp; !BInvis &amp;&amp; !See_invisible
&nbsp;                    &amp;&amp; !Blind) {
&nbsp;                    newsym(u.ux, u.uy);
&nbsp;                    Your("body takes on a %s transparency...",
&nbsp;                         Hallucination ? "normal" : "strange");
&nbsp;                    makeknown(typ);
&nbsp;                }
&nbsp;                break;
&nbsp;            case RIN_PROTECTION_FROM_SHAPE_CHAN:
&nbsp;                rescham();
&nbsp;                break;
&nbsp;            case RIN_LEVITATION:
&nbsp;                /* undo the `.intrinsic |= FROMOUTSIDE' done above */
&nbsp;                u.uprops[LEVITATION].intrinsic = oldprop;
&nbsp;                if (!Levitation) {
&nbsp;                    float_up();
&nbsp;                    incr_itimeout(&amp;HLevitation, d(10, 20));
&nbsp;                    makeknown(typ);
&nbsp;                }
&nbsp;                break;
&nbsp;            } /* inner switch */
&nbsp;            break; /* default case of outer switch */
&nbsp;
&nbsp;        case RIN_ADORNMENT:
&nbsp;            accessory_has_effect(otmp);
&nbsp;            if (adjattrib(A_CHA, otmp-&gt;spe, -1))
&nbsp;                makeknown(typ);
&nbsp;            break;
&nbsp;        case RIN_GAIN_STRENGTH:
&nbsp;            accessory_has_effect(otmp);
&nbsp;            if (adjattrib(A_STR, otmp-&gt;spe, -1))
&nbsp;                makeknown(typ);
&nbsp;            break;
&nbsp;        case RIN_GAIN_CONSTITUTION:
&nbsp;            accessory_has_effect(otmp);
&nbsp;            if (adjattrib(A_CON, otmp-&gt;spe, -1))
&nbsp;                makeknown(typ);
&nbsp;            break;
&nbsp;        case RIN_INCREASE_ACCURACY:
&nbsp;            accessory_has_effect(otmp);
&nbsp;            u.uhitinc = (schar) bounded_increase((int) u.uhitinc, otmp-&gt;spe,
&nbsp;                                                 RIN_INCREASE_ACCURACY);
&nbsp;            break;
&nbsp;        case RIN_INCREASE_DAMAGE:
&nbsp;            accessory_has_effect(otmp);
&nbsp;            u.udaminc = (schar) bounded_increase((int) u.udaminc, otmp-&gt;spe,
&nbsp;                                                 RIN_INCREASE_DAMAGE);
&nbsp;            break;
&nbsp;        case RIN_PROTECTION:
&nbsp;            accessory_has_effect(otmp);
&nbsp;            HProtection |= FROMOUTSIDE;
&nbsp;            u.ublessed = bounded_increase(u.ublessed, otmp-&gt;spe,
&nbsp;                                          RIN_PROTECTION);
&nbsp;            context.botl = 1;
&nbsp;            break;
&nbsp;        case RIN_FREE_ACTION:
&nbsp;            /* Give sleep resistance instead */
&nbsp;            if (!(HSleep_resistance &amp; FROMOUTSIDE))
&nbsp;                accessory_has_effect(otmp);
&nbsp;            if (!Sleep_resistance)
&nbsp;                You_feel("wide awake.");
&nbsp;            HSleep_resistance |= FROMOUTSIDE;
&nbsp;            break;
&nbsp;        case AMULET_OF_CHANGE:
&nbsp;            accessory_has_effect(otmp);
&nbsp;            makeknown(typ);
&nbsp;            change_sex();
&nbsp;            You("are suddenly very %s!",
&nbsp;                flags.female ? "feminine" : "masculine");
&nbsp;            context.botl = 1;
&nbsp;            break;
&nbsp;        case AMULET_OF_UNCHANGING:
&nbsp;            /* un-change: it's a pun */
&nbsp;            if (!Unchanging &amp;&amp; Upolyd) {
&nbsp;                accessory_has_effect(otmp);
&nbsp;                makeknown(typ);
&nbsp;                rehumanize();
&nbsp;            }
&nbsp;            break;
&nbsp;        case AMULET_OF_STRANGULATION: /* bad idea! */
&nbsp;            /* no message--this gives no permanent effect */
&nbsp;            choke(otmp);
&nbsp;            break;
&nbsp;        case AMULET_OF_RESTFUL_SLEEP: { /* another bad idea! */
&nbsp;            long newnap = (long) rnd(100), oldnap = (HSleepy &amp; TIMEOUT);
&nbsp;
&nbsp;            if (!(HSleepy &amp; FROMOUTSIDE))
&nbsp;                accessory_has_effect(otmp);
&nbsp;            HSleepy |= FROMOUTSIDE;
&nbsp;            /* might also be wearing one; use shorter of two timeouts */
&nbsp;            if (newnap &lt; oldnap || oldnap == 0L)
&nbsp;                HSleepy = (HSleepy &amp; ~TIMEOUT) | newnap;
&nbsp;            break;
&nbsp;        }
&nbsp;        case RIN_SUSTAIN_ABILITY:
&nbsp;        case AMULET_OF_LIFE_SAVING:
&nbsp;        case AMULET_OF_REFLECTION: /* nice try */
&nbsp;            /* can't eat Amulet of Yendor or fakes,
&nbsp;             * and no oc_prop even if you could -3.
&nbsp;             */
&nbsp;            break;
&nbsp;        }
&nbsp;    }
&nbsp;}
&nbsp;
eatspecial
&nbsp;/* called after eating non-food */
&nbsp;STATIC_OVL void
&nbsp;eatspecial()
&nbsp;{
&nbsp;    struct obj *otmp = context.victual.piece;
&nbsp;
&nbsp;    /* lesshungry wants an occupation to handle choke messages correctly */
&nbsp;    set_occupation(eatfood, "eating non-food", 0);
&nbsp;    lesshungry(context.victual.nmod);
&nbsp;    occupation = 0;
&nbsp;    context.victual.piece = (struct obj *) 0;
&nbsp;    context.victual.o_id = 0;
&nbsp;    context.victual.eating = 0;
&nbsp;    if (otmp-&gt;oclass == COIN_CLASS) {
&nbsp;        if (carried(otmp))
&nbsp;            useupall(otmp);
&nbsp;        else
&nbsp;            useupf(otmp, otmp-&gt;quan);
&nbsp;        vault_gd_watching(GD_EATGOLD);
&nbsp;        return;
&nbsp;    }
&nbsp;    if (objects[otmp-&gt;otyp].oc_material == PAPER) {
&nbsp;#ifdef MAIL
&nbsp;        if (otmp-&gt;otyp == SCR_MAIL)
&nbsp;            /* no nutrition */
&nbsp;            pline("This junk mail is less than satisfying.");
&nbsp;        else
&nbsp;#endif
&nbsp;        if (otmp-&gt;otyp == SCR_SCARE_MONSTER)
&nbsp;            /* to eat scroll, hero is currently polymorphed into a monster */
&nbsp;            pline("Yuck%c", otmp-&gt;blessed ? '!' : '.');
&nbsp;        else if (otmp-&gt;oclass == SCROLL_CLASS
&nbsp;                 /* check description after checking for specific scrolls */
&nbsp;                 &amp;&amp; !strcmpi(OBJ_DESCR(objects[otmp-&gt;otyp]), "YUM YUM"))
&nbsp;            pline("Yum%c", otmp-&gt;blessed ? '!' : '.');
&nbsp;        else
&nbsp;            pline("Needs salt...");
&nbsp;    }
&nbsp;    if (otmp-&gt;oclass == POTION_CLASS) {
&nbsp;        otmp-&gt;quan++; /* dopotion() does a useup() */
&nbsp;        (void) dopotion(otmp);
&nbsp;    } else if (otmp-&gt;oclass == RING_CLASS || otmp-&gt;oclass == AMULET_CLASS) {
&nbsp;        eataccessory(otmp);
&nbsp;    } else if (otmp-&gt;otyp == LEASH &amp;&amp; otmp-&gt;leashmon) {
&nbsp;        o_unleash(otmp);
&nbsp;    }
&nbsp;
&nbsp;    /* KMH -- idea by "Tommy the Terrorist" */
&nbsp;    if (otmp-&gt;otyp == TRIDENT &amp;&amp; !otmp-&gt;cursed) {
&nbsp;        /* sugarless chewing gum which used to be heavily advertised on TV */
&nbsp;        pline(Hallucination ? "Four out of five dentists agree."
&nbsp;                            : "That was pure chewing satisfaction!");
&nbsp;        exercise(A_WIS, TRUE);
&nbsp;    }
&nbsp;    if (otmp-&gt;otyp == FLINT &amp;&amp; !otmp-&gt;cursed) {
&nbsp;        /* chewable vitamin for kids based on "The Flintstones" TV cartoon */
&nbsp;        pline("Yabba-dabba delicious!");
&nbsp;        exercise(A_CON, TRUE);
&nbsp;    }
&nbsp;
&nbsp;    if (otmp == uwep &amp;&amp; otmp-&gt;quan == 1L)
&nbsp;        uwepgone();
&nbsp;    if (otmp == uquiver &amp;&amp; otmp-&gt;quan == 1L)
&nbsp;        uqwepgone();
&nbsp;    if (otmp == uswapwep &amp;&amp; otmp-&gt;quan == 1L)
&nbsp;        uswapwepgone();
&nbsp;
&nbsp;    if (otmp == uball)
&nbsp;        unpunish();
&nbsp;    if (otmp == uchain)
&nbsp;        unpunish(); /* but no useup() */
&nbsp;    else if (carried(otmp))
&nbsp;        useup(otmp);
&nbsp;    else
&nbsp;        useupf(otmp, 1L);
&nbsp;}
&nbsp;
&nbsp;/* NOTE: the order of these words exactly corresponds to the
&nbsp;   order of oc_material values #define'd in objclass.h. */
&nbsp;static const char *foodwords[] = {
&nbsp;    "meal",    "liquid",  "wax",       "food", "meat",     "paper",
&nbsp;    "cloth",   "leather", "wood",      "bone", "scale",    "metal",
&nbsp;    "metal",   "metal",   "silver",    "gold", "platinum", "mithril",
&nbsp;    "plastic", "glass",   "rich food", "stone"
&nbsp;};
&nbsp;
foodword
&nbsp;STATIC_OVL const char *
&nbsp;foodword(otmp)
&nbsp;struct obj *otmp;
&nbsp;{
&nbsp;    if (otmp-&gt;oclass == FOOD_CLASS)
&nbsp;        return "food";
&nbsp;    if (otmp-&gt;oclass == GEM_CLASS &amp;&amp; objects[otmp-&gt;otyp].oc_material == GLASS
&nbsp;        &amp;&amp; otmp-&gt;dknown)
&nbsp;        makeknown(otmp-&gt;otyp);
&nbsp;    return foodwords[objects[otmp-&gt;otyp].oc_material];
&nbsp;}
&nbsp;
fpostfx
&nbsp;/* called after consuming (non-corpse) food */
&nbsp;STATIC_OVL void
&nbsp;fpostfx(otmp)
&nbsp;struct obj *otmp;
&nbsp;{
&nbsp;    switch (otmp-&gt;otyp) {
&nbsp;    case SPRIG_OF_WOLFSBANE:
&nbsp;        if (u.ulycn &gt;= LOW_PM || is_were(youmonst.data))
&nbsp;            you_unwere(TRUE);
&nbsp;        break;
&nbsp;    case CARROT:
&nbsp;        if (!u.uswallow
&nbsp;            || !attacktype_fordmg(u.ustuck-&gt;data, AT_ENGL, AD_BLND))
&nbsp;            make_blinded((long) u.ucreamed, TRUE);
&nbsp;        break;
&nbsp;    case FORTUNE_COOKIE:
&nbsp;        outrumor(bcsign(otmp), BY_COOKIE);
&nbsp;        if (!Blind)
&nbsp;            u.uconduct.literate++;
&nbsp;        break;
&nbsp;    case LUMP_OF_ROYAL_JELLY:
&nbsp;        /* This stuff seems to be VERY healthy! */
&nbsp;        gainstr(otmp, 1, TRUE);
&nbsp;        if (Upolyd) {
&nbsp;            u.mh += otmp-&gt;cursed ? -rnd(20) : rnd(20);
&nbsp;            if (u.mh &gt; u.mhmax) {
&nbsp;                if (!rn2(17))
&nbsp;                    u.mhmax++;
&nbsp;                u.mh = u.mhmax;
&nbsp;            } else if (u.mh &lt;= 0) {
&nbsp;                rehumanize();
&nbsp;            }
&nbsp;        } else {
&nbsp;            u.uhp += otmp-&gt;cursed ? -rnd(20) : rnd(20);
&nbsp;            if (u.uhp &gt; u.uhpmax) {
&nbsp;                if (!rn2(17))
&nbsp;                    u.uhpmax++;
&nbsp;                u.uhp = u.uhpmax;
&nbsp;            } else if (u.uhp &lt;= 0) {
&nbsp;                killer.format = KILLED_BY_AN;
&nbsp;                Strcpy(killer.name, "rotten lump of royal jelly");
&nbsp;                done(POISONING);
&nbsp;            }
&nbsp;        }
&nbsp;        if (!otmp-&gt;cursed)
&nbsp;            heal_legs();
&nbsp;        break;
&nbsp;    case EGG:
&nbsp;        if (flesh_petrifies(&amp;mons[otmp-&gt;corpsenm])) {
&nbsp;            if (!Stone_resistance
&nbsp;                &amp;&amp; !(poly_when_stoned(youmonst.data)
&nbsp;                     &amp;&amp; polymon(PM_STONE_GOLEM))) {
&nbsp;                if (!Stoned) {
&nbsp;                    Sprintf(killer.name, "%s egg",
&nbsp;                            mons[otmp-&gt;corpsenm].mname);
&nbsp;                    make_stoned(5L, (char *) 0, KILLED_BY_AN, killer.name);
&nbsp;                }
&nbsp;            }
&nbsp;            /* note: no "tastes like chicken" message for eggs */
&nbsp;        }
&nbsp;        break;
&nbsp;    case EUCALYPTUS_LEAF:
&nbsp;        if (Sick &amp;&amp; !otmp-&gt;cursed)
&nbsp;            make_sick(0L, (char *) 0, TRUE, SICK_ALL);
&nbsp;        if (Vomiting &amp;&amp; !otmp-&gt;cursed)
&nbsp;            make_vomiting(0L, TRUE);
&nbsp;        break;
&nbsp;    case APPLE:
&nbsp;        if (otmp-&gt;cursed &amp;&amp; !Sleep_resistance) {
&nbsp;            /* Snow White; 'poisoned' applies to [a subset of] weapons,
&nbsp;               not food, so we substitute cursed; fortunately our hero
&nbsp;               won't have to wait for a prince to be rescued/revived */
&nbsp;            if (Race_if(PM_DWARF) &amp;&amp; Hallucination)
&nbsp;                verbalize("Heigh-ho, ho-hum, I think I'll skip work today.");
&nbsp;            else if (Deaf || !flags.acoustics)
&nbsp;                You("fall asleep.");
&nbsp;            else
&nbsp;                You_hear("sinister laughter as you fall asleep...");
&nbsp;            fall_asleep(-rn1(11, 20), TRUE);
&nbsp;        }
&nbsp;        break;
&nbsp;    }
&nbsp;    return;
&nbsp;}
&nbsp;
leather_cover
&nbsp;#if 0
&nbsp;/* intended for eating a spellbook while polymorphed, but not used;
&nbsp;   "leather" applied to appearance, not composition, and has been
&nbsp;   changed to "leathery" to reflect that */
&nbsp;STATIC_DCL boolean FDECL(leather_cover, (struct obj *));
&nbsp;
&nbsp;STATIC_OVL boolean
&nbsp;leather_cover(otmp)
&nbsp;struct obj *otmp;
&nbsp;{
&nbsp;    const char *odesc = OBJ_DESCR(objects[otmp-&gt;otyp]);
&nbsp;
&nbsp;    if (odesc &amp;&amp; (otmp-&gt;oclass == SPBOOK_CLASS)) {
&nbsp;        if (!strcmp(odesc, "leather"))
&nbsp;            return TRUE;
&nbsp;    }
&nbsp;    return FALSE;
&nbsp;}
&nbsp;#endif
&nbsp;
edibility_prompts
&nbsp;/*
&nbsp; * return 0 if the food was not dangerous.
&nbsp; * return 1 if the food was dangerous and you chose to stop.
&nbsp; * return 2 if the food was dangerous and you chose to eat it anyway.
&nbsp; */
&nbsp;STATIC_OVL int
&nbsp;edibility_prompts(otmp)
&nbsp;struct obj *otmp;
&nbsp;{
&nbsp;    /* Blessed food detection grants hero a one-use
&nbsp;     * ability to detect food that is unfit for consumption
&nbsp;     * or dangerous and avoid it.
&nbsp;     */
&nbsp;    char buf[BUFSZ], foodsmell[BUFSZ],
&nbsp;         it_or_they[QBUFSZ], eat_it_anyway[QBUFSZ];
&nbsp;    boolean cadaver = (otmp-&gt;otyp == CORPSE || otmp-&gt;globby),
&nbsp;            stoneorslime = FALSE;
&nbsp;    int material = objects[otmp-&gt;otyp].oc_material, mnum = otmp-&gt;corpsenm;
&nbsp;    long rotted = 0L;
&nbsp;
&nbsp;    Strcpy(foodsmell, Tobjnam(otmp, "smell"));
&nbsp;    Strcpy(it_or_they, (otmp-&gt;quan == 1L) ? "it" : "they");
&nbsp;    Sprintf(eat_it_anyway, "Eat %s anyway?",
&nbsp;            (otmp-&gt;quan == 1L) ? "it" : "one");
&nbsp;
&nbsp;    if (cadaver || otmp-&gt;otyp == EGG || otmp-&gt;otyp == TIN) {
&nbsp;        /* These checks must match those in eatcorpse() */
&nbsp;        stoneorslime = (flesh_petrifies(&amp;mons[mnum]) &amp;&amp; !Stone_resistance
&nbsp;                        &amp;&amp; !poly_when_stoned(youmonst.data));
&nbsp;
&nbsp;        if (mnum == PM_GREEN_SLIME || otmp-&gt;otyp == GLOB_OF_GREEN_SLIME)
&nbsp;            stoneorslime = (!Unchanging &amp;&amp; !slimeproof(youmonst.data));
&nbsp;
&nbsp;        if (cadaver &amp;&amp; !nonrotting_corpse(mnum)) {
&nbsp;            long age = peek_at_iced_corpse_age(otmp);
&nbsp;
&nbsp;            /* worst case rather than random
&nbsp;               in this calculation to force prompt */
&nbsp;            rotted = (monstermoves - age) / (10L + 0 /* was rn2(20) */);
&nbsp;            if (otmp-&gt;cursed)
&nbsp;                rotted += 2L;
&nbsp;            else if (otmp-&gt;blessed)
&nbsp;                rotted -= 2L;
&nbsp;        }
&nbsp;    }
&nbsp;
&nbsp;    /*
&nbsp;     * These problems with food should be checked in
&nbsp;     * order from most detrimental to least detrimental.
&nbsp;     */
&nbsp;    if (cadaver &amp;&amp; mnum != PM_ACID_BLOB &amp;&amp; rotted &gt; 5L &amp;&amp; !Sick_resistance) {
&nbsp;        /* Tainted meat */
&nbsp;        Sprintf(buf, "%s like %s could be tainted! %s", foodsmell, it_or_they,
&nbsp;                eat_it_anyway);
&nbsp;        if (yn_function(buf, ynchars, 'n') == 'n')
&nbsp;            return 1;
&nbsp;        else
&nbsp;            return 2;
&nbsp;    }
&nbsp;    if (stoneorslime) {
&nbsp;        Sprintf(buf, "%s like %s could be something very dangerous! %s",
&nbsp;                foodsmell, it_or_they, eat_it_anyway);
&nbsp;        if (yn_function(buf, ynchars, 'n') == 'n')
&nbsp;            return 1;
&nbsp;        else
&nbsp;            return 2;
&nbsp;    }
&nbsp;    if (otmp-&gt;orotten || (cadaver &amp;&amp; rotted &gt; 3L)) {
&nbsp;        /* Rotten */
&nbsp;        Sprintf(buf, "%s like %s could be rotten! %s", foodsmell, it_or_they,
&nbsp;                eat_it_anyway);
&nbsp;        if (yn_function(buf, ynchars, 'n') == 'n')
&nbsp;            return 1;
&nbsp;        else
&nbsp;            return 2;
&nbsp;    }
&nbsp;    if (cadaver &amp;&amp; poisonous(&amp;mons[mnum]) &amp;&amp; !Poison_resistance) {
&nbsp;        /* poisonous */
&nbsp;        Sprintf(buf, "%s like %s might be poisonous! %s", foodsmell,
&nbsp;                it_or_they, eat_it_anyway);
&nbsp;        if (yn_function(buf, ynchars, 'n') == 'n')
&nbsp;            return 1;
&nbsp;        else
&nbsp;            return 2;
&nbsp;    }
&nbsp;    if (otmp-&gt;otyp == APPLE &amp;&amp; otmp-&gt;cursed &amp;&amp; !Sleep_resistance) {
&nbsp;        /* causes sleep, for long enough to be dangerous */
&nbsp;        Sprintf(buf, "%s like %s might have been poisoned. %s", foodsmell,
&nbsp;                it_or_they, eat_it_anyway);
&nbsp;        return (yn_function(buf, ynchars, 'n') == 'n') ? 1 : 2;
&nbsp;    }
&nbsp;    if (cadaver &amp;&amp; !vegetarian(&amp;mons[mnum]) &amp;&amp; !u.uconduct.unvegetarian
&nbsp;        &amp;&amp; Role_if(PM_MONK)) {
&nbsp;        Sprintf(buf, "%s unhealthy. %s", foodsmell, eat_it_anyway);
&nbsp;        if (yn_function(buf, ynchars, 'n') == 'n')
&nbsp;            return 1;
&nbsp;        else
&nbsp;            return 2;
&nbsp;    }
&nbsp;    if (cadaver &amp;&amp; acidic(&amp;mons[mnum]) &amp;&amp; !Acid_resistance) {
&nbsp;        Sprintf(buf, "%s rather acidic. %s", foodsmell, eat_it_anyway);
&nbsp;        if (yn_function(buf, ynchars, 'n') == 'n')
&nbsp;            return 1;
&nbsp;        else
&nbsp;            return 2;
&nbsp;    }
&nbsp;    if (Upolyd &amp;&amp; u.umonnum == PM_RUST_MONSTER &amp;&amp; is_metallic(otmp)
&nbsp;        &amp;&amp; otmp-&gt;oerodeproof) {
&nbsp;        Sprintf(buf, "%s disgusting to you right now. %s", foodsmell,
&nbsp;                eat_it_anyway);
&nbsp;        if (yn_function(buf, ynchars, 'n') == 'n')
&nbsp;            return 1;
&nbsp;        else
&nbsp;            return 2;
&nbsp;    }
&nbsp;
&nbsp;    /*
&nbsp;     * Breaks conduct, but otherwise safe.
&nbsp;     */
&nbsp;    if (!u.uconduct.unvegan
&nbsp;        &amp;&amp; ((material == LEATHER || material == BONE
&nbsp;             || material == DRAGON_HIDE || material == WAX)
&nbsp;            || (cadaver &amp;&amp; !vegan(&amp;mons[mnum])))) {
&nbsp;        Sprintf(buf, "%s foul and unfamiliar to you. %s", foodsmell,
&nbsp;                eat_it_anyway);
&nbsp;        if (yn_function(buf, ynchars, 'n') == 'n')
&nbsp;            return 1;
&nbsp;        else
&nbsp;            return 2;
&nbsp;    }
&nbsp;    if (!u.uconduct.unvegetarian
&nbsp;        &amp;&amp; ((material == LEATHER || material == BONE
&nbsp;             || material == DRAGON_HIDE)
&nbsp;            || (cadaver &amp;&amp; !vegetarian(&amp;mons[mnum])))) {
&nbsp;        Sprintf(buf, "%s unfamiliar to you. %s", foodsmell, eat_it_anyway);
&nbsp;        if (yn_function(buf, ynchars, 'n') == 'n')
&nbsp;            return 1;
&nbsp;        else
&nbsp;            return 2;
&nbsp;    }
&nbsp;
&nbsp;    if (cadaver &amp;&amp; mnum != PM_ACID_BLOB &amp;&amp; rotted &gt; 5L &amp;&amp; Sick_resistance) {
&nbsp;        /* Tainted meat with Sick_resistance */
&nbsp;        Sprintf(buf, "%s like %s could be tainted! %s", foodsmell, it_or_they,
&nbsp;                eat_it_anyway);
&nbsp;        if (yn_function(buf, ynchars, 'n') == 'n')
&nbsp;            return 1;
&nbsp;        else
&nbsp;            return 2;
&nbsp;    }
&nbsp;    return 0;
&nbsp;}
&nbsp;
doeat
&nbsp;/* 'e' command */
&nbsp;int
&nbsp;doeat()
&nbsp;{
&nbsp;    struct obj *otmp;
&nbsp;    int basenutrit; /* nutrition of full item */
&nbsp;    boolean dont_start = FALSE, nodelicious = FALSE;
&nbsp;
&nbsp;    if (Strangled) {
&nbsp;        pline("If you can't breathe air, how can you consume solids?");
&nbsp;        return 0;
&nbsp;    }
&nbsp;    if (!(otmp = floorfood("eat", 0)))
&nbsp;        return 0;
&nbsp;    if (check_capacity((char *) 0))
&nbsp;        return 0;
&nbsp;
&nbsp;    if (u.uedibility) {
&nbsp;        int res = edibility_prompts(otmp);
&nbsp;
&nbsp;        if (res) {
&nbsp;            Your(
&nbsp;               "%s stops tingling and your sense of smell returns to normal.",
&nbsp;                 body_part(NOSE));
&nbsp;            u.uedibility = 0;
&nbsp;            if (res == 1)
&nbsp;                return 0;
&nbsp;        }
&nbsp;    }
&nbsp;
&nbsp;    /* We have to make non-foods take 1 move to eat, unless we want to
&nbsp;     * do ridiculous amounts of coding to deal with partly eaten plate
&nbsp;     * mails, players who polymorph back to human in the middle of their
&nbsp;     * metallic meal, etc....
&nbsp;     */
&nbsp;    if (!is_edible(otmp)) {
&nbsp;        You("cannot eat that!");
&nbsp;        return 0;
&nbsp;    } else if ((otmp-&gt;owornmask &amp; (W_ARMOR | W_TOOL | W_AMUL | W_SADDLE))
&nbsp;               != 0) {
&nbsp;        /* let them eat rings */
&nbsp;        You_cant("eat %s you're wearing.", something);
&nbsp;        return 0;
&nbsp;    } else if (!(carried(otmp) ? retouch_object(&amp;otmp, FALSE)
&nbsp;                               : touch_artifact(otmp, &amp;youmonst))) {
&nbsp;        return 1; /* got blasted so use a turn */
&nbsp;    }
&nbsp;    if (is_metallic(otmp) &amp;&amp; u.umonnum == PM_RUST_MONSTER
&nbsp;        &amp;&amp; otmp-&gt;oerodeproof) {
&nbsp;        otmp-&gt;rknown = TRUE;
&nbsp;        if (otmp-&gt;quan &gt; 1L) {
&nbsp;            if (!carried(otmp))
&nbsp;                (void) splitobj(otmp, otmp-&gt;quan - 1L);
&nbsp;            else
&nbsp;                otmp = splitobj(otmp, 1L);
&nbsp;        }
&nbsp;        pline("Ulch - that %s was rustproofed!", xname(otmp));
&nbsp;        /* The regurgitated object's rustproofing is gone now */
&nbsp;        otmp-&gt;oerodeproof = 0;
&nbsp;        make_stunned((HStun &amp; TIMEOUT) + (long) rn2(10), TRUE);
&nbsp;        /*
&nbsp;         * We don't expect rust monsters to be wielding welded weapons
&nbsp;         * or wearing cursed rings which were rustproofed, but guard
&nbsp;         * against the possibility just in case.
&nbsp;         */
&nbsp;        if (welded(otmp) || (otmp-&gt;cursed &amp;&amp; (otmp-&gt;owornmask &amp; W_RING))) {
&nbsp;            otmp-&gt;bknown = 1; /* for ring; welded() does this for weapon */
&nbsp;            You("spit out %s.", the(xname(otmp)));
&nbsp;        } else {
&nbsp;            You("spit %s out onto the %s.", the(xname(otmp)),
&nbsp;                surface(u.ux, u.uy));
&nbsp;            if (carried(otmp)) {
&nbsp;                /* no need to check for leash in use; it's not metallic */
&nbsp;                if (otmp-&gt;owornmask)
&nbsp;                    remove_worn_item(otmp, FALSE);
&nbsp;                freeinv(otmp);
&nbsp;                dropy(otmp);
&nbsp;            }
&nbsp;            stackobj(otmp);
&nbsp;        }
&nbsp;        return 1;
&nbsp;    }
&nbsp;    /* KMH -- Slow digestion is... indigestible */
&nbsp;    if (otmp-&gt;otyp == RIN_SLOW_DIGESTION) {
&nbsp;        pline("This ring is indigestible!");
&nbsp;        (void) rottenfood(otmp);
&nbsp;        if (otmp-&gt;dknown &amp;&amp; !objects[otmp-&gt;otyp].oc_name_known
&nbsp;            &amp;&amp; !objects[otmp-&gt;otyp].oc_uname)
&nbsp;            docall(otmp);
&nbsp;        return 1;
&nbsp;    }
&nbsp;    if (otmp-&gt;oclass != FOOD_CLASS) {
&nbsp;        int material;
&nbsp;
&nbsp;        context.victual.reqtime = 1;
&nbsp;        context.victual.piece = otmp;
&nbsp;        context.victual.o_id = otmp-&gt;o_id;
&nbsp;        /* Don't split it, we don't need to if it's 1 move */
&nbsp;        context.victual.usedtime = 0;
&nbsp;        context.victual.canchoke = (u.uhs == SATIATED);
&nbsp;        /* Note: gold weighs 1 pt. for each 1000 pieces (see
&nbsp;           pickup.c) so gold and non-gold is consistent. */
&nbsp;        if (otmp-&gt;oclass == COIN_CLASS)
&nbsp;            basenutrit = ((otmp-&gt;quan &gt; 200000L)
&nbsp;                             ? 2000
&nbsp;                             : (int) (otmp-&gt;quan / 100L));
&nbsp;        else if (otmp-&gt;oclass == BALL_CLASS || otmp-&gt;oclass == CHAIN_CLASS)
&nbsp;            basenutrit = weight(otmp);
&nbsp;        /* oc_nutrition is usually weight anyway */
&nbsp;        else
&nbsp;            basenutrit = objects[otmp-&gt;otyp].oc_nutrition;
&nbsp;#ifdef MAIL
&nbsp;        if (otmp-&gt;otyp == SCR_MAIL) {
&nbsp;            basenutrit = 0;
&nbsp;            nodelicious = TRUE;
&nbsp;        }
&nbsp;#endif
&nbsp;        context.victual.nmod = basenutrit;
&nbsp;        context.victual.eating = TRUE; /* needed for lesshungry() */
&nbsp;
&nbsp;        material = objects[otmp-&gt;otyp].oc_material;
&nbsp;        if (material == LEATHER || material == BONE
&nbsp;            || material == DRAGON_HIDE) {
&nbsp;            u.uconduct.unvegan++;
&nbsp;            violated_vegetarian();
&nbsp;        } else if (material == WAX)
&nbsp;            u.uconduct.unvegan++;
&nbsp;        u.uconduct.food++;
&nbsp;
&nbsp;        if (otmp-&gt;cursed) {
&nbsp;            (void) rottenfood(otmp);
&nbsp;            nodelicious = TRUE;
&nbsp;        } else if (objects[otmp-&gt;otyp].oc_material == PAPER)
&nbsp;            nodelicious = TRUE;
&nbsp;
&nbsp;        if (otmp-&gt;oclass == WEAPON_CLASS &amp;&amp; otmp-&gt;opoisoned) {
&nbsp;            pline("Ecch - that must have been poisonous!");
&nbsp;            if (!Poison_resistance) {
&nbsp;                losestr(rnd(4));
&nbsp;                losehp(rnd(15), xname(otmp), KILLED_BY_AN);
&nbsp;            } else
&nbsp;                You("seem unaffected by the poison.");
&nbsp;        } else if (!nodelicious) {
&nbsp;            pline("%s%s is delicious!",
&nbsp;                  (obj_is_pname(otmp)
&nbsp;                   &amp;&amp; otmp-&gt;oartifact &lt; ART_ORB_OF_DETECTION)
&nbsp;                      ? ""
&nbsp;                      : "This ",
&nbsp;                  (otmp-&gt;oclass == COIN_CLASS)
&nbsp;                      ? foodword(otmp)
&nbsp;                      : singular(otmp, xname));
&nbsp;        }
&nbsp;        eatspecial();
&nbsp;        return 1;
&nbsp;    }
&nbsp;
&nbsp;    if (otmp == context.victual.piece) {
&nbsp;        /* If they weren't able to choke, they don't suddenly become able to
&nbsp;         * choke just because they were interrupted.  On the other hand, if
&nbsp;         * they were able to choke before, if they lost food it's possible
&nbsp;         * they shouldn't be able to choke now.
&nbsp;         */
&nbsp;        if (u.uhs != SATIATED)
&nbsp;            context.victual.canchoke = FALSE;
&nbsp;        context.victual.o_id = 0;
&nbsp;        context.victual.piece = touchfood(otmp);
&nbsp;        if (context.victual.piece)
&nbsp;            context.victual.o_id = context.victual.piece-&gt;o_id;
&nbsp;        You("resume your meal.");
&nbsp;        start_eating(context.victual.piece);
&nbsp;        return 1;
&nbsp;    }
&nbsp;
&nbsp;    /* nothing in progress - so try to find something. */
&nbsp;    /* tins are a special case */
&nbsp;    /* tins must also check conduct separately in case they're discarded */
&nbsp;    if (otmp-&gt;otyp == TIN) {
&nbsp;        start_tin(otmp);
&nbsp;        return 1;
&nbsp;    }
&nbsp;
&nbsp;    /* KMH, conduct */
&nbsp;    u.uconduct.food++;
&nbsp;
&nbsp;    context.victual.o_id = 0;
&nbsp;    context.victual.piece = otmp = touchfood(otmp);
&nbsp;    if (context.victual.piece)
&nbsp;        context.victual.o_id = context.victual.piece-&gt;o_id;
&nbsp;    context.victual.usedtime = 0;
&nbsp;
&nbsp;    /* Now we need to calculate delay and nutritional info.
&nbsp;     * The base nutrition calculated here and in eatcorpse() accounts
&nbsp;     * for normal vs. rotten food.  The reqtime and nutrit values are
&nbsp;     * then adjusted in accordance with the amount of food left.
&nbsp;     */
&nbsp;    if (otmp-&gt;otyp == CORPSE || otmp-&gt;globby) {
&nbsp;        int tmp = eatcorpse(otmp);
&nbsp;
&nbsp;        if (tmp == 2) {
&nbsp;            /* used up */
&nbsp;            context.victual.piece = (struct obj *) 0;
&nbsp;            context.victual.o_id = 0;
&nbsp;            return 1;
&nbsp;        } else if (tmp)
&nbsp;            dont_start = TRUE;
&nbsp;        /* if not used up, eatcorpse sets up reqtime and may modify oeaten */
&nbsp;    } else {
&nbsp;        /* No checks for WAX, LEATHER, BONE, DRAGON_HIDE.  These are
&nbsp;         * all handled in the != FOOD_CLASS case, above.
&nbsp;         */
&nbsp;        switch (objects[otmp-&gt;otyp].oc_material) {
&nbsp;        case FLESH:
&nbsp;            u.uconduct.unvegan++;
&nbsp;            if (otmp-&gt;otyp != EGG) {
&nbsp;                violated_vegetarian();
&nbsp;            }
&nbsp;            break;
&nbsp;
&nbsp;        default:
&nbsp;            if (otmp-&gt;otyp == PANCAKE || otmp-&gt;otyp == FORTUNE_COOKIE /*eggs*/
&nbsp;                || otmp-&gt;otyp == CREAM_PIE || otmp-&gt;otyp == CANDY_BAR /*milk*/
&nbsp;                || otmp-&gt;otyp == LUMP_OF_ROYAL_JELLY)
&nbsp;                u.uconduct.unvegan++;
&nbsp;            break;
&nbsp;        }
&nbsp;
&nbsp;        context.victual.reqtime = objects[otmp-&gt;otyp].oc_delay;
&nbsp;        if (otmp-&gt;otyp != FORTUNE_COOKIE
&nbsp;            &amp;&amp; (otmp-&gt;cursed || (!nonrotting_food(otmp-&gt;otyp)
&nbsp;                                 &amp;&amp; (monstermoves - otmp-&gt;age)
&nbsp;                                        &gt; (otmp-&gt;blessed ? 50L : 30L)
&nbsp;                                 &amp;&amp; (otmp-&gt;orotten || !rn2(7))))) {
&nbsp;            if (rottenfood(otmp)) {
&nbsp;                otmp-&gt;orotten = TRUE;
&nbsp;                dont_start = TRUE;
&nbsp;            }
&nbsp;            consume_oeaten(otmp, 1); /* oeaten &gt;&gt;= 1 */
&nbsp;        } else
&nbsp;            fprefx(otmp);
&nbsp;    }
&nbsp;
&nbsp;    /* re-calc the nutrition */
&nbsp;    basenutrit = (int) obj_nutrition(otmp);
&nbsp;
&nbsp;    debugpline3(
&nbsp;     "before rounddiv: victual.reqtime == %d, oeaten == %d, basenutrit == %d",
&nbsp;                context.victual.reqtime, otmp-&gt;oeaten, basenutrit);
&nbsp;
&nbsp;    context.victual.reqtime = (basenutrit == 0) ? 0
&nbsp;        : rounddiv(context.victual.reqtime * (long) otmp-&gt;oeaten, basenutrit);
&nbsp;
&nbsp;    debugpline1("after rounddiv: victual.reqtime == %d",
&nbsp;                context.victual.reqtime);
&nbsp;    /*
&nbsp;     * calculate the modulo value (nutrit. units per round eating)
&nbsp;     * note: this isn't exact - you actually lose a little nutrition due
&nbsp;     *       to this method.
&nbsp;     * TODO: add in a "remainder" value to be given at the end of the meal.
&nbsp;     */
&nbsp;    if (context.victual.reqtime == 0 || otmp-&gt;oeaten == 0)
&nbsp;        /* possible if most has been eaten before */
&nbsp;        context.victual.nmod = 0;
&nbsp;    else if ((int) otmp-&gt;oeaten &gt;= context.victual.reqtime)
&nbsp;        context.victual.nmod = -((int) otmp-&gt;oeaten
&nbsp;                                 / context.victual.reqtime);
&nbsp;    else
&nbsp;        context.victual.nmod = context.victual.reqtime % otmp-&gt;oeaten;
&nbsp;    context.victual.canchoke = (u.uhs == SATIATED);
&nbsp;
&nbsp;    if (!dont_start)
&nbsp;        start_eating(otmp);
&nbsp;    return 1;
&nbsp;}
&nbsp;
use_tin_opener
&nbsp;int
&nbsp;use_tin_opener(obj)
&nbsp;struct obj *obj;
&nbsp;{
&nbsp;    struct obj *otmp;
&nbsp;    int res = 0;
&nbsp;
&nbsp;    if (!carrying(TIN)) {
&nbsp;        You("have no tin to open.");
&nbsp;        return 0;
&nbsp;    }
&nbsp;
&nbsp;    if (obj != uwep) {
&nbsp;        if (obj-&gt;cursed &amp;&amp; obj-&gt;bknown) {
&nbsp;            char qbuf[QBUFSZ];
&nbsp;
&nbsp;            if (ynq(safe_qbuf(qbuf, "Really wield ", "?",
&nbsp;                              obj, doname, thesimpleoname, "that")) != 'y')
&nbsp;                return 0;
&nbsp;        }
&nbsp;        if (!wield_tool(obj, "use"))
&nbsp;            return 0;
&nbsp;        res = 1;
&nbsp;    }
&nbsp;
&nbsp;    otmp = getobj(comestibles, "open");
&nbsp;    if (!otmp)
&nbsp;        return res;
&nbsp;
&nbsp;    start_tin(otmp);
&nbsp;    return 1;
&nbsp;}
&nbsp;
bite
&nbsp;/* Take a single bite from a piece of food, checking for choking and
&nbsp; * modifying usedtime.  Returns 1 if they choked and survived, 0 otherwise.
&nbsp; */
&nbsp;STATIC_OVL int
&nbsp;bite()
&nbsp;{
&nbsp;    if (context.victual.canchoke &amp;&amp; u.uhunger &gt;= 2000) {
&nbsp;        choke(context.victual.piece);
&nbsp;        return 1;
&nbsp;    }
&nbsp;    if (context.victual.doreset) {
&nbsp;        do_reset_eat();
&nbsp;        return 0;
&nbsp;    }
&nbsp;    force_save_hs = TRUE;
&nbsp;    if (context.victual.nmod &lt; 0) {
&nbsp;        lesshungry(-context.victual.nmod);
&nbsp;        consume_oeaten(context.victual.piece,
&nbsp;                       context.victual.nmod); /* -= -nmod */
&nbsp;    } else if (context.victual.nmod &gt; 0
&nbsp;               &amp;&amp; (context.victual.usedtime % context.victual.nmod)) {
&nbsp;        lesshungry(1);
&nbsp;        consume_oeaten(context.victual.piece, -1); /* -= 1 */
&nbsp;    }
&nbsp;    force_save_hs = FALSE;
&nbsp;    recalc_wt();
&nbsp;    return 0;
&nbsp;}
&nbsp;
gethungry
&nbsp;/* as time goes by - called by moveloop(every move) &amp; domove(melee attack) */
&nbsp;void
&nbsp;gethungry()
&nbsp;{
&nbsp;    if (u.uinvulnerable)
&nbsp;        return; /* you don't feel hungrier */
&nbsp;
&nbsp;    /* being polymorphed into a creature which doesn't eat prevents
&nbsp;       this first uhunger decrement, but to stay in such form the hero
&nbsp;       will need to wear an Amulet of Unchanging so still burn a small
&nbsp;       amount of nutrition in the 'moves % 20' ring/amulet check below */
&nbsp;    if ((!Unaware || !rn2(10)) /* slow metabolic rate while asleep */
&nbsp;        &amp;&amp; (carnivorous(youmonst.data)
&nbsp;            || herbivorous(youmonst.data)
&nbsp;            || metallivorous(youmonst.data))
&nbsp;        &amp;&amp; !Slow_digestion)
&nbsp;        u.uhunger--; /* ordinary food consumption */
&nbsp;
&nbsp;    if (moves % 2) { /* odd turns */
&nbsp;        /* Regeneration uses up food, unless due to an artifact */
&nbsp;        if ((HRegeneration &amp; ~FROMFORM)
&nbsp;            || (ERegeneration &amp; ~(W_ARTI | W_WEP)))
&nbsp;            u.uhunger--;
&nbsp;        if (near_capacity() &gt; SLT_ENCUMBER)
&nbsp;            u.uhunger--;
&nbsp;    } else { /* even turns */
&nbsp;        if (Hunger)
&nbsp;            u.uhunger--;
&nbsp;        /* Conflict uses up food too */
&nbsp;        if (HConflict || (EConflict &amp; (~W_ARTI)))
&nbsp;            u.uhunger--;
&nbsp;        /* +0 charged rings don't do anything, so don't affect hunger.
&nbsp;           Slow digestion cancels move hunger but still causes ring hunger. */
&nbsp;        switch ((int) (moves % 20)) { /* note: use even cases only */
&nbsp;        case 4:
&nbsp;            if (uleft &amp;&amp; (uleft-&gt;spe || !objects[uleft-&gt;otyp].oc_charged))
&nbsp;                u.uhunger--;
&nbsp;            break;
&nbsp;        case 8:
&nbsp;            if (uamul)
&nbsp;                u.uhunger--;
&nbsp;            break;
&nbsp;        case 12:
&nbsp;            if (uright &amp;&amp; (uright-&gt;spe || !objects[uright-&gt;otyp].oc_charged))
&nbsp;                u.uhunger--;
&nbsp;            break;
&nbsp;        case 16:
&nbsp;            if (u.uhave.amulet)
&nbsp;                u.uhunger--;
&nbsp;            break;
&nbsp;        default:
&nbsp;            break;
&nbsp;        }
&nbsp;    }
&nbsp;    newuhs(TRUE);
&nbsp;}
&nbsp;
morehungry
&nbsp;/* called after vomiting and after performing feats of magic */
&nbsp;void
&nbsp;morehungry(num)
&nbsp;int num;
&nbsp;{
&nbsp;    u.uhunger -= num;
&nbsp;    newuhs(TRUE);
&nbsp;}
&nbsp;
lesshungry
&nbsp;/* called after eating (and after drinking fruit juice) */
&nbsp;void
&nbsp;lesshungry(num)
&nbsp;int num;
&nbsp;{
&nbsp;    /* See comments in newuhs() for discussion on force_save_hs */
&nbsp;    boolean iseating = (occupation == eatfood) || force_save_hs;
&nbsp;
&nbsp;    debugpline1("lesshungry(%d)", num);
&nbsp;    u.uhunger += num;
&nbsp;    if (u.uhunger &gt;= 2000) {
&nbsp;        if (!iseating || context.victual.canchoke) {
&nbsp;            if (iseating) {
&nbsp;                choke(context.victual.piece);
&nbsp;                reset_eat();
&nbsp;            } else
&nbsp;                choke(occupation == opentin ? context.tin.tin
&nbsp;                                            : (struct obj *) 0);
&nbsp;            /* no reset_eat() */
&nbsp;        }
&nbsp;    } else {
&nbsp;        /* Have lesshungry() report when you're nearly full so all eating
&nbsp;         * warns when you're about to choke.
&nbsp;         */
&nbsp;        if (u.uhunger &gt;= 1500) {
&nbsp;            if (!context.victual.eating
&nbsp;                || (context.victual.eating &amp;&amp; !context.victual.fullwarn)) {
&nbsp;                pline("You're having a hard time getting all of it down.");
&nbsp;                nomovemsg = "You're finally finished.";
&nbsp;                if (!context.victual.eating) {
&nbsp;                    multi = -2;
&nbsp;                } else {
&nbsp;                    context.victual.fullwarn = TRUE;
&nbsp;                    if (context.victual.canchoke
&nbsp;                        &amp;&amp; context.victual.reqtime &gt; 1) {
&nbsp;                        /* a one-gulp food will not survive a stop */
&nbsp;                        if (yn_function("Continue eating?", ynchars, 'n')
&nbsp;                            != 'y') {
&nbsp;                            reset_eat();
&nbsp;                            nomovemsg = (char *) 0;
&nbsp;                        }
&nbsp;                    }
&nbsp;                }
&nbsp;            }
&nbsp;        }
&nbsp;    }
&nbsp;    newuhs(FALSE);
&nbsp;}
&nbsp;
unfaint
&nbsp;STATIC_PTR
&nbsp;int
&nbsp;unfaint(VOID_ARGS)
&nbsp;{
&nbsp;    (void) Hear_again();
&nbsp;    if (u.uhs &gt; FAINTING)
&nbsp;        u.uhs = FAINTING;
&nbsp;    stop_occupation();
&nbsp;    context.botl = 1;
&nbsp;    return 0;
&nbsp;}
&nbsp;
is_fainted
&nbsp;boolean
&nbsp;is_fainted()
&nbsp;{
&nbsp;    return (boolean) (u.uhs == FAINTED);
&nbsp;}
&nbsp;
reset_faint
&nbsp;/* call when a faint must be prematurely terminated */
&nbsp;void
&nbsp;reset_faint()
&nbsp;{
&nbsp;    if (afternmv == unfaint)
&nbsp;        unmul("You revive.");
&nbsp;}
&nbsp;
newuhs
&nbsp;/* compute and comment on your (new?) hunger status */
&nbsp;void
&nbsp;newuhs(incr)
&nbsp;boolean incr;
&nbsp;{
&nbsp;    unsigned newhs;
&nbsp;    static unsigned save_hs;
&nbsp;    static boolean saved_hs = FALSE;
&nbsp;    int h = u.uhunger;
&nbsp;
&nbsp;    newhs = (h &gt; 1000)
&nbsp;                ? SATIATED
&nbsp;                : (h &gt; 150) ? NOT_HUNGRY
&nbsp;                            : (h &gt; 50) ? HUNGRY : (h &gt; 0) ? WEAK : FAINTING;
&nbsp;
&nbsp;    /* While you're eating, you may pass from WEAK to HUNGRY to NOT_HUNGRY.
&nbsp;     * This should not produce the message "you only feel hungry now";
&nbsp;     * that message should only appear if HUNGRY is an endpoint.  Therefore
&nbsp;     * we check to see if we're in the middle of eating.  If so, we save
&nbsp;     * the first hunger status, and at the end of eating we decide what
&nbsp;     * message to print based on the _entire_ meal, not on each little bit.
&nbsp;     */
&nbsp;    /* It is normally possible to check if you are in the middle of a meal
&nbsp;     * by checking occupation == eatfood, but there is one special case:
&nbsp;     * start_eating() can call bite() for your first bite before it
&nbsp;     * sets the occupation.
&nbsp;     * Anyone who wants to get that case to work _without_ an ugly static
&nbsp;     * force_save_hs variable, feel free.
&nbsp;     */
&nbsp;    /* Note: If you become a certain hunger status in the middle of the
&nbsp;     * meal, and still have that same status at the end of the meal,
&nbsp;     * this will incorrectly print the associated message at the end of
&nbsp;     * the meal instead of the middle.  Such a case is currently
&nbsp;     * impossible, but could become possible if a message for SATIATED
&nbsp;     * were added or if HUNGRY and WEAK were separated by a big enough
&nbsp;     * gap to fit two bites.
&nbsp;     */
&nbsp;    if (occupation == eatfood || force_save_hs) {
&nbsp;        if (!saved_hs) {
&nbsp;            save_hs = u.uhs;
&nbsp;            saved_hs = TRUE;
&nbsp;        }
&nbsp;        u.uhs = newhs;
&nbsp;        return;
&nbsp;    } else {
&nbsp;        if (saved_hs) {
&nbsp;            u.uhs = save_hs;
&nbsp;            saved_hs = FALSE;
&nbsp;        }
&nbsp;    }
&nbsp;
&nbsp;    if (newhs == FAINTING) {
&nbsp;        /* u,uhunger is likely to be negative at this point */
&nbsp;        int uhunger_div_by_10 = sgn(u.uhunger) * ((abs(u.uhunger) + 5) / 10);
&nbsp;
&nbsp;        if (is_fainted())
&nbsp;            newhs = FAINTED;
&nbsp;        if (u.uhs &lt;= WEAK || rn2(20 - uhunger_div_by_10) &gt;= 19) {
&nbsp;            if (!is_fainted() &amp;&amp; multi &gt;= 0 /* %% */) {
&nbsp;                int duration = 10 - uhunger_div_by_10;
&nbsp;
&nbsp;                /* stop what you're doing, then faint */
&nbsp;                stop_occupation();
&nbsp;                You("faint from lack of food.");
&nbsp;                incr_itimeout(&amp;HDeaf, duration);
&nbsp;                context.botl = TRUE;
&nbsp;                nomul(-duration);
&nbsp;                multi_reason = "fainted from lack of food";
&nbsp;                nomovemsg = "You regain consciousness.";
&nbsp;                afternmv = unfaint;
&nbsp;                newhs = FAINTED;
&nbsp;                if (!Levitation)
&nbsp;                    selftouch("Falling, you");
&nbsp;            }
&nbsp;
&nbsp;        /* this used to be -(200 + 20 * Con) but that was when being asleep
&nbsp;           suppressed per-turn uhunger decrement but being fainted didn't;
&nbsp;           now uhunger becomes more negative at a slower rate */
&nbsp;        } else if (u.uhunger &lt; -(100 + 10 * (int) ACURR(A_CON))) {
&nbsp;            u.uhs = STARVED;
&nbsp;            context.botl = 1;
&nbsp;            bot();
&nbsp;            You("die from starvation.");
&nbsp;            killer.format = KILLED_BY;
&nbsp;            Strcpy(killer.name, "starvation");
&nbsp;            done(STARVING);
&nbsp;            /* if we return, we lifesaved, and that calls newuhs */
&nbsp;            return;
&nbsp;        }
&nbsp;    }
&nbsp;
&nbsp;    if (newhs != u.uhs) {
&nbsp;        if (newhs &gt;= WEAK &amp;&amp; u.uhs &lt; WEAK) {
&nbsp;            /* this used to be losestr(1) which had the potential to
&nbsp;               be fatal (still handled below) by reducing HP if it
&nbsp;               tried to take base strength below minimum of 3 */
&nbsp;            ATEMP(A_STR) = -1; /* temporary loss overrides Fixed_abil */
&nbsp;            /* defer context.botl status update until after hunger message */
&nbsp;        } else if (newhs &lt; WEAK &amp;&amp; u.uhs &gt;= WEAK) {
&nbsp;            /* this used to be losestr(-1) which could be abused by
&nbsp;               becoming weak while wearing ring of sustain ability,
&nbsp;               removing ring, eating to 'restore' strength which boosted
&nbsp;               strength by a point each time the cycle was performed;
&nbsp;               substituting "while polymorphed" for sustain ability and
&nbsp;               "rehumanize" for ring removal might have done that too */
&nbsp;            ATEMP(A_STR) = 0; /* repair of loss also overrides Fixed_abil */
&nbsp;            /* defer context.botl status update until after hunger message */
&nbsp;        }
&nbsp;
&nbsp;        switch (newhs) {
&nbsp;        case HUNGRY:
&nbsp;            if (Hallucination) {
&nbsp;                You((!incr) ? "now have a lesser case of the munchies."
&nbsp;                            : "are getting the munchies.");
&nbsp;            } else
&nbsp;                You((!incr) ? "only feel hungry now."
&nbsp;                            : (u.uhunger &lt; 145)
&nbsp;                                  ? "feel hungry."
&nbsp;                                  : "are beginning to feel hungry.");
&nbsp;            if (incr &amp;&amp; occupation
&nbsp;                &amp;&amp; (occupation != eatfood &amp;&amp; occupation != opentin))
&nbsp;                stop_occupation();
&nbsp;            context.travel = context.travel1 = context.mv = context.run = 0;
&nbsp;            break;
&nbsp;        case WEAK:
&nbsp;            if (Hallucination)
&nbsp;                pline((!incr) ? "You still have the munchies."
&nbsp;              : "The munchies are interfering with your motor capabilities.");
&nbsp;            else if (incr &amp;&amp; (Role_if(PM_WIZARD) || Race_if(PM_ELF)
&nbsp;                              || Role_if(PM_VALKYRIE)))
&nbsp;                pline("%s needs food, badly!",
&nbsp;                      (Role_if(PM_WIZARD) || Role_if(PM_VALKYRIE))
&nbsp;                          ? urole.name.m
&nbsp;                          : "Elf");
&nbsp;            else
&nbsp;                You((!incr)
&nbsp;                        ? "feel weak now."
&nbsp;                        : (u.uhunger &lt; 45) ? "feel weak."
&nbsp;                                           : "are beginning to feel weak.");
&nbsp;            if (incr &amp;&amp; occupation
&nbsp;                &amp;&amp; (occupation != eatfood &amp;&amp; occupation != opentin))
&nbsp;                stop_occupation();
&nbsp;            context.travel = context.travel1 = context.mv = context.run = 0;
&nbsp;            break;
&nbsp;        }
&nbsp;        u.uhs = newhs;
&nbsp;        context.botl = 1;
&nbsp;        bot();
&nbsp;        if ((Upolyd ? u.mh : u.uhp) &lt; 1) {
&nbsp;            You("die from hunger and exhaustion.");
&nbsp;            killer.format = KILLED_BY;
&nbsp;            Strcpy(killer.name, "exhaustion");
&nbsp;            done(STARVING);
&nbsp;            return;
&nbsp;        }
&nbsp;    }
&nbsp;}
&nbsp;
floorfood
&nbsp;/* Returns an object representing food.
&nbsp; * Object may be either on floor or in inventory.
&nbsp; */
&nbsp;struct obj *
&nbsp;floorfood(verb, corpsecheck)
&nbsp;const char *verb;
&nbsp;int corpsecheck; /* 0, no check, 1, corpses, 2, tinnable corpses */
&nbsp;{
&nbsp;    register struct obj *otmp;
&nbsp;    char qbuf[QBUFSZ];
&nbsp;    char c;
&nbsp;    boolean feeding = !strcmp(verb, "eat"),    /* corpsecheck==0 */
&nbsp;        offering = !strcmp(verb, "sacrifice"); /* corpsecheck==1 */
&nbsp;
&nbsp;    /* if we can't touch floor objects then use invent food only */
&nbsp;    if (iflags.menu_requested /* command was preceded by 'm' prefix */
&nbsp;        || !can_reach_floor(TRUE) || (feeding &amp;&amp; u.usteed)
&nbsp;        || (is_pool_or_lava(u.ux, u.uy)
&nbsp;            &amp;&amp; (Wwalking || is_clinger(youmonst.data)
&nbsp;                || (Flying &amp;&amp; !Breathless))))
&nbsp;        goto skipfloor;
&nbsp;
&nbsp;    if (feeding &amp;&amp; metallivorous(youmonst.data)) {
&nbsp;        struct obj *gold;
&nbsp;        struct trap *ttmp = t_at(u.ux, u.uy);
&nbsp;
&nbsp;        if (ttmp &amp;&amp; ttmp-&gt;tseen &amp;&amp; ttmp-&gt;ttyp == BEAR_TRAP) {
&nbsp;            /* If not already stuck in the trap, perhaps there should
&nbsp;               be a chance to becoming trapped?  Probably not, because
&nbsp;               then the trap would just get eaten on the _next_ turn... */
&nbsp;            Sprintf(qbuf, "There is a bear trap here (%s); eat it?",
&nbsp;                    (u.utrap &amp;&amp; u.utraptype == TT_BEARTRAP) ? "holding you"
&nbsp;                                                            : "armed");
&nbsp;            if ((c = yn_function(qbuf, ynqchars, 'n')) == 'y') {
&nbsp;                u.utrap = u.utraptype = 0;
&nbsp;                deltrap(ttmp);
&nbsp;                return mksobj(BEARTRAP, TRUE, FALSE);
&nbsp;            } else if (c == 'q') {
&nbsp;                return (struct obj *) 0;
&nbsp;            }
&nbsp;        }
&nbsp;
&nbsp;        if (youmonst.data != &amp;mons[PM_RUST_MONSTER]
&nbsp;            &amp;&amp; (gold = g_at(u.ux, u.uy)) != 0) {
&nbsp;            if (gold-&gt;quan == 1L)
&nbsp;                Sprintf(qbuf, "There is 1 gold piece here; eat it?");
&nbsp;            else
&nbsp;                Sprintf(qbuf, "There are %ld gold pieces here; eat them?",
&nbsp;                        gold-&gt;quan);
&nbsp;            if ((c = yn_function(qbuf, ynqchars, 'n')) == 'y') {
&nbsp;                return gold;
&nbsp;            } else if (c == 'q') {
&nbsp;                return (struct obj *) 0;
&nbsp;            }
&nbsp;        }
&nbsp;    }
&nbsp;
&nbsp;    /* Is there some food (probably a heavy corpse) here on the ground? */
&nbsp;    for (otmp = level.objects[u.ux][u.uy]; otmp; otmp = otmp-&gt;nexthere) {
&nbsp;        if (corpsecheck
&nbsp;                ? (otmp-&gt;otyp == CORPSE
&nbsp;                   &amp;&amp; (corpsecheck == 1 || tinnable(otmp)))
&nbsp;                : feeding ? (otmp-&gt;oclass != COIN_CLASS &amp;&amp; is_edible(otmp))
&nbsp;                          : otmp-&gt;oclass == FOOD_CLASS) {
&nbsp;            char qsfx[QBUFSZ];
&nbsp;            boolean one = (otmp-&gt;quan == 1L);
&nbsp;
&nbsp;            /* if blind and without gloves, attempting to eat (or tin or
&nbsp;               offer) a cockatrice corpse is fatal before asking whether
&nbsp;               or not to use it; otherwise, 'm

<dir>' followed by 'e' could
&nbsp;               be used to locate cockatrice corpses without touching them */
&nbsp;            if (otmp-&gt;otyp == CORPSE &amp;&amp; will_feel_cockatrice(otmp, FALSE)) {
&nbsp;                feel_cockatrice(otmp, FALSE);
&nbsp;                /* if life-saved (or poly'd into stone golem), terminate
&nbsp;                   attempt to eat off floor */
&nbsp;                return (struct obj *) 0;
&nbsp;            }
&nbsp;            /* "There is <an object=""> here; <verb> it?" or
&nbsp;               "There are <n objects=""> here; <verb> one?" */
&nbsp;            Sprintf(qbuf, "There %s ", otense(otmp, "are"));
&nbsp;            Sprintf(qsfx, " here; %s %s?", verb, one ? "it" : "one");
&nbsp;            (void) safe_qbuf(qbuf, qbuf, qsfx, otmp, doname, ansimpleoname,
&nbsp;                             one ? something : (const char *) "things");
&nbsp;            if ((c = yn_function(qbuf, ynqchars, 'n')) == 'y')
&nbsp;                return  otmp;
&nbsp;            else if (c == 'q')
&nbsp;                return (struct obj *) 0;
&nbsp;        }
&nbsp;    }
&nbsp;
&nbsp;skipfloor:
&nbsp;    /* We cannot use ALL_CLASSES since that causes getobj() to skip its
&nbsp;     * "ugly checks" and we need to check for inedible items.
&nbsp;     */
&nbsp;    otmp = getobj(feeding ? allobj : offering ? offerfodder : comestibles,
&nbsp;                  verb);
&nbsp;    if (corpsecheck &amp;&amp; otmp &amp;&amp; !(offering &amp;&amp; otmp-&gt;oclass == AMULET_CLASS))
&nbsp;        if (otmp-&gt;otyp != CORPSE || (corpsecheck == 2 &amp;&amp; !tinnable(otmp))) {
&nbsp;            You_cant("%s that!", verb);
&nbsp;            return (struct obj *) 0;
&nbsp;        }
&nbsp;    return otmp;
&nbsp;}
&nbsp;
vomit
&nbsp;/* Side effects of vomiting */
&nbsp;/* added nomul (MRS) - it makes sense, you're too busy being sick! */
&nbsp;void
&nbsp;vomit() /* A good idea from David Neves */
&nbsp;{
&nbsp;    if (cantvomit(youmonst.data)) {
&nbsp;        /* doesn't cure food poisoning; message assumes that we aren't
&nbsp;           dealing with some esoteric body_part() */
&nbsp;        Your("jaw gapes convulsively.");
&nbsp;    } else {
&nbsp;        make_sick(0L, (char *) 0, TRUE, SICK_VOMITABLE);
&nbsp;        /* if not enough in stomach to actually vomit then dry heave;
&nbsp;           vomiting_dialog() gives a vomit message when its countdown
&nbsp;           reaches 0, but only if u.uhs &lt; FAINTING (and !cantvomit()) */
&nbsp;        if (u.uhs &gt;= FAINTING)
&nbsp;            Your("%s heaves convulsively!", body_part(STOMACH));
&nbsp;    }
&nbsp;
&nbsp;    /* nomul()/You_can_move_again used to be unconditional, which was
&nbsp;       viable while eating but not for Vomiting countdown where hero might
&nbsp;       be immobilized for some other reason at the time vomit() is called */
&nbsp;    if (multi &gt;= -2) {
&nbsp;        nomul(-2);
&nbsp;        multi_reason = "vomiting";
&nbsp;        nomovemsg = You_can_move_again;
&nbsp;    }
&nbsp;}
&nbsp;
eaten_stat
&nbsp;int
&nbsp;eaten_stat(base, obj)
&nbsp;int base;
&nbsp;struct obj *obj;
&nbsp;{
&nbsp;    long uneaten_amt, full_amount;
&nbsp;
&nbsp;    /* get full_amount first; obj_nutrition() might modify obj-&gt;oeaten */
&nbsp;    full_amount = (long) obj_nutrition(obj);
&nbsp;    uneaten_amt = (long) obj-&gt;oeaten;
&nbsp;    if (uneaten_amt &gt; full_amount) {
&nbsp;        impossible(
&nbsp;          "partly eaten food (%ld) more nutritious than untouched food (%ld)",
&nbsp;                   uneaten_amt, full_amount);
&nbsp;        uneaten_amt = full_amount;
&nbsp;    }
&nbsp;
&nbsp;    base = (int) (full_amount ? (long) base * uneaten_amt / full_amount : 0L);
&nbsp;    return (base &lt; 1) ? 1 : base;
&nbsp;}
&nbsp;
consume_oeaten
&nbsp;/* reduce obj's oeaten field, making sure it never hits or passes 0 */
&nbsp;void
&nbsp;consume_oeaten(obj, amt)
&nbsp;struct obj *obj;
&nbsp;int amt;
&nbsp;{
&nbsp;    /*
&nbsp;     * This is a hack to try to squelch several long standing mystery
&nbsp;     * food bugs.  A better solution would be to rewrite the entire
&nbsp;     * victual handling mechanism from scratch using a less complex
&nbsp;     * model.  Alternatively, this routine could call done_eating()
&nbsp;     * or food_disappears() but its callers would need revisions to
&nbsp;     * cope with context.victual.piece unexpectedly going away.
&nbsp;     *
&nbsp;     * Multi-turn eating operates by setting the food's oeaten field
&nbsp;     * to its full nutritional value and then running a counter which
&nbsp;     * independently keeps track of whether there is any food left.
&nbsp;     * The oeaten field can reach exactly zero on the last turn, and
&nbsp;     * the object isn't removed from inventory until the next turn
&nbsp;     * when the "you finish eating" message gets delivered, so the
&nbsp;     * food would be restored to the status of untouched during that
&nbsp;     * interval.  This resulted in unexpected encumbrance messages
&nbsp;     * at the end of a meal (if near enough to a threshold) and would
&nbsp;     * yield full food if there was an interruption on the critical
&nbsp;     * turn.  Also, there have been reports over the years of food
&nbsp;     * becoming massively heavy or producing unlimited satiation;
&nbsp;     * this would occur if reducing oeaten via subtraction attempted
&nbsp;     * to drop it below 0 since its unsigned type would produce a
&nbsp;     * huge positive value instead.  So far, no one has figured out
&nbsp;     * _why_ that inappropriate subtraction might sometimes happen.
&nbsp;     */
&nbsp;
&nbsp;    if (amt &gt; 0) {
&nbsp;        /* bit shift to divide the remaining amount of food */
&nbsp;        obj-&gt;oeaten &gt;&gt;= amt;
&nbsp;    } else {
&nbsp;        /* simple decrement; value is negative so we actually add it */
&nbsp;        if ((int) obj-&gt;oeaten &gt; -amt)
&nbsp;            obj-&gt;oeaten += amt;
&nbsp;        else
&nbsp;            obj-&gt;oeaten = 0;
&nbsp;    }
&nbsp;
&nbsp;    if (obj-&gt;oeaten == 0) {
&nbsp;        if (obj == context.victual.piece) /* always true unless wishing... */
&nbsp;            context.victual.reqtime =
&nbsp;                context.victual.usedtime; /* no bites left */
&nbsp;        obj-&gt;oeaten = 1; /* smallest possible positive value */
&nbsp;    }
&nbsp;}
&nbsp;
maybe_finished_meal
&nbsp;/* called when eatfood occupation has been interrupted,
&nbsp;   or in the case of theft, is about to be interrupted */
&nbsp;boolean
&nbsp;maybe_finished_meal(stopping)
&nbsp;boolean stopping;
&nbsp;{
&nbsp;    /* in case consume_oeaten() has decided that the food is all gone */
&nbsp;    if (occupation == eatfood
&nbsp;        &amp;&amp; context.victual.usedtime &gt;= context.victual.reqtime) {
&nbsp;        if (stopping)
&nbsp;            occupation = 0; /* for do_reset_eat */
&nbsp;        (void) eatfood();   /* calls done_eating() to use up
&nbsp;                               context.victual.piece */
&nbsp;        return TRUE;
&nbsp;    }
&nbsp;    return FALSE;
&nbsp;}
&nbsp;
Popeye
&nbsp;/* Tin of <something> to the rescue?  Decide whether current occupation
&nbsp;   is an attempt to eat a tin of something capable of saving hero's life.
&nbsp;   We don't care about consumption of non-tinned food here because special
&nbsp;   effects there take place on first bite rather than at end of occupation.
&nbsp;   [Popeye the Sailor gets out of trouble by eating tins of spinach. :-] */
&nbsp;boolean
&nbsp;Popeye(threat)
&nbsp;int threat;
&nbsp;{
&nbsp;    struct obj *otin;
&nbsp;    int mndx;
&nbsp;
&nbsp;    if (occupation != opentin)
&nbsp;        return FALSE;
&nbsp;    otin = context.tin.tin;
&nbsp;    /* make sure hero still has access to tin */
&nbsp;    if (!carried(otin)
&nbsp;        &amp;&amp; (!obj_here(otin, u.ux, u.uy) || !can_reach_floor(TRUE)))
&nbsp;        return FALSE;
&nbsp;    /* unknown tin is assumed to be helpful */
&nbsp;    if (!otin-&gt;known)
&nbsp;        return TRUE;
&nbsp;    /* known tin is helpful if it will stop life-threatening problem */
&nbsp;    mndx = otin-&gt;corpsenm;
&nbsp;    switch (threat) {
&nbsp;    /* note: not used; hunger code bypasses stop_occupation() when eating */
&nbsp;    case HUNGER:
&nbsp;        return (boolean) (mndx != NON_PM || otin-&gt;spe == 1);
&nbsp;    /* flesh from lizards and acidic critters stops petrification */
&nbsp;    case STONED:
&nbsp;        return (boolean) (mndx &gt;= LOW_PM
&nbsp;                          &amp;&amp; (mndx == PM_LIZARD || acidic(&amp;mons[mndx])));
&nbsp;    /* no tins can cure these (yet?) */
&nbsp;    case SLIMED:
&nbsp;    case SICK:
&nbsp;    case VOMITING:
&nbsp;        break;
&nbsp;    default:
&nbsp;        break;
&nbsp;    }
&nbsp;    return FALSE;
&nbsp;}
&nbsp;
&nbsp;/*eat.c*/

</something></verb></n></verb></an></dir>