OSDN Git Service

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