OSDN Git Service

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