OSDN Git Service

update year to 2020
[jnethack/source.git] / src / do.c
1 /* NetHack 3.6  do.c    $NHDT-Date: 1576638499 2019/12/18 03:08:19 $  $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.198 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /*-Copyright (c) Derek S. Ray, 2015. */
4 /* NetHack may be freely redistributed.  See license for details. */
5
6 /* Contains code for 'd', 'D' (drop), '>', '<' (up, down) */
7
8 /* JNetHack Copyright */
9 /* (c) Issei Numata, Naoki Hamada, Shigehiro Miyashita, 1994-2000  */
10 /* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2020            */
11 /* JNetHack may be freely redistributed.  See license for details. */
12
13 #include "hack.h"
14 #include "lev.h"
15
16 STATIC_DCL void FDECL(trycall, (struct obj *));
17 STATIC_DCL void NDECL(polymorph_sink);
18 STATIC_DCL boolean NDECL(teleport_sink);
19 STATIC_DCL void FDECL(dosinkring, (struct obj *));
20 STATIC_PTR int FDECL(drop, (struct obj *));
21 STATIC_PTR int NDECL(wipeoff);
22 STATIC_DCL int FDECL(menu_drop, (int));
23 STATIC_DCL int NDECL(currentlevel_rewrite);
24 STATIC_DCL void NDECL(final_level);
25 /* static boolean FDECL(badspot, (XCHAR_P,XCHAR_P)); */
26
27 extern int n_dgns; /* number of dungeons, from dungeon.c */
28
29 static NEARDATA const char drop_types[] = { ALLOW_COUNT, COIN_CLASS,
30                                             ALL_CLASSES, 0 };
31
32 /* 'd' command: drop one inventory item */
33 int
34 dodrop()
35 {
36     int result, i = (invent) ? 0 : (SIZE(drop_types) - 1);
37
38     if (*u.ushops)
39         sellobj_state(SELL_DELIBERATE);
40     result = drop(getobj(&drop_types[i], "drop"));
41     if (*u.ushops)
42         sellobj_state(SELL_NORMAL);
43     if (result)
44         reset_occupations();
45
46     return result;
47 }
48
49 /* Called when a boulder is dropped, thrown, or pushed.  If it ends up
50  * in a pool, it either fills the pool up or sinks away.  In either case,
51  * it's gone for good...  If the destination is not a pool, returns FALSE.
52  */
53 boolean
54 boulder_hits_pool(otmp, rx, ry, pushing)
55 struct obj *otmp;
56 register int rx, ry;
57 boolean pushing;
58 {
59     if (!otmp || otmp->otyp != BOULDER) {
60         impossible("Not a boulder?");
61     } else if (!Is_waterlevel(&u.uz) && is_pool_or_lava(rx, ry)) {
62         boolean lava = is_lava(rx, ry), fills_up;
63         const char *what = waterbody_name(rx, ry);
64         schar ltyp = levl[rx][ry].typ;
65         int chance = rn2(10); /* water: 90%; lava: 10% */
66         fills_up = lava ? chance == 0 : chance != 0;
67
68         if (fills_up) {
69             struct trap *ttmp = t_at(rx, ry);
70
71             if (ltyp == DRAWBRIDGE_UP) {
72                 levl[rx][ry].drawbridgemask &= ~DB_UNDER; /* clear lava */
73                 levl[rx][ry].drawbridgemask |= DB_FLOOR;
74             } else
75                 levl[rx][ry].typ = ROOM, levl[rx][ry].flags = 0;
76
77             if (ttmp)
78                 (void) delfloortrap(ttmp);
79             bury_objs(rx, ry);
80
81             newsym(rx, ry);
82             if (pushing) {
83                 char whobuf[BUFSZ];
84
85 /*JP
86                 Strcpy(whobuf, "you");
87 */
88                 Strcpy(whobuf, "\82 \82È\82½");
89                 if (u.usteed)
90                     Strcpy(whobuf, y_monnam(u.usteed));
91 #if 0 /*JP:T*/
92                 pline("%s %s %s into the %s.", upstart(whobuf),
93                       vtense(whobuf, "push"), the(xname(otmp)), what);
94 #else
95                 pline("%s\82Í%s\82ð%s\82Ì\92\86\82Ö\89\9f\82µ\82±\82ñ\82¾\81D", whobuf,
96                       xname(otmp), what);
97 #endif
98                 if (flags.verbose && !Blind)
99 /*JP
100                     pline("Now you can cross it!");
101 */
102                     pline("\82³\82\9f\93n\82ê\82é\82¼\81I");
103                 /* no splashing in this case */
104             }
105         }
106         if (!fills_up || !pushing) { /* splashing occurs */
107             if (!u.uinwater) {
108                 if (pushing ? !Blind : cansee(rx, ry)) {
109 #if 0 /*JP:T*/
110                     There("is a large splash as %s %s the %s.",
111                           the(xname(otmp)), fills_up ? "fills" : "falls into",
112                           what);
113 #else
114                     pline("%s\82ð%s\82É%s\82Æ\91å\82«\82È\82µ\82Ô\82«\82ª\82 \82ª\82Á\82½\81D",
115                           xname(otmp), what,
116                           fills_up ? "\96\84\82ß\8d\9e\82Þ" : "\97\8e\82·" );
117 #endif
118                 } else if (!Deaf)
119 /*JP
120                     You_hear("a%s splash.", lava ? " sizzling" : "");
121 */
122                     You_hear("%s\82Æ\8c¾\82¤\89¹\82ð\95·\82¢\82½\81D",lava ? "\83V\83\85\81[\83b" : "\83p\83V\83\83\83b");
123                 wake_nearto(rx, ry, 40);
124             }
125
126             if (fills_up && u.uinwater && distu(rx, ry) == 0) {
127                 u.uinwater = 0;
128                 docrt();
129                 vision_full_recalc = 1;
130 /*JP
131                 You("find yourself on dry land again!");
132 */
133                 You("\82¢\82Â\82Ì\82Ü\82É\82©\8a£\82¢\82½\8fê\8f\8a\82É\82¢\82½\81I");
134             } else if (lava && distu(rx, ry) <= 2) {
135                 int dmg;
136 #if 0 /*JP:T*/
137                 You("are hit by molten %s%c",
138                     hliquid("lava"), Fire_resistance ? '.' : '!');
139 #else
140                 You("\82Ç\82ë\82Ç\82ë\82Ì%s\82Å\83_\83\81\81[\83W\82ð\8eó\82¯\82½%s",
141                     hliquid("\97n\8aâ"), Fire_resistance ? "\81D" : "\81I");
142 #endif
143                 burn_away_slime();
144                 dmg = d((Fire_resistance ? 1 : 3), 6);
145 #if 0 /*JP:T*/
146                 losehp(Maybe_Half_Phys(dmg), /* lava damage */
147                        "molten lava", KILLED_BY);
148 #else
149                 losehp(Maybe_Half_Phys(dmg), /* lava damage */
150                        "\82Ç\82ë\82Ç\82ë\82Ì\97n\8aâ\82Å", KILLED_BY);
151 #endif
152             } else if (!fills_up && flags.verbose
153                        && (pushing ? !Blind : cansee(rx, ry)))
154 /*JP
155                 pline("It sinks without a trace!");
156 */
157                 pline("\82»\82ê\82Í\82 \82Æ\82©\82½\82à\82È\82­\92¾\82ñ\82¾\81I");
158         }
159
160         /* boulder is now gone */
161         if (pushing)
162             delobj(otmp);
163         else
164             obfree(otmp, (struct obj *) 0);
165         return TRUE;
166     }
167     return FALSE;
168 }
169
170 /* Used for objects which sometimes do special things when dropped; must be
171  * called with the object not in any chain.  Returns TRUE if the object goes
172  * away.
173  */
174 boolean
175 flooreffects(obj, x, y, verb)
176 struct obj *obj;
177 int x, y;
178 const char *verb;
179 {
180 #if 1 /*JP*//* trap.c */
181         extern const char *set_you[2];
182 #endif
183     struct trap *t;
184     struct monst *mtmp;
185     struct obj *otmp;
186 #if 0 /*JP*//*unused*/
187     boolean tseen;
188     int ttyp = NO_TRAP;
189 #endif
190
191     if (obj->where != OBJ_FREE)
192         panic("flooreffects: obj not free");
193
194     /* make sure things like water_damage() have no pointers to follow */
195     obj->nobj = obj->nexthere = (struct obj *) 0;
196
197     if (obj->otyp == BOULDER && boulder_hits_pool(obj, x, y, FALSE)) {
198         return TRUE;
199     } else if (obj->otyp == BOULDER && (t = t_at(x, y)) != 0
200                && (is_pit(t->ttyp) || is_hole(t->ttyp))) {
201 #if 0 /*JP*/
202         ttyp = t->ttyp;
203         tseen = t->tseen ? TRUE : FALSE;
204 #endif
205         if (((mtmp = m_at(x, y)) && mtmp->mtrapped)
206             || (u.utrap && u.ux == x && u.uy == y)) {
207             if (*verb && (cansee(x, y) || distu(x, y) == 0))
208 #if 0 /*JP:T*/
209                 pline("%s boulder %s into the pit%s.",
210                       Blind ? "A" : "The",
211                       vtense((const char *) 0, verb),
212                       mtmp ? "" : " with you");
213 #else
214                 pline("\8aâ\82Í%s\97\8e\82µ\8c\8a\82Ö%s\81D",
215                       mtmp ? "" : "\82 \82È\82½\82Æ\82¢\82Á\82µ\82å\82É",
216                       jpast(verb));
217 #endif
218             if (mtmp) {
219                 if (!passes_walls(mtmp->data) && !throws_rocks(mtmp->data)) {
220                     /* dieroll was rnd(20); 1: maximum chance to hit
221                        since trapped target is a sitting duck */
222                     int damage, dieroll = 1;
223
224                     /* As of 3.6.2: this was calling hmon() unconditionally
225                        so always credited/blamed the hero but the boulder
226                        might have been thrown by a giant or launched by
227                        a rolling boulder trap triggered by a monster or
228                        dropped by a scroll of earth read by a monster */
229                     if (context.mon_moving) {
230                         /* normally we'd use ohitmon() but it can call
231                            drop_throw() which calls flooreffects() */
232                         damage = dmgval(obj, mtmp);
233                         mtmp->mhp -= damage;
234                         if (DEADMONSTER(mtmp)) {
235                             if (canspotmon(mtmp))
236 #if 0 /*JP:T*/
237                                 pline("%s is %s!", Monnam(mtmp),
238                                       (nonliving(mtmp->data)
239                                        || is_vampshifter(mtmp))
240                                       ? "destroyed" : "killed");
241 #else
242                                 pline("%s\82Í%s\81I", Monnam(mtmp),
243                                       (nonliving(mtmp->data)
244                                        || is_vampshifter(mtmp))
245                                       ? "\93|\82³\82ê\82½" : "\8eE\82³\82ê\82½");
246 #endif
247                             mondied(mtmp);
248                         }
249                     } else {
250                         (void) hmon(mtmp, obj, HMON_THROWN, dieroll);
251                     }
252                     if (!DEADMONSTER(mtmp) && !is_whirly(mtmp->data))
253                         return FALSE; /* still alive */
254                 }
255                 mtmp->mtrapped = 0;
256             } else {
257                 if (!Passes_walls && !throws_rocks(youmonst.data)) {
258 #if 0 /*JP*/
259                     losehp(Maybe_Half_Phys(rnd(15)),
260                            "squished under a boulder", NO_KILLER_PREFIX);
261 #else
262                     losehp(Maybe_Half_Phys(rnd(15)),
263                            "\8aâ\82Ì\89º\82Å\92×\82³\82ê\82Ä", KILLED_BY);
264 #endif
265                     return FALSE; /* player remains trapped */
266                 } else
267                     reset_utrap(TRUE);
268             }
269         }
270         if (*verb) {
271             if (Blind && (x == u.ux) && (y == u.uy)) {
272 /*JP
273                 You_hear("a CRASH! beneath you.");
274 */
275                 You_hear("\91«\8c³\82Å\89½\82©\82ª\8dÓ\82¯\82é\89¹\82ð\95·\82¢\82½\81D");
276             } else if (!Blind && cansee(x, y)) {
277 #if 0 /*JP:T*/
278                 pline_The("boulder %s%s.",
279                           (ttyp == TRAPDOOR && !tseen)
280                               ? "triggers and " : "",
281                           (ttyp == TRAPDOOR)
282                               ? "plugs a trap door"
283                               : (ttyp == HOLE) ? "plugs a hole"
284                                                : "fills a pit");
285 #else
286                 pline_The("\8aâ\82Í%s%s\81D", t->tseen ? "" : "ã©\82ð\8bN\93®\82µ\82Ä\81C",
287                           t->ttyp == TRAPDOOR ? "\97\8e\82µ\94à\82ð\96\84\82ß\82½" :
288                           t->ttyp == HOLE ? "\8c\8a\82ð\96\84\82ß\82½" :
289                           "\97\8e\82µ\8c\8a\82ð\96\84\82ß\82½");
290 #endif
291             } else {
292 /*JP
293                 You_hear("a boulder %s.", verb);
294 */
295                 You_hear("\8aâ\82ª%s\89¹\82ð\95·\82¢\82½\81D", verb);
296             }
297         }
298         /*
299          * Note:  trap might have gone away via ((hmon -> killed -> xkilled)
300          *  || mondied) -> mondead -> m_detach -> fill_pit.
301          */
302         if ((t = t_at(x, y)) != 0)
303             deltrap(t);
304         useupf(obj, 1L);
305         bury_objs(x, y);
306         newsym(x, y);
307         return TRUE;
308     } else if (is_lava(x, y)) {
309         return lava_damage(obj, x, y);
310     } else if (is_pool(x, y)) {
311         /* Reasonably bulky objects (arbitrary) splash when dropped.
312          * If you're floating above the water even small things make
313          * noise.  Stuff dropped near fountains always misses */
314         if ((Blind || (Levitation || Flying)) && !Deaf
315             && ((x == u.ux) && (y == u.uy))) {
316             if (!Underwater) {
317                 if (weight(obj) > 9) {
318 /*JP
319                     pline("Splash!");
320 */
321                     pline("\83o\83V\83\83\83b\81I");
322                 } else if (Levitation || Flying) {
323 /*JP
324                     pline("Plop!");
325 */
326                     pline("\83|\83`\83\83\83\93\81I");
327                 }
328             }
329             map_background(x, y, 0);
330             newsym(x, y);
331         }
332         return water_damage(obj, NULL, FALSE) == ER_DESTROYED;
333     } else if (u.ux == x && u.uy == y && (t = t_at(x, y)) != 0
334                && (uteetering_at_seen_pit(t) || uescaped_shaft(t))) {
335         if (Blind && !Deaf)
336 /*JP
337             You_hear("%s tumble downwards.", the(xname(obj)));
338 */
339             You_hear("%s\82ª\89º\82Ì\95û\82Ö\93]\82ª\82Á\82Ä\82¢\82­\89¹\82ð\95·\82¢\82½\81D", xname(obj));
340         else
341 #if 0 /*JP*/
342             pline("%s %s into %s %s.", The(xname(obj)),
343                   otense(obj, "tumble"), the_your[t->madeby_u],
344                   is_pit(t->ttyp) ? "pit" : "hole");
345 #else
346             pline("%s\82Í%s\8c\8a\82É\93]\82ª\82è\82¨\82¿\82½\81D", xname(obj),
347                   set_you[t->madeby_u]);
348 #endif
349     } else if (obj->globby) {
350         /* Globby things like puddings might stick together */
351         while (obj && (otmp = obj_nexto_xy(obj, x, y, TRUE)) != 0) {
352             pudding_merge_message(obj, otmp);
353             /* intentionally not getting the melded object; obj_meld may set
354              * obj to null. */
355             (void) obj_meld(&obj, &otmp);
356         }
357         return (boolean) !obj;
358     }
359     return FALSE;
360 }
361
362 /* obj is an object dropped on an altar */
363 void
364 doaltarobj(obj)
365 register struct obj *obj;
366 {
367     if (Blind)
368         return;
369
370     if (obj->oclass != COIN_CLASS) {
371         /* KMH, conduct */
372         u.uconduct.gnostic++;
373     } else {
374         /* coins don't have bless/curse status */
375         obj->blessed = obj->cursed = 0;
376     }
377
378     if (obj->blessed || obj->cursed) {
379 #if 0 /*JP:T*/
380         There("is %s flash as %s %s the altar.",
381               an(hcolor(obj->blessed ? NH_AMBER : NH_BLACK)), doname(obj),
382               otense(obj, "hit"));
383 #else
384         pline("%s\82ª\8dÕ\92d\82É\90G\82ê\82é\82Æ%s\8cõ\82Á\82½\81D",
385               doname(obj),
386               jconj_adj(hcolor(obj->blessed ? NH_AMBER : NH_BLACK)));
387 #endif
388         if (!Hallucination)
389             obj->bknown = 1; /* ok to bypass set_bknown() */
390     } else {
391 /*JP
392         pline("%s %s on the altar.", Doname2(obj), otense(obj, "land"));
393 */
394         pline("%s\82ð\8dÕ\92d\82Ì\8fã\82É\92u\82¢\82½\81D", Doname2(obj));
395         if (obj->oclass != COIN_CLASS)
396             obj->bknown = 1; /* ok to bypass set_bknown() */
397     }
398 }
399
400 STATIC_OVL void
401 trycall(obj)
402 register struct obj *obj;
403 {
404     if (!objects[obj->otyp].oc_name_known && !objects[obj->otyp].oc_uname)
405         docall(obj);
406 }
407
408 /* Transforms the sink at the player's position into
409    a fountain, throne, altar or grave. */
410 STATIC_DCL void
411 polymorph_sink()
412 {
413     uchar sym = S_sink;
414     boolean sinklooted;
415     int algn;
416
417     if (levl[u.ux][u.uy].typ != SINK)
418         return;
419
420     sinklooted = levl[u.ux][u.uy].looted != 0;
421     level.flags.nsinks--;
422     levl[u.ux][u.uy].doormask = 0; /* levl[][].flags */
423     switch (rn2(4)) {
424     default:
425     case 0:
426         sym = S_fountain;
427         levl[u.ux][u.uy].typ = FOUNTAIN;
428         levl[u.ux][u.uy].blessedftn = 0;
429         if (sinklooted)
430             SET_FOUNTAIN_LOOTED(u.ux, u.uy);
431         level.flags.nfountains++;
432         break;
433     case 1:
434         sym = S_throne;
435         levl[u.ux][u.uy].typ = THRONE;
436         if (sinklooted)
437             levl[u.ux][u.uy].looted = T_LOOTED;
438         break;
439     case 2:
440         sym = S_altar;
441         levl[u.ux][u.uy].typ = ALTAR;
442         /* 3.6.3: this used to pass 'rn2(A_LAWFUL + 2) - 1' to
443            Align2amask() but that evaluates its argument more than once */
444         algn = rn2(3) - 1; /* -1 (A_Cha) or 0 (A_Neu) or +1 (A_Law) */
445         levl[u.ux][u.uy].altarmask = ((Inhell && rn2(3)) ? AM_NONE
446                                       : Align2amask(algn));
447         break;
448     case 3:
449         sym = S_room;
450         levl[u.ux][u.uy].typ = ROOM;
451         make_grave(u.ux, u.uy, (char *) 0);
452         if (levl[u.ux][u.uy].typ == GRAVE)
453             sym = S_grave;
454         break;
455     }
456     /* give message even if blind; we know we're not levitating,
457        so can feel the outcome even if we can't directly see it */
458     if (levl[u.ux][u.uy].typ != ROOM)
459 /*JP
460         pline_The("sink transforms into %s!", an(defsyms[sym].explanation));
461 */
462         pline_The("\97¬\82µ\91ä\82Í%s\82É\95Ï\89»\82µ\82½\81I", defsyms[sym].explanation);
463     else
464 /*JP
465         pline_The("sink vanishes.");
466 */
467         pline("\97¬\82µ\91ä\82Í\8fÁ\82¦\82½\81D");
468     newsym(u.ux, u.uy);
469 }
470
471 /* Teleports the sink at the player's position;
472    return True if sink teleported. */
473 STATIC_DCL boolean
474 teleport_sink()
475 {
476     int cx, cy;
477     int cnt = 0;
478     struct trap *trp;
479     struct engr *eng;
480
481     do {
482         cx = rnd(COLNO - 1);
483         cy = rn2(ROWNO);
484         trp = t_at(cx, cy);
485         eng = engr_at(cx, cy);
486     } while ((levl[cx][cy].typ != ROOM || trp || eng || cansee(cx, cy))
487              && cnt++ < 200);
488
489     if (levl[cx][cy].typ == ROOM && !trp && !eng) {
490         /* create sink at new position */
491         levl[cx][cy].typ = SINK;
492         levl[cx][cy].looted = levl[u.ux][u.uy].looted;
493         newsym(cx, cy);
494         /* remove old sink */
495         levl[u.ux][u.uy].typ = ROOM;
496         levl[u.ux][u.uy].looted = 0;
497         newsym(u.ux, u.uy);
498         return TRUE;
499     }
500     return FALSE;
501 }
502
503 /* obj is a ring being dropped over a kitchen sink */
504 STATIC_OVL void
505 dosinkring(obj)
506 register struct obj *obj;
507 {
508     struct obj *otmp, *otmp2;
509     boolean ideed = TRUE;
510     boolean nosink = FALSE;
511
512 /*JP
513     You("drop %s down the drain.", doname(obj));
514 */
515     You("%s\82ð\94r\90\85\8cû\82É\97\8e\82µ\82½\81D", doname(obj));
516     obj->in_use = TRUE;  /* block free identification via interrupt */
517     switch (obj->otyp) { /* effects that can be noticed without eyes */
518     case RIN_SEARCHING:
519 /*JP
520         You("thought %s got lost in the sink, but there it is!", yname(obj));
521 */
522         You("%s\82ð\8e¸\82Á\82½\8bC\82ª\82µ\82½\82ª\81C\8bC\82Ì\82¹\82¢\82¾\82Á\82½\81I", yname(obj));
523         goto giveback;
524     case RIN_SLOW_DIGESTION:
525 /*JP
526         pline_The("ring is regurgitated!");
527 */
528         pline("\8ew\97Ö\82Í\8bt\97¬\82µ\82½\81I");
529  giveback:
530         obj->in_use = FALSE;
531         dropx(obj);
532         trycall(obj);
533         return;
534     case RIN_LEVITATION:
535 /*JP
536         pline_The("sink quivers upward for a moment.");
537 */
538         pline("\97¬\82µ\91ä\82Í\88ê\8fu\81C\8fã\89º\82É\90k\82¦\82½\81D");
539         break;
540     case RIN_POISON_RESISTANCE:
541 /*JP
542         You("smell rotten %s.", makeplural(fruitname(FALSE)));
543 */
544         pline("\95\85\82Á\82½%s\82Ì\82æ\82¤\82È\93õ\82¢\82ª\82µ\82½\81D", fruitname(FALSE));
545         break;
546     case RIN_AGGRAVATE_MONSTER:
547 #if 0 /*JP:T*/
548         pline("Several %s buzz angrily around the sink.",
549               Hallucination ? makeplural(rndmonnam(NULL)) : "flies");
550 #else
551         pline("\90\94\95C\82Ì%s\82ª\83u\83\93\83u\83\93\97¬\82µ\91ä\82Ì\89ñ\82è\82ð\94ò\82Ñ\82Ü\82í\82Á\82½\81D",
552               Hallucination ? rndmonnam(NULL) : "\83n\83G");
553 #endif
554         break;
555     case RIN_SHOCK_RESISTANCE:
556 /*JP
557         pline("Static electricity surrounds the sink.");
558 */
559         pline("\97¬\82µ\91ä\82ª\83s\83\8a\83s\83\8a\82µ\82Í\82\82ß\82½\81D");
560         break;
561     case RIN_CONFLICT:
562 /*JP
563         You_hear("loud noises coming from the drain.");
564 */
565         You_hear("\94r\90\85\8cû\82©\82ç\82Ì\91å\82«\82È\89¹\82ð\95·\82¢\82½\81D");
566         break;
567     case RIN_SUSTAIN_ABILITY: /* KMH */
568 /*JP
569         pline_The("%s flow seems fixed.", hliquid("water"));
570 */
571         pline("%s\82Ì\97¬\82ê\82ª\88ê\92è\82É\82È\82Á\82½\82æ\82¤\82¾\81D", hliquid("\90\85"));
572         break;
573     case RIN_GAIN_STRENGTH:
574 #if 0 /*JP:T*/
575         pline_The("%s flow seems %ser now.",
576                   hliquid("water"),
577                   (obj->spe < 0) ? "weak" : "strong");
578 #else
579         pline("%s\82Ì\97¬\82ê\82ª%s\82­\82È\82Á\82½\82æ\82¤\82¾\81D",
580                   hliquid("\90\85"),
581                   (obj->spe < 0) ? "\8eã" : "\8b­");
582 #endif
583         break;
584     case RIN_GAIN_CONSTITUTION:
585 #if 0 /*JP:T*/
586         pline_The("%s flow seems %ser now.",
587                   hliquid("water"),
588                   (obj->spe < 0) ? "less" : "great");
589 #else
590         pline("\97¬\82ê\82é%s\82Ì\97Ê\82ª%s\82­\82È\82Á\82½\82æ\82¤\82¾\81D",
591                   hliquid("\90\85"),
592                   (obj->spe < 0) ? "\8f­\82È" : "\91½");
593 #endif
594         break;
595     case RIN_INCREASE_ACCURACY: /* KMH */
596 #if 0 /*JP:T*/
597         pline_The("%s flow %s the drain.",
598                   hliquid("water"),
599                   (obj->spe < 0) ? "misses" : "hits");
600 #else
601         pline("%s\82ª\94r\90\85\8cû%s\82æ\82¤\82É\82È\82Á\82½\81D",
602                   hliquid("\90\85"),
603                   (obj->spe < 0) ? "\82©\82ç\94½\82ê\82é" : "\82ß\82ª\82¯\82Ä\97¬\82ê\82é");
604 #endif
605         break;
606     case RIN_INCREASE_DAMAGE:
607 #if 0 /*JP:T*/
608         pline_The("water's force seems %ser now.",
609                   (obj->spe < 0) ? "small" : "great");
610 #else
611         pline("\90\85\82Ì\90¨\82¢\82ª%s\82­\82È\82Á\82½\82æ\82¤\82¾\81D",
612                   (obj->spe < 0) ? "\8eã" : "\8b­");
613 #endif
614         break;
615     case RIN_HUNGER:
616         ideed = FALSE;
617         for (otmp = level.objects[u.ux][u.uy]; otmp; otmp = otmp2) {
618             otmp2 = otmp->nexthere;
619             if (otmp != uball && otmp != uchain
620                 && !obj_resists(otmp, 1, 99)) {
621                 if (!Blind) {
622 #if 0 /*JP:T*/
623                     pline("Suddenly, %s %s from the sink!", doname(otmp),
624                           otense(otmp, "vanish"));
625 #else
626                     pline("\93Ë\91R\81C%s\82Í\97¬\82µ\91ä\82©\82ç\8fÁ\82¦\82½\81I", doname(otmp));
627 #endif
628                     ideed = TRUE;
629                 }
630                 delobj(otmp);
631             }
632         }
633         break;
634     case MEAT_RING:
635         /* Not the same as aggravate monster; besides, it's obvious. */
636 /*JP
637         pline("Several flies buzz around the sink.");
638 */
639         pline("\90\94\95C\82Ì\83n\83G\82ª\83u\83\93\83u\83\93\97¬\82µ\91ä\82Ì\89ñ\82è\82ð\94ò\82Ñ\82Ü\82í\82Á\82½\81D");
640         break;
641     case RIN_TELEPORTATION:
642         nosink = teleport_sink();
643         /* give message even if blind; we know we're not levitating,
644            so can feel the outcome even if we can't directly see it */
645 /*JP
646         pline_The("sink %svanishes.", nosink ? "" : "momentarily ");
647 */
648         pline_The("\97¬\82µ\91ä\82Í%s\8fÁ\82¦\82½\81D", nosink ? "" : "\88ê\8fu");
649         ideed = FALSE;
650         break;
651     case RIN_POLYMORPH:
652         polymorph_sink();
653         nosink = TRUE;
654         /* for S_room case, same message as for teleportation is given */
655         ideed = (levl[u.ux][u.uy].typ != ROOM);
656         break;
657     default:
658         ideed = FALSE;
659         break;
660     }
661     if (!Blind && !ideed) {
662         ideed = TRUE;
663         switch (obj->otyp) { /* effects that need eyes */
664         case RIN_ADORNMENT:
665 /*JP
666             pline_The("faucets flash brightly for a moment.");
667 */
668             pline("\8eÖ\8cû\82Í\88ê\8fu\96¾\82é\82­\8bP\82¢\82½\81D");
669             break;
670         case RIN_REGENERATION:
671 /*JP
672             pline_The("sink looks as good as new.");
673 */
674             pline("\97¬\82µ\91ä\82ª\90V\95i\82Ì\82æ\82¤\82É\82È\82Á\82½\81D");
675             break;
676         case RIN_INVISIBILITY:
677 /*JP
678             You("don't see anything happen to the sink.");
679 */
680             pline("\97¬\82µ\91ä\82É\89½\82ª\8bN\82«\82½\82Ì\82©\8c©\82¦\82È\82©\82Á\82½\81D");
681             break;
682         case RIN_FREE_ACTION:
683 /*JP
684             You_see("the ring slide right down the drain!");
685 */
686             pline("\8ew\97Ö\82ª\94r\90\85\8cû\82ð\82·\82é\82è\82Æ\94ð\82¯\82é\82Ì\82ð\8c©\82½\81I");
687             break;
688         case RIN_SEE_INVISIBLE:
689 #if 0 /*JP:T*/
690             You_see("some %s in the sink.",
691                     Hallucination ? "oxygen molecules" : "air");
692 #else
693             pline("\97¬\82µ\91ä\82Ì\8fã\82Ì%s\82ª\8c©\82¦\82½\81D",
694                   Hallucination ? "\8e_\91f\95ª\8eq" : "\8bó\8bC");
695 #endif
696             break;
697         case RIN_STEALTH:
698 /*JP
699             pline_The("sink seems to blend into the floor for a moment.");
700 */
701             pline("\88ê\8fu\81C\97¬\82µ\91ä\82ª\8f°\82É\97n\82¯\82±\82ñ\82¾\82æ\82¤\82É\8c©\82¦\82½\81D");
702             break;
703         case RIN_FIRE_RESISTANCE:
704 #if 0 /*JP*/
705             pline_The("hot %s faucet flashes brightly for a moment.",
706                       hliquid("water"));
707 #else /*\82Æ\82è\82 \82¦\82¸hliquid()\82Í\8eg\82í\82È\82¢\8c`\82É*/
708             pline("\88ê\8fu\81C\94M\93\92\82Ì\8eÖ\8cû\82ª\96¾\82é\82­\8bP\82¢\82½\81D");
709 #endif
710             break;
711         case RIN_COLD_RESISTANCE:
712 #if 0 /*JP*/
713             pline_The("cold %s faucet flashes brightly for a moment.",
714                       hliquid("water"));
715 #else /*\82Æ\82è\82 \82¦\82¸hliquid()\82Í\8eg\82í\82È\82¢\8c`\82É*/
716             pline("\88ê\8fu\81C\97â\90\85\82Ì\8eÖ\8cû\82ª\96¾\82é\82­\8bP\82¢\82½\81D");
717 #endif
718             break;
719         case RIN_PROTECTION_FROM_SHAPE_CHAN:
720 /*JP
721             pline_The("sink looks nothing like a fountain.");
722 */
723             pline("\97¬\82µ\91ä\82Í\90ò\82Æ\82Í\82Ü\82Á\82½\82­\88á\82¤\82à\82Ì\82Ì\82æ\82¤\82É\8c©\82¦\82½\81D");
724             break;
725         case RIN_PROTECTION:
726 #if 0 /*JP:T*/
727             pline_The("sink glows %s for a moment.",
728                       hcolor((obj->spe < 0) ? NH_BLACK : NH_SILVER));
729 #else
730             pline("\97¬\82µ\91ä\82Í\88ê\8fu%s\8bP\82¢\82½\81D",
731                       jconj_adj(hcolor((obj->spe < 0) ? NH_BLACK : NH_SILVER)));
732 #endif
733             break;
734         case RIN_WARNING:
735 /*JP
736             pline_The("sink glows %s for a moment.", hcolor(NH_WHITE));
737 */
738             pline("\97¬\82µ\91ä\82Í\88ê\8fu%s\8bP\82¢\82½\81D", jconj_adj(hcolor(NH_WHITE)));
739             break;
740         case RIN_TELEPORT_CONTROL:
741 /*JP: "beam aboard" \82Í\83X\83^\81[\83g\83\8c\83b\83N\82Ì\81u\93]\91\97\81v*/
742 /*JP
743             pline_The("sink looks like it is being beamed aboard somewhere.");
744 */
745             pline("\97¬\82µ\91ä\82Í\82Ç\82±\82©\82É\93]\91\97\82³\82ê\82æ\82¤\82Æ\82µ\82Ä\82¢\82é\82æ\82¤\82É\8c©\82¦\82½\81D");
746             break;
747         case RIN_POLYMORPH_CONTROL:
748             pline_The(
749 /*JP
750                   "sink momentarily looks like a regularly erupting geyser.");
751 */
752                   "\97¬\82µ\91ä\82Í\88ê\8fu\8bK\91¥\90³\82µ\82­\95¬\8fo\82·\82é\8aÔ\8c\87\90ò\82Ì\82æ\82¤\82É\8c©\82¦\82½\81D");
753             break;
754         default:
755             break;
756         }
757     }
758     if (ideed)
759         trycall(obj);
760     else if (!nosink)
761 /*JP
762         You_hear("the ring bouncing down the drainpipe.");
763 */
764         You_hear("\8ew\97Ö\82ª\94r\90\85\8cû\82É\93\96\82½\82è\82È\82ª\82ç\97\8e\82¿\82é\89¹\82ð\95·\82¢\82½\81D");
765
766     if (!rn2(20) && !nosink) {
767 /*JP
768         pline_The("sink backs up, leaving %s.", doname(obj));
769 */
770         pline("\97¬\82µ\91ä\82ª\8bt\97¬\82µ\82Ä\81C%s\82ª\96ß\82Á\82Ä\82«\82½\81D", doname(obj));
771         obj->in_use = FALSE;
772         dropx(obj);
773     } else if (!rn2(5)) {
774         freeinv(obj);
775         obj->in_use = FALSE;
776         obj->ox = u.ux;
777         obj->oy = u.uy;
778         add_to_buried(obj);
779     } else
780         useup(obj);
781 }
782
783 /* some common tests when trying to drop or throw items */
784 boolean
785 canletgo(obj, word)
786 struct obj *obj;
787 const char *word;
788 {
789     if (obj->owornmask & (W_ARMOR | W_ACCESSORY)) {
790         if (*word)
791 /*JP
792             Norep("You cannot %s %s you are wearing.", word, something);
793 */
794             Norep("\82 \82È\82½\82ª\90g\82É\82Â\82¯\82Ä\82¢\82é\82à\82Ì\82ð%s\82±\82Æ\82Í\82Å\82«\82È\82¢\81D", word);
795         return FALSE;
796     }
797     if (obj->otyp == LOADSTONE && obj->cursed) {
798         /* getobj() kludge sets corpsenm to user's specified count
799            when refusing to split a stack of cursed loadstones */
800         if (*word) {
801 #if 0 /*JP*//*\93ú\96{\8cê\82Å\82Í\95s\97v*/
802             /* getobj() ignores a count for throwing since that is
803                implicitly forced to be 1; replicate its kludge... */
804             if (!strcmp(word, "throw") && obj->quan > 1L)
805                 obj->corpsenm = 1;
806 #endif
807 #if 0 /*JP:T*/
808             pline("For some reason, you cannot %s%s the stone%s!", word,
809                   obj->corpsenm ? " any of" : "", plur(obj->quan));
810 #else
811             pline("\82Ç\82¤\82¢\82¤\82í\82¯\82©\81C\82 \82È\82½\82Í\90Î\82ð%s\82±\82Æ\82Í\82Å\82«\82È\82¢\81I",
812                   word);
813 #endif
814         }
815         obj->corpsenm = 0; /* reset */
816         set_bknown(obj, 1);
817         return FALSE;
818     }
819     if (obj->otyp == LEASH && obj->leashmon != 0) {
820         if (*word)
821 /*JP
822             pline_The("leash is tied around your %s.", body_part(HAND));
823 */
824             pline("\95R\82Í\82 \82È\82½\82Ì%s\82É\8c\8b\82Ñ\82Â\82¯\82ç\82ê\82Ä\82¢\82é\81D", body_part(HAND));
825         return FALSE;
826     }
827     if (obj->owornmask & W_SADDLE) {
828         if (*word)
829 /*JP
830             You("cannot %s %s you are sitting on.", word, something);
831 */
832             You("\8fæ\82Á\82Ä\82¢\82é\8aÔ\82Í%s\82±\82Æ\82Í\82Å\82«\82È\82¢\81D", word);
833         return FALSE;
834     }
835     return TRUE;
836 }
837
838 STATIC_PTR int
839 drop(obj)
840 register struct obj *obj;
841 {
842     if (!obj)
843         return 0;
844 /*JP
845     if (!canletgo(obj, "drop"))
846 */
847     if (!canletgo(obj, "\92u\82­"))
848         return 0;
849     if (obj == uwep) {
850         if (welded(uwep)) {
851             weldmsg(obj);
852             return 0;
853         }
854         setuwep((struct obj *) 0);
855     }
856     if (obj == uquiver) {
857         setuqwep((struct obj *) 0);
858     }
859     if (obj == uswapwep) {
860         setuswapwep((struct obj *) 0);
861     }
862
863     if (u.uswallow) {
864         /* barrier between you and the floor */
865         if (flags.verbose) {
866             char *onam_p, monbuf[BUFSZ];
867
868             /* doname can call s_suffix, reusing its buffer */
869             Strcpy(monbuf, s_suffix(mon_nam(u.ustuck)));
870             onam_p = is_unpaid(obj) ? yobjnam(obj, (char *) 0) : doname(obj);
871 #if 0 /*JP:T*/
872             You("drop %s into %s %s.", onam_p, monbuf,
873                 mbodypart(u.ustuck, STOMACH));
874 #else
875             You("%s\82ð%s%s\82É\92u\82¢\82½\81D", onam_p, monbuf,
876                 mbodypart(u.ustuck, STOMACH));
877 #endif
878         }
879     } else {
880         if ((obj->oclass == RING_CLASS || obj->otyp == MEAT_RING)
881             && IS_SINK(levl[u.ux][u.uy].typ)) {
882             dosinkring(obj);
883             return 1;
884         }
885         if (!can_reach_floor(TRUE)) {
886             /* we might be levitating due to #invoke Heart of Ahriman;
887                if so, levitation would end during call to freeinv()
888                and we want hitfloor() to happen before float_down() */
889             boolean levhack = finesse_ahriman(obj);
890
891             if (levhack)
892                 ELevitation = W_ART; /* other than W_ARTI */
893             if (flags.verbose)
894 /*JP
895                 You("drop %s.", doname(obj));
896 */
897                 You("%s\82ð\92u\82¢\82½\81D", doname(obj));
898             /* Ensure update when we drop gold objects */
899             if (obj->oclass == COIN_CLASS)
900                 context.botl = 1;
901             freeinv(obj);
902             hitfloor(obj, TRUE);
903             if (levhack)
904                 float_down(I_SPECIAL | TIMEOUT, W_ARTI | W_ART);
905             return 1;
906         }
907         if (!IS_ALTAR(levl[u.ux][u.uy].typ) && flags.verbose)
908 /*JP
909             You("drop %s.", doname(obj));
910 */
911             You("%s\82ð\92u\82¢\82½\81D", doname(obj));
912     }
913     dropx(obj);
914     return 1;
915 }
916
917 /* dropx - take dropped item out of inventory;
918    called in several places - may produce output
919    (eg ship_object() and dropy() -> sellobj() both produce output) */
920 void
921 dropx(obj)
922 register struct obj *obj;
923 {
924     /* Ensure update when we drop gold objects */
925     if (obj->oclass == COIN_CLASS)
926         context.botl = 1;
927     freeinv(obj);
928     if (!u.uswallow) {
929         if (ship_object(obj, u.ux, u.uy, FALSE))
930             return;
931         if (IS_ALTAR(levl[u.ux][u.uy].typ))
932             doaltarobj(obj); /* set bknown */
933     }
934     dropy(obj);
935 }
936
937 /* dropy - put dropped object at destination; called from lots of places */
938 void
939 dropy(obj)
940 struct obj *obj;
941 {
942     dropz(obj, FALSE);
943 }
944
945 /* dropz - really put dropped object at its destination... */
946 void
947 dropz(obj, with_impact)
948 struct obj *obj;
949 boolean with_impact;
950 {
951     if (obj == uwep)
952         setuwep((struct obj *) 0);
953     if (obj == uquiver)
954         setuqwep((struct obj *) 0);
955     if (obj == uswapwep)
956         setuswapwep((struct obj *) 0);
957
958 /*JP
959     if (!u.uswallow && flooreffects(obj, u.ux, u.uy, "drop"))
960 */
961     if (!u.uswallow && flooreffects(obj,u.ux,u.uy, "\97\8e\82¿\82é"))
962         return;
963     /* uswallow check done by GAN 01/29/87 */
964     if (u.uswallow) {
965         boolean could_petrify = FALSE;
966         boolean could_poly = FALSE;
967         boolean could_slime = FALSE;
968         boolean could_grow = FALSE;
969         boolean could_heal = FALSE;
970
971         if (obj != uball) { /* mon doesn't pick up ball */
972             if (obj->otyp == CORPSE) {
973                 could_petrify = touch_petrifies(&mons[obj->corpsenm]);
974                 could_poly = polyfodder(obj);
975                 could_slime = (obj->corpsenm == PM_GREEN_SLIME);
976                 could_grow = (obj->corpsenm == PM_WRAITH);
977                 could_heal = (obj->corpsenm == PM_NURSE);
978             }
979             if (is_unpaid(obj))
980                 (void) stolen_value(obj, u.ux, u.uy, TRUE, FALSE);
981             (void) mpickobj(u.ustuck, obj);
982             if (is_animal(u.ustuck->data)) {
983                 if (could_poly || could_slime) {
984                     (void) newcham(u.ustuck,
985                                    could_poly ? (struct permonst *) 0
986                                               : &mons[PM_GREEN_SLIME],
987                                    FALSE, could_slime);
988                     delobj(obj); /* corpse is digested */
989                 } else if (could_petrify) {
990                     minstapetrify(u.ustuck, TRUE);
991                     /* Don't leave a cockatrice corpse in a statue */
992                     if (!u.uswallow)
993                         delobj(obj);
994                 } else if (could_grow) {
995                     (void) grow_up(u.ustuck, (struct monst *) 0);
996                     delobj(obj); /* corpse is digested */
997                 } else if (could_heal) {
998                     u.ustuck->mhp = u.ustuck->mhpmax;
999                     delobj(obj); /* corpse is digested */
1000                 }
1001             }
1002         }
1003     } else {
1004         place_object(obj, u.ux, u.uy);
1005         if (with_impact)
1006             container_impact_dmg(obj, u.ux, u.uy);
1007         if (obj == uball)
1008             drop_ball(u.ux, u.uy);
1009         else if (level.flags.has_shop)
1010             sellobj(obj, u.ux, u.uy);
1011         stackobj(obj);
1012         if (Blind && Levitation)
1013             map_object(obj, 0);
1014         newsym(u.ux, u.uy); /* remap location under self */
1015     }
1016 }
1017
1018 /* things that must change when not held; recurse into containers.
1019    Called for both player and monsters */
1020 void
1021 obj_no_longer_held(obj)
1022 struct obj *obj;
1023 {
1024     if (!obj) {
1025         return;
1026     } else if (Has_contents(obj)) {
1027         struct obj *contents;
1028
1029         for (contents = obj->cobj; contents; contents = contents->nobj)
1030             obj_no_longer_held(contents);
1031     }
1032     switch (obj->otyp) {
1033     case CRYSKNIFE:
1034         /* Normal crysknife reverts to worm tooth when not held by hero
1035          * or monster; fixed crysknife has only 10% chance of reverting.
1036          * When a stack of the latter is involved, it could be worthwhile
1037          * to give each individual crysknife its own separate 10% chance,
1038          * but we aren't in any position to handle stack splitting here.
1039          */
1040         if (!obj->oerodeproof || !rn2(10)) {
1041             /* if monsters aren't moving, assume player is responsible */
1042             if (!context.mon_moving && !program_state.gameover)
1043                 costly_alteration(obj, COST_DEGRD);
1044             obj->otyp = WORM_TOOTH;
1045             obj->oerodeproof = 0;
1046         }
1047         break;
1048     }
1049 }
1050
1051 /* 'D' command: drop several things */
1052 int
1053 doddrop()
1054 {
1055     int result = 0;
1056
1057     if (!invent) {
1058 /*JP
1059         You("have nothing to drop.");
1060 */
1061         You("\97\8e\82Æ\82·\82à\82Ì\82ð\89½\82à\8e\9d\82Á\82Ä\82¢\82È\82¢\81D");
1062         return 0;
1063     }
1064     add_valid_menu_class(0); /* clear any classes already there */
1065     if (*u.ushops)
1066         sellobj_state(SELL_DELIBERATE);
1067     if (flags.menu_style != MENU_TRADITIONAL
1068         || (result = ggetobj("drop", drop, 0, FALSE, (unsigned *) 0)) < -1)
1069         result = menu_drop(result);
1070     if (*u.ushops)
1071         sellobj_state(SELL_NORMAL);
1072     if (result)
1073         reset_occupations();
1074
1075     return result;
1076 }
1077
1078 /* Drop things from the hero's inventory, using a menu. */
1079 STATIC_OVL int
1080 menu_drop(retry)
1081 int retry;
1082 {
1083     int n, i, n_dropped = 0;
1084     long cnt;
1085     struct obj *otmp, *otmp2;
1086     menu_item *pick_list;
1087     boolean all_categories = TRUE;
1088     boolean drop_everything = FALSE;
1089
1090     if (retry) {
1091         all_categories = (retry == -2);
1092     } else if (flags.menu_style == MENU_FULL) {
1093         all_categories = FALSE;
1094 /*JP
1095         n = query_category("Drop what type of items?", invent,
1096 */
1097         n = query_category("\82Ç\82Ì\8eí\97Þ\82Ì\83A\83C\83e\83\80\82ð\92u\82«\82Ü\82·\82©\81H", invent,
1098                            UNPAID_TYPES | ALL_TYPES | CHOOSE_ALL | BUC_BLESSED
1099                                | BUC_CURSED | BUC_UNCURSED | BUC_UNKNOWN,
1100                            &pick_list, PICK_ANY);
1101         if (!n)
1102             goto drop_done;
1103         for (i = 0; i < n; i++) {
1104             if (pick_list[i].item.a_int == ALL_TYPES_SELECTED)
1105                 all_categories = TRUE;
1106             else if (pick_list[i].item.a_int == 'A')
1107                 drop_everything = TRUE;
1108             else
1109                 add_valid_menu_class(pick_list[i].item.a_int);
1110         }
1111         free((genericptr_t) pick_list);
1112     } else if (flags.menu_style == MENU_COMBINATION) {
1113         unsigned ggoresults = 0;
1114
1115         all_categories = FALSE;
1116         /* Gather valid classes via traditional NetHack method */
1117         i = ggetobj("drop", drop, 0, TRUE, &ggoresults);
1118         if (i == -2)
1119             all_categories = TRUE;
1120         if (ggoresults & ALL_FINISHED) {
1121             n_dropped = i;
1122             goto drop_done;
1123         }
1124     }
1125
1126     if (drop_everything) {
1127         /*
1128          * Dropping a burning potion of oil while levitating can cause
1129          * an explosion which might destroy some of hero's inventory,
1130          * so the old code
1131          *      for (otmp = invent; otmp; otmp = otmp2) {
1132          *          otmp2 = otmp->nobj;
1133          *          n_dropped += drop(otmp);
1134          *      }
1135          * was unreliable and could lead to an "object lost" panic.
1136          *
1137          * Use the bypass bit to mark items already processed (hence
1138          * not droppable) and rescan inventory until no unbypassed
1139          * items remain.
1140          */
1141         bypass_objlist(invent, FALSE); /* clear bypass bit for invent */
1142         while ((otmp = nxt_unbypassed_obj(invent)) != 0)
1143             n_dropped += drop(otmp);
1144         /* we might not have dropped everything (worn armor, welded weapon,
1145            cursed loadstones), so reset any remaining inventory to normal */
1146         bypass_objlist(invent, FALSE);
1147     } else {
1148         /* should coordinate with perm invent, maybe not show worn items */
1149 #if 0 /*JP:T*/
1150         n = query_objlist("What would you like to drop?", &invent,
1151                           (USE_INVLET | INVORDER_SORT), &pick_list, PICK_ANY,
1152                           all_categories ? allow_all : allow_category);
1153 #else
1154         n = query_objlist("\82Ç\82ê\82ð\92u\82«\82Ü\82·\82©\81H", &invent,
1155                           (USE_INVLET | INVORDER_SORT), &pick_list, PICK_ANY,
1156                           all_categories ? allow_all : allow_category);
1157 #endif
1158         if (n > 0) {
1159             /*
1160              * picklist[] contains a set of pointers into inventory, but
1161              * as soon as something gets dropped, they might become stale
1162              * (see the drop_everything code above for an explanation).
1163              * Just checking to see whether one is still in the invent
1164              * chain is not sufficient validation since destroyed items
1165              * will be freed and items we've split here might have already
1166              * reused that memory and put the same pointer value back into
1167              * invent.  Ditto for using invlet to validate.  So we start
1168              * by setting bypass on all of invent, then check each pointer
1169              * to verify that it is in invent and has that bit set.
1170              */
1171             bypass_objlist(invent, TRUE);
1172             for (i = 0; i < n; i++) {
1173                 otmp = pick_list[i].item.a_obj;
1174                 for (otmp2 = invent; otmp2; otmp2 = otmp2->nobj)
1175                     if (otmp2 == otmp)
1176                         break;
1177                 if (!otmp2 || !otmp2->bypass)
1178                     continue;
1179                 /* found next selected invent item */
1180                 cnt = pick_list[i].count;
1181                 if (cnt < otmp->quan) {
1182                     if (welded(otmp)) {
1183                         ; /* don't split */
1184                     } else if (otmp->otyp == LOADSTONE && otmp->cursed) {
1185                         /* same kludge as getobj(), for canletgo()'s use */
1186                         otmp->corpsenm = (int) cnt; /* don't split */
1187                     } else {
1188                         otmp = splitobj(otmp, cnt);
1189                     }
1190                 }
1191                 n_dropped += drop(otmp);
1192             }
1193             bypass_objlist(invent, FALSE); /* reset invent to normal */
1194             free((genericptr_t) pick_list);
1195         }
1196     }
1197
1198  drop_done:
1199     return n_dropped;
1200 }
1201
1202 /* on a ladder, used in goto_level */
1203 static NEARDATA boolean at_ladder = FALSE;
1204
1205 /* the '>' command */
1206 int
1207 dodown()
1208 {
1209     struct trap *trap = 0;
1210     boolean stairs_down = ((u.ux == xdnstair && u.uy == ydnstair)
1211                            || (u.ux == sstairs.sx && u.uy == sstairs.sy
1212                                && !sstairs.up)),
1213             ladder_down = (u.ux == xdnladder && u.uy == ydnladder);
1214
1215     if (u_rooted())
1216         return 1;
1217
1218     if (stucksteed(TRUE)) {
1219         return 0;
1220     }
1221     /* Levitation might be blocked, but player can still use '>' to
1222        turn off controlled levitation */
1223     if (HLevitation || ELevitation) {
1224         if ((HLevitation & I_SPECIAL) || (ELevitation & W_ARTI)) {
1225             /* end controlled levitation */
1226             if (ELevitation & W_ARTI) {
1227                 struct obj *obj;
1228
1229                 for (obj = invent; obj; obj = obj->nobj) {
1230                     if (obj->oartifact
1231                         && artifact_has_invprop(obj, LEVITATION)) {
1232                         if (obj->age < monstermoves)
1233                             obj->age = monstermoves;
1234                         obj->age += rnz(100);
1235                     }
1236                 }
1237             }
1238             if (float_down(I_SPECIAL | TIMEOUT, W_ARTI)) {
1239                 return 1; /* came down, so moved */
1240             } else if (!HLevitation && !ELevitation) {
1241 /*JP
1242                 Your("latent levitation ceases.");
1243 */
1244                 pline("\90ö\8dÝ\93I\82È\95\82\97V\94\\97Í\82ª\92\86\92f\82µ\82½\81D");
1245                 return 1; /* did something, effectively moved */
1246             }
1247         }
1248         if (BLevitation) {
1249             ; /* weren't actually floating after all */
1250         } else if (Blind) {
1251             /* Avoid alerting player to an unknown stair or ladder.
1252              * Changes the message for a covered, known staircase
1253              * too; staircase knowledge is not stored anywhere.
1254              */
1255             if (stairs_down)
1256                 stairs_down =
1257                     (glyph_to_cmap(levl[u.ux][u.uy].glyph) == S_dnstair);
1258             else if (ladder_down)
1259                 ladder_down =
1260                     (glyph_to_cmap(levl[u.ux][u.uy].glyph) == S_dnladder);
1261         }
1262         if (Is_airlevel(&u.uz))
1263 /*JP
1264             You("are floating in the %s.", surface(u.ux, u.uy));
1265 */
1266             You("%s\82Ì\92\86\82É\95\82\82¢\82Ä\82¢\82é\81D", surface(u.ux, u.uy));
1267         else if (Is_waterlevel(&u.uz))
1268 #if 0 /*JP:T*/
1269             You("are floating in %s.",
1270                 is_pool(u.ux, u.uy) ? "the water" : "a bubble of air");
1271 #else
1272             You("%s\82Ì\92\86\82É\95\82\82¢\82Ä\82¢\82é\81D",
1273                 is_pool(u.ux, u.uy) ? "\90\85" : "\8bó\8bC\82Ì\96A");
1274 #endif
1275         else
1276 #if 0 /*JP:T*/
1277             floating_above(stairs_down ? "stairs" : ladder_down
1278                                                     ? "ladder"
1279                                                     : surface(u.ux, u.uy));
1280 #else
1281             floating_above(stairs_down ? "\8aK\92i" : ladder_down
1282                                                     ? "\82Í\82µ\82²"
1283                                                     : surface(u.ux, u.uy));
1284 #endif
1285         return 0; /* didn't move */
1286     }
1287
1288     if (Upolyd && ceiling_hider(&mons[u.umonnum]) && u.uundetected) {
1289         u.uundetected = 0;
1290         if (Flying) { /* lurker above */
1291 /*JP
1292             You("fly out of hiding.");
1293 */
1294             You("\89B\82ê\82é\82Ì\82ð\82â\82ß\82Ä\94ò\82Ñ\8fo\82µ\82½\81D");
1295         } else { /* piercer */
1296 /*JP
1297             You("drop to the %s.", surface(u.ux, u.uy));
1298 */
1299             You("%s\82É\97\8e\82¿\82½\81D", surface(u.ux, u.uy));
1300             if (is_pool_or_lava(u.ux, u.uy)) {
1301                 pooleffects(FALSE);
1302             } else {
1303                 (void) pickup(1);
1304                 if ((trap = t_at(u.ux, u.uy)) != 0)
1305                     dotrap(trap, TOOKPLUNGE);
1306             }
1307         }
1308         return 1; /* came out of hiding; might need '>' again to go down */
1309     }
1310
1311     if (!stairs_down && !ladder_down) {
1312         trap = t_at(u.ux, u.uy);
1313         if (trap && (uteetering_at_seen_pit(trap) || uescaped_shaft(trap))) {
1314             dotrap(trap, TOOKPLUNGE);
1315             return 1;
1316         } else if (!trap || !is_hole(trap->ttyp)
1317                    || !Can_fall_thru(&u.uz) || !trap->tseen) {
1318             if (flags.autodig && !context.nopick && uwep && is_pick(uwep)) {
1319                 return use_pick_axe2(uwep);
1320             } else {
1321 /*JP
1322                 You_cant("go down here.");
1323 */
1324                 pline("\82±\82±\82Å\82Í\8d~\82è\82é\82±\82Æ\82ª\82Å\82«\82È\82¢\81D");
1325                 return 0;
1326             }
1327         }
1328     }
1329     if (u.ustuck) {
1330 #if 0 /*JP*/
1331         You("are %s, and cannot go down.",
1332             !u.uswallow ? "being held" : is_animal(u.ustuck->data)
1333                                              ? "swallowed"
1334                                              : "engulfed");
1335 #else
1336         You("%s\8d~\82è\82é\82±\82Æ\82ª\82Å\82«\82È\82¢\81D",
1337             !u.uswallow ? "\82Â\82©\82Ü\82¦\82ç\82ê\82Ä\82¢\82Ä" : is_animal(u.ustuck->data)
1338                                              ? "\88ù\82Ý\8d\9e\82Ü\82ê\82Ä\82¢\82Ä"
1339                                              : "\8aª\82«\8d\9e\82Ü\82ê\82Ä\82¢\82Ä");
1340 #endif
1341         return 1;
1342     }
1343     if (on_level(&valley_level, &u.uz) && !u.uevent.gehennom_entered) {
1344 /*JP
1345         You("are standing at the gate to Gehennom.");
1346 */
1347         You("\83Q\83w\83i\82Ì\96å\82Ì\91O\82É\97§\82Á\82Ä\82¢\82é\81D");
1348 /*JP
1349         pline("Unspeakable cruelty and harm lurk down there.");
1350 */
1351         pline("\8c¾\97t\82É\82·\82ç\82Å\82«\82È\82¢\8ec\8bs\82Æ\8eS\8e\96\82ª\82±\82Ì\89º\82É\90ö\82ñ\82Å\82¢\82é\81D");
1352 /*JP
1353         if (yn("Are you sure you want to enter?") != 'y')
1354 */
1355         if (yn("\96{\93\96\82É\93ü\82è\82Ü\82·\82©\81H") != 'y')
1356             return 0;
1357         else
1358 /*JP
1359             pline("So be it.");
1360 */
1361             pline("\82È\82ç\8dD\82«\82É\82·\82ê\82Î\82æ\82¢\81D");
1362         u.uevent.gehennom_entered = 1; /* don't ask again */
1363     }
1364
1365     if (!next_to_u()) {
1366 /*JP
1367         You("are held back by your pet!");
1368 */
1369         You("\83y\83b\83g\82É\88ø\82«\82à\82Ç\82³\82ê\82½\81I");
1370         return 0;
1371     }
1372
1373     if (trap) {
1374 #if 0 /*JP*/
1375         const char *down_or_thru = trap->ttyp == HOLE ? "down" : "through";
1376 #endif
1377 #if 0 /*JP*/
1378         const char *actn = Flying ? "fly" : locomotion(youmonst.data, "jump");
1379 #else
1380         const char *actn = "";
1381 #endif
1382
1383         if (youmonst.data->msize >= MZ_HUGE) {
1384             char qbuf[QBUFSZ];
1385
1386 #if 0 /*JP:T*/
1387             You("don't fit %s easily.", down_or_thru);
1388             Sprintf(qbuf, "Try to squeeze %s?", down_or_thru);
1389 #else
1390             pline("\82±\82±\82Í\8b·\82­\82Ä\8aÈ\92P\82É\82Í\92Ê\82è\94²\82¯\82ç\82ê\82È\82¢\81D");
1391             Sprintf(qbuf, "\91Ì\82ð\89\9f\82µ\8d\9e\82Ý\82Ü\82·\82©?");
1392 #endif
1393             if (yn(qbuf) == 'y') {
1394                 if (!rn2(3)) {
1395 #if 0 /*JP*/
1396                     actn = "manage to squeeze";
1397 #else
1398                     actn = "\82È\82ñ\82Æ\82©";
1399 #endif
1400 #if 0 /*JP*/
1401                     losehp(Maybe_Half_Phys(rnd(4)),
1402                            "contusion from a small passage", KILLED_BY);
1403 #else
1404                     losehp(Maybe_Half_Phys(rnd(4)),
1405                            "\8b·\82¢\93¹\82Å\82Ì\91Å\82¿\90g\82Å", KILLED_BY);
1406 #endif
1407                 } else {
1408 /*JP
1409                     You("were unable to fit %s.", down_or_thru);
1410 */
1411                     You("\92Ê\82è\94²\82¯\82ç\82ê\82È\82¢\81D");
1412                     return 0;
1413                 }
1414             } else {
1415                 return 0;
1416             }
1417         }
1418 #if 0 /*JP:T*/
1419         You("%s %s the %s.", actn, down_or_thru,
1420             trap->ttyp == HOLE ? "hole" : "trap door");
1421 #else
1422         You("%s%s\81D", actn,
1423             trap->ttyp == HOLE ? "\8c\8a\82ð\8d~\82è\82½" : "\97\8e\82µ\94à\82ð\92Ê\82è\94²\82¯\82½");
1424 #endif
1425     }
1426     if (trap && Is_stronghold(&u.uz)) {
1427         goto_hell(FALSE, TRUE);
1428     } else {
1429         at_ladder = (boolean) (levl[u.ux][u.uy].typ == LADDER);
1430         next_level(!trap);
1431         at_ladder = FALSE;
1432     }
1433     return 1;
1434 }
1435
1436 /* the '<' command */
1437 int
1438 doup()
1439 {
1440     if (u_rooted())
1441         return 1;
1442
1443     /* "up" to get out of a pit... */
1444     if (u.utrap && u.utraptype == TT_PIT) {
1445         climb_pit();
1446         return 1;
1447     }
1448
1449     if ((u.ux != xupstair || u.uy != yupstair)
1450         && (!xupladder || u.ux != xupladder || u.uy != yupladder)
1451         && (!sstairs.sx || u.ux != sstairs.sx || u.uy != sstairs.sy
1452             || !sstairs.up)) {
1453 /*JP
1454         You_cant("go up here.");
1455 */
1456         You("\82±\82±\82Å\82Í\8fã\82é\82±\82Æ\82ª\82Å\82«\82È\82¢\81D");
1457         return 0;
1458     }
1459     if (stucksteed(TRUE)) {
1460         return 0;
1461     }
1462     if (u.ustuck) {
1463 #if 0 /*JP:T*/
1464         You("are %s, and cannot go up.",
1465             !u.uswallow ? "being held" : is_animal(u.ustuck->data)
1466                                              ? "swallowed"
1467                                              : "engulfed");
1468 #else
1469         You("%s\8fã\82é\82±\82Æ\82ª\82Å\82«\82È\82¢\81D",
1470             !u.uswallow ? "\82Â\82©\82Ü\82¦\82ç\82ê\82Ä\82¢\82Ä" : is_animal(u.ustuck->data)
1471                                                      ? "\88ù\82Ý\8d\9e\82Ü\82ê\82Ä\82¢\82Ä"
1472                                                      : "\8aª\82«\8d\9e\82Ü\82ê\82Ä\82¢\82Ä");
1473 #endif
1474         return 1;
1475     }
1476     if (near_capacity() > SLT_ENCUMBER) {
1477         /* No levitation check; inv_weight() already allows for it */
1478 #if 0 /*JP:T*/
1479         Your("load is too heavy to climb the %s.",
1480              levl[u.ux][u.uy].typ == STAIRS ? "stairs" : "ladder");
1481 #else
1482         You("\95¨\82ð\8e\9d\82¿\82·\82¬\82Ä%s\82ð\8fã\82é\82±\82Æ\82ª\82Å\82«\82È\82¢\81D",
1483             levl[u.ux][u.uy].typ == STAIRS ? "\8aK\92i" : "\82Í\82µ\82²");
1484 #endif
1485         return 1;
1486     }
1487     if (ledger_no(&u.uz) == 1) {
1488         if (iflags.debug_fuzzer)
1489             return 0;
1490 /*JP
1491         if (yn("Beware, there will be no return!  Still climb?") != 'y')
1492 */
1493         if (yn("\8bC\82ð\82Â\82¯\82ë\81C\96ß\82ê\82È\82¢\82¼\81I\82»\82ê\82Å\82à\8fã\82é\81H") != 'y')
1494             return 0;
1495     }
1496     if (!next_to_u()) {
1497 /*JP
1498         You("are held back by your pet!");
1499 */
1500         You("\83y\83b\83g\82É\88ø\82«\82à\82Ç\82³\82ê\82½\81I");
1501         return 0;
1502     }
1503     at_ladder = (boolean) (levl[u.ux][u.uy].typ == LADDER);
1504     prev_level(TRUE);
1505     at_ladder = FALSE;
1506     return 1;
1507 }
1508
1509 d_level save_dlevel = { 0, 0 };
1510
1511 /* check that we can write out the current level */
1512 STATIC_OVL int
1513 currentlevel_rewrite()
1514 {
1515     register int fd;
1516     char whynot[BUFSZ];
1517
1518     /* since level change might be a bit slow, flush any buffered screen
1519      *  output (like "you fall through a trap door") */
1520     mark_synch();
1521
1522     fd = create_levelfile(ledger_no(&u.uz), whynot);
1523     if (fd < 0) {
1524         /*
1525          * This is not quite impossible: e.g., we may have
1526          * exceeded our quota. If that is the case then we
1527          * cannot leave this level, and cannot save either.
1528          * Another possibility is that the directory was not
1529          * writable.
1530          */
1531         pline1(whynot);
1532         return -1;
1533     }
1534
1535 #ifdef MFLOPPY
1536     if (!savelev(fd, ledger_no(&u.uz), COUNT_SAVE)) {
1537         (void) nhclose(fd);
1538         delete_levelfile(ledger_no(&u.uz));
1539 /*JP
1540         pline("NetHack is out of disk space for making levels!");
1541 */
1542         pline("\90V\82µ\82¢\83\8c\83x\83\8b\82ð\8dì\82é\82½\82ß\82Ì\83f\83B\83X\83N\97e\97Ê\82ª\91«\82è\82È\82¢\81I");
1543 /*JP
1544         You("can save, quit, or continue playing.");
1545 */
1546         You("\83Z\81[\83u\82·\82é\82©\8fI\97¹\82·\82é\82©\81C\82 \82é\82¢\82Í\83v\83\8c\83C\82ð\91±\8ds\82Å\82«\82é\81D");
1547         return -1;
1548     }
1549 #endif
1550     return fd;
1551 }
1552
1553 #ifdef INSURANCE
1554 void
1555 save_currentstate()
1556 {
1557     int fd;
1558
1559     if (flags.ins_chkpt) {
1560         /* write out just-attained level, with pets and everything */
1561         fd = currentlevel_rewrite();
1562         if (fd < 0)
1563             return;
1564         bufon(fd);
1565         savelev(fd, ledger_no(&u.uz), WRITE_SAVE);
1566         bclose(fd);
1567     }
1568
1569     /* write out non-level state */
1570     savestateinlock();
1571 }
1572 #endif
1573
1574 /*
1575 static boolean
1576 badspot(x, y)
1577 register xchar x, y;
1578 {
1579     return (boolean) ((levl[x][y].typ != ROOM
1580                        && levl[x][y].typ != AIR
1581                        && levl[x][y].typ != CORR)
1582                       || MON_AT(x, y));
1583 }
1584 */
1585
1586 /* when arriving on a level, if hero and a monster are trying to share same
1587    spot, move one; extracted from goto_level(); also used by wiz_makemap() */
1588 void
1589 u_collide_m(mtmp)
1590 struct monst *mtmp;
1591 {
1592     coord cc;
1593
1594     if (!mtmp || mtmp == u.usteed || mtmp != m_at(u.ux, u.uy)) {
1595         impossible("level arrival collision: %s?",
1596                    !mtmp ? "no monster"
1597                      : (mtmp == u.usteed) ? "steed is on map"
1598                        : "monster not co-located");
1599         return;
1600     }
1601
1602     /* There's a monster at your target destination; it might be one
1603        which accompanied you--see mon_arrive(dogmove.c)--or perhaps
1604        it was already here.  Randomly move you to an adjacent spot
1605        or else the monster to any nearby location.  Prior to 3.3.0
1606        the latter was done unconditionally. */
1607     if (!rn2(2) && enexto(&cc, u.ux, u.uy, youmonst.data)
1608         && distu(cc.x, cc.y) <= 2)
1609         u_on_newpos(cc.x, cc.y); /*[maybe give message here?]*/
1610     else
1611         mnexto(mtmp);
1612
1613     if ((mtmp = m_at(u.ux, u.uy)) != 0) {
1614         /* there was an unconditional impossible("mnexto failed")
1615            here, but it's not impossible and we're prepared to cope
1616            with the situation, so only say something when debugging */
1617         if (wizard)
1618             pline("(monster in hero's way)");
1619         if (!rloc(mtmp, TRUE) || (mtmp = m_at(u.ux, u.uy)) != 0)
1620             /* no room to move it; send it away, to return later */
1621             m_into_limbo(mtmp);
1622     }
1623 }
1624
1625 void
1626 goto_level(newlevel, at_stairs, falling, portal)
1627 d_level *newlevel;
1628 boolean at_stairs, falling, portal;
1629 {
1630     int fd, l_idx;
1631     xchar new_ledger;
1632     boolean cant_go_back, great_effort,
1633             up = (depth(newlevel) < depth(&u.uz)),
1634             newdungeon = (u.uz.dnum != newlevel->dnum),
1635             was_in_W_tower = In_W_tower(u.ux, u.uy, &u.uz),
1636             familiar = FALSE,
1637             new = FALSE; /* made a new level? */
1638     struct monst *mtmp;
1639     char whynot[BUFSZ];
1640     char *annotation;
1641
1642     if (dunlev(newlevel) > dunlevs_in_dungeon(newlevel))
1643         newlevel->dlevel = dunlevs_in_dungeon(newlevel);
1644     if (newdungeon && In_endgame(newlevel)) { /* 1st Endgame Level !!! */
1645         if (!u.uhave.amulet)
1646             return;  /* must have the Amulet */
1647         if (!wizard) /* wizard ^V can bypass Earth level */
1648             assign_level(newlevel, &earth_level); /* (redundant) */
1649     }
1650     new_ledger = ledger_no(newlevel);
1651     if (new_ledger <= 0)
1652         done(ESCAPED); /* in fact < 0 is impossible */
1653
1654     /* If you have the amulet and are trying to get out of Gehennom,
1655      * going up a set of stairs sometimes does some very strange things!
1656      * Biased against law and towards chaos.  (The chance to be sent
1657      * down multiple levels when attempting to go up are significantly
1658      * less than the corresponding comment in older versions indicated
1659      * due to overlooking the effect of the call to assign_rnd_lvl().)
1660      *
1661      * Odds for making it to the next level up, or of being sent down:
1662      *  "up"    L      N      C
1663      *   +1   75.0   75.0   75.0
1664      *    0    6.25   8.33  12.5
1665      *   -1   11.46  12.50  12.5
1666      *   -2    5.21   4.17   0.0
1667      *   -3    2.08   0.0    0.0
1668      */
1669     if (Inhell && up && u.uhave.amulet && !newdungeon && !portal
1670         && (dunlev(&u.uz) < dunlevs_in_dungeon(&u.uz) - 3)) {
1671         if (!rn2(4)) {
1672             int odds = 3 + (int) u.ualign.type,   /* 2..4 */
1673                 diff = odds <= 1 ? 0 : rn2(odds); /* paranoia */
1674
1675             if (diff != 0) {
1676                 assign_rnd_level(newlevel, &u.uz, diff);
1677                 /* if inside the tower, stay inside */
1678                 if (was_in_W_tower && !On_W_tower_level(newlevel))
1679                     diff = 0;
1680             }
1681             if (diff == 0)
1682                 assign_level(newlevel, &u.uz);
1683
1684             new_ledger = ledger_no(newlevel);
1685
1686 /*JP
1687             pline("A mysterious force momentarily surrounds you...");
1688 */
1689             pline("\88ê\8fu\8aï\96­\82È\97Í\82ª\82 \82È\82½\82ð\95ï\82ñ\82¾\81D\81D\81D");
1690             if (on_level(newlevel, &u.uz)) {
1691                 (void) safe_teleds(FALSE);
1692                 (void) next_to_u();
1693                 return;
1694             } else
1695                 at_stairs = at_ladder = FALSE;
1696         }
1697     }
1698
1699     /* Prevent the player from going past the first quest level unless
1700      * (s)he has been given the go-ahead by the leader.
1701      */
1702     if (on_level(&u.uz, &qstart_level) && !newdungeon && !ok_to_quest()) {
1703 /*JP
1704         pline("A mysterious force prevents you from descending.");
1705 */
1706         pline("\8aï\96­\82È\97Í\82ª\82 \82È\82½\82ª\8d~\82è\82é\82Ì\82ð\96W\82°\82½\81D");
1707         return;
1708     }
1709
1710     if (on_level(newlevel, &u.uz))
1711         return; /* this can happen */
1712
1713     /* tethered movement makes level change while trapped feasible */
1714     if (u.utrap && u.utraptype == TT_BURIEDBALL)
1715         buried_ball_to_punishment(); /* (before we save/leave old level) */
1716
1717     fd = currentlevel_rewrite();
1718     if (fd < 0)
1719         return;
1720
1721     /* discard context which applies to the level we're leaving;
1722        for lock-picking, container may be carried, in which case we
1723        keep context; if on the floor, it's about to be saved+freed and
1724        maybe_reset_pick() needs to do its carried() check before that */
1725     maybe_reset_pick((struct obj *) 0);
1726     reset_trapset(); /* even if to-be-armed trap obj is accompanying hero */
1727     iflags.travelcc.x = iflags.travelcc.y = 0; /* travel destination cache */
1728     context.polearm.hitmon = (struct monst *) 0; /* polearm target */
1729     /* digging context is level-aware and can actually be resumed if
1730        hero returns to the previous level without any intervening dig */
1731
1732     if (falling) /* assuming this is only trap door or hole */
1733         impact_drop((struct obj *) 0, u.ux, u.uy, newlevel->dlevel);
1734
1735     check_special_room(TRUE); /* probably was a trap door */
1736     if (Punished)
1737         unplacebc();
1738     reset_utrap(FALSE); /* needed in level_tele */
1739     fill_pit(u.ux, u.uy);
1740     u.ustuck = 0; /* idem */
1741     u.uinwater = 0;
1742     u.uundetected = 0; /* not hidden, even if means are available */
1743     keepdogs(FALSE);
1744     if (u.uswallow) /* idem */
1745         u.uswldtim = u.uswallow = 0;
1746     recalc_mapseen(); /* recalculate map overview before we leave the level */
1747     /*
1748      *  We no longer see anything on the level.  Make sure that this
1749      *  follows u.uswallow set to null since uswallow overrides all
1750      *  normal vision.
1751      */
1752     vision_recalc(2);
1753
1754     /*
1755      * Save the level we're leaving.  If we're entering the endgame,
1756      * we can get rid of all existing levels because they cannot be
1757      * reached any more.  We still need to use savelev()'s cleanup
1758      * for the level being left, to recover dynamic memory in use and
1759      * to avoid dangling timers and light sources.
1760      */
1761     cant_go_back = (newdungeon && In_endgame(newlevel));
1762     if (!cant_go_back) {
1763         update_mlstmv(); /* current monsters are becoming inactive */
1764         bufon(fd);       /* use buffered output */
1765     }
1766     savelev(fd, ledger_no(&u.uz),
1767             cant_go_back ? FREE_SAVE : (WRITE_SAVE | FREE_SAVE));
1768     /* air bubbles and clouds are saved in game-state rather than with the
1769        level they're used on; in normal play, you can't leave and return
1770        to any endgame level--bubbles aren't needed once you move to the
1771        next level so used to be discarded when the next special level was
1772        loaded; but in wizard mode you can leave and return, and since they
1773        aren't saved with the level and restored upon return (new ones are
1774        created instead), we need to discard them to avoid a memory leak;
1775        so bubbles are now discarded as we leave the level they're used on */
1776     if (Is_waterlevel(&u.uz) || Is_airlevel(&u.uz))
1777         save_waterlevel(-1, FREE_SAVE);
1778     bclose(fd);
1779     if (cant_go_back) {
1780         /* discard unreachable levels; keep #0 */
1781         for (l_idx = maxledgerno(); l_idx > 0; --l_idx)
1782             delete_levelfile(l_idx);
1783         /* mark #overview data for all dungeon branches as uninteresting */
1784         for (l_idx = 0; l_idx < n_dgns; ++l_idx)
1785             remdun_mapseen(l_idx);
1786     }
1787
1788     if (Is_rogue_level(newlevel) || Is_rogue_level(&u.uz))
1789         assign_graphics(Is_rogue_level(newlevel) ? ROGUESET : PRIMARY);
1790 #ifdef USE_TILES
1791     substitute_tiles(newlevel);
1792 #endif
1793     check_gold_symbol();
1794     /* record this level transition as a potential seen branch unless using
1795      * some non-standard means of transportation (level teleport).
1796      */
1797     if ((at_stairs || falling || portal) && (u.uz.dnum != newlevel->dnum))
1798         recbranch_mapseen(&u.uz, newlevel);
1799     assign_level(&u.uz0, &u.uz);
1800     assign_level(&u.uz, newlevel);
1801     assign_level(&u.utolev, newlevel);
1802     u.utotype = 0;
1803     if (!builds_up(&u.uz)) { /* usual case */
1804         if (dunlev(&u.uz) > dunlev_reached(&u.uz))
1805             dunlev_reached(&u.uz) = dunlev(&u.uz);
1806     } else {
1807         if (dunlev_reached(&u.uz) == 0
1808             || dunlev(&u.uz) < dunlev_reached(&u.uz))
1809             dunlev_reached(&u.uz) = dunlev(&u.uz);
1810     }
1811     reset_rndmonst(NON_PM); /* u.uz change affects monster generation */
1812
1813     /* set default level change destination areas */
1814     /* the special level code may override these */
1815     (void) memset((genericptr_t) &updest, 0, sizeof updest);
1816     (void) memset((genericptr_t) &dndest, 0, sizeof dndest);
1817
1818     if (!(level_info[new_ledger].flags & LFILE_EXISTS)) {
1819         /* entering this level for first time; make it now */
1820         if (level_info[new_ledger].flags & (FORGOTTEN | VISITED)) {
1821             impossible("goto_level: returning to discarded level?");
1822             level_info[new_ledger].flags &= ~(FORGOTTEN | VISITED);
1823         }
1824         mklev();
1825         new = TRUE; /* made the level */
1826     } else {
1827         /* returning to previously visited level; reload it */
1828         fd = open_levelfile(new_ledger, whynot);
1829         if (tricked_fileremoved(fd, whynot)) {
1830             /* we'll reach here if running in wizard mode */
1831             error("Cannot continue this game.");
1832         }
1833         reseed_random(rn2);
1834         reseed_random(rn2_on_display_rng);
1835         minit(); /* ZEROCOMP */
1836         getlev(fd, hackpid, new_ledger, FALSE);
1837         /* when in wizard mode, it is possible to leave from and return to
1838            any level in the endgame; above, we discarded bubble/cloud info
1839            when leaving Plane of Water or Air so recreate some now */
1840         if (Is_waterlevel(&u.uz) || Is_airlevel(&u.uz))
1841             restore_waterlevel(-1);
1842         (void) nhclose(fd);
1843         oinit(); /* reassign level dependent obj probabilities */
1844     }
1845     reglyph_darkroom();
1846     u.uinwater = 0;
1847     /* do this prior to level-change pline messages */
1848     vision_reset();         /* clear old level's line-of-sight */
1849     vision_full_recalc = 0; /* don't let that reenable vision yet */
1850     flush_screen(-1);       /* ensure all map flushes are postponed */
1851
1852     if (portal && !In_endgame(&u.uz)) {
1853         /* find the portal on the new level */
1854         register struct trap *ttrap;
1855
1856         for (ttrap = ftrap; ttrap; ttrap = ttrap->ntrap)
1857             if (ttrap->ttyp == MAGIC_PORTAL)
1858                 break;
1859
1860         if (!ttrap)
1861             panic("goto_level: no corresponding portal!");
1862         seetrap(ttrap);
1863         u_on_newpos(ttrap->tx, ttrap->ty);
1864     } else if (at_stairs && !In_endgame(&u.uz)) {
1865         if (up) {
1866             if (at_ladder)
1867                 u_on_newpos(xdnladder, ydnladder);
1868             else if (newdungeon)
1869                 u_on_sstairs(1);
1870             else
1871                 u_on_dnstairs();
1872             /* you climb up the {stairs|ladder};
1873                fly up the stairs; fly up along the ladder */
1874             great_effort = (Punished && !Levitation);
1875             if (flags.verbose || great_effort)
1876 #if 0 /*JP*/
1877                 pline("%s %s up%s the %s.",
1878                       great_effort ? "With great effort, you" : "You",
1879                       Levitation ? "float" : Flying ? "fly" : "climb",
1880                       (Flying && at_ladder) ? " along" : "",
1881                       at_ladder ? "ladder" : "stairs");
1882 #else /* \94ò\82ñ\82¾\82è\82µ\82Ä\82¢\82Ä\82à\81u\8fã\82Á\82½\81v */
1883                 pline("%s%s\82ð\8fã\82Á\82½\81D",
1884                       great_effort ? "\82â\82Á\82Æ\82±\82³" : "",
1885                       at_ladder ? "\82Í\82µ\82²" : "\8aK\92i");
1886 #endif
1887         } else { /* down */
1888             if (at_ladder)
1889                 u_on_newpos(xupladder, yupladder);
1890             else if (newdungeon)
1891                 u_on_sstairs(0);
1892             else
1893                 u_on_upstairs();
1894             if (!u.dz) {
1895                 ; /* stayed on same level? (no transit effects) */
1896             } else if (Flying) {
1897                 if (flags.verbose)
1898 #if 0 /*JP:T*/
1899                     You("fly down %s.",
1900                         at_ladder ? "along the ladder" : "the stairs");
1901 #else
1902                     You("%s\94ò\82ñ\82Å\8d~\82è\82½\81D",
1903                         at_ladder ? "\82Í\82µ\82²\82É\89\88\82Á\82Ä" : "\8aK\92i\82ð");
1904 #endif
1905             } else if (near_capacity() > UNENCUMBERED
1906                        || Punished || Fumbling) {
1907 /*JP
1908                 You("fall down the %s.", at_ladder ? "ladder" : "stairs");
1909 */
1910                 You("%s\82ð\93]\82°\97\8e\82¿\82½\81D", at_ladder ? "\82Í\82µ\82²" : "\8aK\92i");
1911                 if (Punished) {
1912                     drag_down();
1913                     ballrelease(FALSE);
1914                 }
1915                 /* falling off steed has its own losehp() call */
1916                 if (u.usteed)
1917                     dismount_steed(DISMOUNT_FELL);
1918                 else
1919                     losehp(Maybe_Half_Phys(rnd(3)),
1920 /*JP
1921                            at_ladder ? "falling off a ladder"
1922 */
1923                            at_ladder ? "\82Í\82µ\82²\82©\82ç\97\8e\82¿\82Ä"
1924 /*JP
1925                                      : "tumbling down a flight of stairs",
1926 */
1927                                      : "\8aK\92i\82ð\93]\82°\97\8e\82¿\82Ä",
1928                            KILLED_BY);
1929 /*JP
1930                 selftouch("Falling, you");
1931 */
1932                 selftouch("\97\8e\82¿\82È\82ª\82ç\81C\82 \82È\82½\82Í");
1933             } else { /* ordinary descent */
1934                 if (flags.verbose)
1935 #if 0 /*JP:T*/
1936                     You("%s.", at_ladder ? "climb down the ladder"
1937                                          : "descend the stairs");
1938 #else
1939                     You("%s\82ð\8d~\82è\82½\81D", at_ladder ? "\82Í\82µ\82²"
1940                                                   : "\8aK\92i");
1941 #endif
1942             }
1943         }
1944     } else { /* trap door or level_tele or In_endgame */
1945         u_on_rndspot((up ? 1 : 0) | (was_in_W_tower ? 2 : 0));
1946         if (falling) {
1947             if (Punished)
1948                 ballfall();
1949 /*JP
1950             selftouch("Falling, you");
1951 */
1952             selftouch("\97\8e\82¿\82È\82ª\82ç\81C\82 \82È\82½\82Í");
1953         }
1954     }
1955
1956     if (Punished)
1957         placebc();
1958     obj_delivery(FALSE);
1959     losedogs();
1960     kill_genocided_monsters(); /* for those wiped out while in limbo */
1961     /*
1962      * Expire all timers that have gone off while away.  Must be
1963      * after migrating monsters and objects are delivered
1964      * (losedogs and obj_delivery).
1965      */
1966     run_timers();
1967
1968     /* hero might be arriving at a spot containing a monster;
1969        if so, move one or the other to another location */
1970     if ((mtmp = m_at(u.ux, u.uy)) != 0)
1971         u_collide_m(mtmp);
1972
1973     initrack();
1974
1975     /* initial movement of bubbles just before vision_recalc */
1976     if (Is_waterlevel(&u.uz) || Is_airlevel(&u.uz))
1977         movebubbles();
1978     else if (Is_firelevel(&u.uz))
1979         fumaroles();
1980
1981     if (level_info[new_ledger].flags & FORGOTTEN) {
1982         forget_map(ALL_MAP); /* forget the map */
1983         forget_traps();      /* forget all traps too */
1984         familiar = TRUE;
1985         level_info[new_ledger].flags &= ~FORGOTTEN;
1986     }
1987
1988     /* Reset the screen. */
1989     vision_reset(); /* reset the blockages */
1990     docrt();        /* does a full vision recalc */
1991     flush_screen(-1);
1992
1993     /*
1994      *  Move all plines beyond the screen reset.
1995      */
1996
1997     /* special levels can have a custom arrival message */
1998     deliver_splev_message();
1999
2000     /* give room entrance message, if any */
2001     check_special_room(FALSE);
2002
2003     /* deliver objects traveling with player */
2004     obj_delivery(TRUE);
2005
2006     /* Check whether we just entered Gehennom. */
2007     if (!In_hell(&u.uz0) && Inhell) {
2008         if (Is_valley(&u.uz)) {
2009 /*JP
2010             You("arrive at the Valley of the Dead...");
2011 */
2012             You("\8e\80\82Ì\92J\82É\93\9e\92B\82µ\82½\81D\81D\81D");
2013 /*JP
2014             pline_The("odor of burnt flesh and decay pervades the air.");
2015 */
2016             pline("\8fÅ\82°\82é\8e\80\93÷\82â\95\85\93÷\82Ì\88«\8fL\82ª\82½\82¾\82æ\82Á\82Ä\82¢\82é\81D");
2017 #ifdef MICRO
2018             display_nhwindow(WIN_MESSAGE, FALSE);
2019 #endif
2020 /*JP
2021             You_hear("groans and moans everywhere.");
2022 */
2023             You_hear("\82»\82±\82©\82µ\82±\82©\82ç\82Ì\82¤\82ß\82«\90º\82â\82¤\82È\82è\90º\82ð\95·\82¢\82½\81D");
2024         } else
2025 /*JP
2026             pline("It is hot here.  You smell smoke...");
2027 */
2028             pline("\82±\82±\82Í\8f\8b\82¢\81D\89\8c\82Ì\93õ\82¢\82ª\82·\82é\81D\81D\81D");
2029         u.uachieve.enter_gehennom = 1;
2030     }
2031     /* in case we've managed to bypass the Valley's stairway down */
2032     if (Inhell && !Is_valley(&u.uz))
2033         u.uevent.gehennom_entered = 1;
2034
2035     if (familiar) {
2036         static const char *const fam_msgs[4] = {
2037 /*JP
2038             "You have a sense of deja vu.",
2039 */
2040             "\8aù\8e\8b\8a´\82É\82¨\82»\82í\82ê\82½\81D",
2041 /*JP
2042             "You feel like you've been here before.",
2043 */
2044             "\91O\82É\82±\82±\82É\97\88\82½\82±\82Æ\82ª\82 \82é\82æ\82¤\82È\8bC\82ª\82µ\82½\81D",
2045 #if 0 /*JP:T*/
2046             "This place %s familiar...", 0 /* no message */
2047 #else
2048             "\82±\82Ì\8fê\8f\8a\82Í\89ù\82©\82µ\82¢\81D\81D\81D", 0 /* no message */
2049 #endif
2050         };
2051         static const char *const halu_fam_msgs[4] = {
2052 /*JP
2053             "Whoa!  Everything %s different.",
2054 */
2055             "\83I\83\8f\83b\81I\82Ü\82Á\82½\82­\95Ï\82í\82Á\82¿\82Ü\82Á\82Ä\82é\81D",
2056 /*JP
2057             "You are surrounded by twisty little passages, all alike.",
2058 */
2059             "\82 \82È\82½\82Í\82Ü\82ª\82è\82­\82Ë\82Á\82½\92Ê\98H\82É\82©\82±\82Ü\82ê\82Ä\82¢\82½\81D\81D\81D",
2060 #if 0 /*JP:T*/
2061             "Gee, this %s like uncle Conan's place...", 0 /* no message */
2062 #else
2063             "\83Q\81[\81I\83R\83i\83\93\82¨\82\82³\82ñ\82Ì\8fê\8f\8a\82É\8e\97\82Ä\82¢\82é\81D\81D\81D", 0 /* no message */
2064 #endif
2065         };
2066         const char *mesg;
2067 #if 0 /*JP*/
2068         char buf[BUFSZ];
2069 #endif
2070         int which = rn2(4);
2071
2072         if (Hallucination)
2073             mesg = halu_fam_msgs[which];
2074         else
2075             mesg = fam_msgs[which];
2076 #if 0 /*JP:\93ú\96{\8cê\82Å\82Í\82»\82±\82Ü\82Å\82µ\82È\82¢*/
2077         if (mesg && index(mesg, '%')) {
2078             Sprintf(buf, mesg, !Blind ? "looks" : "seems");
2079             mesg = buf;
2080         }
2081 #endif
2082         if (mesg)
2083             pline1(mesg);
2084     }
2085
2086     /* special location arrival messages/events */
2087     if (In_endgame(&u.uz)) {
2088         if (new &&on_level(&u.uz, &astral_level))
2089             final_level(); /* guardian angel,&c */
2090         else if (newdungeon && u.uhave.amulet)
2091             resurrect(); /* force confrontation with Wizard */
2092     } else if (In_quest(&u.uz)) {
2093         onquest(); /* might be reaching locate|goal level */
2094     } else if (In_V_tower(&u.uz)) {
2095         if (newdungeon && In_hell(&u.uz0))
2096 /*JP
2097             pline_The("heat and smoke are gone.");
2098 */
2099             pline("\94M\82Æ\89\8c\82è\82Í\8fÁ\82¦\82³\82Á\82½\81D");
2100     } else if (Is_knox(&u.uz)) {
2101         /* alarm stops working once Croesus has died */
2102         if (new || !mvitals[PM_CROESUS].died) {
2103 /*JP
2104             You("have penetrated a high security area!");
2105 */
2106             You("\8dÅ\8d\82\8b@\96§\82Ì\8fê\8f\8a\82Ö\93¥\82Ý\8d\9e\82ñ\82¾\81I");
2107 /*JP
2108             pline("An alarm sounds!");
2109 */
2110             pline("\8cx\95ñ\82ª\82È\82Á\82½\81I");
2111             for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
2112                 if (DEADMONSTER(mtmp))
2113                     continue;
2114                 mtmp->msleeping = 0;
2115             }
2116         }
2117     } else {
2118         if (new && Is_rogue_level(&u.uz))
2119 /*JP
2120             You("enter what seems to be an older, more primitive world.");
2121 */
2122             You("\8cÃ\82­\82³\82­\81C\82¸\82¢\82Ô\82ñ\92P\8f\83\82È\90¢\8aE\82É\8c©\82¦\82é\95\94\89®\82É\93ü\82Á\82½\81D");
2123         /* main dungeon message from your quest leader */
2124 /*JP
2125         if (!In_quest(&u.uz0) && at_dgn_entrance("The Quest")
2126 */
2127         if (!In_quest(&u.uz0) && at_dgn_entrance("\83N\83G\83X\83g")
2128             && !(u.uevent.qcompleted || u.uevent.qexpelled
2129                  || quest_status.leader_is_dead)) {
2130             if (!u.uevent.qcalled) {
2131                 u.uevent.qcalled = 1;
2132                 com_pager(2); /* main "leader needs help" message */
2133             } else {          /* reminder message */
2134                 com_pager(Role_if(PM_ROGUE) ? 4 : 3);
2135             }
2136         }
2137     }
2138
2139     assign_level(&u.uz0, &u.uz); /* reset u.uz0 */
2140 #ifdef INSURANCE
2141     save_currentstate();
2142 #endif
2143
2144     if ((annotation = get_annotation(&u.uz)) != 0)
2145 /*JP
2146         You("remember this level as %s.", annotation);
2147 */
2148         You("\82±\82Ì\8aK\82ª%s\82Å\82 \82é\82±\82Æ\82ð\8ev\82¢\8fo\82µ\82½\81D", annotation);
2149
2150     /* assume this will always return TRUE when changing level */
2151     (void) in_out_region(u.ux, u.uy);
2152     (void) pickup(1);
2153 }
2154
2155 STATIC_OVL void
2156 final_level()
2157 {
2158     struct monst *mtmp;
2159
2160     /* reset monster hostility relative to player */
2161     for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
2162         if (DEADMONSTER(mtmp))
2163             continue;
2164         reset_hostility(mtmp);
2165     }
2166
2167     /* create some player-monsters */
2168     create_mplayers(rn1(4, 3), TRUE);
2169
2170     /* create a guardian angel next to player, if worthy */
2171     gain_guardian_angel();
2172 }
2173
2174 static char *dfr_pre_msg = 0,  /* pline() before level change */
2175             *dfr_post_msg = 0; /* pline() after level change */
2176
2177 /* change levels at the end of this turn, after monsters finish moving */
2178 void
2179 schedule_goto(tolev, at_stairs, falling, portal_flag, pre_msg, post_msg)
2180 d_level *tolev;
2181 boolean at_stairs, falling;
2182 int portal_flag;
2183 const char *pre_msg, *post_msg;
2184 {
2185     int typmask = 0100; /* non-zero triggers `deferred_goto' */
2186
2187     /* destination flags (`goto_level' args) */
2188     if (at_stairs)
2189         typmask |= 1;
2190     if (falling)
2191         typmask |= 2;
2192     if (portal_flag)
2193         typmask |= 4;
2194     if (portal_flag < 0)
2195         typmask |= 0200; /* flag for portal removal */
2196     u.utotype = typmask;
2197     /* destination level */
2198     assign_level(&u.utolev, tolev);
2199
2200     if (pre_msg)
2201         dfr_pre_msg = dupstr(pre_msg);
2202     if (post_msg)
2203         dfr_post_msg = dupstr(post_msg);
2204 }
2205
2206 /* handle something like portal ejection */
2207 void
2208 deferred_goto()
2209 {
2210     if (!on_level(&u.uz, &u.utolev)) {
2211         d_level dest;
2212         int typmask = u.utotype; /* save it; goto_level zeroes u.utotype */
2213
2214         assign_level(&dest, &u.utolev);
2215         if (dfr_pre_msg)
2216             pline1(dfr_pre_msg);
2217         goto_level(&dest, !!(typmask & 1), !!(typmask & 2), !!(typmask & 4));
2218         if (typmask & 0200) { /* remove portal */
2219             struct trap *t = t_at(u.ux, u.uy);
2220
2221             if (t) {
2222                 deltrap(t);
2223                 newsym(u.ux, u.uy);
2224             }
2225         }
2226         if (dfr_post_msg)
2227             pline1(dfr_post_msg);
2228     }
2229     u.utotype = 0; /* our caller keys off of this */
2230     if (dfr_pre_msg)
2231         free((genericptr_t) dfr_pre_msg), dfr_pre_msg = 0;
2232     if (dfr_post_msg)
2233         free((genericptr_t) dfr_post_msg), dfr_post_msg = 0;
2234 }
2235
2236 /*
2237  * Return TRUE if we created a monster for the corpse.  If successful, the
2238  * corpse is gone.
2239  */
2240 boolean
2241 revive_corpse(corpse)
2242 struct obj *corpse;
2243 {
2244     struct monst *mtmp, *mcarry;
2245     boolean is_uwep, chewed;
2246     xchar where;
2247     char cname[BUFSZ];
2248     struct obj *container = (struct obj *) 0;
2249     int container_where = 0;
2250
2251     where = corpse->where;
2252     is_uwep = (corpse == uwep);
2253     chewed = (corpse->oeaten != 0);
2254 #if 0 /*JP:T*/
2255     Strcpy(cname, corpse_xname(corpse,
2256                                chewed ? "bite-covered" : (const char *) 0,
2257                                CXN_SINGULAR));
2258 #else
2259     Strcpy(cname, corpse_xname(corpse,
2260                                chewed ? "\8e\95\8c^\82Ì\82Â\82¢\82½" : (const char *) 0,
2261                                CXN_SINGULAR));
2262 #endif
2263     mcarry = (where == OBJ_MINVENT) ? corpse->ocarry : 0;
2264
2265     if (where == OBJ_CONTAINED) {
2266         struct monst *mtmp2;
2267
2268         container = corpse->ocontainer;
2269         mtmp2 = get_container_location(container, &container_where, (int *) 0);
2270         /* container_where is the outermost container's location even if
2271          * nested */
2272         if (container_where == OBJ_MINVENT && mtmp2)
2273             mcarry = mtmp2;
2274     }
2275     mtmp = revive(corpse, FALSE); /* corpse is gone if successful */
2276
2277     if (mtmp) {
2278         switch (where) {
2279         case OBJ_INVENT:
2280             if (is_uwep)
2281 /*JP
2282                 pline_The("%s writhes out of your grasp!", cname);
2283 */
2284                 pline_The("%s\82Í\82à\82ª\82¢\82½\81I", cname);
2285             else
2286 /*JP
2287                 You_feel("squirming in your backpack!");
2288 */
2289                 pline("\94w\95\89\82¢\91Ü\82Å\89½\82©\82ª\82à\82ª\82¢\82Ä\82¢\82é\82æ\82¤\82È\8bC\82ª\82µ\82½\81I");
2290             break;
2291
2292         case OBJ_FLOOR:
2293             if (cansee(mtmp->mx, mtmp->my))
2294 #if 0 /*JP:T*/
2295                 pline("%s rises from the dead!",
2296                       chewed ? Adjmonnam(mtmp, "bite-covered")
2297                              : Monnam(mtmp));
2298 #else
2299                 pline("%s\82ª\91h\82Á\82½\81I",
2300                       chewed ? Adjmonnam(mtmp, "\8e\95\8c^\82Ì\82Â\82¢\82½")
2301                              : Monnam(mtmp));
2302 #endif
2303             break;
2304
2305         case OBJ_MINVENT: /* probably a nymph's */
2306             if (cansee(mtmp->mx, mtmp->my)) {
2307                 if (canseemon(mcarry))
2308 #if 0 /*JP:T*/
2309                     pline("Startled, %s drops %s as it revives!",
2310                           mon_nam(mcarry), an(cname));
2311 #else
2312                     pline("%s\82ª\90\82«\82©\82¦\82Á\82½\82Ì\82É\82Ñ\82Á\82­\82è\82µ\82Ä\81C%s\82Í%s\82ð\97\8e\82µ\82½\81I",
2313                           cname, mon_nam(mcarry), cname);
2314 #endif
2315                 else
2316 #if 0 /*JP:T*/
2317                     pline("%s suddenly appears!",
2318                           chewed ? Adjmonnam(mtmp, "bite-covered")
2319                                  : Monnam(mtmp));
2320 #else
2321                     pline("%s\82ª\93Ë\91R\8c»\82í\82ê\82½\81I",
2322                           chewed ? Adjmonnam(mtmp, "\8e\95\8c^\82Ì\82Â\82¢\82½")
2323                                  : Monnam(mtmp));
2324 #endif
2325             }
2326             break;
2327         case OBJ_CONTAINED: {
2328             char sackname[BUFSZ];
2329
2330             if (container_where == OBJ_MINVENT && cansee(mtmp->mx, mtmp->my)
2331                 && mcarry && canseemon(mcarry) && container) {
2332 /*JP
2333                 pline("%s writhes out of %s!", Amonnam(mtmp),
2334 */
2335                 pline("%s\82Í%s\82©\82ç\93¦\82ê\82æ\82¤\82Æ\82à\82ª\82¢\82½\81I", Amonnam(mtmp),
2336                       yname(container));
2337             } else if (container_where == OBJ_INVENT && container) {
2338                 Strcpy(sackname, an(xname(container)));
2339 #if 0 /*JP:T*/
2340                 pline("%s %s out of %s in your pack!",
2341                       Blind ? Something : Amonnam(mtmp),
2342                       locomotion(mtmp->data, "writhes"), sackname);
2343 #else
2344                 pline("%s\82Í\91Ü\82Ì\92\86\82Å%s\82©\82ç\93¦\82ê\82æ\82¤\82Æ\82à\82ª\82¢\82½\81I",
2345                       Blind ? Something : Amonnam(mtmp),
2346                       sackname);
2347 #endif
2348             } else if (container_where == OBJ_FLOOR && container
2349                        && cansee(mtmp->mx, mtmp->my)) {
2350                 Strcpy(sackname, an(xname(container)));
2351 /*JP
2352                 pline("%s escapes from %s!", Amonnam(mtmp), sackname);
2353 */
2354                 pline("%s\82Í%s\82©\82ç\93¦\82ê\82½\81I", Amonnam(mtmp), sackname);
2355             }
2356             break;
2357         }
2358         default:
2359             /* we should be able to handle the other cases... */
2360             impossible("revive_corpse: lost corpse @ %d", where);
2361             break;
2362         }
2363         return TRUE;
2364     }
2365     return FALSE;
2366 }
2367
2368 /* Revive the corpse via a timeout. */
2369 /*ARGSUSED*/
2370 void
2371 revive_mon(arg, timeout)
2372 anything *arg;
2373 long timeout UNUSED;
2374 {
2375     struct obj *body = arg->a_obj;
2376     struct permonst *mptr = &mons[body->corpsenm];
2377     struct monst *mtmp;
2378     xchar x, y;
2379
2380     /* corpse will revive somewhere else if there is a monster in the way;
2381        Riders get a chance to try to bump the obstacle out of their way */
2382     if ((mptr->mflags3 & M3_DISPLACES) != 0 && body->where == OBJ_FLOOR
2383         && get_obj_location(body, &x, &y, 0) && (mtmp = m_at(x, y)) != 0) {
2384         boolean notice_it = canseemon(mtmp); /* before rloc() */
2385         char *monname = Monnam(mtmp);
2386
2387         if (rloc(mtmp, TRUE)) {
2388             if (notice_it && !canseemon(mtmp))
2389 /*JP
2390                 pline("%s vanishes.", monname);
2391 */
2392                 pline("%s\82Í\8fÁ\82¦\82½\81D", monname);
2393             else if (!notice_it && canseemon(mtmp))
2394 #if 0 /*JP:T*/
2395                 pline("%s appears.", Monnam(mtmp)); /* not pre-rloc monname */
2396 #else
2397                 pline("%s\82ª\8c»\82ê\82½\81D", Monnam(mtmp)); /* not pre-rloc monname */
2398 #endif
2399             else if (notice_it && dist2(mtmp->mx, mtmp->my, x, y) > 2)
2400 #if 0 /*JP:T*/
2401                 pline("%s teleports.", monname); /* saw it and still see it */
2402 #else
2403                 pline("%s\82Í\8fu\8aÔ\88Ú\93®\82µ\82½\81D", monname); /* saw it and still see it */
2404 #endif
2405         }
2406     }
2407
2408     /* if we succeed, the corpse is gone */
2409     if (!revive_corpse(body)) {
2410         long when;
2411         int action;
2412
2413         if (is_rider(mptr) && rn2(99)) { /* Rider usually tries again */
2414             action = REVIVE_MON;
2415             for (when = 3L; when < 67L; when++)
2416                 if (!rn2(3))
2417                     break;
2418         } else { /* rot this corpse away */
2419 /*JP
2420             You_feel("%sless hassled.", is_rider(mptr) ? "much " : "");
2421 */
2422             You("\94Y\82Ý\8e\96\82ª%s\8c¸\82Á\82½\8bC\82ª\82µ\82½\81D", is_rider(mptr) ? "\82Æ\82Ä\82à" : "");
2423             action = ROT_CORPSE;
2424             when = 250L - (monstermoves - body->age);
2425             if (when < 1L)
2426                 when = 1L;
2427         }
2428         (void) start_timer(when, TIMER_OBJECT, action, arg);
2429     }
2430 }
2431
2432 int
2433 donull()
2434 {
2435     return 1; /* Do nothing, but let other things happen */
2436 }
2437
2438 STATIC_PTR int
2439 wipeoff(VOID_ARGS)
2440 {
2441     if (u.ucreamed < 4)
2442         u.ucreamed = 0;
2443     else
2444         u.ucreamed -= 4;
2445     if (Blinded < 4)
2446         Blinded = 0;
2447     else
2448         Blinded -= 4;
2449     if (!Blinded) {
2450 /*JP
2451         pline("You've got the glop off.");
2452 */
2453         You("%s\82©\82ç\83l\83o\83l\83o\82ª\82Æ\82ê\82½\81D", body_part(FACE));
2454         u.ucreamed = 0;
2455         if (!gulp_blnd_check()) {
2456             Blinded = 1;
2457             make_blinded(0L, TRUE);
2458         }
2459         return 0;
2460     } else if (!u.ucreamed) {
2461 /*JP
2462         Your("%s feels clean now.", body_part(FACE));
2463 */
2464         Your("%s\82Í\82«\82ê\82¢\82É\82È\82Á\82½\81D", body_part(FACE));
2465         return 0;
2466     }
2467     return 1; /* still busy */
2468 }
2469
2470 int
2471 dowipe()
2472 {
2473     if (u.ucreamed) {
2474         static NEARDATA char buf[39];
2475
2476 /*JP
2477         Sprintf(buf, "wiping off your %s", body_part(FACE));
2478 */
2479         Sprintf(buf, "%s\82ð\90@\82¢\82Ä\82¢\82é", body_part(FACE));
2480         set_occupation(wipeoff, buf, 0);
2481         /* Not totally correct; what if they change back after now
2482          * but before they're finished wiping?
2483          */
2484         return 1;
2485     }
2486 /*JP
2487     Your("%s is already clean.", body_part(FACE));
2488 */
2489     Your("%s\82Í\89\98\82ê\82Ä\82¢\82È\82¢\81D", body_part(FACE));
2490     return 1;
2491 }
2492
2493 void
2494 set_wounded_legs(side, timex)
2495 register long side;
2496 register int timex;
2497 {
2498     /* KMH -- STEED
2499      * If you are riding, your steed gets the wounded legs instead.
2500      * You still call this function, but don't lose hp.
2501      * Caller is also responsible for adjusting messages.
2502      */
2503
2504     if (!Wounded_legs) {
2505         ATEMP(A_DEX)--;
2506         context.botl = 1;
2507     }
2508
2509     if (!Wounded_legs || (HWounded_legs & TIMEOUT))
2510         HWounded_legs = timex;
2511     EWounded_legs = side;
2512     (void) encumber_msg();
2513 }
2514
2515 void
2516 heal_legs(how)
2517 int how; /* 0: ordinary, 1: dismounting steed, 2: limbs turn to stone */
2518 {
2519     if (Wounded_legs) {
2520         if (ATEMP(A_DEX) < 0) {
2521             ATEMP(A_DEX)++;
2522             context.botl = 1;
2523         }
2524
2525         /* when mounted, wounded legs applies to the steed;
2526            during petrification countdown, "your limbs turn to stone"
2527            before the final stages and that calls us (how==2) to cure
2528            wounded legs, but we want to suppress the feel better message */
2529         if (!u.usteed && how != 2) {
2530 #if 0 /*JP:T*/
2531             const char *legs = body_part(LEG);
2532
2533             if ((EWounded_legs & BOTH_SIDES) == BOTH_SIDES)
2534                 legs = makeplural(legs);
2535             /* this used to say "somewhat better" but that was
2536                misleading since legs are being fully healed */
2537             Your("%s %s better.", legs, vtense(legs, "feel"));
2538 #else
2539             Your("%s\82Í\89ñ\95\9c\82µ\82½\81D", body_part(LEG));
2540 #endif
2541         }
2542
2543         HWounded_legs = EWounded_legs = 0L;
2544
2545         /* Wounded_legs reduces carrying capacity, so we want
2546            an encumbrance check when they're healed.  However,
2547            while dismounting, first steed's legs get healed,
2548            then hero is dropped to floor and a new encumbrance
2549            check is made [in dismount_steed()].  So don't give
2550            encumbrance feedback during the dismount stage
2551            because it could seem to be shown out of order and
2552            it might be immediately contradicted [able to carry
2553            more when steed becomes healthy, then possible floor
2554            feedback, then able to carry less when back on foot]. */
2555         if (how == 0)
2556             (void) encumber_msg();
2557     }
2558 }
2559
2560 /*do.c*/