OSDN Git Service

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