OSDN Git Service

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