OSDN Git Service

version++
[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 /*JP
1352                 multi_reason = "stuck in a spider web";
1353 */
1354                 multi_reason = "\82­\82à\82Ì\91\83\82É\95ß\82Ü\82Á\82Ä\82¢\82é\8aÔ\82É";
1355 /*JP
1356                 nomovemsg = "You pull free.";
1357 */
1358                 nomovemsg = "\82Ð\82«\82Í\82È\82µ\82½\81D";
1359             } else if (lev->typ == IRONBARS) {
1360 /*JP
1361                 pline("Clang!");
1362 */
1363                 pline("\83K\83c\83\93\81I");
1364                 wake_nearby();
1365             } else if (IS_TREE(lev->typ))
1366 /*JP
1367                 You("need an axe to cut down a tree.");
1368 */
1369                 You("\96Ø\82ð\90Ø\82é\82É\82Í\95\80\82ª\95K\97v\82¾\81D");
1370             else if (IS_ROCK(lev->typ))
1371 /*JP
1372                 You("need a pick to dig rock.");
1373 */
1374                 You("\8c@\82é\82É\82Í\82Â\82é\82Í\82µ\82ª\95K\97v\82¾\81D");
1375             else if (!ispick && (sobj_at(STATUE, rx, ry)
1376                                  || sobj_at(BOULDER, rx, ry))) {
1377                 boolean vibrate = !rn2(3);
1378 #if 0 /*JP:T*/
1379                 pline("Sparks fly as you whack the %s.%s",
1380                       sobj_at(STATUE, rx, ry) ? "statue" : "boulder",
1381                       vibrate ? " The axe-handle vibrates violently!" : "");
1382 #else
1383                 pline("%s\82ð\90Ø\82ë\82¤\82Æ\82µ\82½\82ç\89Î\89Ô\82ª\8eU\82Á\82½\81I%s",
1384                       sobj_at(STATUE, rx, ry) ? "\92¤\91\9c" : "\8aâ",
1385                       vibrate ? "\95\80\82Í\8c\83\82µ\82­\90U\93®\82µ\82½\81I" : "");
1386 #endif
1387                 if (vibrate)
1388 /*JP
1389                     losehp(Maybe_Half_Phys(2), "axing a hard object",
1390 */
1391                     losehp(Maybe_Half_Phys(2), "\8cÅ\82¢\82à\82Ì\82É\95\80\82ð\8eg\82¨\82¤\82Æ\82µ\82Ä",
1392                            KILLED_BY);
1393             } else if (u.utrap && u.utraptype == TT_PIT && trap
1394                        && (trap_with_u = t_at(u.ux, u.uy))
1395                        && (trap->ttyp == PIT || trap->ttyp == SPIKED_PIT)
1396                        && !conjoined_pits(trap, trap_with_u, FALSE)) {
1397                 int idx;
1398                 for (idx = 0; idx < 8; idx++) {
1399                     if (xdir[idx] == u.dx && ydir[idx] == u.dy)
1400                         break;
1401                 }
1402                 /* idx is valid if < 8 */
1403                 if (idx < 8) {
1404                     int adjidx = (idx + 4) % 8;
1405                     trap_with_u->conjoined |= (1 << idx);
1406                     trap->conjoined |= (1 << adjidx);
1407 /*JP
1408                     pline("You clear some debris from between the pits.");
1409 */
1410                     pline("\82 \82È\82½\82Í\97\8e\82µ\8c\8a\82Ì\8aÔ\82©\82ç\82²\82Ý\82ð\8eæ\82è\82Ì\82¼\82¢\82½\81D");
1411                 }
1412             } else if (u.utrap && u.utraptype == TT_PIT
1413                        && (trap_with_u = t_at(u.ux, u.uy))) {
1414 #if 0 /*JP*/
1415                 You("swing %s, but the rubble has no place to go.",
1416                     yobjnam(obj, (char *) 0));
1417 #else
1418                 You("%s\82ð\90U\82è\89ñ\82µ\82½\82ª\81C\94j\95Ð\82Ì\8ds\82«\8fê\8f\8a\82ª\82È\82¢\81D", xname(obj));
1419 #endif
1420             } else
1421 /*JP
1422                 You("swing %s through thin air.", yobjnam(obj, (char *) 0));
1423 */
1424                 You("\8bó\92\86\82Å%s\82ð\90U\82è\89ñ\82µ\82½\81D", xname(obj));
1425         } else {
1426 #if 0 /*JP*/
1427             static const char *const d_action[6] = { "swinging", "digging",
1428                                                      "chipping the statue",
1429                                                      "hitting the boulder",
1430                                                      "chopping at the door",
1431                                                      "cutting the tree" };
1432 #else
1433             static const char * const d_action1[6] = {
1434                 "\90U\82è",
1435                 "\8c@\82è",
1436                 "\92¤\91\9c\82ð\8dí\82è",
1437                 "\8aâ\82ð\91Å\82¿\82Â\82¯",
1438                 "\94à\82ð\8dí\82è",
1439                 "\96Ø\82ð\90Ø\82è"
1440               };
1441             static const char * const d_action2[6] = {
1442                 "\90U\82é",
1443                 "\8c@\82é",
1444                 "\92¤\91\9c\82ð\8dí\82é",
1445                 "\8aâ\82ð\91Å\82¿\82Â\82¯\82é",
1446                 "\94à\82ð\8dí\82é",
1447                 "\96Ø\82ð\90Ø\82é"
1448               };
1449 #endif
1450             did_dig_msg = FALSE;
1451             context.digging.quiet = FALSE;
1452             if (context.digging.pos.x != rx || context.digging.pos.y != ry
1453                 || !on_level(&context.digging.level, &u.uz)
1454                 || context.digging.down) {
1455                 if (flags.autodig && dig_target == DIGTYP_ROCK
1456                     && !context.digging.down && context.digging.pos.x == u.ux
1457                     && context.digging.pos.y == u.uy
1458                     && (moves <= context.digging.lastdigtime + 2
1459                         && moves >= context.digging.lastdigtime)) {
1460                     /* avoid messages if repeated autodigging */
1461                     did_dig_msg = TRUE;
1462                     context.digging.quiet = TRUE;
1463                 }
1464                 context.digging.down = context.digging.chew = FALSE;
1465                 context.digging.warned = FALSE;
1466                 context.digging.pos.x = rx;
1467                 context.digging.pos.y = ry;
1468                 assign_level(&context.digging.level, &u.uz);
1469                 context.digging.effort = 0;
1470                 if (!context.digging.quiet)
1471 /*JP
1472                     You("start %s.", d_action[dig_target]);
1473 */
1474                     You("%s\82Í\82\82ß\82½\81D", d_action1[dig_target]);
1475             } else {
1476 #if 0 /*JP*/
1477                 You("%s %s.", context.digging.chew ? "begin" : "continue",
1478                     d_action[dig_target]);
1479 #else
1480                 You("%s\82Ì\82ð%s\82µ\82½\81D", d_action2[dig_target],
1481                     context.digging.chew ? "\8aJ\8en" : "\8dÄ\8aJ");
1482 #endif
1483                 context.digging.chew = FALSE;
1484             }
1485             set_occupation(dig, verbing, 0);
1486         }
1487     } else if (Is_airlevel(&u.uz) || Is_waterlevel(&u.uz)) {
1488         /* it must be air -- water checked above */
1489 /*JP
1490         You("swing %s through thin air.", yobjnam(obj, (char *) 0));
1491 */
1492         You("\89½\82à\82È\82¢\8bó\8aÔ\82Å%s\82ð\90U\82è\82Ü\82í\82µ\82½\81D", xname(obj));
1493     } else if (!can_reach_floor(FALSE)) {
1494         cant_reach_floor(u.ux, u.uy, FALSE, FALSE);
1495     } else if (is_pool_or_lava(u.ux, u.uy)) {
1496         /* Monsters which swim also happen not to be able to dig */
1497 #if 0 /*JP:T*/
1498         You("cannot stay under%s long enough.",
1499             is_pool(u.ux, u.uy) ? "water" : " the lava");
1500 #else
1501         You("%s\82É\82Í\92·\8e\9e\8aÔ\82¢\82ç\82ê\82È\82¢\81D",
1502             is_pool(u.ux, u.uy) ? "\90\85\96Ê\89º" : "\97n\8aâ\82Ì\92\86");
1503 #endif
1504     } else if ((trap = t_at(u.ux, u.uy)) != 0
1505                && uteetering_at_seen_pit(trap)) {
1506         dotrap(trap, FORCEBUNGLE);
1507         /* might escape trap and still be teetering at brink */
1508         if (!u.utrap)
1509             cant_reach_floor(u.ux, u.uy, FALSE, TRUE);
1510     } else if (!ispick
1511                /* can only dig down with an axe when doing so will
1512                   trigger or disarm a trap here */
1513                && (!trap || (trap->ttyp != LANDMINE
1514                              && trap->ttyp != BEAR_TRAP))) {
1515 #if 0 /*JP:T*/
1516         pline("%s merely scratches the %s.", Yobjnam2(obj, (char *) 0),
1517               surface(u.ux, u.uy));
1518 #else
1519         Your("%s\82Í%s\82É\82©\82·\82è\8f\9d\82ð\82Â\82¯\82½\82¾\82¯\82¾\82Á\82½\81D", aobjnam(obj, (char *)0),
1520               surface(u.ux,u.uy));
1521 #endif
1522         u_wipe_engr(3);
1523     } else {
1524         if (context.digging.pos.x != u.ux || context.digging.pos.y != u.uy
1525             || !on_level(&context.digging.level, &u.uz)
1526             || !context.digging.down) {
1527             context.digging.chew = FALSE;
1528             context.digging.down = TRUE;
1529             context.digging.warned = FALSE;
1530             context.digging.pos.x = u.ux;
1531             context.digging.pos.y = u.uy;
1532             assign_level(&context.digging.level, &u.uz);
1533             context.digging.effort = 0;
1534 /*JP
1535             You("start %s downward.", verbing);
1536 */
1537             You("\89º\8cü\82«\82É\8c@\82è\82Í\82\82ß\82½\81D");
1538             if (*u.ushops)
1539                 shopdig(0);
1540         } else
1541 /*JP
1542             You("continue %s downward.", verbing);
1543 */
1544             You("\89º\8cü\82«\82É\8c@\82é\82Ì\82ð\8dÄ\8aJ\82µ\82½\81D");
1545         did_dig_msg = FALSE;
1546         set_occupation(dig, verbing, 0);
1547     }
1548     return 1;
1549 }
1550
1551 /*
1552  * Town Watchmen frown on damage to the town walls, trees or fountains.
1553  * It's OK to dig holes in the ground, however.
1554  * If mtmp is assumed to be a watchman, a watchman is found if mtmp == 0
1555  * zap == TRUE if wand/spell of digging, FALSE otherwise (chewing)
1556  */
1557 void
1558 watch_dig(mtmp, x, y, zap)
1559 struct monst *mtmp;
1560 xchar x, y;
1561 boolean zap;
1562 {
1563     struct rm *lev = &levl[x][y];
1564
1565     if (in_town(x, y)
1566         && (closed_door(x, y) || lev->typ == SDOOR || IS_WALL(lev->typ)
1567             || IS_FOUNTAIN(lev->typ) || IS_TREE(lev->typ))) {
1568         if (!mtmp) {
1569             for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
1570                 if (DEADMONSTER(mtmp))
1571                     continue;
1572                 if (is_watch(mtmp->data) && mtmp->mcansee && m_canseeu(mtmp)
1573                     && couldsee(mtmp->mx, mtmp->my) && mtmp->mpeaceful)
1574                     break;
1575             }
1576         }
1577
1578         if (mtmp) {
1579             if (zap || context.digging.warned) {
1580 /*JP
1581                 verbalize("Halt, vandal!  You're under arrest!");
1582 */
1583                 verbalize("\8e~\82Ü\82ê\96ì\94Ø\90l\81I\82¨\82Ü\82¦\82ð\91ß\95ß\82·\82é\81I");
1584                 (void) angry_guards(!!Deaf);
1585             } else {
1586                 const char *str;
1587
1588                 if (IS_DOOR(lev->typ))
1589 /*JP
1590                     str = "door";
1591 */
1592                     str = "\94à";
1593                 else if (IS_TREE(lev->typ))
1594 /*JP
1595                     str = "tree";
1596 */
1597                     str = "\96Ø";
1598                 else if (IS_ROCK(lev->typ))
1599 /*JP
1600                     str = "wall";
1601 */
1602                     str = "\95Ç";
1603                 else
1604 /*JP
1605                     str = "fountain";
1606 */
1607                     str = "\90ò";
1608 /*JP
1609                 verbalize("Hey, stop damaging that %s!", str);
1610 */
1611                 verbalize("\82¨\82¢\81C%s\82ð\94j\89ó\82·\82é\82Ì\82ð\82â\82ß\82ë\81I", str);
1612                 context.digging.warned = TRUE;
1613             }
1614             if (is_digging())
1615                 stop_occupation();
1616         }
1617     }
1618 }
1619
1620 /* Return TRUE if monster died, FALSE otherwise.  Called from m_move(). */
1621 boolean
1622 mdig_tunnel(mtmp)
1623 register struct monst *mtmp;
1624 {
1625     register struct rm *here;
1626     int pile = rnd(12);
1627
1628     here = &levl[mtmp->mx][mtmp->my];
1629     if (here->typ == SDOOR)
1630         cvt_sdoor_to_door(here); /* ->typ = DOOR */
1631
1632     /* Eats away door if present & closed or locked */
1633     if (closed_door(mtmp->mx, mtmp->my)) {
1634         if (*in_rooms(mtmp->mx, mtmp->my, SHOPBASE))
1635             add_damage(mtmp->mx, mtmp->my, 0L);
1636         unblock_point(mtmp->mx, mtmp->my); /* vision */
1637         if (here->doormask & D_TRAPPED) {
1638             here->doormask = D_NODOOR;
1639             if (mb_trapped(mtmp)) { /* mtmp is killed */
1640                 newsym(mtmp->mx, mtmp->my);
1641                 return TRUE;
1642             }
1643         } else {
1644             if (!rn2(3) && flags.verbose) /* not too often.. */
1645                 draft_message(TRUE); /* "You feel an unexpected draft." */
1646             here->doormask = D_BROKEN;
1647         }
1648         newsym(mtmp->mx, mtmp->my);
1649         return FALSE;
1650     } else if (here->typ == SCORR) {
1651         here->typ = CORR;
1652         unblock_point(mtmp->mx, mtmp->my);
1653         newsym(mtmp->mx, mtmp->my);
1654         draft_message(FALSE); /* "You feel a draft." */
1655         return FALSE;
1656     } else if (!IS_ROCK(here->typ) && !IS_TREE(here->typ)) /* no dig */
1657         return FALSE;
1658
1659     /* Only rock, trees, and walls fall through to this point. */
1660     if ((here->wall_info & W_NONDIGGABLE) != 0) {
1661         impossible("mdig_tunnel:  %s at (%d,%d) is undiggable",
1662                    (IS_WALL(here->typ) ? "wall"
1663                     : IS_TREE(here->typ) ? "tree" : "stone"),
1664                    (int) mtmp->mx, (int) mtmp->my);
1665         return FALSE; /* still alive */
1666     }
1667
1668     if (IS_WALL(here->typ)) {
1669         /* KMH -- Okay on arboreal levels (room walls are still stone) */
1670         if (flags.verbose && !rn2(5))
1671 /*JP
1672             You_hear("crashing rock.");
1673 */
1674             You_hear("\8aâ\82Ì\82­\82¾\82¯\82é\89¹\82ð\95·\82¢\82½\81D");
1675         if (*in_rooms(mtmp->mx, mtmp->my, SHOPBASE))
1676             add_damage(mtmp->mx, mtmp->my, 0L);
1677         if (level.flags.is_maze_lev) {
1678             here->typ = ROOM;
1679         } else if (level.flags.is_cavernous_lev
1680                    && !in_town(mtmp->mx, mtmp->my)) {
1681             here->typ = CORR;
1682         } else {
1683             here->typ = DOOR;
1684             here->doormask = D_NODOOR;
1685         }
1686     } else if (IS_TREE(here->typ)) {
1687         here->typ = ROOM;
1688         if (pile && pile < 5)
1689             (void) rnd_treefruit_at(mtmp->mx, mtmp->my);
1690     } else {
1691         here->typ = CORR;
1692         if (pile && pile < 5)
1693             (void) mksobj_at((pile == 1) ? BOULDER : ROCK, mtmp->mx, mtmp->my,
1694                              TRUE, FALSE);
1695     }
1696     newsym(mtmp->mx, mtmp->my);
1697     if (!sobj_at(BOULDER, mtmp->mx, mtmp->my))
1698         unblock_point(mtmp->mx, mtmp->my); /* vision */
1699
1700     return FALSE;
1701 }
1702
1703 #define STRIDENT 4 /* from pray.c */
1704
1705 /* draft refers to air currents, but can be a pun on "draft" as conscription
1706    for military service (probably not a good pun if it has to be explained) */
1707 void
1708 draft_message(unexpected)
1709 boolean unexpected;
1710 {
1711     /*
1712      * [Bug or TODO?  Have caller pass coordinates and use the travel
1713      * mechanism to determine whether there is a path between
1714      * destroyed door (or exposed secret corridor) and hero's location.
1715      * When there is no such path, no draft should be felt.]
1716      */
1717
1718     if (unexpected) {
1719         if (!Hallucination)
1720 /*JP
1721             You_feel("an unexpected draft.");
1722 */
1723             You("\8ev\82¢\82à\82æ\82ç\82¸\81C\82·\82«\82Ü\95\97\82ð\8a´\82\82½\81D");
1724         else
1725             /* U.S. classification system uses 1-A for eligible to serve
1726                and 4-F for ineligible due to physical or mental defect;
1727                some intermediate values exist but are rarely seen */
1728 #if 0 /*JP*/
1729             You_feel("like you are %s.",
1730                      (ACURR(A_STR) < 6 || ACURR(A_DEX) < 6
1731                       || ACURR(A_CON) < 6 || ACURR(A_CHA) < 6
1732                       || ACURR(A_INT) < 6 || ACURR(A_WIS) < 6) ? "4-F"
1733                                                                : "1-A");
1734 #else
1735             You("\93Ë\91R\90\99\97Ç\91¾\98Y\82ð\8ev\82¢\8fo\82µ\82½\81D");
1736 #endif
1737     } else {
1738         if (!Hallucination) {
1739 /*JP
1740             You_feel("a draft.");
1741 */
1742             You_feel("\82·\82«\82Ü\95\97\82ð\8a´\82\82½\81D");
1743         } else {
1744 #if 0 /*JP*//*"draft"=\81u\92¥\95º\81v*/
1745             /* "marching" is deliberately ambiguous; it might mean drills
1746                 after entering military service or mean engaging in protests */
1747             static const char *draft_reaction[] = {
1748                 "enlisting", "marching", "protesting", "fleeing",
1749             };
1750             int dridx;
1751
1752             /* Lawful: 0..1, Neutral: 1..2, Chaotic: 2..3 */
1753             dridx = rn1(2, 1 - sgn(u.ualign.type));
1754             if (u.ualign.record < STRIDENT)
1755                 /* L: +(0..2), N: +(-1..1), C: +(-2..0); all: 0..3 */
1756                 dridx += rn1(3, sgn(u.ualign.type) - 1);
1757             You_feel("like %s.", draft_reaction[dridx]);
1758 #else /*JP:\93ú\96{\8cê\82Å\82Í\8bÃ\82Á\82½\82±\82Æ\82Í\82µ\82È\82¢*/
1759             You("\90\99\97Ç\91¾\98Y\82ð\8ev\82¢\8fo\82µ\82½\81D");
1760 #endif
1761         }
1762     }
1763 }
1764
1765 /* digging via wand zap or spell cast */
1766 void
1767 zap_dig()
1768 {
1769     struct rm *room;
1770     struct monst *mtmp;
1771     struct obj *otmp;
1772     struct trap *trap_with_u = (struct trap *) 0;
1773     int zx, zy, diridx = 8, digdepth, flow_x = -1, flow_y = -1;
1774     boolean shopdoor, shopwall, maze_dig, pitdig = FALSE, pitflow = FALSE;
1775
1776     /*
1777      * Original effect (approximately):
1778      * from CORR: dig until we pierce a wall
1779      * from ROOM: pierce wall and dig until we reach
1780      * an ACCESSIBLE place.
1781      * Currently: dig for digdepth positions;
1782      * also down on request of Lennart Augustsson.
1783      * 3.6.0: from a PIT: dig one adjacent pit.
1784      */
1785
1786     if (u.uswallow) {
1787         mtmp = u.ustuck;
1788
1789         if (!is_whirly(mtmp->data)) {
1790             if (is_animal(mtmp->data))
1791 #if 0 /*JP*/
1792                 You("pierce %s %s wall!", s_suffix(mon_nam(mtmp)),
1793                     mbodypart(mtmp, STOMACH));
1794 #else
1795                 You("%s\82Ì%s\82Ì\95Ç\82É\8c\8a\82ð\8aJ\82¯\82½\81I", s_suffix(mon_nam(mtmp)),
1796                     mbodypart(mtmp, STOMACH));
1797 #endif
1798             mtmp->mhp = 1; /* almost dead */
1799             expels(mtmp, mtmp->data, !is_animal(mtmp->data));
1800         }
1801         return;
1802     } /* swallowed */
1803
1804     if (u.dz) {
1805         if (!Is_airlevel(&u.uz) && !Is_waterlevel(&u.uz) && !Underwater) {
1806             if (u.dz < 0 || On_stairs(u.ux, u.uy)) {
1807                 int dmg;
1808                 if (On_stairs(u.ux, u.uy))
1809 #if 0 /*JP*/
1810                     pline_The("beam bounces off the %s and hits the %s.",
1811                               (u.ux == xdnladder || u.ux == xupladder)
1812                                   ? "ladder"
1813                                   : "stairs",
1814                               ceiling(u.ux, u.uy));
1815 #else
1816                     pline("\8cõ\90ü\82Í%s\82Å\94½\8eË\82µ%s\82É\96½\92\86\82µ\82½\81D",
1817                               (u.ux == xdnladder || u.ux == xupladder)
1818                                   ? "\82Í\82µ\82²"
1819                                   : "\8aK\92i",
1820                               ceiling(u.ux, u.uy));
1821 #endif
1822 /*JP
1823                 You("loosen a rock from the %s.", ceiling(u.ux, u.uy));
1824 */
1825                 pline("%s\82Ì\8aâ\82ª\83K\83^\83K\83^\82µ\82Í\82\82ß\82½\81D", ceiling(u.ux, u.uy));
1826 /*JP
1827                 pline("It falls on your %s!", body_part(HEAD));
1828 */
1829                 pline("\82»\82ê\82Í\82 \82È\82½\82Ì%s\82É\97\8e\82¿\82Ä\82«\82½\81I", body_part(HEAD));
1830                 dmg = rnd((uarmh && is_metallic(uarmh)) ? 2 : 6);
1831 /*JP
1832                 losehp(Maybe_Half_Phys(dmg), "falling rock", KILLED_BY_AN);
1833 */
1834                 losehp(Maybe_Half_Phys(dmg), "\97\8e\8aâ\82Å", KILLED_BY_AN);
1835                 otmp = mksobj_at(ROCK, u.ux, u.uy, FALSE, FALSE);
1836                 if (otmp) {
1837                     (void) xname(otmp); /* set dknown, maybe bknown */
1838                     stackobj(otmp);
1839                 }
1840                 newsym(u.ux, u.uy);
1841             } else {
1842                 watch_dig((struct monst *) 0, u.ux, u.uy, TRUE);
1843                 (void) dighole(FALSE, TRUE, (coord *) 0);
1844             }
1845         }
1846         return;
1847     } /* up or down */
1848
1849     /* normal case: digging across the level */
1850     shopdoor = shopwall = FALSE;
1851     maze_dig = level.flags.is_maze_lev && !Is_earthlevel(&u.uz);
1852     zx = u.ux + u.dx;
1853     zy = u.uy + u.dy;
1854     if (u.utrap && u.utraptype == TT_PIT
1855         && (trap_with_u = t_at(u.ux, u.uy))) {
1856         pitdig = TRUE;
1857         for (diridx = 0; diridx < 8; diridx++) {
1858             if (xdir[diridx] == u.dx && ydir[diridx] == u.dy)
1859                 break;
1860             /* diridx is valid if < 8 */
1861         }
1862     }
1863     digdepth = rn1(18, 8);
1864     tmp_at(DISP_BEAM, cmap_to_glyph(S_digbeam));
1865     while (--digdepth >= 0) {
1866         if (!isok(zx, zy))
1867             break;
1868         room = &levl[zx][zy];
1869         tmp_at(zx, zy);
1870         delay_output(); /* wait a little bit */
1871
1872         if (pitdig) { /* we are already in a pit if this is true */
1873             coord cc;
1874             struct trap *adjpit = t_at(zx, zy);
1875             if ((diridx < 8) && !conjoined_pits(adjpit, trap_with_u, FALSE)) {
1876                 digdepth = 0; /* limited to the adjacent location only */
1877                 if (!(adjpit && (adjpit->ttyp == PIT
1878                                  || adjpit->ttyp == SPIKED_PIT))) {
1879                     char buf[BUFSZ];
1880                     cc.x = zx;
1881                     cc.y = zy;
1882                     if (!adj_pit_checks(&cc, buf)) {
1883                         if (buf[0])
1884                             pline1(buf);
1885                     } else {
1886                         /* this can also result in a pool at zx,zy */
1887                         dighole(TRUE, TRUE, &cc);
1888                         adjpit = t_at(zx, zy);
1889                     }
1890                 }
1891                 if (adjpit
1892                     && (adjpit->ttyp == PIT || adjpit->ttyp == SPIKED_PIT)) {
1893                     int adjidx = (diridx + 4) % 8;
1894                     trap_with_u->conjoined |= (1 << diridx);
1895                     adjpit->conjoined |= (1 << adjidx);
1896                     flow_x = zx;
1897                     flow_y = zy;
1898                     pitflow = TRUE;
1899                 }
1900                 if (is_pool(zx, zy) || is_lava(zx, zy)) {
1901                     flow_x = zx - u.dx;
1902                     flow_y = zy - u.dy;
1903                     pitflow = TRUE;
1904                 }
1905                 break;
1906             }
1907         } else if (closed_door(zx, zy) || room->typ == SDOOR) {
1908             if (*in_rooms(zx, zy, SHOPBASE)) {
1909                 add_damage(zx, zy, 400L);
1910                 shopdoor = TRUE;
1911             }
1912             if (room->typ == SDOOR)
1913                 room->typ = DOOR;
1914             else if (cansee(zx, zy))
1915 /*JP
1916                 pline_The("door is razed!");
1917 */
1918                 pline("\94à\82Í\95ö\82ê\97\8e\82¿\82½\81I");
1919             watch_dig((struct monst *) 0, zx, zy, TRUE);
1920             room->doormask = D_NODOOR;
1921             unblock_point(zx, zy); /* vision */
1922             digdepth -= 2;
1923             if (maze_dig)
1924                 break;
1925         } else if (maze_dig) {
1926             if (IS_WALL(room->typ)) {
1927                 if (!(room->wall_info & W_NONDIGGABLE)) {
1928                     if (*in_rooms(zx, zy, SHOPBASE)) {
1929                         add_damage(zx, zy, 200L);
1930                         shopwall = TRUE;
1931                     }
1932                     room->typ = ROOM;
1933                     unblock_point(zx, zy); /* vision */
1934                 } else if (!Blind)
1935 /*JP
1936                     pline_The("wall glows then fades.");
1937 */
1938                     pline("\95Ç\82Í\88ê\8fu\8bP\82¢\82½\81D");
1939                 break;
1940             } else if (IS_TREE(room->typ)) { /* check trees before stone */
1941                 if (!(room->wall_info & W_NONDIGGABLE)) {
1942                     room->typ = ROOM;
1943                     unblock_point(zx, zy); /* vision */
1944                 } else if (!Blind)
1945 /*JP
1946                     pline_The("tree shudders but is unharmed.");
1947 */
1948                     pline("\96Ø\82Í\82ä\82ê\82½\82ª\8f\9d\82Â\82©\82È\82©\82Á\82½\81D");
1949                 break;
1950             } else if (room->typ == STONE || room->typ == SCORR) {
1951                 if (!(room->wall_info & W_NONDIGGABLE)) {
1952                     room->typ = CORR;
1953                     unblock_point(zx, zy); /* vision */
1954                 } else if (!Blind)
1955 /*JP
1956                     pline_The("rock glows then fades.");
1957 */
1958                     pline("\90Î\82Í\88ê\8fu\8bP\82¢\82½\81D");
1959                 break;
1960             }
1961         } else if (IS_ROCK(room->typ)) {
1962             if (!may_dig(zx, zy))
1963                 break;
1964             if (IS_WALL(room->typ) || room->typ == SDOOR) {
1965                 if (*in_rooms(zx, zy, SHOPBASE)) {
1966                     add_damage(zx, zy, 200L);
1967                     shopwall = TRUE;
1968                 }
1969                 watch_dig((struct monst *) 0, zx, zy, TRUE);
1970                 if (level.flags.is_cavernous_lev && !in_town(zx, zy)) {
1971                     room->typ = CORR;
1972                 } else {
1973                     room->typ = DOOR;
1974                     room->doormask = D_NODOOR;
1975                 }
1976                 digdepth -= 2;
1977             } else if (IS_TREE(room->typ)) {
1978                 room->typ = ROOM;
1979                 digdepth -= 2;
1980             } else { /* IS_ROCK but not IS_WALL or SDOOR */
1981                 room->typ = CORR;
1982                 digdepth--;
1983             }
1984             unblock_point(zx, zy); /* vision */
1985         }
1986         zx += u.dx;
1987         zy += u.dy;
1988     }                    /* while */
1989     tmp_at(DISP_END, 0); /* closing call */
1990
1991     if (pitflow && isok(flow_x, flow_y)) {
1992         struct trap *ttmp = t_at(flow_x, flow_y);
1993         if (ttmp && (ttmp->ttyp == PIT || ttmp->ttyp == SPIKED_PIT)) {
1994             schar filltyp = fillholetyp(ttmp->tx, ttmp->ty, TRUE);
1995             if (filltyp != ROOM)
1996                 pit_flow(ttmp, filltyp);
1997         }
1998     }
1999
2000     if (shopdoor || shopwall)
2001 /*JP
2002         pay_for_damage(shopdoor ? "destroy" : "dig into", FALSE);
2003 */
2004         pay_for_damage(shopdoor ? "\94j\89ó\82·\82é" : "\8c\8a\82ð\82 \82¯\82é", FALSE);
2005     return;
2006 }
2007
2008 /*
2009  * This checks what is on the surface above the
2010  * location where an adjacent pit might be created if
2011  * you're zapping a wand of digging laterally while
2012  * down in the pit.
2013  */
2014 STATIC_OVL int
2015 adj_pit_checks(cc, msg)
2016 coord *cc;
2017 char *msg;
2018 {
2019     int ltyp;
2020     struct rm *room;
2021     const char *foundation_msg =
2022 /*JP
2023         "The foundation is too hard to dig through from this angle.";
2024 */
2025         "\8aî\91b\82Í\82±\82Ì\8ap\93x\82©\82ç\8c@\82é\82É\82Í\8cÅ\82·\82¬\82é\81D";
2026
2027     if (!cc)
2028         return FALSE;
2029     if (!isok(cc->x, cc->y))
2030         return FALSE;
2031     *msg = '\0';
2032     room = &levl[cc->x][cc->y];
2033     ltyp = room->typ;
2034
2035     if (is_pool(cc->x, cc->y) || is_lava(cc->x, cc->y)) {
2036         /* this is handled by the caller after we return FALSE */
2037         return FALSE;
2038     } else if (closed_door(cc->x, cc->y) || room->typ == SDOOR) {
2039         /* We reject this here because dighole() isn't
2040            prepared to deal with this case */
2041         Strcpy(msg, foundation_msg);
2042         return FALSE;
2043     } else if (IS_WALL(ltyp)) {
2044         /* if (room->wall_info & W_NONDIGGABLE) */
2045         Strcpy(msg, foundation_msg);
2046         return FALSE;
2047     } else if (IS_TREE(ltyp)) { /* check trees before stone */
2048         /* if (room->wall_info & W_NONDIGGABLE) */
2049 /*JP
2050         Strcpy(msg, "The tree's roots glow then fade.");
2051 */
2052         Strcpy(msg, "\96Ø\82Ì\8dª\82Í\88ê\8fu\8bP\82¢\82½\81D");
2053         return FALSE;
2054     } else if (ltyp == STONE || ltyp == SCORR) {
2055         if (room->wall_info & W_NONDIGGABLE) {
2056 /*JP
2057             Strcpy(msg, "The rock glows then fades.");
2058 */
2059             Strcpy(msg, "\90Î\82Í\88ê\8fu\8bP\82¢\82½\81D");
2060             return FALSE;
2061         }
2062     } else if (ltyp == IRONBARS) {
2063         /* "set of iron bars" */
2064 /*JP
2065         Strcpy(msg, "The bars go much deeper than your pit.");
2066 */
2067         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");
2068 #if 0
2069     } else if (is_lava(cc->x, cc->y)) {
2070     } else if (is_ice(cc->x, cc->y)) {
2071     } else if (is_pool(cc->x, cc->y)) {
2072     } else if (IS_GRAVE(ltyp)) {
2073 #endif
2074     } else if (IS_SINK(ltyp)) {
2075 /*JP
2076         Strcpy(msg, "A tangled mass of plumbing remains below the sink.");
2077 */
2078         Strcpy(msg, "\93ü\82è\91g\82ñ\82¾\94z\8aÇ\82ª\97¬\82µ\91ä\82Ì\89º\82É\8ec\82Á\82½\82Ü\82Ü\82¾\81D");
2079         return FALSE;
2080     } else if ((cc->x == xupladder && cc->y == yupladder) /* ladder up */
2081                || (cc->x == xdnladder && cc->y == ydnladder)) { /* " down */
2082 /*JP
2083         Strcpy(msg, "The ladder is unaffected.");
2084 */
2085         Strcpy(msg, "\82Í\82µ\82²\82Í\89e\8b¿\82ð\8eó\82¯\82È\82¢\81D");
2086         return FALSE;
2087     } else {
2088         const char *supporting = (const char *) 0;
2089
2090         if (IS_FOUNTAIN(ltyp))
2091 /*JP
2092             supporting = "fountain";
2093 */
2094             supporting = "\90ò";
2095         else if (IS_THRONE(ltyp))
2096 /*JP
2097             supporting = "throne";
2098 */
2099             supporting = "\8bÊ\8dÀ";
2100         else if (IS_ALTAR(ltyp))
2101 /*JP
2102             supporting = "altar";
2103 */
2104             supporting = "\8dÕ\92d";
2105         else if ((cc->x == xupstair && cc->y == yupstair)
2106                  || (cc->x == sstairs.sx && cc->y == sstairs.sy
2107                      && sstairs.up))
2108             /* "staircase up" */
2109 /*JP
2110             supporting = "stairs";
2111 */
2112             supporting = "\8aK\92i";
2113         else if ((cc->x == xdnstair && cc->y == ydnstair)
2114                  || (cc->x == sstairs.sx && cc->y == sstairs.sy
2115                      && !sstairs.up))
2116             /* "staircase down" */
2117 /*JP
2118             supporting = "stairs";
2119 */
2120             supporting = "\8aK\92i";
2121         else if (ltyp == DRAWBRIDGE_DOWN   /* "lowered drawbridge" */
2122                  || ltyp == DBWALL)        /* "raised drawbridge" */
2123 /*JP
2124             supporting = "drawbridge";
2125 */
2126             supporting = "\92µ\82Ë\8b´";
2127
2128         if (supporting) {
2129 #if 0 /*JP*/
2130             Sprintf(msg, "The %s%ssupporting structures remain intact.",
2131                     supporting ? s_suffix(supporting) : "",
2132                     supporting ? " " : "");
2133 #else
2134             Sprintf(msg, "%s%s\8ex\82¦\82Ä\82¢\82é\95\94\95ª\82Í\82»\82Ì\82Ü\82Ü\82¾\81D",
2135                     supporting ? supporting : "",
2136                     supporting ? "\82ð" : "");
2137 #endif
2138             return FALSE;
2139         }
2140     }
2141     return TRUE;
2142 }
2143
2144 /*
2145  * Ensure that all conjoined pits fill up.
2146  */
2147 STATIC_OVL void
2148 pit_flow(trap, filltyp)
2149 struct trap *trap;
2150 schar filltyp;
2151 {
2152     if (trap && (filltyp != ROOM)
2153         && (trap->ttyp == PIT || trap->ttyp == SPIKED_PIT)) {
2154         struct trap t;
2155         int idx;
2156
2157         t = *trap;
2158         levl[trap->tx][trap->ty].typ = filltyp;
2159         liquid_flow(trap->tx, trap->ty, filltyp, trap,
2160                     (trap->tx == u.ux && trap->ty == u.uy)
2161 /*JP
2162                         ? "Suddenly %s flows in from the adjacent pit!"
2163 */
2164                         ? "\93Ë\91R\97×\82Ì\97\8e\82µ\8c\8a\82©\82ç%s\82ª\97¬\82ê\8d\9e\82ñ\82Å\82«\82½\81I"
2165                         : (char *) 0);
2166         for (idx = 0; idx < 8; ++idx) {
2167             if (t.conjoined & (1 << idx)) {
2168                 int x, y;
2169                 struct trap *t2;
2170
2171                 x = t.tx + xdir[idx];
2172                 y = t.ty + ydir[idx];
2173                 t2 = t_at(x, y);
2174 #if 0
2175                 /* cannot do this back-check; liquid_flow()
2176                  * called deltrap() which cleaned up the
2177                  * conjoined fields on both pits.
2178                  */
2179                 if (t2 && (t2->conjoined & (1 << ((idx + 4) % 8))))
2180 #endif
2181                 /* recursion */
2182                 pit_flow(t2, filltyp);
2183             }
2184         }
2185     }
2186 }
2187
2188 struct obj *
2189 buried_ball(cc)
2190 coord *cc;
2191 {
2192     xchar check_x, check_y;
2193     struct obj *otmp, *otmp2;
2194
2195     if (u.utraptype == TT_BURIEDBALL)
2196         for (otmp = level.buriedobjlist; otmp; otmp = otmp2) {
2197             otmp2 = otmp->nobj;
2198             if (otmp->otyp != HEAVY_IRON_BALL)
2199                 continue;
2200             /* try the exact location first */
2201             if (otmp->ox == cc->x && otmp->oy == cc->y)
2202                 return otmp;
2203             /* Now try the vicinity */
2204             /*
2205              * (x-2,y-2)       (x+2,y-2)
2206              *           (x,y)
2207              * (x-2,y+2)       (x+2,y+2)
2208              */
2209             for (check_x = cc->x - 2; check_x <= cc->x + 2; ++check_x)
2210                 for (check_y = cc->y - 2; check_y <= cc->y + 2; ++check_y) {
2211                     if (check_x == cc->x && check_y == cc->y)
2212                         continue;
2213                     if (isok(check_x, check_y)
2214                         && (otmp->ox == check_x && otmp->oy == check_y)) {
2215                         cc->x = check_x;
2216                         cc->y = check_y;
2217                         return otmp;
2218                     }
2219                 }
2220         }
2221     return (struct obj *) 0;
2222 }
2223
2224 void
2225 buried_ball_to_punishment()
2226 {
2227     coord cc;
2228     struct obj *ball;
2229     cc.x = u.ux;
2230     cc.y = u.uy;
2231     ball = buried_ball(&cc);
2232     if (ball) {
2233         obj_extract_self(ball);
2234 #if 0
2235         /* rusting buried metallic objects is not implemented yet */
2236         if (ball->timed)
2237             (void) stop_timer(RUST_METAL, obj_to_any(ball));
2238 #endif
2239         punish(ball); /* use ball as flag for unearthed buried ball */
2240         u.utrap = 0;
2241         u.utraptype = 0;
2242         del_engr_at(cc.x, cc.y);
2243         newsym(cc.x, cc.y);
2244     }
2245 }
2246
2247 void
2248 buried_ball_to_freedom()
2249 {
2250     coord cc;
2251     struct obj *ball;
2252     cc.x = u.ux;
2253     cc.y = u.uy;
2254     ball = buried_ball(&cc);
2255     if (ball) {
2256         obj_extract_self(ball);
2257 #if 0
2258         /* rusting buried metallic objects is not implemented yet */
2259         if (ball->timed)
2260             (void) stop_timer(RUST_METAL, obj_to_any(ball));
2261 #endif
2262         place_object(ball, cc.x, cc.y);
2263         stackobj(ball);
2264         u.utrap = 0;
2265         u.utraptype = 0;
2266         del_engr_at(cc.x, cc.y);
2267         newsym(cc.x, cc.y);
2268     }
2269 }
2270
2271 /* move objects from fobj/nexthere lists to buriedobjlist, keeping position
2272    information */
2273 struct obj *
2274 bury_an_obj(otmp, dealloced)
2275 struct obj *otmp;
2276 boolean *dealloced;
2277 {
2278     struct obj *otmp2;
2279     boolean under_ice;
2280
2281     debugpline1("bury_an_obj: %s", xname(otmp));
2282     if (dealloced)
2283         *dealloced = FALSE;
2284     if (otmp == uball) {
2285         unpunish();
2286         u.utrap = rn1(50, 20);
2287         u.utraptype = TT_BURIEDBALL;
2288 /*JP
2289         pline_The("iron ball gets buried!");
2290 */
2291         pline_The("\93S\82Ì\8b\85\82Í\96\84\82Ü\82Á\82½\81I");
2292     }
2293     /* after unpunish(), or might get deallocated chain */
2294     otmp2 = otmp->nexthere;
2295     /*
2296      * obj_resists(,0,0) prevents Rider corpses from being buried.
2297      * It also prevents The Amulet and invocation tools from being
2298      * buried.  Since they can't be confined to bags and statues,
2299      * it makes sense that they can't be buried either, even though
2300      * the real reason there (direct accessibility when carried) is
2301      * completely different.
2302      */
2303     if (otmp == uchain || obj_resists(otmp, 0, 0))
2304         return otmp2;
2305
2306     if (otmp->otyp == LEASH && otmp->leashmon != 0)
2307         o_unleash(otmp);
2308
2309     if (otmp->lamplit && otmp->otyp != POT_OIL)
2310         end_burn(otmp, TRUE);
2311
2312     obj_extract_self(otmp);
2313
2314     under_ice = is_ice(otmp->ox, otmp->oy);
2315     if (otmp->otyp == ROCK && !under_ice) {
2316         /* merges into burying material */
2317         if (dealloced)
2318             *dealloced = TRUE;
2319         obfree(otmp, (struct obj *) 0);
2320         return otmp2;
2321     }
2322     /*
2323      * Start a rot on organic material.  Not corpses -- they
2324      * are already handled.
2325      */
2326     if (otmp->otyp == CORPSE) {
2327         ; /* should cancel timer if under_ice */
2328     } else if ((under_ice ? otmp->oclass == POTION_CLASS : is_organic(otmp))
2329                && !obj_resists(otmp, 5, 95)) {
2330         (void) start_timer((under_ice ? 0L : 250L) + (long) rnd(250),
2331                            TIMER_OBJECT, ROT_ORGANIC, obj_to_any(otmp));
2332 #if 0
2333     /* rusting of buried metal not yet implemented */
2334     } else if (is_rustprone(otmp)) {
2335         (void) start_timer((long) rnd((otmp->otyp == HEAVY_IRON_BALL)
2336                                          ? 1500
2337                                          : 250),
2338                            TIMER_OBJECT, RUST_METAL, obj_to_any(otmp));
2339 #endif
2340     }
2341     add_to_buried(otmp);
2342     return  otmp2;
2343 }
2344
2345 void
2346 bury_objs(x, y)
2347 int x, y;
2348 {
2349     struct obj *otmp, *otmp2;
2350
2351     if (level.objects[x][y] != (struct obj *) 0) {
2352         debugpline2("bury_objs: at <%d,%d>", x, y);
2353     }
2354     for (otmp = level.objects[x][y]; otmp; otmp = otmp2)
2355         otmp2 = bury_an_obj(otmp, (boolean *) 0);
2356
2357     /* don't expect any engravings here, but just in case */
2358     del_engr_at(x, y);
2359     newsym(x, y);
2360 }
2361
2362 /* move objects from buriedobjlist to fobj/nexthere lists */
2363 void
2364 unearth_objs(x, y)
2365 int x, y;
2366 {
2367     struct obj *otmp, *otmp2, *bball;
2368     coord cc;
2369
2370     debugpline2("unearth_objs: at <%d,%d>", x, y);
2371     cc.x = x;
2372     cc.y = y;
2373     bball = buried_ball(&cc);
2374     for (otmp = level.buriedobjlist; otmp; otmp = otmp2) {
2375         otmp2 = otmp->nobj;
2376         if (otmp->ox == x && otmp->oy == y) {
2377             if (bball && otmp == bball && u.utraptype == TT_BURIEDBALL) {
2378                 buried_ball_to_punishment();
2379             } else {
2380                 obj_extract_self(otmp);
2381                 if (otmp->timed)
2382                     (void) stop_timer(ROT_ORGANIC, obj_to_any(otmp));
2383                 place_object(otmp, x, y);
2384                 stackobj(otmp);
2385             }
2386         }
2387     }
2388     del_engr_at(x, y);
2389     newsym(x, y);
2390 }
2391
2392 /*
2393  * The organic material has rotted away while buried.  As an expansion,
2394  * we could add add partial damage.  A damage count is kept in the object
2395  * and every time we are called we increment the count and reschedule another
2396  * timeout.  Eventually the object rots away.
2397  *
2398  * This is used by buried objects other than corpses.  When a container rots
2399  * away, any contents become newly buried objects.
2400  */
2401 /* ARGSUSED */
2402 void
2403 rot_organic(arg, timeout)
2404 anything *arg;
2405 long timeout UNUSED;
2406 {
2407     struct obj *obj = arg->a_obj;
2408
2409     while (Has_contents(obj)) {
2410         /* We don't need to place contained object on the floor
2411            first, but we do need to update its map coordinates. */
2412         obj->cobj->ox = obj->ox, obj->cobj->oy = obj->oy;
2413         /* Everything which can be held in a container can also be
2414            buried, so bury_an_obj's use of obj_extract_self insures
2415            that Has_contents(obj) will eventually become false. */
2416         (void) bury_an_obj(obj->cobj, (boolean *) 0);
2417     }
2418     obj_extract_self(obj);
2419     obfree(obj, (struct obj *) 0);
2420 }
2421
2422 /*
2423  * Called when a corpse has rotted completely away.
2424  */
2425 void
2426 rot_corpse(arg, timeout)
2427 anything *arg;
2428 long timeout;
2429 {
2430     xchar x = 0, y = 0;
2431     struct obj *obj = arg->a_obj;
2432     boolean on_floor = obj->where == OBJ_FLOOR,
2433             in_invent = obj->where == OBJ_INVENT;
2434
2435     if (on_floor) {
2436         x = obj->ox;
2437         y = obj->oy;
2438     } else if (in_invent) {
2439         if (flags.verbose) {
2440             char *cname = corpse_xname(obj, (const char *) 0, CXN_NO_PFX);
2441
2442 #if 0 /*JP:T*/
2443             Your("%s%s %s away%c", obj == uwep ? "wielded " : "", cname,
2444                  otense(obj, "rot"), obj == uwep ? '!' : '.');
2445 #else
2446             pline("\82 \82È\82½\82Ì%s%s\82Í\95\85\82Á\82Ä\82µ\82Ü\82Á\82½%s",
2447                      obj == uwep ? "\8eè\82É\82µ\82Ä\82¢\82é" : "", cname,
2448                      obj == uwep ? "\81I" : "\81D");
2449 #endif
2450         }
2451         if (obj == uwep) {
2452             uwepgone(); /* now bare handed */
2453             stop_occupation();
2454         } else if (obj == uswapwep) {
2455             uswapwepgone();
2456             stop_occupation();
2457         } else if (obj == uquiver) {
2458             uqwepgone();
2459             stop_occupation();
2460         }
2461     } else if (obj->where == OBJ_MINVENT && obj->owornmask) {
2462         if (obj == MON_WEP(obj->ocarry))
2463             setmnotwielded(obj->ocarry, obj);
2464     } else if (obj->where == OBJ_MIGRATING) {
2465         /* clear destination flag so that obfree()'s check for
2466            freeing a worn object doesn't get a false hit */
2467         obj->owornmask = 0L;
2468     }
2469     rot_organic(arg, timeout);
2470     if (on_floor) {
2471         struct monst *mtmp = m_at(x, y);
2472
2473         /* a hiding monster may be exposed */
2474         if (mtmp && !OBJ_AT(x, y) && mtmp->mundetected
2475             && hides_under(mtmp->data)) {
2476             mtmp->mundetected = 0;
2477         } else if (x == u.ux && y == u.uy && u.uundetected && hides_under(youmonst.data))
2478             (void) hideunder(&youmonst);
2479         newsym(x, y);
2480     } else if (in_invent)
2481         update_inventory();
2482 }
2483
2484 #if 0
2485 void
2486 bury_monst(mtmp)
2487 struct monst *mtmp;
2488 {
2489     debugpline1("bury_monst: %s", mon_nam(mtmp));
2490     if (canseemon(mtmp)) {
2491         if (is_flyer(mtmp->data) || is_floater(mtmp->data)) {
2492             pline_The("%s opens up, but %s is not swallowed!",
2493                       surface(mtmp->mx, mtmp->my), mon_nam(mtmp));
2494             return;
2495         } else
2496             pline_The("%s opens up and swallows %s!",
2497                       surface(mtmp->mx, mtmp->my), mon_nam(mtmp));
2498     }
2499
2500     mtmp->mburied = TRUE;
2501     wakeup(mtmp);       /* at least give it a chance :-) */
2502     newsym(mtmp->mx, mtmp->my);
2503 }
2504
2505 void
2506 bury_you()
2507 {
2508     debugpline0("bury_you");
2509     if (!Levitation && !Flying) {
2510         if (u.uswallow)
2511 /*JP
2512             You_feel("a sensation like falling into a trap!");
2513 */
2514             You("ã©\82É\97\8e\82¿\82é\82æ\82¤\82È\8a´\8ao\82É\82¨\82»\82í\82ê\82½\81I");
2515         else
2516 /*JP
2517             pline_The("%s opens beneath you and you fall in!",
2518 */
2519             pline("%s\82ª\89º\95û\82É\8aJ\82«\81C\82 \82È\82½\82Í\97\8e\82¿\82½\81I",
2520                       surface(u.ux, u.uy));
2521
2522         u.uburied = TRUE;
2523         if (!Strangled && !Breathless)
2524             Strangled = 6;
2525         under_ground(1);
2526     }
2527 }
2528
2529 void
2530 unearth_you()
2531 {
2532     debugpline0("unearth_you");
2533     u.uburied = FALSE;
2534     under_ground(0);
2535     if (!uamul || uamul->otyp != AMULET_OF_STRANGULATION)
2536         Strangled = 0;
2537     vision_recalc(0);
2538 }
2539
2540 void
2541 escape_tomb()
2542 {
2543     debugpline0("escape_tomb");
2544     if ((Teleportation || can_teleport(youmonst.data))
2545         && (Teleport_control || rn2(3) < Luck+2)) {
2546 /*JP
2547         You("attempt a teleport spell.");
2548 */
2549         You("\8fu\8aÔ\88Ú\93®\82ð\8e\8e\82Ý\82½\81D");
2550         (void) dotele();        /* calls unearth_you() */
2551     } else if (u.uburied) { /* still buried after 'port attempt */
2552         boolean good;
2553
2554         if (amorphous(youmonst.data) || Passes_walls
2555             || noncorporeal(youmonst.data)
2556             || (unsolid(youmonst.data)
2557                 && youmonst.data != &mons[PM_WATER_ELEMENTAL])
2558             || (tunnels(youmonst.data) && !needspick(youmonst.data))) {
2559 #if 0 /*JP*/
2560             You("%s up through the %s.",
2561                 (tunnels(youmonst.data) && !needspick(youmonst.data))
2562                    ? "try to tunnel"
2563                    : (amorphous(youmonst.data))
2564                       ? "ooze"
2565                       : "phase",
2566                 surface(u.ux, u.uy));
2567 #else
2568             You("%s\82É%s\82ë\82¤\82Æ\82µ\82½\81D",
2569                 surface(u.ux, u.uy),
2570                 (tunnels(youmonst.data) && !needspick(youmonst.data))
2571                 ? "\83g\83\93\83l\83\8b\82ð\8c@"
2572                 : (amorphous(youmonst.data))
2573                    ? "\82É\82\82Ý\82Ì\82Ú"
2574                    : "\8f\99\81X\82É\82Í\82¢\82 \82ª");
2575 #endif
2576
2577             good = (tunnels(youmonst.data) && !needspick(youmonst.data))
2578                       ? dighole(TRUE, FALSE, (coord *)0) : TRUE;
2579             if (good)
2580                 unearth_you();
2581         }
2582     }
2583 }
2584
2585 void
2586 bury_obj(otmp)
2587 struct obj *otmp;
2588 {
2589     debugpline0("bury_obj");
2590     if (cansee(otmp->ox, otmp->oy))
2591 /*JP
2592         pline_The("objects on the %s tumble into a hole!",
2593 */
2594         pline_The("%s\82Ì\95¨\91Ì\82Í\8c\8a\82É\93]\82ª\82Á\82½\81I",
2595                   surface(otmp->ox, otmp->oy));
2596
2597     bury_objs(otmp->ox, otmp->oy);
2598 }
2599 #endif /*0*/
2600
2601 #ifdef DEBUG
2602 /* bury everything at your loc and around */
2603 int
2604 wiz_debug_cmd_bury()
2605 {
2606     int x, y;
2607
2608     for (x = u.ux - 1; x <= u.ux + 1; x++)
2609         for (y = u.uy - 1; y <= u.uy + 1; y++)
2610             if (isok(x, y))
2611                 bury_objs(x, y);
2612     return 0;
2613 }
2614 #endif /* DEBUG */
2615
2616 /*dig.c*/