OSDN Git Service

patch src/
[jnethack/source.git] / src / eat.c
1 /* NetHack 3.6  eat.c   $NHDT-Date: 1449269916 2015/12/04 22:58:36 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.154 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed.  See license for details. */
4
5 /* JNetHack Copyright */
6 /* (c) Issei Numata, Naoki Hamada, Shigehiro Miyashita, 1994-2000  */
7 /* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2016            */
8 /* JNetHack may be freely redistributed.  See license for details. */
9
10 #include "hack.h"
11
12 STATIC_PTR int NDECL(eatmdone);
13 STATIC_PTR int NDECL(eatfood);
14 STATIC_PTR void FDECL(costly_tin, (int));
15 STATIC_PTR int NDECL(opentin);
16 STATIC_PTR int NDECL(unfaint);
17
18 STATIC_DCL const char *FDECL(food_xname, (struct obj *, BOOLEAN_P));
19 STATIC_DCL void FDECL(choke, (struct obj *));
20 STATIC_DCL void NDECL(recalc_wt);
21 STATIC_DCL struct obj *FDECL(touchfood, (struct obj *));
22 STATIC_DCL void NDECL(do_reset_eat);
23 STATIC_DCL void FDECL(done_eating, (BOOLEAN_P));
24 STATIC_DCL void FDECL(cprefx, (int));
25 STATIC_DCL int FDECL(intrinsic_possible, (int, struct permonst *));
26 STATIC_DCL void FDECL(givit, (int, struct permonst *));
27 STATIC_DCL void FDECL(cpostfx, (int));
28 STATIC_DCL void FDECL(consume_tin, (const char *));
29 STATIC_DCL void FDECL(start_tin, (struct obj *));
30 STATIC_DCL int FDECL(eatcorpse, (struct obj *));
31 STATIC_DCL void FDECL(start_eating, (struct obj *));
32 STATIC_DCL void FDECL(fprefx, (struct obj *));
33 STATIC_DCL void FDECL(fpostfx, (struct obj *));
34 STATIC_DCL int NDECL(bite);
35 STATIC_DCL int FDECL(edibility_prompts, (struct obj *));
36 STATIC_DCL int FDECL(rottenfood, (struct obj *));
37 STATIC_DCL void NDECL(eatspecial);
38 STATIC_DCL int FDECL(bounded_increase, (int, int, int));
39 STATIC_DCL void FDECL(accessory_has_effect, (struct obj *));
40 STATIC_DCL void FDECL(eataccessory, (struct obj *));
41 STATIC_DCL const char *FDECL(foodword, (struct obj *));
42 STATIC_DCL int FDECL(tin_variety, (struct obj *, BOOLEAN_P));
43 STATIC_DCL boolean FDECL(maybe_cannibal, (int, BOOLEAN_P));
44
45 char msgbuf[BUFSZ];
46
47 /* also used to see if you're allowed to eat cats and dogs */
48 #define CANNIBAL_ALLOWED() (Role_if(PM_CAVEMAN) || Race_if(PM_ORC))
49
50 /* monster types that cause hero to be turned into stone if eaten */
51 #define flesh_petrifies(pm) (touch_petrifies(pm) || (pm) == &mons[PM_MEDUSA])
52
53 /* Rider corpses are treated as non-rotting so that attempting to eat one
54    will be sure to reach the stage of eating where that meal is fatal */
55 #define nonrotting_corpse(mnum) \
56     ((mnum) == PM_LIZARD || (mnum) == PM_LICHEN || is_rider(&mons[mnum]))
57
58 /* non-rotting non-corpses; unlike lizard corpses, these items will behave
59    as if rotten if they are cursed (fortune cookies handled elsewhere) */
60 #define nonrotting_food(otyp) \
61     ((otyp) == LEMBAS_WAFER || (otyp) == CRAM_RATION)
62
63 STATIC_OVL NEARDATA const char comestibles[] = { FOOD_CLASS, 0 };
64 STATIC_OVL NEARDATA const char offerfodder[] = { FOOD_CLASS, AMULET_CLASS,
65                                                  0 };
66
67 /* Gold must come first for getobj(). */
68 STATIC_OVL NEARDATA const char allobj[] = {
69     COIN_CLASS,   WEAPON_CLASS, ARMOR_CLASS,  POTION_CLASS,
70     SCROLL_CLASS, WAND_CLASS,   RING_CLASS,   AMULET_CLASS,
71     FOOD_CLASS,   TOOL_CLASS,   GEM_CLASS,    ROCK_CLASS,
72     BALL_CLASS,   CHAIN_CLASS,  SPBOOK_CLASS, 0
73 };
74
75 STATIC_OVL boolean force_save_hs = FALSE;
76
77 /* see hunger states in hack.h - texts used on bottom line */
78 #if 0 /*JP*/
79 const char *hu_stat[] = { "Satiated", "        ", "Hungry  ", "Weak    ",
80                           "Fainting", "Fainted ", "Starved " };
81 #else
82 const char *hu_stat[] = { "\96\9e\95     ", "        ", "\82Ø\82±\82Ø\82±", "\90\8a\8eã    ",
83                           "\82Ó\82ç\82Ó\82ç", "\91²\93|    ", "\89ì\8e\80    " };
84 #endif
85
86 /*
87  * Decide whether a particular object can be eaten by the possibly
88  * polymorphed character.  Not used for monster checks.
89  */
90 boolean
91 is_edible(obj)
92 register struct obj *obj;
93 {
94     /* protect invocation tools but not Rider corpses (handled elsewhere)*/
95     /* if (obj->oclass != FOOD_CLASS && obj_resists(obj, 0, 0)) */
96     if (objects[obj->otyp].oc_unique)
97         return FALSE;
98     /* above also prevents the Amulet from being eaten, so we must never
99        allow fake amulets to be eaten either [which is already the case] */
100
101     if (metallivorous(youmonst.data) && is_metallic(obj)
102         && (youmonst.data != &mons[PM_RUST_MONSTER] || is_rustprone(obj)))
103         return TRUE;
104
105     if (u.umonnum == PM_GELATINOUS_CUBE && is_organic(obj)
106         /* [g.cubes can eat containers and retain all contents
107             as engulfed items, but poly'd player can't do that] */
108         && !Has_contents(obj))
109         return TRUE;
110
111     /* return (boolean) !!index(comestibles, obj->oclass); */
112     return (boolean) (obj->oclass == FOOD_CLASS);
113 }
114
115 void
116 init_uhunger()
117 {
118     u.uhunger = 900;
119     u.uhs = NOT_HUNGRY;
120 }
121
122 /* tin types [SPINACH_TIN = -1, overrides corpsenm, nut==600] */
123 static const struct {
124     const char *txt;                      /* description */
125     int nut;                              /* nutrition */
126     Bitfield(fodder, 1);                  /* stocked by health food shops */
127     Bitfield(greasy, 1);                  /* causes slippery fingers */
128 #if 0 /*JP*/
129 } tintxts[] = { { "rotten", -50, 0, 0 },  /* ROTTEN_TIN = 0 */
130                 { "homemade", 50, 1, 0 }, /* HOMEMADE_TIN = 1 */
131                 { "soup made from", 20, 1, 0 },
132                 { "french fried", 40, 0, 1 },
133                 { "pickled", 40, 1, 0 },
134                 { "boiled", 50, 1, 0 },
135                 { "smoked", 50, 1, 0 },
136                 { "dried", 55, 1, 0 },
137                 { "deep fried", 60, 0, 1 },
138                 { "szechuan", 70, 1, 0 },
139                 { "broiled", 80, 0, 0 },
140                 { "stir fried", 80, 0, 1 },
141                 { "sauteed", 95, 0, 0 },
142                 { "candied", 100, 1, 0 },
143                 { "pureed", 500, 1, 0 },
144                 { "", 0, 0, 0 } };
145 #else
146 } tintxts[] = { { "\95\85\82Á\82½", -50, 0, 0 },  /* ROTTEN_TIN = 0 */
147                 { "\8e©\89Æ\90»\82Ì", 50, 1, 0 }, /* HOMEMADE_TIN = 1 */
148                 { "\82Ì\83X\81[\83v", 20, 1, 0 },
149                 { "\82Ì\83t\83\89\83C", 40, 0, 1 },
150                 { "\82Ì\92Ð\95¨", 40, 1, 0 },
151                 { "\82ä\82Å", 50, 1, 0 },
152                 { "\82Ìà\8e\90»", 50, 1, 0 },
153                 { "\8a£\91\87", 55, 1, 0 },
154                 { "\82Ì\97g\82°\95¨", 60, 0, 1 },
155                 { "\8el\90ì\95\97", 70, 1, 0 },
156                 { "\82Ì\96Ô\8fÄ\82«", 80, 0, 0 },
157                 { "àu\82ß", 80, 0, 1 },
158                 { "\82Ì\83\\83e\81[", 95, 0, 0 },
159                 { "\82Ì\8d»\93\9c\92Ð\82¯", 100, 1, 0 },
160                 { "\82Ì\83s\83\85\81[\83\8c", 500, 1, 0 },
161                 { "", 0, 0, 0 } };
162 #endif
163 #define TTSZ SIZE(tintxts)
164
165 static char *eatmbuf = 0; /* set by cpostfx() */
166
167 /* called after mimicing is over */
168 STATIC_PTR int
169 eatmdone(VOID_ARGS)
170 {
171     /* release `eatmbuf' */
172     if (eatmbuf) {
173         if (nomovemsg == eatmbuf)
174             nomovemsg = 0;
175         free((genericptr_t) eatmbuf), eatmbuf = 0;
176     }
177     /* update display */
178     if (youmonst.m_ap_type) {
179         youmonst.m_ap_type = M_AP_NOTHING;
180         newsym(u.ux, u.uy);
181     }
182     return 0;
183 }
184
185 /* called when hallucination is toggled */
186 void
187 eatmupdate()
188 {
189     const char *altmsg = 0;
190     int altapp = 0; /* lint suppression */
191
192     if (!eatmbuf || nomovemsg != eatmbuf)
193         return;
194
195     if (is_obj_mappear(&youmonst,ORANGE) && !Hallucination) {
196         /* revert from hallucinatory to "normal" mimicking */
197         altmsg = "You now prefer mimicking yourself.";
198         altapp = GOLD_PIECE;
199     } else if (is_obj_mappear(&youmonst,GOLD_PIECE) && Hallucination) {
200         /* won't happen; anything which might make immobilized
201            hero begin hallucinating (black light attack, theft
202            of Grayswandir) will terminate the mimicry first */
203         altmsg = "Your rind escaped intact.";
204         altapp = ORANGE;
205     }
206
207     if (altmsg) {
208         /* replace end-of-mimicking message */
209         if (strlen(altmsg) > strlen(eatmbuf)) {
210             free((genericptr_t) eatmbuf);
211             eatmbuf = (char *) alloc(strlen(altmsg) + 1);
212         }
213         nomovemsg = strcpy(eatmbuf, altmsg);
214         /* update current image */
215         youmonst.mappearance = altapp;
216         newsym(u.ux, u.uy);
217     }
218 }
219
220 /* ``[the(] singular(food, xname) [)]'' */
221 STATIC_OVL const char *
222 food_xname(food, the_pfx)
223 struct obj *food;
224 boolean the_pfx;
225 {
226     const char *result;
227
228     if (food->otyp == CORPSE) {
229         result = corpse_xname(food, (const char *) 0,
230                               CXN_SINGULAR | (the_pfx ? CXN_PFX_THE : 0));
231         /* not strictly needed since pname values are capitalized
232            and the() is a no-op for them */
233         if (type_is_pname(&mons[food->corpsenm]))
234             the_pfx = FALSE;
235     } else {
236         /* the ordinary case */
237         result = singular(food, xname);
238     }
239     if (the_pfx)
240         result = the(result);
241     return result;
242 }
243
244 /* Created by GAN 01/28/87
245  * Amended by AKP 09/22/87: if not hard, don't choke, just vomit.
246  * Amended by 3.  06/12/89: if not hard, sometimes choke anyway, to keep risk.
247  *                11/10/89: if hard, rarely vomit anyway, for slim chance.
248  *
249  * To a full belly all food is bad. (It.)
250  */
251 STATIC_OVL void
252 choke(food)
253 struct obj *food;
254 {
255     /* only happens if you were satiated */
256     if (u.uhs != SATIATED) {
257         if (!food || food->otyp != AMULET_OF_STRANGULATION)
258             return;
259     } else if (Role_if(PM_KNIGHT) && u.ualign.type == A_LAWFUL) {
260         adjalign(-1); /* gluttony is unchivalrous */
261 /*JP
262         You_feel("like a glutton!");
263 */
264         You("\91å\90H\8a¿\82Ì\82æ\82¤\82È\8bC\82ª\82µ\82½\81I");
265     }
266
267     exercise(A_CON, FALSE);
268
269     if (Breathless || (!Strangled && !rn2(20))) {
270         /* choking by eating AoS doesn't involve stuffing yourself */
271         if (food && food->otyp == AMULET_OF_STRANGULATION) {
272 /*JP
273             You("choke, but recover your composure.");
274 */
275             You("\8eñ\82ð\8di\82ß\82ç\82ê\82½\81D\82µ\82©\82µ\82È\82ñ\82Æ\82à\82È\82©\82Á\82½\81D");
276             return;
277         }
278 /*JP
279         You("stuff yourself and then vomit voluminously.");
280 */
281         pline("\82ª\82Â\82ª\82Â\82Æ\8cû\82É\8bl\82ß\8d\9e\82ñ\82¾\82ª\81C\83h\83o\82Á\82Æ\93f\82«\8fo\82µ\82Ä\82µ\82Ü\82Á\82½\81D");
282         morehungry(1000); /* you just got *very* sick! */
283         vomit();
284     } else {
285         killer.format = KILLED_BY_AN;
286         /*
287          * Note all "killer"s below read "Choked on %s" on the
288          * high score list & tombstone.  So plan accordingly.
289          */
290         if (food) {
291 /*JP
292             You("choke over your %s.", foodword(food));
293 */
294             You("%s\82ð\8dA\82É\8bl\82Ü\82ç\82¹\82Ä\82µ\82Ü\82Á\82½\81D", foodword(food));
295             if (food->oclass == COIN_CLASS) {
296 /*JP
297                 Strcpy(killer.name, "very rich meal");
298 */
299                 Strcpy(killer.name, "\82Æ\82Ä\82à\8d\82\89¿\82È\97¿\97\9d");
300             } else {
301                 killer.format = KILLED_BY;
302                 Strcpy(killer.name, killer_xname(food));
303             }
304         } else {
305 /*JP
306             You("choke over it.");
307 */
308             pline("\8dA\82É\8bl\82Ü\82ç\82¹\82Ä\82µ\82Ü\82Á\82½\81D");
309 /*JP
310             Strcpy(killer.name, "quick snack");
311 */
312             Strcpy(killer.name, "\91\81\90H\82¢");
313         }
314 /*JP
315         You("die...");
316 */
317         pline("\82 \82È\82½\82Í\8e\80\82É\82Ü\82µ\82½\81D\81D\81D");
318         done(CHOKING);
319     }
320 }
321
322 /* modify object wt. depending on time spent consuming it */
323 STATIC_OVL void
324 recalc_wt()
325 {
326     struct obj *piece = context.victual.piece;
327     if (!piece) {
328         impossible("recalc_wt without piece");
329         return;
330     }
331     debugpline1("Old weight = %d", piece->owt);
332     debugpline2("Used time = %d, Req'd time = %d", context.victual.usedtime,
333                 context.victual.reqtime);
334     piece->owt = weight(piece);
335     debugpline1("New weight = %d", piece->owt);
336 }
337
338 /* called when eating interrupted by an event */
339 void
340 reset_eat()
341 {
342     /* we only set a flag here - the actual reset process is done after
343      * the round is spent eating.
344      */
345     if (context.victual.eating && !context.victual.doreset) {
346         debugpline0("reset_eat...");
347         context.victual.doreset = TRUE;
348     }
349     return;
350 }
351
352 STATIC_OVL struct obj *
353 touchfood(otmp)
354 struct obj *otmp;
355 {
356     if (otmp->quan > 1L) {
357         if (!carried(otmp))
358             (void) splitobj(otmp, otmp->quan - 1L);
359         else
360             otmp = splitobj(otmp, 1L);
361         debugpline0("split object,");
362     }
363
364     if (!otmp->oeaten) {
365         costly_alteration(otmp, COST_BITE);
366         otmp->oeaten =
367             (otmp->otyp == CORPSE ? mons[otmp->corpsenm].cnutrit
368                                   : objects[otmp->otyp].oc_nutrition);
369     }
370
371     if (carried(otmp)) {
372         freeinv(otmp);
373         if (inv_cnt(FALSE) >= 52) {
374             sellobj_state(SELL_DONTSELL);
375             dropy(otmp);
376             sellobj_state(SELL_NORMAL);
377         } else {
378             otmp->nomerge = 1; /* used to prevent merge */
379             otmp = addinv(otmp);
380             otmp->nomerge = 0;
381         }
382     }
383     return otmp;
384 }
385
386 /* When food decays, in the middle of your meal, we don't want to dereference
387  * any dangling pointers, so set it to null (which should still trigger
388  * do_reset_eat() at the beginning of eatfood()) and check for null pointers
389  * in do_reset_eat().
390  */
391 void
392 food_disappears(obj)
393 struct obj *obj;
394 {
395     if (obj == context.victual.piece) {
396         context.victual.piece = (struct obj *) 0;
397         context.victual.o_id = 0;
398     }
399     if (obj->timed)
400         obj_stop_timers(obj);
401 }
402
403 /* renaming an object used to result in it having a different address,
404    so the sequence start eating/opening, get interrupted, name the food,
405    resume eating/opening would restart from scratch */
406 void
407 food_substitution(old_obj, new_obj)
408 struct obj *old_obj, *new_obj;
409 {
410     if (old_obj == context.victual.piece) {
411         context.victual.piece = new_obj;
412         context.victual.o_id = new_obj->o_id;
413     }
414     if (old_obj == context.tin.tin) {
415         context.tin.tin = new_obj;
416         context.tin.o_id = new_obj->o_id;
417     }
418 }
419
420 STATIC_OVL void
421 do_reset_eat()
422 {
423     debugpline0("do_reset_eat...");
424     if (context.victual.piece) {
425         context.victual.o_id = 0;
426         context.victual.piece = touchfood(context.victual.piece);
427         if (context.victual.piece)
428             context.victual.o_id = context.victual.piece->o_id;
429         recalc_wt();
430     }
431     context.victual.fullwarn = context.victual.eating =
432         context.victual.doreset = FALSE;
433     /* Do not set canchoke to FALSE; if we continue eating the same object
434      * we need to know if canchoke was set when they started eating it the
435      * previous time.  And if we don't continue eating the same object
436      * canchoke always gets recalculated anyway.
437      */
438     stop_occupation();
439     newuhs(FALSE);
440 }
441
442 /* called each move during eating process */
443 STATIC_PTR int
444 eatfood(VOID_ARGS)
445 {
446     if (!context.victual.piece
447         || (!carried(context.victual.piece)
448             && !obj_here(context.victual.piece, u.ux, u.uy))) {
449         /* maybe it was stolen? */
450         do_reset_eat();
451         return 0;
452     }
453     if (!context.victual.eating)
454         return 0;
455
456     if (++context.victual.usedtime <= context.victual.reqtime) {
457         if (bite())
458             return 0;
459         return 1; /* still busy */
460     } else {        /* done */
461         done_eating(TRUE);
462         return 0;
463     }
464 }
465
466 STATIC_OVL void
467 done_eating(message)
468 boolean message;
469 {
470     context.victual.piece->in_use = TRUE;
471     occupation = 0; /* do this early, so newuhs() knows we're done */
472     newuhs(FALSE);
473     if (nomovemsg) {
474         if (message)
475             pline1(nomovemsg);
476         nomovemsg = 0;
477     } else if (message)
478 /*JP
479         You("finish eating %s.", food_xname(context.victual.piece, TRUE));
480 */
481         You("%s\82ð\90H\82×\8fI\82¦\82½\81D",  food_xname(context.victual.piece, TRUE));
482
483     if (context.victual.piece->otyp == CORPSE)
484         cpostfx(context.victual.piece->corpsenm);
485     else
486         fpostfx(context.victual.piece);
487
488     if (carried(context.victual.piece))
489         useup(context.victual.piece);
490     else
491         useupf(context.victual.piece, 1L);
492     context.victual.piece = (struct obj *) 0;
493     context.victual.o_id = 0;
494     context.victual.fullwarn = context.victual.eating =
495         context.victual.doreset = FALSE;
496 }
497
498 void
499 eating_conducts(pd)
500 struct permonst *pd;
501 {
502     u.uconduct.food++;
503     if (!vegan(pd))
504         u.uconduct.unvegan++;
505     if (!vegetarian(pd))
506         violated_vegetarian();
507 }
508
509 /* handle side-effects of mind flayer's tentacle attack */
510 int
511 eat_brains(magr, mdef, visflag, dmg_p)
512 struct monst *magr, *mdef;
513 boolean visflag;
514 int *dmg_p; /* for dishing out extra damage in lieu of Int loss */
515 {
516     struct permonst *pd = mdef->data;
517     boolean give_nutrit = FALSE;
518     int result = MM_HIT, xtra_dmg = rnd(10);
519
520     if (noncorporeal(pd)) {
521         if (visflag)
522             pline("%s brain is unharmed.",
523                   (mdef == &youmonst) ? "Your" : s_suffix(Monnam(mdef)));
524         return MM_MISS; /* side-effects can't occur */
525     } else if (magr == &youmonst) {
526         You("eat %s brain!", s_suffix(mon_nam(mdef)));
527     } else if (mdef == &youmonst) {
528         Your("brain is eaten!");
529     } else { /* monster against monster */
530         if (visflag)
531             pline("%s brain is eaten!", s_suffix(Monnam(mdef)));
532     }
533
534     if (flesh_petrifies(pd)) {
535         /* mind flayer has attempted to eat the brains of a petrification
536            inducing critter (most likely Medusa; attacking a cockatrice via
537            tentacle-touch should have been caught before reaching this far) */
538         if (magr == &youmonst) {
539             if (!Stone_resistance && !Stoned)
540                 make_stoned(5L, (char *) 0, KILLED_BY_AN, pd->mname);
541         } else {
542             /* no need to check for poly_when_stoned or Stone_resistance;
543                mind flayers don't have those capabilities */
544             if (visflag)
545                 pline("%s turns to stone!", Monnam(magr));
546             monstone(magr);
547             if (magr->mhp > 0) {
548                 /* life-saved; don't continue eating the brains */
549                 return MM_MISS;
550             } else {
551                 if (magr->mtame && !visflag)
552                     /* parallels mhitm.c's brief_feeling */
553                     You("have a sad thought for a moment, then is passes.");
554                 return MM_AGR_DIED;
555             }
556         }
557     }
558
559     if (magr == &youmonst) {
560         /*
561          * player mind flayer is eating something's brain
562          */
563         eating_conducts(pd);
564         if (mindless(pd)) { /* (cannibalism not possible here) */
565             pline("%s doesn't notice.", Monnam(mdef));
566             /* all done; no extra harm inflicted upon target */
567             return MM_MISS;
568         } else if (is_rider(pd)) {
569             pline("Ingesting that is fatal.");
570             Sprintf(killer.name, "unwisely ate the brain of %s", pd->mname);
571             killer.format = NO_KILLER_PREFIX;
572             done(DIED);
573             /* life-saving needed to reach here */
574             exercise(A_WIS, FALSE);
575             *dmg_p += xtra_dmg; /* Rider takes extra damage */
576         } else {
577             morehungry(-rnd(30)); /* cannot choke */
578             if (ABASE(A_INT) < AMAX(A_INT)) {
579                 /* recover lost Int; won't increase current max */
580                 ABASE(A_INT) += rnd(4);
581                 if (ABASE(A_INT) > AMAX(A_INT))
582                     ABASE(A_INT) = AMAX(A_INT);
583                 context.botl = 1;
584             }
585             exercise(A_WIS, TRUE);
586             *dmg_p += xtra_dmg;
587         }
588         /* targetting another mind flayer or your own underlying species
589            is cannibalism */
590         (void) maybe_cannibal(monsndx(pd), TRUE);
591
592     } else if (mdef == &youmonst) {
593         /*
594          * monster mind flayer is eating hero's brain
595          */
596         /* no such thing as mindless players */
597         if (ABASE(A_INT) <= ATTRMIN(A_INT)) {
598             static NEARDATA const char brainlessness[] = "brainlessness";
599
600             if (Lifesaved) {
601                 Strcpy(killer.name, brainlessness);
602                 killer.format = KILLED_BY;
603                 done(DIED);
604                 /* amulet of life saving has now been used up */
605                 pline("Unfortunately your brain is still gone.");
606                 /* sanity check against adding other forms of life-saving */
607                 u.uprops[LIFESAVED].extrinsic =
608                     u.uprops[LIFESAVED].intrinsic = 0L;
609             } else {
610                 Your("last thought fades away.");
611             }
612             Strcpy(killer.name, brainlessness);
613             killer.format = KILLED_BY;
614             done(DIED);
615             /* can only get here when in wizard or explore mode and user has
616                explicitly chosen not to die; arbitrarily boost intelligence */
617             ABASE(A_INT) = ATTRMIN(A_INT) + 2;
618             You_feel("like a scarecrow.");
619         }
620         give_nutrit = TRUE; /* in case a conflicted pet is doing this */
621         exercise(A_WIS, FALSE);
622         /* caller handles Int and memory loss */
623
624     } else { /* mhitm */
625         /*
626          * monster mind flayer is eating another monster's brain
627          */
628         if (mindless(pd)) {
629             if (visflag)
630                 pline("%s doesn't notice.", Monnam(mdef));
631             return MM_MISS;
632         } else if (is_rider(pd)) {
633             mondied(magr);
634             if (magr->mhp <= 0)
635                 result = MM_AGR_DIED;
636             /* Rider takes extra damage regardless of whether attacker dies */
637             *dmg_p += xtra_dmg;
638         } else {
639             *dmg_p += xtra_dmg;
640             give_nutrit = TRUE;
641             if (*dmg_p >= mdef->mhp && visflag)
642                 pline("%s last thought fades away...",
643                       s_suffix(Monnam(mdef)));
644         }
645     }
646
647     if (give_nutrit && magr->mtame && !magr->isminion) {
648         EDOG(magr)->hungrytime += rnd(60);
649         magr->mconf = 0;
650     }
651
652     return result;
653 }
654
655 /* eating a corpse or egg of one's own species is usually naughty */
656 STATIC_OVL boolean
657 maybe_cannibal(pm, allowmsg)
658 int pm;
659 boolean allowmsg;
660 {
661     static NEARDATA long ate_brains = 0L;
662     struct permonst *fptr = &mons[pm]; /* food type */
663
664     /* when poly'd into a mind flayer, multiple tentacle hits in one
665        turn cause multiple digestion checks to occur; avoid giving
666        multiple luck penalties for the same attack */
667     if (moves == ate_brains)
668         return FALSE;
669     ate_brains = moves; /* ate_anything, not just brains... */
670
671     if (!CANNIBAL_ALLOWED()
672         /* non-cannibalistic heroes shouldn't eat own species ever
673            and also shouldn't eat current species when polymorphed
674            (even if having the form of something which doesn't care
675            about cannibalism--hero's innate traits aren't altered) */
676         && (your_race(fptr) || (Upolyd && same_race(youmonst.data, fptr)))) {
677         if (allowmsg) {
678             if (Upolyd && your_race(fptr))
679 /*JP
680                 You("have a bad feeling deep inside.");
681 */
682                 You("\8c\99\88«\8a´\82É\82¨\82»\82í\82ê\82½\81D");
683 /*JP
684             You("cannibal!  You will regret this!");
685 */
686             pline("\8b¤\8bò\82¢\82¾\81I\8cã\89÷\82·\82é\82¼\81I");
687         }
688         HAggravate_monster |= FROMOUTSIDE;
689         change_luck(-rn1(4, 2)); /* -5..-2 */
690         return TRUE;
691     }
692     return FALSE;
693 }
694
695 STATIC_OVL void
696 cprefx(pm)
697 register int pm;
698 {
699     (void) maybe_cannibal(pm, TRUE);
700     if (flesh_petrifies(&mons[pm])) {
701         if (!Stone_resistance
702             && !(poly_when_stoned(youmonst.data)
703                  && polymon(PM_STONE_GOLEM))) {
704 /*JP
705             Sprintf(killer.name, "tasting %s meat", mons[pm].mname);
706 */
707             Sprintf(killer.name, "%s\82Ì\93÷\82ð\90H\82×", mons[pm].mname);
708             killer.format = KILLED_BY;
709 /*JP
710             You("turn to stone.");
711 */
712             You("\90Î\82É\82È\82Á\82½\81D");
713             done(STONING);
714             if (context.victual.piece)
715                 context.victual.eating = FALSE;
716             return; /* lifesaved */
717         }
718     }
719
720     switch (pm) {
721     case PM_LITTLE_DOG:
722     case PM_DOG:
723     case PM_LARGE_DOG:
724     case PM_KITTEN:
725     case PM_HOUSECAT:
726     case PM_LARGE_CAT:
727         /* cannibals are allowed to eat domestic animals without penalty */
728         if (!CANNIBAL_ALLOWED()) {
729 /*JP
730             You_feel("that eating the %s was a bad idea.", mons[pm].mname);
731 */
732             pline("%s\82ð\90H\82×\82é\82Ì\82Í\82æ\82­\82È\82¢\8bC\82ª\82µ\82½\81D", mons[pm].mname);
733             HAggravate_monster |= FROMOUTSIDE;
734         }
735         break;
736     case PM_LIZARD:
737         if (Stoned)
738             fix_petrification();
739         break;
740     case PM_DEATH:
741     case PM_PESTILENCE:
742     case PM_FAMINE: {
743 /*JP
744         pline("Eating that is instantly fatal.");
745 */
746         pline("\90H\82×\82½\82ç\82·\82®\82É\8e\80\82ñ\82Å\82µ\82Ü\82Á\82½\81D");
747 #if 0 /*JP*/
748         Sprintf(killer.name, "unwisely ate the body of %s", mons[pm].mname);
749         killer.format = NO_KILLER_PREFIX;
750 #else
751         Sprintf(killer.name, "\8bð\82©\82É\82à%s\82Ì\91Ì\82ð\90H\82×\82Ä", mons[pm].mname);
752         killer.format = KILLED_BY;
753 #endif
754         done(DIED);
755         /* life-saving needed to reach here */
756         exercise(A_WIS, FALSE);
757         /* It so happens that since we know these monsters */
758         /* cannot appear in tins, context.victual.piece will always */
759         /* be what we want, which is not generally true. */
760         if (revive_corpse(context.victual.piece)) {
761             context.victual.piece = (struct obj *) 0;
762             context.victual.o_id = 0;
763         }
764         return;
765     }
766     case PM_GREEN_SLIME:
767         if (!Slimed && !Unchanging && !slimeproof(youmonst.data)) {
768 /*JP
769             You("don't feel very well.");
770 */
771             You("\82·\82²\82­\8bC\95ª\82ª\88«\82¢\81D");
772             make_slimed(10L, (char *) 0);
773             delayed_killer(SLIMED, KILLED_BY_AN, "");
774         }
775     /* Fall through */
776     default:
777         if (acidic(&mons[pm]) && Stoned)
778             fix_petrification();
779         break;
780     }
781 }
782
783 void
784 fix_petrification()
785 {
786     char buf[BUFSZ];
787
788     if (Hallucination)
789 #if 0 /*JP*/
790         Sprintf(buf, "What a pity--you just ruined a future piece of %sart!",
791                 ACURR(A_CHA) > 15 ? "fine " : "");
792 #else
793         Sprintf(buf, "\82È\82ñ\82Ä\82±\82Æ\82¾\81I%s\8c|\8fp\8dì\95i\82É\82È\82ê\82½\82©\82à\82µ\82ê\82È\82¢\82Ì\82É\81I",
794                 ACURR(A_CHA) > 15 ? "\8bM\8fd\82È" : "");
795 #endif
796     else
797 /*JP
798         Strcpy(buf, "You feel limber!");
799 */
800         Strcpy(buf, "\91Ì\82ª\93î\82ç\82©\82­\82È\82Á\82½\82æ\82¤\82È\8bC\82ª\82µ\82½\81I");
801     make_stoned(0L, buf, 0, (char *) 0);
802 }
803
804 /*
805  * If you add an intrinsic that can be gotten by eating a monster, add it
806  * to intrinsic_possible() and givit().  (It must already be in prop.h to
807  * be an intrinsic property.)
808  * It would be very easy to make the intrinsics not try to give you one
809  * that you already had by checking to see if you have it in
810  * intrinsic_possible() instead of givit(), but we're not that nice.
811  */
812
813 /* intrinsic_possible() returns TRUE iff a monster can give an intrinsic. */
814 STATIC_OVL int
815 intrinsic_possible(type, ptr)
816 int type;
817 register struct permonst *ptr;
818 {
819     int res = 0;
820
821 #ifdef DEBUG
822 #define ifdebugresist(Msg)      \
823     do {                        \
824         if (res)                \
825             debugpline0(Msg);   \
826     } while (0)
827 #else
828 #define ifdebugresist(Msg) /*empty*/
829 #endif
830     switch (type) {
831     case FIRE_RES:
832         res = (ptr->mconveys & MR_FIRE) != 0;
833         ifdebugresist("can get fire resistance");
834         break;
835     case SLEEP_RES:
836         res = (ptr->mconveys & MR_SLEEP) != 0;
837         ifdebugresist("can get sleep resistance");
838         break;
839     case COLD_RES:
840         res = (ptr->mconveys & MR_COLD) != 0;
841         ifdebugresist("can get cold resistance");
842         break;
843     case DISINT_RES:
844         res = (ptr->mconveys & MR_DISINT) != 0;
845         ifdebugresist("can get disintegration resistance");
846         break;
847     case SHOCK_RES: /* shock (electricity) resistance */
848         res = (ptr->mconveys & MR_ELEC) != 0;
849         ifdebugresist("can get shock resistance");
850         break;
851     case POISON_RES:
852         res = (ptr->mconveys & MR_POISON) != 0;
853         ifdebugresist("can get poison resistance");
854         break;
855     case TELEPORT:
856         res = can_teleport(ptr);
857         ifdebugresist("can get teleport");
858         break;
859     case TELEPORT_CONTROL:
860         res = control_teleport(ptr);
861         ifdebugresist("can get teleport control");
862         break;
863     case TELEPAT:
864         res = telepathic(ptr);
865         ifdebugresist("can get telepathy");
866         break;
867     default:
868         /* res stays 0 */
869         break;
870     }
871 #undef ifdebugresist
872     return res;
873 }
874
875 /* givit() tries to give you an intrinsic based on the monster's level
876  * and what type of intrinsic it is trying to give you.
877  */
878 STATIC_OVL void
879 givit(type, ptr)
880 int type;
881 register struct permonst *ptr;
882 {
883     register int chance;
884
885     debugpline1("Attempting to give intrinsic %d", type);
886     /* some intrinsics are easier to get than others */
887     switch (type) {
888     case POISON_RES:
889         if ((ptr == &mons[PM_KILLER_BEE] || ptr == &mons[PM_SCORPION])
890             && !rn2(4))
891             chance = 1;
892         else
893             chance = 15;
894         break;
895     case TELEPORT:
896         chance = 10;
897         break;
898     case TELEPORT_CONTROL:
899         chance = 12;
900         break;
901     case TELEPAT:
902         chance = 1;
903         break;
904     default:
905         chance = 15;
906         break;
907     }
908
909     if (ptr->mlevel <= rn2(chance))
910         return; /* failed die roll */
911
912     switch (type) {
913     case FIRE_RES:
914         debugpline0("Trying to give fire resistance");
915         if (!(HFire_resistance & FROMOUTSIDE)) {
916 /*JP
917             You(Hallucination ? "be chillin'." : "feel a momentary chill.");
918 */
919             You(Hallucination ? "\81u\83N\81[\83\8b\91î\94z\95Ö\81v\82³\82ê\82Ä\82¢\82é\82æ\82¤\82¾\81D" : "\88ê\8fu\8a¦\82¯\82ª\82µ\82½\81D");
920             HFire_resistance |= FROMOUTSIDE;
921         }
922         break;
923     case SLEEP_RES:
924         debugpline0("Trying to give sleep resistance");
925         if (!(HSleep_resistance & FROMOUTSIDE)) {
926 /*JP
927             You_feel("wide awake.");
928 */
929             You("\82Ï\82Á\82¿\82è\96Ú\82ª\82³\82ß\82½\81D");
930             HSleep_resistance |= FROMOUTSIDE;
931         }
932         break;
933     case COLD_RES:
934         debugpline0("Trying to give cold resistance");
935         if (!(HCold_resistance & FROMOUTSIDE)) {
936 /*JP
937             You_feel("full of hot air.");
938 */
939             You("\94M\95\97\82ð\91S\90g\82É\8a´\82\82½\81D");
940             HCold_resistance |= FROMOUTSIDE;
941         }
942         break;
943     case DISINT_RES:
944         debugpline0("Trying to give disintegration resistance");
945         if (!(HDisint_resistance & FROMOUTSIDE)) {
946 /*JP
947             You_feel(Hallucination ? "totally together, man." : "very firm.");
948 */
949             You_feel(Hallucination ? "\90¢\8aE\90l\97Þ\82Æ\8cZ\92í\82É\82È\82Á\82½\82æ\82¤\82È\8bC\82ª\82µ\82½\81D" : "\82Æ\82Ä\82à\8aæ\8fä\82É\82È\82Á\82½\82æ\82¤\82È\8bC\82ª\82µ\82½\81D");
950             HDisint_resistance |= FROMOUTSIDE;
951         }
952         break;
953     case SHOCK_RES: /* shock (electricity) resistance */
954         debugpline0("Trying to give shock resistance");
955         if (!(HShock_resistance & FROMOUTSIDE)) {
956             if (Hallucination)
957 /*JP
958                 You_feel("grounded in reality.");
959 */
960               You("\8eÀ\82Í\83A\81[\83X\82³\82ê\82Ä\82¢\82é\82æ\82¤\82È\8bC\82ª\82µ\82½\81D");
961             else
962 /*JP
963                 Your("health currently feels amplified!");
964 */
965               pline("\8c\92\8dN\82ª\91\9d\95\9d\82³\82ê\82½\82æ\82¤\82È\8bC\82ª\82µ\82½\81I");
966             HShock_resistance |= FROMOUTSIDE;
967         }
968         break;
969     case POISON_RES:
970         debugpline0("Trying to give poison resistance");
971         if (!(HPoison_resistance & FROMOUTSIDE)) {
972 /*JP
973             You_feel(Poison_resistance ? "especially healthy." : "healthy.");
974 */
975             You_feel(Poison_resistance ? "\93Á\82É\8c\92\8dN\82É\82È\82Á\82½\8bC\82ª\82µ\82½\81D" : "\8c\92\8dN\82É\82È\82Á\82½\8bC\82ª\82µ\82½\81D");
976             HPoison_resistance |= FROMOUTSIDE;
977         }
978         break;
979     case TELEPORT:
980         debugpline0("Trying to give teleport");
981         if (!(HTeleportation & FROMOUTSIDE)) {
982 /*JP
983             You_feel(Hallucination ? "diffuse." : "very jumpy.");
984 */
985             pline(Hallucination ? "\91Ì\82ª\94ò\82Ñ\8eU\82Á\82½\82æ\82¤\82È\8bC\82ª\82µ\82½\81D" : "\92µ\96ô\97Í\82ª\8d\82\82Ü\82Á\82½\82æ\82¤\82È\8bC\82ª\82µ\82½\81D");
986             HTeleportation |= FROMOUTSIDE;
987         }
988         break;
989     case TELEPORT_CONTROL:
990         debugpline0("Trying to give teleport control");
991         if (!(HTeleport_control & FROMOUTSIDE)) {
992 #if 0 /*JP*/
993             You_feel(Hallucination ? "centered in your personal space."
994                                    : "in control of yourself.");
995 #else
996             You_feel(Hallucination ? "\8e©\8cÈ\92\86\90S\93I\82É\82È\82Á\82½\82æ\82¤\82È\8bC\82ª\82µ\82½\81D"
997                                    : "\8e©\95ª\8e©\90g\82ð\90§\8cä\82Å\82«\82é\82æ\82¤\82È\8bC\82ª\82µ\82½\81D");
998 #endif
999             HTeleport_control |= FROMOUTSIDE;
1000         }
1001         break;
1002     case TELEPAT:
1003         debugpline0("Trying to give telepathy");
1004         if (!(HTelepat & FROMOUTSIDE)) {
1005 #if 0 /*JP*/
1006             You_feel(Hallucination ? "in touch with the cosmos."
1007                                    : "a strange mental acuity.");
1008 #else
1009             You_feel(Hallucination ? "\89F\92\88\82Ì\90_\94é\82É\90G\82ê\82½\82æ\82¤\82È\8bC\82ª\82µ\82½\81D"
1010                                    : "\8aï\96­\82È\90¸\90_\93I\89s\82³\82ð\8a´\82\82½\81D");
1011 #endif
1012             HTelepat |= FROMOUTSIDE;
1013             /* If blind, make sure monsters show up. */
1014             if (Blind)
1015                 see_monsters();
1016         }
1017         break;
1018     default:
1019         debugpline0("Tried to give an impossible intrinsic");
1020         break;
1021     }
1022 }
1023
1024 /* called after completely consuming a corpse */
1025 STATIC_OVL void
1026 cpostfx(pm)
1027 register int pm;
1028 {
1029     register int tmp = 0;
1030     boolean catch_lycanthropy = FALSE;
1031
1032     /* in case `afternmv' didn't get called for previously mimicking
1033        gold, clean up now to avoid `eatmbuf' memory leak */
1034     if (eatmbuf)
1035         (void) eatmdone();
1036
1037     switch (pm) {
1038     case PM_NEWT:
1039         /* MRKR: "eye of newt" may give small magical energy boost */
1040         if (rn2(3) || 3 * u.uen <= 2 * u.uenmax) {
1041             int old_uen = u.uen;
1042             u.uen += rnd(3);
1043             if (u.uen > u.uenmax) {
1044                 if (!rn2(3))
1045                     u.uenmax++;
1046                 u.uen = u.uenmax;
1047             }
1048             if (old_uen != u.uen) {
1049 /*JP
1050                 You_feel("a mild buzz.");
1051 */
1052                 You("\82·\82±\82µ\82Ó\82ç\82Ó\82ç\82µ\82½\81D");
1053                 context.botl = 1;
1054             }
1055         }
1056         break;
1057     case PM_WRAITH:
1058         pluslvl(FALSE);
1059         break;
1060     case PM_HUMAN_WERERAT:
1061         catch_lycanthropy = TRUE;
1062         u.ulycn = PM_WERERAT;
1063         break;
1064     case PM_HUMAN_WEREJACKAL:
1065         catch_lycanthropy = TRUE;
1066         u.ulycn = PM_WEREJACKAL;
1067         break;
1068     case PM_HUMAN_WEREWOLF:
1069         catch_lycanthropy = TRUE;
1070         u.ulycn = PM_WEREWOLF;
1071         break;
1072     case PM_NURSE:
1073         if (Upolyd)
1074             u.mh = u.mhmax;
1075         else
1076             u.uhp = u.uhpmax;
1077         context.botl = 1;
1078         break;
1079     case PM_STALKER:
1080         if (!Invis) {
1081             set_itimeout(&HInvis, (long) rn1(100, 50));
1082             if (!Blind && !BInvis)
1083                 self_invis_message();
1084         } else {
1085             if (!(HInvis & INTRINSIC))
1086 /*JP
1087                 You_feel("hidden!");
1088 */
1089                 Your("\8ep\82Í\89B\82³\82ê\82½\81I");
1090             HInvis |= FROMOUTSIDE;
1091             HSee_invisible |= FROMOUTSIDE;
1092         }
1093         newsym(u.ux, u.uy);
1094         /*FALLTHRU*/
1095     case PM_YELLOW_LIGHT:
1096     case PM_GIANT_BAT:
1097         make_stunned((HStun & TIMEOUT) + 30L, FALSE);
1098         /*FALLTHRU*/
1099     case PM_BAT:
1100         make_stunned((HStun & TIMEOUT) + 30L, FALSE);
1101         break;
1102     case PM_GIANT_MIMIC:
1103         tmp += 10;
1104         /*FALLTHRU*/
1105     case PM_LARGE_MIMIC:
1106         tmp += 20;
1107         /*FALLTHRU*/
1108     case PM_SMALL_MIMIC:
1109         tmp += 20;
1110         if (youmonst.data->mlet != S_MIMIC && !Unchanging) {
1111             char buf[BUFSZ];
1112
1113             u.uconduct.polyselfs++; /* you're changing form */
1114 #if 0 /*JP*/
1115             You_cant("resist the temptation to mimic %s.",
1116                      Hallucination ? "an orange" : "a pile of gold");
1117 #else
1118             You("%s\82ð\90^\8e\97\82µ\82½\82¢\97U\98f\82É\82©\82ç\82ê\82½\81D",
1119                      Hallucination ? "\83I\83\8c\83\93\83W" : "\8bà\89Ý\82Ì\8eR");
1120 #endif
1121             /* A pile of gold can't ride. */
1122             if (u.usteed)
1123                 dismount_steed(DISMOUNT_FELL);
1124             nomul(-tmp);
1125             multi_reason = "pretending to be a pile of gold";
1126             Sprintf(buf,
1127                     Hallucination
1128 /*JP
1129                        ? "You suddenly dread being peeled and mimic %s again!"
1130 */
1131                        ? "\93Ë\91R\8aÛ\97\87\82É\82³\82ê\82é\82Ì\82ª\8b°\82ë\82µ\82­\82È\82Á\82Ä\82Ü\82½%s\82Ì\90^\8e\97\82ð\82µ\82½\81I"
1132 /*JP
1133                        : "You now prefer mimicking %s again.",
1134 */
1135                        : "\82±\82ñ\82Ç\82Í\82Ü\82½%s\82Ì\90^\8e\97\82ª\82µ\82½\82­\82È\82Á\82½\81D",
1136                     an(Upolyd ? youmonst.data->mname : urace.noun));
1137             eatmbuf = dupstr(buf);
1138             nomovemsg = eatmbuf;
1139             afternmv = eatmdone;
1140             /* ??? what if this was set before? */
1141             youmonst.m_ap_type = M_AP_OBJECT;
1142             youmonst.mappearance = Hallucination ? ORANGE : GOLD_PIECE;
1143             newsym(u.ux, u.uy);
1144             curs_on_u();
1145             /* make gold symbol show up now */
1146             display_nhwindow(WIN_MAP, TRUE);
1147         }
1148         break;
1149     case PM_QUANTUM_MECHANIC:
1150 /*JP
1151         Your("velocity suddenly seems very uncertain!");
1152 */
1153         Your("\91¬\93x\82ª\93Ë\91R\81C\95s\8am\92è\82É\82È\82Á\82½\81I");
1154         if (HFast & INTRINSIC) {
1155             HFast &= ~INTRINSIC;
1156 /*JP
1157             You("seem slower.");
1158 */
1159             You("\92x\82­\82È\82Á\82½\82æ\82¤\82¾\81D");
1160         } else {
1161             HFast |= FROMOUTSIDE;
1162 /*JP
1163             You("seem faster.");
1164 */
1165             You("\91¬\82­\82È\82Á\82½\82æ\82¤\82¾\81D");
1166         }
1167         break;
1168     case PM_LIZARD:
1169         if ((HStun & TIMEOUT) > 2)
1170             make_stunned(2L, FALSE);
1171         if ((HConfusion & TIMEOUT) > 2)
1172             make_confused(2L, FALSE);
1173         break;
1174     case PM_CHAMELEON:
1175     case PM_DOPPELGANGER:
1176     case PM_SANDESTIN: /* moot--they don't leave corpses */
1177         if (Unchanging) {
1178             You_feel("momentarily different."); /* same as poly trap */
1179         } else {
1180 /*JP
1181             You_feel("a change coming over you.");
1182 */
1183             pline("\95Ï\89»\82ª\96K\82ê\82½\81D");
1184             polyself(0);
1185         }
1186         break;
1187     case PM_DISENCHANTER:
1188         /* picks an intrinsic at random and removes it; there's
1189            no feedback if hero already lacks the chosen ability */
1190         debugpline0("using attrcurse to strip an intrinsic");
1191         attrcurse();
1192         break;
1193     case PM_MIND_FLAYER:
1194     case PM_MASTER_MIND_FLAYER:
1195         if (ABASE(A_INT) < ATTRMAX(A_INT)) {
1196             if (!rn2(2)) {
1197 /*JP
1198                 pline("Yum! That was real brain food!");
1199 */
1200                 pline("\82¤\82Ü\82¢\81I\82±\82ê\82±\82»\96{\93\96\82Ì\81u\93ª\82Ì\97Ç\82­\82È\82é\90H\8e\96\81v\82¾\81I");
1201                 (void) adjattrib(A_INT, 1, FALSE);
1202                 break; /* don't give them telepathy, too */
1203             }
1204         } else {
1205 /*JP
1206             pline("For some reason, that tasted bland.");
1207 */
1208             pline("\82Ç\82¤\82µ\82½\82í\82¯\82©\81C\92W\94\92\82È\96¡\82¾\81D");
1209         }
1210     /*FALLTHRU*/
1211     default: {
1212         struct permonst *ptr = &mons[pm];
1213         boolean conveys_STR = is_giant(ptr);
1214         int i, count;
1215
1216         if (dmgtype(ptr, AD_STUN) || dmgtype(ptr, AD_HALU)
1217             || pm == PM_VIOLET_FUNGUS) {
1218 /*JP
1219             pline("Oh wow!  Great stuff!");
1220 */
1221             pline("\83\8f\81[\83H\81I\82±\82è\82á\82·\82²\82¢\81I");
1222             (void) make_hallucinated((HHallucination & TIMEOUT) + 200L, FALSE,
1223                                      0L);
1224         }
1225
1226         /* Check the monster for all of the intrinsics.  If this
1227          * monster can give more than one, pick one to try to give
1228          * from among all it can give.
1229          *
1230          * Strength from giants is now treated like an intrinsic
1231          * rather than being given unconditionally.
1232          */
1233         count = 0; /* number of possible intrinsics */
1234         tmp = 0;   /* which one we will try to give */
1235         if (conveys_STR) {
1236             count = 1;
1237             tmp = -1; /* use -1 as fake prop index for STR */
1238             debugpline1("\"Intrinsic\" strength, %d", tmp);
1239         }
1240         for (i = 1; i <= LAST_PROP; i++) {
1241             if (!intrinsic_possible(i, ptr))
1242                 continue;
1243             ++count;
1244             /* a 1 in count chance of replacing the old choice
1245                with this one, and a count-1 in count chance
1246                of keeping the old choice (note that 1 in 1 and
1247                0 in 1 are what we want for the first candidate) */
1248             if (!rn2(count)) {
1249                 debugpline2("Intrinsic %d replacing %d", i, tmp);
1250                 tmp = i;
1251             }
1252         }
1253         /* if strength is the only candidate, give it 50% chance */
1254         if (conveys_STR && count == 1 && !rn2(2))
1255             tmp = 0;
1256         /* if something was chosen, give it now (givit() might fail) */
1257         if (tmp == -1)
1258             gainstr((struct obj *) 0, 0, TRUE);
1259         else if (tmp > 0)
1260             givit(tmp, ptr);
1261     } break;
1262     }
1263
1264     if (catch_lycanthropy)
1265         retouch_equipment(2);
1266
1267     return;
1268 }
1269
1270 void
1271 violated_vegetarian()
1272 {
1273     u.uconduct.unvegetarian++;
1274     if (Role_if(PM_MONK)) {
1275 /*JP
1276         You_feel("guilty.");
1277 */
1278         pline("\8dß\82ð\8a´\82\82½\81D");
1279         adjalign(-1);
1280     }
1281     return;
1282 }
1283
1284 /* common code to check and possibly charge for 1 context.tin.tin,
1285  * will split() context.tin.tin if necessary */
1286 STATIC_PTR void
1287 costly_tin(alter_type)
1288 int alter_type; /* COST_xxx */
1289 {
1290     struct obj *tin = context.tin.tin;
1291
1292     if (carried(tin) ? tin->unpaid
1293                      : (costly_spot(tin->ox, tin->oy) && !tin->no_charge)) {
1294         if (tin->quan > 1L) {
1295             tin = context.tin.tin = splitobj(tin, 1L);
1296             context.tin.o_id = tin->o_id;
1297         }
1298         costly_alteration(tin, alter_type);
1299     }
1300 }
1301
1302 int
1303 tin_variety_txt(s, tinvariety)
1304 char *s;
1305 int *tinvariety;
1306 {
1307     int k, l;
1308
1309     if (s && tinvariety) {
1310         *tinvariety = -1;
1311         for (k = 0; k < TTSZ - 1; ++k) {
1312             l = (int) strlen(tintxts[k].txt);
1313             if (!strncmpi(s, tintxts[k].txt, l) && ((int) strlen(s) > l)
1314                 && s[l] == ' ') {
1315                 *tinvariety = k;
1316                 return (l + 1);
1317             }
1318         }
1319     }
1320     return 0;
1321 }
1322
1323 /*
1324  * This assumes that buf already contains the word "tin",
1325  * as is the case with caller xname().
1326  */
1327 /*JP:\81u\8aÊ\8bl\81v\82Í\8cã\82Å\95t\82¯\82é */
1328 void
1329 tin_details(obj, mnum, buf)
1330 struct obj *obj;
1331 int mnum;
1332 char *buf;
1333 {
1334     char buf2[BUFSZ];
1335     int r = tin_variety(obj, TRUE);
1336
1337     if (obj && buf) {
1338         if (r == SPINACH_TIN)
1339 /*JP
1340             Strcat(buf, " of spinach");
1341 */
1342             Strcat(buf, "\83z\83E\83\8c\83\93\91\90\82Ì");
1343         else if (mnum == NON_PM)
1344 /*JP
1345             Strcpy(buf, "empty tin");
1346 */
1347             Strcat(buf, "\8bó\82Á\82Û\82Ì");
1348         else {
1349             if ((obj->cknown || iflags.override_ID) && obj->spe < 0) {
1350                 if (r == ROTTEN_TIN || r == HOMEMADE_TIN) {
1351                     /* put these before the word tin */
1352                     Sprintf(buf2, "%s %s of ", tintxts[r].txt, buf);
1353                     Strcpy(buf, buf2);
1354                 } else {
1355                     Sprintf(eos(buf), " of %s ", tintxts[r].txt);
1356                 }
1357             } else {
1358                 Strcpy(eos(buf), " of ");
1359             }
1360             if (vegetarian(&mons[mnum]))
1361 /*JP
1362                 Sprintf(eos(buf), "%s", mons[mnum].mname);
1363 */
1364                 Sprintf(eos(buf), "%s\82Ì", mons[mnum].mname);
1365             else
1366 /*JP
1367                 Sprintf(eos(buf), "%s meat", mons[mnum].mname);
1368 */
1369                 Sprintf(eos(buf), "%s\82Ì\93÷\82Ì", mons[mnum].mname);
1370         }
1371     }
1372 }
1373
1374 void
1375 set_tin_variety(obj, forcetype)
1376 struct obj *obj;
1377 int forcetype;
1378 {
1379     register int r;
1380
1381     if (forcetype == SPINACH_TIN
1382         || (forcetype == HEALTHY_TIN
1383             && (obj->corpsenm == NON_PM /* empty or already spinach */
1384                 || !vegetarian(&mons[obj->corpsenm])))) { /* replace meat */
1385         obj->corpsenm = NON_PM; /* not based on any monster */
1386         obj->spe = 1;           /* spinach */
1387         return;
1388     } else if (forcetype == HEALTHY_TIN) {
1389         r = tin_variety(obj, FALSE);
1390         if (r < 0 || r >= TTSZ)
1391             r = ROTTEN_TIN; /* shouldn't happen */
1392         while ((r == ROTTEN_TIN && !obj->cursed) || !tintxts[r].fodder)
1393             r = rn2(TTSZ - 1);
1394     } else if (forcetype >= 0 && forcetype < TTSZ - 1) {
1395         r = forcetype;
1396     } else {               /* RANDOM_TIN */
1397         r = rn2(TTSZ - 1); /* take your pick */
1398         if (r == ROTTEN_TIN && nonrotting_corpse(obj->corpsenm))
1399             r = HOMEMADE_TIN; /* lizards don't rot */
1400     }
1401     obj->spe = -(r + 1); /* offset by 1 to allow index 0 */
1402 }
1403
1404 STATIC_OVL int
1405 tin_variety(obj, disp)
1406 struct obj *obj;
1407 boolean disp; /* we're just displaying so leave things alone */
1408 {
1409     register int r;
1410
1411     if (obj->spe == 1) {
1412         r = SPINACH_TIN;
1413     } else if (obj->cursed) {
1414         r = ROTTEN_TIN; /* always rotten if cursed */
1415     } else if (obj->spe < 0) {
1416         r = -(obj->spe);
1417         --r; /* get rid of the offset */
1418     } else
1419         r = rn2(TTSZ - 1);
1420
1421     if (!disp && r == HOMEMADE_TIN && !obj->blessed && !rn2(7))
1422         r = ROTTEN_TIN; /* some homemade tins go bad */
1423
1424     if (r == ROTTEN_TIN && nonrotting_corpse(obj->corpsenm))
1425         r = HOMEMADE_TIN; /* lizards don't rot */
1426     return r;
1427 }
1428
1429 STATIC_OVL void
1430 consume_tin(mesg)
1431 const char *mesg;
1432 {
1433     const char *what;
1434     int which, mnum, r;
1435     struct obj *tin = context.tin.tin;
1436
1437     r = tin_variety(tin, FALSE);
1438     if (tin->otrapped || (tin->cursed && r != HOMEMADE_TIN && !rn2(8))) {
1439         b_trapped("tin", 0);
1440         costly_tin(COST_DSTROY);
1441         goto use_up_tin;
1442     }
1443
1444     pline1(mesg); /* "You succeed in opening the tin." */
1445
1446     if (r != SPINACH_TIN) {
1447         mnum = tin->corpsenm;
1448         if (mnum == NON_PM) {
1449 /*JP
1450             pline("It turns out to be empty.");
1451 */
1452             pline("\8aÊ\82Í\8bó\82Á\82Û\82¾\82Á\82½\81D");
1453             tin->dknown = tin->known = 1;
1454             costly_tin(COST_OPEN);
1455             goto use_up_tin;
1456         }
1457
1458         which = 0; /* 0=>plural, 1=>as-is, 2=>"the" prefix */
1459         if ((mnum == PM_COCKATRICE || mnum == PM_CHICKATRICE)
1460             && (Stone_resistance || Hallucination)) {
1461             what = "chicken";
1462             which = 1; /* suppress pluralization */
1463         } else if (Hallucination) {
1464             what = rndmonnam(NULL);
1465         } else {
1466             what = mons[mnum].mname;
1467             if (the_unique_pm(&mons[mnum]))
1468                 which = 2;
1469             else if (type_is_pname(&mons[mnum]))
1470                 which = 1;
1471         }
1472         if (which == 0)
1473             what = makeplural(what);
1474         else if (which == 2)
1475             what = the(what);
1476
1477 /*JP
1478         pline("It smells like %s.", what);
1479 */
1480         pline("%s\82Ì\82æ\82¤\82È\93õ\82¢\82ª\82µ\82½\81D", what);
1481 /*JP
1482         if (yn("Eat it?") == 'n') {
1483 */
1484         if (yn("\90H\82×\82Ü\82·\82©\81H") == 'n') {
1485             if (flags.verbose)
1486 /*JP
1487                 You("discard the open tin.");
1488 */
1489                 You("\8aJ\82¯\82½\8aÊ\82ð\8eÌ\82Ä\82½\81D");
1490             if (!Hallucination)
1491                 tin->dknown = tin->known = 1;
1492             costly_tin(COST_OPEN);
1493             goto use_up_tin;
1494         }
1495
1496         /* in case stop_occupation() was called on previous meal */
1497         context.victual.piece = (struct obj *) 0;
1498         context.victual.o_id = 0;
1499         context.victual.fullwarn = context.victual.eating =
1500             context.victual.doreset = FALSE;
1501
1502 #if 0 /*JP*/
1503         You("consume %s %s.", tintxts[r].txt, mons[mnum].mname);
1504 #else /*JP: \81u\82Ì\81v\82Å\8en\82Ü\82é\82È\82ç\8cã\92u\81A\82»\82ê\88È\8aO\82È\82ç\91O\92u */
1505         if (strstr(tintxts[r].txt, "\82Ì") == tintxts[r].txt) {
1506             You("%s%s\82Ì\8aÊ\8bl\82ð\82½\82¢\82ç\82°\82½\81D", mons[mnum].mname, tintxts[r].txt);
1507         } else {
1508             You("%s%s\82Ì\8aÊ\8bl\82ð\82½\82¢\82ç\82°\82½\81D", tintxts[r].txt, mons[mnum].mname);
1509         }
1510 #endif
1511
1512         eating_conducts(&mons[mnum]);
1513
1514         tin->dknown = tin->known = 1;
1515         cprefx(mnum);
1516         cpostfx(mnum);
1517
1518         /* charge for one at pre-eating cost */
1519         costly_tin(COST_OPEN);
1520
1521         if (tintxts[r].nut < 0) /* rotten */
1522             make_vomiting((long) rn1(15, 10), FALSE);
1523         else
1524             lesshungry(tintxts[r].nut);
1525
1526         if (tintxts[r].greasy) {
1527             /* Assume !Glib, because you can't open tins when Glib. */
1528             incr_itimeout(&Glib, rnd(15));
1529 #if 0 /*JP*/
1530             pline("Eating %s food made your %s very slippery.",
1531                   tintxts[r].txt, makeplural(body_part(FINGER)));
1532 #else
1533             pline("\96û\82Á\82Û\82¢\95¨\82ð\90H\82×\82½\82Ì\82Å\82 \82È\82½\82Ì%s\82Í\8a\8a\82è\82â\82·\82­\82È\82Á\82½\81D",
1534                   body_part(FINGER));
1535 #endif
1536         }
1537
1538     } else { /* spinach... */
1539         if (tin->cursed) {
1540 #if 0 /*JP*/
1541             pline("It contains some decaying%s%s substance.",
1542                   Blind ? "" : " ", Blind ? "" : hcolor(NH_GREEN));
1543 #else
1544             pline("%s\95\85\82Á\82½\95¨\91Ì\82ª\93ü\82Á\82Ä\82¢\82é\81D",
1545                   Blind ? "" : hcolor(NH_GREEN));
1546 #endif
1547         } else {
1548 /*JP
1549             pline("It contains spinach.");
1550 */
1551             pline("\83z\83E\83\8c\83\93\91\90\82ª\93ü\82Á\82Ä\82¢\82é\81D");
1552             tin->dknown = tin->known = 1;
1553         }
1554
1555 /*JP
1556         if (yn("Eat it?") == 'n') {
1557 */
1558         if (yn("\90H\82×\82Ü\82·\82©\81H") == 'n') {
1559             if (flags.verbose)
1560 /*JP
1561                 You("discard the open tin.");
1562 */
1563                 You("\8aJ\82¯\82½\8aÊ\82ð\8eÌ\82Ä\82½\81D");
1564             costly_tin(COST_OPEN);
1565             goto use_up_tin;
1566         }
1567
1568         /*
1569          * Same order as with non-spinach above:
1570          * conduct update, side-effects, shop handling, and nutrition.
1571          */
1572         u.uconduct
1573             .food++; /* don't need vegan/vegetarian checks for spinach */
1574         if (!tin->cursed)
1575 #if 0 /*JP:T*/
1576             pline("This makes you feel like %s!",
1577                   Hallucination ? "Swee'pea" : "Popeye");
1578 #else
1579             pline("%s\82Ì\82æ\82¤\82È\8bC\95ª\82É\82È\82Á\82½\81I",
1580                   Hallucination ? "\83X\83C\81[\83s\81[" : "\83|\83p\83C");
1581 #endif
1582         gainstr(tin, 0, FALSE);
1583
1584         costly_tin(COST_OPEN);
1585
1586         lesshungry(tin->blessed
1587                       ? 600                   /* blessed */
1588                       : !tin->cursed
1589                          ? (400 + rnd(200))   /* uncursed */
1590                          : (200 + rnd(400))); /* cursed */
1591     }
1592
1593 use_up_tin:
1594     if (carried(tin))
1595         useup(tin);
1596     else
1597         useupf(tin, 1L);
1598     context.tin.tin = (struct obj *) 0;
1599     context.tin.o_id = 0;
1600 }
1601
1602 /* called during each move whilst opening a tin */
1603 STATIC_PTR int
1604 opentin(VOID_ARGS)
1605 {
1606     /* perhaps it was stolen (although that should cause interruption) */
1607     if (!carried(context.tin.tin)
1608         && (!obj_here(context.tin.tin, u.ux, u.uy) || !can_reach_floor(TRUE)))
1609         return 0; /* %% probably we should use tinoid */
1610     if (context.tin.usedtime++ >= 50) {
1611 /*JP
1612         You("give up your attempt to open the tin.");
1613 */
1614         You("\8aÊ\82ð\8aJ\82¯\82é\82Ì\82ð\82 \82«\82ç\82ß\82½\81D");
1615         return 0;
1616     }
1617     if (context.tin.usedtime < context.tin.reqtime)
1618         return 1; /* still busy */
1619
1620 /*JP
1621     consume_tin("You succeed in opening the tin.");
1622 */
1623     consume_tin("\8aÊ\82ð\8aJ\82¯\82é\82Ì\82É\90¬\8c÷\82µ\82½\81D");
1624     return 0;
1625 }
1626
1627 /* called when starting to open a tin */
1628 STATIC_OVL void
1629 start_tin(otmp)
1630 struct obj *otmp;
1631 {
1632     const char *mesg = 0;
1633     register int tmp;
1634
1635     if (metallivorous(youmonst.data)) {
1636 /*JP
1637         mesg = "You bite right into the metal tin...";
1638 */
1639         mesg = "\8bà\91®\82Ì\8aÊ\82ð\8a\9a\82Ý\82Í\82\82ß\82½\81D\81D\81D";
1640         tmp = 0;
1641     } else if (cantwield(youmonst.data)) { /* nohands || verysmall */
1642 /*JP
1643         You("cannot handle the tin properly to open it.");
1644 */
1645         You("\8aÊ\82ð\82¤\82Ü\82­\8aJ\82¯\82ç\82ê\82È\82¢\81D");
1646         return;
1647     } else if (otmp->blessed) {
1648         /* 50/50 chance for immediate access vs 1 turn delay (unless
1649            wielding blessed tin opener which always yields immediate
1650            access); 1 turn delay case is non-deterministic:  getting
1651            interrupted and retrying might yield another 1 turn delay
1652            or might open immediately on 2nd (or 3rd, 4th, ...) try */
1653         tmp = (uwep && uwep->blessed && uwep->otyp == TIN_OPENER) ? 0 : rn2(2);
1654         if (!tmp)
1655 /*JP
1656             mesg = "The tin opens like magic!";
1657 */
1658             mesg = "\8aÊ\82Í\96\82\96@\82Ì\82æ\82¤\82É\8aJ\82¢\82½\81I";
1659         else
1660             pline_The("tin seems easy to open.");
1661     } else if (uwep) {
1662         switch (uwep->otyp) {
1663         case TIN_OPENER:
1664             mesg = "You easily open the tin."; /* iff tmp==0 */
1665             tmp = rn2(uwep->cursed ? 3 : !uwep->blessed ? 2 : 1);
1666             break;
1667         case DAGGER:
1668         case SILVER_DAGGER:
1669         case ELVEN_DAGGER:
1670         case ORCISH_DAGGER:
1671         case ATHAME:
1672         case CRYSKNIFE:
1673             tmp = 3;
1674             break;
1675         case PICK_AXE:
1676         case AXE:
1677             tmp = 6;
1678             break;
1679         default:
1680             goto no_opener;
1681         }
1682 /*JP
1683         pline("Using %s you try to open the tin.", yobjnam(uwep, (char *) 0));
1684 */
1685         You("%s\82ð\8eg\82Á\82Ä\8aÊ\82ð\8aJ\82¯\82æ\82¤\82Æ\82µ\82½\81D", xname(uwep));
1686     } else {
1687     no_opener:
1688 /*JP
1689         pline("It is not so easy to open this tin.");
1690 */
1691         pline("\82±\82Ì\8aÊ\82ð\8aJ\82¯\82é\82Ì\82Í\97e\88Õ\82È\82±\82Æ\82Å\82Í\82È\82¢\81D");
1692         if (Glib) {
1693 /*JP
1694             pline_The("tin slips from your %s.",
1695 */
1696             pline("\8aÊ\82Í\82 \82È\82½\82Ì%s\82©\82ç\8a\8a\82è\97\8e\82¿\82½\81D",
1697                       makeplural(body_part(FINGER)));
1698             if (otmp->quan > 1L) {
1699                 otmp = splitobj(otmp, 1L);
1700             }
1701             if (carried(otmp))
1702                 dropx(otmp);
1703             else
1704                 stackobj(otmp);
1705             return;
1706         }
1707         tmp = rn1(1 + 500 / ((int) (ACURR(A_DEX) + ACURRSTR)), 10);
1708     }
1709
1710     context.tin.tin = otmp;
1711     context.tin.o_id = otmp->o_id;
1712     if (!tmp) {
1713         consume_tin(mesg); /* begin immediately */
1714     } else {
1715         context.tin.reqtime = tmp;
1716         context.tin.usedtime = 0;
1717 /*JP
1718         set_occupation(opentin, "opening the tin", 0);
1719 */
1720         set_occupation(opentin, "\8aÊ\82ð\8aJ\82¯\82é", 0);
1721     }
1722     return;
1723 }
1724
1725 /* called when waking up after fainting */
1726 int
1727 Hear_again(VOID_ARGS)
1728 {
1729     /* Chance of deafness going away while fainted/sleeping/etc. */
1730     if (!rn2(2))
1731         make_deaf(0L, FALSE);
1732     return 0;
1733 }
1734
1735 /* called on the "first bite" of rotten food */
1736 STATIC_OVL int
1737 rottenfood(obj)
1738 struct obj *obj;
1739 {
1740 /*JP
1741     pline("Blecch!  Rotten %s!", foodword(obj));
1742 */
1743     pline("\83Q\83F\81I\95\85\82Á\82½%s\82¾\81I", foodword(obj));
1744     if (!rn2(4)) {
1745         if (Hallucination)
1746 /*JP
1747             You_feel("rather trippy.");
1748 */
1749             You("\82Ö\82ë\82Ö\82ë\82µ\82½\81D");
1750         else
1751 /*JP
1752             You_feel("rather %s.", body_part(LIGHT_HEADED));
1753 */
1754             You("%s\81D", body_part(LIGHT_HEADED));
1755         make_confused(HConfusion + d(2, 4), FALSE);
1756     } else if (!rn2(4) && !Blind) {
1757 /*JP
1758         pline("Everything suddenly goes dark.");
1759 */
1760         pline("\93Ë\91R\91S\82Ä\82ª\88Ã\82­\82È\82Á\82½\81D");
1761         make_blinded((long) d(2, 10), FALSE);
1762         if (!Blind)
1763             Your1(vision_clears);
1764     } else if (!rn2(3)) {
1765         const char *what, *where;
1766         int duration = rnd(10);
1767
1768         if (!Blind)
1769 /*JP
1770             what = "goes", where = "dark";
1771 */
1772             what = "\82È\82Á\82½", where = "\88Ã\88Å\82É";
1773         else if (Levitation || Is_airlevel(&u.uz) || Is_waterlevel(&u.uz))
1774 /*JP
1775             what = "you lose control of", where = "yourself";
1776 */
1777             what = "\90§\8cä\82Å\82«\82È\82­\82È\82Á\82½", where = "\8e©\95ª\82ð";
1778         else
1779 /*JP
1780             what = "you slap against the",
1781 */
1782             what = "\82É\82Ô\82Â\82©\82Á\82½",
1783 /*JP
1784             where = (u.usteed) ? "saddle" : surface(u.ux, u.uy);
1785 */
1786             where = (u.usteed) ? "\88Æ" : surface(u.ux, u.uy);
1787 /*JP
1788         pline_The("world spins and %s %s.", what, where);
1789 */
1790         pline("\90¢\8aE\82ª\89ñ\93]\82µ\81C%s%s\81D", where, what);
1791         incr_itimeout(&HDeaf, duration);
1792         nomul(-duration);
1793         multi_reason = "unconscious from rotten food";
1794 /*JP
1795         nomovemsg = "You are conscious again.";
1796 */
1797         nomovemsg = "\82 \82È\82½\82Í\82Ü\82½\90³\8bC\82Ã\82¢\82½\81D";
1798         afternmv = Hear_again;
1799         return 1;
1800     }
1801     return 0;
1802 }
1803
1804 /* called when a corpse is selected as food */
1805 STATIC_OVL int
1806 eatcorpse(otmp)
1807 struct obj *otmp;
1808 {
1809     int tp = 0, mnum = otmp->corpsenm;
1810     long rotted = 0L;
1811     int retcode = 0;
1812     boolean stoneable = (flesh_petrifies(&mons[mnum]) && !Stone_resistance
1813                          && !poly_when_stoned(youmonst.data));
1814
1815     /* KMH, conduct */
1816     if (!vegan(&mons[mnum]))
1817         u.uconduct.unvegan++;
1818     if (!vegetarian(&mons[mnum]))
1819         violated_vegetarian();
1820
1821     if (!nonrotting_corpse(mnum)) {
1822         long age = peek_at_iced_corpse_age(otmp);
1823
1824         rotted = (monstermoves - age) / (10L + rn2(20));
1825         if (otmp->cursed)
1826             rotted += 2L;
1827         else if (otmp->blessed)
1828             rotted -= 2L;
1829     }
1830
1831     if (mnum != PM_ACID_BLOB && !stoneable && rotted > 5L) {
1832         boolean cannibal = maybe_cannibal(mnum, FALSE);
1833
1834 #if 0 /*JP*/
1835         pline("Ulch - that %s was tainted%s!",
1836               mons[mnum].mlet == S_FUNGUS
1837                   ? "fungoid vegetation"
1838                   : !vegetarian(&mons[mnum]) ? "meat" : "protoplasm",
1839               cannibal ? ", you cannibal" : "");
1840 #else
1841         pline("\83I\83F\81I\82±\82Ì%s\82Í\95\85\82Á\82Ä\82¢\82é%s\81I", 
1842               mons[mnum].mlet == S_FUNGUS
1843                   ? "\8d×\8bÛ\82É\89\98\90õ\82³\82ê\82½\90A\95¨"
1844                   : !vegetarian(&mons[mnum]) ? "\93÷" : "\90\95¨",
1845               cannibal ? "\81D\82µ\82©\82à\8b¤\90H\82¢\82¾" : "");
1846 #endif
1847         if (Sick_resistance) {
1848 /*JP
1849             pline("It doesn't seem at all sickening, though...");
1850 */
1851             pline("\82µ\82©\82µ\81C\82¢\82½\82Á\82Ä\8c³\8bC\82¾\81D\81D\81D");
1852         } else {
1853             long sick_time;
1854
1855             sick_time = (long) rn1(10, 10);
1856             /* make sure new ill doesn't result in improvement */
1857             if (Sick && (sick_time > Sick))
1858                 sick_time = (Sick > 1L) ? Sick - 1L : 1L;
1859 #if 0 /*JP*/
1860             make_sick(sick_time, corpse_xname(otmp, "rotted", CXN_NORMAL),
1861                       TRUE, SICK_VOMITABLE);
1862 #else
1863             make_sick(sick_time, corpse_xname(otmp, "\95\85\82Á\82½", CXN_NORMAL),
1864                       TRUE, SICK_VOMITABLE);
1865 #endif
1866         }
1867         if (carried(otmp))
1868             useup(otmp);
1869         else
1870             useupf(otmp, 1L);
1871         return 2;
1872     } else if (acidic(&mons[mnum]) && !Acid_resistance) {
1873         tp++;
1874 #if 0 /*JP:T*/
1875         You("have a very bad case of stomach acid.");   /* not body_part() */
1876 #else
1877         pline("\88Ý\8e_\82Ì\92²\8eq\82ª\82Æ\82Ä\82à\88«\82¢\81D");
1878 #endif
1879 #if 0 /*JP*/
1880         losehp(rnd(15), "acidic corpse", KILLED_BY_AN); /* acid damage */
1881 #else
1882         losehp(rnd(15), "\8e_\82Ì\8e\80\91Ì\82Å", KILLED_BY_AN);
1883 #endif
1884     } else if (poisonous(&mons[mnum]) && rn2(5)) {
1885         tp++;
1886 /*JP
1887         pline("Ecch - that must have been poisonous!");
1888 */
1889         pline("\83E\83Q\83F\81[\81C\97L\93Å\82¾\82Á\82½\82É\82¿\82ª\82¢\82È\82¢\81I");  
1890         if (!Poison_resistance) {
1891             losestr(rnd(4));
1892 /*JP
1893             losehp(rnd(15), "poisonous corpse", KILLED_BY_AN);
1894 */
1895             losehp(rnd(15), "\93Å\82Ì\8e\80\91Ì\82Å", KILLED_BY_AN);
1896         } else
1897 /*JP
1898             You("seem unaffected by the poison.");
1899 */
1900             You("\93Å\82Ì\89e\8b¿\82ð\8eó\82¯\82È\82¢\82æ\82¤\82¾\81D");
1901         /* now any corpse left too long will make you mildly ill */
1902     } else if ((rotted > 5L || (rotted > 3L && rn2(5))) && !Sick_resistance) {
1903         tp++;
1904 /*JP
1905         You_feel("%ssick.", (Sick) ? "very " : "");
1906 */
1907         You("%s\8bC\95ª\82ª\88«\82¢\81D", (Sick) ? "\82Æ\82Ä\82à" : "");
1908 /*JP
1909         losehp(rnd(8), "cadaver", KILLED_BY_AN);
1910 */
1911         losehp(rnd(8), "\95\85\97\90\8e\80\91Ì\82Å", KILLED_BY_AN);
1912     }
1913
1914     /* delay is weight dependent */
1915     context.victual.reqtime = 3 + (mons[mnum].cwt >> 6);
1916
1917     if (!tp && !nonrotting_corpse(mnum) && (otmp->orotten || !rn2(7))) {
1918         if (rottenfood(otmp)) {
1919             otmp->orotten = TRUE;
1920             (void) touchfood(otmp);
1921             retcode = 1;
1922         }
1923
1924         if (!mons[otmp->corpsenm].cnutrit) {
1925             /* no nutrition: rots away, no message if you passed out */
1926             if (!retcode)
1927 /*JP
1928                 pline_The("corpse rots away completely.");
1929 */
1930                 pline("\8e\80\91Ì\82Í\8a®\91S\82É\95\85\82Á\82Ä\82µ\82Ü\82Á\82½\81D");
1931             if (carried(otmp))
1932                 useup(otmp);
1933             else
1934                 useupf(otmp, 1L);
1935             retcode = 2;
1936         }
1937
1938         if (!retcode)
1939             consume_oeaten(otmp, 2); /* oeaten >>= 2 */
1940     } else if ((mnum == PM_COCKATRICE || mnum == PM_CHICKATRICE)
1941                && (Stone_resistance || Hallucination)) {
1942         pline("This tastes just like chicken!");
1943     } else if (mnum == PM_FLOATING_EYE && u.umonnum == PM_RAVEN) {
1944         You("peck the eyeball with delight.");
1945     } else {
1946         /* [is this right?  omnivores end up always disliking the taste] */
1947         boolean yummy = vegan(&mons[mnum])
1948                            ? (!carnivorous(youmonst.data)
1949                               && herbivorous(youmonst.data))
1950                            : (carnivorous(youmonst.data)
1951                               && !herbivorous(youmonst.data));
1952
1953 #if 0 /*JP*/
1954         pline("%s%s %s!",
1955               type_is_pname(&mons[mnum])
1956                  ? "" : the_unique_pm(&mons[mnum]) ? "The " : "This ",
1957               food_xname(otmp, FALSE),
1958               Hallucination
1959                   ? (yummy ? ((u.umonnum == PM_TIGER) ? "is gr-r-reat"
1960                                                       : "is gnarly")
1961                            : "is grody")
1962                   : (yummy ? "is delicious" : "tastes terrible"));
1963 #else
1964         pline("\82±\82Ì%s\82Í%s\81I",
1965               food_xname(otmp, FALSE),
1966               Hallucination
1967                   ? (yummy ? ((u.umonnum == PM_TIGER) ? "\83O\83D\83\8c\83C\83g\83D"
1968                                                       : "\83C\83P\82Ä\82é")
1969                            : "\83C\83P\82Ä\82È\82¢")
1970                   : (yummy ? "\82Æ\82Ä\82à\8e|\82¢" : "\82Ð\82Ç\82¢\96¡\82¾"));
1971 #endif
1972     }
1973
1974     return retcode;
1975 }
1976
1977 /* called as you start to eat */
1978 STATIC_OVL void
1979 start_eating(otmp)
1980 struct obj *otmp;
1981 {
1982     const char *old_nomovemsg, *save_nomovemsg;
1983
1984     debugpline2("start_eating: %lx (victual = %lx)", (unsigned long) otmp,
1985                 (unsigned long) context.victual.piece);
1986     debugpline1("reqtime = %d", context.victual.reqtime);
1987     debugpline1("(original reqtime = %d)", objects[otmp->otyp].oc_delay);
1988     debugpline1("nmod = %d", context.victual.nmod);
1989     debugpline1("oeaten = %d", otmp->oeaten);
1990     context.victual.fullwarn = context.victual.doreset = FALSE;
1991     context.victual.eating = TRUE;
1992
1993     if (otmp->otyp == CORPSE || otmp->globby) {
1994         cprefx(context.victual.piece->corpsenm);
1995         if (!context.victual.piece || !context.victual.eating) {
1996             /* rider revived, or died and lifesaved */
1997             return;
1998         }
1999     }
2000
2001     old_nomovemsg = nomovemsg;
2002     if (bite()) {
2003         /* survived choking, finish off food that's nearly done;
2004            need this to handle cockatrice eggs, fortune cookies, etc */
2005         if (++context.victual.usedtime >= context.victual.reqtime) {
2006             /* don't want done_eating() to issue nomovemsg if it
2007                is due to vomit() called by bite() */
2008             save_nomovemsg = nomovemsg;
2009             if (!old_nomovemsg)
2010                 nomovemsg = 0;
2011             done_eating(FALSE);
2012             if (!old_nomovemsg)
2013                 nomovemsg = save_nomovemsg;
2014         }
2015         return;
2016     }
2017
2018     if (++context.victual.usedtime >= context.victual.reqtime) {
2019         /* print "finish eating" message if they just resumed -dlc */
2020         done_eating(context.victual.reqtime > 1 ? TRUE : FALSE);
2021         return;
2022     }
2023
2024 /*JP
2025     Sprintf(msgbuf, "eating %s", food_xname(otmp, TRUE));
2026 */
2027     Sprintf(msgbuf, "%s\82ð\90H\82×\82é", food_xname(otmp, TRUE));
2028     set_occupation(eatfood, msgbuf, 0);
2029 }
2030
2031 /*
2032  * called on "first bite" of (non-corpse) food.
2033  * used for non-rotten non-tin non-corpse food
2034  */
2035 STATIC_OVL void
2036 fprefx(otmp)
2037 struct obj *otmp;
2038 {
2039     switch (otmp->otyp) {
2040     case FOOD_RATION:
2041         if (u.uhunger <= 200)
2042 /*JP
2043             pline(Hallucination ? "Oh wow, like, superior, man!"
2044 */
2045             pline(Hallucination ? "\82Ü\82Á\82½\82è\82Æ\82µ\82Ä\81C\82»\82ê\82Å\82¢\82Ä\82µ\82Â\82±\82­\82È\82¢\81I\82±\82ê\82¼\8b\86\8bÉ\82Ì\83\81\83j\83\85\81[\82¾\81I"
2046 /*JP
2047                                 : "That food really hit the spot!");
2048 */
2049                                 : "That food really hit the spot!");
2050         else if (u.uhunger <= 700)
2051 /*JP
2052             pline("That satiated your %s!", body_part(STOMACH));
2053 */
2054             pline("\96\9e\95 \82É\82È\82Á\82½\81I");
2055         break;
2056     case TRIPE_RATION:
2057         if (carnivorous(youmonst.data) && !humanoid(youmonst.data))
2058 /*JP
2059             pline("That tripe ration was surprisingly good!");
2060 */
2061             pline("\82±\82Ì\83\82\83c\93÷\82Í\82¨\82Ç\82ë\82­\82Ù\82Ç\8e|\82¢\81I");
2062         else if (maybe_polyd(is_orc(youmonst.data), Race_if(PM_ORC)))
2063 /*JP
2064             pline(Hallucination ? "Tastes great! Less filling!"
2065 */
2066             pline(Hallucination ? "\82¤\82Ü\82¢\81I\82à\82Á\82Æ\82Ù\82µ\82­\82È\82é\82Ë\81I"
2067 /*JP
2068                                 : "Mmm, tripe... not bad!");
2069 */
2070                                 : "\82ñ\81[\81C\83\82\83c\82©\81D\81D\81D\88«\82­\82È\82¢\81I");
2071         else {
2072 /*JP
2073             pline("Yak - dog food!");
2074 */
2075             pline("\82¤\82°\81C\83h\83b\83O\83t\81[\83h\82¾\81I");
2076             more_experienced(1, 0);
2077             newexplevel();
2078             /* not cannibalism, but we use similar criteria
2079                for deciding whether to be sickened by this meal */
2080             if (rn2(2) && !CANNIBAL_ALLOWED())
2081                 make_vomiting((long) rn1(context.victual.reqtime, 14), FALSE);
2082         }
2083         break;
2084     case MEATBALL:
2085     case MEAT_STICK:
2086     case HUGE_CHUNK_OF_MEAT:
2087     case MEAT_RING:
2088         goto give_feedback;
2089     case CLOVE_OF_GARLIC:
2090         if (is_undead(youmonst.data)) {
2091             make_vomiting((long) rn1(context.victual.reqtime, 5), FALSE);
2092             break;
2093         }
2094         /* else FALLTHRU */
2095     default:
2096         if (otmp->otyp == SLIME_MOLD && !otmp->cursed
2097             && otmp->spe == context.current_fruit) {
2098 #if 0 /*JP*/
2099             pline("My, that was a %s %s!",
2100                   Hallucination ? "primo" : "yummy",
2101                   singular(otmp, xname));
2102 #else
2103             pline("\82¨\82â\81C\82È\82ñ\82Ä%s%s\82¾\81I",
2104                   Hallucination ? "\8fã\95i\82È" : "\82¨\82¢\82µ\82¢",
2105                   singular(otmp, xname));
2106 #endif
2107         } else if (otmp->otyp == APPLE && otmp->cursed && !Sleep_resistance) {
2108             ; /* skip core joke; feedback deferred til fpostfx() */
2109
2110 #if defined(MAC) || defined(MACOSX)
2111         /* KMH -- Why should Unix have all the fun?
2112            We check MACOSX before UNIX to get the Apple-specific apple
2113            message; the '#if UNIX' code will still kick in for pear. */
2114         } else if (otmp->otyp == APPLE) {
2115 /*JP
2116             pline("Delicious!  Must be a Macintosh!");
2117 */
2118             pline("\82·\82Î\82ç\82µ\82¢\81I\83}\83b\83L\83\93\83g\83b\83V\83\85\82É\88á\82¢\82È\82¢\81I");
2119 #endif
2120
2121 #ifdef UNIX
2122         } else if (otmp->otyp == APPLE || otmp->otyp == PEAR) {
2123             if (!Hallucination) {
2124                 pline("Core dumped.");
2125             } else {
2126                 /* This is based on an old Usenet joke, a fake a.out manual
2127                  * page
2128                  */
2129                 int x = rnd(100);
2130
2131                 pline("%s -- core dumped.",
2132                       (x <= 75)
2133                          ? "Segmentation fault"
2134                          : (x <= 99)
2135                             ? "Bus error"
2136                             : "Yo' mama");
2137             }
2138 #endif
2139         } else if (otmp->otyp == EGG && stale_egg(otmp)) {
2140 #if 0 /*JP*/
2141             pline("Ugh.  Rotten egg."); /* perhaps others like it */
2142 #else
2143             pline("\83E\83Q\83F\81[\95\85\82Á\82½\97\91\82¾\81D");
2144 #endif
2145             make_vomiting((Vomiting & TIMEOUT) + (long) d(10, 4), TRUE);
2146         } else {
2147         give_feedback:
2148 #if 0 /*JP*/
2149             pline("This %s is %s", singular(otmp, xname),
2150                   otmp->cursed
2151                      ? (Hallucination ? "grody!" : "terrible!")
2152                      : (otmp->otyp == CRAM_RATION
2153                         || otmp->otyp == K_RATION
2154                         || otmp->otyp == C_RATION)
2155                         ? "bland."
2156                         : Hallucination ? "gnarly!" : "delicious!");
2157 #else
2158             pline("\82±\82Ì%s\82Í%s", singular(otmp, xname),
2159                   otmp->cursed
2160                     ? (Hallucination ? "\83C\83P\82Ä\82È\82¢\81I" : "\82Ð\82Ç\82¢\96¡\82¾\81I")
2161                     : (otmp->otyp == CRAM_RATION
2162                         || otmp->otyp == K_RATION
2163                         || otmp->otyp == C_RATION)
2164                         ? "\96¡\8bC\82È\82¢\81D"
2165                         : Hallucination ? "\83C\83P\82Ä\82é\81I" : "\82¤\82Ü\82¢\81I");
2166 #endif
2167         }
2168         break; /* default */
2169     } /* switch */
2170 }
2171
2172 /* increment a combat intrinsic with limits on its growth */
2173 STATIC_OVL int
2174 bounded_increase(old, inc, typ)
2175 int old, inc, typ;
2176 {
2177     int absold, absinc, sgnold, sgninc;
2178
2179     /* don't include any amount coming from worn rings */
2180     if (uright && uright->otyp == typ)
2181         old -= uright->spe;
2182     if (uleft && uleft->otyp == typ)
2183         old -= uleft->spe;
2184     absold = abs(old), absinc = abs(inc);
2185     sgnold = sgn(old), sgninc = sgn(inc);
2186
2187     if (absinc == 0 || sgnold != sgninc || absold + absinc < 10) {
2188         ; /* use inc as-is */
2189     } else if (absold + absinc < 20) {
2190         absinc = rnd(absinc); /* 1..n */
2191         if (absold + absinc < 10)
2192             absinc = 10 - absold;
2193         inc = sgninc * absinc;
2194     } else if (absold + absinc < 40) {
2195         absinc = rn2(absinc) ? 1 : 0;
2196         if (absold + absinc < 20)
2197             absinc = rnd(20 - absold);
2198         inc = sgninc * absinc;
2199     } else {
2200         inc = 0; /* no further increase allowed via this method */
2201     }
2202     return old + inc;
2203 }
2204
2205 STATIC_OVL void
2206 accessory_has_effect(otmp)
2207 struct obj *otmp;
2208 {
2209 #if 0 /*JP*/
2210     pline("Magic spreads through your body as you digest the %s.",
2211           otmp->oclass == RING_CLASS ? "ring" : "amulet");
2212 #else
2213     pline("\82 \82È\82½\82ª%s\82ð\8fÁ\89»\82·\82é\82Æ\81C\82»\82Ì\96\82\97Í\82ª\91Ì\82É\82µ\82Ý\82±\82ñ\82¾\81D",
2214           otmp->oclass == RING_CLASS ? "\8ew\97Ö" : "\96\82\8f\9c\82¯");
2215 #endif
2216 }
2217
2218 STATIC_OVL void
2219 eataccessory(otmp)
2220 struct obj *otmp;
2221 {
2222     int typ = otmp->otyp;
2223     long oldprop;
2224
2225     /* Note: rings are not so common that this is unbalancing. */
2226     /* (How often do you even _find_ 3 rings of polymorph in a game?) */
2227     oldprop = u.uprops[objects[typ].oc_oprop].intrinsic;
2228     if (otmp == uleft || otmp == uright) {
2229         Ring_gone(otmp);
2230         if (u.uhp <= 0)
2231             return; /* died from sink fall */
2232     }
2233     otmp->known = otmp->dknown = 1; /* by taste */
2234     if (!rn2(otmp->oclass == RING_CLASS ? 3 : 5)) {
2235         switch (otmp->otyp) {
2236         default:
2237             if (!objects[typ].oc_oprop)
2238                 break; /* should never happen */
2239
2240             if (!(u.uprops[objects[typ].oc_oprop].intrinsic & FROMOUTSIDE))
2241                 accessory_has_effect(otmp);
2242
2243             u.uprops[objects[typ].oc_oprop].intrinsic |= FROMOUTSIDE;
2244
2245             switch (typ) {
2246             case RIN_SEE_INVISIBLE:
2247                 set_mimic_blocking();
2248                 see_monsters();
2249                 if (Invis && !oldprop && !ESee_invisible
2250                     && !perceives(youmonst.data) && !Blind) {
2251                     newsym(u.ux, u.uy);
2252 /*JP
2253                     pline("Suddenly you can see yourself.");
2254 */
2255                     pline("\93Ë\91R\8e©\95ª\8e©\90g\82ª\8c©\82¦\82é\82æ\82¤\82É\82È\82Á\82½\81D");
2256                     makeknown(typ);
2257                 }
2258                 break;
2259             case RIN_INVISIBILITY:
2260                 if (!oldprop && !EInvis && !BInvis && !See_invisible
2261                     && !Blind) {
2262                     newsym(u.ux, u.uy);
2263 #if 0 /*JP*/
2264                     Your("body takes on a %s transparency...",
2265                          Hallucination ? "normal" : "strange");
2266 #else
2267                     pline("%s\82 \82È\82½\82Ì\91Ì\82Í\93§\89ß\90«\82ð\82à\82Á\82½\81D\81D\81D",
2268                           Hallucination ? "\82 \82½\82è\82Ü\82¦\82È\82±\82Æ\82¾\82ª" : "\8aï\96­\82È\82±\82Æ\82É");
2269 #endif
2270                     makeknown(typ);
2271                 }
2272                 break;
2273             case RIN_PROTECTION_FROM_SHAPE_CHAN:
2274                 rescham();
2275                 break;
2276             case RIN_LEVITATION:
2277                 /* undo the `.intrinsic |= FROMOUTSIDE' done above */
2278                 u.uprops[LEVITATION].intrinsic = oldprop;
2279                 if (!Levitation) {
2280                     float_up();
2281                     incr_itimeout(&HLevitation, d(10, 20));
2282                     makeknown(typ);
2283                 }
2284                 break;
2285             } /* inner switch */
2286             break; /* default case of outer switch */
2287
2288         case RIN_ADORNMENT:
2289             accessory_has_effect(otmp);
2290             if (adjattrib(A_CHA, otmp->spe, -1))
2291                 makeknown(typ);
2292             break;
2293         case RIN_GAIN_STRENGTH:
2294             accessory_has_effect(otmp);
2295             if (adjattrib(A_STR, otmp->spe, -1))
2296                 makeknown(typ);
2297             break;
2298         case RIN_GAIN_CONSTITUTION:
2299             accessory_has_effect(otmp);
2300             if (adjattrib(A_CON, otmp->spe, -1))
2301                 makeknown(typ);
2302             break;
2303         case RIN_INCREASE_ACCURACY:
2304             accessory_has_effect(otmp);
2305             u.uhitinc = (schar) bounded_increase((int) u.uhitinc, otmp->spe,
2306                                                  RIN_INCREASE_ACCURACY);
2307             break;
2308         case RIN_INCREASE_DAMAGE:
2309             accessory_has_effect(otmp);
2310             u.udaminc = (schar) bounded_increase((int) u.udaminc, otmp->spe,
2311                                                  RIN_INCREASE_DAMAGE);
2312             break;
2313         case RIN_PROTECTION:
2314             accessory_has_effect(otmp);
2315             HProtection |= FROMOUTSIDE;
2316             u.ublessed = bounded_increase(u.ublessed, otmp->spe,
2317                                           RIN_PROTECTION);
2318             context.botl = 1;
2319             break;
2320         case RIN_FREE_ACTION:
2321             /* Give sleep resistance instead */
2322             if (!(HSleep_resistance & FROMOUTSIDE))
2323                 accessory_has_effect(otmp);
2324             if (!Sleep_resistance)
2325 /*JP
2326                 You_feel("wide awake.");
2327 */
2328                 You("\82Ï\82Á\82¿\82è\96Ú\82ª\82³\82ß\82½\81D");
2329             HSleep_resistance |= FROMOUTSIDE;
2330             break;
2331         case AMULET_OF_CHANGE:
2332             accessory_has_effect(otmp);
2333             makeknown(typ);
2334             change_sex();
2335 #if 0 /*JP*/
2336             You("are suddenly very %s!",
2337                 flags.female ? "feminine" : "masculine");
2338 #else
2339             You("\93Ë\91R\82Æ\82Ä\82à%s\82Á\82Û\82­\82È\82Á\82½\81I", 
2340                 flags.female ? "\8f\97" : "\92j");
2341 #endif
2342             context.botl = 1;
2343             break;
2344         case AMULET_OF_UNCHANGING:
2345             /* un-change: it's a pun */
2346             if (!Unchanging && Upolyd) {
2347                 accessory_has_effect(otmp);
2348                 makeknown(typ);
2349                 rehumanize();
2350             }
2351             break;
2352         case AMULET_OF_STRANGULATION: /* bad idea! */
2353             /* no message--this gives no permanent effect */
2354             choke(otmp);
2355             break;
2356         case AMULET_OF_RESTFUL_SLEEP: { /* another bad idea! */
2357             long newnap = (long) rnd(100), oldnap = (HSleepy & TIMEOUT);
2358
2359             if (!(HSleepy & FROMOUTSIDE))
2360                 accessory_has_effect(otmp);
2361             HSleepy |= FROMOUTSIDE;
2362             /* might also be wearing one; use shorter of two timeouts */
2363             if (newnap < oldnap || oldnap == 0L)
2364                 HSleepy = (HSleepy & ~TIMEOUT) | newnap;
2365             break;
2366         }
2367         case RIN_SUSTAIN_ABILITY:
2368         case AMULET_OF_LIFE_SAVING:
2369         case AMULET_OF_REFLECTION: /* nice try */
2370             /* can't eat Amulet of Yendor or fakes,
2371              * and no oc_prop even if you could -3.
2372              */
2373             break;
2374         }
2375     }
2376 }
2377
2378 /* called after eating non-food */
2379 STATIC_OVL void
2380 eatspecial()
2381 {
2382     struct obj *otmp = context.victual.piece;
2383
2384     /* lesshungry wants an occupation to handle choke messages correctly */
2385 /*JP
2386     set_occupation(eatfood, "eating non-food", 0);
2387 */
2388     set_occupation(eatfood, "\90H\82×\82é", 0);
2389     lesshungry(context.victual.nmod);
2390     occupation = 0;
2391     context.victual.piece = (struct obj *) 0;
2392     context.victual.o_id = 0;
2393     context.victual.eating = 0;
2394     if (otmp->oclass == COIN_CLASS) {
2395         if (carried(otmp))
2396             useupall(otmp);
2397         else
2398             useupf(otmp, otmp->quan);
2399         vault_gd_watching(GD_EATGOLD);
2400         return;
2401     }
2402 #ifdef MAIL
2403     if (otmp->otyp == SCR_MAIL) {
2404         /* no nutrition */
2405         pline("This junk mail is less than satisfying.");
2406     }
2407 #endif
2408     if (otmp->oclass == POTION_CLASS) {
2409         otmp->quan++; /* dopotion() does a useup() */
2410         (void) dopotion(otmp);
2411     } else if (otmp->oclass == RING_CLASS || otmp->oclass == AMULET_CLASS) {
2412         eataccessory(otmp);
2413     } else if (otmp->otyp == LEASH && otmp->leashmon) {
2414         o_unleash(otmp);
2415     }
2416
2417     /* KMH -- idea by "Tommy the Terrorist" */
2418     if (otmp->otyp == TRIDENT && !otmp->cursed) {
2419         /* sugarless chewing gum which used to be heavily advertised on TV */
2420 #if 0 /*JP*/
2421         pline(Hallucination ? "Four out of five dentists agree."
2422                             : "That was pure chewing satisfaction!");
2423 #else
2424         pline(Hallucination ? "\8cÜ\90l\82É\8el\90l\82Ì\8e\95\88ã\8eÒ\82ª\83g\83\89\83C\83f\83\93\83g\82ð\82¨\91E\82ß\82µ\82Ä\82¢\82Ü\82·\81D"
2425                             : "\8f\83\90\88\82É\8a\9a\82Ý\82½\82¢\8bC\8e\9d\82ð\96\9e\82½\82µ\82½\81I");
2426 #endif
2427         exercise(A_WIS, TRUE);
2428     }
2429     if (otmp->otyp == FLINT && !otmp->cursed) {
2430         /* chewable vitamin for kids based on "The Flintstones" TV cartoon */
2431 /*JP
2432         pline("Yabba-dabba delicious!");
2433 */
2434         pline("\83\84\83b\83o\83_\83b\83o\82¤\82Ü\82¢\81I");
2435         exercise(A_CON, TRUE);
2436     }
2437
2438     if (otmp == uwep && otmp->quan == 1L)
2439         uwepgone();
2440     if (otmp == uquiver && otmp->quan == 1L)
2441         uqwepgone();
2442     if (otmp == uswapwep && otmp->quan == 1L)
2443         uswapwepgone();
2444
2445     if (otmp == uball)
2446         unpunish();
2447     if (otmp == uchain)
2448         unpunish(); /* but no useup() */
2449     else if (carried(otmp))
2450         useup(otmp);
2451     else
2452         useupf(otmp, 1L);
2453 }
2454
2455 /* NOTE: the order of these words exactly corresponds to the
2456    order of oc_material values #define'd in objclass.h. */
2457 static const char *foodwords[] = {
2458 #if 0 /*JP*/
2459     "meal",    "liquid",  "wax",       "food", "meat",     "paper",
2460     "cloth",   "leather", "wood",      "bone", "scale",    "metal",
2461     "metal",   "metal",   "silver",    "gold", "platinum", "mithril",
2462     "plastic", "glass",   "rich food", "stone"
2463 #else
2464     "\93÷",           "\89t\91Ì",   "\96û",       "\90H\97¿", "\93÷",       "\8e\86",
2465     "\95\9e",           "\94ç",     "\96Ø",       "\8d\9c",   "\97Ø",       "\8bà\91®",
2466     "\8bà\91®",         "\8bà\91®",   "\8bâ",       "\8bà",   "\83v\83\89\83`\83i", "\83~\83X\83\8a\83\8b",
2467     "\83v\83\89\83X\83`\83b\83N", "\83K\83\89\83X", "\8d\82\8b\89\97¿\97\9d", "\90Î"
2468 #endif
2469 };
2470
2471 STATIC_OVL const char *
2472 foodword(otmp)
2473 struct obj *otmp;
2474 {
2475     if (otmp->oclass == FOOD_CLASS)
2476 /*JP
2477         return "food";
2478 */
2479         return "\90H\97¿";
2480     if (otmp->oclass == GEM_CLASS && objects[otmp->otyp].oc_material == GLASS
2481         && otmp->dknown)
2482         makeknown(otmp->otyp);
2483     return foodwords[objects[otmp->otyp].oc_material];
2484 }
2485
2486 /* called after consuming (non-corpse) food */
2487 STATIC_OVL void
2488 fpostfx(otmp)
2489 struct obj *otmp;
2490 {
2491     switch (otmp->otyp) {
2492     case SPRIG_OF_WOLFSBANE:
2493         if (u.ulycn >= LOW_PM || is_were(youmonst.data))
2494             you_unwere(TRUE);
2495         break;
2496     case CARROT:
2497         if (!u.uswallow
2498             || !attacktype_fordmg(u.ustuck->data, AT_ENGL, AD_BLND))
2499             make_blinded((long) u.ucreamed, TRUE);
2500         break;
2501     case FORTUNE_COOKIE:
2502         outrumor(bcsign(otmp), BY_COOKIE);
2503         if (!Blind)
2504             u.uconduct.literate++;
2505         break;
2506     case LUMP_OF_ROYAL_JELLY:
2507         /* This stuff seems to be VERY healthy! */
2508         gainstr(otmp, 1, TRUE);
2509         if (Upolyd) {
2510             u.mh += otmp->cursed ? -rnd(20) : rnd(20);
2511             if (u.mh > u.mhmax) {
2512                 if (!rn2(17))
2513                     u.mhmax++;
2514                 u.mh = u.mhmax;
2515             } else if (u.mh <= 0) {
2516                 rehumanize();
2517             }
2518         } else {
2519             u.uhp += otmp->cursed ? -rnd(20) : rnd(20);
2520             if (u.uhp > u.uhpmax) {
2521                 if (!rn2(17))
2522                     u.uhpmax++;
2523                 u.uhp = u.uhpmax;
2524             } else if (u.uhp <= 0) {
2525                 killer.format = KILLED_BY_AN;
2526 #if 0 /*JP*/
2527                 Strcpy(killer.name, "rotten lump of royal jelly");
2528                 done(POISONING);
2529 #else
2530                 Strcpy(killer.name, "\95\85\82Á\82½\83\8d\83C\83\84\83\8b\83[\83\8a\81[\82ð\90H\82×\90H\92\86\93Å\82Å");
2531                 done(DIED);
2532 #endif
2533             }
2534         }
2535         if (!otmp->cursed)
2536             heal_legs();
2537         break;
2538     case EGG:
2539         if (flesh_petrifies(&mons[otmp->corpsenm])) {
2540             if (!Stone_resistance
2541                 && !(poly_when_stoned(youmonst.data)
2542                      && polymon(PM_STONE_GOLEM))) {
2543                 if (!Stoned) {
2544 /*JP
2545                     Sprintf(killer.name, "%s egg",
2546 */
2547                     Sprintf(killer.name, "%s\82Ì\97\91\82Å",
2548                             mons[otmp->corpsenm].mname);
2549                     make_stoned(5L, (char *) 0, KILLED_BY_AN, killer.name);
2550                 }
2551             }
2552             /* note: no "tastes like chicken" message for eggs */
2553         }
2554         break;
2555     case EUCALYPTUS_LEAF:
2556         if (Sick && !otmp->cursed)
2557             make_sick(0L, (char *) 0, TRUE, SICK_ALL);
2558         if (Vomiting && !otmp->cursed)
2559             make_vomiting(0L, TRUE);
2560         break;
2561     case APPLE:
2562         if (otmp->cursed && !Sleep_resistance) {
2563             /* Snow White; 'poisoned' applies to [a subset of] weapons,
2564                not food, so we substitute cursed; fortunately our hero
2565                won't have to wait for a prince to be rescued/revived */
2566             if (Race_if(PM_DWARF) && Hallucination)
2567                 verbalize("Heigh-ho, ho-hum, I think I'll skip work today.");
2568             else if (Deaf || !flags.acoustics)
2569                 You("fall asleep.");
2570             else
2571                 You_hear("sinister laughter as you fall asleep...");
2572             fall_asleep(-rn1(11, 20), TRUE);
2573         }
2574         break;
2575     }
2576     return;
2577 }
2578
2579 #if 0
2580 /* intended for eating a spellbook while polymorphed, but not used;
2581    "leather" applied to appearance, not composition, and has been
2582    changed to "leathery" to reflect that */
2583 STATIC_DCL boolean FDECL(leather_cover, (struct obj *));
2584
2585 STATIC_OVL boolean
2586 leather_cover(otmp)
2587 struct obj *otmp;
2588 {
2589     const char *odesc = OBJ_DESCR(objects[otmp->otyp]);
2590
2591     if (odesc && (otmp->oclass == SPBOOK_CLASS)) {
2592         if (!strcmp(odesc, "leather"))
2593             return TRUE;
2594     }
2595     return FALSE;
2596 }
2597 #endif
2598
2599 /*
2600  * return 0 if the food was not dangerous.
2601  * return 1 if the food was dangerous and you chose to stop.
2602  * return 2 if the food was dangerous and you chose to eat it anyway.
2603  */
2604 STATIC_OVL int
2605 edibility_prompts(otmp)
2606 struct obj *otmp;
2607 {
2608     /* Blessed food detection grants hero a one-use
2609      * ability to detect food that is unfit for consumption
2610      * or dangerous and avoid it.
2611      */
2612     char buf[BUFSZ], foodsmell[BUFSZ],
2613          it_or_they[QBUFSZ], eat_it_anyway[QBUFSZ];
2614     boolean cadaver = (otmp->otyp == CORPSE), stoneorslime = FALSE;
2615     int material = objects[otmp->otyp].oc_material, mnum = otmp->corpsenm;
2616     long rotted = 0L;
2617
2618     Strcpy(foodsmell, Tobjnam(otmp, "smell"));
2619     Strcpy(it_or_they, (otmp->quan == 1L) ? "it" : "they");
2620 #if 0 /*JP*/
2621     Sprintf(eat_it_anyway, "Eat %s anyway?",
2622             (otmp->quan == 1L) ? "it" : "one");
2623 #else
2624     Strcpy(eat_it_anyway, "\82»\82ê\82Å\82à\90H\82×\82é\81H");
2625 #endif
2626
2627     if (cadaver || otmp->otyp == EGG || otmp->otyp == TIN) {
2628         /* These checks must match those in eatcorpse() */
2629         stoneorslime = (flesh_petrifies(&mons[mnum]) && !Stone_resistance
2630                         && !poly_when_stoned(youmonst.data));
2631
2632         if (mnum == PM_GREEN_SLIME || otmp->otyp == GLOB_OF_GREEN_SLIME)
2633             stoneorslime = (!Unchanging && !slimeproof(youmonst.data));
2634
2635         if (cadaver && !nonrotting_corpse(mnum)) {
2636             long age = peek_at_iced_corpse_age(otmp);
2637             /* worst case rather than random
2638                in this calculation to force prompt */
2639             rotted = (monstermoves - age) / (10L + 0 /* was rn2(20) */);
2640             if (otmp->cursed)
2641                 rotted += 2L;
2642             else if (otmp->blessed)
2643                 rotted -= 2L;
2644         }
2645     }
2646
2647     /*
2648      * These problems with food should be checked in
2649      * order from most detrimental to least detrimental.
2650      */
2651     if (cadaver && mnum != PM_ACID_BLOB && rotted > 5L && !Sick_resistance) {
2652         /* Tainted meat */
2653 #if 0 /*JP*/
2654         Sprintf(buf, "%s like %s could be tainted! %s", foodsmell, it_or_they,
2655                 eat_it_anyway);
2656 #else
2657         Sprintf(buf, "%s\82Í\89\98\90õ\82³\82ê\82Ä\82¢\82é\82æ\82¤\82È\82É\82¨\82¢\82ª\82·\82é\81I%s",
2658                 foodsmell, eat_it_anyway);
2659 #endif
2660         if (yn_function(buf, ynchars, 'n') == 'n')
2661             return 1;
2662         else
2663             return 2;
2664     }
2665     if (stoneorslime) {
2666 #if 0 /*JP*/
2667         Sprintf(buf, "%s like %s could be something very dangerous! %s",
2668                 foodsmell, it_or_they, eat_it_anyway);
2669 #else
2670         Sprintf(buf, "%s\82Í\82È\82ñ\82¾\82©\82·\82²\82­\8aë\8c¯\82»\82¤\82È\82É\82¨\82¢\82ª\82·\82é\81I%s",
2671                 foodsmell, eat_it_anyway);
2672 #endif
2673         if (yn_function(buf, ynchars, 'n') == 'n')
2674             return 1;
2675         else
2676             return 2;
2677     }
2678     if (otmp->orotten || (cadaver && rotted > 3L)) {
2679         /* Rotten */
2680 #if 0 /*JP*/
2681         Sprintf(buf, "%s like %s could be rotten! %s", foodsmell, it_or_they,
2682                 eat_it_anyway);
2683 #else
2684         Sprintf(buf, "%s\82Í\95\85\82Á\82½\82æ\82¤\82È\82É\82¨\82¢\82ª\82·\82é\81I%s",
2685                 foodsmell, eat_it_anyway);
2686 #endif
2687         if (yn_function(buf, ynchars, 'n') == 'n')
2688             return 1;
2689         else
2690             return 2;
2691     }
2692     if (cadaver && poisonous(&mons[mnum]) && !Poison_resistance) {
2693         /* poisonous */
2694 #if 0 /*JP*/
2695         Sprintf(buf, "%s like %s might be poisonous! %s", foodsmell,
2696                 it_or_they, eat_it_anyway);
2697 #else
2698         Sprintf(buf, "%s\82Í\93Å\82ð\82à\82Á\82Ä\82¢\82»\82¤\82È\82É\82¨\82¢\82ª\82·\82é\81I%s",
2699                 foodsmell, eat_it_anyway);
2700 #endif
2701         if (yn_function(buf, ynchars, 'n') == 'n')
2702             return 1;
2703         else
2704             return 2;
2705     }
2706     if (otmp->otyp == APPLE && otmp->cursed && !Sleep_resistance) {
2707         /* causes sleep, for long enough to be dangerous */
2708 #if 0 /*JP*/
2709         Sprintf(buf, "%s like %s might have been poisoned. %s", foodsmell,
2710                 it_or_they, eat_it_anyway);
2711 #else
2712         Sprintf(buf, "%s\82Í\93Å\82ª\93ü\82ê\82ç\82ê\82Ä\82¢\82»\82¤\82È\82É\82¨\82¢\82ª\82·\82é\81I%s",
2713                 foodsmell, eat_it_anyway);
2714 #endif
2715         return (yn_function(buf, ynchars, 'n') == 'n') ? 1 : 2;
2716     }
2717     if (cadaver && !vegetarian(&mons[mnum]) && !u.uconduct.unvegetarian
2718         && Role_if(PM_MONK)) {
2719 /*JP
2720         Sprintf(buf, "%s unhealthy. %s", foodsmell, eat_it_anyway);
2721 */
2722         Sprintf(buf, "%s\82Í\8c\92\8dN\82É\88«\82»\82¤\82È\82É\82¨\82¢\82ª\82·\82é\81D%s", foodsmell, eat_it_anyway);
2723         if (yn_function(buf, ynchars, 'n') == 'n')
2724             return 1;
2725         else
2726             return 2;
2727     }
2728     if (cadaver && acidic(&mons[mnum]) && !Acid_resistance) {
2729 /*JP
2730         Sprintf(buf, "%s rather acidic. %s", foodsmell, eat_it_anyway);
2731 */
2732         Sprintf(buf, "%s\82Í\8f­\82µ\8e_\82Á\82Ï\82»\82¤\82È\82É\82¨\82¢\82ª\82·\82é\81D%s", foodsmell, eat_it_anyway);
2733         if (yn_function(buf, ynchars, 'n') == 'n')
2734             return 1;
2735         else
2736             return 2;
2737     }
2738     if (Upolyd && u.umonnum == PM_RUST_MONSTER && is_metallic(otmp)
2739         && otmp->oerodeproof) {
2740 #if 0 /*JP*/
2741         Sprintf(buf, "%s disgusting to you right now. %s", foodsmell,
2742                 eat_it_anyway);
2743 #else
2744         Sprintf(buf, "%s\82Í\8bC\95ª\82ª\88«\82­\82È\82é\82É\82¨\82¢\82ª\82·\82é\81D%s", foodsmell,
2745                 eat_it_anyway);
2746 #endif
2747         if (yn_function(buf, ynchars, 'n') == 'n')
2748             return 1;
2749         else
2750             return 2;
2751     }
2752
2753     /*
2754      * Breaks conduct, but otherwise safe.
2755      */
2756     if (!u.uconduct.unvegan
2757         && ((material == LEATHER || material == BONE
2758              || material == DRAGON_HIDE || material == WAX)
2759             || (cadaver && !vegan(&mons[mnum])))) {
2760 #if 0 /*JP*/
2761         Sprintf(buf, "%s foul and unfamiliar to you. %s", foodsmell,
2762                 eat_it_anyway);
2763 #else
2764         Sprintf(buf, "%s\82Í\89\98\82ê\82Ä\82¢\82Ä\81C\82 \82È\82½\82É\82È\82\82Ü\82È\82¢\82æ\82¤\82È\82É\82¨\82¢\82ª\82·\82é\81D%s", foodsmell,
2765                 eat_it_anyway);
2766 #endif
2767         if (yn_function(buf, ynchars, 'n') == 'n')
2768             return 1;
2769         else
2770             return 2;
2771     }
2772     if (!u.uconduct.unvegetarian
2773         && ((material == LEATHER || material == BONE
2774              || material == DRAGON_HIDE)
2775             || (cadaver && !vegetarian(&mons[mnum])))) {
2776 /*JP
2777         Sprintf(buf, "%s unfamiliar to you. %s", foodsmell, eat_it_anyway);
2778 */
2779         Sprintf(buf, "%s\82Í\82 \82È\82½\82É\82È\82\82Ü\82È\82¢\82æ\82¤\82È\82É\82¨\82¢\82ª\82·\82é\81D%s", foodsmell, eat_it_anyway);
2780         if (yn_function(buf, ynchars, 'n') == 'n')
2781             return 1;
2782         else
2783             return 2;
2784     }
2785
2786     if (cadaver && mnum != PM_ACID_BLOB && rotted > 5L && Sick_resistance) {
2787         /* Tainted meat with Sick_resistance */
2788 #if 0 /*JP*/
2789         Sprintf(buf, "%s like %s could be tainted! %s", foodsmell, it_or_they,
2790                 eat_it_anyway);
2791 #else
2792         Sprintf(buf, "%s\82Í\89\98\90õ\82³\82ê\82Ä\82¢\82é\82æ\82¤\82È\82É\82¨\82¢\82ª\82·\82é\81I%s", foodsmell,
2793                 eat_it_anyway);
2794 #endif
2795         if (yn_function(buf, ynchars, 'n') == 'n')
2796             return 1;
2797         else
2798             return 2;
2799     }
2800     return 0;
2801 }
2802
2803 /* 'e' command */
2804 int
2805 doeat()
2806 {
2807     struct obj *otmp;
2808     int basenutrit; /* nutrition of full item */
2809     boolean dont_start = FALSE, nodelicious = FALSE;
2810
2811     if (Strangled) {
2812 /*JP
2813         pline("If you can't breathe air, how can you consume solids?");
2814 */
2815         pline("\91§\82à\82Å\82«\82È\82¢\82Ì\82É\81C\82Ç\82¤\82â\82Á\82Ä\90H\82×\82½\82ç\82¢\82¢\82ñ\82¾\82¢\81H");
2816         return 0;
2817     }
2818     if (!(otmp = floorfood("eat", 0)))
2819         return 0;
2820     if (check_capacity((char *) 0))
2821         return 0;
2822
2823     if (u.uedibility) {
2824         int res = edibility_prompts(otmp);
2825         if (res) {
2826 #if 0 /*JP*/
2827             Your(
2828                "%s stops tingling and your sense of smell returns to normal.",
2829                  body_part(NOSE));
2830 #else
2831             Your("%s\82ª\82¤\82¸\82¤\82¸\82·\82é\82Ì\82Í\8e~\82Ü\82è\81C\9ak\8ao\82Í\95\81\92Ê\82É\96ß\82Á\82½\81D",
2832                  body_part(NOSE));
2833 #endif
2834             u.uedibility = 0;
2835             if (res == 1)
2836                 return 0;
2837         }
2838     }
2839
2840     /* We have to make non-foods take 1 move to eat, unless we want to
2841      * do ridiculous amounts of coding to deal with partly eaten plate
2842      * mails, players who polymorph back to human in the middle of their
2843      * metallic meal, etc....
2844      */
2845     if (!(carried(otmp) ? retouch_object(&otmp, FALSE)
2846                         : touch_artifact(otmp, &youmonst))) {
2847         return 1;
2848     } else if (!is_edible(otmp)) {
2849 /*JP
2850         You("cannot eat that!");
2851 */
2852         You("\82»\82ê\82ð\90H\82×\82ç\82ê\82È\82¢\81I");
2853         return 0;
2854     } else if ((otmp->owornmask & (W_ARMOR | W_TOOL | W_AMUL | W_SADDLE))
2855                != 0) {
2856         /* let them eat rings */
2857 /*JP
2858         You_cant("eat %s you're wearing.", something);
2859 */
2860         You("\90g\82É\82Â\82¯\82Ä\82¢\82é\8aÔ\82Í\90H\82×\82ê\82È\82¢\81D");
2861         return 0;
2862     }
2863     if (is_metallic(otmp) && u.umonnum == PM_RUST_MONSTER
2864         && otmp->oerodeproof) {
2865         otmp->rknown = TRUE;
2866         if (otmp->quan > 1L) {
2867             if (!carried(otmp))
2868                 (void) splitobj(otmp, otmp->quan - 1L);
2869             else
2870                 otmp = splitobj(otmp, 1L);
2871         }
2872 /*JP
2873         pline("Ulch - that %s was rustproofed!", xname(otmp));
2874 */
2875         pline("\83E\83Q\83F\81[\81I%s\82Í\96h\8eK\82³\82ê\82Ä\82¢\82é\81I", xname(otmp));
2876         /* The regurgitated object's rustproofing is gone now */
2877         otmp->oerodeproof = 0;
2878         make_stunned((HStun & TIMEOUT) + (long) rn2(10), TRUE);
2879 #if 0 /*JP*/
2880         You("spit %s out onto the %s.", the(xname(otmp)),
2881             surface(u.ux, u.uy));
2882 #else
2883         You("%s\82ð%s\82É\93f\82«\8fo\82µ\82½\81D", the(xname(otmp)),
2884             surface(u.ux, u.uy));
2885 #endif
2886         if (carried(otmp)) {
2887             freeinv(otmp);
2888             dropy(otmp);
2889         }
2890         stackobj(otmp);
2891         return 1;
2892     }
2893     /* KMH -- Slow digestion is... indigestible */
2894     if (otmp->otyp == RIN_SLOW_DIGESTION) {
2895 /*JP
2896         pline("This ring is indigestible!");
2897 */
2898         pline("\82±\82Ì\8ew\97Ö\82Í\8fÁ\89»\82µ\82É\82­\82¢\81I");
2899         (void) rottenfood(otmp);
2900         if (otmp->dknown && !objects[otmp->otyp].oc_name_known
2901             && !objects[otmp->otyp].oc_uname)
2902             docall(otmp);
2903         return 1;
2904     }
2905     if (otmp->oclass != FOOD_CLASS) {
2906         int material;
2907
2908         context.victual.reqtime = 1;
2909         context.victual.piece = otmp;
2910         context.victual.o_id = otmp->o_id;
2911         /* Don't split it, we don't need to if it's 1 move */
2912         context.victual.usedtime = 0;
2913         context.victual.canchoke = (u.uhs == SATIATED);
2914         /* Note: gold weighs 1 pt. for each 1000 pieces (see
2915            pickup.c) so gold and non-gold is consistent. */
2916         if (otmp->oclass == COIN_CLASS)
2917             basenutrit = ((otmp->quan > 200000L)
2918                              ? 2000
2919                              : (int) (otmp->quan / 100L));
2920         else if (otmp->oclass == BALL_CLASS || otmp->oclass == CHAIN_CLASS)
2921             basenutrit = weight(otmp);
2922         /* oc_nutrition is usually weight anyway */
2923         else
2924             basenutrit = objects[otmp->otyp].oc_nutrition;
2925 #ifdef MAIL
2926         if (otmp->otyp == SCR_MAIL) {
2927             basenutrit = 0;
2928             nodelicious = TRUE;
2929         }
2930 #endif
2931         context.victual.nmod = basenutrit;
2932         context.victual.eating = TRUE; /* needed for lesshungry() */
2933
2934         material = objects[otmp->otyp].oc_material;
2935         if (material == LEATHER || material == BONE
2936             || material == DRAGON_HIDE) {
2937             u.uconduct.unvegan++;
2938             violated_vegetarian();
2939         } else if (material == WAX)
2940             u.uconduct.unvegan++;
2941         u.uconduct.food++;
2942
2943         if (otmp->cursed)
2944             (void) rottenfood(otmp);
2945
2946         if (otmp->oclass == WEAPON_CLASS && otmp->opoisoned) {
2947 /*JP
2948             pline("Ecch - that must have been poisonous!");
2949 */
2950             pline("\83E\83Q\83F\81[\81C\97L\93Å\82¾\82Á\82½\82É\88á\82¢\82È\82¢\81I");  
2951             if (!Poison_resistance) {
2952                 losestr(rnd(4));
2953 #if 0 /*JP*/
2954                 losehp(rnd(15), xname(otmp), KILLED_BY_AN);
2955 #else
2956                 {
2957                     char jbuf[BUFSZ];
2958                     Sprintf(jbuf, "%s\82Å", xname(otmp));
2959                     losehp(rnd(15), jbuf, KILLED_BY_AN);
2960                 }
2961 #endif
2962             } else
2963 /*JP
2964                 You("seem unaffected by the poison.");
2965 */
2966                 You("\93Å\82Ì\89e\8b¿\82ð\8eó\82¯\82È\82¢\82æ\82¤\82¾\81D");
2967         } else if (!otmp->cursed && !nodelicious) {
2968 #if 0 /*JP*/
2969             pline("%s%s is delicious!",
2970                   (obj_is_pname(otmp)
2971                    && otmp->oartifact < ART_ORB_OF_DETECTION)
2972                       ? ""
2973                       : "This ",
2974                   (otmp->oclass == COIN_CLASS)
2975                       ? foodword(otmp)
2976                       : singular(otmp, xname));
2977 #else
2978             pline("\82±\82Ì%s\82Í\8e|\82¢\81I",
2979                   otmp->oclass == COIN_CLASS
2980                       ? foodword(otmp)
2981                       : singular(otmp, xname));
2982 #endif
2983         }
2984         eatspecial();
2985         return 1;
2986     }
2987
2988     if (otmp == context.victual.piece) {
2989         /* If they weren't able to choke, they don't suddenly become able to
2990          * choke just because they were interrupted.  On the other hand, if
2991          * they were able to choke before, if they lost food it's possible
2992          * they shouldn't be able to choke now.
2993          */
2994         if (u.uhs != SATIATED)
2995             context.victual.canchoke = FALSE;
2996         context.victual.o_id = 0;
2997         context.victual.piece = touchfood(otmp);
2998         if (context.victual.piece)
2999             context.victual.o_id = context.victual.piece->o_id;
3000 /*JP
3001         You("resume your meal.");
3002 */
3003         You("\90H\8e\96\82ð\8dÄ\8aJ\82µ\82½\81D");
3004         start_eating(context.victual.piece);
3005         return 1;
3006     }
3007
3008     /* nothing in progress - so try to find something. */
3009     /* tins are a special case */
3010     /* tins must also check conduct separately in case they're discarded */
3011     if (otmp->otyp == TIN) {
3012         start_tin(otmp);
3013         return 1;
3014     }
3015
3016     /* KMH, conduct */
3017     u.uconduct.food++;
3018
3019     context.victual.o_id = 0;
3020     context.victual.piece = otmp = touchfood(otmp);
3021     if (context.victual.piece)
3022         context.victual.o_id = context.victual.piece->o_id;
3023     context.victual.usedtime = 0;
3024
3025     /* Now we need to calculate delay and nutritional info.
3026      * The base nutrition calculated here and in eatcorpse() accounts
3027      * for normal vs. rotten food.  The reqtime and nutrit values are
3028      * then adjusted in accordance with the amount of food left.
3029      */
3030     if (otmp->otyp == CORPSE || otmp->globby) {
3031         int tmp = eatcorpse(otmp);
3032
3033         if (tmp == 2) {
3034             /* used up */
3035             context.victual.piece = (struct obj *) 0;
3036             context.victual.o_id = 0;
3037             return 1;
3038         } else if (tmp)
3039             dont_start = TRUE;
3040         /* if not used up, eatcorpse sets up reqtime and may modify oeaten */
3041     } else {
3042         /* No checks for WAX, LEATHER, BONE, DRAGON_HIDE.  These are
3043          * all handled in the != FOOD_CLASS case, above.
3044          */
3045         switch (objects[otmp->otyp].oc_material) {
3046         case FLESH:
3047             u.uconduct.unvegan++;
3048             if (otmp->otyp != EGG) {
3049                 violated_vegetarian();
3050             }
3051             break;
3052
3053         default:
3054             if (otmp->otyp == PANCAKE || otmp->otyp == FORTUNE_COOKIE /*eggs*/
3055                 || otmp->otyp == CREAM_PIE || otmp->otyp == CANDY_BAR /*milk*/
3056                 || otmp->otyp == LUMP_OF_ROYAL_JELLY)
3057                 u.uconduct.unvegan++;
3058             break;
3059         }
3060
3061         context.victual.reqtime = objects[otmp->otyp].oc_delay;
3062         if (otmp->otyp != FORTUNE_COOKIE
3063             && (otmp->cursed || (!nonrotting_food(otmp->otyp)
3064                                  && (monstermoves - otmp->age)
3065                                         > (otmp->blessed ? 50L : 30L)
3066                                  && (otmp->orotten || !rn2(7))))) {
3067             if (rottenfood(otmp)) {
3068                 otmp->orotten = TRUE;
3069                 dont_start = TRUE;
3070             }
3071             consume_oeaten(otmp, 1); /* oeaten >>= 1 */
3072         } else
3073             fprefx(otmp);
3074     }
3075
3076     /* re-calc the nutrition */
3077     if (otmp->otyp == CORPSE)
3078         basenutrit = mons[otmp->corpsenm].cnutrit;
3079     else
3080         basenutrit = objects[otmp->otyp].oc_nutrition;
3081
3082     debugpline1("before rounddiv: context.victual.reqtime == %d",
3083                 context.victual.reqtime);
3084     debugpline2("oeaten == %d, basenutrit == %d", otmp->oeaten, basenutrit);
3085     context.victual.reqtime = (basenutrit == 0)
3086                                  ? 0
3087                                  : rounddiv(context.victual.reqtime
3088                                             * (long) otmp->oeaten,
3089                                             basenutrit);
3090     debugpline1("after rounddiv: context.victual.reqtime == %d",
3091                 context.victual.reqtime);
3092     /*
3093      * calculate the modulo value (nutrit. units per round eating)
3094      * note: this isn't exact - you actually lose a little nutrition due
3095      *       to this method.
3096      * TODO: add in a "remainder" value to be given at the end of the meal.
3097      */
3098     if (context.victual.reqtime == 0 || otmp->oeaten == 0)
3099         /* possible if most has been eaten before */
3100         context.victual.nmod = 0;
3101     else if ((int) otmp->oeaten >= context.victual.reqtime)
3102         context.victual.nmod = -((int) otmp->oeaten
3103                                  / context.victual.reqtime);
3104     else
3105         context.victual.nmod = context.victual.reqtime % otmp->oeaten;
3106     context.victual.canchoke = (u.uhs == SATIATED);
3107
3108     if (!dont_start)
3109         start_eating(otmp);
3110     return 1;
3111 }
3112
3113 /* Take a single bite from a piece of food, checking for choking and
3114  * modifying usedtime.  Returns 1 if they choked and survived, 0 otherwise.
3115  */
3116 STATIC_OVL int
3117 bite()
3118 {
3119     if (context.victual.canchoke && u.uhunger >= 2000) {
3120         choke(context.victual.piece);
3121         return 1;
3122     }
3123     if (context.victual.doreset) {
3124         do_reset_eat();
3125         return 0;
3126     }
3127     force_save_hs = TRUE;
3128     if (context.victual.nmod < 0) {
3129         lesshungry(-context.victual.nmod);
3130         consume_oeaten(context.victual.piece,
3131                        context.victual.nmod); /* -= -nmod */
3132     } else if (context.victual.nmod > 0
3133                && (context.victual.usedtime % context.victual.nmod)) {
3134         lesshungry(1);
3135         consume_oeaten(context.victual.piece, -1); /* -= 1 */
3136     }
3137     force_save_hs = FALSE;
3138     recalc_wt();
3139     return 0;
3140 }
3141
3142 /* as time goes by - called by moveloop() and domove() */
3143 void
3144 gethungry()
3145 {
3146     if (u.uinvulnerable)
3147         return; /* you don't feel hungrier */
3148
3149     if ((!u.usleep || !rn2(10)) /* slow metabolic rate while asleep */
3150         && (carnivorous(youmonst.data) || herbivorous(youmonst.data))
3151         && !Slow_digestion)
3152         u.uhunger--; /* ordinary food consumption */
3153
3154     if (moves % 2) { /* odd turns */
3155         /* Regeneration uses up food, unless due to an artifact */
3156         if ((HRegeneration & ~FROMFORM)
3157             || (ERegeneration & ~(W_ARTI | W_WEP)))
3158             u.uhunger--;
3159         if (near_capacity() > SLT_ENCUMBER)
3160             u.uhunger--;
3161     } else { /* even turns */
3162         if (Hunger)
3163             u.uhunger--;
3164         /* Conflict uses up food too */
3165         if (HConflict || (EConflict & (~W_ARTI)))
3166             u.uhunger--;
3167         /* +0 charged rings don't do anything, so don't affect hunger */
3168         /* Slow digestion still uses ring hunger */
3169         switch ((int) (moves % 20)) { /* note: use even cases only */
3170         case 4:
3171             if (uleft && (uleft->spe || !objects[uleft->otyp].oc_charged))
3172                 u.uhunger--;
3173             break;
3174         case 8:
3175             if (uamul)
3176                 u.uhunger--;
3177             break;
3178         case 12:
3179             if (uright && (uright->spe || !objects[uright->otyp].oc_charged))
3180                 u.uhunger--;
3181             break;
3182         case 16:
3183             if (u.uhave.amulet)
3184                 u.uhunger--;
3185             break;
3186         default:
3187             break;
3188         }
3189     }
3190     newuhs(TRUE);
3191 }
3192
3193 /* called after vomiting and after performing feats of magic */
3194 void
3195 morehungry(num)
3196 int num;
3197 {
3198     u.uhunger -= num;
3199     newuhs(TRUE);
3200 }
3201
3202 /* called after eating (and after drinking fruit juice) */
3203 void
3204 lesshungry(num)
3205 int num;
3206 {
3207     /* See comments in newuhs() for discussion on force_save_hs */
3208     boolean iseating = (occupation == eatfood) || force_save_hs;
3209
3210     debugpline1("lesshungry(%d)", num);
3211     u.uhunger += num;
3212     if (u.uhunger >= 2000) {
3213         if (!iseating || context.victual.canchoke) {
3214             if (iseating) {
3215                 choke(context.victual.piece);
3216                 reset_eat();
3217             } else
3218                 choke(occupation == opentin ? context.tin.tin
3219                                             : (struct obj *) 0);
3220             /* no reset_eat() */
3221         }
3222     } else {
3223         /* Have lesshungry() report when you're nearly full so all eating
3224          * warns when you're about to choke.
3225          */
3226         if (u.uhunger >= 1500) {
3227             if (!context.victual.eating
3228                 || (context.victual.eating && !context.victual.fullwarn)) {
3229 /*JP
3230                 pline("You're having a hard time getting all of it down.");
3231 */
3232                 pline("\91S\82Ä\82ð\88ù\82Ý\82±\82Þ\82É\82Í\8e\9e\8aÔ\82ª\82©\82©\82é\81D");
3233 /*JP
3234                 nomovemsg = "You're finally finished.";
3235 */
3236                 nomovemsg = "\82â\82Á\82Æ\90H\82×\8fI\82¦\82½\81D";
3237                 if (!context.victual.eating) {
3238                     multi = -2;
3239                 } else {
3240                     context.victual.fullwarn = TRUE;
3241                     if (context.victual.canchoke
3242                         && context.victual.reqtime > 1) {
3243                         /* a one-gulp food will not survive a stop */
3244 /*JP
3245                         if (yn_function("Continue eating?", ynchars, 'n')
3246 */
3247                         if (yn_function("\90H\82×\91±\82¯\82Ü\82·\82©\81H", ynchars, 'n')
3248                             != 'y') {
3249                             reset_eat();
3250                             nomovemsg = (char *) 0;
3251                         }
3252                     }
3253                 }
3254             }
3255         }
3256     }
3257     newuhs(FALSE);
3258 }
3259
3260 STATIC_PTR
3261 int
3262 unfaint(VOID_ARGS)
3263 {
3264     (void) Hear_again();
3265     if (u.uhs > FAINTING)
3266         u.uhs = FAINTING;
3267     stop_occupation();
3268     context.botl = 1;
3269     return 0;
3270 }
3271
3272 boolean
3273 is_fainted()
3274 {
3275     return (boolean) (u.uhs == FAINTED);
3276 }
3277
3278 /* call when a faint must be prematurely terminated */
3279 void
3280 reset_faint()
3281 {
3282     if (afternmv == unfaint)
3283         unmul("You revive.");
3284 }
3285
3286 /* compute and comment on your (new?) hunger status */
3287 void
3288 newuhs(incr)
3289 boolean incr;
3290 {
3291     unsigned newhs;
3292     static unsigned save_hs;
3293     static boolean saved_hs = FALSE;
3294     int h = u.uhunger;
3295
3296     newhs = (h > 1000)
3297                 ? SATIATED
3298                 : (h > 150) ? NOT_HUNGRY
3299                             : (h > 50) ? HUNGRY : (h > 0) ? WEAK : FAINTING;
3300
3301     /* While you're eating, you may pass from WEAK to HUNGRY to NOT_HUNGRY.
3302      * This should not produce the message "you only feel hungry now";
3303      * that message should only appear if HUNGRY is an endpoint.  Therefore
3304      * we check to see if we're in the middle of eating.  If so, we save
3305      * the first hunger status, and at the end of eating we decide what
3306      * message to print based on the _entire_ meal, not on each little bit.
3307      */
3308     /* It is normally possible to check if you are in the middle of a meal
3309      * by checking occupation == eatfood, but there is one special case:
3310      * start_eating() can call bite() for your first bite before it
3311      * sets the occupation.
3312      * Anyone who wants to get that case to work _without_ an ugly static
3313      * force_save_hs variable, feel free.
3314      */
3315     /* Note: If you become a certain hunger status in the middle of the
3316      * meal, and still have that same status at the end of the meal,
3317      * this will incorrectly print the associated message at the end of
3318      * the meal instead of the middle.  Such a case is currently
3319      * impossible, but could become possible if a message for SATIATED
3320      * were added or if HUNGRY and WEAK were separated by a big enough
3321      * gap to fit two bites.
3322      */
3323     if (occupation == eatfood || force_save_hs) {
3324         if (!saved_hs) {
3325             save_hs = u.uhs;
3326             saved_hs = TRUE;
3327         }
3328         u.uhs = newhs;
3329         return;
3330     } else {
3331         if (saved_hs) {
3332             u.uhs = save_hs;
3333             saved_hs = FALSE;
3334         }
3335     }
3336
3337     if (newhs == FAINTING) {
3338         if (is_fainted())
3339             newhs = FAINTED;
3340         if (u.uhs <= WEAK || rn2(20 - u.uhunger / 10) >= 19) {
3341             if (!is_fainted() && multi >= 0 /* %% */) {
3342                 int duration = 10 - (u.uhunger / 10);
3343
3344                 /* stop what you're doing, then faint */
3345                 stop_occupation();
3346 /*JP
3347                 You("faint from lack of food.");
3348 */
3349                 You("\95 \82ª\8c¸\82Á\82Ä\93|\82ê\82½\81D");
3350                 if (!Levitation)
3351 /*JP
3352                     selftouch("Falling, you");
3353 */
3354                     selftouch("\97\8e\82¿\82È\82ª\82ç\81C\82 \82È\82½\82Í");
3355                 incr_itimeout(&HDeaf, duration);
3356                 nomul(-duration);
3357                 multi_reason = "fainted from lack of food";
3358 /*JP
3359                 nomovemsg = "You regain consciousness.";
3360 */
3361                 nomovemsg = "\82 \82È\82½\82Í\90³\8bC\82Ã\82¢\82½\81D";
3362                 afternmv = unfaint;
3363                 newhs = FAINTED;
3364             }
3365         } else if (u.uhunger < -(int) (200 + 20 * ACURR(A_CON))) {
3366             u.uhs = STARVED;
3367             context.botl = 1;
3368             bot();
3369 /*JP
3370             You("die from starvation.");
3371 */
3372             You("\89ì\8e\80\82µ\82½\81D");
3373             killer.format = KILLED_BY;
3374 /*JP
3375             Strcpy(killer.name, "starvation");
3376 */
3377             Strcpy(killer.name, "\90H\97¿\95s\91«\82Å\89ì\8e\80\82µ\82½");
3378             done(STARVING);
3379             /* if we return, we lifesaved, and that calls newuhs */
3380             return;
3381         }
3382     }
3383
3384     if (newhs != u.uhs) {
3385         if (newhs >= WEAK && u.uhs < WEAK)
3386             losestr(1); /* this may kill you -- see below */
3387         else if (newhs < WEAK && u.uhs >= WEAK)
3388             losestr(-1);
3389         switch (newhs) {
3390         case HUNGRY:
3391             if (Hallucination) {
3392 #if 0 /*JP:T*/
3393                 You((!incr) ? "now have a lesser case of the munchies."
3394                             : "are getting the munchies.");
3395 #else
3396                 if (!incr) {
3397                     You("\83n\83\89\83w\83\8a\82ª\8c¸\82Á\82½\81D");
3398                 } else {
3399                     pline("\83n\83\89\83w\83\8a\83w\83\8a\83n\83\89\81D");
3400                 }
3401 #endif
3402             } else
3403 /*JP
3404                 You((!incr) ? "only feel hungry now."
3405 */
3406                 You((!incr) ? "\92P\82É\95 \83y\83R\8fó\91Ô\82É\82È\82Á\82½\81D"
3407                             : (u.uhunger < 145)
3408 /*JP
3409                                   ? "feel hungry."
3410 */
3411                                   ? "\8bó\95 \8a´\82ð\8a´\82\82½\81D"
3412 /*JP
3413                                   : "are beginning to feel hungry.");
3414 */
3415                                   : "\8bó\95 \8a´\82ð\82¨\82Ú\82¦\82Í\82\82ß\82½\81D");
3416             if (incr && occupation
3417                 && (occupation != eatfood && occupation != opentin))
3418                 stop_occupation();
3419             context.travel = context.travel1 = context.mv = context.run = 0;
3420             break;
3421         case WEAK:
3422             if (Hallucination)
3423 /*JP
3424                 pline((!incr) ? "You still have the munchies."
3425 */
3426                 pline((!incr) ? "\83n\83\89\83w\83\8a\82ª\8c¸\82ç\82È\82¢\81D"
3427 /*JP
3428               : "The munchies are interfering with your motor capabilities.");
3429 */
3430               : "\83n\83\89\83w\83\8a\82ª\83\82\81[\83^\81[\90«\94\\82É\89e\8b¿\82ð\97^\82¦\82Ä\82¢\82é\81D");
3431             else if (incr && (Role_if(PM_WIZARD) || Race_if(PM_ELF)
3432                               || Role_if(PM_VALKYRIE)))
3433 /*JP
3434                 pline("%s needs food, badly!",
3435 */
3436                 pline("%s\82É\82Í\8e\8a\8b}\90H\97¿\82ª\95K\97v\82¾\81I",
3437                       (Role_if(PM_WIZARD) || Role_if(PM_VALKYRIE))
3438                           ? urole.name.m
3439 /*JP
3440                           : "Elf");
3441 */
3442                           : "\83G\83\8b\83t");
3443             else
3444                 You((!incr)
3445 /*JP
3446                         ? "feel weak now."
3447 */
3448                         ? "\90\8a\8eã\8fó\91Ô\82É\82È\82Á\82½\81D"
3449 /*JP
3450                         : (u.uhunger < 45) ? "feel weak."
3451 */
3452                         : (u.uhunger < 45) ? "\90\8a\8eã\82µ\82Ä\82«\82½\81D"
3453 /*JP
3454                                            : "are beginning to feel weak.");
3455 */
3456                                            : "\8eã\82­\82È\82Á\82Ä\82«\82½\82æ\82¤\82É\8a´\82\82½\81D");
3457             if (incr && occupation
3458                 && (occupation != eatfood && occupation != opentin))
3459                 stop_occupation();
3460             context.travel = context.travel1 = context.mv = context.run = 0;
3461             break;
3462         }
3463         u.uhs = newhs;
3464         context.botl = 1;
3465         bot();
3466         if ((Upolyd ? u.mh : u.uhp) < 1) {
3467 /*JP
3468             You("die from hunger and exhaustion.");
3469 */
3470             You("\8bó\95 \82Æ\90\8a\8eã\82Å\8e\80\82ñ\82¾\81D");
3471             killer.format = KILLED_BY;
3472 /*JP
3473             Strcpy(killer.name, "exhaustion");
3474 */
3475             Strcpy(killer.name, "\8bó\95 \82Æ\90\8a\8eã\82Å\8e\80\82ñ\82¾");
3476             done(STARVING);
3477             return;
3478         }
3479     }
3480 }
3481
3482 /* Returns an object representing food.
3483  * Object may be either on floor or in inventory.
3484  */
3485 /*JP CHECK: 3.4.3 \82Å\82Ì\8cÄ\82Ñ\8fo\82µ\8c³
3486 apply.c:1959:   if (!(corpse = floorfood("\8aÊ\8bl\82ß\82É\82·\82é", 2))) return;
3487 eat.c:2404:     if (!(otmp = floorfood("\90H\82×\82é", 0))) return 0;
3488 pray.c:1478:    if (!(otmp = floorfood("\95ù\82°\82é", 1))) return 0;
3489 */
3490 struct obj *
3491 floorfood(verb, corpsecheck)
3492 const char *verb;
3493 int corpsecheck; /* 0, no check, 1, corpses, 2, tinnable corpses */
3494 {
3495     register struct obj *otmp;
3496     char qbuf[QBUFSZ];
3497     char c;
3498     boolean feeding = !strcmp(verb, "eat"),    /* corpsecheck==0 */
3499         offering = !strcmp(verb, "sacrifice"); /* corpsecheck==1 */
3500
3501 #if 1 /*JP*/
3502     const char *jverb = trans_verb(verb)->jp;
3503 #endif
3504
3505     /* if we can't touch floor objects then use invent food only */
3506     if (!can_reach_floor(TRUE) || (feeding && u.usteed)
3507         || (is_pool_or_lava(u.ux, u.uy)
3508             && (Wwalking || is_clinger(youmonst.data)
3509                 || (Flying && !Breathless))))
3510         goto skipfloor;
3511
3512     if (feeding && metallivorous(youmonst.data)) {
3513         struct obj *gold;
3514         struct trap *ttmp = t_at(u.ux, u.uy);
3515
3516         if (ttmp && ttmp->tseen && ttmp->ttyp == BEAR_TRAP) {
3517             /* If not already stuck in the trap, perhaps there should
3518                be a chance to becoming trapped?  Probably not, because
3519                then the trap would just get eaten on the _next_ turn... */
3520 /*JP
3521             Sprintf(qbuf, "There is a bear trap here (%s); eat it?",
3522 */
3523             Sprintf(qbuf, "\82±\82±\82É\82Í\8cF\82Ìã©(%s)\82ª\82 \82é; \90H\82×\82Ü\82·\82©\81H",
3524 /*JP
3525                     (u.utrap && u.utraptype == TT_BEARTRAP) ? "holding you"
3526 */
3527                     (u.utrap && u.utraptype == TT_BEARTRAP) ? "\82 \82È\82½\82ð\92Í\82Ü\82¦\82Ä\82¢\82é"
3528 /*JP
3529                                                             : "armed");
3530 */
3531                                                             : "\89Ò\93®\92\86");
3532             if ((c = yn_function(qbuf, ynqchars, 'n')) == 'y') {
3533                 u.utrap = u.utraptype = 0;
3534                 deltrap(ttmp);
3535                 return mksobj(BEARTRAP, TRUE, FALSE);
3536             } else if (c == 'q') {
3537                 return (struct obj *) 0;
3538             }
3539         }
3540
3541         if (youmonst.data != &mons[PM_RUST_MONSTER]
3542             && (gold = g_at(u.ux, u.uy)) != 0) {
3543 #if 0 /*JP*/
3544             if (gold->quan == 1L)
3545                 Sprintf(qbuf, "There is 1 gold piece here; eat it?");
3546             else
3547                 Sprintf(qbuf, "There are %ld gold pieces here; eat them?",
3548                         gold->quan);
3549 #else
3550             Sprintf(qbuf, "\82±\82±\82É\82Í%ld\96\87\82Ì\8bà\89Ý\82ª\82 \82é\81D\90H\82×\82Ü\82·\82©\81H", gold->quan);
3551 #endif
3552             if ((c = yn_function(qbuf, ynqchars, 'n')) == 'y') {
3553                 return gold;
3554             } else if (c == 'q') {
3555                 return (struct obj *) 0;
3556             }
3557         }
3558     }
3559
3560     /* Is there some food (probably a heavy corpse) here on the ground? */
3561     for (otmp = level.objects[u.ux][u.uy]; otmp; otmp = otmp->nexthere) {
3562         if (corpsecheck
3563                 ? (otmp->otyp == CORPSE
3564                    && (corpsecheck == 1 || tinnable(otmp)))
3565                 : feeding ? (otmp->oclass != COIN_CLASS && is_edible(otmp))
3566                           : otmp->oclass == FOOD_CLASS) {
3567             char qsfx[QBUFSZ];
3568             boolean one = (otmp->quan == 1L);
3569
3570             /* "There is <an object> here; <verb> it?" or
3571                "There are <N objects> here; <verb> one?" */
3572 #if 0 /*JP*/
3573             Sprintf(qbuf, "There %s ", otense(otmp, "are"));
3574             Sprintf(qsfx, " here; %s %s?", verb, one ? "it" : "one");
3575             (void) safe_qbuf(qbuf, qbuf, qsfx, otmp, doname, ansimpleoname,
3576                              one ? something : (const char *) "things");
3577 #else
3578             Strcpy(qbuf, "\82±\82±\82É");
3579             Sprintf(qsfx, "\82ª\82 \82é; %s%s?", one ? "" : "\88ê\82Â", jverb);
3580             (void) safe_qbuf(qbuf, qbuf, qsfx, otmp, doname, ansimpleoname,
3581                              one ? something : (const char *) "\89½\82©");
3582 #endif
3583             if ((c = yn_function(qbuf, ynqchars, 'n')) == 'y')
3584                 return  otmp;
3585             else if (c == 'q')
3586                 return (struct obj *) 0;
3587         }
3588     }
3589
3590 skipfloor:
3591     /* We cannot use ALL_CLASSES since that causes getobj() to skip its
3592      * "ugly checks" and we need to check for inedible items.
3593      */
3594     otmp =
3595         getobj(feeding ? allobj : offering ? offerfodder : comestibles, verb);
3596     if (corpsecheck && otmp && !(offering && otmp->oclass == AMULET_CLASS))
3597         if (otmp->otyp != CORPSE || (corpsecheck == 2 && !tinnable(otmp))) {
3598 /*JP
3599             You_cant("%s that!", verb);
3600 */
3601             You_cant("\82»\82ê\82ð%s\82±\82Æ\82Í\82Å\82«\82È\82¢\81I", jverb);
3602             return (struct obj *) 0;
3603         }
3604     return otmp;
3605 }
3606
3607 /* Side effects of vomiting */
3608 /* added nomul (MRS) - it makes sense, you're too busy being sick! */
3609 void
3610 vomit() /* A good idea from David Neves */
3611 {
3612     if (cantvomit(youmonst.data))
3613         /* doesn't cure food poisoning; message assumes that we aren't
3614            dealing with some esoteric body_part() */
3615         Your("jaw gapes convulsively.");
3616     else
3617         make_sick(0L, (char *) 0, TRUE, SICK_VOMITABLE);
3618     nomul(-2);
3619     multi_reason = "vomiting";
3620     nomovemsg = You_can_move_again;
3621 }
3622
3623 int
3624 eaten_stat(base, obj)
3625 int base;
3626 struct obj *obj;
3627 {
3628     long uneaten_amt, full_amount;
3629
3630     uneaten_amt = (long) obj->oeaten;
3631     full_amount = (obj->otyp == CORPSE)
3632                       ? (long) mons[obj->corpsenm].cnutrit
3633                       : (long) objects[obj->otyp].oc_nutrition;
3634     if (uneaten_amt > full_amount) {
3635         impossible(
3636           "partly eaten food (%ld) more nutritious than untouched food (%ld)",
3637                    uneaten_amt, full_amount);
3638         uneaten_amt = full_amount;
3639     }
3640
3641     base = (int) (full_amount ? (long) base * uneaten_amt / full_amount : 0L);
3642     return (base < 1) ? 1 : base;
3643 }
3644
3645 /* reduce obj's oeaten field, making sure it never hits or passes 0 */
3646 void
3647 consume_oeaten(obj, amt)
3648 struct obj *obj;
3649 int amt;
3650 {
3651     /*
3652      * This is a hack to try to squelch several long standing mystery
3653      * food bugs.  A better solution would be to rewrite the entire
3654      * victual handling mechanism from scratch using a less complex
3655      * model.  Alternatively, this routine could call done_eating()
3656      * or food_disappears() but its callers would need revisions to
3657      * cope with context.victual.piece unexpectedly going away.
3658      *
3659      * Multi-turn eating operates by setting the food's oeaten field
3660      * to its full nutritional value and then running a counter which
3661      * independently keeps track of whether there is any food left.
3662      * The oeaten field can reach exactly zero on the last turn, and
3663      * the object isn't removed from inventory until the next turn
3664      * when the "you finish eating" message gets delivered, so the
3665      * food would be restored to the status of untouched during that
3666      * interval.  This resulted in unexpected encumbrance messages
3667      * at the end of a meal (if near enough to a threshold) and would
3668      * yield full food if there was an interruption on the critical
3669      * turn.  Also, there have been reports over the years of food
3670      * becoming massively heavy or producing unlimited satiation;
3671      * this would occur if reducing oeaten via subtraction attempted
3672      * to drop it below 0 since its unsigned type would produce a
3673      * huge positive value instead.  So far, no one has figured out
3674      * _why_ that inappropriate subtraction might sometimes happen.
3675      */
3676
3677     if (amt > 0) {
3678         /* bit shift to divide the remaining amount of food */
3679         obj->oeaten >>= amt;
3680     } else {
3681         /* simple decrement; value is negative so we actually add it */
3682         if ((int) obj->oeaten > -amt)
3683             obj->oeaten += amt;
3684         else
3685             obj->oeaten = 0;
3686     }
3687
3688     if (obj->oeaten == 0) {
3689         if (obj == context.victual.piece) /* always true unless wishing... */
3690             context.victual.reqtime =
3691                 context.victual.usedtime; /* no bites left */
3692         obj->oeaten = 1; /* smallest possible positive value */
3693     }
3694 }
3695
3696 /* called when eatfood occupation has been interrupted,
3697    or in the case of theft, is about to be interrupted */
3698 boolean
3699 maybe_finished_meal(stopping)
3700 boolean stopping;
3701 {
3702     /* in case consume_oeaten() has decided that the food is all gone */
3703     if (occupation == eatfood
3704         && context.victual.usedtime >= context.victual.reqtime) {
3705         if (stopping)
3706             occupation = 0; /* for do_reset_eat */
3707         (void) eatfood();   /* calls done_eating() to use up
3708                                context.victual.piece */
3709         return TRUE;
3710     }
3711     return FALSE;
3712 }
3713
3714 /* Tin of <something> to the rescue?  Decide whether current occupation
3715    is an attempt to eat a tin of something capable of saving hero's life.
3716    We don't care about consumption of non-tinned food here because special
3717    effects there take place on first bite rather than at end of occupation.
3718    [Popeye the Sailor gets out of trouble by eating tins of spinach. :-] */
3719 boolean
3720 Popeye(threat)
3721 int threat;
3722 {
3723     struct obj *otin;
3724     int mndx;
3725
3726     if (occupation != opentin)
3727         return FALSE;
3728     otin = context.tin.tin;
3729     /* make sure hero still has access to tin */
3730     if (!carried(otin)
3731         && (!obj_here(otin, u.ux, u.uy) || !can_reach_floor(TRUE)))
3732         return FALSE;
3733     /* unknown tin is assumed to be helpful */
3734     if (!otin->known)
3735         return TRUE;
3736     /* known tin is helpful if it will stop life-threatening problem */
3737     mndx = otin->corpsenm;
3738     switch (threat) {
3739     /* note: not used; hunger code bypasses stop_occupation() when eating */
3740     case HUNGER:
3741         return (boolean) (mndx != NON_PM || otin->spe == 1);
3742     /* flesh from lizards and acidic critters stops petrification */
3743     case STONED:
3744         return (boolean) (mndx >= LOW_PM
3745                           && (mndx == PM_LIZARD || acidic(&mons[mndx])));
3746     /* no tins can cure these (yet?) */
3747     case SLIMED:
3748     case SICK:
3749     case VOMITING:
3750         break;
3751     default:
3752         break;
3753     }
3754     return FALSE;
3755 }
3756
3757 /*eat.c*/