OSDN Git Service

add translation
[jnethack/source.git] / src / dig.c
1 /* NetHack 3.6  dig.c   $NHDT-Date: 1449269915 2015/12/04 22:58:35 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.103 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed.  See license for details. */
4
5 /* JNetHack Copyright */
6 /* (c) Issei Numata, Naoki Hamada, Shigehiro Miyashita, 1994-2000  */
7 /* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2016            */
8 /* JNetHack may be freely redistributed.  See license for details. */
9
10 #include "hack.h"
11
12 static NEARDATA boolean did_dig_msg;
13
14 STATIC_DCL boolean NDECL(rm_waslit);
15 STATIC_DCL void FDECL(mkcavepos,
16                       (XCHAR_P, XCHAR_P, int, BOOLEAN_P, BOOLEAN_P));
17 STATIC_DCL void FDECL(mkcavearea, (BOOLEAN_P));
18 STATIC_DCL int NDECL(dig);
19 STATIC_DCL void FDECL(dig_up_grave, (coord *));
20 STATIC_DCL int FDECL(adj_pit_checks, (coord *, char *));
21 STATIC_DCL void FDECL(pit_flow, (struct trap *, SCHAR_P));
22
23 /* Indices returned by dig_typ() */
24 #define DIGTYP_UNDIGGABLE 0
25 #define DIGTYP_ROCK 1
26 #define DIGTYP_STATUE 2
27 #define DIGTYP_BOULDER 3
28 #define DIGTYP_DOOR 4
29 #define DIGTYP_TREE 5
30
31 STATIC_OVL boolean
32 rm_waslit()
33 {
34     register xchar x, y;
35
36     if (levl[u.ux][u.uy].typ == ROOM && levl[u.ux][u.uy].waslit)
37         return TRUE;
38     for (x = u.ux - 2; x < u.ux + 3; x++)
39         for (y = u.uy - 1; y < u.uy + 2; y++)
40             if (isok(x, y) && levl[x][y].waslit)
41                 return TRUE;
42     return FALSE;
43 }
44
45 /* Change level topology.  Messes with vision tables and ignores things like
46  * boulders in the name of a nice effect.  Vision will get fixed up again
47  * immediately after the effect is complete.
48  */
49 STATIC_OVL void
50 mkcavepos(x, y, dist, waslit, rockit)
51 xchar x, y;
52 int dist;
53 boolean waslit, rockit;
54 {
55     register struct rm *lev;
56
57     if (!isok(x, y))
58         return;
59     lev = &levl[x][y];
60
61     if (rockit) {
62         register struct monst *mtmp;
63
64         if (IS_ROCK(lev->typ))
65             return;
66         if (t_at(x, y))
67             return;                   /* don't cover the portal */
68         if ((mtmp = m_at(x, y)) != 0) /* make sure crucial monsters survive */
69             if (!passes_walls(mtmp->data))
70                 (void) rloc(mtmp, TRUE);
71     } else if (lev->typ == ROOM)
72         return;
73
74     unblock_point(x, y); /* make sure vision knows this location is open */
75
76     /* fake out saved state */
77     lev->seenv = 0;
78     lev->doormask = 0;
79     if (dist < 3)
80         lev->lit = (rockit ? FALSE : TRUE);
81     if (waslit)
82         lev->waslit = (rockit ? FALSE : TRUE);
83     lev->horizontal = FALSE;
84     /* short-circuit vision recalc */
85     viz_array[y][x] = (dist < 3) ? (IN_SIGHT | COULD_SEE) : COULD_SEE;
86     lev->typ = (rockit ? STONE : ROOM);
87     if (dist >= 3)
88         impossible("mkcavepos called with dist %d", dist);
89     feel_newsym(x, y);
90 }
91
92 STATIC_OVL void
93 mkcavearea(rockit)
94 register boolean rockit;
95 {
96     int dist;
97     xchar xmin = u.ux, xmax = u.ux;
98     xchar ymin = u.uy, ymax = u.uy;
99     register xchar i;
100     register boolean waslit = rm_waslit();
101
102     if (rockit)
103 /*JP
104         pline("Crash!  The ceiling collapses around you!");
105 */
106         pline("\82°\82°\82ñ\81I\82 \82È\82½\82Ì\82Ü\82í\82è\82Ì\93V\88ä\82ª\95ö\82ê\82½\81I");
107     else
108 #if 0 /*JP*/
109         pline("A mysterious force %s cave around you!",
110               (levl[u.ux][u.uy].typ == CORR) ? "creates a" : "extends the");
111 #else
112         pline("\90_\94é\93I\82È\97Í\82É\82æ\82è\82 \82È\82½\82Ì\82Ü\82í\82è%s\82½\81I",
113               (levl[u.ux][u.uy].typ == CORR) ? "\82É\93´\8cA\82ª\82Å\82«" : "\82Ì\93´\8cA\82ª\8dL\82ª\82Á");
114 #endif
115     display_nhwindow(WIN_MESSAGE, TRUE);
116
117     for (dist = 1; dist <= 2; dist++) {
118         xmin--;
119         xmax++;
120
121         /* top and bottom */
122         if (dist < 2) { /* the area is wider that it is high */
123             ymin--;
124             ymax++;
125             for (i = xmin + 1; i < xmax; i++) {
126                 mkcavepos(i, ymin, dist, waslit, rockit);
127                 mkcavepos(i, ymax, dist, waslit, rockit);
128             }
129         }
130
131         /* left and right */
132         for (i = ymin; i <= ymax; i++) {
133             mkcavepos(xmin, i, dist, waslit, rockit);
134             mkcavepos(xmax, i, dist, waslit, rockit);
135         }
136
137         flush_screen(1); /* make sure the new glyphs shows up */
138         delay_output();
139     }
140
141     if (!rockit && levl[u.ux][u.uy].typ == CORR) {
142         levl[u.ux][u.uy].typ = ROOM;
143         if (waslit)
144             levl[u.ux][u.uy].waslit = TRUE;
145         newsym(u.ux, u.uy); /* in case player is invisible */
146     }
147
148     vision_full_recalc = 1; /* everything changed */
149 }
150
151 /* When digging into location <x,y>, what are you actually digging into? */
152 int
153 dig_typ(otmp, x, y)
154 struct obj *otmp;
155 xchar x, y;
156 {
157     boolean ispick;
158
159     if (!otmp)
160         return DIGTYP_UNDIGGABLE;
161     ispick = is_pick(otmp);
162     if (!ispick && !is_axe(otmp))
163         return DIGTYP_UNDIGGABLE;
164
165     return ((ispick && sobj_at(STATUE, x, y))
166                ? DIGTYP_STATUE
167                : (ispick && sobj_at(BOULDER, x, y))
168                   ? DIGTYP_BOULDER
169                   : closed_door(x, y)
170                      ? DIGTYP_DOOR
171                      : IS_TREE(levl[x][y].typ)
172                         ? (ispick ? DIGTYP_UNDIGGABLE : DIGTYP_TREE)
173                         : (ispick && IS_ROCK(levl[x][y].typ)
174                            && (!level.flags.arboreal
175                                || IS_WALL(levl[x][y].typ)))
176                            ? DIGTYP_ROCK
177                            : DIGTYP_UNDIGGABLE);
178 }
179
180 boolean
181 is_digging()
182 {
183     if (occupation == dig) {
184         return TRUE;
185     }
186     return FALSE;
187 }
188
189 #define BY_YOU (&youmonst)
190 #define BY_OBJECT ((struct monst *) 0)
191
192 boolean
193 dig_check(madeby, verbose, x, y)
194 struct monst *madeby;
195 boolean verbose;
196 int x, y;
197 {
198     struct trap *ttmp = t_at(x, y);
199     const char *verb =
200 /*JP
201         (madeby == BY_YOU && uwep && is_axe(uwep)) ? "chop" : "dig in";
202 */
203         (madeby == BY_YOU && uwep && is_axe(uwep)) ? "\8dÓ\82¯\82È\82¢" : "\8c@\82ê\82È\82¢";
204
205     if (On_stairs(x, y)) {
206         if (x == xdnladder || x == xupladder) {
207             if (verbose)
208 /*JP
209                 pline_The("ladder resists your effort.");
210 */
211                 pline("\82Í\82µ\82²\82ª\8e×\96\82\82ð\82µ\82½\81D");
212         } else if (verbose)
213 /*JP
214             pline_The("stairs are too hard to %s.", verb);
215 */
216             pline("\8aK\92i\82Í\82Æ\82Ä\82à\8cÅ\82­\82Ä%s\81D", verb);
217         return FALSE;
218     } else if (IS_THRONE(levl[x][y].typ) && madeby != BY_OBJECT) {
219         if (verbose)
220 /*JP
221             pline_The("throne is too hard to break apart.");
222 */
223             pline("\8bÊ\8dÀ\82Í\82Æ\82Ä\82à\8cÅ\82­\82Ä\8dÓ\82¯\82È\82¢\81D");
224         return FALSE;
225     } else if (IS_ALTAR(levl[x][y].typ)
226                && (madeby != BY_OBJECT || Is_astralevel(&u.uz)
227                    || Is_sanctum(&u.uz))) {
228         if (verbose)
229 /*JP
230             pline_The("altar is too hard to break apart.");
231 */
232             pline_The("\8dÕ\92d\82Í\82Æ\82Ä\82à\8cÅ\82­\82Ä\8dÓ\82¯\82È\82¢\81D");
233         return FALSE;
234     } else if (Is_airlevel(&u.uz)) {
235         if (verbose)
236 /*JP
237             You("cannot %s thin air.", verb);
238 */
239             You("\89½\82à\82È\82¢\8bó\8aÔ\82Í%s\81D", verb);
240         return FALSE;
241     } else if (Is_waterlevel(&u.uz)) {
242         if (verbose)
243 /*JP
244             pline_The("water splashes and subsides.");
245 */
246             pline("\90\85\82ª\83s\83V\83\83\83b\82Æ\92µ\82Ë\82½\81D");
247         return FALSE;
248     } else if ((IS_ROCK(levl[x][y].typ) && levl[x][y].typ != SDOOR
249                 && (levl[x][y].wall_info & W_NONDIGGABLE) != 0)
250                || (ttmp
251                    && (ttmp->ttyp == MAGIC_PORTAL
252                        || ttmp->ttyp == VIBRATING_SQUARE
253                        || (!Can_dig_down(&u.uz) && !levl[x][y].candig)))) {
254         if (verbose)
255 /*JP
256             pline_The("%s here is too hard to %s.", surface(x, y), verb);
257 */
258             pline_The("%s\82Í\82Æ\82Ä\82à\8cÅ\82­\82Ä%s\81D", surface(x,y), verb);
259         return FALSE;
260     } else if (sobj_at(BOULDER, x, y)) {
261         if (verbose)
262 /*JP
263             There("isn't enough room to %s here.", verb);
264 */
265             pline("\8f\\95ª\82È\8fê\8f\8a\82ª\82È\82¢\82Ì\82Å%s\81D", verb);
266         return FALSE;
267     } else if (madeby == BY_OBJECT
268                /* the block against existing traps is mainly to
269                   prevent broken wands from turning holes into pits */
270                && (ttmp || is_pool_or_lava(x, y))) {
271         /* digging by player handles pools separately */
272         return FALSE;
273     }
274     return TRUE;
275 }
276
277 STATIC_OVL int
278 dig(VOID_ARGS)
279 {
280     register struct rm *lev;
281     register xchar dpx = context.digging.pos.x, dpy = context.digging.pos.y;
282     register boolean ispick = uwep && is_pick(uwep);
283 /*JP
284     const char *verb = (!uwep || is_pick(uwep)) ? "dig into" : "chop through";
285 */
286     const char *verb = (!uwep || is_pick(uwep)) ? "\8c@\82ê\82È\82¢" : "\8dÓ\82¯\82È\82¢";
287
288     lev = &levl[dpx][dpy];
289     /* perhaps a nymph stole your pick-axe while you were busy digging */
290     /* or perhaps you teleported away */
291     if (u.uswallow || !uwep || (!ispick && !is_axe(uwep))
292         || !on_level(&context.digging.level, &u.uz)
293         || ((context.digging.down ? (dpx != u.ux || dpy != u.uy)
294                                   : (distu(dpx, dpy) > 2))))
295         return 0;
296
297     if (context.digging.down) {
298         if (!dig_check(BY_YOU, TRUE, u.ux, u.uy))
299             return 0;
300     } else { /* !context.digging.down */
301         if (IS_TREE(lev->typ) && !may_dig(dpx, dpy)
302             && dig_typ(uwep, dpx, dpy) == DIGTYP_TREE) {
303 /*JP
304             pline("This tree seems to be petrified.");
305 */
306             pline("\82±\82Ì\96Ø\82Í\90Î\89»\82µ\82Ä\82¢\82é\82æ\82¤\82¾\81D");
307             return 0;
308         }
309         if (IS_ROCK(lev->typ) && !may_dig(dpx, dpy)
310             && dig_typ(uwep, dpx, dpy) == DIGTYP_ROCK) {
311 #if 0 /*JP*/
312             pline("This %s is too hard to %s.",
313                   is_db_wall(dpx, dpy) ? "drawbridge" : "wall", verb);
314 #else
315             pline("\82±\82Ì%s\82Í\82Æ\82Ä\82à\8cÅ\82­\82Ä%s\81D",
316                   is_db_wall(dpx, dpy) ? "\92µ\82Ë\8b´" : "\95Ç", verb);
317 #endif
318             return 0;
319         }
320     }
321     if (Fumbling && !rn2(3)) {
322         switch (rn2(3)) {
323         case 0:
324             if (!welded(uwep)) {
325 /*JP
326                 You("fumble and drop %s.", yname(uwep));
327 */
328                 You("\8eè\82ª\8a\8a\82è%s\82ð\97\8e\82µ\82½\81D", yname(uwep));
329                 dropx(uwep);
330             } else {
331                 if (u.usteed)
332 #if 0 /*JP:T*/
333                     pline("%s and %s %s!", Yobjnam2(uwep, "bounce"),
334                           otense(uwep, "hit"), mon_nam(u.usteed));
335 #else
336                     pline("%s\82Í\92µ\82Ë\82©\82¦\82è%s\82É\96½\92\86\82µ\82½\81I",
337                           xname(uwep), mon_nam(u.usteed));
338 #endif
339                 else
340 #if 0 /*JP:T*/
341                     pline("Ouch!  %s and %s you!", Yobjnam2(uwep, "bounce"),
342                           otense(uwep, "hit"));
343 #else
344                     pline("\82¢\82Ä\82Á\81I%s\82Í\92µ\82Ë\82©\82¦\82è\82 \82È\82½\82É\96½\92\86\82µ\82½\81I",
345                           xname(uwep));
346 #endif
347                 set_wounded_legs(RIGHT_SIDE, 5 + rnd(5));
348             }
349             break;
350         case 1:
351 /*JP
352             pline("Bang!  You hit with the broad side of %s!",
353 */
354             pline("\83o\83\93\81I%s\82Ì\95¿\82Å\91Å\82Á\82Ä\82µ\82Ü\82Á\82½\81I",
355                   the(xname(uwep)));
356             break;
357         default:
358 /*JP
359             Your("swing misses its mark.");
360 */
361             You("\91_\82¢\82ð\92è\82ß\82Ä\90U\82è\82¨\82ë\82µ\82½\82ª\82Í\82¸\82µ\82½\81D");
362             break;
363         }
364         return 0;
365     }
366
367     context.digging.effort +=
368         10 + rn2(5) + abon() + uwep->spe - greatest_erosion(uwep) + u.udaminc;
369     if (Race_if(PM_DWARF))
370         context.digging.effort *= 2;
371     if (context.digging.down) {
372         struct trap *ttmp = t_at(dpx, dpy);
373
374         if (context.digging.effort > 250 || (ttmp && ttmp->ttyp == HOLE)) {
375             (void) dighole(FALSE, FALSE, (coord *) 0);
376             (void) memset((genericptr_t) &context.digging, 0,
377                           sizeof context.digging);
378             return 0; /* done with digging */
379         }
380
381         if (context.digging.effort <= 50
382             || (ttmp && (ttmp->ttyp == TRAPDOOR || ttmp->ttyp == PIT
383                          || ttmp->ttyp == SPIKED_PIT))) {
384             return 1;
385         } else if (ttmp && (ttmp->ttyp == LANDMINE
386                             || (ttmp->ttyp == BEAR_TRAP && !u.utrap))) {
387             /* digging onto a set object trap triggers it;
388                hero should have used #untrap first */
389             dotrap(ttmp, FORCETRAP);
390             /* restart completely from scratch if we resume digging */
391             (void) memset((genericptr_t) &context.digging, 0,
392                           sizeof context.digging);
393             return 0;
394         } else if (ttmp && ttmp->ttyp == BEAR_TRAP && u.utrap) {
395             if (rnl(7) > (Fumbling ? 1 : 4)) {
396                 char kbuf[BUFSZ];
397                 int dmg = dmgval(uwep, &youmonst) + dbon();
398
399                 if (dmg < 1)
400                     dmg = 1;
401                 else if (uarmf)
402                     dmg = (dmg + 1) / 2;
403 /*JP
404                 You("hit yourself in the %s.", body_part(FOOT));
405 */
406                 pline("%s\82É\93\96\82½\82Á\82½\81D", body_part(FOOT));
407 #if 0 /*JP*/
408                 Sprintf(kbuf, "chopping off %s own %s", uhis(),
409                         body_part(FOOT));
410 #else
411                 Sprintf(kbuf, "\8e©\95ª\82Ì%s\82ð\90Ø\82è\97\8e\82Æ\82µ\82Ä", body_part(FOOT));
412 #endif
413                 losehp(Maybe_Half_Phys(dmg), kbuf, KILLED_BY);
414             } else {
415 #if 0 /*JP*/
416                 You("destroy the bear trap with %s.",
417                     yobjnam(uwep, (const char *) 0));
418 #else
419                 You("%s\82Å\8cF\82Ìã©\82ð\89ó\82µ\82½\81D", xname(uwep));
420 #endif
421                 u.utrap = 0; /* release from trap */
422                 deltrap(ttmp);
423             }
424             /* we haven't made any progress toward a pit yet */
425             context.digging.effort = 0;
426             return 0;
427         }
428
429         if (IS_ALTAR(lev->typ)) {
430             altar_wrath(dpx, dpy);
431             angry_priest();
432         }
433
434         /* make pit at <u.ux,u.uy> */
435         if (dighole(TRUE, FALSE, (coord *) 0)) {
436             context.digging.level.dnum = 0;
437             context.digging.level.dlevel = -1;
438         }
439         return 0;
440     }
441
442     if (context.digging.effort > 100) {
443         register const char *digtxt, *dmgtxt = (const char *) 0;
444         register struct obj *obj;
445         register boolean shopedge = *in_rooms(dpx, dpy, SHOPBASE);
446
447         if ((obj = sobj_at(STATUE, dpx, dpy)) != 0) {
448             if (break_statue(obj))
449 /*JP
450                 digtxt = "The statue shatters.";
451 */
452                 digtxt = "\92¤\91\9c\82Í\82±\82È\82²\82È\82É\82È\82Á\82½\81D";
453             else
454                 /* it was a statue trap; break_statue()
455                  * printed a message and updated the screen
456                  */
457                 digtxt = (char *) 0;
458         } else if ((obj = sobj_at(BOULDER, dpx, dpy)) != 0) {
459             struct obj *bobj;
460
461             fracture_rock(obj);
462             if ((bobj = sobj_at(BOULDER, dpx, dpy)) != 0) {
463                 /* another boulder here, restack it to the top */
464                 obj_extract_self(bobj);
465                 place_object(bobj, dpx, dpy);
466             }
467 /*JP
468             digtxt = "The boulder falls apart.";
469 */
470             digtxt = "\8aâ\82Í\82±\82È\82²\82È\82É\82È\82Á\82½\81D";
471         } else if (lev->typ == STONE || lev->typ == SCORR
472                    || IS_TREE(lev->typ)) {
473             if (Is_earthlevel(&u.uz)) {
474                 if (uwep->blessed && !rn2(3)) {
475                     mkcavearea(FALSE);
476                     goto cleanup;
477                 } else if ((uwep->cursed && !rn2(4))
478                            || (!uwep->blessed && !rn2(6))) {
479                     mkcavearea(TRUE);
480                     goto cleanup;
481                 }
482             }
483             if (IS_TREE(lev->typ)) {
484 /*JP
485                 digtxt = "You cut down the tree.";
486 */
487                 digtxt = "\96Ø\82ð\90Ø\82è\93|\82µ\82½\81D";
488                 lev->typ = ROOM;
489                 if (!rn2(5))
490                     (void) rnd_treefruit_at(dpx, dpy);
491             } else {
492 /*JP
493                 digtxt = "You succeed in cutting away some rock.";
494 */
495                 digtxt = "\8aâ\82ð\8f­\82µ\90Ø\82è\82Æ\82Á\82½\81D";
496                 lev->typ = CORR;
497             }
498         } else if (IS_WALL(lev->typ)) {
499             if (shopedge) {
500                 add_damage(dpx, dpy, 10L * ACURRSTR);
501 /*JP
502                 dmgtxt = "damage";
503 */
504                 dmgtxt = "\8f\9d\82Â\82¯\82é";
505             }
506             if (level.flags.is_maze_lev) {
507                 lev->typ = ROOM;
508             } else if (level.flags.is_cavernous_lev && !in_town(dpx, dpy)) {
509                 lev->typ = CORR;
510             } else {
511                 lev->typ = DOOR;
512                 lev->doormask = D_NODOOR;
513             }
514 /*JP
515             digtxt = "You make an opening in the wall.";
516 */
517             digtxt = "\95Ç\82É\8c\8a\82ð\8bó\82¯\82½\81D";
518         } else if (lev->typ == SDOOR) {
519             cvt_sdoor_to_door(lev); /* ->typ = DOOR */
520 /*JP
521             digtxt = "You break through a secret door!";
522 */
523             digtxt = "\94é\96§\82Ì\94à\82ð\92Ê\82è\94²\82¯\82½\81I";
524             if (!(lev->doormask & D_TRAPPED))
525                 lev->doormask = D_BROKEN;
526         } else if (closed_door(dpx, dpy)) {
527 /*JP
528             digtxt = "You break through the door.";
529 */
530             digtxt = "\94à\82ð\92Ê\82è\94²\82¯\82½\81D";
531             if (shopedge) {
532                 add_damage(dpx, dpy, 400L);
533 /*JP
534                 dmgtxt = "break";
535 */
536                 dmgtxt = "\89ó\82·";
537             }
538             if (!(lev->doormask & D_TRAPPED))
539                 lev->doormask = D_BROKEN;
540         } else
541             return 0; /* statue or boulder got taken */
542
543         if (!does_block(dpx, dpy, &levl[dpx][dpy]))
544             unblock_point(dpx, dpy); /* vision:  can see through */
545         feel_newsym(dpx, dpy);
546         if (digtxt && !context.digging.quiet)
547             pline1(digtxt); /* after newsym */
548         if (dmgtxt)
549             pay_for_damage(dmgtxt, FALSE);
550
551         if (Is_earthlevel(&u.uz) && !rn2(3)) {
552             register struct monst *mtmp;
553
554             switch (rn2(2)) {
555             case 0:
556                 mtmp = makemon(&mons[PM_EARTH_ELEMENTAL], dpx, dpy,
557                                NO_MM_FLAGS);
558                 break;
559             default:
560                 mtmp = makemon(&mons[PM_XORN], dpx, dpy, NO_MM_FLAGS);
561                 break;
562             }
563             if (mtmp)
564 /*JP
565                 pline_The("debris from your digging comes to life!");
566 */
567                 pline("\8aâ\82Ì\94j\95Ð\82ª\90\96½\82ð\91Ñ\82Ñ\82½\81I");
568         }
569         if (IS_DOOR(lev->typ) && (lev->doormask & D_TRAPPED)) {
570             lev->doormask = D_NODOOR;
571 /*JP
572             b_trapped("door", 0);
573 */
574             b_trapped("\94à", 0);
575             newsym(dpx, dpy);
576         }
577     cleanup:
578         context.digging.lastdigtime = moves;
579         context.digging.quiet = FALSE;
580         context.digging.level.dnum = 0;
581         context.digging.level.dlevel = -1;
582         return 0;
583     } else { /* not enough effort has been spent yet */
584 #if 0 /*JP:T*/
585         static const char *const d_target[6] = { "",        "rock", "statue",
586                                                  "boulder", "door", "tree" };
587 #else
588         static const char *const d_target[6] = { "",   "\90Î", "\92¤\91\9c",
589                                                  "\8aâ", "\94à", "\96Ø" };
590 #endif
591         int dig_target = dig_typ(uwep, dpx, dpy);
592
593         if (IS_WALL(lev->typ) || dig_target == DIGTYP_DOOR) {
594             if (*in_rooms(dpx, dpy, SHOPBASE)) {
595 #if 0 /*JP:T*/
596                 pline("This %s seems too hard to %s.",
597                       IS_DOOR(lev->typ) ? "door" : "wall", verb);
598 #else
599                 pline("\82±\82Ì%s\82Í\82Æ\82Ä\82à\8cÅ\82­\82Ä%s\81D",
600                       IS_DOOR(lev->typ) ? "\94à" : "\95Ç", verb);
601 #endif
602                 return 0;
603             }
604         } else if (dig_target == DIGTYP_UNDIGGABLE
605                    || (dig_target == DIGTYP_ROCK && !IS_ROCK(lev->typ)))
606             return 0; /* statue or boulder got taken */
607
608         if (!did_dig_msg) {
609 /*JP
610             You("hit the %s with all your might.", d_target[dig_target]);
611 */
612             You("%s\82ð\97Í\88ê\94t\91Å\82¿\82Â\82¯\82½\81D", d_target[dig_target]);
613             did_dig_msg = TRUE;
614         }
615     }
616     return 1;
617 }
618
619 /* When will hole be finished? Very rough indication used by shopkeeper. */
620 int
621 holetime()
622 {
623     if (occupation != dig || !*u.ushops)
624         return -1;
625     return ((250 - context.digging.effort) / 20);
626 }
627
628 /* Return typ of liquid to fill a hole with, or ROOM, if no liquid nearby */
629 schar
630 fillholetyp(x, y, fill_if_any)
631 int x, y;
632 boolean fill_if_any; /* force filling if it exists at all */
633 {
634     register int x1, y1;
635     int lo_x = max(1, x - 1), hi_x = min(x + 1, COLNO - 1),
636         lo_y = max(0, y - 1), hi_y = min(y + 1, ROWNO - 1);
637     int pool_cnt = 0, moat_cnt = 0, lava_cnt = 0;
638
639     for (x1 = lo_x; x1 <= hi_x; x1++)
640         for (y1 = lo_y; y1 <= hi_y; y1++)
641             if (is_moat(x1, y1))
642                 moat_cnt++;
643             else if (is_pool(x1, y1))
644                 /* This must come after is_moat since moats are pools
645                  * but not vice-versa. */
646                 pool_cnt++;
647             else if (is_lava(x1, y1))
648                 lava_cnt++;
649
650     if (!fill_if_any)
651         pool_cnt /= 3; /* not as much liquid as the others */
652
653     if ((lava_cnt > moat_cnt + pool_cnt && rn2(lava_cnt + 1))
654         || (lava_cnt && fill_if_any))
655         return LAVAPOOL;
656     else if ((moat_cnt > 0 && rn2(moat_cnt + 1)) || (moat_cnt && fill_if_any))
657         return MOAT;
658     else if ((pool_cnt > 0 && rn2(pool_cnt + 1)) || (pool_cnt && fill_if_any))
659         return POOL;
660     else
661         return ROOM;
662 }
663
664 void
665 digactualhole(x, y, madeby, ttyp)
666 register int x, y;
667 struct monst *madeby;
668 int ttyp;
669 {
670     struct obj *oldobjs, *newobjs;
671     register struct trap *ttmp;
672     char surface_type[BUFSZ];
673     struct rm *lev = &levl[x][y];
674     boolean shopdoor;
675     struct monst *mtmp = m_at(x, y); /* may be madeby */
676     boolean madeby_u = (madeby == BY_YOU);
677     boolean madeby_obj = (madeby == BY_OBJECT);
678     boolean at_u = (x == u.ux) && (y == u.uy);
679     boolean wont_fall = Levitation || Flying;
680
681     if (at_u && u.utrap) {
682         if (u.utraptype == TT_BURIEDBALL)
683             buried_ball_to_punishment();
684         else if (u.utraptype == TT_INFLOOR)
685             u.utrap = 0;
686     }
687
688     /* these furniture checks were in dighole(), but wand
689        breaking bypasses that routine and calls us directly */
690     if (IS_FOUNTAIN(lev->typ)) {
691         dogushforth(FALSE);
692         SET_FOUNTAIN_WARNED(x, y); /* force dryup */
693         dryup(x, y, madeby_u);
694         return;
695     } else if (IS_SINK(lev->typ)) {
696         breaksink(x, y);
697         return;
698     } else if (lev->typ == DRAWBRIDGE_DOWN
699                || (is_drawbridge_wall(x, y) >= 0)) {
700         int bx = x, by = y;
701         /* if under the portcullis, the bridge is adjacent */
702         (void) find_drawbridge(&bx, &by);
703         destroy_drawbridge(bx, by);
704         return;
705     }
706
707     if (ttyp != PIT && (!Can_dig_down(&u.uz) && !lev->candig)) {
708         impossible("digactualhole: can't dig %s on this level.",
709                    defsyms[trap_to_defsym(ttyp)].explanation);
710         ttyp = PIT;
711     }
712
713     /* maketrap() might change it, also, in this situation,
714        surface() returns an inappropriate string for a grave */
715     if (IS_GRAVE(lev->typ))
716 /*JP
717         Strcpy(surface_type, "grave");
718 */
719         Strcpy(surface_type, "\95æ");
720     else
721         Strcpy(surface_type, surface(x, y));
722     shopdoor = IS_DOOR(lev->typ) && *in_rooms(x, y, SHOPBASE);
723     oldobjs = level.objects[x][y];
724     ttmp = maketrap(x, y, ttyp);
725     if (!ttmp)
726         return;
727     newobjs = level.objects[x][y];
728     ttmp->madeby_u = madeby_u;
729     ttmp->tseen = 0;
730     if (cansee(x, y))
731         seetrap(ttmp);
732     else if (madeby_u)
733         feeltrap(ttmp);
734
735     if (ttyp == PIT) {
736         if (madeby_u) {
737             if (x != u.ux || y != u.uy)
738                 You("dig an adjacent pit.");
739             else
740 /*JP
741                 You("dig a pit in the %s.", surface_type);
742 */
743                 You("%s\82É\97\8e\82µ\8c\8a\82ð\8c@\82Á\82½\81D", surface_type);
744             if (shopdoor)
745 /*JP
746                 pay_for_damage("ruin", FALSE);
747 */
748                 pay_for_damage("\89ó\82·", FALSE);
749         } else if (!madeby_obj && canseemon(madeby))
750 /*JP
751             pline("%s digs a pit in the %s.", Monnam(madeby), surface_type);
752 */
753             pline("%s\82Í%s\82É\97\8e\82µ\8c\8a\82ð\8c@\82Á\82½\81D", Monnam(madeby), surface_type);
754         else if (cansee(x, y) && flags.verbose)
755 /*JP
756             pline("A pit appears in the %s.", surface_type);
757 */
758             pline("\97\8e\82µ\8c\8a\82ª%s\82É\8c»\82í\82ê\82½\81D", surface_type);
759
760         if (at_u) {
761             if (!wont_fall) {
762                 u.utrap = rn1(4, 2);
763                 u.utraptype = TT_PIT;
764                 vision_full_recalc = 1; /* vision limits change */
765             } else
766                 u.utrap = 0;
767             if (oldobjs != newobjs) /* something unearthed */
768                 (void) pickup(1);   /* detects pit */
769         } else if (mtmp) {
770             if (is_flyer(mtmp->data) || is_floater(mtmp->data)) {
771                 if (canseemon(mtmp))
772 #if 0 /*JP*/
773                     pline("%s %s over the pit.", Monnam(mtmp),
774                           (is_flyer(mtmp->data)) ? "flies" : "floats");
775 #else
776                     pline("%s\82Í%s\97\8e\82µ\8c\8a\82ð\89z\82¦\82½\81D", Monnam(mtmp),
777                           (is_flyer(mtmp->data)) ? "\94ò\82ñ\82Å" : "\95\82\82¢\82Ä");
778 #endif
779             } else if (mtmp != madeby)
780                 (void) mintrap(mtmp);
781         }
782     } else { /* was TRAPDOOR now a HOLE*/
783
784         if (madeby_u)
785 /*JP
786             You("dig a hole through the %s.", surface_type);
787 */
788             You("%s\82É\8c\8a\82ð\8aJ\82¯\82½\81D", surface_type);
789         else if (!madeby_obj && canseemon(madeby))
790 #if 0 /*JP:T*/
791             pline("%s digs a hole through the %s.", Monnam(madeby),
792                   surface_type);
793 #else
794             pline("%s\82Í%s\82É\8c\8a\82ð\8aJ\82¯\82½\81D", Monnam(madeby),
795                   surface_type);
796 #endif
797         else if (cansee(x, y) && flags.verbose)
798 /*JP
799             pline("A hole appears in the %s.", surface_type);
800 */
801             pline("%s\82É\8c\8a\82ª\8c»\82í\82ê\82½\81D", surface_type);
802
803         if (at_u) {
804             if (!u.ustuck && !wont_fall && !next_to_u()) {
805 /*JP
806                 You("are jerked back by your pet!");
807 */
808                 You("\83y\83b\83g\82É\82æ\82Á\82Ä\88ø\82«\96ß\82³\82ê\82½\81I");
809                 wont_fall = TRUE;
810             }
811
812             /* Floor objects get a chance of falling down.  The case where
813              * the hero does NOT fall down is treated here.  The case
814              * where the hero does fall down is treated in goto_level().
815              */
816             if (u.ustuck || wont_fall) {
817                 if (newobjs)
818                     impact_drop((struct obj *) 0, x, y, 0);
819                 if (oldobjs != newobjs)
820                     (void) pickup(1);
821                 if (shopdoor && madeby_u)
822 /*JP
823                     pay_for_damage("ruin", FALSE);
824 */
825                     pay_for_damage("\82ß\82¿\82á\82ß\82¿\82á\82É\82·\82é", FALSE);
826
827             } else {
828                 d_level newlevel;
829
830                 if (*u.ushops && madeby_u)
831                     shopdig(1); /* shk might snatch pack */
832                 /* handle earlier damage, eg breaking wand of digging */
833                 else if (!madeby_u)
834 /*JP
835                     pay_for_damage("dig into", TRUE);
836 */
837                     pay_for_damage("\8c\8a\82ð\82 \82¯\82é", TRUE);
838
839 /*JP
840                 You("fall through...");
841 */
842                 You("\97\8e\82¿\82½\81D\81D\81D");
843                 /* Earlier checks must ensure that the destination
844                  * level exists and is in the present dungeon.
845                  */
846                 newlevel.dnum = u.uz.dnum;
847                 newlevel.dlevel = u.uz.dlevel + 1;
848                 goto_level(&newlevel, FALSE, TRUE, FALSE);
849                 /* messages for arriving in special rooms */
850                 spoteffects(FALSE);
851             }
852         } else {
853             if (shopdoor && madeby_u)
854 /*JP
855                 pay_for_damage("ruin", FALSE);
856 */
857                 pay_for_damage("\82ß\82¿\82á\82ß\82¿\82á\82É\82·\82é", FALSE);
858             if (newobjs)
859                 impact_drop((struct obj *) 0, x, y, 0);
860             if (mtmp) {
861                 /*[don't we need special sokoban handling here?]*/
862                 if (is_flyer(mtmp->data) || is_floater(mtmp->data)
863                     || mtmp->data == &mons[PM_WUMPUS]
864                     || (mtmp->wormno && count_wsegs(mtmp) > 5)
865                     || mtmp->data->msize >= MZ_HUGE)
866                     return;
867                 if (mtmp == u.ustuck) /* probably a vortex */
868                     return;           /* temporary? kludge */
869
870                 if (teleport_pet(mtmp, FALSE)) {
871                     d_level tolevel;
872
873                     if (Is_stronghold(&u.uz)) {
874                         assign_level(&tolevel, &valley_level);
875                     } else if (Is_botlevel(&u.uz)) {
876                         if (canseemon(mtmp))
877 /*JP
878                             pline("%s avoids the trap.", Monnam(mtmp));
879 */
880                             pline("%s\82Íã©\82ð\94ð\82¯\82½\81D", Monnam(mtmp));
881                         return;
882                     } else {
883                         get_level(&tolevel, depth(&u.uz) + 1);
884                     }
885                     if (mtmp->isshk)
886                         make_angry_shk(mtmp, 0, 0);
887                     migrate_to_level(mtmp, ledger_no(&tolevel), MIGR_RANDOM,
888                                      (coord *) 0);
889                 }
890             }
891         }
892     }
893 }
894
895 /*
896  * Called from dighole(), but also from do_break_wand()
897  * in apply.c.
898  */
899 void
900 liquid_flow(x, y, typ, ttmp, fillmsg)
901 xchar x, y;
902 schar typ;
903 struct trap *ttmp;
904 const char *fillmsg;
905 {
906     boolean u_spot = (x == u.ux && y == u.uy);
907
908     if (ttmp)
909         (void) delfloortrap(ttmp);
910     /* if any objects were frozen here, they're released now */
911     unearth_objs(x, y);
912
913     if (fillmsg)
914 /*JP
915         pline(fillmsg, typ == LAVAPOOL ? "lava" : "water");
916 */
917         pline(fillmsg, typ == LAVAPOOL ? "\97n\8aâ" : "\90\85");
918     if (u_spot && !(Levitation || Flying)) {
919         if (typ == LAVAPOOL)
920             (void) lava_effects();
921         else if (!Wwalking)
922             (void) drown();
923     }
924 }
925
926 /* return TRUE if digging succeeded, FALSE otherwise */
927 boolean
928 dighole(pit_only, by_magic, cc)
929 boolean pit_only, by_magic;
930 coord *cc;
931 {
932     register struct trap *ttmp;
933     struct rm *lev;
934     struct obj *boulder_here;
935     schar typ;
936     xchar dig_x, dig_y;
937     boolean nohole;
938
939     if (!cc) {
940         dig_x = u.ux;
941         dig_y = u.uy;
942     } else {
943         dig_x = cc->x;
944         dig_y = cc->y;
945         if (!isok(dig_x, dig_y))
946             return FALSE;
947     }
948
949     ttmp = t_at(dig_x, dig_y);
950     lev = &levl[dig_x][dig_y];
951     nohole = (!Can_dig_down(&u.uz) && !lev->candig);
952
953     if ((ttmp && (ttmp->ttyp == MAGIC_PORTAL
954                   || ttmp->ttyp == VIBRATING_SQUARE || nohole))
955         || (IS_ROCK(lev->typ) && lev->typ != SDOOR
956             && (lev->wall_info & W_NONDIGGABLE) != 0)) {
957 #if 0 /*JP:T*/
958         pline_The("%s %shere is too hard to dig in.", surface(dig_x, dig_y),
959                   (dig_x != u.ux || dig_y != u.uy) ? "t" : "");
960 #else
961         pline("%s\82Í\82Æ\82Ä\82à\8cÅ\82­\82Ä\8c@\82ê\82È\82¢\81D", surface(dig_x, dig_y));
962 #endif
963
964     } else if (is_pool_or_lava(dig_x, dig_y)) {
965 #if 0 /*JP:T*/
966         pline_The("%s sloshes furiously for a moment, then subsides.",
967                   is_lava(dig_x, dig_y) ? "lava" : "water");
968 #else
969         pline("%s\82Í\8c\83\82µ\82­\94g\82¤\82Á\82½\81D",
970                   is_lava(dig_x, dig_y) ? "\97n\8aâ" : "\90\85");
971 #endif
972         wake_nearby(); /* splashing */
973
974     } else if (lev->typ == DRAWBRIDGE_DOWN
975                || (is_drawbridge_wall(dig_x, dig_y) >= 0)) {
976         /* drawbridge_down is the platform crossing the moat when the
977            bridge is extended; drawbridge_wall is the open "doorway" or
978            closed "door" where the portcullis/mechanism is located */
979         if (pit_only) {
980 /*JP
981             pline_The("drawbridge seems too hard to dig through.");
982 */
983             pline("\92µ\82Ë\8b´\82Í\82Æ\82Ä\82à\8cÅ\82­\82Ä\8c@\82ê\82»\82¤\82É\82È\82¢\81D");
984             return FALSE;
985         } else {
986             int x = dig_x, y = dig_y;
987             /* if under the portcullis, the bridge is adjacent */
988             (void) find_drawbridge(&x, &y);
989             destroy_drawbridge(x, y);
990             return TRUE;
991         }
992
993     } else if ((boulder_here = sobj_at(BOULDER, dig_x, dig_y)) != 0) {
994         if (ttmp && (ttmp->ttyp == PIT || ttmp->ttyp == SPIKED_PIT)
995             && rn2(2)) {
996 #if 0 /*JP*/
997             pline_The("boulder settles into the %spit.",
998                       (dig_x != u.ux || dig_y != u.uy) ? "adjacent " : "");
999 #else
1000             pline("\8aâ\82Í%s\97\8e\82µ\8c\8a\82ð\96\84\82ß\82½\81D",
1001                       (dig_x != u.ux || dig_y != u.uy) ? "\97×\82Ì" : "");
1002 #endif
1003             ttmp->ttyp = PIT; /* crush spikes */
1004         } else {
1005             /*
1006              * digging makes a hole, but the boulder immediately
1007              * fills it.  Final outcome:  no hole, no boulder.
1008              */
1009 /*JP
1010             pline("KADOOM! The boulder falls in!");
1011 */
1012             pline("\82Ç\82Ç\81[\82ñ\81I\8aâ\82Í\97\8e\82¿\82½\81I");
1013             (void) delfloortrap(ttmp);
1014         }
1015         delobj(boulder_here);
1016         return TRUE;
1017
1018     } else if (IS_GRAVE(lev->typ)) {
1019         digactualhole(dig_x, dig_y, BY_YOU, PIT);
1020         dig_up_grave(cc);
1021         return TRUE;
1022     } else if (lev->typ == DRAWBRIDGE_UP) {
1023         /* must be floor or ice, other cases handled above */
1024         /* dig "pit" and let fluid flow in (if possible) */
1025         typ = fillholetyp(dig_x, dig_y, FALSE);
1026
1027         if (typ == ROOM) {
1028             /*
1029              * We can't dig a hole here since that will destroy
1030              * the drawbridge.  The following is a cop-out. --dlc
1031              */
1032 #if 0 /*JP*/
1033             pline_The("%s %shere is too hard to dig in.",
1034                       surface(dig_x, dig_y),
1035                       (dig_x != u.ux || dig_y != u.uy) ? "t" : "");
1036 #else
1037             pline("%s\82Í\82Æ\82Ä\82à\8cÅ\82­\82Ä\8c@\82ê\82È\82¢\81D", surface(dig_x, dig_y));
1038 #endif
1039             return FALSE;
1040         }
1041
1042         lev->drawbridgemask &= ~DB_UNDER;
1043         lev->drawbridgemask |= (typ == LAVAPOOL) ? DB_LAVA : DB_MOAT;
1044 #if 0 /*JP:T*/
1045         liquid_flow(dig_x, dig_y, typ, ttmp,
1046                     "As you dig, the hole fills with %s!");
1047 #else
1048         liquid_flow(dig_x, dig_y, typ, ttmp,
1049                     "\82 \82È\82½\82ª\8c@\82é\82Æ\81C%s\82ª\97N\82¢\82Ä\82«\82½\81I");
1050 #endif
1051         return TRUE;
1052
1053         /* the following two are here for the wand of digging */
1054     } else if (IS_THRONE(lev->typ)) {
1055 /*JP
1056         pline_The("throne is too hard to break apart.");
1057 */
1058         pline("\8bÊ\8dÀ\82Í\82Æ\82Ä\82à\8cÅ\82­\82Ä\8dÓ\82¯\82È\82¢\81D");
1059
1060     } else if (IS_ALTAR(lev->typ)) {
1061 /*JP
1062         pline_The("altar is too hard to break apart.");
1063 */
1064         pline("\8dÕ\92d\82Í\82Æ\82Ä\82à\8cÅ\82­\82Ä\8dÓ\82¯\82È\82¢\81D");
1065
1066     } else {
1067         typ = fillholetyp(dig_x, dig_y, FALSE);
1068
1069         if (typ != ROOM) {
1070             lev->typ = typ;
1071 #if 0 /*JP*/
1072             liquid_flow(dig_x, dig_y, typ, ttmp,
1073                         "As you dig, the hole fills with %s!");
1074 #else
1075             liquid_flow(dig_x, dig_y, typ, ttmp,
1076                         "\82 \82È\82½\82ª\8c@\82é\82Æ\81C%s\82ª\97N\82¢\82Ä\82«\82½\81I");
1077 #endif
1078             return TRUE;
1079         }
1080
1081         /* magical digging disarms settable traps */
1082         if (by_magic && ttmp
1083             && (ttmp->ttyp == LANDMINE || ttmp->ttyp == BEAR_TRAP)) {
1084             int otyp = (ttmp->ttyp == LANDMINE) ? LAND_MINE : BEARTRAP;
1085
1086             /* convert trap into buried object (deletes trap) */
1087             cnv_trap_obj(otyp, 1, ttmp, TRUE);
1088         }
1089
1090         /* finally we get to make a hole */
1091         if (nohole || pit_only)
1092             digactualhole(dig_x, dig_y, BY_YOU, PIT);
1093         else
1094             digactualhole(dig_x, dig_y, BY_YOU, HOLE);
1095
1096         return TRUE;
1097     }
1098
1099     return FALSE;
1100 }
1101
1102 STATIC_OVL void
1103 dig_up_grave(cc)
1104 coord *cc;
1105 {
1106     struct obj *otmp;
1107     xchar dig_x, dig_y;
1108
1109     if (!cc) {
1110         dig_x = u.ux;
1111         dig_y = u.uy;
1112     } else {
1113         dig_x = cc->x;
1114         dig_y = cc->y;
1115         if (!isok(dig_x, dig_y))
1116             return;
1117     }
1118
1119     /* Grave-robbing is frowned upon... */
1120     exercise(A_WIS, FALSE);
1121     if (Role_if(PM_ARCHEOLOGIST)) {
1122         adjalign(-sgn(u.ualign.type) * 3);
1123 /*JP
1124         You_feel("like a despicable grave-robber!");
1125 */
1126         pline("\82±\82ê\82Å\82Í\82Ü\82é\82Å\95æ\93D\96_\82¾\81I");
1127     } else if (Role_if(PM_SAMURAI)) {
1128         adjalign(-sgn(u.ualign.type));
1129 /*JP
1130         You("disturb the honorable dead!");
1131 */
1132         You("\96¼\97_\82 \82é\8e\80\8eÒ\82Ì\96°\82è\82ð\96W\82°\82¾\81I");
1133     } else if ((u.ualign.type == A_LAWFUL) && (u.ualign.record > -10)) {
1134         adjalign(-sgn(u.ualign.type));
1135 /*JP
1136         You("have violated the sanctity of this grave!");
1137 */
1138         You("\90¹\82È\82é\95æ\92n\82ð\94Æ\82µ\82½\81I");
1139     }
1140
1141     switch (rn2(5)) {
1142     case 0:
1143     case 1:
1144 /*JP
1145         You("unearth a corpse.");
1146 */
1147         You("\8e\80\91Ì\82ð\8c@\82è\8bN\82µ\82½\81D");
1148         if (!!(otmp = mk_tt_object(CORPSE, dig_x, dig_y)))
1149             otmp->age -= 100; /* this is an *OLD* corpse */
1150         ;
1151         break;
1152     case 2:
1153         if (!Blind)
1154 /*JP
1155             pline(Hallucination ? "Dude!  The living dead!"
1156 */
1157             pline(Hallucination ? "\83]\83\93\83r\82ª\82­\82é\82è\82Æ\97Ö\82ð\95`\82¢\82½\81I"
1158 /*JP
1159                                 : "The grave's owner is very upset!");
1160 */
1161                                 : "\95æ\82Ì\8f\8a\97L\8eÒ\82Í\82Æ\82Ä\82à\8bÁ\82¢\82½\81I");
1162         (void) makemon(mkclass(S_ZOMBIE, 0), dig_x, dig_y, NO_MM_FLAGS);
1163         break;
1164     case 3:
1165         if (!Blind)
1166 /*JP
1167             pline(Hallucination ? "I want my mummy!"
1168 */
1169             pline(Hallucination ? "\83}\83~\81[\82ª\95K\97v\82¾\81I"
1170 /*JP
1171                                 : "You've disturbed a tomb!");
1172 */
1173                                 : "\95æ\82ð\8dr\82µ\82Ä\82µ\82Ü\82Á\82½\81I");
1174         (void) makemon(mkclass(S_MUMMY, 0), dig_x, dig_y, NO_MM_FLAGS);
1175         break;
1176     default:
1177         /* No corpse */
1178 /*JP
1179         pline_The("grave seems unused.  Strange....");
1180 */
1181         pline("\82±\82Ì\95æ\82Í\96¢\8eg\97p\82Ì\82æ\82¤\82¾\81D\8aï\96­\82¾\81D\81D\81D");
1182         break;
1183     }
1184     levl[dig_x][dig_y].typ = ROOM;
1185     del_engr_at(dig_x, dig_y);
1186     newsym(dig_x, dig_y);
1187     return;
1188 }
1189
1190 int
1191 use_pick_axe(obj)
1192 struct obj *obj;
1193 {
1194     const char *sdp, *verb;
1195     char *dsp, dirsyms[12], qbuf[BUFSZ];
1196     boolean ispick;
1197     int rx, ry, downok, res = 0;
1198
1199     /* Check tool */
1200     if (obj != uwep) {
1201         if (!wield_tool(obj, "swing"))
1202             return 0;
1203         else
1204             res = 1;
1205     }
1206     ispick = is_pick(obj);
1207 /*JP
1208     verb = ispick ? "dig" : "chop";
1209 */
1210     verb = ispick ? "\8c@\82é" : "\8dÓ\82­";
1211
1212     if (u.utrap && u.utraptype == TT_WEB) {
1213 #if 0 /*JP:T*/
1214         pline("%s you can't %s while entangled in a web.",
1215               /* res==0 => no prior message;
1216                  res==1 => just got "You now wield a pick-axe." message */
1217               !res ? "Unfortunately," : "But", verb);
1218 #else
1219         pline("%s\82­\82à\82Ì\91\83\82É\82Ð\82Á\82©\82©\82Á\82Ä\82¢\82é\8aÔ\82Í%s\81D",
1220               !res ? "\8ec\94O\82È\82ª\82ç" : "\82µ\82©\82µ", jconj(verb, "\82È\82¢"));
1221 #endif
1222         return res;
1223     }
1224
1225     /* construct list of directions to show player for likely choices */
1226     downok = !!can_reach_floor(FALSE);
1227     dsp = dirsyms;
1228     for (sdp = Cmd.dirchars; *sdp; ++sdp) {
1229         /* filter out useless directions */
1230         if (u.uswallow) {
1231             ; /* all directions are viable when swallowed */
1232         } else if (movecmd(*sdp)) {
1233             /* normal direction, within plane of the level map;
1234                movecmd() sets u.dx, u.dy, u.dz and returns !u.dz */
1235             if (!dxdy_moveok())
1236                 continue; /* handle NODIAG */
1237             rx = u.ux + u.dx;
1238             ry = u.uy + u.dy;
1239             if (!isok(rx, ry) || dig_typ(obj, rx, ry) == DIGTYP_UNDIGGABLE)
1240                 continue;
1241         } else {
1242             /* up or down; we used to always include down, so that
1243                there would always be at least one choice shown, but
1244                it shouldn't be a likely candidate when floating high
1245                above the floor; include up instead in that situation
1246                (as a silly candidate rather than a likely one...) */
1247             if ((u.dz > 0) ^ downok)
1248                 continue;
1249         }
1250         /* include this direction */
1251         *dsp++ = *sdp;
1252     }
1253     *dsp = 0;
1254 /*JP
1255     Sprintf(qbuf, "In what direction do you want to %s? [%s]", verb, dirsyms);
1256 */
1257     Sprintf(qbuf, "\82Ç\82Ì\95û\8cü\82ð%s\81H[%s]", verb, dirsyms);
1258     if (!getdir(qbuf))
1259         return res;
1260
1261     return use_pick_axe2(obj);
1262 }
1263
1264 /* MRKR: use_pick_axe() is split in two to allow autodig to bypass */
1265 /*       the "In what direction do you want to dig?" query.        */
1266 /*       use_pick_axe2() uses the existing u.dx, u.dy and u.dz    */
1267 int
1268 use_pick_axe2(obj)
1269 struct obj *obj;
1270 {
1271     register int rx, ry;
1272     register struct rm *lev;
1273     struct trap *trap, *trap_with_u;
1274     int dig_target;
1275     boolean ispick = is_pick(obj);
1276 /*JP
1277     const char *verbing = ispick ? "digging" : "chopping";
1278 */
1279     const char *verbing = ispick ? "\8c@\82é" : "\8dÓ\82­";
1280
1281     if (u.uswallow && attack(u.ustuck)) {
1282         ; /* return 1 */
1283     } else if (Underwater) {
1284 /*JP
1285         pline("Turbulence torpedoes your %s attempts.", verbing);
1286 */
1287         pline("%s\82Æ\82·\82é\82Æ\97\90\90\85\97¬\82ª\8bN\82«\82½\81D", jconj(verbing, "\82æ\82¤"));
1288     } else if (u.dz < 0) {
1289         if (Levitation)
1290 /*JP
1291             You("don't have enough leverage.");
1292 */
1293             You("\95\82\82¢\82Ä\82¢\82é\82Ì\82Å\82Ó\82ñ\82Î\82è\82ª\82«\82©\82È\82¢\81D");
1294         else
1295 /*JP
1296             You_cant("reach the %s.", ceiling(u.ux, u.uy));
1297 */
1298             You("%s\82É\93Í\82©\82È\82¢\81D", ceiling(u.ux,u.uy));
1299     } else if (!u.dx && !u.dy && !u.dz) {
1300         char buf[BUFSZ];
1301         int dam;
1302
1303         dam = rnd(2) + dbon() + obj->spe;
1304         if (dam <= 0)
1305             dam = 1;
1306 /*JP
1307         You("hit yourself with %s.", yname(uwep));
1308 */
1309         You("\8e©\95ª\8e©\90g\82ð%s\82Å\92@\82¢\82½\81D", yname(uwep));
1310 /*JP
1311         Sprintf(buf, "%s own %s", uhis(), OBJ_NAME(objects[obj->otyp]));
1312 */
1313         Sprintf(buf, "\8e©\95ª\8e©\90g\82ð%s\82Å\92@\82¢\82Ä", yname(uwep));
1314         losehp(Maybe_Half_Phys(dam), buf, KILLED_BY);
1315         context.botl = 1;
1316         return 1;
1317     } else if (u.dz == 0) {
1318         if (Stunned || (Confusion && !rn2(5)))
1319             confdir();
1320         rx = u.ux + u.dx;
1321         ry = u.uy + u.dy;
1322         if (!isok(rx, ry)) {
1323 /*JP
1324             pline("Clash!");
1325 */
1326             pline("\83K\83\89\83K\83\89\81I");
1327             return 1;
1328         }
1329         lev = &levl[rx][ry];
1330         if (MON_AT(rx, ry) && attack(m_at(rx, ry)))
1331             return 1;
1332         dig_target = dig_typ(obj, rx, ry);
1333         if (dig_target == DIGTYP_UNDIGGABLE) {
1334             /* ACCESSIBLE or POOL */
1335             trap = t_at(rx, ry);
1336             if (trap && trap->ttyp == WEB) {
1337                 if (!trap->tseen) {
1338                     seetrap(trap);
1339 /*JP
1340                     There("is a spider web there!");
1341 */
1342                     pline("\82»\82±\82É\82Í\82­\82à\82Ì\91\83\82ª\82 \82é\81I");
1343                 }
1344 /*JP
1345                 pline("%s entangled in the web.", Yobjnam2(obj, "become"));
1346 */
1347                 Your("%s\82Í\82­\82à\82Ì\91\83\82É\82©\82ç\82Ü\82Á\82½\81D", xname(obj));
1348                 /* you ought to be able to let go; tough luck */
1349                 /* (maybe `move_into_trap()' would be better) */
1350                 nomul(-d(2, 2));
1351                 multi_reason = "stuck in a spider web";
1352 /*JP
1353                 nomovemsg = "You pull free.";
1354 */
1355                 nomovemsg = "\82Ð\82«\82Í\82È\82µ\82½\81D";
1356             } else if (lev->typ == IRONBARS) {
1357 /*JP
1358                 pline("Clang!");
1359 */
1360                 pline("\83K\83c\83\93\81I");
1361                 wake_nearby();
1362             } else if (IS_TREE(lev->typ))
1363 /*JP
1364                 You("need an axe to cut down a tree.");
1365 */
1366                 You("\96Ø\82ð\90Ø\82é\82É\82Í\95\80\82ª\95K\97v\82¾\81D");
1367             else if (IS_ROCK(lev->typ))
1368 /*JP
1369                 You("need a pick to dig rock.");
1370 */
1371                 You("\8c@\82é\82É\82Í\82Â\82é\82Í\82µ\82ª\95K\97v\82¾\81D");
1372             else if (!ispick && (sobj_at(STATUE, rx, ry)
1373                                  || sobj_at(BOULDER, rx, ry))) {
1374                 boolean vibrate = !rn2(3);
1375 #if 0 /*JP:T*/
1376                 pline("Sparks fly as you whack the %s.%s",
1377                       sobj_at(STATUE, rx, ry) ? "statue" : "boulder",
1378                       vibrate ? " The axe-handle vibrates violently!" : "");
1379 #else
1380                 pline("%s\82ð\90Ø\82ë\82¤\82Æ\82µ\82½\82ç\89Î\89Ô\82ª\8eU\82Á\82½\81I%s",
1381                       sobj_at(STATUE, rx, ry) ? "\92¤\91\9c" : "\8aâ",
1382                       vibrate ? "\95\80\82Í\8c\83\82µ\82­\90U\93®\82µ\82½\81I" : "");
1383 #endif
1384                 if (vibrate)
1385 /*JP
1386                     losehp(Maybe_Half_Phys(2), "axing a hard object",
1387 */
1388                     losehp(Maybe_Half_Phys(2), "\8cÅ\82¢\82à\82Ì\82É\95\80\82ð\8eg\82¨\82¤\82Æ\82µ\82Ä",
1389                            KILLED_BY);
1390             } else if (u.utrap && u.utraptype == TT_PIT && trap
1391                        && (trap_with_u = t_at(u.ux, u.uy))
1392                        && (trap->ttyp == PIT || trap->ttyp == SPIKED_PIT)
1393                        && !conjoined_pits(trap, trap_with_u, FALSE)) {
1394                 int idx;
1395                 for (idx = 0; idx < 8; idx++) {
1396                     if (xdir[idx] == u.dx && ydir[idx] == u.dy)
1397                         break;
1398                 }
1399                 /* idx is valid if < 8 */
1400                 if (idx < 8) {
1401                     int adjidx = (idx + 4) % 8;
1402                     trap_with_u->conjoined |= (1 << idx);
1403                     trap->conjoined |= (1 << adjidx);
1404 /*JP
1405                     pline("You clear some debris from between the pits.");
1406 */
1407                     pline("\82 \82È\82½\82Í\97\8e\82µ\8c\8a\82Ì\8aÔ\82©\82ç\82²\82Ý\82ð\8eæ\82è\82Ì\82¼\82¢\82½\81D");
1408                 }
1409             } else if (u.utrap && u.utraptype == TT_PIT
1410                        && (trap_with_u = t_at(u.ux, u.uy))) {
1411 #if 0 /*JP*/
1412                 You("swing %s, but the rubble has no place to go.",
1413                     yobjnam(obj, (char *) 0));
1414 #else
1415                 You("%s\82ð\90U\82è\89ñ\82µ\82½\82ª\81C\94j\95Ð\82Ì\8ds\82«\8fê\8f\8a\82ª\82È\82¢\81D", xname(obj));
1416 #endif
1417             } else
1418 /*JP
1419                 You("swing %s through thin air.", yobjnam(obj, (char *) 0));
1420 */
1421                 You("\8bó\92\86\82Å%s\82ð\90U\82è\89ñ\82µ\82½\81D", xname(obj));
1422         } else {
1423 #if 0 /*JP*/
1424             static const char *const d_action[6] = { "swinging", "digging",
1425                                                      "chipping the statue",
1426                                                      "hitting the boulder",
1427                                                      "chopping at the door",
1428                                                      "cutting the tree" };
1429 #else
1430             static const char * const d_action1[6] = {
1431                 "\90U\82è",
1432                 "\8c@\82è",
1433                 "\92¤\91\9c\82ð\8dí\82è",
1434                 "\8aâ\82ð\91Å\82¿\82Â\82¯",
1435                 "\94à\82ð\8dí\82è",
1436                 "\96Ø\82ð\90Ø\82è"
1437               };
1438             static const char * const d_action2[6] = {
1439                 "\90U\82é",
1440                 "\8c@\82é",
1441                 "\92¤\91\9c\82ð\8dí\82é",
1442                 "\8aâ\82ð\91Å\82¿\82Â\82¯\82é",
1443                 "\94à\82ð\8dí\82é",
1444                 "\96Ø\82ð\90Ø\82é"
1445               };
1446 #endif
1447             did_dig_msg = FALSE;
1448             context.digging.quiet = FALSE;
1449             if (context.digging.pos.x != rx || context.digging.pos.y != ry
1450                 || !on_level(&context.digging.level, &u.uz)
1451                 || context.digging.down) {
1452                 if (flags.autodig && dig_target == DIGTYP_ROCK
1453                     && !context.digging.down && context.digging.pos.x == u.ux
1454                     && context.digging.pos.y == u.uy
1455                     && (moves <= context.digging.lastdigtime + 2
1456                         && moves >= context.digging.lastdigtime)) {
1457                     /* avoid messages if repeated autodigging */
1458                     did_dig_msg = TRUE;
1459                     context.digging.quiet = TRUE;
1460                 }
1461                 context.digging.down = context.digging.chew = FALSE;
1462                 context.digging.warned = FALSE;
1463                 context.digging.pos.x = rx;
1464                 context.digging.pos.y = ry;
1465                 assign_level(&context.digging.level, &u.uz);
1466                 context.digging.effort = 0;
1467                 if (!context.digging.quiet)
1468 /*JP
1469                     You("start %s.", d_action[dig_target]);
1470 */
1471                     You("%s\82Í\82\82ß\82½\81D", d_action1[dig_target]);
1472             } else {
1473 #if 0 /*JP*/
1474                 You("%s %s.", context.digging.chew ? "begin" : "continue",
1475                     d_action[dig_target]);
1476 #else
1477                 You("%s\82Ì\82ð%s\82µ\82½\81D", d_action2[dig_target],
1478                     context.digging.chew ? "\8aJ\8en" : "\8dÄ\8aJ");
1479 #endif
1480                 context.digging.chew = FALSE;
1481             }
1482             set_occupation(dig, verbing, 0);
1483         }
1484     } else if (Is_airlevel(&u.uz) || Is_waterlevel(&u.uz)) {
1485         /* it must be air -- water checked above */
1486 /*JP
1487         You("swing %s through thin air.", yobjnam(obj, (char *) 0));
1488 */
1489         You("\89½\82à\82È\82¢\8bó\8aÔ\82Å%s\82ð\90U\82è\82Ü\82í\82µ\82½\81D", xname(obj));
1490     } else if (!can_reach_floor(FALSE)) {
1491         cant_reach_floor(u.ux, u.uy, FALSE, FALSE);
1492     } else if (is_pool_or_lava(u.ux, u.uy)) {
1493         /* Monsters which swim also happen not to be able to dig */
1494 #if 0 /*JP:T*/
1495         You("cannot stay under%s long enough.",
1496             is_pool(u.ux, u.uy) ? "water" : " the lava");
1497 #else
1498         You("%s\82É\82Í\92·\8e\9e\8aÔ\82¢\82ç\82ê\82È\82¢\81D",
1499             is_pool(u.ux, u.uy) ? "\90\85\96Ê\89º" : "\97n\8aâ\82Ì\92\86");
1500 #endif
1501     } else if ((trap = t_at(u.ux, u.uy)) != 0
1502                && uteetering_at_seen_pit(trap)) {
1503         dotrap(trap, FORCEBUNGLE);
1504         /* might escape trap and still be teetering at brink */
1505         if (!u.utrap)
1506             cant_reach_floor(u.ux, u.uy, FALSE, TRUE);
1507     } else if (!ispick
1508                /* can only dig down with an axe when doing so will
1509                   trigger or disarm a trap here */
1510                && (!trap || (trap->ttyp != LANDMINE
1511                              && trap->ttyp != BEAR_TRAP))) {
1512 #if 0 /*JP:T*/
1513         pline("%s merely scratches the %s.", Yobjnam2(obj, (char *) 0),
1514               surface(u.ux, u.uy));
1515 #else
1516         Your("%s\82Í%s\82É\82©\82·\82è\8f\9d\82ð\82Â\82¯\82½\82¾\82¯\82¾\82Á\82½\81D", aobjnam(obj, (char *)0),
1517               surface(u.ux,u.uy));
1518 #endif
1519         u_wipe_engr(3);
1520     } else {
1521         if (context.digging.pos.x != u.ux || context.digging.pos.y != u.uy
1522             || !on_level(&context.digging.level, &u.uz)
1523             || !context.digging.down) {
1524             context.digging.chew = FALSE;
1525             context.digging.down = TRUE;
1526             context.digging.warned = FALSE;
1527             context.digging.pos.x = u.ux;
1528             context.digging.pos.y = u.uy;
1529             assign_level(&context.digging.level, &u.uz);
1530             context.digging.effort = 0;
1531 /*JP
1532             You("start %s downward.", verbing);
1533 */
1534             You("\89º\8cü\82«\82É\8c@\82è\82Í\82\82ß\82½\81D");
1535             if (*u.ushops)
1536                 shopdig(0);
1537         } else
1538 /*JP
1539             You("continue %s downward.", verbing);
1540 */
1541             You("\89º\8cü\82«\82É\8c@\82é\82Ì\82ð\8dÄ\8aJ\82µ\82½\81D");
1542         did_dig_msg = FALSE;
1543         set_occupation(dig, verbing, 0);
1544     }
1545     return 1;
1546 }
1547
1548 /*
1549  * Town Watchmen frown on damage to the town walls, trees or fountains.
1550  * It's OK to dig holes in the ground, however.
1551  * If mtmp is assumed to be a watchman, a watchman is found if mtmp == 0
1552  * zap == TRUE if wand/spell of digging, FALSE otherwise (chewing)
1553  */
1554 void
1555 watch_dig(mtmp, x, y, zap)
1556 struct monst *mtmp;
1557 xchar x, y;
1558 boolean zap;
1559 {
1560     struct rm *lev = &levl[x][y];
1561
1562     if (in_town(x, y)
1563         && (closed_door(x, y) || lev->typ == SDOOR || IS_WALL(lev->typ)
1564             || IS_FOUNTAIN(lev->typ) || IS_TREE(lev->typ))) {
1565         if (!mtmp) {
1566             for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
1567                 if (DEADMONSTER(mtmp))
1568                     continue;
1569                 if (is_watch(mtmp->data) && mtmp->mcansee && m_canseeu(mtmp)
1570                     && couldsee(mtmp->mx, mtmp->my) && mtmp->mpeaceful)
1571                     break;
1572             }
1573         }
1574
1575         if (mtmp) {
1576             if (zap || context.digging.warned) {
1577 /*JP
1578                 verbalize("Halt, vandal!  You're under arrest!");
1579 */
1580                 verbalize("\8e~\82Ü\82ê\96ì\94Ø\90l\81I\82¨\82Ü\82¦\82ð\91ß\95ß\82·\82é\81I");
1581                 (void) angry_guards(!!Deaf);
1582             } else {
1583                 const char *str;
1584
1585                 if (IS_DOOR(lev->typ))
1586 /*JP
1587                     str = "door";
1588 */
1589                     str = "\94à";
1590                 else if (IS_TREE(lev->typ))
1591 /*JP
1592                     str = "tree";
1593 */
1594                     str = "\96Ø";
1595                 else if (IS_ROCK(lev->typ))
1596 /*JP
1597                     str = "wall";
1598 */
1599                     str = "\95Ç";
1600                 else
1601 /*JP
1602                     str = "fountain";
1603 */
1604                     str = "\90ò";
1605 /*JP
1606                 verbalize("Hey, stop damaging that %s!", str);
1607 */
1608                 verbalize("\82¨\82¢\81C%s\82ð\94j\89ó\82·\82é\82Ì\82ð\82â\82ß\82ë\81I", str);
1609                 context.digging.warned = TRUE;
1610             }
1611             if (is_digging())
1612                 stop_occupation();
1613         }
1614     }
1615 }
1616
1617 /* Return TRUE if monster died, FALSE otherwise.  Called from m_move(). */
1618 boolean
1619 mdig_tunnel(mtmp)
1620 register struct monst *mtmp;
1621 {
1622     register struct rm *here;
1623     int pile = rnd(12);
1624
1625     here = &levl[mtmp->mx][mtmp->my];
1626     if (here->typ == SDOOR)
1627         cvt_sdoor_to_door(here); /* ->typ = DOOR */
1628
1629     /* Eats away door if present & closed or locked */
1630     if (closed_door(mtmp->mx, mtmp->my)) {
1631         if (*in_rooms(mtmp->mx, mtmp->my, SHOPBASE))
1632             add_damage(mtmp->mx, mtmp->my, 0L);
1633         unblock_point(mtmp->mx, mtmp->my); /* vision */
1634         if (here->doormask & D_TRAPPED) {
1635             here->doormask = D_NODOOR;
1636             if (mb_trapped(mtmp)) { /* mtmp is killed */
1637                 newsym(mtmp->mx, mtmp->my);
1638                 return TRUE;
1639             }
1640         } else {
1641             if (!rn2(3) && flags.verbose) /* not too often.. */
1642                 draft_message(TRUE); /* "You feel an unexpected draft." */
1643             here->doormask = D_BROKEN;
1644         }
1645         newsym(mtmp->mx, mtmp->my);
1646         return FALSE;
1647     } else if (here->typ == SCORR) {
1648         here->typ = CORR;
1649         unblock_point(mtmp->mx, mtmp->my);
1650         newsym(mtmp->mx, mtmp->my);
1651         draft_message(FALSE); /* "You feel a draft." */
1652         return FALSE;
1653     } else if (!IS_ROCK(here->typ) && !IS_TREE(here->typ)) /* no dig */
1654         return FALSE;
1655
1656     /* Only rock, trees, and walls fall through to this point. */
1657     if ((here->wall_info & W_NONDIGGABLE) != 0) {
1658         impossible("mdig_tunnel:  %s at (%d,%d) is undiggable",
1659                    (IS_WALL(here->typ) ? "wall"
1660                     : IS_TREE(here->typ) ? "tree" : "stone"),
1661                    (int) mtmp->mx, (int) mtmp->my);
1662         return FALSE; /* still alive */
1663     }
1664
1665     if (IS_WALL(here->typ)) {
1666         /* KMH -- Okay on arboreal levels (room walls are still stone) */
1667         if (flags.verbose && !rn2(5))
1668 /*JP
1669             You_hear("crashing rock.");
1670 */
1671             You_hear("\8aâ\82Ì\82­\82¾\82¯\82é\89¹\82ð\95·\82¢\82½\81D");
1672         if (*in_rooms(mtmp->mx, mtmp->my, SHOPBASE))
1673             add_damage(mtmp->mx, mtmp->my, 0L);
1674         if (level.flags.is_maze_lev) {
1675             here->typ = ROOM;
1676         } else if (level.flags.is_cavernous_lev
1677                    && !in_town(mtmp->mx, mtmp->my)) {
1678             here->typ = CORR;
1679         } else {
1680             here->typ = DOOR;
1681             here->doormask = D_NODOOR;
1682         }
1683     } else if (IS_TREE(here->typ)) {
1684         here->typ = ROOM;
1685         if (pile && pile < 5)
1686             (void) rnd_treefruit_at(mtmp->mx, mtmp->my);
1687     } else {
1688         here->typ = CORR;
1689         if (pile && pile < 5)
1690             (void) mksobj_at((pile == 1) ? BOULDER : ROCK, mtmp->mx, mtmp->my,
1691                              TRUE, FALSE);
1692     }
1693     newsym(mtmp->mx, mtmp->my);
1694     if (!sobj_at(BOULDER, mtmp->mx, mtmp->my))
1695         unblock_point(mtmp->mx, mtmp->my); /* vision */
1696
1697     return FALSE;
1698 }
1699
1700 #define STRIDENT 4 /* from pray.c */
1701
1702 /* draft refers to air currents, but can be a pun on "draft" as conscription
1703    for military service (probably not a good pun if it has to be explained) */
1704 void
1705 draft_message(unexpected)
1706 boolean unexpected;
1707 {
1708     /*
1709      * [Bug or TODO?  Have caller pass coordinates and use the travel
1710      * mechanism to determine whether there is a path between
1711      * destroyed door (or exposed secret corridor) and hero's location.
1712      * When there is no such path, no draft should be felt.]
1713      */
1714
1715     if (unexpected) {
1716         if (!Hallucination)
1717 /*JP
1718             You_feel("an unexpected draft.");
1719 */
1720             You("\8ev\82¢\82à\82æ\82ç\82¸\81C\82·\82«\82Ü\95\97\82ð\8a´\82\82½\81D");
1721         else
1722             /* U.S. classification system uses 1-A for eligible to serve
1723                and 4-F for ineligible due to physical or mental defect;
1724                some intermediate values exist but are rarely seen */
1725 #if 0 /*JP*/
1726             You_feel("like you are %s.",
1727                      (ACURR(A_STR) < 6 || ACURR(A_DEX) < 6
1728                       || ACURR(A_CON) < 6 || ACURR(A_CHA) < 6
1729                       || ACURR(A_INT) < 6 || ACURR(A_WIS) < 6) ? "4-F"
1730                                                                : "1-A");
1731 #else
1732             You("\93Ë\91R\90\99\97Ç\91¾\98Y\82ð\8ev\82¢\8fo\82µ\82½\81D");
1733 #endif
1734     } else {
1735         if (!Hallucination) {
1736 /*JP
1737             You_feel("a draft.");
1738 */
1739             You_feel("\82·\82«\82Ü\95\97\82ð\8a´\82\82½\81D");
1740         } else {
1741 #if 0 /*JP*//*"draft"=\81u\92¥\95º\81v*/
1742             /* "marching" is deliberately ambiguous; it might mean drills
1743                 after entering military service or mean engaging in protests */
1744             static const char *draft_reaction[] = {
1745                 "enlisting", "marching", "protesting", "fleeing",
1746             };
1747             int dridx;
1748
1749             /* Lawful: 0..1, Neutral: 1..2, Chaotic: 2..3 */
1750             dridx = rn1(2, 1 - sgn(u.ualign.type));
1751             if (u.ualign.record < STRIDENT)
1752                 /* L: +(0..2), N: +(-1..1), C: +(-2..0); all: 0..3 */
1753                 dridx += rn1(3, sgn(u.ualign.type) - 1);
1754             You_feel("like %s.", draft_reaction[dridx]);
1755 #else /*JP:\93ú\96{\8cê\82Å\82Í\8bÃ\82Á\82½\82±\82Æ\82Í\82µ\82È\82¢*/
1756             You("\90\99\97Ç\91¾\98Y\82ð\8ev\82¢\8fo\82µ\82½\81D");
1757 #endif
1758         }
1759     }
1760 }
1761
1762 /* digging via wand zap or spell cast */
1763 void
1764 zap_dig()
1765 {
1766     struct rm *room;
1767     struct monst *mtmp;
1768     struct obj *otmp;
1769     struct trap *trap_with_u = (struct trap *) 0;
1770     int zx, zy, diridx = 8, digdepth, flow_x = -1, flow_y = -1;
1771     boolean shopdoor, shopwall, maze_dig, pitdig = FALSE, pitflow = FALSE;
1772
1773     /*
1774      * Original effect (approximately):
1775      * from CORR: dig until we pierce a wall
1776      * from ROOM: pierce wall and dig until we reach
1777      * an ACCESSIBLE place.
1778      * Currently: dig for digdepth positions;
1779      * also down on request of Lennart Augustsson.
1780      * 3.6.0: from a PIT: dig one adjacent pit.
1781      */
1782
1783     if (u.uswallow) {
1784         mtmp = u.ustuck;
1785
1786         if (!is_whirly(mtmp->data)) {
1787             if (is_animal(mtmp->data))
1788 #if 0 /*JP*/
1789                 You("pierce %s %s wall!", s_suffix(mon_nam(mtmp)),
1790                     mbodypart(mtmp, STOMACH));
1791 #else
1792                 You("%s\82Ì%s\82Ì\95Ç\82É\8c\8a\82ð\8aJ\82¯\82½\81I", s_suffix(mon_nam(mtmp)),
1793                     mbodypart(mtmp, STOMACH));
1794 #endif
1795             mtmp->mhp = 1; /* almost dead */
1796             expels(mtmp, mtmp->data, !is_animal(mtmp->data));
1797         }
1798         return;
1799     } /* swallowed */
1800
1801     if (u.dz) {
1802         if (!Is_airlevel(&u.uz) && !Is_waterlevel(&u.uz) && !Underwater) {
1803             if (u.dz < 0 || On_stairs(u.ux, u.uy)) {
1804                 int dmg;
1805                 if (On_stairs(u.ux, u.uy))
1806 #if 0 /*JP*/
1807                     pline_The("beam bounces off the %s and hits the %s.",
1808                               (u.ux == xdnladder || u.ux == xupladder)
1809                                   ? "ladder"
1810                                   : "stairs",
1811                               ceiling(u.ux, u.uy));
1812 #else
1813                     pline("\8cõ\90ü\82Í%s\82Å\94½\8eË\82µ%s\82É\96½\92\86\82µ\82½\81D",
1814                               (u.ux == xdnladder || u.ux == xupladder)
1815                                   ? "\82Í\82µ\82²"
1816                                   : "\8aK\92i",
1817                               ceiling(u.ux, u.uy));
1818 #endif
1819 /*JP
1820                 You("loosen a rock from the %s.", ceiling(u.ux, u.uy));
1821 */
1822                 pline("%s\82Ì\8aâ\82ª\83K\83^\83K\83^\82µ\82Í\82\82ß\82½\81D", ceiling(u.ux, u.uy));
1823 /*JP
1824                 pline("It falls on your %s!", body_part(HEAD));
1825 */
1826                 pline("\82»\82ê\82Í\82 \82È\82½\82Ì%s\82É\97\8e\82¿\82Ä\82«\82½\81I", body_part(HEAD));
1827                 dmg = rnd((uarmh && is_metallic(uarmh)) ? 2 : 6);
1828 /*JP
1829                 losehp(Maybe_Half_Phys(dmg), "falling rock", KILLED_BY_AN);
1830 */
1831                 losehp(Maybe_Half_Phys(dmg), "\97\8e\8aâ\82Å", KILLED_BY_AN);
1832                 otmp = mksobj_at(ROCK, u.ux, u.uy, FALSE, FALSE);
1833                 if (otmp) {
1834                     (void) xname(otmp); /* set dknown, maybe bknown */
1835                     stackobj(otmp);
1836                 }
1837                 newsym(u.ux, u.uy);
1838             } else {
1839                 watch_dig((struct monst *) 0, u.ux, u.uy, TRUE);
1840                 (void) dighole(FALSE, TRUE, (coord *) 0);
1841             }
1842         }
1843         return;
1844     } /* up or down */
1845
1846     /* normal case: digging across the level */
1847     shopdoor = shopwall = FALSE;
1848     maze_dig = level.flags.is_maze_lev && !Is_earthlevel(&u.uz);
1849     zx = u.ux + u.dx;
1850     zy = u.uy + u.dy;
1851     if (u.utrap && u.utraptype == TT_PIT
1852         && (trap_with_u = t_at(u.ux, u.uy))) {
1853         pitdig = TRUE;
1854         for (diridx = 0; diridx < 8; diridx++) {
1855             if (xdir[diridx] == u.dx && ydir[diridx] == u.dy)
1856                 break;
1857             /* diridx is valid if < 8 */
1858         }
1859     }
1860     digdepth = rn1(18, 8);
1861     tmp_at(DISP_BEAM, cmap_to_glyph(S_digbeam));
1862     while (--digdepth >= 0) {
1863         if (!isok(zx, zy))
1864             break;
1865         room = &levl[zx][zy];
1866         tmp_at(zx, zy);
1867         delay_output(); /* wait a little bit */
1868
1869         if (pitdig) { /* we are already in a pit if this is true */
1870             coord cc;
1871             struct trap *adjpit = t_at(zx, zy);
1872             if ((diridx < 8) && !conjoined_pits(adjpit, trap_with_u, FALSE)) {
1873                 digdepth = 0; /* limited to the adjacent location only */
1874                 if (!(adjpit && (adjpit->ttyp == PIT
1875                                  || adjpit->ttyp == SPIKED_PIT))) {
1876                     char buf[BUFSZ];
1877                     cc.x = zx;
1878                     cc.y = zy;
1879                     if (!adj_pit_checks(&cc, buf)) {
1880                         if (buf[0])
1881                             pline1(buf);
1882                     } else {
1883                         /* this can also result in a pool at zx,zy */
1884                         dighole(TRUE, TRUE, &cc);
1885                         adjpit = t_at(zx, zy);
1886                     }
1887                 }
1888                 if (adjpit
1889                     && (adjpit->ttyp == PIT || adjpit->ttyp == SPIKED_PIT)) {
1890                     int adjidx = (diridx + 4) % 8;
1891                     trap_with_u->conjoined |= (1 << diridx);
1892                     adjpit->conjoined |= (1 << adjidx);
1893                     flow_x = zx;
1894                     flow_y = zy;
1895                     pitflow = TRUE;
1896                 }
1897                 if (is_pool(zx, zy) || is_lava(zx, zy)) {
1898                     flow_x = zx - u.dx;
1899                     flow_y = zy - u.dy;
1900                     pitflow = TRUE;
1901                 }
1902                 break;
1903             }
1904         } else if (closed_door(zx, zy) || room->typ == SDOOR) {
1905             if (*in_rooms(zx, zy, SHOPBASE)) {
1906                 add_damage(zx, zy, 400L);
1907                 shopdoor = TRUE;
1908             }
1909             if (room->typ == SDOOR)
1910                 room->typ = DOOR;
1911             else if (cansee(zx, zy))
1912 /*JP
1913                 pline_The("door is razed!");
1914 */
1915                 pline("\94à\82Í\95ö\82ê\97\8e\82¿\82½\81I");
1916             watch_dig((struct monst *) 0, zx, zy, TRUE);
1917             room->doormask = D_NODOOR;
1918             unblock_point(zx, zy); /* vision */
1919             digdepth -= 2;
1920             if (maze_dig)
1921                 break;
1922         } else if (maze_dig) {
1923             if (IS_WALL(room->typ)) {
1924                 if (!(room->wall_info & W_NONDIGGABLE)) {
1925                     if (*in_rooms(zx, zy, SHOPBASE)) {
1926                         add_damage(zx, zy, 200L);
1927                         shopwall = TRUE;
1928                     }
1929                     room->typ = ROOM;
1930                     unblock_point(zx, zy); /* vision */
1931                 } else if (!Blind)
1932 /*JP
1933                     pline_The("wall glows then fades.");
1934 */
1935                     pline("\95Ç\82Í\88ê\8fu\8bP\82¢\82½\81D");
1936                 break;
1937             } else if (IS_TREE(room->typ)) { /* check trees before stone */
1938                 if (!(room->wall_info & W_NONDIGGABLE)) {
1939                     room->typ = ROOM;
1940                     unblock_point(zx, zy); /* vision */
1941                 } else if (!Blind)
1942 /*JP
1943                     pline_The("tree shudders but is unharmed.");
1944 */
1945                     pline("\96Ø\82Í\82ä\82ê\82½\82ª\8f\9d\82Â\82©\82È\82©\82Á\82½\81D");
1946                 break;
1947             } else if (room->typ == STONE || room->typ == SCORR) {
1948                 if (!(room->wall_info & W_NONDIGGABLE)) {
1949                     room->typ = CORR;
1950                     unblock_point(zx, zy); /* vision */
1951                 } else if (!Blind)
1952 /*JP
1953                     pline_The("rock glows then fades.");
1954 */
1955                     pline("\90Î\82Í\88ê\8fu\8bP\82¢\82½\81D");
1956                 break;
1957             }
1958         } else if (IS_ROCK(room->typ)) {
1959             if (!may_dig(zx, zy))
1960                 break;
1961             if (IS_WALL(room->typ) || room->typ == SDOOR) {
1962                 if (*in_rooms(zx, zy, SHOPBASE)) {
1963                     add_damage(zx, zy, 200L);
1964                     shopwall = TRUE;
1965                 }
1966                 watch_dig((struct monst *) 0, zx, zy, TRUE);
1967                 if (level.flags.is_cavernous_lev && !in_town(zx, zy)) {
1968                     room->typ = CORR;
1969                 } else {
1970                     room->typ = DOOR;
1971                     room->doormask = D_NODOOR;
1972                 }
1973                 digdepth -= 2;
1974             } else if (IS_TREE(room->typ)) {
1975                 room->typ = ROOM;
1976                 digdepth -= 2;
1977             } else { /* IS_ROCK but not IS_WALL or SDOOR */
1978                 room->typ = CORR;
1979                 digdepth--;
1980             }
1981             unblock_point(zx, zy); /* vision */
1982         }
1983         zx += u.dx;
1984         zy += u.dy;
1985     }                    /* while */
1986     tmp_at(DISP_END, 0); /* closing call */
1987
1988     if (pitflow && isok(flow_x, flow_y)) {
1989         struct trap *ttmp = t_at(flow_x, flow_y);
1990         if (ttmp && (ttmp->ttyp == PIT || ttmp->ttyp == SPIKED_PIT)) {
1991             schar filltyp = fillholetyp(ttmp->tx, ttmp->ty, TRUE);
1992             if (filltyp != ROOM)
1993                 pit_flow(ttmp, filltyp);
1994         }
1995     }
1996
1997     if (shopdoor || shopwall)
1998 /*JP
1999         pay_for_damage(shopdoor ? "destroy" : "dig into", FALSE);
2000 */
2001         pay_for_damage(shopdoor ? "\94j\89ó\82·\82é" : "\8c\8a\82ð\82 \82¯\82é", FALSE);
2002     return;
2003 }
2004
2005 /*
2006  * This checks what is on the surface above the
2007  * location where an adjacent pit might be created if
2008  * you're zapping a wand of digging laterally while
2009  * down in the pit.
2010  */
2011 STATIC_OVL int
2012 adj_pit_checks(cc, msg)
2013 coord *cc;
2014 char *msg;
2015 {
2016     int ltyp;
2017     struct rm *room;
2018     const char *foundation_msg =
2019 /*JP
2020         "The foundation is too hard to dig through from this angle.";
2021 */
2022         "\8aî\91b\82Í\82±\82Ì\8ap\93x\82©\82ç\8c@\82é\82É\82Í\8cÅ\82·\82¬\82é\81D";
2023
2024     if (!cc)
2025         return FALSE;
2026     if (!isok(cc->x, cc->y))
2027         return FALSE;
2028     *msg = '\0';
2029     room = &levl[cc->x][cc->y];
2030     ltyp = room->typ;
2031
2032     if (is_pool(cc->x, cc->y) || is_lava(cc->x, cc->y)) {
2033         /* this is handled by the caller after we return FALSE */
2034         return FALSE;
2035     } else if (closed_door(cc->x, cc->y) || room->typ == SDOOR) {
2036         /* We reject this here because dighole() isn't
2037            prepared to deal with this case */
2038         Strcpy(msg, foundation_msg);
2039         return FALSE;
2040     } else if (IS_WALL(ltyp)) {
2041         /* if (room->wall_info & W_NONDIGGABLE) */
2042         Strcpy(msg, foundation_msg);
2043         return FALSE;
2044     } else if (IS_TREE(ltyp)) { /* check trees before stone */
2045         /* if (room->wall_info & W_NONDIGGABLE) */
2046 /*JP
2047         Strcpy(msg, "The tree's roots glow then fade.");
2048 */
2049         Strcpy(msg, "\96Ø\82Ì\8dª\82Í\88ê\8fu\8bP\82¢\82½\81D");
2050         return FALSE;
2051     } else if (ltyp == STONE || ltyp == SCORR) {
2052         if (room->wall_info & W_NONDIGGABLE) {
2053 /*JP
2054             Strcpy(msg, "The rock glows then fades.");
2055 */
2056             Strcpy(msg, "\90Î\82Í\88ê\8fu\8bP\82¢\82½\81D");
2057             return FALSE;
2058         }
2059     } else if (ltyp == IRONBARS) {
2060         /* "set of iron bars" */
2061 /*JP
2062         Strcpy(msg, "The bars go much deeper than your pit.");
2063 */
2064         Strcpy(msg, "\96_\82Í\97\8e\82µ\8c\8a\82æ\82è\97y\82©\82É\90[\82¢\82Æ\82±\82ë\82Ü\82Å\96\84\82Ü\82Á\82Ä\82¢\82é\81D");
2065 #if 0
2066     } else if (is_lava(cc->x, cc->y)) {
2067     } else if (is_ice(cc->x, cc->y)) {
2068     } else if (is_pool(cc->x, cc->y)) {
2069     } else if (IS_GRAVE(ltyp)) {
2070 #endif
2071     } else if (IS_SINK(ltyp)) {
2072 /*JP
2073         Strcpy(msg, "A tangled mass of plumbing remains below the sink.");
2074 */
2075         Strcpy(msg, "\93ü\82è\91g\82ñ\82¾\94z\8aÇ\82ª\97¬\82µ\91ä\82Ì\89º\82É\8ec\82Á\82½\82Ü\82Ü\82¾\81D");
2076         return FALSE;
2077     } else if ((cc->x == xupladder && cc->y == yupladder) /* ladder up */
2078                || (cc->x == xdnladder && cc->y == ydnladder)) { /* " down */
2079 /*JP
2080         Strcpy(msg, "The ladder is unaffected.");
2081 */
2082         Strcpy(msg, "\82Í\82µ\82²\82Í\89e\8b¿\82ð\8eó\82¯\82È\82¢\81D");
2083         return FALSE;
2084     } else {
2085         const char *supporting = (const char *) 0;
2086
2087         if (IS_FOUNTAIN(ltyp))
2088 /*JP
2089             supporting = "fountain";
2090 */
2091             supporting = "\90ò";
2092         else if (IS_THRONE(ltyp))
2093 /*JP
2094             supporting = "throne";
2095 */
2096             supporting = "\8bÊ\8dÀ";
2097         else if (IS_ALTAR(ltyp))
2098 /*JP
2099             supporting = "altar";
2100 */
2101             supporting = "\8dÕ\92d";
2102         else if ((cc->x == xupstair && cc->y == yupstair)
2103                  || (cc->x == sstairs.sx && cc->y == sstairs.sy
2104                      && sstairs.up))
2105             /* "staircase up" */
2106 /*JP
2107             supporting = "stairs";
2108 */
2109             supporting = "\8aK\92i";
2110         else if ((cc->x == xdnstair && cc->y == ydnstair)
2111                  || (cc->x == sstairs.sx && cc->y == sstairs.sy
2112                      && !sstairs.up))
2113             /* "staircase down" */
2114 /*JP
2115             supporting = "stairs";
2116 */
2117             supporting = "\8aK\92i";
2118         else if (ltyp == DRAWBRIDGE_DOWN   /* "lowered drawbridge" */
2119                  || ltyp == DBWALL)        /* "raised drawbridge" */
2120 /*JP
2121             supporting = "drawbridge";
2122 */
2123             supporting = "\92µ\82Ë\8b´";
2124
2125         if (supporting) {
2126 #if 0 /*JP*/
2127             Sprintf(msg, "The %s%ssupporting structures remain intact.",
2128                     supporting ? s_suffix(supporting) : "",
2129                     supporting ? " " : "");
2130 #else
2131             Sprintf(msg, "%s%s\8ex\82¦\82Ä\82¢\82é\95\94\95ª\82Í\82»\82Ì\82Ü\82Ü\82¾\81D",
2132                     supporting ? supporting : "",
2133                     supporting ? "\82ð" : "");
2134 #endif
2135             return FALSE;
2136         }
2137     }
2138     return TRUE;
2139 }
2140
2141 /*
2142  * Ensure that all conjoined pits fill up.
2143  */
2144 STATIC_OVL void
2145 pit_flow(trap, filltyp)
2146 struct trap *trap;
2147 schar filltyp;
2148 {
2149     if (trap && (filltyp != ROOM)
2150         && (trap->ttyp == PIT || trap->ttyp == SPIKED_PIT)) {
2151         struct trap t;
2152         int idx;
2153
2154         t = *trap;
2155         levl[trap->tx][trap->ty].typ = filltyp;
2156         liquid_flow(trap->tx, trap->ty, filltyp, trap,
2157                     (trap->tx == u.ux && trap->ty == u.uy)
2158 /*JP
2159                         ? "Suddenly %s flows in from the adjacent pit!"
2160 */
2161                         ? "\93Ë\91R\97×\82Ì\97\8e\82µ\8c\8a\82©\82ç%s\82ª\97¬\82ê\8d\9e\82ñ\82Å\82«\82½\81I"
2162                         : (char *) 0);
2163         for (idx = 0; idx < 8; ++idx) {
2164             if (t.conjoined & (1 << idx)) {
2165                 int x, y;
2166                 struct trap *t2;
2167
2168                 x = t.tx + xdir[idx];
2169                 y = t.ty + ydir[idx];
2170                 t2 = t_at(x, y);
2171 #if 0
2172                 /* cannot do this back-check; liquid_flow()
2173                  * called deltrap() which cleaned up the
2174                  * conjoined fields on both pits.
2175                  */
2176                 if (t2 && (t2->conjoined & (1 << ((idx + 4) % 8))))
2177 #endif
2178                 /* recursion */
2179                 pit_flow(t2, filltyp);
2180             }
2181         }
2182     }
2183 }
2184
2185 struct obj *
2186 buried_ball(cc)
2187 coord *cc;
2188 {
2189     xchar check_x, check_y;
2190     struct obj *otmp, *otmp2;
2191
2192     if (u.utraptype == TT_BURIEDBALL)
2193         for (otmp = level.buriedobjlist; otmp; otmp = otmp2) {
2194             otmp2 = otmp->nobj;
2195             if (otmp->otyp != HEAVY_IRON_BALL)
2196                 continue;
2197             /* try the exact location first */
2198             if (otmp->ox == cc->x && otmp->oy == cc->y)
2199                 return otmp;
2200             /* Now try the vicinity */
2201             /*
2202              * (x-2,y-2)       (x+2,y-2)
2203              *           (x,y)
2204              * (x-2,y+2)       (x+2,y+2)
2205              */
2206             for (check_x = cc->x - 2; check_x <= cc->x + 2; ++check_x)
2207                 for (check_y = cc->y - 2; check_y <= cc->y + 2; ++check_y) {
2208                     if (check_x == cc->x && check_y == cc->y)
2209                         continue;
2210                     if (isok(check_x, check_y)
2211                         && (otmp->ox == check_x && otmp->oy == check_y)) {
2212                         cc->x = check_x;
2213                         cc->y = check_y;
2214                         return otmp;
2215                     }
2216                 }
2217         }
2218     return (struct obj *) 0;
2219 }
2220
2221 void
2222 buried_ball_to_punishment()
2223 {
2224     coord cc;
2225     struct obj *ball;
2226     cc.x = u.ux;
2227     cc.y = u.uy;
2228     ball = buried_ball(&cc);
2229     if (ball) {
2230         obj_extract_self(ball);
2231 #if 0
2232         /* rusting buried metallic objects is not implemented yet */
2233         if (ball->timed)
2234             (void) stop_timer(RUST_METAL, obj_to_any(ball));
2235 #endif
2236         punish(ball); /* use ball as flag for unearthed buried ball */
2237         u.utrap = 0;
2238         u.utraptype = 0;
2239         del_engr_at(cc.x, cc.y);
2240         newsym(cc.x, cc.y);
2241     }
2242 }
2243
2244 void
2245 buried_ball_to_freedom()
2246 {
2247     coord cc;
2248     struct obj *ball;
2249     cc.x = u.ux;
2250     cc.y = u.uy;
2251     ball = buried_ball(&cc);
2252     if (ball) {
2253         obj_extract_self(ball);
2254 #if 0
2255         /* rusting buried metallic objects is not implemented yet */
2256         if (ball->timed)
2257             (void) stop_timer(RUST_METAL, obj_to_any(ball));
2258 #endif
2259         place_object(ball, cc.x, cc.y);
2260         stackobj(ball);
2261         u.utrap = 0;
2262         u.utraptype = 0;
2263         del_engr_at(cc.x, cc.y);
2264         newsym(cc.x, cc.y);
2265     }
2266 }
2267
2268 /* move objects from fobj/nexthere lists to buriedobjlist, keeping position
2269    information */
2270 struct obj *
2271 bury_an_obj(otmp, dealloced)
2272 struct obj *otmp;
2273 boolean *dealloced;
2274 {
2275     struct obj *otmp2;
2276     boolean under_ice;
2277
2278     debugpline1("bury_an_obj: %s", xname(otmp));
2279     if (dealloced)
2280         *dealloced = FALSE;
2281     if (otmp == uball) {
2282         unpunish();
2283         u.utrap = rn1(50, 20);
2284         u.utraptype = TT_BURIEDBALL;
2285 /*JP
2286         pline_The("iron ball gets buried!");
2287 */
2288         pline_The("\93S\82Ì\8b\85\82Í\96\84\82Ü\82Á\82½\81I");
2289     }
2290     /* after unpunish(), or might get deallocated chain */
2291     otmp2 = otmp->nexthere;
2292     /*
2293      * obj_resists(,0,0) prevents Rider corpses from being buried.
2294      * It also prevents The Amulet and invocation tools from being
2295      * buried.  Since they can't be confined to bags and statues,
2296      * it makes sense that they can't be buried either, even though
2297      * the real reason there (direct accessibility when carried) is
2298      * completely different.
2299      */
2300     if (otmp == uchain || obj_resists(otmp, 0, 0))
2301         return otmp2;
2302
2303     if (otmp->otyp == LEASH && otmp->leashmon != 0)
2304         o_unleash(otmp);
2305
2306     if (otmp->lamplit && otmp->otyp != POT_OIL)
2307         end_burn(otmp, TRUE);
2308
2309     obj_extract_self(otmp);
2310
2311     under_ice = is_ice(otmp->ox, otmp->oy);
2312     if (otmp->otyp == ROCK && !under_ice) {
2313         /* merges into burying material */
2314         if (dealloced)
2315             *dealloced = TRUE;
2316         obfree(otmp, (struct obj *) 0);
2317         return otmp2;
2318     }
2319     /*
2320      * Start a rot on organic material.  Not corpses -- they
2321      * are already handled.
2322      */
2323     if (otmp->otyp == CORPSE) {
2324         ; /* should cancel timer if under_ice */
2325     } else if ((under_ice ? otmp->oclass == POTION_CLASS : is_organic(otmp))
2326                && !obj_resists(otmp, 5, 95)) {
2327         (void) start_timer((under_ice ? 0L : 250L) + (long) rnd(250),
2328                            TIMER_OBJECT, ROT_ORGANIC, obj_to_any(otmp));
2329 #if 0
2330     /* rusting of buried metal not yet implemented */
2331     } else if (is_rustprone(otmp)) {
2332         (void) start_timer((long) rnd((otmp->otyp == HEAVY_IRON_BALL)
2333                                          ? 1500
2334                                          : 250),
2335                            TIMER_OBJECT, RUST_METAL, obj_to_any(otmp));
2336 #endif
2337     }
2338     add_to_buried(otmp);
2339     return  otmp2;
2340 }
2341
2342 void
2343 bury_objs(x, y)
2344 int x, y;
2345 {
2346     struct obj *otmp, *otmp2;
2347
2348     if (level.objects[x][y] != (struct obj *) 0) {
2349         debugpline2("bury_objs: at <%d,%d>", x, y);
2350     }
2351     for (otmp = level.objects[x][y]; otmp; otmp = otmp2)
2352         otmp2 = bury_an_obj(otmp, (boolean *) 0);
2353
2354     /* don't expect any engravings here, but just in case */
2355     del_engr_at(x, y);
2356     newsym(x, y);
2357 }
2358
2359 /* move objects from buriedobjlist to fobj/nexthere lists */
2360 void
2361 unearth_objs(x, y)
2362 int x, y;
2363 {
2364     struct obj *otmp, *otmp2, *bball;
2365     coord cc;
2366
2367     debugpline2("unearth_objs: at <%d,%d>", x, y);
2368     cc.x = x;
2369     cc.y = y;
2370     bball = buried_ball(&cc);
2371     for (otmp = level.buriedobjlist; otmp; otmp = otmp2) {
2372         otmp2 = otmp->nobj;
2373         if (otmp->ox == x && otmp->oy == y) {
2374             if (bball && otmp == bball && u.utraptype == TT_BURIEDBALL) {
2375                 buried_ball_to_punishment();
2376             } else {
2377                 obj_extract_self(otmp);
2378                 if (otmp->timed)
2379                     (void) stop_timer(ROT_ORGANIC, obj_to_any(otmp));
2380                 place_object(otmp, x, y);
2381                 stackobj(otmp);
2382             }
2383         }
2384     }
2385     del_engr_at(x, y);
2386     newsym(x, y);
2387 }
2388
2389 /*
2390  * The organic material has rotted away while buried.  As an expansion,
2391  * we could add add partial damage.  A damage count is kept in the object
2392  * and every time we are called we increment the count and reschedule another
2393  * timeout.  Eventually the object rots away.
2394  *
2395  * This is used by buried objects other than corpses.  When a container rots
2396  * away, any contents become newly buried objects.
2397  */
2398 /* ARGSUSED */
2399 void
2400 rot_organic(arg, timeout)
2401 anything *arg;
2402 long timeout UNUSED;
2403 {
2404     struct obj *obj = arg->a_obj;
2405
2406     while (Has_contents(obj)) {
2407         /* We don't need to place contained object on the floor
2408            first, but we do need to update its map coordinates. */
2409         obj->cobj->ox = obj->ox, obj->cobj->oy = obj->oy;
2410         /* Everything which can be held in a container can also be
2411            buried, so bury_an_obj's use of obj_extract_self insures
2412            that Has_contents(obj) will eventually become false. */
2413         (void) bury_an_obj(obj->cobj, (boolean *) 0);
2414     }
2415     obj_extract_self(obj);
2416     obfree(obj, (struct obj *) 0);
2417 }
2418
2419 /*
2420  * Called when a corpse has rotted completely away.
2421  */
2422 void
2423 rot_corpse(arg, timeout)
2424 anything *arg;
2425 long timeout;
2426 {
2427     xchar x = 0, y = 0;
2428     struct obj *obj = arg->a_obj;
2429     boolean on_floor = obj->where == OBJ_FLOOR,
2430             in_invent = obj->where == OBJ_INVENT;
2431
2432     if (on_floor) {
2433         x = obj->ox;
2434         y = obj->oy;
2435     } else if (in_invent) {
2436         if (flags.verbose) {
2437             char *cname = corpse_xname(obj, (const char *) 0, CXN_NO_PFX);
2438
2439 #if 0 /*JP:T*/
2440             Your("%s%s %s away%c", obj == uwep ? "wielded " : "", cname,
2441                  otense(obj, "rot"), obj == uwep ? '!' : '.');
2442 #else
2443             pline("\82 \82È\82½\82Ì%s%s\82Í\95\85\82Á\82Ä\82µ\82Ü\82Á\82½%s",
2444                      obj == uwep ? "\8eè\82É\82µ\82Ä\82¢\82é" : "", cname,
2445                      obj == uwep ? "\81I" : "\81D");
2446 #endif
2447         }
2448         if (obj == uwep) {
2449             uwepgone(); /* now bare handed */
2450             stop_occupation();
2451         } else if (obj == uswapwep) {
2452             uswapwepgone();
2453             stop_occupation();
2454         } else if (obj == uquiver) {
2455             uqwepgone();
2456             stop_occupation();
2457         }
2458     } else if (obj->where == OBJ_MINVENT && obj->owornmask) {
2459         if (obj == MON_WEP(obj->ocarry))
2460             setmnotwielded(obj->ocarry, obj);
2461     } else if (obj->where == OBJ_MIGRATING) {
2462         /* clear destination flag so that obfree()'s check for
2463            freeing a worn object doesn't get a false hit */
2464         obj->owornmask = 0L;
2465     }
2466     rot_organic(arg, timeout);
2467     if (on_floor) {
2468         struct monst *mtmp = m_at(x, y);
2469
2470         /* a hiding monster may be exposed */
2471         if (mtmp && !OBJ_AT(x, y) && mtmp->mundetected
2472             && hides_under(mtmp->data)) {
2473             mtmp->mundetected = 0;
2474         } else if (x == u.ux && y == u.uy && u.uundetected && hides_under(youmonst.data))
2475             (void) hideunder(&youmonst);
2476         newsym(x, y);
2477     } else if (in_invent)
2478         update_inventory();
2479 }
2480
2481 #if 0
2482 void
2483 bury_monst(mtmp)
2484 struct monst *mtmp;
2485 {
2486     debugpline1("bury_monst: %s", mon_nam(mtmp));
2487     if (canseemon(mtmp)) {
2488         if (is_flyer(mtmp->data) || is_floater(mtmp->data)) {
2489             pline_The("%s opens up, but %s is not swallowed!",
2490                       surface(mtmp->mx, mtmp->my), mon_nam(mtmp));
2491             return;
2492         } else
2493             pline_The("%s opens up and swallows %s!",
2494                       surface(mtmp->mx, mtmp->my), mon_nam(mtmp));
2495     }
2496
2497     mtmp->mburied = TRUE;
2498     wakeup(mtmp);       /* at least give it a chance :-) */
2499     newsym(mtmp->mx, mtmp->my);
2500 }
2501
2502 void
2503 bury_you()
2504 {
2505     debugpline0("bury_you");
2506     if (!Levitation && !Flying) {
2507         if (u.uswallow)
2508 /*JP
2509             You_feel("a sensation like falling into a trap!");
2510 */
2511             You("ã©\82É\97\8e\82¿\82é\82æ\82¤\82È\8a´\8ao\82É\82¨\82»\82í\82ê\82½\81I");
2512         else
2513 /*JP
2514             pline_The("%s opens beneath you and you fall in!",
2515 */
2516             pline("%s\82ª\89º\95û\82É\8aJ\82«\81C\82 \82È\82½\82Í\97\8e\82¿\82½\81I",
2517                       surface(u.ux, u.uy));
2518
2519         u.uburied = TRUE;
2520         if (!Strangled && !Breathless)
2521             Strangled = 6;
2522         under_ground(1);
2523     }
2524 }
2525
2526 void
2527 unearth_you()
2528 {
2529     debugpline0("unearth_you");
2530     u.uburied = FALSE;
2531     under_ground(0);
2532     if (!uamul || uamul->otyp != AMULET_OF_STRANGULATION)
2533         Strangled = 0;
2534     vision_recalc(0);
2535 }
2536
2537 void
2538 escape_tomb()
2539 {
2540     debugpline0("escape_tomb");
2541     if ((Teleportation || can_teleport(youmonst.data))
2542         && (Teleport_control || rn2(3) < Luck+2)) {
2543 /*JP
2544         You("attempt a teleport spell.");
2545 */
2546         You("\8fu\8aÔ\88Ú\93®\82ð\8e\8e\82Ý\82½\81D");
2547         (void) dotele();        /* calls unearth_you() */
2548     } else if (u.uburied) { /* still buried after 'port attempt */
2549         boolean good;
2550
2551         if (amorphous(youmonst.data) || Passes_walls
2552             || noncorporeal(youmonst.data)
2553             || (unsolid(youmonst.data)
2554                 && youmonst.data != &mons[PM_WATER_ELEMENTAL])
2555             || (tunnels(youmonst.data) && !needspick(youmonst.data))) {
2556 #if 0 /*JP*/
2557             You("%s up through the %s.",
2558                 (tunnels(youmonst.data) && !needspick(youmonst.data))
2559                    ? "try to tunnel"
2560                    : (amorphous(youmonst.data))
2561                       ? "ooze"
2562                       : "phase",
2563                 surface(u.ux, u.uy));
2564 #else
2565             You("%s\82É%s\82ë\82¤\82Æ\82µ\82½\81D",
2566                 surface(u.ux, u.uy),
2567                 (tunnels(youmonst.data) && !needspick(youmonst.data))
2568                 ? "\83g\83\93\83l\83\8b\82ð\8c@"
2569                 : (amorphous(youmonst.data))
2570                    ? "\82É\82\82Ý\82Ì\82Ú"
2571                    : "\8f\99\81X\82É\82Í\82¢\82 \82ª");
2572 #endif
2573
2574             good = (tunnels(youmonst.data) && !needspick(youmonst.data))
2575                       ? dighole(TRUE, FALSE, (coord *)0) : TRUE;
2576             if (good)
2577                 unearth_you();
2578         }
2579     }
2580 }
2581
2582 void
2583 bury_obj(otmp)
2584 struct obj *otmp;
2585 {
2586     debugpline0("bury_obj");
2587     if (cansee(otmp->ox, otmp->oy))
2588 /*JP
2589         pline_The("objects on the %s tumble into a hole!",
2590 */
2591         pline_The("%s\82Ì\95¨\91Ì\82Í\8c\8a\82É\93]\82ª\82Á\82½\81I",
2592                   surface(otmp->ox, otmp->oy));
2593
2594     bury_objs(otmp->ox, otmp->oy);
2595 }
2596 #endif /*0*/
2597
2598 #ifdef DEBUG
2599 /* bury everything at your loc and around */
2600 int
2601 wiz_debug_cmd_bury()
2602 {
2603     int x, y;
2604
2605     for (x = u.ux - 1; x <= u.ux + 1; x++)
2606         for (y = u.uy - 1; y <= u.uy + 1; y++)
2607             if (isok(x, y))
2608                 bury_objs(x, y);
2609     return 0;
2610 }
2611 #endif /* DEBUG */
2612
2613 /*dig.c*/