OSDN Git Service

update year to 2020
[jnethack/source.git] / src / trap.c
1 /* NetHack 3.6  trap.c  $NHDT-Date: 1576638501 2019/12/18 03:08:21 $  $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.329 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /*-Copyright (c) Robert Patrick Rankin, 2013. */
4 /* NetHack may be freely redistributed.  See license for details. */
5
6 /* JNetHack Copyright */
7 /* (c) Issei Numata, Naoki Hamada, Shigehiro Miyashita, 1994-2000  */
8 /* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2020            */
9 /* JNetHack may be freely redistributed.  See license for details. */
10
11 #include "hack.h"
12
13 extern const char *const destroy_strings[][3]; /* from zap.c */
14
15 STATIC_DCL boolean FDECL(keep_saddle_with_steedcorpse, (unsigned, struct obj *,
16                                                         struct obj *));
17 STATIC_DCL struct obj *FDECL(t_missile, (int, struct trap *));
18 STATIC_DCL char *FDECL(trapnote, (struct trap *, BOOLEAN_P));
19 STATIC_DCL int FDECL(steedintrap, (struct trap *, struct obj *));
20 STATIC_DCL void FDECL(launch_drop_spot, (struct obj *, XCHAR_P, XCHAR_P));
21 STATIC_DCL int FDECL(mkroll_launch, (struct trap *, XCHAR_P, XCHAR_P,
22                                      SHORT_P, long));
23 STATIC_DCL boolean FDECL(isclearpath, (coord *, int, SCHAR_P, SCHAR_P));
24 STATIC_DCL void FDECL(dofiretrap, (struct obj *));
25 STATIC_DCL void NDECL(domagictrap);
26 STATIC_DCL boolean FDECL(emergency_disrobe, (boolean *));
27 STATIC_DCL int FDECL(untrap_prob, (struct trap *));
28 STATIC_DCL void FDECL(move_into_trap, (struct trap *));
29 STATIC_DCL int FDECL(try_disarm, (struct trap *, BOOLEAN_P));
30 STATIC_DCL void FDECL(reward_untrap, (struct trap *, struct monst *));
31 STATIC_DCL int FDECL(disarm_holdingtrap, (struct trap *));
32 STATIC_DCL int FDECL(disarm_landmine, (struct trap *));
33 STATIC_DCL int FDECL(disarm_squeaky_board, (struct trap *));
34 STATIC_DCL int FDECL(disarm_shooting_trap, (struct trap *, int));
35 STATIC_DCL void FDECL(clear_conjoined_pits, (struct trap *));
36 STATIC_DCL boolean FDECL(adj_nonconjoined_pit, (struct trap *));
37 STATIC_DCL int FDECL(try_lift, (struct monst *, struct trap *, int,
38                                 BOOLEAN_P));
39 STATIC_DCL int FDECL(help_monster_out, (struct monst *, struct trap *));
40 #if 0
41 STATIC_DCL void FDECL(join_adjacent_pits, (struct trap *));
42 #endif
43 STATIC_DCL boolean FDECL(thitm, (int, struct monst *, struct obj *, int,
44                                  BOOLEAN_P));
45 STATIC_DCL void NDECL(maybe_finish_sokoban);
46
47 /* mintrap() should take a flags argument, but for time being we use this */
48 STATIC_VAR int force_mintrap = 0;
49
50 #if 0 /*JP*/
51 STATIC_VAR const char *const a_your[2] = { "a", "your" };
52 STATIC_VAR const char *const A_Your[2] = { "A", "Your" };
53 STATIC_VAR const char tower_of_flame[] = "tower of flame";
54 STATIC_VAR const char *const A_gush_of_water_hits = "A gush of water hits";
55 #endif
56 #if 0 /*JP:T*/
57 STATIC_VAR const char *const blindgas[6] = { "humid",   "odorless",
58                                              "pungent", "chilling",
59                                              "acrid",   "biting" };
60 #else
61 STATIC_VAR const char * const blindgas[6] = {
62     "\82Þ\82µ\82Þ\82µ\82·\82é", "\96³\8fL\82Ì",
63     "\8eh\8c\83\8fL\82Ì\82·\82é", "\97â\82½\82¢",
64     "\83c\83\93\82Æ\82µ\82½\82É\82¨\82¢\82Ì", "\82Ð\82è\82Ð\82è\82·\82é"
65     };
66 #endif
67 #if 1 /*JP*/
68 const char *set_you[2] = { "", "\82 \82È\82½\82Ì\8ed\8a|\82¯\82½" };
69 STATIC_VAR const char *dig_you[2] = { "", "\82 \82È\82½\82ª\8c@\82Á\82½" };
70 STATIC_VAR const char *web_you[2] = { "", "\82 \82È\82½\82ª\92£\82Á\82½" };
71 #endif
72
73 /* called when you're hit by fire (dofiretrap,buzz,zapyourself,explode);
74    returns TRUE if hit on torso */
75 boolean
76 burnarmor(victim)
77 struct monst *victim;
78 {
79     struct obj *item;
80     char buf[BUFSZ];
81     int mat_idx, oldspe;
82     boolean hitting_u;
83
84     if (!victim)
85         return 0;
86     hitting_u = (victim == &youmonst);
87
88     /* burning damage may dry wet towel */
89     item = hitting_u ? carrying(TOWEL) : m_carrying(victim, TOWEL);
90     while (item) {
91         if (is_wet_towel(item)) {
92             oldspe = item->spe;
93             dry_a_towel(item, rn2(oldspe + 1), TRUE);
94             if (item->spe != oldspe)
95                 break; /* stop once one towel has been affected */
96         }
97         item = item->nobj;
98     }
99
100 #define burn_dmg(obj, descr) erode_obj(obj, descr, ERODE_BURN, EF_GREASE)
101     while (1) {
102         switch (rn2(5)) {
103         case 0:
104             item = hitting_u ? uarmh : which_armor(victim, W_ARMH);
105             if (item) {
106                 mat_idx = objects[item->otyp].oc_material;
107 #if 0 /*JP:T*/
108                 Sprintf(buf, "%s %s", materialnm[mat_idx],
109                         helm_simple_name(item));
110 #else
111                 Sprintf(buf, "%s\82Ì%s", materialnm[mat_idx],
112                         helm_simple_name(item));
113 #endif
114             }
115 /*JP
116             if (!burn_dmg(item, item ? buf : "helmet"))
117 */
118             if (!burn_dmg(item, item ? buf : "\8a\95"))
119                 continue;
120             break;
121         case 1:
122             item = hitting_u ? uarmc : which_armor(victim, W_ARMC);
123             if (item) {
124                 (void) burn_dmg(item, cloak_simple_name(item));
125                 return TRUE;
126             }
127             item = hitting_u ? uarm : which_armor(victim, W_ARM);
128             if (item) {
129                 (void) burn_dmg(item, xname(item));
130                 return TRUE;
131             }
132             item = hitting_u ? uarmu : which_armor(victim, W_ARMU);
133             if (item)
134 /*JP
135                 (void) burn_dmg(item, "shirt");
136 */
137                 (void) burn_dmg(item, "\83V\83\83\83c");
138             return TRUE;
139         case 2:
140             item = hitting_u ? uarms : which_armor(victim, W_ARMS);
141 /*JP
142             if (!burn_dmg(item, "wooden shield"))
143 */
144             if (!burn_dmg(item, "\96Ø\82Ì\8f\82"))
145                 continue;
146             break;
147         case 3:
148             item = hitting_u ? uarmg : which_armor(victim, W_ARMG);
149 /*JP
150             if (!burn_dmg(item, "gloves"))
151 */
152             if (!burn_dmg(item, "\8f¬\8eè"))
153                 continue;
154             break;
155         case 4:
156             item = hitting_u ? uarmf : which_armor(victim, W_ARMF);
157 /*JP
158             if (!burn_dmg(item, "boots"))
159 */
160             if (!burn_dmg(item, "\8cC"))
161                 continue;
162             break;
163         }
164         break; /* Out of while loop */
165     }
166 #undef burn_dmg
167
168     return FALSE;
169 }
170
171 /* Generic erode-item function.
172  * "ostr", if non-null, is an alternate string to print instead of the
173  *   object's name.
174  * "type" is an ERODE_* value for the erosion type
175  * "flags" is an or-ed list of EF_* flags
176  *
177  * Returns an erosion return value (ER_*)
178  */
179 int
180 erode_obj(otmp, ostr, type, ef_flags)
181 register struct obj *otmp;
182 const char *ostr;
183 int type;
184 int ef_flags;
185 {
186     static NEARDATA const char
187 /*JP
188         *const action[] = { "smoulder", "rust", "rot", "corrode" },
189 */
190         *const action[] = { "\82­\82·\82Ô\82Á\82½", "\8eK\82Ñ\82½", "\95\85\82Á\82½", "\95\85\90H\82µ\82½" },
191 /*JP
192         *const msg[] = { "burnt", "rusted", "rotten", "corroded" },
193 */
194         *const msg[] =  { "\8fÅ\82°\82½", "\8eK\82Ñ\82½", "\95\85\82Á\82½", "\95\85\90H\82µ\82½" },
195 /*JP
196         *const bythe[] = { "heat", "oxidation", "decay", "corrosion" };
197 */
198         *const bythe[] = { "\94M", "\8e_\89»", "\95\85\94s", "\95\85\90H" };
199     boolean vulnerable = FALSE, is_primary = TRUE,
200             check_grease = (ef_flags & EF_GREASE) ? TRUE : FALSE,
201             print = (ef_flags & EF_VERBOSE) ? TRUE : FALSE,
202             uvictim, vismon, visobj;
203     int erosion, cost_type;
204     struct monst *victim;
205
206     if (!otmp)
207         return ER_NOTHING;
208
209     victim = carried(otmp) ? &youmonst : mcarried(otmp) ? otmp->ocarry : NULL;
210     uvictim = (victim == &youmonst);
211     vismon = victim && (victim != &youmonst) && canseemon(victim);
212     /* Is bhitpos correct here? Ugh. */
213     visobj = !victim && cansee(bhitpos.x, bhitpos.y);
214
215     switch (type) {
216     case ERODE_BURN:
217         vulnerable = is_flammable(otmp);
218         check_grease = FALSE;
219         cost_type = COST_BURN;
220         break;
221     case ERODE_RUST:
222         vulnerable = is_rustprone(otmp);
223         cost_type = COST_RUST;
224         break;
225     case ERODE_ROT:
226         vulnerable = is_rottable(otmp);
227         check_grease = FALSE;
228         is_primary = FALSE;
229         cost_type = COST_ROT;
230         break;
231     case ERODE_CORRODE:
232         vulnerable = is_corrodeable(otmp);
233         is_primary = FALSE;
234         cost_type = COST_CORRODE;
235         break;
236     default:
237         impossible("Invalid erosion type in erode_obj");
238         return ER_NOTHING;
239     }
240     erosion = is_primary ? otmp->oeroded : otmp->oeroded2;
241
242     if (!ostr)
243         ostr = cxname(otmp);
244     /* 'visobj' messages insert "the"; probably ought to switch to the() */
245     if (visobj && !(uvictim || vismon) && !strncmpi(ostr, "the ", 4))
246         ostr += 4;
247
248     if (check_grease && otmp->greased) {
249         grease_protect(otmp, ostr, victim);
250         return ER_GREASED;
251     } else if (!erosion_matters(otmp)) {
252         return ER_NOTHING;
253     } else if (!vulnerable || (otmp->oerodeproof && otmp->rknown)) {
254         if (flags.verbose && print && (uvictim || vismon))
255 #if 0 /*JP:T*/
256             pline("%s %s %s not affected by %s.",
257                   uvictim ? "Your" : s_suffix(Monnam(victim)),
258                   ostr, vtense(ostr, "are"), bythe[type]);
259 #else
260             pline("%s%s\82Í%s\82Ì\89e\8b¿\82ð\8eó\82¯\82È\82©\82Á\82½\81D",
261                   uvictim ? "\82 \82È\82½\82Ì" : s_suffix(Monnam(victim)),
262                   ostr, bythe[type]);
263 #endif
264         return ER_NOTHING;
265     } else if (otmp->oerodeproof || (otmp->blessed && !rnl(4))) {
266         if (flags.verbose && (print || otmp->oerodeproof)
267             && (uvictim || vismon || visobj))
268 #if 0 /*JP:T*/
269             pline("Somehow, %s %s %s not affected by the %s.",
270                   uvictim ? "your"
271                           : !vismon ? "the" /* visobj */
272                                     : s_suffix(mon_nam(victim)),
273                   ostr, vtense(ostr, "are"), bythe[type]);
274 #else
275             pline("\82È\82º\82©\81C%s%s\82Í%s\82Ì\89e\8b¿\82ð\8eó\82¯\82È\82©\82Á\82½\81D",
276                   uvictim ? "\82 \82È\82½\82Ì"
277                           : !vismon ? "" /* visobj */
278                                     : s_suffix(mon_nam(victim)),
279                   ostr, bythe[type]);
280 #endif
281         /* We assume here that if the object is protected because it
282          * is blessed, it still shows some minor signs of wear, and
283          * the hero can distinguish this from an object that is
284          * actually proof against damage.
285          */
286         if (otmp->oerodeproof) {
287             otmp->rknown = TRUE;
288             if (victim == &youmonst)
289                 update_inventory();
290         }
291
292         return ER_NOTHING;
293     } else if (erosion < MAX_ERODE) {
294 #if 0 /*JP:T*/
295         const char *adverb = (erosion + 1 == MAX_ERODE)
296                                  ? " completely"
297                                  : erosion ? " further" : "";
298 #else
299         const char *adverb = (erosion + 1 == MAX_ERODE)
300                                  ? "\8a®\91S\82É"
301                                  : erosion ? "\82³\82ç\82É" : "";
302 #endif
303
304         if (uvictim || vismon || visobj)
305 #if 0 /*JP:T*/
306             pline("%s %s %s%s!",
307                   uvictim ? "Your"
308                           : !vismon ? "The" /* visobj */
309                                     : s_suffix(Monnam(victim)),
310                   ostr, vtense(ostr, action[type]), adverb);
311 #else
312             pline("%s%s\82Í%s%s!",
313                   uvictim ? "\82 \82È\82½\82Ì"
314                           : !vismon ? "" /* visobj */
315                                     : s_suffix(Monnam(victim)),
316                   ostr, adverb, action[type]);
317 #endif
318
319         if (ef_flags & EF_PAY)
320             costly_alteration(otmp, cost_type);
321
322         if (is_primary)
323             otmp->oeroded++;
324         else
325             otmp->oeroded2++;
326
327         if (victim == &youmonst)
328             update_inventory();
329
330         return ER_DAMAGED;
331     } else if (ef_flags & EF_DESTROY) {
332         if (uvictim || vismon || visobj)
333 #if 0 /*JP:T*/
334             pline("%s %s %s away!",
335                   uvictim ? "Your"
336                           : !vismon ? "The" /* visobj */
337                                     : s_suffix(Monnam(victim)),
338                   ostr, vtense(ostr, action[type]));
339 #else
340             pline("%s%s\82Í\8a®\91S\82É%s\81I",
341                   uvictim ? "\82 \82È\82½\82Ì"
342                           : !vismon ? "" /* visobj */
343                                     : s_suffix(Monnam(victim)),
344                   ostr, action[type]);
345 #endif
346
347         if (ef_flags & EF_PAY)
348             costly_alteration(otmp, cost_type);
349
350         setnotworn(otmp);
351         delobj(otmp);
352         return ER_DESTROYED;
353     } else {
354         if (flags.verbose && print) {
355             if (uvictim)
356 #if 0 /*JP:T*/
357                 Your("%s %s completely %s.",
358                      ostr, vtense(ostr, Blind ? "feel" : "look"), msg[type]);
359 #else
360                 Your("%s\82Í\8a®\91S\82É%s%s\81D",
361                      ostr, msg[type], Blind ? "\82æ\82¤\82¾" : "");
362 #endif
363             else if (vismon || visobj)
364 #if 0 /*JP:T*/
365                 pline("%s %s %s completely %s.",
366                       !vismon ? "The" : s_suffix(Monnam(victim)),
367                       ostr, vtense(ostr, "look"), msg[type]);
368 #else
369                 pline("%s%s\82Í\8a®\91S\82É%s\82æ\82¤\82¾\81D",
370                       !vismon ? "" : s_suffix(Monnam(victim)),
371                       ostr, msg[type]);
372 #endif
373         }
374         return ER_NOTHING;
375     }
376 }
377
378 /* Protect an item from erosion with grease. Returns TRUE if the grease
379  * wears off.
380  */
381 boolean
382 grease_protect(otmp, ostr, victim)
383 register struct obj *otmp;
384 const char *ostr;
385 struct monst *victim;
386 {
387 /*JP
388     static const char txt[] = "protected by the layer of grease!";
389 */
390     static const char txt[] = "\96û\82Ì\93h\82è\82±\82Ý\82É\82æ\82Á\82Ä\8eç\82ç\82ê\82Ä\82¢\82é\81I";
391     boolean vismon = victim && (victim != &youmonst) && canseemon(victim);
392
393     if (ostr) {
394         if (victim == &youmonst)
395 /*JP
396             Your("%s %s %s", ostr, vtense(ostr, "are"), txt);
397 */
398             Your("%s\82Í%s", ostr, txt);
399         else if (vismon)
400 #if 0 /*JP:T*/
401             pline("%s's %s %s %s", Monnam(victim),
402                   ostr, vtense(ostr, "are"), txt);
403 #else
404             pline("%s\82Ì%s\82Í%s", Monnam(victim), ostr, txt);
405 #endif
406     } else if (victim == &youmonst || vismon) {
407 /*JP
408         pline("%s %s", Yobjnam2(otmp, "are"), txt);
409 */
410         Your("%s\82Í%s",xname(otmp), txt);
411     }
412     if (!rn2(2)) {
413         otmp->greased = 0;
414         if (carried(otmp)) {
415 /*JP
416             pline_The("grease dissolves.");
417 */
418             pline("\96û\82Í\82Í\82°\82Ä\82µ\82Ü\82Á\82½\81D");
419             update_inventory();
420         }
421         return TRUE;
422     }
423     return FALSE;
424 }
425
426 struct trap *
427 maketrap(x, y, typ)
428 int x, y, typ;
429 {
430     static union vlaunchinfo zero_vl;
431     boolean oldplace;
432     struct trap *ttmp;
433     struct rm *lev = &levl[x][y];
434
435     if ((ttmp = t_at(x, y)) != 0) {
436         if (ttmp->ttyp == MAGIC_PORTAL || ttmp->ttyp == VIBRATING_SQUARE)
437             return (struct trap *) 0;
438         oldplace = TRUE;
439         if (u.utrap && x == u.ux && y == u.uy
440             && ((u.utraptype == TT_BEARTRAP && typ != BEAR_TRAP)
441                 || (u.utraptype == TT_WEB && typ != WEB)
442                 || (u.utraptype == TT_PIT && !is_pit(typ))))
443             u.utrap = 0;
444         /* old <tx,ty> remain valid */
445     } else if (IS_FURNITURE(lev->typ)
446                && (!IS_GRAVE(lev->typ) || (typ != PIT && typ != HOLE))) {
447         /* no trap on top of furniture (caller usually screens the
448            location to inhibit this, but wizard mode wishing doesn't) */
449         return (struct trap *) 0;
450     } else {
451         oldplace = FALSE;
452         ttmp = newtrap();
453         (void) memset((genericptr_t)ttmp, 0, sizeof(struct trap));
454         ttmp->ntrap = 0;
455         ttmp->tx = x;
456         ttmp->ty = y;
457     }
458     /* [re-]initialize all fields except ntrap (handled below) and <tx,ty> */
459     ttmp->vl = zero_vl;
460     ttmp->launch.x = ttmp->launch.y = -1; /* force error if used before set */
461     ttmp->dst.dnum = ttmp->dst.dlevel = -1;
462     ttmp->madeby_u = 0;
463     ttmp->once = 0;
464     ttmp->tseen = (typ == HOLE); /* hide non-holes */
465     ttmp->ttyp = typ;
466
467     switch (typ) {
468     case SQKY_BOARD: {
469         int tavail[12], tpick[12], tcnt = 0, k;
470         struct trap *t;
471
472         for (k = 0; k < 12; ++k)
473             tavail[k] = tpick[k] = 0;
474         for (t = ftrap; t; t = t->ntrap)
475             if (t->ttyp == SQKY_BOARD && t != ttmp)
476                 tavail[t->tnote] = 1;
477         /* now populate tpick[] with the available indices */
478         for (k = 0; k < 12; ++k)
479             if (tavail[k] == 0)
480                 tpick[tcnt++] = k;
481         /* choose an unused note; if all are in use, pick a random one */
482         ttmp->tnote = (short) ((tcnt > 0) ? tpick[rn2(tcnt)] : rn2(12));
483         break;
484     }
485     case STATUE_TRAP: { /* create a "living" statue */
486         struct monst *mtmp;
487         struct obj *otmp, *statue;
488         struct permonst *mptr;
489         int trycount = 10;
490
491         do { /* avoid ultimately hostile co-aligned unicorn */
492             mptr = &mons[rndmonnum()];
493         } while (--trycount > 0 && is_unicorn(mptr)
494                  && sgn(u.ualign.type) == sgn(mptr->maligntyp));
495         statue = mkcorpstat(STATUE, (struct monst *) 0, mptr, x, y,
496                             CORPSTAT_NONE);
497         mtmp = makemon(&mons[statue->corpsenm], 0, 0, MM_NOCOUNTBIRTH);
498         if (!mtmp)
499             break; /* should never happen */
500         while (mtmp->minvent) {
501             otmp = mtmp->minvent;
502             otmp->owornmask = 0;
503             obj_extract_self(otmp);
504             (void) add_to_container(statue, otmp);
505         }
506         statue->owt = weight(statue);
507         mongone(mtmp);
508         break;
509     }
510     case ROLLING_BOULDER_TRAP: /* boulder will roll towards trigger */
511         (void) mkroll_launch(ttmp, x, y, BOULDER, 1L);
512         break;
513     case PIT:
514     case SPIKED_PIT:
515         ttmp->conjoined = 0;
516         /*FALLTHRU*/
517     case HOLE:
518     case TRAPDOOR:
519         if (*in_rooms(x, y, SHOPBASE)
520             && (is_hole(typ) || IS_DOOR(lev->typ) || IS_WALL(lev->typ)))
521             add_damage(x, y, /* schedule repair */
522                        ((IS_DOOR(lev->typ) || IS_WALL(lev->typ))
523                         && !context.mon_moving)
524                            ? SHOP_HOLE_COST
525                            : 0L);
526         lev->doormask = 0;     /* subsumes altarmask, icedpool... */
527         if (IS_ROOM(lev->typ)) /* && !IS_AIR(lev->typ) */
528             lev->typ = ROOM;
529         /*
530          * some cases which can happen when digging
531          * down while phazing thru solid areas
532          */
533         else if (lev->typ == STONE || lev->typ == SCORR)
534             lev->typ = CORR;
535         else if (IS_WALL(lev->typ) || lev->typ == SDOOR)
536             lev->typ = level.flags.is_maze_lev
537                            ? ROOM
538                            : level.flags.is_cavernous_lev ? CORR : DOOR;
539
540         unearth_objs(x, y);
541         break;
542     }
543
544     if (!oldplace) {
545         ttmp->ntrap = ftrap;
546         ftrap = ttmp;
547     } else {
548         /* oldplace;
549            it shouldn't be possible to override a sokoban pit or hole
550            with some other trap, but we'll check just to be safe */
551         if (Sokoban)
552             maybe_finish_sokoban();
553     }
554     return ttmp;
555 }
556
557 void
558 fall_through(td, ftflags)
559 boolean td; /* td == TRUE : trap door or hole */
560 unsigned ftflags;
561 {
562     d_level dtmp;
563     char msgbuf[BUFSZ];
564     const char *dont_fall = 0;
565     int newlevel, bottom;
566     struct trap *t = (struct trap *) 0;
567
568     /* we'll fall even while levitating in Sokoban; otherwise, if we
569        won't fall and won't be told that we aren't falling, give up now */
570     if (Blind && Levitation && !Sokoban)
571         return;
572
573     bottom = dunlevs_in_dungeon(&u.uz);
574     /* when in the upper half of the quest, don't fall past the
575        middle "quest locate" level if hero hasn't been there yet */
576     if (In_quest(&u.uz)) {
577         int qlocate_depth = qlocate_level.dlevel;
578
579         /* deepest reached < qlocate implies current < qlocate */
580         if (dunlev_reached(&u.uz) < qlocate_depth)
581             bottom = qlocate_depth; /* early cut-off */
582     }
583     newlevel = dunlev(&u.uz); /* current level */
584     do {
585         newlevel++;
586     } while (!rn2(4) && newlevel < bottom);
587
588     if (td) {
589         t = t_at(u.ux, u.uy);
590         feeltrap(t);
591         if (!Sokoban && !(ftflags & TOOKPLUNGE)) {
592             if (t->ttyp == TRAPDOOR)
593 /*JP
594                 pline("A trap door opens up under you!");
595 */
596                 pline("\97\8e\82µ\94à\82ª\82 \82È\82½\82Ì\91«\8c³\82É\8aJ\82¢\82½\81I");
597             else
598 /*JP
599                 pline("There's a gaping hole under you!");
600 */
601                 pline("\82 \82È\82½\82Ì\91«\89º\82É\82Û\82Á\82©\82è\82Æ\8c\8a\82ª\8aJ\82¢\82Ä\82¢\82é\81I");
602         }
603     } else
604 /*JP
605         pline_The("%s opens up under you!", surface(u.ux, u.uy));
606 */
607         pline("\91«\8c³\82Ì%s\82É\8c\8a\82ª\8aJ\82¢\82½\81I", surface(u.ux,u.uy));
608
609     if (Sokoban && Can_fall_thru(&u.uz))
610         ; /* KMH -- You can't escape the Sokoban level traps */
611     else if (Levitation || u.ustuck
612              || (!Can_fall_thru(&u.uz) && !levl[u.ux][u.uy].candig)
613              || ((Flying || is_clinger(youmonst.data)
614                   || (ceiling_hider(youmonst.data) && u.uundetected))
615                  && !(ftflags & TOOKPLUNGE))
616              || (Inhell && !u.uevent.invoked && newlevel == bottom)) {
617 /*JP
618         dont_fall = "don't fall in.";
619 */
620         dont_fall = "\82µ\82©\82µ\82 \82È\82½\82Í\97\8e\82¿\82È\82©\82Á\82½\81D";
621     } else if (youmonst.data->msize >= MZ_HUGE) {
622 /*JP
623         dont_fall = "don't fit through.";
624 */
625         dont_fall = "\92Ê\82è\94²\82¯\82é\82É\82Í\83T\83C\83Y\82ª\8d\87\82í\82È\82¢\81D";
626     } else if (!next_to_u()) {
627 /*JP
628         dont_fall = "are jerked back by your pet!";
629 */
630         dont_fall = "\82 \82È\82½\82Í\83y\83b\83g\82É\82æ\82Á\82Ä\88ø\82Á\82Ï\82è\82à\82Ç\82³\82ê\82½\81I";
631     }
632     if (dont_fall) {
633 #if 0 /*JP*//*\81u\82 \82È\82½\82Í\81v\82Å\8en\82Ü\82ç\82È\82¢\82à\82Ì\82à\82 \82é*/
634         You1(dont_fall);
635 #else
636         pline1(dont_fall);
637 #endif
638         /* hero didn't fall through, but any objects here might */
639         impact_drop((struct obj *) 0, u.ux, u.uy, 0);
640         if (!td) {
641             display_nhwindow(WIN_MESSAGE, FALSE);
642 /*JP
643             pline_The("opening under you closes up.");
644 */
645             pline_The("\91«\89º\82É\8aJ\82¢\82Ä\82¢\82½\82à\82Ì\82Í\95Â\82\82½\81D");
646         }
647         return;
648     }
649     if ((Flying || is_clinger(youmonst.data))
650         && (ftflags & TOOKPLUNGE) && td && t)
651 #if 0 /*JP:T*/
652         You("%s down %s!",
653             Flying ? "swoop" : "deliberately drop",
654             (t->ttyp == TRAPDOOR)
655                 ? "through the trap door"
656                 : "into the gaping hole");
657 #else
658         You("%s\82É%s\81I",
659             (t->ttyp == TRAPDOOR)
660                 ? "\97\8e\82µ\94à"
661                 : "\8c\8a",
662             Flying ? "\8b}\8d~\89º\82µ\82½" : "\82í\82´\82Æ\97\8e\82¿\82½");
663 #endif
664
665     if (*u.ushops)
666         shopdig(1);
667     if (Is_stronghold(&u.uz)) {
668         find_hell(&dtmp);
669     } else {
670         int dist = newlevel - dunlev(&u.uz);
671         dtmp.dnum = u.uz.dnum;
672         dtmp.dlevel = newlevel;
673         if (dist > 1)
674 #if 0 /*JP:T*/
675             You("fall down a %s%sshaft!", dist > 3 ? "very " : "",
676                 dist > 2 ? "deep " : "");
677 #else
678             You("%s%s\8c\8a\82Ì\92\86\82ð\97\8e\82¿\82Ä\82¢\82Á\82½\81I", dist > 3 ? "\82Æ\82Ä\82à" : "",
679                 dist > 2 ? "\90[\82¢" : "");
680 #endif
681     }
682     if (!td)
683 /*JP
684         Sprintf(msgbuf, "The hole in the %s above you closes up.",
685 */
686         Sprintf(msgbuf, "%s\82É\8aJ\82¢\82½\8c\8a\82Í\95Â\82\82½\81D",
687                 ceiling(u.ux, u.uy));
688
689     schedule_goto(&dtmp, FALSE, TRUE, 0, (char *) 0,
690                   !td ? msgbuf : (char *) 0);
691 }
692
693 /*
694  * Animate the given statue.  May have been via shatter attempt, trap,
695  * or stone to flesh spell.  Return a monster if successfully animated.
696  * If the monster is animated, the object is deleted.  If fail_reason
697  * is non-null, then fill in the reason for failure (or success).
698  *
699  * The cause of animation is:
700  *
701  *      ANIMATE_NORMAL  - hero "finds" the monster
702  *      ANIMATE_SHATTER - hero tries to destroy the statue
703  *      ANIMATE_SPELL   - stone to flesh spell hits the statue
704  *
705  * Perhaps x, y is not needed if we can use get_obj_location() to find
706  * the statue's location... ???
707  *
708  * Sequencing matters:
709  *      create monster; if it fails, give up with statue intact;
710  *      give "statue comes to life" message;
711  *      if statue belongs to shop, have shk give "you owe" message;
712  *      transfer statue contents to monster (after stolen_value());
713  *      delete statue.
714  *      [This ordering means that if the statue ends up wearing a cloak of
715  *       invisibility or a mummy wrapping, the visibility checks might be
716  *       wrong, but to avoid that we'd have to clone the statue contents
717  *       first in order to give them to the monster before checking their
718  *       shop status--it's not worth the hassle.]
719  */
720 struct monst *
721 animate_statue(statue, x, y, cause, fail_reason)
722 struct obj *statue;
723 xchar x, y;
724 int cause;
725 int *fail_reason;
726 {
727     int mnum = statue->corpsenm;
728     struct permonst *mptr = &mons[mnum];
729     struct monst *mon = 0, *shkp;
730     struct obj *item;
731     coord cc;
732     boolean historic = (Role_if(PM_ARCHEOLOGIST)
733                         && (statue->spe & STATUE_HISTORIC) != 0),
734             golem_xform = FALSE, use_saved_traits;
735     const char *comes_to_life;
736     char statuename[BUFSZ], tmpbuf[BUFSZ];
737     static const char historic_statue_is_gone[] =
738 /*JP
739         "that the historic statue is now gone";
740 */
741         "\97ð\8ej\93I\82È\92¤\91\9c\82ª\82È\82­\82È\82Á\82Ä\82µ\82Ü\82Á\82½\82±\82Æ";
742
743     if (cant_revive(&mnum, TRUE, statue)) {
744         /* mnum has changed; we won't be animating this statue as itself */
745         if (mnum != PM_DOPPELGANGER)
746             mptr = &mons[mnum];
747         use_saved_traits = FALSE;
748     } else if (is_golem(mptr) && cause == ANIMATE_SPELL) {
749         /* statue of any golem hit by stone-to-flesh becomes flesh golem */
750         golem_xform = (mptr != &mons[PM_FLESH_GOLEM]);
751         mnum = PM_FLESH_GOLEM;
752         mptr = &mons[PM_FLESH_GOLEM];
753         use_saved_traits = (has_omonst(statue) && !golem_xform);
754     } else {
755         use_saved_traits = has_omonst(statue);
756     }
757
758     if (use_saved_traits) {
759         /* restore a petrified monster */
760         cc.x = x, cc.y = y;
761         mon = montraits(statue, &cc, (cause == ANIMATE_SPELL));
762         if (mon && mon->mtame && !mon->isminion)
763             wary_dog(mon, TRUE);
764     } else {
765         /* statues of unique monsters from bones or wishing end
766            up here (cant_revive() sets mnum to be doppelganger;
767            mptr reflects the original form for use by newcham()) */
768         if ((mnum == PM_DOPPELGANGER && mptr != &mons[PM_DOPPELGANGER])
769             /* block quest guards from other roles */
770             || (mptr->msound == MS_GUARDIAN
771                 && quest_info(MS_GUARDIAN) != mnum)) {
772             mon = makemon(&mons[PM_DOPPELGANGER], x, y,
773                           NO_MINVENT | MM_NOCOUNTBIRTH | MM_ADJACENTOK);
774             /* if hero has protection from shape changers, cham field will
775                be NON_PM; otherwise, set form to match the statue */
776             if (mon && mon->cham >= LOW_PM)
777                 (void) newcham(mon, mptr, FALSE, FALSE);
778         } else
779             mon = makemon(mptr, x, y, (cause == ANIMATE_SPELL)
780                                           ? (NO_MINVENT | MM_ADJACENTOK)
781                                           : NO_MINVENT);
782     }
783
784     if (!mon) {
785         if (fail_reason)
786             *fail_reason = unique_corpstat(&mons[statue->corpsenm])
787                                ? AS_MON_IS_UNIQUE
788                                : AS_NO_MON;
789         return (struct monst *) 0;
790     }
791
792     /* a non-montraits() statue might specify gender */
793     if (statue->spe & STATUE_MALE)
794         mon->female = FALSE;
795     else if (statue->spe & STATUE_FEMALE)
796         mon->female = TRUE;
797     /* if statue has been named, give same name to the monster */
798     if (has_oname(statue) && !unique_corpstat(mon->data))
799         mon = christen_monst(mon, ONAME(statue));
800     /* mimic statue becomes seen mimic; other hiders won't be hidden */
801     if (M_AP_TYPE(mon))
802         seemimic(mon);
803     else
804         mon->mundetected = FALSE;
805     mon->msleeping = 0;
806     if (cause == ANIMATE_NORMAL || cause == ANIMATE_SHATTER) {
807         /* trap always releases hostile monster */
808         mon->mtame = 0; /* (might be petrified pet tossed onto trap) */
809         mon->mpeaceful = 0;
810         set_malign(mon);
811     }
812
813 #if 0 /*JP:T*/
814     comes_to_life = !canspotmon(mon)
815                         ? "disappears"
816                         : golem_xform
817                               ? "turns into flesh"
818                               : (nonliving(mon->data) || is_vampshifter(mon))
819                                     ? "moves"
820                                     : "comes to life";
821 #else
822     comes_to_life = !canspotmon(mon)
823                         ? "\8fÁ\82¦"
824                         : golem_xform
825                               ? "\93÷\91Ì\82É\96ß\82Á"
826                               : (nonliving(mon->data) || is_vampshifter(mon))
827                                     ? "\93®\82¢"
828                                     : "\90\96½\82ð\91Ñ\82Ñ";
829 #endif
830     if ((x == u.ux && y == u.uy) || cause == ANIMATE_SPELL) {
831         /* "the|your|Manlobbi's statue [of a wombat]" */
832         shkp = shop_keeper(*in_rooms(mon->mx, mon->my, SHOPBASE));
833 #if 0 /*JP:T*/
834         Sprintf(statuename, "%s%s", shk_your(tmpbuf, statue),
835                 (cause == ANIMATE_SPELL
836                  /* avoid "of a shopkeeper" if it's Manlobbi himself
837                     (if carried, it can't be unpaid--hence won't be
838                     described as "Manlobbi's statue"--because there
839                     wasn't any living shk when statue was picked up) */
840                  && (mon != shkp || carried(statue)))
841                    ? xname(statue)
842                    : "statue");
843 #else
844         Sprintf(statuename, "%s%s", shk_your(tmpbuf, statue),
845                 (cause == ANIMATE_SPELL
846                  && (mon != shkp || carried(statue)))
847                    ? xname(statue)
848                    : "\92¤\91\9c");
849 #endif
850 /*JP
851         pline("%s %s!", upstart(statuename), comes_to_life);
852 */
853         pline("%s\82Í%s\82½\81I", upstart(statuename), comes_to_life);
854     } else if (Hallucination) { /* They don't know it's a statue */
855 /*JP
856         pline_The("%s suddenly seems more animated.", rndmonnam((char *) 0));
857 */
858         pline_The("%s\82Í\93Ë\91R\82æ\82è\8a\88\93®\93I\82É\82È\82Á\82½\81D", rndmonnam((char *) 0));
859     } else if (cause == ANIMATE_SHATTER) {
860         if (cansee(x, y))
861             Sprintf(statuename, "%s%s", shk_your(tmpbuf, statue),
862                     xname(statue));
863         else
864 /*JP
865             Strcpy(statuename, "a statue");
866 */
867             Strcpy(statuename, "\92¤\91\9c");
868 #if 0 /*JP:T*/
869         pline("Instead of shattering, %s suddenly %s!", statuename,
870               comes_to_life);
871 #else
872         pline("%s\82Í\8dÓ\82¯\82¸\82É%s\82½\81I", statuename,
873               comes_to_life);
874 #endif
875     } else { /* cause == ANIMATE_NORMAL */
876 /*JP
877         You("find %s posing as a statue.",
878 */
879         You("%s\82ª\92¤\91\9c\82Ì\82Ó\82è\82ð\82µ\82Ä\82¢\82é\82Ì\82ð\8c©\82Â\82¯\82½\81D",
880             canspotmon(mon) ? a_monnam(mon) : something);
881         if (!canspotmon(mon) && Blind)
882             map_invisible(x, y);
883         stop_occupation();
884     }
885
886     /* if this isn't caused by a monster using a wand of striking,
887        there might be consequences for the hero */
888     if (!context.mon_moving) {
889         /* if statue is owned by a shop, hero will have to pay for it;
890            stolen_value gives a message (about debt or use of credit)
891            which refers to "it" so needs to follow a message describing
892            the object ("the statue comes to life" one above) */
893         if (cause != ANIMATE_NORMAL && costly_spot(x, y)
894             && (carried(statue) ? statue->unpaid : !statue->no_charge)
895             && (shkp = shop_keeper(*in_rooms(x, y, SHOPBASE))) != 0
896             /* avoid charging for Manlobbi's statue of Manlobbi
897                if stone-to-flesh is used on petrified shopkeep */
898             && mon != shkp)
899             (void) stolen_value(statue, x, y, (boolean) shkp->mpeaceful,
900                                 FALSE);
901
902         if (historic) {
903 /*JP
904             You_feel("guilty %s.", historic_statue_is_gone);
905 */
906             You_feel("%s\82É\8dß\82ð\8a´\82\82½\81D", historic_statue_is_gone);
907             adjalign(-1);
908         }
909     } else {
910         if (historic && cansee(x, y))
911 /*JP
912             You_feel("regret %s.", historic_statue_is_gone);
913 */
914             You_feel("%s\82ð\8cã\89÷\82µ\82½\81D", historic_statue_is_gone);
915         /* no alignment penalty */
916     }
917
918     /* transfer any statue contents to monster's inventory */
919     while ((item = statue->cobj) != 0) {
920         obj_extract_self(item);
921         (void) mpickobj(mon, item);
922     }
923     m_dowear(mon, TRUE);
924     /* in case statue is wielded and hero zaps stone-to-flesh at self */
925     if (statue->owornmask)
926         remove_worn_item(statue, TRUE);
927     /* statue no longer exists */
928     delobj(statue);
929
930     /* avoid hiding under nothing */
931     if (x == u.ux && y == u.uy && Upolyd && hides_under(youmonst.data)
932         && !OBJ_AT(x, y))
933         u.uundetected = 0;
934
935     if (fail_reason)
936         *fail_reason = AS_OK;
937     return mon;
938 }
939
940 /*
941  * You've either stepped onto a statue trap's location or you've triggered a
942  * statue trap by searching next to it or by trying to break it with a wand
943  * or pick-axe.
944  */
945 struct monst *
946 activate_statue_trap(trap, x, y, shatter)
947 struct trap *trap;
948 xchar x, y;
949 boolean shatter;
950 {
951     struct monst *mtmp = (struct monst *) 0;
952     struct obj *otmp = sobj_at(STATUE, x, y);
953     int fail_reason;
954
955     /*
956      * Try to animate the first valid statue.  Stop the loop when we
957      * actually create something or the failure cause is not because
958      * the mon was unique.
959      */
960     deltrap(trap);
961     while (otmp) {
962         mtmp = animate_statue(otmp, x, y,
963                               shatter ? ANIMATE_SHATTER : ANIMATE_NORMAL,
964                               &fail_reason);
965         if (mtmp || fail_reason != AS_MON_IS_UNIQUE)
966             break;
967
968         otmp = nxtobj(otmp, STATUE, TRUE);
969     }
970
971     feel_newsym(x, y);
972     return mtmp;
973 }
974
975 STATIC_OVL boolean
976 keep_saddle_with_steedcorpse(steed_mid, objchn, saddle)
977 unsigned steed_mid;
978 struct obj *objchn, *saddle;
979 {
980     if (!saddle)
981         return FALSE;
982     while (objchn) {
983         if (objchn->otyp == CORPSE && has_omonst(objchn)) {
984             struct monst *mtmp = OMONST(objchn);
985
986             if (mtmp->m_id == steed_mid) {
987                 /* move saddle */
988                 xchar x, y;
989                 if (get_obj_location(objchn, &x, &y, 0)) {
990                     obj_extract_self(saddle);
991                     place_object(saddle, x, y);
992                     stackobj(saddle);
993                 }
994                 return TRUE;
995             }
996         }
997         if (Has_contents(objchn)
998             && keep_saddle_with_steedcorpse(steed_mid, objchn->cobj, saddle))
999             return TRUE;
1000         objchn = objchn->nobj;
1001     }
1002     return FALSE;
1003 }
1004
1005 /* monster or you go through and possibly destroy a web.
1006    return TRUE if could go through. */
1007 boolean
1008 mu_maybe_destroy_web(mtmp, domsg, trap)
1009 struct monst *mtmp;
1010 boolean domsg;
1011 struct trap *trap;
1012 {
1013     boolean isyou = (mtmp == &youmonst);
1014     struct permonst *mptr = mtmp->data;
1015
1016     if (amorphous(mptr) || is_whirly(mptr) || flaming(mptr)
1017         || unsolid(mptr) || mptr == &mons[PM_GELATINOUS_CUBE]) {
1018         xchar x = trap->tx;
1019         xchar y = trap->ty;
1020
1021         if (flaming(mptr) || acidic(mptr)) {
1022             if (domsg) {
1023                 if (isyou)
1024 #if 0 /*JP:T*/
1025                     You("%s %s spider web!",
1026                         (flaming(mptr)) ? "burn" : "dissolve",
1027                         a_your[trap->madeby_u]);
1028 #else
1029                     You("%s\82­\82à\82Ì\91\83\82ð%s\81I",
1030                         web_you[trap->madeby_u],
1031                         (flaming(mptr)) ? "\8fÄ\82¢\82½" : "\82±\82È\82²\82È\82É\82µ\82½");
1032 #endif
1033                 else
1034 #if 0 /*JP:T*/
1035                     pline("%s %s %s spider web!", Monnam(mtmp),
1036                           (flaming(mptr)) ? "burns" : "dissolves",
1037                           a_your[trap->madeby_u]);
1038 #else
1039                     pline("%s%s\82­\82à\82Ì\91\83\82ð%s\81I", Monnam(mtmp),
1040                         web_you[trap->madeby_u],
1041                         (flaming(mptr)) ? "\8fÄ\82¢\82½" : "\82±\82È\82²\82È\82É\82µ\82½");
1042 #endif
1043             }
1044             deltrap(trap);
1045             newsym(x, y);
1046             return TRUE;
1047         }
1048         if (domsg) {
1049             if (isyou) {
1050 /*JP
1051                 You("flow through %s spider web.", a_your[trap->madeby_u]);
1052 */
1053                 You("%s\82­\82à\82Ì\91\83\82ð\82·\82é\82è\82Æ\92Ê\82è\94²\82¯\82½\81D", web_you[trap->madeby_u]);
1054             } else {
1055 #if 0 /*JP:T*/
1056                 pline("%s flows through %s spider web.", Monnam(mtmp),
1057                       a_your[trap->madeby_u]);
1058 #else
1059                 pline("%s\82Í%s\82­\82à\82Ì\91\83\82ð\82·\82é\82è\82Æ\92Ê\82è\94²\82¯\82½\81D", Monnam(mtmp),
1060                       web_you[trap->madeby_u]);
1061 #endif
1062                 seetrap(trap);
1063             }
1064         }
1065         return TRUE;
1066     }
1067     return FALSE;
1068 }
1069
1070 /* make a single arrow/dart/rock for a trap to shoot or drop */
1071 STATIC_OVL struct obj *
1072 t_missile(otyp, trap)
1073 int otyp;
1074 struct trap *trap;
1075 {
1076     struct obj *otmp = mksobj(otyp, TRUE, FALSE);
1077
1078     otmp->quan = 1L;
1079     otmp->owt = weight(otmp);
1080     otmp->opoisoned = 0;
1081     otmp->ox = trap->tx, otmp->oy = trap->ty;
1082     return otmp;
1083 }
1084
1085 void
1086 set_utrap(tim, typ)
1087 unsigned tim, typ;
1088 {
1089     u.utrap = tim;
1090     /* FIXME:
1091      * utraptype==0 is bear trap rather than 'none'; we probably ought
1092      * to change that but can't do so until save file compatability is
1093      * able to be broken.
1094      */
1095     u.utraptype = tim ? typ : 0;
1096
1097     float_vs_flight(); /* maybe block Lev and/or Fly */
1098 }
1099
1100 void
1101 reset_utrap(msg)
1102 boolean msg;
1103 {
1104     boolean was_Lev = (Levitation != 0), was_Fly = (Flying != 0);
1105
1106     set_utrap(0, 0);
1107
1108     if (msg) {
1109         if (!was_Lev && Levitation)
1110             float_up();
1111         if (!was_Fly && Flying)
1112 /*JP
1113             You("can fly.");
1114 */
1115             You("\94ò\82×\82é\82æ\82¤\82É\82È\82Á\82½\81D");
1116     }
1117 }
1118
1119 void
1120 dotrap(trap, trflags)
1121 register struct trap *trap;
1122 unsigned trflags;
1123 {
1124     register int ttype = trap->ttyp;
1125     struct obj *otmp;
1126     boolean already_seen = trap->tseen,
1127             forcetrap = ((trflags & FORCETRAP) != 0
1128                          || (trflags & FAILEDUNTRAP) != 0),
1129             webmsgok = (trflags & NOWEBMSG) == 0,
1130             forcebungle = (trflags & FORCEBUNGLE) != 0,
1131             plunged = (trflags & TOOKPLUNGE) != 0,
1132             viasitting = (trflags & VIASITTING) != 0,
1133             conj_pit = conjoined_pits(trap, t_at(u.ux0, u.uy0), TRUE),
1134             adj_pit = adj_nonconjoined_pit(trap);
1135     int oldumort;
1136     int steed_article = ARTICLE_THE;
1137
1138     nomul(0);
1139
1140     /* KMH -- You can't escape the Sokoban level traps */
1141     if (Sokoban && (is_pit(ttype) || is_hole(ttype))) {
1142         /* The "air currents" message is still appropriate -- even when
1143          * the hero isn't flying or levitating -- because it conveys the
1144          * reason why the player cannot escape the trap with a dexterity
1145          * check, clinging to the ceiling, etc.
1146          */
1147 #if 0 /*JP:T*/
1148         pline("Air currents pull you down into %s %s!",
1149               a_your[trap->madeby_u],
1150               defsyms[trap_to_defsym(ttype)].explanation);
1151 #else
1152         pline("\8bó\8bC\82Ì\97¬\82ê\82ª\82 \82È\82½\82ð%s\82É\88ø\82«\96ß\82µ\82½\81I",
1153               defsyms[trap_to_defsym(ttype)].explanation);
1154 #endif
1155         /* then proceed to normal trap effect */
1156     } else if (already_seen && !forcetrap) {
1157         if ((Levitation || (Flying && !plunged))
1158             && (is_pit(ttype) || ttype == HOLE || ttype == BEAR_TRAP)) {
1159 #if 0 /*JP:T*/
1160             You("%s over %s %s.", Levitation ? "float" : "fly",
1161                 a_your[trap->madeby_u],
1162                 defsyms[trap_to_defsym(ttype)].explanation);
1163 #else
1164             You("%s%s\82Ì\8fã%s\81D",
1165                 set_you[trap->madeby_u],
1166                 defsyms[trap_to_defsym(ttype)].explanation,
1167                 Levitation ? "\82ð\8c©\89º\82ë\82µ\82½" : "\82ð\94ò\82ñ\82Å\82¢\82é");
1168 #endif
1169             return;
1170         }
1171         if (!Fumbling && ttype != MAGIC_PORTAL && ttype != VIBRATING_SQUARE
1172             && ttype != ANTI_MAGIC && !forcebungle && !plunged
1173             && !conj_pit && !adj_pit
1174             && (!rn2(5) || (is_pit(ttype)
1175                             && is_clinger(youmonst.data)))) {
1176 #if 0 /*JP:T*/
1177                 You("escape %s %s.", (ttype == ARROW_TRAP && !trap->madeby_u)
1178                                      ? "an"
1179                                      : a_your[trap->madeby_u],
1180                 defsyms[trap_to_defsym(ttype)].explanation);
1181 #else
1182                 You("%s%s\82ð\82·\82é\82è\82Æ\94ð\82¯\82½\81D",
1183                     set_you[trap->madeby_u],
1184                     defsyms[trap_to_defsym(ttype)].explanation);
1185 #endif
1186             return;
1187         }
1188     }
1189
1190     if (u.usteed) {
1191         u.usteed->mtrapseen |= (1 << (ttype - 1));
1192         /* suppress article in various steed messages when using its
1193            name (which won't occur when hallucinating) */
1194         if (has_mname(u.usteed) && !Hallucination)
1195             steed_article = ARTICLE_NONE;
1196     }
1197
1198     switch (ttype) {
1199     case ARROW_TRAP:
1200         if (trap->once && trap->tseen && !rn2(15)) {
1201 /*JP
1202             You_hear("a loud click!");
1203 */
1204             You_hear("\83K\83`\83\83\83b\82Æ\82¢\82¤\91å\82«\82È\89¹\82ð\95·\82¢\82½\81I");
1205             deltrap(trap);
1206             newsym(u.ux, u.uy);
1207             break;
1208         }
1209         trap->once = 1;
1210         seetrap(trap);
1211 /*JP
1212         pline("An arrow shoots out at you!");
1213 */
1214         pline("\96î\82ª\94ò\82ñ\82Å\82«\82½\81I");
1215         otmp = t_missile(ARROW, trap);
1216         if (u.usteed && !rn2(2) && steedintrap(trap, otmp)) {
1217             ; /* nothing */
1218 #if 0 /*JP:T*/
1219         } else if (thitu(8, dmgval(otmp, &youmonst), &otmp, "arrow")) {
1220 #else
1221         } else if (thitu(8, dmgval(otmp, &youmonst), &otmp, "\96î")) {
1222 #endif
1223             if (otmp)
1224                 obfree(otmp, (struct obj *) 0);
1225         } else {
1226             place_object(otmp, u.ux, u.uy);
1227             if (!Blind)
1228                 otmp->dknown = 1;
1229             stackobj(otmp);
1230             newsym(u.ux, u.uy);
1231         }
1232         break;
1233
1234     case DART_TRAP:
1235         if (trap->once && trap->tseen && !rn2(15)) {
1236 /*JP
1237             You_hear("a soft click.");
1238 */
1239             You_hear("\83J\83`\83b\82Æ\82¢\82¤\89¹\82ð\95·\82¢\82½\81D");
1240             deltrap(trap);
1241             newsym(u.ux, u.uy);
1242             break;
1243         }
1244         trap->once = 1;
1245         seetrap(trap);
1246 /*JP
1247         pline("A little dart shoots out at you!");
1248 */
1249         pline("\8f¬\82³\82È\93\8a\82°\96î\82ª\94ò\82ñ\82Å\82«\82½\81I");
1250         otmp = t_missile(DART, trap);
1251         if (!rn2(6))
1252             otmp->opoisoned = 1;
1253         oldumort = u.umortality;
1254         if (u.usteed && !rn2(2) && steedintrap(trap, otmp)) {
1255             ; /* nothing */
1256 #if 0 /*JP:T*/
1257         } else if (thitu(7, dmgval(otmp, &youmonst), &otmp, "little dart")) {
1258 #else
1259         } else if (thitu(7, dmgval(otmp, &youmonst), &otmp, "\93\8a\82°\96î")) {
1260 #endif
1261             if (otmp) {
1262                 if (otmp->opoisoned)
1263 #if 0 /*JP:T*/
1264                     poisoned("dart", A_CON, "little dart",
1265                              /* if damage triggered life-saving,
1266                                 poison is limited to attrib loss */
1267                              (u.umortality > oldumort) ? 0 : 10, TRUE);
1268 #else
1269                     poisoned("\93\8a\82°\96î", A_CON, "\8f¬\82³\82È\93\8a\82°\96î",
1270                              /* if damage triggered life-saving,
1271                                 poison is limited to attrib loss */
1272                              (u.umortality > oldumort) ? 0 : 10, TRUE);
1273 #endif
1274                 obfree(otmp, (struct obj *) 0);
1275             }
1276         } else {
1277             place_object(otmp, u.ux, u.uy);
1278             if (!Blind)
1279                 otmp->dknown = 1;
1280             stackobj(otmp);
1281             newsym(u.ux, u.uy);
1282         }
1283         break;
1284
1285     case ROCKTRAP:
1286         if (trap->once && trap->tseen && !rn2(15)) {
1287 /*JP
1288             pline("A trap door in %s opens, but nothing falls out!",
1289 */
1290             pline("\97\8e\82µ\94à\82ª%s\82É\8aJ\82¢\82½\82ª\81C\89½\82à\97\8e\82¿\82Ä\82±\82È\82©\82Á\82½\81I",
1291                   the(ceiling(u.ux, u.uy)));
1292             deltrap(trap);
1293             newsym(u.ux, u.uy);
1294         } else {
1295             int dmg = d(2, 6); /* should be std ROCK dmg? */
1296
1297             trap->once = 1;
1298             feeltrap(trap);
1299             otmp = t_missile(ROCK, trap);
1300             place_object(otmp, u.ux, u.uy);
1301
1302 #if 0 /*JP:T*/
1303             pline("A trap door in %s opens and %s falls on your %s!",
1304                   the(ceiling(u.ux, u.uy)), an(xname(otmp)), body_part(HEAD));
1305 #else
1306             pline("\97\8e\82µ\94à\82ª%s\82É\8aJ\82«\81C%s\82ª\82 \82È\82½\82Ì%s\82É\97\8e\82¿\82Ä\82«\82½\81I",
1307                   ceiling(u.ux,u.uy), xname(otmp), body_part(HEAD));
1308 #endif
1309             if (uarmh) {
1310                 if (is_metallic(uarmh)) {
1311 /*JP
1312                     pline("Fortunately, you are wearing a hard helmet.");
1313 */
1314                     pline("\8dK\89^\82É\82à\81C\82 \82È\82½\82Í\8cÅ\82¢\8a\95\82ð\90g\82É\82Â\82¯\82Ä\82¢\82½\81D");
1315                     dmg = 2;
1316                 } else if (flags.verbose) {
1317 /*JP
1318                     pline("%s does not protect you.", Yname2(uarmh));
1319 */
1320                     pline("%s\82Å\82Í\96h\82°\82È\82¢\81D", xname(uarmh));
1321                 }
1322             }
1323             if (!Blind)
1324                 otmp->dknown = 1;
1325             stackobj(otmp);
1326             newsym(u.ux, u.uy); /* map the rock */
1327
1328 /*JP
1329             losehp(Maybe_Half_Phys(dmg), "falling rock", KILLED_BY_AN);
1330 */
1331             losehp(Maybe_Half_Phys(dmg), "\97\8e\8aâ\82Å", KILLED_BY_AN);
1332             exercise(A_STR, FALSE);
1333         }
1334         break;
1335
1336     case SQKY_BOARD: /* stepped on a squeaky board */
1337         if ((Levitation || Flying) && !forcetrap) {
1338             if (!Blind) {
1339                 seetrap(trap);
1340                 if (Hallucination)
1341 /*JP
1342                     You("notice a crease in the linoleum.");
1343 */
1344                     You("\8f°\82Ì\8ed\8fã\8dÞ\82Ì\82µ\82í\82É\8bC\82ª\82Â\82¢\82½\81D");
1345                 else
1346 /*JP
1347                     You("notice a loose board below you.");
1348 */
1349                     You("\91«\8c³\82Ì\8aÉ\82ñ\82¾\94Â\82É\8bC\82ª\82Â\82¢\82½\81D");
1350             }
1351         } else {
1352             seetrap(trap);
1353 #if 0 /*JP*/
1354             pline("A board beneath you %s%s%s.",
1355                   Deaf ? "vibrates" : "squeaks ",
1356                   Deaf ? "" : trapnote(trap, 0), Deaf ? "" : " loudly");
1357 #else
1358             if (Deaf) {
1359                 pline("\91«\8c³\82Ì\94Â\82ª\82ä\82ê\82½\81D");
1360             } else {
1361                 pline("\91«\8c³\82Ì\94Â\82ª\91å\82«\82­%s\82Ì\89¹\82É\82«\82µ\82ñ\82¾\81D", trapnote(trap, 0));
1362             }
1363 #endif
1364             wake_nearby();
1365         }
1366         break;
1367
1368     case BEAR_TRAP: {
1369         int dmg = d(2, 4);
1370
1371         if ((Levitation || Flying) && !forcetrap)
1372             break;
1373         feeltrap(trap);
1374         if (amorphous(youmonst.data) || is_whirly(youmonst.data)
1375             || unsolid(youmonst.data)) {
1376 #if 0 /*JP:T*/
1377             pline("%s bear trap closes harmlessly through you.",
1378                   A_Your[trap->madeby_u]);
1379 #else
1380             pline("%s\8cF\82Ìã©\82Í\8a\9a\82Ý\82Â\82¢\82½\82ª\81C\82·\82é\82Á\82Æ\92Ê\82è\94²\82¯\82½\81D",
1381                   set_you[trap->madeby_u]);
1382 #endif
1383             break;
1384         }
1385         if (!u.usteed && youmonst.data->msize <= MZ_SMALL) {
1386 #if 0 /*JP:T*/
1387             pline("%s bear trap closes harmlessly over you.",
1388                   A_Your[trap->madeby_u]);
1389 #else
1390             pline("%s\8cF\82Ìã©\82Í\8a\9a\82Ý\82Â\82¢\82½\82ª\81C\97y\82©\8fã\95û\82¾\82Á\82½\81D",
1391                   set_you[trap->madeby_u]);
1392 #endif
1393             break;
1394         }
1395         set_utrap((unsigned) rn1(4, 4), TT_BEARTRAP);
1396         if (u.usteed) {
1397 #if 0 /*JP:T*/
1398             pline("%s bear trap closes on %s %s!", A_Your[trap->madeby_u],
1399                   s_suffix(mon_nam(u.usteed)), mbodypart(u.usteed, FOOT));
1400 #else
1401             pline("%s\8cF\82Ìã©\82Í%s\82Ì%s\82É\8a\9a\82Ý\82Â\82¢\82½\81I", set_you[trap->madeby_u],
1402                   mon_nam(u.usteed), mbodypart(u.usteed, FOOT));
1403 #endif
1404             if (thitm(0, u.usteed, (struct obj *) 0, dmg, FALSE))
1405                 reset_utrap(TRUE); /* steed died, hero not trapped */
1406         } else {
1407 #if 0 /*JP:T*/
1408             pline("%s bear trap closes on your %s!", A_Your[trap->madeby_u],
1409                   body_part(FOOT));
1410 #else
1411             pline("%s\8cF\82Ìã©\82ª\82 \82È\82½\82Ì%s\82É\8a\9a\82Ý\82Â\82¢\82½\81I", set_you[trap->madeby_u],
1412                   body_part(FOOT));
1413 #endif
1414             set_wounded_legs(rn2(2) ? RIGHT_SIDE : LEFT_SIDE, rn1(10, 10));
1415             if (u.umonnum == PM_OWLBEAR || u.umonnum == PM_BUGBEAR)
1416 /*JP
1417                 You("howl in anger!");
1418 */
1419                 You("\93{\82è\82Ì\99ô\9aK\82ð\82 \82°\82½\81I");
1420 /*JP
1421             losehp(Maybe_Half_Phys(dmg), "bear trap", KILLED_BY_AN);
1422 */
1423             losehp(Maybe_Half_Phys(dmg), "\8cF\82Ìã©\82Å", KILLED_BY_AN);
1424         }
1425         exercise(A_DEX, FALSE);
1426         break;
1427     }
1428
1429     case SLP_GAS_TRAP:
1430         seetrap(trap);
1431         if (Sleep_resistance || breathless(youmonst.data)) {
1432 /*JP
1433             You("are enveloped in a cloud of gas!");
1434 */
1435             You("\83K\83X\89_\82É\82Â\82Â\82Ü\82ê\82½\81I");
1436         } else {
1437 /*JP
1438             pline("A cloud of gas puts you to sleep!");
1439 */
1440             pline("\82 \82È\82½\82Í\83K\83X\89_\82Å\96°\82Á\82Ä\82µ\82Ü\82Á\82½\81I");
1441             fall_asleep(-rnd(25), TRUE);
1442         }
1443         (void) steedintrap(trap, (struct obj *) 0);
1444         break;
1445
1446     case RUST_TRAP:
1447         seetrap(trap);
1448
1449         /* Unlike monsters, traps cannot aim their rust attacks at
1450          * you, so instead of looping through and taking either the
1451          * first rustable one or the body, we take whatever we get,
1452          * even if it is not rustable.
1453          */
1454         switch (rn2(5)) {
1455         case 0:
1456 /*JP
1457             pline("%s you on the %s!", A_gush_of_water_hits, body_part(HEAD));
1458 */
1459             pline("\90\85\82ª\95¬\8fo\82µ\82Ä\82 \82È\82½\82Ì%s\82É\96½\92\86\82µ\82½\81I", body_part(HEAD));
1460             (void) water_damage(uarmh, helm_simple_name(uarmh), TRUE);
1461             break;
1462         case 1:
1463 /*JP
1464             pline("%s your left %s!", A_gush_of_water_hits, body_part(ARM));
1465 */
1466             pline("\90\85\82ª\95¬\8fo\82µ\82Ä\82 \82È\82½\82Ì\8d¶%s\82É\96½\92\86\82µ\82½\81I", body_part(ARM));
1467 /*JP
1468             if (water_damage(uarms, "shield", TRUE) != ER_NOTHING)
1469 */
1470             if (water_damage(uarms, "\8f\82", TRUE) != ER_NOTHING)
1471                 break;
1472             if (u.twoweap || (uwep && bimanual(uwep)))
1473                 (void) water_damage(u.twoweap ? uswapwep : uwep, 0, TRUE);
1474         glovecheck:
1475 /*JP
1476             (void) water_damage(uarmg, "gauntlets", TRUE);
1477 */
1478             (void) water_damage(uarmg, "\8f¬\8eè", TRUE);
1479             /* Not "metal gauntlets" since it gets called
1480              * even if it's leather for the message
1481              */
1482             break;
1483         case 2:
1484 /*JP
1485             pline("%s your right %s!", A_gush_of_water_hits, body_part(ARM));
1486 */
1487             pline("\90\85\82ª\95¬\8fo\82µ\82Ä\82 \82È\82½\82Ì\89E%s\82É\96½\92\86\82µ\82½\81I", body_part(ARM));
1488             (void) water_damage(uwep, 0, TRUE);
1489             goto glovecheck;
1490         default:
1491 /*JP
1492             pline("%s you!", A_gush_of_water_hits);
1493 */
1494             pline("\90\85\82ª\95¬\8fo\82µ\82Ä\82 \82È\82½\82É\96½\92\86\82µ\82½\81I");
1495             for (otmp = invent; otmp; otmp = otmp->nobj)
1496                 if (otmp->lamplit && otmp != uwep
1497                     && (otmp != uswapwep || !u.twoweap))
1498                     (void) snuff_lit(otmp);
1499             if (uarmc)
1500                 (void) water_damage(uarmc, cloak_simple_name(uarmc), TRUE);
1501             else if (uarm)
1502                 (void) water_damage(uarm, suit_simple_name(uarm), TRUE);
1503             else if (uarmu)
1504 /*JP
1505                 (void) water_damage(uarmu, "shirt", TRUE);
1506 */
1507                 (void) water_damage(uarmu, "\83V\83\83\83c", TRUE);
1508         }
1509         update_inventory();
1510
1511         if (u.umonnum == PM_IRON_GOLEM) {
1512             int dam = u.mhmax;
1513
1514 /*JP
1515             You("are covered with rust!");
1516 */
1517             You("\8eK\82É\95¢\82í\82ê\82½\81I");
1518 /*JP
1519             losehp(Maybe_Half_Phys(dam), "rusting away", KILLED_BY);
1520 */
1521             losehp(Maybe_Half_Phys(dam), "\8a®\91S\82É\8eK\82Ñ\82Ä", KILLED_BY);
1522         } else if (u.umonnum == PM_GREMLIN && rn2(3)) {
1523             (void) split_mon(&youmonst, (struct monst *) 0);
1524         }
1525
1526         break;
1527
1528     case FIRE_TRAP:
1529         seetrap(trap);
1530         dofiretrap((struct obj *) 0);
1531         break;
1532
1533     case PIT:
1534     case SPIKED_PIT:
1535         /* KMH -- You can't escape the Sokoban level traps */
1536         if (!Sokoban && (Levitation || (Flying && !plunged)))
1537             break;
1538         feeltrap(trap);
1539         if (!Sokoban && is_clinger(youmonst.data) && !plunged) {
1540             if (trap->tseen) {
1541 #if 0 /*JP:T*/
1542                 You_see("%s %spit below you.", a_your[trap->madeby_u],
1543                         ttype == SPIKED_PIT ? "spiked " : "");
1544 #else
1545                 pline("\91«\8c³\82É%s%s\97\8e\82µ\8c\8a\82ð\94­\8c©\82µ\82½\81D", dig_you[trap->madeby_u],
1546                       ttype == SPIKED_PIT ? "\83g\83Q\82¾\82ç\82¯\82Ì" : "");
1547 #endif
1548             } else {
1549 #if 0 /*JP:T*/
1550                 pline("%s pit %sopens up under you!", A_Your[trap->madeby_u],
1551                       ttype == SPIKED_PIT ? "full of spikes " : "");
1552 #else
1553                 pline("%s%s\97\8e\82µ\8c\8a\82ª\91«\8c³\82É\8aJ\82¢\82½\81I", dig_you[trap->madeby_u],
1554                       ttype == SPIKED_PIT ? "\83g\83Q\82¾\82ç\82¯\82Ì" : "");
1555 #endif
1556 /*JP
1557                 You("don't fall in!");
1558 */
1559                 pline("\82µ\82©\82µ\81C\82 \82È\82½\82Í\97\8e\82¿\82È\82©\82Á\82½\81I");
1560             }
1561             break;
1562         }
1563         if (!Sokoban) {
1564             char verbbuf[BUFSZ];
1565
1566             *verbbuf = '\0';
1567             if (u.usteed) {
1568                 if ((trflags & RECURSIVETRAP) != 0)
1569 /*JP
1570                     Sprintf(verbbuf, "and %s fall",
1571 */
1572                     Sprintf(verbbuf, "\82Æ%s",
1573                             x_monnam(u.usteed, steed_article, (char *) 0,
1574                                      SUPPRESS_SADDLE, FALSE));
1575                 else
1576 #if 0 /*JP:T*/
1577                     Sprintf(verbbuf, "lead %s",
1578                             x_monnam(u.usteed, steed_article, "poor",
1579                                      SUPPRESS_SADDLE, FALSE));
1580 #else
1581                     Sprintf(verbbuf, "\82Æ%s",
1582                             x_monnam(u.usteed, steed_article, "\82©\82í\82¢\82»\82¤\82È",
1583                                      SUPPRESS_SADDLE, FALSE));
1584 #endif
1585             } else if (conj_pit) {
1586 /*JP
1587                 You("move into an adjacent pit.");
1588 */
1589                 You("\97×\82Ì\97\8e\82µ\8c\8a\82É\88Ú\93®\82µ\82½\81D");
1590             } else if (adj_pit) {
1591 #if 0 /*JP:T*/
1592                 You("stumble over debris%s.",
1593                     !rn2(5) ? " between the pits" : "");
1594 #else
1595                 You("\82Í%s\82ª\82ç\82­\82½\82Å\82Â\82Ü\82Ã\82¢\82½\81D",
1596                     !rn2(5) ? "\97\8e\82µ\8c\8a\82Ì" : "");
1597 #endif
1598             } else {
1599 #if 0 /*JP:T*/
1600                 Strcpy(verbbuf,
1601                        !plunged ? "fall" : (Flying ? "dive" : "plunge"));
1602 #else
1603                 Strcpy(verbbuf,
1604                        !plunged ? "\97\8e\82¿\82½" : (Flying ? "\94ò\82Ñ\8d\9e\82ñ\82¾" : "\93Ë\93ü\82µ\82½"));
1605 #endif
1606             }
1607             if (*verbbuf)
1608 /*JP
1609                 You("%s into %s pit!", verbbuf, a_your[trap->madeby_u]);
1610 */
1611                 You("%s\97\8e\82µ\8c\8a\82É%s!", set_you[trap->madeby_u], verbbuf);
1612         }
1613         /* wumpus reference */
1614         if (Role_if(PM_RANGER) && !trap->madeby_u && !trap->once
1615             && In_quest(&u.uz) && Is_qlocate(&u.uz)) {
1616 /*JP
1617             pline("Fortunately it has a bottom after all...");
1618 */
1619             pline("\8dK\82¢\81C\8c\8b\8bÇ\82Í\92ê\82ª\82 \82Á\82½\81D\81D\81D");
1620             trap->once = 1;
1621         } else if (u.umonnum == PM_PIT_VIPER || u.umonnum == PM_PIT_FIEND) {
1622 /*JP
1623             pline("How pitiful.  Isn't that the pits?");
1624 */
1625             pline("\82±\82Ì\97\8e\82µ\8c\8a\82Í\82¢\82¢\8ed\8e\96\82ð\82µ\82Ä\82¢\82é\81D");
1626         }
1627         if (ttype == SPIKED_PIT) {
1628 /*JP
1629             const char *predicament = "on a set of sharp iron spikes";
1630 */
1631             const char *predicament = "\89s\82¢\93S\82Ì\83g\83Q\83g\83Q\82Ì\8fã\82É";
1632
1633             if (u.usteed) {
1634 #if 0 /*JP:T*/
1635                 pline("%s %s %s!",
1636                       upstart(x_monnam(u.usteed, steed_article, "poor",
1637                                        SUPPRESS_SADDLE, FALSE)),
1638                       conj_pit ? "steps" : "lands", predicament);
1639 #else
1640                 pline("%s\82Í%s%s\81I",
1641                       upstart(x_monnam(u.usteed, steed_article, "\82©\82í\82¢\82»\82¤\82È",
1642                                        SUPPRESS_SADDLE, FALSE)),
1643                       predicament, conj_pit ? "\97\8e\82¿\82½" : "\8d~\82è\82½");
1644 #endif
1645             } else
1646 /*JP
1647                 You("%s %s!", conj_pit ? "step" : "land", predicament);
1648 */
1649                 You("%s%s\81I", predicament, conj_pit ? "\97\8e\82¿\82½" : "\8d~\82è\82½");
1650         }
1651         /* FIXME:
1652          * if hero gets killed here, setting u.utrap in advance will
1653          * show "you were trapped in a pit" during disclosure's display
1654          * of enlightenment, but hero is dying *before* becoming trapped.
1655          */
1656         set_utrap((unsigned) rn1(6, 2), TT_PIT);
1657         if (!steedintrap(trap, (struct obj *) 0)) {
1658             if (ttype == SPIKED_PIT) {
1659                 oldumort = u.umortality;
1660 #if 0 /*JP:T*/
1661                 losehp(Maybe_Half_Phys(rnd(conj_pit ? 4 : adj_pit ? 6 : 10)),
1662                        /* note: these don't need locomotion() handling;
1663                           if fatal while poly'd and Unchanging, the
1664                           death reason will be overridden with
1665                           "killed while stuck in creature form" */
1666                        plunged
1667                           ? "deliberately plunged into a pit of iron spikes"
1668                           : conj_pit
1669                              ? "stepped into a pit of iron spikes"
1670                              : adj_pit
1671                                 ? "stumbled into a pit of iron spikes"
1672                                 : "fell into a pit of iron spikes",
1673                        NO_KILLER_PREFIX);
1674 #else
1675                 losehp(Maybe_Half_Phys(rnd(conj_pit ? 4 : adj_pit ? 6 : 10)),
1676                        plunged
1677                           ? "\82í\82´\82í\82´\83g\83Q\82¾\82ç\82¯\82Ì\97\8e\82µ\8c\8a\82É\93Ë\93ü\82µ\82Ä"
1678                           : conj_pit
1679                              ? "\83g\83Q\82¾\82ç\82¯\82Ì\97\8e\82µ\8c\8a\82É\93¥\82Ý\8d\9e\82ñ\82Å"
1680                              : adj_pit
1681                                 ? "\83g\83Q\82¾\82ç\82¯\82Ì\97\8e\82µ\8c\8a\82É\82æ\82ë\82ß\82«\97\8e\82¿\82Ä"
1682                                 : "\83g\83Q\82¾\82ç\82¯\82Ì\97\8e\82µ\8c\8a\82É\97\8e\82¿\82Ä",
1683                        KILLED_BY);
1684 #endif
1685                 if (!rn2(6))
1686 #if 0 /*JP:T*/
1687                     poisoned("spikes", A_STR,
1688                              (conj_pit || adj_pit)
1689                                 ? "stepping on poison spikes"
1690                                 : "fall onto poison spikes",
1691                              /* if damage triggered life-saving,
1692                                 poison is limited to attrib loss */
1693                              (u.umortality > oldumort) ? 0 : 8, FALSE);
1694 #else
1695                     poisoned("\83g\83Q", A_STR,
1696                              (conj_pit || adj_pit)
1697                                 ? "\93Å\82Ì\93h\82ç\82ê\82½\83g\83Q\82ð\93¥\82ñ\82Å"
1698                                 : "\93Å\82Ì\93h\82ç\82ê\82½\83g\83Q\82Ì\8fã\82É\97\8e\82¿\82Ä",
1699                              /* if damage triggered life-saving,
1700                                 poison is limited to attrib loss */
1701                              (u.umortality > oldumort) ? 0 : 8, FALSE);
1702 #endif
1703             } else {
1704                 /* plunging flyers take spike damage but not pit damage */
1705                 if (!conj_pit
1706                     && !(plunged && (Flying || is_clinger(youmonst.data))))
1707 #if 0 /*JP:T*/
1708                     losehp(Maybe_Half_Phys(rnd(adj_pit ? 3 : 6)),
1709                            plunged ? "deliberately plunged into a pit"
1710                                    : "fell into a pit",
1711                            NO_KILLER_PREFIX);
1712 #else
1713                     losehp(Maybe_Half_Phys(rnd(adj_pit ? 3 : 6)),
1714                            plunged ? "\82í\82´\82í\82´\97\8e\82µ\8c\8a\82É\93Ë\93ü\82µ\82Ä"
1715                                    : "\97\8e\82µ\8c\8a\82É\97\8e\82¿\82Ä",
1716                            KILLED_BY);
1717 #endif
1718             }
1719             if (Punished && !carried(uball)) {
1720                 unplacebc();
1721                 ballfall();
1722                 placebc();
1723             }
1724             if (!conj_pit)
1725 /*JP
1726                 selftouch("Falling, you");
1727 */
1728                 selftouch("\97\8e\89º\92\86\81C\82 \82È\82½\82Í");
1729             vision_full_recalc = 1; /* vision limits change */
1730             exercise(A_STR, FALSE);
1731             exercise(A_DEX, FALSE);
1732         }
1733         break;
1734
1735     case HOLE:
1736     case TRAPDOOR:
1737         if (!Can_fall_thru(&u.uz)) {
1738             seetrap(trap); /* normally done in fall_through */
1739             impossible("dotrap: %ss cannot exist on this level.",
1740                        defsyms[trap_to_defsym(ttype)].explanation);
1741             break; /* don't activate it after all */
1742         }
1743         fall_through(TRUE, (trflags & TOOKPLUNGE));
1744         break;
1745
1746     case TELEP_TRAP:
1747         seetrap(trap);
1748         tele_trap(trap);
1749         break;
1750
1751     case LEVEL_TELEP:
1752         seetrap(trap);
1753         level_tele_trap(trap, trflags);
1754         break;
1755
1756     case WEB: /* Our luckless player has stumbled into a web. */
1757         feeltrap(trap);
1758         if (mu_maybe_destroy_web(&youmonst, webmsgok, trap))
1759             break;
1760         if (webmaker(youmonst.data)) {
1761             if (webmsgok)
1762 #if 0 /*JP:T*/
1763                 pline(trap->madeby_u ? "You take a walk on your web."
1764                                      : "There is a spider web here.");
1765 #else
1766                 pline(trap->madeby_u ? "\8e©\95ª\82Å\92£\82Á\82½\82­\82à\82Ì\91\83\82Ì\8fã\82ð\95à\82¢\82½\81D"
1767                                      : "\82±\82±\82É\82Í\82­\82à\82Ì\91\83\82ª\82 \82é\81D");
1768 #endif
1769             break;
1770         }
1771         if (webmsgok) {
1772             char verbbuf[BUFSZ];
1773
1774 #if 0 /*JP*/
1775             if (forcetrap || viasitting) {
1776                 Strcpy(verbbuf, "are caught by");
1777             } else if (u.usteed) {
1778                 Sprintf(verbbuf, "lead %s into",
1779                         x_monnam(u.usteed, steed_article, "poor",
1780                                  SUPPRESS_SADDLE, FALSE));
1781             } else {
1782                 Sprintf(verbbuf, "%s into",
1783                         Levitation ? (const char *) "float"
1784                                    : locomotion(youmonst.data, "stumble"));
1785             }
1786             You("%s %s spider web!", verbbuf, a_your[trap->madeby_u]);
1787 #else
1788             if (forcetrap) {
1789                 Strcpy(verbbuf, "\82 \82È\82½\82Í");
1790             } else if (u.usteed) {
1791                 Sprintf(verbbuf, "\82 \82È\82½\82Æ%s",
1792                         x_monnam(u.usteed, steed_article, "\82©\82í\82¢\82»\82¤\82È",
1793                                  SUPPRESS_SADDLE, FALSE));
1794             } else {
1795                 Sprintf(verbbuf, "\82 \82È\82½\82Í%s",
1796                         Levitation ? (const char *) "\95\82\82«\82È\82ª\82ç"
1797                         : jconj(locomotion(youmonst.data, "\82Â\82Ü\82¸\82­"), "\82Ä"));
1798             }
1799             pline("%s%s\82­\82à\82Ì\91\83\82É\82Ð\82Á\82©\82©\82Á\82½\81I", verbbuf, web_you[trap->madeby_u]);
1800 #endif
1801         }
1802
1803         /* time will be adjusted below */
1804         set_utrap(1, TT_WEB);
1805
1806         /* Time stuck in the web depends on your/steed strength. */
1807         {
1808             int tim, str = ACURR(A_STR);
1809
1810             /* If mounted, the steed gets trapped.  Use mintrap
1811              * to do all the work.  If mtrapped is set as a result,
1812              * unset it and set utrap instead.  In the case of a
1813              * strongmonst and mintrap said it's trapped, use a
1814              * short but non-zero trap time.  Otherwise, monsters
1815              * have no specific strength, so use player strength.
1816              * This gets skipped for webmsgok, which implies that
1817              * the steed isn't a factor.
1818              */
1819             if (u.usteed && webmsgok) {
1820                 /* mtmp location might not be up to date */
1821                 u.usteed->mx = u.ux;
1822                 u.usteed->my = u.uy;
1823
1824                 /* mintrap currently does not return 2(died) for webs */
1825                 if (mintrap(u.usteed)) {
1826                     u.usteed->mtrapped = 0;
1827                     if (strongmonst(u.usteed->data))
1828                         str = 17;
1829                 } else {
1830                     reset_utrap(FALSE);
1831                     break;
1832                 }
1833
1834                 webmsgok = FALSE; /* mintrap printed the messages */
1835             }
1836             if (str <= 3)
1837                 tim = rn1(6, 6);
1838             else if (str < 6)
1839                 tim = rn1(6, 4);
1840             else if (str < 9)
1841                 tim = rn1(4, 4);
1842             else if (str < 12)
1843                 tim = rn1(4, 2);
1844             else if (str < 15)
1845                 tim = rn1(2, 2);
1846             else if (str < 18)
1847                 tim = rnd(2);
1848             else if (str < 69)
1849                 tim = 1;
1850             else {
1851                 tim = 0;
1852                 if (webmsgok)
1853 /*JP
1854                     You("tear through %s web!", a_your[trap->madeby_u]);
1855 */
1856                     You("%s\82­\82à\82Ì\91\83\82ð\90Ø\82è\97ô\82¢\82½\81I", web_you[trap->madeby_u]);
1857                 deltrap(trap);
1858                 newsym(u.ux, u.uy); /* get rid of trap symbol */
1859             }
1860             set_utrap((unsigned) tim, TT_WEB);
1861         }
1862         break;
1863
1864     case STATUE_TRAP:
1865         (void) activate_statue_trap(trap, u.ux, u.uy, FALSE);
1866         break;
1867
1868     case MAGIC_TRAP: /* A magic trap. */
1869         seetrap(trap);
1870         if (!rn2(30)) {
1871             deltrap(trap);
1872             newsym(u.ux, u.uy); /* update position */
1873 /*JP
1874             You("are caught in a magical explosion!");
1875 */
1876             You("\96\82\96@\82Ì\94\9a\94­\82ð\97\81\82Ñ\82½\81I");
1877 /*JP
1878             losehp(rnd(10), "magical explosion", KILLED_BY_AN);
1879 */
1880             losehp(rnd(10), "\96\82\96@\82Ì\94\9a\94­\82ð\97\81\82Ñ\82Ä", KILLED_BY_AN);
1881 /*JP
1882             Your("body absorbs some of the magical energy!");
1883 */
1884             Your("\91Ì\82Í\96\82\96@\82Ì\83G\83l\83\8b\83M\81[\82ð\8f­\82µ\8bz\82¢\82Æ\82Á\82½\81I");
1885             u.uen = (u.uenmax += 2);
1886             break;
1887         } else {
1888             domagictrap();
1889         }
1890         (void) steedintrap(trap, (struct obj *) 0);
1891         break;
1892
1893     case ANTI_MAGIC:
1894         seetrap(trap);
1895         /* hero without magic resistance loses spell energy,
1896            hero with magic resistance takes damage instead;
1897            possibly non-intuitive but useful for play balance */
1898         if (!Antimagic) {
1899             drain_en(rnd(u.ulevel) + 1);
1900         } else {
1901             int dmgval2 = rnd(4), hp = Upolyd ? u.mh : u.uhp;
1902
1903             /* Half_XXX_damage has opposite its usual effect (approx)
1904                but isn't cumulative if hero has more than one */
1905             if (Half_physical_damage || Half_spell_damage)
1906                 dmgval2 += rnd(4);
1907             /* give Magicbane wielder dose of own medicine */
1908             if (uwep && uwep->oartifact == ART_MAGICBANE)
1909                 dmgval2 += rnd(4);
1910             /* having an artifact--other than own quest one--which
1911                confers magic resistance simply by being carried
1912                also increases the effect */
1913             for (otmp = invent; otmp; otmp = otmp->nobj)
1914                 if (otmp->oartifact && !is_quest_artifact(otmp)
1915                     && defends_when_carried(AD_MAGM, otmp))
1916                     break;
1917             if (otmp)
1918                 dmgval2 += rnd(4);
1919             if (Passes_walls)
1920                 dmgval2 = (dmgval2 + 3) / 4;
1921
1922 #if 0 /*JP:T*/
1923             You_feel((dmgval2 >= hp) ? "unbearably torpid!"
1924                                      : (dmgval2 >= hp / 4) ? "very lethargic."
1925                                                            : "sluggish.");
1926 #else
1927             You_feel((dmgval2 >= hp) ? "\91Ï\82¦\82ç\82ê\82È\82¢\82Ù\82Ç\96³\8bC\97Í\82É\82È\82Á\82½\81I"
1928                                      : (dmgval2 >= hp / 4) ? "\82Æ\82Ä\82à\8bC\82¾\82é\82­\82È\82Á\82½\81D"
1929                                                            : "\82à\82Ì\82®\82³\82È\8bC\95ª\82É\82È\82Á\82½\81D");
1930 #endif
1931             /* opposite of magical explosion */
1932 /*JP
1933             losehp(dmgval2, "anti-magic implosion", KILLED_BY_AN);
1934 */
1935             losehp(dmgval2, "\94½\96\82\96@\82Ì\93à\95\94\94j\97ô\82Å", KILLED_BY_AN);
1936         }
1937         break;
1938
1939     case POLY_TRAP: {
1940         char verbbuf[BUFSZ];
1941
1942         seetrap(trap);
1943         if (viasitting)
1944 #if 0 /*JP*/
1945             Strcpy(verbbuf, "trigger"); /* follows "You sit down." */
1946 #else
1947             Strcpy(verbbuf, "\82ð\88ø\82«\8bN\82±\82µ\82½"); /* follows "You sit down." */
1948 #endif
1949         else if (u.usteed)
1950 #if 0 /*JP*/
1951             Sprintf(verbbuf, "lead %s onto",
1952                     x_monnam(u.usteed, steed_article, (char *) 0,
1953                              SUPPRESS_SADDLE, FALSE));
1954 #else
1955             Sprintf(verbbuf, "\82É%s\82Æ\82Æ\82à\82É\94ò\82Ñ\8d\9e\82ñ\82¾",
1956                     x_monnam(u.usteed, steed_article, (char *) 0,
1957                              SUPPRESS_SADDLE, FALSE));
1958 #endif
1959         else
1960 #if 0 /*JP*/
1961             Sprintf(verbbuf, "%s onto",
1962                     Levitation ? (const char *) "float"
1963                                : locomotion(youmonst.data, "step"));
1964 #else
1965             Sprintf(verbbuf,"\82É%s",
1966                     jpast(Levitation ? (const char *)"\95\82\82«\82È\82ª\82ç\94ò\82Ñ\82±\82Þ"
1967                           : locomotion(youmonst.data, "\93¥\82Ý\8d\9e\82Þ")));
1968 #endif
1969 /*JP
1970         You("%s a polymorph trap!", verbbuf);
1971 */
1972         You("\95Ï\89»\82Ìã©%s\81I", verbbuf);
1973         if (Antimagic || Unchanging) {
1974             shieldeff(u.ux, u.uy);
1975 /*JP
1976             You_feel("momentarily different.");
1977 */
1978             You("\88ê\8fu\88á\82Á\82½\8a´\82\82ª\82µ\82½\81D");
1979             /* Trap did nothing; don't remove it --KAA */
1980         } else {
1981             (void) steedintrap(trap, (struct obj *) 0);
1982             deltrap(trap);      /* delete trap before polymorph */
1983             newsym(u.ux, u.uy); /* get rid of trap symbol */
1984 /*JP
1985             You_feel("a change coming over you.");
1986 */
1987             You("\95Ï\89»\82ª\96K\82ê\82½\82æ\82¤\82È\8bC\82ª\82µ\82½\81D");
1988             polyself(0);
1989         }
1990         break;
1991     }
1992     case LANDMINE: {
1993         unsigned steed_mid = 0;
1994         struct obj *saddle = 0;
1995
1996         if ((Levitation || Flying) && !forcetrap) {
1997             if (!already_seen && rn2(3))
1998                 break;
1999             feeltrap(trap);
2000 #if 0 /*JP*/
2001             pline("%s %s in a pile of soil below you.",
2002                   already_seen ? "There is" : "You discover",
2003                   trap->madeby_u ? "the trigger of your mine" : "a trigger");
2004 #else
2005             if(already_seen)
2006                 pline("\82±\82±\82É\82Í%s\92n\97\8b\82Ì\8bN\94\9a\83X\83C\83b\83`\82ª\82 \82é\81D",
2007                       set_you[trap->madeby_u]);
2008             else
2009                 You("\91«\89º\82Ì\93y\82Ì\8eR\82É%s\92n\97\8b\82Ì\8bN\94\9a\83X\83C\83b\83`\82ð\82Ý\82Â\82¯\82½\81D",
2010                     set_you[trap->madeby_u]);
2011 #endif
2012             if (already_seen && rn2(3))
2013                 break;
2014 #if 0 /*JP:T*/
2015             pline("KAABLAMM!!!  %s %s%s off!",
2016                   forcebungle ? "Your inept attempt sets"
2017                               : "The air currents set",
2018                   already_seen ? a_your[trap->madeby_u] : "",
2019                   already_seen ? " land mine" : "it");
2020 #else
2021             pline("\82¿\82ã\82Ç\81[\82ñ\81I\81I%s%s%s\8bN\94\9a\83X\83C\83b\83`\82ª\94­\93®\82µ\82½\81I",
2022                   forcebungle ? "\95s\8aí\97p\82È\82¹\82¢\82Å"
2023                               : "\8bó\8bC\82Ì\97¬\82ê\82Å",
2024                   already_seen ? set_you[trap->madeby_u] : "",
2025                   already_seen ? "\92n\97\8b\82Ì" : "");
2026 #endif
2027         } else {
2028             /* prevent landmine from killing steed, throwing you to
2029              * the ground, and you being affected again by the same
2030              * mine because it hasn't been deleted yet
2031              */
2032             static boolean recursive_mine = FALSE;
2033
2034             if (recursive_mine)
2035                 break;
2036             feeltrap(trap);
2037 #if 0 /*JP:T*/
2038             pline("KAABLAMM!!!  You triggered %s land mine!",
2039                   a_your[trap->madeby_u]);
2040 #else
2041             pline("\82¿\82ã\82Ç\81[\82ñ\81I\81I%s\92n\97\8b\82Ì\8bN\94\9a\83X\83C\83b\83`\82ð\93¥\82ñ\82¾\81I",
2042                   set_you[trap->madeby_u]);
2043 #endif
2044             if (u.usteed)
2045                 steed_mid = u.usteed->m_id;
2046             recursive_mine = TRUE;
2047             (void) steedintrap(trap, (struct obj *) 0);
2048             recursive_mine = FALSE;
2049             saddle = sobj_at(SADDLE, u.ux, u.uy);
2050             set_wounded_legs(LEFT_SIDE, rn1(35, 41));
2051             set_wounded_legs(RIGHT_SIDE, rn1(35, 41));
2052             exercise(A_DEX, FALSE);
2053         }
2054         blow_up_landmine(trap);
2055         if (steed_mid && saddle && !u.usteed)
2056             (void) keep_saddle_with_steedcorpse(steed_mid, fobj, saddle);
2057         newsym(u.ux, u.uy); /* update trap symbol */
2058 /*JP
2059         losehp(Maybe_Half_Phys(rnd(16)), "land mine", KILLED_BY_AN);
2060 */
2061         losehp(Maybe_Half_Phys(rnd(16)), "\92n\97\8b\82ð\93¥\82ñ\82Å", KILLED_BY_AN);
2062         /* fall recursively into the pit... */
2063         if ((trap = t_at(u.ux, u.uy)) != 0)
2064             dotrap(trap, RECURSIVETRAP);
2065         fill_pit(u.ux, u.uy);
2066         break;
2067     }
2068
2069     case ROLLING_BOULDER_TRAP: {
2070         int style = ROLL | (trap->tseen ? LAUNCH_KNOWN : 0);
2071
2072         feeltrap(trap);
2073 /*JP
2074         pline("Click!  You trigger a rolling boulder trap!");
2075 */
2076         pline("\83J\83`\83b\81I\82 \82È\82½\82Í\8b\90\8aâ\82Ìã©\82Ì\83X\83C\83b\83`\82ð\93¥\82ñ\82¾\81I");
2077         if (!launch_obj(BOULDER, trap->launch.x, trap->launch.y,
2078                         trap->launch2.x, trap->launch2.y, style)) {
2079             deltrap(trap);
2080             newsym(u.ux, u.uy); /* get rid of trap symbol */
2081 /*JP
2082             pline("Fortunately for you, no boulder was released.");
2083 */
2084             pline("\89^\82Ì\82æ\82¢\82±\82Æ\82É\8aâ\82Í\93]\82ª\82Á\82Ä\82±\82È\82©\82Á\82½\81D");
2085         }
2086         break;
2087     }
2088
2089     case MAGIC_PORTAL:
2090         feeltrap(trap);
2091         domagicportal(trap);
2092         break;
2093
2094     case VIBRATING_SQUARE:
2095         feeltrap(trap);
2096         /* messages handled elsewhere; the trap symbol is merely to mark the
2097          * square for future reference */
2098         break;
2099
2100     default:
2101         feeltrap(trap);
2102         impossible("You hit a trap of type %u", trap->ttyp);
2103     }
2104 }
2105
2106 STATIC_OVL char *
2107 trapnote(trap, noprefix)
2108 struct trap *trap;
2109 boolean noprefix;
2110 {
2111     static char tnbuf[12];
2112     const char *tn,
2113 #if 0 /*JP:T*/
2114         *tnnames[12] = { "C note",  "D flat", "D note",  "E flat",
2115                          "E note",  "F note", "F sharp", "G note",
2116                          "G sharp", "A note", "B flat",  "B note" };
2117 #else
2118         *tnnames[12] = { "\83h",  "\83\8c\81ó", "\83\8c",  "\83~\81ó",
2119                          "\83~",  "\83t\83@", "\83t\83@\81ò", "\83\",
2120                          "\83\\81ò", "\83\89", "\83V\81ó",  "\83V" };
2121 #endif
2122
2123     tnbuf[0] = '\0';
2124     tn = tnnames[trap->tnote];
2125 #if 0 /*JP*/
2126     if (!noprefix)
2127         Sprintf(tnbuf, "%s ",
2128                 (*tn == 'A' || *tn == 'E' || *tn == 'F') ? "an" : "a");
2129     Sprintf(eos(tnbuf), "%s", tn);
2130 #else
2131     Sprintf(tnbuf, "%s\82Ì\89¹", tn);
2132 #endif
2133     return tnbuf;
2134 }
2135
2136 STATIC_OVL int
2137 steedintrap(trap, otmp)
2138 struct trap *trap;
2139 struct obj *otmp;
2140 {
2141     struct monst *steed = u.usteed;
2142     int tt;
2143     boolean trapkilled, steedhit;
2144
2145     if (!steed || !trap)
2146         return 0;
2147     tt = trap->ttyp;
2148     steed->mx = u.ux;
2149     steed->my = u.uy;
2150     trapkilled = steedhit = FALSE;
2151
2152     switch (tt) {
2153     case ARROW_TRAP:
2154         if (!otmp) {
2155             impossible("steed hit by non-existent arrow?");
2156             return 0;
2157         }
2158         trapkilled = thitm(8, steed, otmp, 0, FALSE);
2159         steedhit = TRUE;
2160         break;
2161     case DART_TRAP:
2162         if (!otmp) {
2163             impossible("steed hit by non-existent dart?");
2164             return 0;
2165         }
2166         trapkilled = thitm(7, steed, otmp, 0, FALSE);
2167         steedhit = TRUE;
2168         break;
2169     case SLP_GAS_TRAP:
2170         if (!resists_sleep(steed) && !breathless(steed->data)
2171             && !steed->msleeping && steed->mcanmove) {
2172             if (sleep_monst(steed, rnd(25), -1))
2173                 /* no in_sight check here; you can feel it even if blind */
2174 /*JP
2175                 pline("%s suddenly falls asleep!", Monnam(steed));
2176 */
2177                 pline("%s\82Í\82Æ\82Â\82º\82ñ\96°\82Á\82Ä\82µ\82Ü\82Á\82½\81I", Monnam(steed));
2178         }
2179         steedhit = TRUE;
2180         break;
2181     case LANDMINE:
2182         trapkilled = thitm(0, steed, (struct obj *) 0, rnd(16), FALSE);
2183         steedhit = TRUE;
2184         break;
2185     case PIT:
2186     case SPIKED_PIT:
2187         trapkilled = (DEADMONSTER(steed)
2188                       || thitm(0, steed, (struct obj *) 0,
2189                                rnd((tt == PIT) ? 6 : 10), FALSE));
2190         steedhit = TRUE;
2191         break;
2192     case POLY_TRAP:
2193         if (!resists_magm(steed) && !resist(steed, WAND_CLASS, 0, NOTELL)) {
2194             struct permonst *mdat = steed->data;
2195
2196             (void) newcham(steed, (struct permonst *) 0, FALSE, FALSE);
2197             if (!can_saddle(steed) || !can_ride(steed)) {
2198                 dismount_steed(DISMOUNT_POLY);
2199             } else {
2200                 char buf[BUFSZ];
2201
2202                 Strcpy(buf, x_monnam(steed, ARTICLE_YOUR, (char *) 0,
2203                                             SUPPRESS_SADDLE, FALSE));
2204                 if (mdat != steed->data)
2205                     (void) strsubst(buf, "your ", "your new ");
2206 /*JP
2207                 You("adjust yourself in the saddle on %s.", buf);
2208 */
2209                 You("%s\82Ì\88Æ\82Ì\8fã\82Å\8dÀ\82è\82È\82¨\82µ\82½\81D", buf);
2210             }
2211         }
2212         steedhit = TRUE;
2213         break;
2214     default:
2215         break;
2216     }
2217
2218     if (trapkilled) {
2219         dismount_steed(DISMOUNT_POLY);
2220         return 2;
2221     }
2222     return steedhit ? 1 : 0;
2223 }
2224
2225 /* some actions common to both player and monsters for triggered landmine */
2226 void
2227 blow_up_landmine(trap)
2228 struct trap *trap;
2229 {
2230     int x = trap->tx, y = trap->ty, dbx, dby;
2231     struct rm *lev = &levl[x][y];
2232
2233     (void) scatter(x, y, 4,
2234                    MAY_DESTROY | MAY_HIT | MAY_FRACTURE | VIS_EFFECTS,
2235                    (struct obj *) 0);
2236     del_engr_at(x, y);
2237     wake_nearto(x, y, 400);
2238     if (IS_DOOR(lev->typ))
2239         lev->doormask = D_BROKEN;
2240     /* destroy drawbridge if present */
2241     if (lev->typ == DRAWBRIDGE_DOWN || is_drawbridge_wall(x, y) >= 0) {
2242         dbx = x, dby = y;
2243         /* if under the portcullis, the bridge is adjacent */
2244         if (find_drawbridge(&dbx, &dby))
2245             destroy_drawbridge(dbx, dby);
2246         trap = t_at(x, y); /* expected to be null after destruction */
2247     }
2248     /* convert landmine into pit */
2249     if (trap) {
2250         if (Is_waterlevel(&u.uz) || Is_airlevel(&u.uz)) {
2251             /* no pits here */
2252             deltrap(trap);
2253         } else {
2254             trap->ttyp = PIT;       /* explosion creates a pit */
2255             trap->madeby_u = FALSE; /* resulting pit isn't yours */
2256             seetrap(trap);          /* and it isn't concealed */
2257         }
2258     }
2259 }
2260
2261 /*
2262  * The following are used to track launched objects to
2263  * prevent them from vanishing if you are killed. They
2264  * will reappear at the launchplace in bones files.
2265  */
2266 static struct {
2267     struct obj *obj;
2268     xchar x, y;
2269 } launchplace;
2270
2271 STATIC_OVL void
2272 launch_drop_spot(obj, x, y)
2273 struct obj *obj;
2274 xchar x, y;
2275 {
2276     if (!obj) {
2277         launchplace.obj = (struct obj *) 0;
2278         launchplace.x = 0;
2279         launchplace.y = 0;
2280     } else {
2281         launchplace.obj = obj;
2282         launchplace.x = x;
2283         launchplace.y = y;
2284     }
2285 }
2286
2287 boolean
2288 launch_in_progress()
2289 {
2290     if (launchplace.obj)
2291         return TRUE;
2292     return FALSE;
2293 }
2294
2295 void
2296 force_launch_placement()
2297 {
2298     if (launchplace.obj) {
2299         launchplace.obj->otrapped = 0;
2300         place_object(launchplace.obj, launchplace.x, launchplace.y);
2301     }
2302 }
2303
2304 /*
2305  * Move obj from (x1,y1) to (x2,y2)
2306  *
2307  * Return 0 if no object was launched.
2308  *        1 if an object was launched and placed somewhere.
2309  *        2 if an object was launched, but used up.
2310  */
2311 int
2312 launch_obj(otyp, x1, y1, x2, y2, style)
2313 short otyp;
2314 register int x1, y1, x2, y2;
2315 int style;
2316 {
2317     register struct monst *mtmp;
2318     register struct obj *otmp, *otmp2;
2319     register int dx, dy;
2320     struct obj *singleobj;
2321     boolean used_up = FALSE;
2322     boolean otherside = FALSE;
2323     int dist;
2324     int tmp;
2325     int delaycnt = 0;
2326
2327     otmp = sobj_at(otyp, x1, y1);
2328     /* Try the other side too, for rolling boulder traps */
2329     if (!otmp && otyp == BOULDER) {
2330         otherside = TRUE;
2331         otmp = sobj_at(otyp, x2, y2);
2332     }
2333     if (!otmp)
2334         return 0;
2335     if (otherside) { /* swap 'em */
2336         int tx, ty;
2337
2338         tx = x1;
2339         ty = y1;
2340         x1 = x2;
2341         y1 = y2;
2342         x2 = tx;
2343         y2 = ty;
2344     }
2345
2346     if (otmp->quan == 1L) {
2347         obj_extract_self(otmp);
2348         singleobj = otmp;
2349         otmp = (struct obj *) 0;
2350     } else {
2351         singleobj = splitobj(otmp, 1L);
2352         obj_extract_self(singleobj);
2353     }
2354     newsym(x1, y1);
2355     /* in case you're using a pick-axe to chop the boulder that's being
2356        launched (perhaps a monster triggered it), destroy context so that
2357        next dig attempt never thinks you're resuming previous effort */
2358     if ((otyp == BOULDER || otyp == STATUE)
2359         && singleobj->ox == context.digging.pos.x
2360         && singleobj->oy == context.digging.pos.y)
2361         (void) memset((genericptr_t) &context.digging, 0,
2362                       sizeof(struct dig_info));
2363
2364     dist = distmin(x1, y1, x2, y2);
2365     bhitpos.x = x1;
2366     bhitpos.y = y1;
2367     dx = sgn(x2 - x1);
2368     dy = sgn(y2 - y1);
2369     switch (style) {
2370     case ROLL | LAUNCH_UNSEEN:
2371         if (otyp == BOULDER) {
2372 #if 0 /*JP:T*/
2373             You_hear(Hallucination ? "someone bowling."
2374                                    : "rumbling in the distance.");
2375 #else
2376             You_hear(Hallucination ? "\92N\82©\82ª\83{\81[\83\8a\83\93\83O\82ð\82µ\82Ä\82¢\82é\89¹\82ð\95·\82¢\82½\81D"
2377                                    : "\89\93\82­\82Ì\83S\83\8d\83S\83\8d\82Æ\82¢\82¤\89¹\82ð\95·\82¢\82½\81D");
2378 #endif
2379         }
2380         style &= ~LAUNCH_UNSEEN;
2381         goto roll;
2382     case ROLL | LAUNCH_KNOWN:
2383         /* use otrapped as a flag to ohitmon */
2384         singleobj->otrapped = 1;
2385         style &= ~LAUNCH_KNOWN;
2386     /* fall through */
2387     roll:
2388     case ROLL:
2389         delaycnt = 2;
2390     /* fall through */
2391     default:
2392         if (!delaycnt)
2393             delaycnt = 1;
2394         if (!cansee(bhitpos.x, bhitpos.y))
2395             curs_on_u();
2396         tmp_at(DISP_FLASH, obj_to_glyph(singleobj, rn2_on_display_rng));
2397         tmp_at(bhitpos.x, bhitpos.y);
2398     }
2399     /* Mark a spot to place object in bones files to prevent
2400      * loss of object. Use the starting spot to ensure that
2401      * a rolling boulder will still launch, which it wouldn't
2402      * do if left midstream. Unfortunately we can't use the
2403      * target resting spot, because there are some things/situations
2404      * that would prevent it from ever getting there (bars), and we
2405      * can't tell that yet.
2406      */
2407     launch_drop_spot(singleobj, bhitpos.x, bhitpos.y);
2408
2409     /* Set the object in motion */
2410     while (dist-- > 0 && !used_up) {
2411         struct trap *t;
2412         tmp_at(bhitpos.x, bhitpos.y);
2413         tmp = delaycnt;
2414
2415         /* dstage@u.washington.edu -- Delay only if hero sees it */
2416         if (cansee(bhitpos.x, bhitpos.y))
2417             while (tmp-- > 0)
2418                 delay_output();
2419
2420         bhitpos.x += dx;
2421         bhitpos.y += dy;
2422
2423         if ((mtmp = m_at(bhitpos.x, bhitpos.y)) != 0) {
2424             if (otyp == BOULDER && throws_rocks(mtmp->data)) {
2425                 if (rn2(3)) {
2426                     if (cansee(bhitpos.x, bhitpos.y))
2427 /*JP
2428                         pline("%s snatches the boulder.", Monnam(mtmp));
2429 */
2430                         pline("%s\82Í\8aâ\82ð\82Â\82©\82Ý\8eæ\82Á\82½\81D", Monnam(mtmp));
2431                     singleobj->otrapped = 0;
2432                     (void) mpickobj(mtmp, singleobj);
2433                     used_up = TRUE;
2434                     launch_drop_spot((struct obj *) 0, 0, 0);
2435                     break;
2436                 }
2437             }
2438             if (ohitmon(mtmp, singleobj, (style == ROLL) ? -1 : dist,
2439                         FALSE)) {
2440                 used_up = TRUE;
2441                 launch_drop_spot((struct obj *) 0, 0, 0);
2442                 break;
2443             }
2444         } else if (bhitpos.x == u.ux && bhitpos.y == u.uy) {
2445             if (multi)
2446                 nomul(0);
2447             if (thitu(9 + singleobj->spe, dmgval(singleobj, &youmonst),
2448                       &singleobj, (char *) 0))
2449                 stop_occupation();
2450         }
2451         if (style == ROLL) {
2452             if (down_gate(bhitpos.x, bhitpos.y) != -1) {
2453                 if (ship_object(singleobj, bhitpos.x, bhitpos.y, FALSE)) {
2454                     used_up = TRUE;
2455                     launch_drop_spot((struct obj *) 0, 0, 0);
2456                     break;
2457                 }
2458             }
2459             if ((t = t_at(bhitpos.x, bhitpos.y)) != 0 && otyp == BOULDER) {
2460                 switch (t->ttyp) {
2461                 case LANDMINE:
2462                     if (rn2(10) > 2) {
2463 #if 0 /*JP:T*/
2464                         pline(
2465                             "KAABLAMM!!!%s",
2466                             cansee(bhitpos.x, bhitpos.y)
2467                                 ? " The rolling boulder triggers a land mine."
2468                                 : "");
2469 #else
2470                         pline(
2471                             "\82¿\82ã\82Ç\81[\82ñ\81I\81I%s",
2472                             cansee(bhitpos.x, bhitpos.y)
2473                                 ? "\93]\82ª\82Á\82Ä\82«\82½\8aâ\82ª\92n\97\8b\82Ì\8bN\94\9a\83X\83C\83b\83`\82ð\93¥\82ñ\82¾\81D"
2474                                 : "");
2475 #endif
2476                         deltrap(t);
2477                         del_engr_at(bhitpos.x, bhitpos.y);
2478                         place_object(singleobj, bhitpos.x, bhitpos.y);
2479                         singleobj->otrapped = 0;
2480                         fracture_rock(singleobj);
2481                         (void) scatter(bhitpos.x, bhitpos.y, 4,
2482                                        MAY_DESTROY | MAY_HIT | MAY_FRACTURE
2483                                            | VIS_EFFECTS,
2484                                        (struct obj *) 0);
2485                         if (cansee(bhitpos.x, bhitpos.y))
2486                             newsym(bhitpos.x, bhitpos.y);
2487                         used_up = TRUE;
2488                         launch_drop_spot((struct obj *) 0, 0, 0);
2489                     }
2490                     break;
2491                 case LEVEL_TELEP:
2492                 case TELEP_TRAP:
2493                     if (cansee(bhitpos.x, bhitpos.y))
2494 /*JP
2495                         pline("Suddenly the rolling boulder disappears!");
2496 */
2497                         pline("\93]\82ª\82Á\82Ä\82«\82½\8aâ\82ª\82Æ\82Â\82º\82ñ\8fÁ\82¦\82½\81I");
2498                     else
2499 /*JP
2500                         You_hear("a rumbling stop abruptly.");
2501 */
2502                         pline("\83S\83\8d\83S\83\8d\82Æ\82¢\82¤\89¹\82ª\93Ë\91R\8e~\82Ü\82Á\82½\81D");
2503                     singleobj->otrapped = 0;
2504                     if (t->ttyp == TELEP_TRAP)
2505                         (void) rloco(singleobj);
2506                     else {
2507                         int newlev = random_teleport_level();
2508                         d_level dest;
2509
2510                         if (newlev == depth(&u.uz) || In_endgame(&u.uz))
2511                             continue;
2512                         add_to_migration(singleobj);
2513                         get_level(&dest, newlev);
2514                         singleobj->ox = dest.dnum;
2515                         singleobj->oy = dest.dlevel;
2516                         singleobj->owornmask = (long) MIGR_RANDOM;
2517                     }
2518                     seetrap(t);
2519                     used_up = TRUE;
2520                     launch_drop_spot((struct obj *) 0, 0, 0);
2521                     break;
2522                 case PIT:
2523                 case SPIKED_PIT:
2524                 case HOLE:
2525                 case TRAPDOOR:
2526                     /* the boulder won't be used up if there is a
2527                        monster in the trap; stop rolling anyway */
2528                     x2 = bhitpos.x, y2 = bhitpos.y; /* stops here */
2529 /*JP
2530                     if (flooreffects(singleobj, x2, y2, "fall")) {
2531 */
2532                     if (flooreffects(singleobj, x2, y2, "\97\8e\82¿\82é")) {
2533                         used_up = TRUE;
2534                         launch_drop_spot((struct obj *) 0, 0, 0);
2535                     }
2536                     dist = -1; /* stop rolling immediately */
2537                     break;
2538                 }
2539                 if (used_up || dist == -1)
2540                     break;
2541             }
2542 /*JP
2543             if (flooreffects(singleobj, bhitpos.x, bhitpos.y, "fall")) {
2544 */
2545             if (flooreffects(singleobj, bhitpos.x, bhitpos.y, "\97\8e\82¿\82é")) {
2546                 used_up = TRUE;
2547                 launch_drop_spot((struct obj *) 0, 0, 0);
2548                 break;
2549             }
2550             if (otyp == BOULDER
2551                 && (otmp2 = sobj_at(BOULDER, bhitpos.x, bhitpos.y)) != 0) {
2552 /*JP
2553                 const char *bmsg = " as one boulder sets another in motion";
2554 */
2555                 const char *bmsg = "\82Ð\82Æ\82Â\82Ì\8aâ\82ª\91¼\82Ì\8aâ\82ð\93®\82©\82µ\82½\82©\82Ì\82æ\82¤\82È\81C";
2556
2557                 if (!isok(bhitpos.x + dx, bhitpos.y + dy) || !dist
2558                     || IS_ROCK(levl[bhitpos.x + dx][bhitpos.y + dy].typ))
2559 /*JP
2560                     bmsg = " as one boulder hits another";
2561 */
2562                     bmsg = "\82Ð\82Æ\82Â\82Ì\8aâ\82ª\91¼\82Ì\8aâ\82É\93\96\82½\82Á\82½\82æ\82¤\82È";
2563
2564 /*JP
2565                 You_hear("a loud crash%s!",
2566 */
2567                 You_hear("%s\91å\82«\82È\83S\83\93\82Æ\82¢\82¤\89¹\82ð\95·\82¢\82½\81I",
2568                          cansee(bhitpos.x, bhitpos.y) ? bmsg : "");
2569                 obj_extract_self(otmp2);
2570                 /* pass off the otrapped flag to the next boulder */
2571                 otmp2->otrapped = singleobj->otrapped;
2572                 singleobj->otrapped = 0;
2573                 place_object(singleobj, bhitpos.x, bhitpos.y);
2574                 singleobj = otmp2;
2575                 otmp2 = (struct obj *) 0;
2576                 wake_nearto(bhitpos.x, bhitpos.y, 10 * 10);
2577             }
2578         }
2579         if (otyp == BOULDER && closed_door(bhitpos.x, bhitpos.y)) {
2580             if (cansee(bhitpos.x, bhitpos.y))
2581 /*JP
2582                 pline_The("boulder crashes through a door.");
2583 */
2584                 pline("\8aâ\82Í\94à\82ð\94j\89ó\82µ\82½\81D");
2585             levl[bhitpos.x][bhitpos.y].doormask = D_BROKEN;
2586             if (dist)
2587                 unblock_point(bhitpos.x, bhitpos.y);
2588         }
2589
2590         /* if about to hit iron bars, do so now */
2591         if (dist > 0 && isok(bhitpos.x + dx, bhitpos.y + dy)
2592             && levl[bhitpos.x + dx][bhitpos.y + dy].typ == IRONBARS) {
2593             x2 = bhitpos.x, y2 = bhitpos.y; /* object stops here */
2594             if (hits_bars(&singleobj,
2595                           x2, y2, x2+dx, y2+dy,
2596                           !rn2(20), 0)) {
2597                 if (!singleobj) {
2598                     used_up = TRUE;
2599                     launch_drop_spot((struct obj *) 0, 0, 0);
2600                 }
2601                 break;
2602             }
2603         }
2604     }
2605     tmp_at(DISP_END, 0);
2606     launch_drop_spot((struct obj *) 0, 0, 0);
2607     if (!used_up) {
2608         singleobj->otrapped = 0;
2609         place_object(singleobj, x2, y2);
2610         newsym(x2, y2);
2611         return 1;
2612     } else
2613         return 2;
2614 }
2615
2616 void
2617 seetrap(trap)
2618 struct trap *trap;
2619 {
2620     if (!trap->tseen) {
2621         trap->tseen = 1;
2622         newsym(trap->tx, trap->ty);
2623     }
2624 }
2625
2626 /* like seetrap() but overrides vision */
2627 void
2628 feeltrap(trap)
2629 struct trap *trap;
2630 {
2631     trap->tseen = 1;
2632     map_trap(trap, 1);
2633     /* in case it's beneath something, redisplay the something */
2634     newsym(trap->tx, trap->ty);
2635 }
2636
2637 STATIC_OVL int
2638 mkroll_launch(ttmp, x, y, otyp, ocount)
2639 struct trap *ttmp;
2640 xchar x, y;
2641 short otyp;
2642 long ocount;
2643 {
2644     struct obj *otmp;
2645     register int tmp;
2646     schar dx, dy;
2647     int distance;
2648     coord cc;
2649     coord bcc;
2650     int trycount = 0;
2651     boolean success = FALSE;
2652     int mindist = 4;
2653
2654     if (ttmp->ttyp == ROLLING_BOULDER_TRAP)
2655         mindist = 2;
2656     distance = rn1(5, 4); /* 4..8 away */
2657     tmp = rn2(8);         /* randomly pick a direction to try first */
2658     while (distance >= mindist) {
2659         dx = xdir[tmp];
2660         dy = ydir[tmp];
2661         cc.x = x;
2662         cc.y = y;
2663         /* Prevent boulder from being placed on water */
2664         if (ttmp->ttyp == ROLLING_BOULDER_TRAP
2665             && is_pool_or_lava(x + distance * dx, y + distance * dy))
2666             success = FALSE;
2667         else
2668             success = isclearpath(&cc, distance, dx, dy);
2669         if (ttmp->ttyp == ROLLING_BOULDER_TRAP) {
2670             boolean success_otherway;
2671
2672             bcc.x = x;
2673             bcc.y = y;
2674             success_otherway = isclearpath(&bcc, distance, -(dx), -(dy));
2675             if (!success_otherway)
2676                 success = FALSE;
2677         }
2678         if (success)
2679             break;
2680         if (++tmp > 7)
2681             tmp = 0;
2682         if ((++trycount % 8) == 0)
2683             --distance;
2684     }
2685     if (!success) {
2686         /* create the trap without any ammo, launch pt at trap location */
2687         cc.x = bcc.x = x;
2688         cc.y = bcc.y = y;
2689     } else {
2690         otmp = mksobj(otyp, TRUE, FALSE);
2691         otmp->quan = ocount;
2692         otmp->owt = weight(otmp);
2693         place_object(otmp, cc.x, cc.y);
2694         stackobj(otmp);
2695     }
2696     ttmp->launch.x = cc.x;
2697     ttmp->launch.y = cc.y;
2698     if (ttmp->ttyp == ROLLING_BOULDER_TRAP) {
2699         ttmp->launch2.x = bcc.x;
2700         ttmp->launch2.y = bcc.y;
2701     } else
2702         ttmp->launch_otyp = otyp;
2703     newsym(ttmp->launch.x, ttmp->launch.y);
2704     return 1;
2705 }
2706
2707 STATIC_OVL boolean
2708 isclearpath(cc, distance, dx, dy)
2709 coord *cc;
2710 int distance;
2711 schar dx, dy;
2712 {
2713     uchar typ;
2714     xchar x, y;
2715
2716     x = cc->x;
2717     y = cc->y;
2718     while (distance-- > 0) {
2719         x += dx;
2720         y += dy;
2721         typ = levl[x][y].typ;
2722         if (!isok(x, y) || !ZAP_POS(typ) || closed_door(x, y))
2723             return FALSE;
2724     }
2725     cc->x = x;
2726     cc->y = y;
2727     return TRUE;
2728 }
2729
2730 int
2731 mintrap(mtmp)
2732 register struct monst *mtmp;
2733 {
2734     register struct trap *trap = t_at(mtmp->mx, mtmp->my);
2735     boolean trapkilled = FALSE;
2736     struct permonst *mptr = mtmp->data;
2737     struct obj *otmp;
2738
2739     if (!trap) {
2740         mtmp->mtrapped = 0;      /* perhaps teleported? */
2741     } else if (mtmp->mtrapped) { /* is currently in the trap */
2742         if (!trap->tseen && cansee(mtmp->mx, mtmp->my) && canseemon(mtmp)
2743             && (is_pit(trap->ttyp) || trap->ttyp == BEAR_TRAP
2744                 || trap->ttyp == HOLE
2745                 || trap->ttyp == WEB)) {
2746             /* If you come upon an obviously trapped monster, then
2747              * you must be able to see the trap it's in too.
2748              */
2749             seetrap(trap);
2750         }
2751
2752         if (!rn2(40)) {
2753             if (sobj_at(BOULDER, mtmp->mx, mtmp->my)
2754                 && is_pit(trap->ttyp)) {
2755                 if (!rn2(2)) {
2756                     mtmp->mtrapped = 0;
2757                     if (canseemon(mtmp))
2758 /*JP
2759                         pline("%s pulls free...", Monnam(mtmp));
2760 */
2761                         pline("%s\82Í\8f\95\82¯\8fã\82°\82ç\82ê\82½\81D", Monnam(mtmp));
2762                     fill_pit(mtmp->mx, mtmp->my);
2763                 }
2764             } else {
2765                 mtmp->mtrapped = 0;
2766             }
2767         } else if (metallivorous(mptr)) {
2768             if (trap->ttyp == BEAR_TRAP) {
2769                 if (canseemon(mtmp))
2770 /*JP
2771                     pline("%s eats a bear trap!", Monnam(mtmp));
2772 */
2773                     pline("%s\82Í\8cF\82Ìã©\82ð\90H\82×\82½\81I", Monnam(mtmp));
2774                 deltrap(trap);
2775                 mtmp->meating = 5;
2776                 mtmp->mtrapped = 0;
2777             } else if (trap->ttyp == SPIKED_PIT) {
2778                 if (canseemon(mtmp))
2779 /*JP
2780                     pline("%s munches on some spikes!", Monnam(mtmp));
2781 */
2782                     pline("%s\82Í\83g\83Q\83g\83Q\82ð\90H\82×\82½\81I", Monnam(mtmp));
2783                 trap->ttyp = PIT;
2784                 mtmp->meating = 5;
2785             }
2786         }
2787     } else {
2788         register int tt = trap->ttyp;
2789         boolean in_sight, tear_web, see_it,
2790             inescapable = force_mintrap || ((tt == HOLE || tt == PIT)
2791                                             && Sokoban && !trap->madeby_u);
2792         const char *fallverb;
2793         xchar tx = trap->tx, ty = trap->ty;
2794
2795         /* true when called from dotrap, inescapable is not an option */
2796         if (mtmp == u.usteed)
2797             inescapable = TRUE;
2798         if (!inescapable && ((mtmp->mtrapseen & (1 << (tt - 1))) != 0
2799                              || (tt == HOLE && !mindless(mptr)))) {
2800             /* it has been in such a trap - perhaps it escapes */
2801             if (rn2(4))
2802                 return 0;
2803         } else {
2804             mtmp->mtrapseen |= (1 << (tt - 1));
2805         }
2806         /* Monster is aggravated by being trapped by you.
2807            Recognizing who made the trap isn't completely
2808            unreasonable; everybody has their own style. */
2809         if (trap->madeby_u && rnl(5))
2810             setmangry(mtmp, TRUE);
2811
2812         in_sight = canseemon(mtmp);
2813         see_it = cansee(mtmp->mx, mtmp->my);
2814         /* assume hero can tell what's going on for the steed */
2815         if (mtmp == u.usteed)
2816             in_sight = TRUE;
2817         switch (tt) {
2818         case ARROW_TRAP:
2819             if (trap->once && trap->tseen && !rn2(15)) {
2820                 if (in_sight && see_it)
2821 #if 0 /*JP:T*/
2822                     pline("%s triggers a trap but nothing happens.",
2823                           Monnam(mtmp));
2824 #else
2825                     pline("%s\82ª\82í\82È\82ð\8bN\93®\82³\82¹\82½\82ª\89½\82à\8bN\82±\82ç\82È\82©\82Á\82½\81D",
2826                           Monnam(mtmp));
2827 #endif
2828                 deltrap(trap);
2829                 newsym(mtmp->mx, mtmp->my);
2830                 break;
2831             }
2832             trap->once = 1;
2833             otmp = t_missile(ARROW, trap);
2834             if (in_sight)
2835                 seetrap(trap);
2836             if (thitm(8, mtmp, otmp, 0, FALSE))
2837                 trapkilled = TRUE;
2838             break;
2839         case DART_TRAP:
2840             if (trap->once && trap->tseen && !rn2(15)) {
2841                 if (in_sight && see_it)
2842 #if 0 /*JP:T*/
2843                     pline("%s triggers a trap but nothing happens.",
2844                           Monnam(mtmp));
2845 #else
2846                     pline("%s\82ª\82í\82È\82ð\8bN\93®\82³\82¹\82½\82ª\89½\82à\8bN\82±\82ç\82È\82©\82Á\82½\81D",
2847                           Monnam(mtmp));
2848 #endif
2849                 deltrap(trap);
2850                 newsym(mtmp->mx, mtmp->my);
2851                 break;
2852             }
2853             trap->once = 1;
2854             otmp = t_missile(DART, trap);
2855             if (!rn2(6))
2856                 otmp->opoisoned = 1;
2857             if (in_sight)
2858                 seetrap(trap);
2859             if (thitm(7, mtmp, otmp, 0, FALSE))
2860                 trapkilled = TRUE;
2861             break;
2862         case ROCKTRAP:
2863             if (trap->once && trap->tseen && !rn2(15)) {
2864                 if (in_sight && see_it)
2865                     pline(
2866 /*JP
2867                         "A trap door above %s opens, but nothing falls out!",
2868 */
2869                         "%s\82Ì\8fã\82Ì\94à\82ª\8aJ\82¢\82½\82ª\81C\89½\82à\97\8e\82¿\82Ä\82±\82È\82©\82Á\82½\81I",
2870                         mon_nam(mtmp));
2871                 deltrap(trap);
2872                 newsym(mtmp->mx, mtmp->my);
2873                 break;
2874             }
2875             trap->once = 1;
2876             otmp = t_missile(ROCK, trap);
2877             if (in_sight)
2878                 seetrap(trap);
2879             if (thitm(0, mtmp, otmp, d(2, 6), FALSE))
2880                 trapkilled = TRUE;
2881             break;
2882         case SQKY_BOARD:
2883             if (is_flyer(mptr))
2884                 break;
2885             /* stepped on a squeaky board */
2886             if (in_sight) {
2887                 if (!Deaf) {
2888 #if 0 /*JP:T*/
2889                     pline("A board beneath %s squeaks %s loudly.",
2890                           mon_nam(mtmp), trapnote(trap, 0));
2891 #else
2892                     pline("%s\82Ì\91«\8c³\82Ì\94Â\82ª\91å\82«\82­%s\82É\82«\82µ\82ñ\82¾\81D",
2893                           mon_nam(mtmp), trapnote(trap, 0));
2894 #endif
2895                     seetrap(trap);
2896                 } else {
2897 /*JP
2898                     pline("%s stops momentarily and appears to cringe.",
2899 */
2900                     pline("%s\82Í\88ê\8fu\8e~\82Ü\82Á\82Ä\90g\82ð\82·\82­\82ß\82½\82æ\82¤\82¾\81D",
2901                           Monnam(mtmp));
2902                 }
2903             } else {
2904                 /* same near/far threshold as mzapmsg() */
2905                 int range = couldsee(mtmp->mx, mtmp->my) /* 9 or 5 */
2906                                ? (BOLT_LIM + 1) : (BOLT_LIM - 3);
2907
2908 #if 0 /*JP:T*/
2909                 You_hear("a %s squeak %s.", trapnote(trap, 1),
2910                          (distu(mtmp->mx, mtmp->my) <= range * range)
2911                             ? "nearby" : "in the distance");
2912 #else
2913                 You_hear("%s\82­\82Å%s\82ª\82«\82µ\82Þ\89¹\82ð\95·\82¢\82½\81D",
2914                          (distu(mtmp->mx, mtmp->my) <= range * range)
2915                             ? "\8bß" : "\89\93",
2916                          trapnote(trap, 1));
2917 #endif
2918             }
2919             /* wake up nearby monsters */
2920             wake_nearto(mtmp->mx, mtmp->my, 40);
2921             break;
2922         case BEAR_TRAP:
2923             if (mptr->msize > MZ_SMALL && !amorphous(mptr) && !is_flyer(mptr)
2924                 && !is_whirly(mptr) && !unsolid(mptr)) {
2925                 mtmp->mtrapped = 1;
2926                 if (in_sight) {
2927 #if 0 /*JP:T*/
2928                     pline("%s is caught in %s bear trap!", Monnam(mtmp),
2929                           a_your[trap->madeby_u]);
2930 #else
2931                     pline("%s\82Í%s\8cF\82Ìã©\82É\82Â\82©\82Ü\82Á\82½\81I", Monnam(mtmp),
2932                           set_you[trap->madeby_u]);
2933 #endif
2934                     seetrap(trap);
2935                 } else {
2936                     if (mptr == &mons[PM_OWLBEAR]
2937                         || mptr == &mons[PM_BUGBEAR])
2938 /*JP
2939                         You_hear("the roaring of an angry bear!");
2940 */
2941                         You_hear("\93{\82è\82Ì\99ô\9aK\82ð\95·\82¢\82½\81I");
2942                 }
2943             } else if (force_mintrap) {
2944                 if (in_sight) {
2945 #if 0 /*JP:T*/
2946                     pline("%s evades %s bear trap!", Monnam(mtmp),
2947                           a_your[trap->madeby_u]);
2948 #else
2949                     pline("%s\82Í%s\8cF\82Ìã©\82ð\82½\82­\82Ý\82É\94ð\82¯\82½\81I", Monnam(mtmp),
2950                           set_you[trap->madeby_u]);
2951 #endif
2952                     seetrap(trap);
2953                 }
2954             }
2955             if (mtmp->mtrapped)
2956                 trapkilled = thitm(0, mtmp, (struct obj *) 0, d(2, 4), FALSE);
2957             break;
2958         case SLP_GAS_TRAP:
2959             if (!resists_sleep(mtmp) && !breathless(mptr) && !mtmp->msleeping
2960                 && mtmp->mcanmove) {
2961                 if (sleep_monst(mtmp, rnd(25), -1) && in_sight) {
2962 /*JP
2963                     pline("%s suddenly falls asleep!", Monnam(mtmp));
2964 */
2965                     pline("%s\82Í\93Ë\91R\96°\82è\82É\97\8e\82¿\82½\81I", Monnam(mtmp));
2966                     seetrap(trap);
2967                 }
2968             }
2969             break;
2970         case RUST_TRAP: {
2971             struct obj *target;
2972
2973             if (in_sight)
2974                 seetrap(trap);
2975             switch (rn2(5)) {
2976             case 0:
2977                 if (in_sight)
2978 #if 0 /*JP:T*/
2979                     pline("%s %s on the %s!", A_gush_of_water_hits,
2980                           mon_nam(mtmp), mbodypart(mtmp, HEAD));
2981 #else
2982                     pline("\90\85\82ª\95¬\8fo\82µ\82Ä\81C%s\82Ì%s\82É\96½\92\86\82µ\82½\81I", 
2983                           mon_nam(mtmp), mbodypart(mtmp, HEAD));
2984 #endif
2985                 target = which_armor(mtmp, W_ARMH);
2986                 (void) water_damage(target, helm_simple_name(target), TRUE);
2987                 break;
2988             case 1:
2989                 if (in_sight)
2990 #if 0 /*JP:T*/
2991                     pline("%s %s's left %s!", A_gush_of_water_hits,
2992                           mon_nam(mtmp), mbodypart(mtmp, ARM));
2993 #else
2994                     pline("\90\85\82ª\95¬\8fo\82µ\82Ä\81C%s\82Ì\8d¶%s\82É\96½\92\86\82µ\82½\81I",
2995                           mon_nam(mtmp), mbodypart(mtmp, ARM));
2996 #endif
2997                 target = which_armor(mtmp, W_ARMS);
2998 /*JP
2999                 if (water_damage(target, "shield", TRUE) != ER_NOTHING)
3000 */
3001                 if (water_damage(target, "\8f\82", TRUE) != ER_NOTHING)
3002                     break;
3003                 target = MON_WEP(mtmp);
3004                 if (target && bimanual(target))
3005                     (void) water_damage(target, 0, TRUE);
3006             glovecheck:
3007                 target = which_armor(mtmp, W_ARMG);
3008 /*JP
3009                 (void) water_damage(target, "gauntlets", TRUE);
3010 */
3011                 (void) water_damage(target, "\8f¬\8eè", TRUE);
3012                 break;
3013             case 2:
3014                 if (in_sight)
3015 #if 0 /*JP:T*/
3016                     pline("%s %s's right %s!", A_gush_of_water_hits,
3017                           mon_nam(mtmp), mbodypart(mtmp, ARM));
3018 #else
3019                     pline("\90\85\82ª\95¬\8fo\82µ\82Ä\81C%s\82Ì\89E%s\82É\96½\92\86\82µ\82½\81I",
3020                           mon_nam(mtmp), mbodypart(mtmp, ARM));
3021 #endif
3022                 (void) water_damage(MON_WEP(mtmp), 0, TRUE);
3023                 goto glovecheck;
3024             default:
3025                 if (in_sight)
3026 /*JP
3027                     pline("%s %s!", A_gush_of_water_hits, mon_nam(mtmp));
3028 */
3029                     pline("\90\85\82ª\95¬\8fo\82µ\82Ä\81C%s\82É\96½\92\86\82µ\82½\81I", mon_nam(mtmp));
3030                 for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj)
3031                     if (otmp->lamplit
3032                         && (otmp->owornmask & (W_WEP | W_SWAPWEP)) == 0)
3033                         (void) snuff_lit(otmp);
3034                 if ((target = which_armor(mtmp, W_ARMC)) != 0)
3035                     (void) water_damage(target, cloak_simple_name(target),
3036                                         TRUE);
3037                 else if ((target = which_armor(mtmp, W_ARM)) != 0)
3038                     (void) water_damage(target, suit_simple_name(target),
3039                                         TRUE);
3040                 else if ((target = which_armor(mtmp, W_ARMU)) != 0)
3041 /*JP
3042                     (void) water_damage(target, "shirt", TRUE);
3043 */
3044                     (void) water_damage(target, "\83V\83\83\83c", TRUE);
3045             }
3046
3047             if (mptr == &mons[PM_IRON_GOLEM]) {
3048                 if (in_sight)
3049 /*JP
3050                     pline("%s falls to pieces!", Monnam(mtmp));
3051 */
3052                     pline("%s\82Í\82­\82¾\82¯\82¿\82Á\82½\81I", Monnam(mtmp));
3053                 else if (mtmp->mtame)
3054 /*JP
3055                     pline("May %s rust in peace.", mon_nam(mtmp));
3056 */
3057                     pline("%s\82æ\81C\88À\82ç\82©\82É\8eK\82Ñ\82ñ\8e\96\82ð\81D", mon_nam(mtmp));
3058                 mondied(mtmp);
3059                 if (DEADMONSTER(mtmp))
3060                     trapkilled = TRUE;
3061             } else if (mptr == &mons[PM_GREMLIN] && rn2(3)) {
3062                 (void) split_mon(mtmp, (struct monst *) 0);
3063             }
3064             break;
3065         } /* RUST_TRAP */
3066         case FIRE_TRAP:
3067         mfiretrap:
3068             if (in_sight)
3069 #if 0 /*JP:T*/
3070                 pline("A %s erupts from the %s under %s!", tower_of_flame,
3071                       surface(mtmp->mx, mtmp->my), mon_nam(mtmp));
3072 #else
3073                 pline("\89Î\92\8c\82ª%s\82Ì\91«\8c³\82Ì%s\82©\82ç\97§\82¿\82Ì\82Ú\82Á\82½\81I",
3074                       mon_nam(mtmp), surface(mtmp->mx,mtmp->my));
3075 #endif
3076             else if (see_it) /* evidently `mtmp' is invisible */
3077 #if 0 /*JP:T*/
3078                 You_see("a %s erupt from the %s!", tower_of_flame,
3079                         surface(mtmp->mx, mtmp->my));
3080 #else
3081                 You("\89Î\92\8c\82ª%s\82©\82ç\90\82\82é\82Ì\82ð\8c©\82½\81I",
3082                     surface(mtmp->mx,mtmp->my));
3083 #endif
3084
3085             if (resists_fire(mtmp)) {
3086                 if (in_sight) {
3087                     shieldeff(mtmp->mx, mtmp->my);
3088 /*JP
3089                     pline("%s is uninjured.", Monnam(mtmp));
3090 */
3091                     pline("\82ª\81C%s\82Í\8f\9d\82Â\82©\82È\82¢\81D", Monnam(mtmp));
3092                 }
3093             } else {
3094                 int num = d(2, 4), alt;
3095                 boolean immolate = FALSE;
3096
3097                 /* paper burns very fast, assume straw is tightly
3098                  * packed and burns a bit slower */
3099                 switch (monsndx(mptr)) {
3100                 case PM_PAPER_GOLEM:
3101                     immolate = TRUE;
3102                     alt = mtmp->mhpmax;
3103                     break;
3104                 case PM_STRAW_GOLEM:
3105                     alt = mtmp->mhpmax / 2;
3106                     break;
3107                 case PM_WOOD_GOLEM:
3108                     alt = mtmp->mhpmax / 4;
3109                     break;
3110                 case PM_LEATHER_GOLEM:
3111                     alt = mtmp->mhpmax / 8;
3112                     break;
3113                 default:
3114                     alt = 0;
3115                     break;
3116                 }
3117                 if (alt > num)
3118                     num = alt;
3119
3120                 if (thitm(0, mtmp, (struct obj *) 0, num, immolate))
3121                     trapkilled = TRUE;
3122                 else
3123                     /* we know mhp is at least `num' below mhpmax,
3124                        so no (mhp > mhpmax) check is needed here */
3125                     mtmp->mhpmax -= rn2(num + 1);
3126             }
3127             if (burnarmor(mtmp) || rn2(3)) {
3128                 (void) destroy_mitem(mtmp, SCROLL_CLASS, AD_FIRE);
3129                 (void) destroy_mitem(mtmp, SPBOOK_CLASS, AD_FIRE);
3130                 (void) destroy_mitem(mtmp, POTION_CLASS, AD_FIRE);
3131             }
3132             if (burn_floor_objects(mtmp->mx, mtmp->my, see_it, FALSE)
3133                 && !see_it && distu(mtmp->mx, mtmp->my) <= 3 * 3)
3134 /*JP
3135                 You("smell smoke.");
3136 */
3137                 pline("\89\8c\82Ì\93õ\82¢\82ª\82µ\82½\81D");
3138             if (is_ice(mtmp->mx, mtmp->my))
3139                 melt_ice(mtmp->mx, mtmp->my, (char *) 0);
3140             if (see_it && t_at(mtmp->mx, mtmp->my))
3141                 seetrap(trap);
3142             break;
3143         case PIT:
3144         case SPIKED_PIT:
3145 /*JP
3146             fallverb = "falls";
3147 */
3148             fallverb = "\97\8e\82¿\82½";
3149             if (is_flyer(mptr) || is_floater(mptr)
3150                 || (mtmp->wormno && count_wsegs(mtmp) > 5)
3151                 || is_clinger(mptr)) {
3152                 if (force_mintrap && !Sokoban) {
3153                     /* openfallingtrap; not inescapable here */
3154                     if (in_sight) {
3155                         seetrap(trap);
3156 /*JP
3157                         pline("%s doesn't fall into the pit.", Monnam(mtmp));
3158 */
3159                         pline("%s\82Í\97\8e\82µ\8c\8a\82É\97\8e\82¿\82È\82©\82Á\82½\81D", Monnam(mtmp));
3160                     }
3161                     break; /* inescapable = FALSE; */
3162                 }
3163                 if (!inescapable)
3164                     break;               /* avoids trap */
3165 #if 0 /*JP:T*/
3166                 fallverb = "is dragged"; /* sokoban pit */
3167 #else
3168                 fallverb = "\82¸\82è\97\8e\82¿\82½"; /* sokoban pit */
3169 #endif
3170             }
3171             if (!passes_walls(mptr))
3172                 mtmp->mtrapped = 1;
3173             if (in_sight) {
3174 #if 0 /*JP:T*/
3175                 pline("%s %s into %s pit!", Monnam(mtmp), fallverb,
3176                       a_your[trap->madeby_u]);
3177 #else
3178                 pline("%s\82Í%s\97\8e\82µ\8c\8a\82É%s\81I", Monnam(mtmp),
3179                       set_you[trap->madeby_u], fallverb);
3180 #endif
3181                 if (mptr == &mons[PM_PIT_VIPER]
3182                     || mptr == &mons[PM_PIT_FIEND])
3183 /*JP
3184                     pline("How pitiful.  Isn't that the pits?");
3185 */
3186                     pline("\82±\82Ì\97\8e\82µ\8c\8a\82Í\82¢\82¢\8ed\8e\96\82ð\82µ\82Ä\82¢\82é\81D");
3187                 seetrap(trap);
3188             }
3189 /*JP
3190             mselftouch(mtmp, "Falling, ", FALSE);
3191 */
3192             mselftouch(mtmp, "\97\8e\89º\92\86\81C", FALSE);
3193             if (DEADMONSTER(mtmp) || thitm(0, mtmp, (struct obj *) 0,
3194                                         rnd((tt == PIT) ? 6 : 10), FALSE))
3195                 trapkilled = TRUE;
3196             break;
3197         case HOLE:
3198         case TRAPDOOR:
3199             if (!Can_fall_thru(&u.uz)) {
3200                 impossible("mintrap: %ss cannot exist on this level.",
3201                            defsyms[trap_to_defsym(tt)].explanation);
3202                 break; /* don't activate it after all */
3203             }
3204             if (is_flyer(mptr) || is_floater(mptr) || mptr == &mons[PM_WUMPUS]
3205                 || (mtmp->wormno && count_wsegs(mtmp) > 5)
3206                 || mptr->msize >= MZ_HUGE) {
3207                 if (force_mintrap && !Sokoban) {
3208                     /* openfallingtrap; not inescapable here */
3209                     if (in_sight) {
3210                         seetrap(trap);
3211                         if (tt == TRAPDOOR)
3212                             pline(
3213 /*JP
3214                             "A trap door opens, but %s doesn't fall through.",
3215 */
3216                             "\97\8e\82µ\94à\82ª\8aJ\82¢\82½\82ª\81C%s\82Í\97\8e\82¿\82È\82©\82Á\82½\81D",
3217                                   mon_nam(mtmp));
3218                         else /* (tt == HOLE) */
3219 /*JP
3220                             pline("%s doesn't fall through the hole.",
3221 */
3222                             pline("%s\82Í\8c\8a\82É\97\8e\82¿\82È\82©\82Á\82½\81D",
3223                                   Monnam(mtmp));
3224                     }
3225                     break; /* inescapable = FALSE; */
3226                 }
3227                 if (inescapable) { /* sokoban hole */
3228                     if (in_sight) {
3229 /*JP
3230                         pline("%s seems to be yanked down!", Monnam(mtmp));
3231 */
3232                         pline("%s\82Í\88ø\82«\97\8e\82³\82ê\82½\82æ\82¤\82¾\81I", Monnam(mtmp));
3233                         /* suppress message in mlevel_tele_trap() */
3234                         in_sight = FALSE;
3235                         seetrap(trap);
3236                     }
3237                 } else
3238                     break;
3239             }
3240             /*FALLTHRU*/
3241         case LEVEL_TELEP:
3242         case MAGIC_PORTAL: {
3243             int mlev_res;
3244
3245             mlev_res = mlevel_tele_trap(mtmp, trap, inescapable, in_sight);
3246             if (mlev_res)
3247                 return mlev_res;
3248             break;
3249         }
3250         case TELEP_TRAP:
3251             mtele_trap(mtmp, trap, in_sight);
3252             break;
3253         case WEB:
3254             /* Monster in a web. */
3255             if (webmaker(mptr))
3256                 break;
3257             if (mu_maybe_destroy_web(mtmp, in_sight, trap))
3258                 break;
3259             tear_web = FALSE;
3260             switch (monsndx(mptr)) {
3261             case PM_OWLBEAR: /* Eric Backus */
3262             case PM_BUGBEAR:
3263                 if (!in_sight) {
3264 /*JP
3265                     You_hear("the roaring of a confused bear!");
3266 */
3267                     You_hear("\8d¬\97\90\82Ì\99ô\9aK\82ð\95·\82¢\82½\81I");
3268                     mtmp->mtrapped = 1;
3269                     break;
3270                 }
3271                 /*FALLTHRU*/
3272             default:
3273                 if (mptr->mlet == S_GIANT
3274                     /* exclude baby dragons and relatively short worms */
3275                     || (mptr->mlet == S_DRAGON && extra_nasty(mptr))
3276                     || (mtmp->wormno && count_wsegs(mtmp) > 5)) {
3277                     tear_web = TRUE;
3278                 } else if (in_sight) {
3279 #if 0 /*JP:T*/
3280                     pline("%s is caught in %s spider web.", Monnam(mtmp),
3281                           a_your[trap->madeby_u]);
3282 #else
3283                     pline("%s\82Í%s\82­\82à\82Ì\91\83\82É\82Â\82©\82Ü\82Á\82½\81D", Monnam(mtmp),
3284                           web_you[trap->madeby_u]);
3285 #endif
3286                     seetrap(trap);
3287                 }
3288                 mtmp->mtrapped = tear_web ? 0 : 1;
3289                 break;
3290             /* this list is fairly arbitrary; it deliberately
3291                excludes wumpus & giant/ettin zombies/mummies */
3292             case PM_TITANOTHERE:
3293             case PM_BALUCHITHERIUM:
3294             case PM_PURPLE_WORM:
3295             case PM_JABBERWOCK:
3296             case PM_IRON_GOLEM:
3297             case PM_BALROG:
3298             case PM_KRAKEN:
3299             case PM_MASTODON:
3300             case PM_ORION:
3301             case PM_NORN:
3302             case PM_CYCLOPS:
3303             case PM_LORD_SURTUR:
3304                 tear_web = TRUE;
3305                 break;
3306             }
3307             if (tear_web) {
3308                 if (in_sight)
3309 #if 0 /*JP:T*/
3310                     pline("%s tears through %s spider web!", Monnam(mtmp),
3311                           a_your[trap->madeby_u]);
3312 #else
3313                     pline("%s\82Í%s\82­\82à\82Ì\91\83\82ð\88ø\82«\97ô\82¢\82½\81I", Monnam(mtmp),
3314                           web_you[trap->madeby_u]);
3315 #endif
3316                 deltrap(trap);
3317                 newsym(mtmp->mx, mtmp->my);
3318             } else if (force_mintrap && !mtmp->mtrapped) {
3319                 if (in_sight) {
3320 #if 0 /*JP:T*/
3321                     pline("%s avoids %s spider web!", Monnam(mtmp),
3322                           a_your[trap->madeby_u]);
3323 #else
3324                     pline("%s\82Í%s\82­\82à\82Ì\91\83\82ð\94ð\82¯\82½\81I", Monnam(mtmp),
3325                           web_you[trap->madeby_u]);
3326 #endif
3327                     seetrap(trap);
3328                 }
3329             }
3330             break;
3331         case STATUE_TRAP:
3332             break;
3333         case MAGIC_TRAP:
3334             /* A magic trap.  Monsters usually immune. */
3335             if (!rn2(21))
3336                 goto mfiretrap;
3337             break;
3338         case ANTI_MAGIC:
3339             /* similar to hero's case, more or less */
3340             if (!resists_magm(mtmp)) { /* lose spell energy */
3341                 if (!mtmp->mcan && (attacktype(mptr, AT_MAGC)
3342                                     || attacktype(mptr, AT_BREA))) {
3343                     mtmp->mspec_used += d(2, 2);
3344                     if (in_sight) {
3345                         seetrap(trap);
3346 /*JP
3347                         pline("%s seems lethargic.", Monnam(mtmp));
3348 */
3349                         pline("%s\88ê\8fu\96³\8bC\97Í\8a´\82ð\8a´\82\82½\81D", Monnam(mtmp));
3350                     }
3351                 }
3352             } else { /* take some damage */
3353                 int dmgval2 = rnd(4);
3354
3355                 if ((otmp = MON_WEP(mtmp)) != 0
3356                     && otmp->oartifact == ART_MAGICBANE)
3357                     dmgval2 += rnd(4);
3358                 for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj)
3359                     if (otmp->oartifact
3360                         && defends_when_carried(AD_MAGM, otmp))
3361                         break;
3362                 if (otmp)
3363                     dmgval2 += rnd(4);
3364                 if (passes_walls(mptr))
3365                     dmgval2 = (dmgval2 + 3) / 4;
3366
3367                 if (in_sight)
3368                     seetrap(trap);
3369                 mtmp->mhp -= dmgval2;
3370                 if (DEADMONSTER(mtmp))
3371                     monkilled(mtmp,
3372                               in_sight
3373 /*JP
3374                                   ? "compression from an anti-magic field"
3375 */
3376                                   ? "\94½\96\82\96@\8bó\8aÔ\82Ì\88³\8fk"
3377                                   : (const char *) 0,
3378                               -AD_MAGM);
3379                 if (DEADMONSTER(mtmp))
3380                     trapkilled = TRUE;
3381                 if (see_it)
3382                     newsym(trap->tx, trap->ty);
3383             }
3384             break;
3385         case LANDMINE:
3386             if (rn2(3))
3387                 break; /* monsters usually don't set it off */
3388             if (is_flyer(mptr)) {
3389                 boolean already_seen = trap->tseen;
3390
3391                 if (in_sight && !already_seen) {
3392 /*JP
3393                     pline("A trigger appears in a pile of soil below %s.",
3394 */
3395                     pline("%s\82Ì\91«\8c³\82Ì\93y\82Ì\8eR\82É\8bN\94\9a\83X\83C\83b\83`\82ª\8c»\82í\82ê\82½\81D",
3396                           mon_nam(mtmp));
3397                     seetrap(trap);
3398                 }
3399                 if (rn2(3))
3400                     break;
3401                 if (in_sight) {
3402                     newsym(mtmp->mx, mtmp->my);
3403 #if 0 /*JP:T*/
3404                     pline_The("air currents set %s off!",
3405                               already_seen ? "a land mine" : "it");
3406 #else
3407                     pline("\8bó\8bC\82Ì\97¬\82ê\82Å\83X\83C\83b\83`\82ª\93ü\82Á\82½\81I");
3408 #endif
3409                 }
3410             } else if (in_sight) {
3411                 newsym(mtmp->mx, mtmp->my);
3412 #if 0 /*JP:T*/
3413                 pline("%s%s triggers %s land mine!",
3414                       !Deaf ? "KAABLAMM!!!  " : "", Monnam(mtmp),
3415                       a_your[trap->madeby_u]);
3416 #else
3417                 pline("%s%s\82Í%s\92n\97\8b\82Ì\8bN\94\9a\83X\83C\83b\83`\82ð\93¥\82ñ\82¾\81I",
3418                       !Deaf ? "\82¿\82ã\82Ç\81[\82ñ\81I\81I" : "", Monnam(mtmp),
3419                       set_you[trap->madeby_u]);
3420 #endif
3421             }
3422             if (!in_sight && !Deaf)
3423 #if 0 /*JP*/
3424                 pline("Kaablamm!  %s an explosion in the distance!",
3425                       "You hear");  /* Deaf-aware */
3426 #else
3427                 /*JP:TODO:Deaf\91Î\89\9e*/
3428                 pline("\82¿\82ã\82Ç\81[\82ñ\81I\82 \82È\82½\82Í\89\93\95û\82Ì\94\9a\94­\89¹\82ð\95·\82¢\82½\81I");
3429 #endif
3430             blow_up_landmine(trap);
3431             /* explosion might have destroyed a drawbridge; don't
3432                dish out more damage if monster is already dead */
3433             if (DEADMONSTER(mtmp)
3434                 || thitm(0, mtmp, (struct obj *) 0, rnd(16), FALSE)) {
3435                 trapkilled = TRUE;
3436             } else {
3437                 /* monsters recursively fall into new pit */
3438                 if (mintrap(mtmp) == 2)
3439                     trapkilled = TRUE;
3440             }
3441             /* a boulder may fill the new pit, crushing monster */
3442             fill_pit(tx, ty); /* thitm may have already destroyed the trap */
3443             if (DEADMONSTER(mtmp))
3444                 trapkilled = TRUE;
3445             if (unconscious()) {
3446                 multi = -1;
3447 /*JP
3448                 nomovemsg = "The explosion awakens you!";
3449 */
3450                 nomovemsg = "\94\9a\94­\82Å\82 \82È\82½\82Í\8bN\82«\82½\81I";
3451             }
3452             break;
3453         case POLY_TRAP:
3454             if (resists_magm(mtmp)) {
3455                 shieldeff(mtmp->mx, mtmp->my);
3456             } else if (!resist(mtmp, WAND_CLASS, 0, NOTELL)) {
3457                 if (newcham(mtmp, (struct permonst *) 0, FALSE, FALSE))
3458                     /* we're done with mptr but keep it up to date */
3459                     mptr = mtmp->data;
3460                 if (in_sight)
3461                     seetrap(trap);
3462             }
3463             break;
3464         case ROLLING_BOULDER_TRAP:
3465             if (!is_flyer(mptr)) {
3466                 int style = ROLL | (in_sight ? 0 : LAUNCH_UNSEEN);
3467
3468                 newsym(mtmp->mx, mtmp->my);
3469                 if (in_sight)
3470 #if 0 /*JP:T*/
3471                     pline("Click!  %s triggers %s.", Monnam(mtmp),
3472                           trap->tseen ? "a rolling boulder trap" : something);
3473 #else
3474                     pline("\83J\83`\83b\81I%s\82Í%s\82Ì\83X\83C\83b\83`\82ð\93¥\82ñ\82¾\81I", Monnam(mtmp),
3475                           trap->tseen ? "\97\8e\8aâ\82Ìã©" : "\89½\82©");
3476 #endif
3477                 if (launch_obj(BOULDER, trap->launch.x, trap->launch.y,
3478                                trap->launch2.x, trap->launch2.y, style)) {
3479                     if (in_sight)
3480                         trap->tseen = TRUE;
3481                     if (DEADMONSTER(mtmp))
3482                         trapkilled = TRUE;
3483                 } else {
3484                     deltrap(trap);
3485                     newsym(mtmp->mx, mtmp->my);
3486                 }
3487             }
3488             break;
3489         case VIBRATING_SQUARE:
3490             if (see_it && !Blind) {
3491                 seetrap(trap); /* before messages */
3492                 if (in_sight) {
3493 #if 0 /*JP*/
3494                     char buf[BUFSZ], *p, *monnm = mon_nam(mtmp);
3495
3496                     if (nolimbs(mtmp->data)
3497                         || is_floater(mtmp->data) || is_flyer(mtmp->data)) {
3498                         /* just "beneath <mon>" */
3499                         Strcpy(buf, monnm);
3500                     } else {
3501                         Strcpy(buf, s_suffix(monnm));
3502                         p = eos(strcat(buf, " "));
3503                         Strcpy(p, makeplural(mbodypart(mtmp, FOOT)));
3504                         /* avoid "beneath 'rear paws'" or 'rear hooves' */
3505                         (void) strsubst(p, "rear ", "");
3506                     }
3507                     You_see("a strange vibration beneath %s.", buf);
3508 #else /* \91«\82ª\82È\82­\82Ä\82à\81u\91«\8c³\81v\82Å\93\9d\88ê */
3509                     You_see("%s\82Ì\91«\8c³\82ª\95s\8ev\8bc\82É\90U\93®\82µ\82Ä\82¢\82é\82Ì\82ð\8c©\82½\81D",
3510                             mon_nam(mtmp));
3511 #endif
3512                 } else {
3513                     /* notice something (hearing uses a larger threshold
3514                        for 'nearby') */
3515 #if 0 /*JP:T*/
3516                     You_see("the ground vibrate %s.",
3517                             (distu(mtmp->mx, mtmp->my) <= 2 * 2)
3518                                ? "nearby" : "in the distance");
3519 #else
3520                     You_see("%s\82­\82Å\92n\96Ê\82ª\90U\93®\82µ\82Ä\82¢\82é\82Ì\82ð\8c©\82½\81D",
3521                             (distu(mtmp->mx, mtmp->my) <= 2 * 2)
3522                                ? "\8bß" : "\89\93");
3523 #endif
3524                 }
3525             }
3526             break;
3527         default:
3528             impossible("Some monster encountered a strange trap of type %d.",
3529                        tt);
3530         }
3531     }
3532     if (trapkilled)
3533         return 2;
3534     return mtmp->mtrapped;
3535 }
3536
3537 /* Combine cockatrice checks into single functions to avoid repeating code. */
3538 void
3539 instapetrify(str)
3540 const char *str;
3541 {
3542     if (Stone_resistance)
3543         return;
3544     if (poly_when_stoned(youmonst.data) && polymon(PM_STONE_GOLEM))
3545         return;
3546 /*JP
3547     You("turn to stone...");
3548 */
3549     You("\90Î\82É\82È\82Á\82½\81D\81D\81D");
3550     killer.format = KILLED_BY;
3551     if (str != killer.name)
3552         Strcpy(killer.name, str ? str : "");
3553     done(STONING);
3554 }
3555
3556 void
3557 minstapetrify(mon, byplayer)
3558 struct monst *mon;
3559 boolean byplayer;
3560 {
3561     if (resists_ston(mon))
3562         return;
3563     if (poly_when_stoned(mon->data)) {
3564         mon_to_stone(mon);
3565         return;
3566     }
3567     if (!vamp_stone(mon))
3568         return;
3569
3570     /* give a "<mon> is slowing down" message and also remove
3571        intrinsic speed (comparable to similar effect on the hero) */
3572     mon_adjust_speed(mon, -3, (struct obj *) 0);
3573
3574     if (cansee(mon->mx, mon->my))
3575 /*JP
3576         pline("%s turns to stone.", Monnam(mon));
3577 */
3578         pline("%s\82Í\90Î\82É\82È\82Á\82½\81D", Monnam(mon));
3579     if (byplayer) {
3580         stoned = TRUE;
3581         xkilled(mon, XKILL_NOMSG);
3582     } else
3583         monstone(mon);
3584 }
3585
3586 void
3587 selftouch(arg)
3588 const char *arg;
3589 {
3590     char kbuf[BUFSZ];
3591
3592     if (uwep && uwep->otyp == CORPSE && touch_petrifies(&mons[uwep->corpsenm])
3593         && !Stone_resistance) {
3594 /*JP
3595         pline("%s touch the %s corpse.", arg, mons[uwep->corpsenm].mname);
3596 */
3597         pline("%s%s\82Ì\8e\80\91Ì\82É\90G\82Á\82½\81D", arg, mons[uwep->corpsenm].mname);
3598 /*JP
3599         Sprintf(kbuf, "%s corpse", an(mons[uwep->corpsenm].mname));
3600 */
3601         Sprintf(kbuf, "%s\82Ì\8e\80\91Ì\82Å", mons[uwep->corpsenm].mname);
3602         instapetrify(kbuf);
3603         /* life-saved; unwield the corpse if we can't handle it */
3604         if (!uarmg && !Stone_resistance)
3605             uwepgone();
3606     }
3607     /* Or your secondary weapon, if wielded [hypothetical; we don't
3608        allow two-weapon combat when either weapon is a corpse] */
3609     if (u.twoweap && uswapwep && uswapwep->otyp == CORPSE
3610         && touch_petrifies(&mons[uswapwep->corpsenm]) && !Stone_resistance) {
3611 /*JP
3612         pline("%s touch the %s corpse.", arg, mons[uswapwep->corpsenm].mname);
3613 */
3614         pline("%s%s\82Ì\8e\80\91Ì\82É\90G\82Á\82½\81D", arg, mons[uswapwep->corpsenm].mname);
3615 /*JP
3616         Sprintf(kbuf, "%s corpse", an(mons[uswapwep->corpsenm].mname));
3617 */
3618         Sprintf(kbuf, "%s\82Ì\8e\80\91Ì\82Å", mons[uswapwep->corpsenm].mname);
3619         instapetrify(kbuf);
3620         /* life-saved; unwield the corpse */
3621         if (!uarmg && !Stone_resistance)
3622             uswapwepgone();
3623     }
3624 }
3625
3626 void
3627 mselftouch(mon, arg, byplayer)
3628 struct monst *mon;
3629 const char *arg;
3630 boolean byplayer;
3631 {
3632     struct obj *mwep = MON_WEP(mon);
3633
3634     if (mwep && mwep->otyp == CORPSE && touch_petrifies(&mons[mwep->corpsenm])
3635         && !resists_ston(mon)) {
3636         if (cansee(mon->mx, mon->my)) {
3637 #if 0 /*JP:T*/
3638             pline("%s%s touches %s.", arg ? arg : "",
3639                   arg ? mon_nam(mon) : Monnam(mon),
3640                   corpse_xname(mwep, (const char *) 0, CXN_PFX_THE));
3641 #else
3642             pline("%s%s\82Í%s\82Ì\8e\80\91Ì\82É\90G\82Á\82½\81D", arg ? arg : "",
3643                   arg ? mon_nam(mon) : Monnam(mon),
3644                   corpse_xname(mwep, (const char *) 0, CXN_PFX_THE));
3645 #endif
3646         }
3647         minstapetrify(mon, byplayer);
3648         /* if life-saved, might not be able to continue wielding */
3649         if (!DEADMONSTER(mon) && !which_armor(mon, W_ARMG) && !resists_ston(mon))
3650             mwepgone(mon);
3651     }
3652 }
3653
3654 /* start levitating */
3655 void
3656 float_up()
3657 {
3658     context.botl = TRUE;
3659     if (u.utrap) {
3660         if (u.utraptype == TT_PIT) {
3661             reset_utrap(FALSE);
3662 /*JP
3663             You("float up, out of the pit!");
3664 */
3665             You("\95\82\82«\8fã\82ª\82Á\82Ä\81C\97\8e\82µ\8c\8a\82©\82ç\8fo\82½\81I");
3666             vision_full_recalc = 1; /* vision limits change */
3667             fill_pit(u.ux, u.uy);
3668         } else if (u.utraptype == TT_LAVA /* molten lava */
3669                    || u.utraptype == TT_INFLOOR) { /* solidified lava */
3670 /*JP
3671             Your("body pulls upward, but your %s are still stuck.",
3672 */
3673             Your("\91Ì\82Í\88ø\82«\8fã\82°\82ç\82ê\82½\81D\82µ\82©\82µ%s\82Í\82Ü\82¾\82Í\82Ü\82Á\82Ä\82¢\82é\81D",
3674                  makeplural(body_part(LEG)));
3675         } else if (u.utraptype == TT_BURIEDBALL) { /* tethered */
3676             coord cc;
3677
3678             cc.x = u.ux, cc.y = u.uy;
3679             /* caveat: this finds the first buried iron ball within
3680                one step of the specified location, not necessarily the
3681                buried [former] uball at the original anchor point */
3682             (void) buried_ball(&cc);
3683             /* being chained to the floor blocks levitation from floating
3684                above that floor but not from enhancing carrying capacity */
3685 #if 0 /*JP:T*/
3686             You("feel lighter, but your %s is still chained to the %s.",
3687                 body_part(LEG),
3688                 IS_ROOM(levl[cc.x][cc.y].typ) ? "floor" : "ground");
3689 #else
3690             You("\82·\82±\82µ\8cy\82­\82È\82Á\82½\82ª\81C\82 \82È\82½\82Ì%s\82Í\82Ü\82¾%s\82É\82Â\82È\82ª\82Á\82Ä\82¢\82é\81D",
3691                 body_part(LEG),
3692                 IS_ROOM(levl[cc.x][cc.y].typ) ? "\8f°" : "\92n\96Ê");
3693 #endif
3694         } else if (u.utraptype == WEB) {
3695 /*JP
3696             You("float up slightly, but you are still stuck in the web.");
3697 */
3698             You("\82·\82±\82µ\95\82\82«\8fã\82ª\82Á\82½\82ª\81C\82Ü\82¾\82­\82à\82Ì\91\83\82É\82Â\82©\82Ü\82Á\82Ä\82¢\82é\81D");
3699         } else { /* bear trap */
3700 /*JP
3701             You("float up slightly, but your %s is still stuck.",
3702 */
3703             You("\8f­\82µ\95\82\82«\8fã\82ª\82Á\82½\82ª%s\82Í\82Ü\82¾\82Í\82Ü\82Á\82Ä\82¢\82é\81D",
3704                 body_part(LEG));
3705         }
3706         /* when still trapped, float_vs_flight() below will block levitation */
3707 #if 0
3708     } else if (Is_waterlevel(&u.uz)) {
3709 /*JP
3710         pline("It feels as though you've lost some weight.");
3711 */
3712         You("\82Ü\82é\82Å\91Ì\8fd\82ª\8c¸\82Á\82½\82æ\82¤\82É\8a´\82\82½\81D");
3713 #endif
3714     } else if (u.uinwater) {
3715         spoteffects(TRUE);
3716     } else if (u.uswallow) {
3717 #if 0 /*JP:T*/
3718         You(is_animal(u.ustuck->data) ? "float away from the %s."
3719                                       : "spiral up into %s.",
3720             is_animal(u.ustuck->data) ? surface(u.ux, u.uy)
3721                                       : mon_nam(u.ustuck));
3722 #else
3723         You(is_animal(u.ustuck->data) ? "%s\82Ì\92\86\82Å\95\82\82¢\82½\81D"
3724                                       : "%s\82Ì\92\86\82Å\82®\82é\82®\82é\89ñ\93]\82µ\82½\81D",
3725             is_animal(u.ustuck->data) ? surface(u.ux, u.uy)
3726                                       : mon_nam(u.ustuck));
3727 #endif
3728     } else if (Hallucination) {
3729 /*JP
3730         pline("Up, up, and awaaaay!  You're walking on air!");
3731 */
3732         pline("\8fã\82ê\81C\8fã\82ê\81C\8fã\82ê\82¥\82¥\82¥\82¥\81I\82 \82È\82½\82Í\8bó\92\86\82ð\95à\82¢\82Ä\82¢\82é\81I");
3733     } else if (Is_airlevel(&u.uz)) {
3734 /*JP
3735         You("gain control over your movements.");
3736 */
3737         You("\82¤\82Ü\82­\93®\82¯\82é\82æ\82¤\82É\82È\82Á\82½\81D");
3738     } else {
3739 /*JP
3740         You("start to float in the air!");
3741 */
3742         You("\8bó\92\86\82É\95\82\82«\82Í\82\82ß\82½\81I");
3743     }
3744     if (u.usteed && !is_floater(u.usteed->data) && !is_flyer(u.usteed->data)) {
3745         if (Lev_at_will) {
3746 /*JP
3747             pline("%s magically floats up!", Monnam(u.usteed));
3748 */
3749             pline("%s\82Í\96\82\96@\82Ì\97Í\82Å\95\82\82¢\82½\81I", Monnam(u.usteed));
3750         } else {
3751 /*JP
3752             You("cannot stay on %s.", mon_nam(u.usteed));
3753 */
3754             You("%s\82Ì\8fã\82É\8fæ\82Á\82Ä\82¢\82ç\82ê\82È\82¢\81D", mon_nam(u.usteed));
3755             dismount_steed(DISMOUNT_GENERIC);
3756         }
3757     }
3758     if (Flying)
3759 /*JP
3760         You("are no longer able to control your flight.");
3761 */
3762         You("\8bó\92\86\82Å\82¤\82Ü\82­\93®\82¯\82È\82­\82È\82Á\82½\81D");
3763     float_vs_flight(); /* set BFlying, also BLevitation if still trapped */
3764     /* levitation gives maximum carrying capacity, so encumbrance
3765        state might be reduced */
3766     (void) encumber_msg();
3767     return;
3768 }
3769
3770 void
3771 fill_pit(x, y)
3772 int x, y;
3773 {
3774     struct obj *otmp;
3775     struct trap *t;
3776
3777     if ((t = t_at(x, y)) && is_pit(t->ttyp)
3778         && (otmp = sobj_at(BOULDER, x, y))) {
3779         obj_extract_self(otmp);
3780 /*JP
3781         (void) flooreffects(otmp, x, y, "settle");
3782 */
3783         (void) flooreffects(otmp, x, y, "\82Í\82Ü\82é");
3784     }
3785 }
3786
3787 /* stop levitating */
3788 int
3789 float_down(hmask, emask)
3790 long hmask, emask; /* might cancel timeout */
3791 {
3792     register struct trap *trap = (struct trap *) 0;
3793     d_level current_dungeon_level;
3794     boolean no_msg = FALSE;
3795
3796     HLevitation &= ~hmask;
3797     ELevitation &= ~emask;
3798     if (Levitation)
3799         return 0; /* maybe another ring/potion/boots */
3800     if (BLevitation) {
3801         /* if blocked by terrain, we haven't actually been levitating so
3802            we don't give any end-of-levitation feedback or side-effects,
3803            but if blocking is solely due to being trapped in/on floor,
3804            do give some feedback but skip other float_down() effects */
3805         boolean trapped = (BLevitation == I_SPECIAL);
3806
3807         float_vs_flight();
3808         if (trapped && u.utrap) /* u.utrap => paranoia */
3809 #if 0 /*JP:T*/
3810             You("are no longer trying to float up from the %s.",
3811                 (u.utraptype == TT_BEARTRAP) ? "trap's jaws"
3812                   : (u.utraptype == TT_WEB) ? "web"
3813                       : (u.utraptype == TT_BURIEDBALL) ? "chain"
3814                           : (u.utraptype == TT_LAVA) ? "lava"
3815                               : "ground"); /* TT_INFLOOR */
3816 #else
3817             You("\82à\82Í\82â%s\82©\82ç\95\82\82«\8fã\82ª\82ë\82¤\82Æ\82µ\82È\82­\82È\82Á\82½\81D",
3818                 (u.utraptype == TT_BEARTRAP) ? "ã©\82Ì\8e\95"
3819                   : (u.utraptype == TT_WEB) ? "\82­\82à\82Ì\91\83"
3820                       : (u.utraptype == TT_BURIEDBALL) ? "\8d½"
3821                           : (u.utraptype == TT_LAVA) ? "\97n\8aâ"
3822                               : "\92n\96Ê"); /* TT_INFLOOR */
3823 #endif
3824         (void) encumber_msg(); /* carrying capacity might have changed */
3825         return 0;
3826     }
3827     context.botl = TRUE;
3828     nomul(0); /* stop running or resting */
3829     if (BFlying) {
3830         /* controlled flight no longer overridden by levitation */
3831         float_vs_flight(); /* clears BFlying & I_SPECIAL
3832                             * unless hero is stuck in floor */
3833         if (Flying) {
3834 /*JP
3835             You("have stopped levitating and are now flying.");
3836 */
3837             You("\8bó\92\86\95\82\97V\82ð\8e~\82ß\82Ä\8bó\82ð\94ò\82Ñ\82Í\82\82ß\82½\81D");
3838             (void) encumber_msg(); /* carrying capacity might have changed */
3839             return 1;
3840         }
3841     }
3842     if (u.uswallow) {
3843 #if 0 /*JP:T*/
3844         You("float down, but you are still %s.",
3845             is_animal(u.ustuck->data) ? "swallowed" : "engulfed");
3846 #else
3847         You("\92\85\92n\82µ\82½\82ª\81C\82Ü\82¾\88ù\82Ý\8d\9e\82Ü\82ê\82½\82Ü\82Ü\82¾\81D");
3848 #endif
3849         (void) encumber_msg();
3850         return 1;
3851     }
3852
3853     if (Punished && !carried(uball)
3854         && (is_pool(uball->ox, uball->oy)
3855             || ((trap = t_at(uball->ox, uball->oy))
3856                 && (is_pit(trap->ttyp) || is_hole(trap->ttyp))))) {
3857         u.ux0 = u.ux;
3858         u.uy0 = u.uy;
3859         u.ux = uball->ox;
3860         u.uy = uball->oy;
3861         movobj(uchain, uball->ox, uball->oy);
3862         newsym(u.ux0, u.uy0);
3863         vision_full_recalc = 1; /* in case the hero moved. */
3864     }
3865     /* check for falling into pool - added by GAN 10/20/86 */
3866     if (!Flying) {
3867         if (!u.uswallow && u.ustuck) {
3868             if (sticks(youmonst.data))
3869 #if 0 /*JP:T*/
3870                 You("aren't able to maintain your hold on %s.",
3871                     mon_nam(u.ustuck));
3872 #else
3873                 You("%s\82ð\82Â\82©\82Ü\82¦\91±\82¯\82Ä\82¢\82ç\82ê\82È\82­\82È\82Á\82½\81D",
3874                     mon_nam(u.ustuck));
3875 #endif
3876             else
3877 #if 0 /*JP:T*/
3878                 pline("Startled, %s can no longer hold you!",
3879                       mon_nam(u.ustuck));
3880 #else
3881                 pline("%s\82Í\8bÁ\82¢\82Ä\82 \82È\82½\82ð\95ú\82µ\82Ä\82µ\82Ü\82Á\82½\81I",
3882                       mon_nam(u.ustuck));
3883 #endif
3884             u.ustuck = 0;
3885         }
3886         /* kludge alert:
3887          * drown() and lava_effects() print various messages almost
3888          * every time they're called which conflict with the "fall
3889          * into" message below.  Thus, we want to avoid printing
3890          * confusing, duplicate or out-of-order messages.
3891          * Use knowledge of the two routines as a hack -- this
3892          * should really be handled differently -dlc
3893          */
3894         if (is_pool(u.ux, u.uy) && !Wwalking && !Swimming && !u.uinwater)
3895             no_msg = drown();
3896
3897         if (is_lava(u.ux, u.uy)) {
3898             (void) lava_effects();
3899             no_msg = TRUE;
3900         }
3901     }
3902     if (!trap) {
3903         trap = t_at(u.ux, u.uy);
3904         if (Is_airlevel(&u.uz)) {
3905 /*JP
3906             You("begin to tumble in place.");
3907 */
3908             You("\82»\82Ì\8fê\82Å\82Ð\82Á\82­\82è\95Ô\82è\82Í\82\82ß\82½\81D");
3909         } else if (Is_waterlevel(&u.uz) && !no_msg) {
3910 /*JP
3911             You_feel("heavier.");
3912 */
3913             You("\8fd\82­\82È\82Á\82½\82æ\82¤\82È\8bC\82ª\82µ\82½\81D");
3914         /* u.uinwater msgs already in spoteffects()/drown() */
3915         } else if (!u.uinwater && !no_msg) {
3916             if (!(emask & W_SADDLE)) {
3917                 if (Sokoban && trap) {
3918                     /* Justification elsewhere for Sokoban traps is based
3919                      * on air currents.  This is consistent with that.
3920                      * The unexpected additional force of the air currents
3921                      * once levitation ceases knocks you off your feet.
3922                      */
3923                     if (Hallucination)
3924 /*JP
3925                         pline("Bummer!  You've crashed.");
3926 */
3927                         pline("\82â\82ß\82Ä\82¥\81I\82 \82È\82½\82Í\92@\82«\82Â\82¯\82ç\82ê\82½\81D");
3928                     else
3929 /*JP
3930                         You("fall over.");
3931 */
3932                         You("\82Â\82Ü\82Ã\82¢\82½\81D");
3933 /*JP
3934                     losehp(rnd(2), "dangerous winds", KILLED_BY);
3935 */
3936                     losehp(rnd(2), "\8aë\8c¯\82È\95\97\82Å", KILLED_BY);
3937                     if (u.usteed)
3938                         dismount_steed(DISMOUNT_FELL);
3939 /*JP
3940                     selftouch("As you fall, you");
3941 */
3942                     selftouch("\97\8e\82¿\82È\82ª\82ç\81C\82 \82È\82½\82Í");
3943                 } else if (u.usteed && (is_floater(u.usteed->data)
3944                                         || is_flyer(u.usteed->data))) {
3945 /*JP
3946                     You("settle more firmly in the saddle.");
3947 */
3948                     You("\82æ\82è\82µ\82Á\82©\82è\82Æ\88Æ\82É\94[\82Ü\82Á\82½\81D");
3949                 } else if (Hallucination) {
3950 #if 0 /*JP:T*/
3951                     pline("Bummer!  You've %s.",
3952                           is_pool(u.ux, u.uy)
3953                              ? "splashed down"
3954                              : "hit the ground");
3955 #else
3956                     pline("\82â\82ß\82Ä\82¥\81I\82 \82È\82½\82Í%s\82É\92@\82«\82Â\82¯\82ç\82ê\82½\81D",
3957                           is_pool(u.ux, u.uy)
3958                              ? "\90\85\96Ê"
3959                              : "\92n\96Ê");
3960 #endif
3961                 } else {
3962 /*JP
3963                     You("float gently to the %s.", surface(u.ux, u.uy));
3964 */
3965                     You("\90Ã\82©\82É%s\82Ü\82Å\92H\82è\82Â\82¢\82½\81D", surface(u.ux, u.uy));
3966                 }
3967             }
3968         }
3969     }
3970
3971     /* levitation gives maximum carrying capacity, so having it end
3972        potentially triggers greater encumbrance; do this after
3973        'come down' messages, before trap activation or autopickup */
3974     (void) encumber_msg();
3975
3976     /* can't rely on u.uz0 for detecting trap door-induced level change;
3977        it gets changed to reflect the new level before we can check it */
3978     assign_level(&current_dungeon_level, &u.uz);
3979     if (trap) {
3980         switch (trap->ttyp) {
3981         case STATUE_TRAP:
3982             break;
3983         case HOLE:
3984         case TRAPDOOR:
3985             if (!Can_fall_thru(&u.uz) || u.ustuck)
3986                 break;
3987             /*FALLTHRU*/
3988         default:
3989             if (!u.utrap) /* not already in the trap */
3990                 dotrap(trap, 0);
3991         }
3992     }
3993     if (!Is_airlevel(&u.uz) && !Is_waterlevel(&u.uz) && !u.uswallow
3994         /* falling through trap door calls goto_level,
3995            and goto_level does its own pickup() call */
3996         && on_level(&u.uz, &current_dungeon_level))
3997         (void) pickup(1);
3998     return 1;
3999 }
4000
4001 /* shared code for climbing out of a pit */
4002 void
4003 climb_pit()
4004 {
4005     if (!u.utrap || u.utraptype != TT_PIT)
4006         return;
4007
4008     if (Passes_walls) {
4009         /* marked as trapped so they can pick things up */
4010 /*JP
4011         You("ascend from the pit.");
4012 */
4013         You("\97\8e\82µ\8c\8a\82ð\8fã\82Á\82Ä\82¢\82Á\82½\81D");
4014         reset_utrap(FALSE);
4015         fill_pit(u.ux, u.uy);
4016         vision_full_recalc = 1; /* vision limits change */
4017     } else if (!rn2(2) && sobj_at(BOULDER, u.ux, u.uy)) {
4018 /*JP
4019         Your("%s gets stuck in a crevice.", body_part(LEG));
4020 */
4021         Your("%s\82Í\8a\84\82ê\96Ú\82É\82Í\82Ü\82Á\82½\81D", body_part(LEG));
4022         display_nhwindow(WIN_MESSAGE, FALSE);
4023         clear_nhwindow(WIN_MESSAGE);
4024 /*JP
4025         You("free your %s.", body_part(LEG));
4026 */
4027         Your("%s\82Í\8e©\97R\82É\82È\82Á\82½\81D", body_part(LEG));
4028     } else if ((Flying || is_clinger(youmonst.data)) && !Sokoban) {
4029         /* eg fell in pit, then poly'd to a flying monster;
4030            or used '>' to deliberately enter it */
4031 /*JP
4032         You("%s from the pit.", Flying ? "fly" : "climb");
4033 */
4034         You("\97\8e\82µ\8c\8a\82©\82ç%s\82¢\82Á\82½\81D", Flying ? "\8fã\82Á\82Ä" : "\93o\82Á\82Ä");
4035         reset_utrap(FALSE);
4036         fill_pit(u.ux, u.uy);
4037         vision_full_recalc = 1; /* vision limits change */
4038     } else if (!(--u.utrap)) {
4039         reset_utrap(FALSE);
4040 #if 0 /*JP:T*/
4041         You("%s to the edge of the pit.",
4042             (Sokoban && Levitation)
4043                 ? "struggle against the air currents and float"
4044                 : u.usteed ? "ride" : "crawl");
4045 #else
4046         You("%s\97\8e\82µ\8c\8a\82Ì\92[\82É\82½\82Ç\82è\92\85\82¢\82½\81D",
4047             (Sokoban && Levitation)
4048                 ? "\8bó\8bC\82Ì\97¬\82ê\82Ì\92\86\82Å\82à\82ª\82«\82È\82ª\82ç" : "");
4049 #endif
4050         fill_pit(u.ux, u.uy);
4051         vision_full_recalc = 1; /* vision limits change */
4052     } else if (u.dz || flags.verbose) {
4053         if (u.usteed)
4054 /*JP
4055             Norep("%s is still in a pit.", upstart(y_monnam(u.usteed)));
4056 */
4057             Norep("%s\82Í\82Ü\82¾\97\8e\82µ\8c\8a\82Ì\92\86\82É\82¢\82é\81D", y_monnam(u.usteed));
4058         else
4059 #if 0 /*JP:T*/
4060             Norep((Hallucination && !rn2(5))
4061                       ? "You've fallen, and you can't get up."
4062                       : "You are still in a pit.");
4063 #else
4064             Norep((Hallucination && !rn2(5))
4065                       ? "\82 \82È\82½\82Í\97\8e\82¿\81C\8fã\82ª\82ê\82È\82¢\81D"
4066                       : "\82 \82È\82½\82Í\82Ü\82¾\97\8e\82µ\8c\8a\82Ì\92\86\82É\82¢\82é\81D");
4067 #endif
4068     }
4069 }
4070
4071 STATIC_OVL void
4072 dofiretrap(box)
4073 struct obj *box; /* null for floor trap */
4074 {
4075     boolean see_it = !Blind;
4076     int num, alt;
4077
4078     /* Bug: for box case, the equivalent of burn_floor_objects() ought
4079      * to be done upon its contents.
4080      */
4081
4082     if ((box && !carried(box)) ? is_pool(box->ox, box->oy) : Underwater) {
4083 /*JP
4084         pline("A cascade of steamy bubbles erupts from %s!",
4085 */
4086         pline("\8fö\8bC\82Ì\96A\82ª%s\82©\82ç\82µ\82ã\81[\82Á\82Æ\94­\90\82µ\82½\81I",
4087               the(box ? xname(box) : surface(u.ux, u.uy)));
4088         if (Fire_resistance)
4089 /*JP
4090             You("are uninjured.");
4091 */
4092             You("\8f\9d\82Â\82©\82È\82¢\81D");
4093         else
4094 /*JP
4095             losehp(rnd(3), "boiling water", KILLED_BY);
4096 */
4097             losehp(rnd(3), "\95¦\93«\82µ\82½\90\85\82Å", KILLED_BY);
4098         return;
4099     }
4100 #if 0 /*JP:T*/
4101     pline("A %s %s from %s!", tower_of_flame, box ? "bursts" : "erupts",
4102           the(box ? xname(box) : surface(u.ux, u.uy)));
4103 #else
4104     pline("\89Î\92\8c\82ª%s\82©\82ç%s\81I", box ? xname(box) : surface(u.ux,u.uy),
4105           box ? "\90\81\82«\8fo\82µ\82½" : "\97§\82¿\82Ì\82Ú\82Á\82½");
4106 #endif
4107     if (Fire_resistance) {
4108         shieldeff(u.ux, u.uy);
4109         num = rn2(2);
4110     } else if (Upolyd) {
4111         num = d(2, 4);
4112         switch (u.umonnum) {
4113         case PM_PAPER_GOLEM:
4114             alt = u.mhmax;
4115             break;
4116         case PM_STRAW_GOLEM:
4117             alt = u.mhmax / 2;
4118             break;
4119         case PM_WOOD_GOLEM:
4120             alt = u.mhmax / 4;
4121             break;
4122         case PM_LEATHER_GOLEM:
4123             alt = u.mhmax / 8;
4124             break;
4125         default:
4126             alt = 0;
4127             break;
4128         }
4129         if (alt > num)
4130             num = alt;
4131         if (u.mhmax > mons[u.umonnum].mlevel)
4132             u.mhmax -= rn2(min(u.mhmax, num + 1)), context.botl = 1;
4133     } else {
4134         num = d(2, 4);
4135         if (u.uhpmax > u.ulevel)
4136             u.uhpmax -= rn2(min(u.uhpmax, num + 1)), context.botl = 1;
4137     }
4138     if (!num)
4139 /*JP
4140         You("are uninjured.");
4141 */
4142         You("\8f\9d\82Â\82©\82È\82¢\81D");
4143     else
4144 #if 0 /*JP:T*/
4145         losehp(num, tower_of_flame, KILLED_BY_AN); /* fire damage */
4146 #else
4147         losehp(num, "\89Î\92\8c\82Å", KILLED_BY_AN); /* fire damage */
4148 #endif
4149     burn_away_slime();
4150
4151     if (burnarmor(&youmonst) || rn2(3)) {
4152         destroy_item(SCROLL_CLASS, AD_FIRE);
4153         destroy_item(SPBOOK_CLASS, AD_FIRE);
4154         destroy_item(POTION_CLASS, AD_FIRE);
4155     }
4156     if (!box && burn_floor_objects(u.ux, u.uy, see_it, TRUE) && !see_it)
4157 /*JP
4158         You("smell paper burning.");
4159 */
4160         You("\8e\86\82Ì\82±\82°\82é\93õ\82¢\82ª\82µ\82½\81D");
4161     if (is_ice(u.ux, u.uy))
4162         melt_ice(u.ux, u.uy, (char *) 0);
4163 }
4164
4165 STATIC_OVL void
4166 domagictrap()
4167 {
4168     register int fate = rnd(20);
4169
4170     /* What happened to the poor sucker? */
4171
4172     if (fate < 10) {
4173         /* Most of the time, it creates some monsters. */
4174         int cnt = rnd(4);
4175
4176         /* blindness effects */
4177         if (!resists_blnd(&youmonst)) {
4178 /*JP
4179             You("are momentarily blinded by a flash of light!");
4180 */
4181             You("\82Ü\82Î\82ä\82¢\8cõ\82Å\88ê\8fu\96Ú\82ª\82­\82ç\82ñ\82¾\81I");
4182             make_blinded((long) rn1(5, 10), FALSE);
4183             if (!Blind)
4184                 Your1(vision_clears);
4185         } else if (!Blind) {
4186 /*JP
4187             You_see("a flash of light!");
4188 */
4189             You("\82Ü\82Î\82ä\82¢\8cõ\82ð\97\81\82Ñ\82½\81I");
4190         }
4191
4192         /* deafness effects */
4193         if (!Deaf) {
4194 /*JP
4195             You_hear("a deafening roar!");
4196 */
4197             You_hear("\8e¨\82ð\82Â\82ñ\82´\82­\82æ\82¤\82È\99ô\9aK\82ð\95·\82¢\82½\81I");
4198             incr_itimeout(&HDeaf, rn1(20, 30));
4199             context.botl = TRUE;
4200         } else {
4201             /* magic vibrations still hit you */
4202 /*JP
4203             You_feel("rankled.");
4204 */
4205             You_feel("\82¢\82ç\82¢\82ç\82µ\82½\81D");
4206             incr_itimeout(&HDeaf, rn1(5, 15));
4207             context.botl = TRUE;
4208         }
4209         while (cnt--)
4210             (void) makemon((struct permonst *) 0, u.ux, u.uy, NO_MM_FLAGS);
4211         /* roar: wake monsters in vicinity, after placing trap-created ones */
4212         wake_nearto(u.ux, u.uy, 7 * 7);
4213         /* [flash: should probably also hit nearby gremlins with light] */
4214     } else
4215         switch (fate) {
4216         case 10:
4217         case 11:
4218             /* sometimes nothing happens */
4219             break;
4220         case 12: /* a flash of fire */
4221             dofiretrap((struct obj *) 0);
4222             break;
4223
4224         /* odd feelings */
4225         case 13:
4226 /*JP
4227             pline("A shiver runs up and down your %s!", body_part(SPINE));
4228 */
4229             pline("\90k\82¦\82ª\82 \82È\82½\82Ì%s\82ð\91\96\82Á\82½\81I", body_part(SPINE));
4230             break;
4231         case 14:
4232 #if 0 /*JP:T*/
4233             You_hear(Hallucination ? "the moon howling at you."
4234                                    : "distant howling.");
4235 #else
4236             You_hear(Hallucination ? "\8c\8e\82ª\96i\82¦\82Ä\82¢\82é\82Ì\82ð\95·\82¢\82½\81D"
4237                                    : "\89\93\95û\82Ì\89\93\96i\82ð\95·\82¢\82½\81D");
4238 #endif
4239             break;
4240         case 15:
4241             if (on_level(&u.uz, &qstart_level))
4242 #if 0 /*JP:T*/
4243                 You_feel(
4244                     "%slike the prodigal son.",
4245                     (flags.female || (Upolyd && is_neuter(youmonst.data)))
4246                         ? "oddly "
4247                         : "");
4248 #else
4249                 /*JP \90¹\8f\91\82Ì\83\8b\83J\93`\82æ\82è */
4250                 You("%s\95ú\93 \91§\8eq\82Ì\82æ\82¤\82É\82È\82Á\82½\82æ\82¤\82È\8bC\82ª\82µ\82½\81D",
4251                     (flags.female || (Upolyd && is_neuter(youmonst.data)))
4252                     ? "\88Ù\8fí\82É"
4253                     : "");
4254 #endif
4255             else
4256 #if 0 /*JP:T*/
4257                 You("suddenly yearn for %s.",
4258                     Hallucination
4259                         ? "Cleveland"
4260                         : (In_quest(&u.uz) || at_dgn_entrance("The Quest"))
4261                               ? "your nearby homeland"
4262                               : "your distant homeland");
4263 #else
4264                 You("\93Ë\91R%s\82ª\97ö\82µ\82­\82È\82Á\82½\81D",
4265                     Hallucination ? "\90Â\90X"
4266                         : (In_quest(&u.uz) || at_dgn_entrance("\83N\83G\83X\83g"))
4267                             ? "\82·\82®\82»\82±\82É\82 \82é\8cÌ\8b½"
4268                             : "\82Í\82é\82©\82©\82È\82½\82Ì\8cÌ\8b½");
4269 #endif
4270             break;
4271         case 16:
4272 /*JP
4273             Your("pack shakes violently!");
4274 */
4275             Your("\91Ü\82Í\8c\83\82µ\82­\97h\82ê\82½\81I");
4276             break;
4277         case 17:
4278 /*JP
4279             You(Hallucination ? "smell hamburgers." : "smell charred flesh.");
4280 */
4281             You(Hallucination ? "\83n\83\93\83o\81[\83K\81[\82Ì\93õ\82¢\82ª\82µ\82½\81D" : "\8d\95\8fÅ\82°\82Ì\93÷\82Ì\93õ\82¢\82ª\82µ\82½\81D");
4282             break;
4283         case 18:
4284 /*JP
4285             You_feel("tired.");
4286 */
4287             You("\94æ\82ê\82ð\8a´\82\82½\81D");
4288             break;
4289
4290         /* very occasionally something nice happens. */
4291         case 19: { /* tame nearby monsters */
4292             int i, j;
4293             struct monst *mtmp;
4294
4295             (void) adjattrib(A_CHA, 1, FALSE);
4296             for (i = -1; i <= 1; i++)
4297                 for (j = -1; j <= 1; j++) {
4298                     if (!isok(u.ux + i, u.uy + j))
4299                         continue;
4300                     mtmp = m_at(u.ux + i, u.uy + j);
4301                     if (mtmp)
4302                         (void) tamedog(mtmp, (struct obj *) 0);
4303                 }
4304             break;
4305         }
4306         case 20: { /* uncurse stuff */
4307             struct obj pseudo;
4308             long save_conf = HConfusion;
4309
4310             pseudo = zeroobj; /* neither cursed nor blessed,
4311                                  and zero out oextra */
4312             pseudo.otyp = SCR_REMOVE_CURSE;
4313             HConfusion = 0L;
4314             (void) seffects(&pseudo);
4315             HConfusion = save_conf;
4316             break;
4317         }
4318         default:
4319             break;
4320         }
4321 }
4322
4323 /* Set an item on fire.
4324  *   "force" means not to roll a luck-based protection check for the
4325  *     item.
4326  *   "x" and "y" are the coordinates to dump the contents of a
4327  *     container, if it burns up.
4328  *
4329  * Return whether the object was destroyed.
4330  */
4331 boolean
4332 fire_damage(obj, force, x, y)
4333 struct obj *obj;
4334 boolean force;
4335 xchar x, y;
4336 {
4337     int chance;
4338     struct obj *otmp, *ncobj;
4339     int in_sight = !Blind && couldsee(x, y); /* Don't care if it's lit */
4340     int dindx;
4341
4342     /* object might light in a controlled manner */
4343     if (catch_lit(obj))
4344         return FALSE;
4345
4346     if (Is_container(obj)) {
4347         switch (obj->otyp) {
4348         case ICE_BOX:
4349             return FALSE; /* Immune */
4350         case CHEST:
4351             chance = 40;
4352             break;
4353         case LARGE_BOX:
4354             chance = 30;
4355             break;
4356         default:
4357             chance = 20;
4358             break;
4359         }
4360         if ((!force && (Luck + 5) > rn2(chance))
4361             || (is_flammable(obj) && obj->oerodeproof))
4362             return FALSE;
4363         /* Container is burnt up - dump contents out */
4364         if (in_sight)
4365 /*JP
4366             pline("%s catches fire and burns.", Yname2(obj));
4367 */
4368             pline("%s\82Í\89Î\82ª\82Â\82¢\82Ä\94R\82¦\82½\81D", Yname2(obj));
4369         if (Has_contents(obj)) {
4370             if (in_sight)
4371 /*JP
4372                 pline("Its contents fall out.");
4373 */
4374                 pline("\92\86\90g\82ª\8fo\82Ä\82«\82½\81D");
4375             for (otmp = obj->cobj; otmp; otmp = ncobj) {
4376                 ncobj = otmp->nobj;
4377                 obj_extract_self(otmp);
4378                 if (!flooreffects(otmp, x, y, ""))
4379                     place_object(otmp, x, y);
4380             }
4381         }
4382         setnotworn(obj);
4383         delobj(obj);
4384         return TRUE;
4385     } else if (!force && (Luck + 5) > rn2(20)) {
4386         /*  chance per item of sustaining damage:
4387           *     max luck (Luck==13):    10%
4388           *     avg luck (Luck==0):     75%
4389           *     awful luck (Luck<-4):  100%
4390           */
4391         return FALSE;
4392     } else if (obj->oclass == SCROLL_CLASS || obj->oclass == SPBOOK_CLASS) {
4393         if (obj->otyp == SCR_FIRE || obj->otyp == SPE_FIREBALL)
4394             return FALSE;
4395         if (obj->otyp == SPE_BOOK_OF_THE_DEAD) {
4396             if (in_sight)
4397 /*JP
4398                 pline("Smoke rises from %s.", the(xname(obj)));
4399 */
4400                 pline("%s\82©\82ç\89\8c\82ª\82 \82ª\82Á\82½\81D", the(xname(obj)));
4401             return FALSE;
4402         }
4403         dindx = (obj->oclass == SCROLL_CLASS) ? 3 : 4;
4404         if (in_sight)
4405 #if 0 /*JP:T*/
4406             pline("%s %s.", Yname2(obj),
4407                   destroy_strings[dindx][(obj->quan > 1L)]);
4408 #else
4409             pline("%s\82Í%s\81D", Yname2(obj),
4410                   destroy_strings[dindx][(obj->quan > 1L)]);
4411 #endif
4412         setnotworn(obj);
4413         delobj(obj);
4414         return TRUE;
4415     } else if (obj->oclass == POTION_CLASS) {
4416         dindx = (obj->otyp != POT_OIL) ? 1 : 2;
4417         if (in_sight)
4418 #if 0 /*JP:T*/
4419             pline("%s %s.", Yname2(obj),
4420                   destroy_strings[dindx][(obj->quan > 1L)]);
4421 #else
4422             pline("%s\82Í%s\81D", Yname2(obj),
4423                   destroy_strings[dindx][(obj->quan > 1L)]);
4424 #endif
4425         setnotworn(obj);
4426         delobj(obj);
4427         return TRUE;
4428     } else if (erode_obj(obj, (char *) 0, ERODE_BURN, EF_DESTROY)
4429                == ER_DESTROYED) {
4430         return TRUE;
4431     }
4432     return FALSE;
4433 }
4434
4435 /*
4436  * Apply fire_damage() to an entire chain.
4437  *
4438  * Return number of objects destroyed. --ALI
4439  */
4440 int
4441 fire_damage_chain(chain, force, here, x, y)
4442 struct obj *chain;
4443 boolean force, here;
4444 xchar x, y;
4445 {
4446     struct obj *obj, *nobj;
4447     int num = 0;
4448
4449     for (obj = chain; obj; obj = nobj) {
4450         nobj = here ? obj->nexthere : obj->nobj;
4451         if (fire_damage(obj, force, x, y))
4452             ++num;
4453     }
4454
4455     if (num && (Blind && !couldsee(x, y)))
4456 /*JP
4457         You("smell smoke.");
4458 */
4459         You("\89\8c\82Ì\82É\82¨\82¢\82ª\82µ\82½\81D");
4460     return num;
4461 }
4462
4463 /* obj has been thrown or dropped into lava; damage is worse than mere fire */
4464 boolean
4465 lava_damage(obj, x, y)
4466 struct obj *obj;
4467 xchar x, y;
4468 {
4469     int otyp = obj->otyp, ocls = obj->oclass;
4470
4471     /* the Amulet, invocation items, and Rider corpses are never destroyed
4472        (let Book of the Dead fall through to fire_damage() to get feedback) */
4473     if (obj_resists(obj, 0, 0) && otyp != SPE_BOOK_OF_THE_DEAD)
4474         return FALSE;
4475     /* destroy liquid (venom), wax, veggy, flesh, paper (except for scrolls
4476        and books--let fire damage deal with them), cloth, leather, wood, bone
4477        unless it's inherently or explicitly fireproof or contains something;
4478        note: potions are glass so fall through to fire_damage() and boil */
4479     if (objects[otyp].oc_material < DRAGON_HIDE
4480         && ocls != SCROLL_CLASS && ocls != SPBOOK_CLASS
4481         && objects[otyp].oc_oprop != FIRE_RES
4482         && otyp != WAN_FIRE && otyp != FIRE_HORN
4483         /* assumes oerodeproof isn't overloaded for some other purpose on
4484            non-eroding items */
4485         && !obj->oerodeproof
4486         /* fire_damage() knows how to deal with containers and contents */
4487         && !Has_contents(obj)) {
4488         if (cansee(x, y)) {
4489             /* this feedback is pretty clunky and can become very verbose
4490                when former contents of a burned container get here via
4491                flooreffects() */
4492             if (obj == thrownobj || obj == kickedobj)
4493 #if 0 /*JP:T*/
4494                 pline("%s %s up!", is_plural(obj) ? "They" : "It",
4495                       otense(obj, "burn"));
4496 #else
4497                 pline("\82»\82ê\82Í\94R\82¦\82Â\82«\82½\81I");
4498 #endif
4499             else
4500 /*JP
4501                 You_see("%s hit lava and burn up!", doname(obj));
4502 */
4503                 You_see("%s\82Í\97n\8aâ\82É\93\96\82½\82Á\82Ä\94R\82¦\82Â\82«\82½\81I", doname(obj));
4504         }
4505         if (carried(obj)) { /* shouldn't happen */
4506             remove_worn_item(obj, TRUE);
4507             useupall(obj);
4508         } else
4509             delobj(obj);
4510         return TRUE;
4511     }
4512     return fire_damage(obj, TRUE, x, y);
4513 }
4514
4515 void
4516 acid_damage(obj)
4517 struct obj *obj;
4518 {
4519     /* Scrolls but not spellbooks can be erased by acid. */
4520     struct monst *victim;
4521     boolean vismon;
4522
4523     if (!obj)
4524         return;
4525
4526     victim = carried(obj) ? &youmonst : mcarried(obj) ? obj->ocarry : NULL;
4527     vismon = victim && (victim != &youmonst) && canseemon(victim);
4528
4529     if (obj->greased) {
4530         grease_protect(obj, (char *) 0, victim);
4531     } else if (obj->oclass == SCROLL_CLASS && obj->otyp != SCR_BLANK_PAPER) {
4532         if (obj->otyp != SCR_BLANK_PAPER
4533 #ifdef MAIL
4534             && obj->otyp != SCR_MAIL
4535 #endif
4536             ) {
4537             if (!Blind) {
4538                 if (victim == &youmonst)
4539 /*JP
4540                     pline("Your %s.", aobjnam(obj, "fade"));
4541 */
4542                     pline("%s\82Ì\95\8e\9a\82Í\94\96\82ê\82½\81D", xname(obj));
4543                 else if (vismon)
4544 #if 0 /*JP:T*/
4545                     pline("%s %s.", s_suffix(Monnam(victim)),
4546                           aobjnam(obj, "fade"));
4547 #else
4548                     pline("%s\82Ì%s\82Ì\95\8e\9a\82Í\94\96\82ê\82½\81D", Monnam(victim),
4549                           xname(obj));
4550 #endif
4551             }
4552         }
4553         obj->otyp = SCR_BLANK_PAPER;
4554         obj->spe = 0;
4555         obj->dknown = 0;
4556     } else
4557         erode_obj(obj, (char *) 0, ERODE_CORRODE, EF_GREASE | EF_VERBOSE);
4558 }
4559
4560 /* context for water_damage(), managed by water_damage_chain();
4561    when more than one stack of potions of acid explode while processing
4562    a chain of objects, use alternate phrasing after the first message */
4563 static struct h2o_ctx {
4564     int dkn_boom, unk_boom; /* track dknown, !dknown separately */
4565     boolean ctx_valid;
4566 } acid_ctx = { 0, 0, FALSE };
4567
4568 /* Get an object wet and damage it appropriately.
4569  *   "ostr", if present, is used instead of the object name in some
4570  *     messages.
4571  *   "force" means not to roll luck to protect some objects.
4572  * Returns an erosion return value (ER_*)
4573  */
4574 int
4575 water_damage(obj, ostr, force)
4576 struct obj *obj;
4577 const char *ostr;
4578 boolean force;
4579 {
4580     if (!obj)
4581         return ER_NOTHING;
4582
4583     if (snuff_lit(obj))
4584         return ER_DAMAGED;
4585
4586     if (!ostr)
4587         ostr = cxname(obj);
4588
4589     if (obj->otyp == CAN_OF_GREASE && obj->spe > 0) {
4590         return ER_NOTHING;
4591     } else if (obj->otyp == TOWEL && obj->spe < 7) {
4592         wet_a_towel(obj, rnd(7), TRUE);
4593         return ER_NOTHING;
4594     } else if (obj->greased) {
4595         if (!rn2(2))
4596             obj->greased = 0;
4597         if (carried(obj))
4598             update_inventory();
4599         return ER_GREASED;
4600     } else if (Is_container(obj) && !Is_box(obj)
4601                && (obj->otyp != OILSKIN_SACK || (obj->cursed && !rn2(3)))) {
4602         if (carried(obj))
4603 /*JP
4604             pline("Water gets into your %s!", ostr);
4605 */
4606             pline("\90\85\82ª%s\82Ì\92\86\82É\93ü\82Á\82½\81I", ostr);
4607
4608         water_damage_chain(obj->cobj, FALSE);
4609         return ER_DAMAGED; /* contents were damaged */
4610     } else if (obj->otyp == OILSKIN_SACK) {
4611         if (carried(obj))
4612 /*JP
4613             pline("Some water slides right off your %s.", ostr);
4614 */
4615             pline("%s\82Í\90\85\82ð\92e\82¢\82½\81D", ostr);
4616         makeknown(OILSKIN_SACK);
4617         /* not actually damaged, but because we /didn't/ get the "water
4618            gets into!" message, the player now has more information and
4619            thus we need to waste any potion they may have used (also,
4620            flavourwise the water is now on the floor) */
4621         return ER_DAMAGED;
4622     } else if (!force && (Luck + 5) > rn2(20)) {
4623         /*  chance per item of sustaining damage:
4624             *   max luck:               10%
4625             *   avg luck (Luck==0):     75%
4626             *   awful luck (Luck<-4):  100%
4627             */
4628         return ER_NOTHING;
4629     } else if (obj->oclass == SCROLL_CLASS) {
4630         if (obj->otyp == SCR_BLANK_PAPER
4631 #ifdef MAIL
4632             || obj->otyp == SCR_MAIL
4633 #endif
4634            ) return 0;
4635         if (carried(obj))
4636 /*JP
4637             pline("Your %s %s.", ostr, vtense(ostr, "fade"));
4638 */
4639             pline("%s\82Ì\95\8e\9a\82Í\94\96\82ê\82½\81D", ostr);
4640
4641         obj->otyp = SCR_BLANK_PAPER;
4642         obj->dknown = 0;
4643         obj->spe = 0;
4644         if (carried(obj))
4645             update_inventory();
4646         return ER_DAMAGED;
4647     } else if (obj->oclass == SPBOOK_CLASS) {
4648         if (obj->otyp == SPE_BOOK_OF_THE_DEAD) {
4649 /*JP
4650             pline("Steam rises from %s.", the(xname(obj)));
4651 */
4652             pline("\8fö\8bC\82ª%s\82©\82ç\97§\82¿\82Ì\82Ú\82Á\82½\81D", xname(obj));
4653             return 0;
4654         } else if (obj->otyp == SPE_BLANK_PAPER) {
4655             return 0;
4656         }
4657         if (carried(obj))
4658 /*JP
4659             pline("Your %s %s.", ostr, vtense(ostr, "fade"));
4660 */
4661             pline("%s\82Ì\95\8e\9a\82Í\94\96\82ê\82½\81D", ostr);
4662
4663         if (obj->otyp == SPE_NOVEL) {
4664             obj->novelidx = 0;
4665             free_oname(obj);
4666         }
4667
4668         obj->otyp = SPE_BLANK_PAPER;
4669         obj->dknown = 0;
4670         if (carried(obj))
4671             update_inventory();
4672         return ER_DAMAGED;
4673     } else if (obj->oclass == POTION_CLASS) {
4674         if (obj->otyp == POT_ACID) {
4675             char *bufp;
4676 #if 0 /*JP*/
4677             boolean one = (obj->quan == 1L), update = carried(obj),
4678                     exploded = FALSE;
4679 #else
4680             boolean update = carried(obj);
4681 #endif
4682
4683             if (Blind && !carried(obj))
4684                 obj->dknown = 0;
4685 #if 0 /*JP*/
4686             if (acid_ctx.ctx_valid)
4687                 exploded = ((obj->dknown ? acid_ctx.dkn_boom
4688                                          : acid_ctx.unk_boom) > 0);
4689 #endif
4690             /* First message is
4691              * "a [potion|<color> potion|potion of acid] explodes"
4692              * depending on obj->dknown (potion has been seen) and
4693              * objects[POT_ACID].oc_name_known (fully discovered),
4694              * or "some {plural version} explode" when relevant.
4695              * Second and subsequent messages for same chain and
4696              * matching dknown status are
4697              * "another [potion|<color> &c] explodes" or plural
4698              * variant.
4699              */
4700             bufp = simpleonames(obj);
4701 #if 0 /*JP:T*/
4702             pline("%s %s %s!", /* "A potion explodes!" */
4703                   !exploded ? (one ? "A" : "Some")
4704                             : (one ? "Another" : "More"),
4705                   bufp, vtense(bufp, "explode"));
4706 #else
4707             pline("%s\82Í\94\9a\94­\82µ\82½\81I", bufp);
4708 #endif
4709             if (acid_ctx.ctx_valid) {
4710                 if (obj->dknown)
4711                     acid_ctx.dkn_boom++;
4712                 else
4713                     acid_ctx.unk_boom++;
4714             }
4715             setnotworn(obj);
4716             delobj(obj);
4717             if (update)
4718                 update_inventory();
4719             return ER_DESTROYED;
4720         } else if (obj->odiluted) {
4721             if (carried(obj))
4722 /*JP
4723                 pline("Your %s %s further.", ostr, vtense(ostr, "dilute"));
4724 */
4725                 pline("%s\82Í\82³\82ç\82É\94\96\82Ü\82Á\82½\81D", ostr);
4726
4727             obj->otyp = POT_WATER;
4728             obj->dknown = 0;
4729             obj->blessed = obj->cursed = 0;
4730             obj->odiluted = 0;
4731             if (carried(obj))
4732                 update_inventory();
4733             return ER_DAMAGED;
4734         } else if (obj->otyp != POT_WATER) {
4735             if (carried(obj))
4736 /*JP
4737                 pline("Your %s %s.", ostr, vtense(ostr, "dilute"));
4738 */
4739                 pline("%s\82Í\94\96\82Ü\82Á\82½\81D", ostr);
4740
4741             obj->odiluted++;
4742             if (carried(obj))
4743                 update_inventory();
4744             return ER_DAMAGED;
4745         }
4746     } else {
4747         return erode_obj(obj, ostr, ERODE_RUST, EF_NONE);
4748     }
4749     return ER_NOTHING;
4750 }
4751
4752 void
4753 water_damage_chain(obj, here)
4754 struct obj *obj;
4755 boolean here;
4756 {
4757     struct obj *otmp;
4758
4759     /* initialize acid context: so far, neither seen (dknown) potions of
4760        acid nor unseen have exploded during this water damage sequence */
4761     acid_ctx.dkn_boom = acid_ctx.unk_boom = 0;
4762     acid_ctx.ctx_valid = TRUE;
4763
4764     for (; obj; obj = otmp) {
4765         otmp = here ? obj->nexthere : obj->nobj;
4766         water_damage(obj, (char *) 0, FALSE);
4767     }
4768
4769     /* reset acid context */
4770     acid_ctx.dkn_boom = acid_ctx.unk_boom = 0;
4771     acid_ctx.ctx_valid = FALSE;
4772 }
4773
4774 /*
4775  * This function is potentially expensive - rolling
4776  * inventory list multiple times.  Luckily it's seldom needed.
4777  * Returns TRUE if disrobing made player unencumbered enough to
4778  * crawl out of the current predicament.
4779  */
4780 STATIC_OVL boolean
4781 emergency_disrobe(lostsome)
4782 boolean *lostsome;
4783 {
4784     int invc = inv_cnt(TRUE);
4785
4786     while (near_capacity() > (Punished ? UNENCUMBERED : SLT_ENCUMBER)) {
4787         register struct obj *obj, *otmp = (struct obj *) 0;
4788         register int i;
4789
4790         /* Pick a random object */
4791         if (invc > 0) {
4792             i = rn2(invc);
4793             for (obj = invent; obj; obj = obj->nobj) {
4794                 /*
4795                  * Undroppables are: body armor, boots, gloves,
4796                  * amulets, and rings because of the time and effort
4797                  * in removing them + loadstone and other cursed stuff
4798                  * for obvious reasons.
4799                  */
4800                 if (!((obj->otyp == LOADSTONE && obj->cursed) || obj == uamul
4801                       || obj == uleft || obj == uright || obj == ublindf
4802                       || obj == uarm || obj == uarmc || obj == uarmg
4803                       || obj == uarmf || obj == uarmu
4804                       || (obj->cursed && (obj == uarmh || obj == uarms))
4805                       || welded(obj)))
4806                     otmp = obj;
4807                 /* reached the mark and found some stuff to drop? */
4808                 if (--i < 0 && otmp)
4809                     break;
4810
4811                 /* else continue */
4812             }
4813         }
4814         if (!otmp)
4815             return FALSE; /* nothing to drop! */
4816         if (otmp->owornmask)
4817             remove_worn_item(otmp, FALSE);
4818         *lostsome = TRUE;
4819         dropx(otmp);
4820         invc--;
4821     }
4822     return TRUE;
4823 }
4824
4825
4826 /*  return TRUE iff player relocated */
4827 boolean
4828 drown()
4829 {
4830     const char *pool_of_water;
4831     boolean inpool_ok = FALSE, crawl_ok;
4832     int i, x, y;
4833
4834     feel_newsym(u.ux, u.uy); /* in case Blind, map the water here */
4835     /* happily wading in the same contiguous pool */
4836     if (u.uinwater && is_pool(u.ux - u.dx, u.uy - u.dy)
4837         && (Swimming || Amphibious)) {
4838         /* water effects on objects every now and then */
4839         if (!rn2(5))
4840             inpool_ok = TRUE;
4841         else
4842             return FALSE;
4843     }
4844
4845     if (!u.uinwater) {
4846 #if 0 /*JP:T*/
4847         You("%s into the %s%c", Is_waterlevel(&u.uz) ? "plunge" : "fall",
4848             hliquid("water"),
4849             Amphibious || Swimming ? '.' : '!');
4850 #else
4851         You("%s\82Ì\92\86\82É%s%s", hliquid("\90\85"),
4852             Is_waterlevel(&u.uz) ? "\94ò\82Ñ\82±\82ñ\82¾" : "\97\8e\82¿\82½",
4853             Amphibious || Swimming ? "\81D" : "\81I");
4854 #endif
4855         if (!Swimming && !Is_waterlevel(&u.uz))
4856 /*JP
4857             You("sink like %s.", Hallucination ? "the Titanic" : "a rock");
4858 */
4859             You("%s\82Ì\82æ\82¤\82É\92¾\82ñ\82¾\81D", Hallucination ? "\83^\83C\83^\83j\83b\83N\8d\86" : "\8aâ");
4860     }
4861
4862     water_damage_chain(invent, FALSE);
4863
4864     if (u.umonnum == PM_GREMLIN && rn2(3))
4865         (void) split_mon(&youmonst, (struct monst *) 0);
4866     else if (u.umonnum == PM_IRON_GOLEM) {
4867 /*JP
4868         You("rust!");
4869 */
4870         You("\8eK\82Ñ\82½\81I");
4871         i = Maybe_Half_Phys(d(2, 6));
4872         if (u.mhmax > i)
4873             u.mhmax -= i;
4874 /*JP
4875         losehp(i, "rusting away", KILLED_BY);
4876 */
4877         losehp(i, "\8a®\91S\82É\8eK\82Ñ\82Ä", KILLED_BY);
4878     }
4879     if (inpool_ok)
4880         return FALSE;
4881
4882     if ((i = number_leashed()) > 0) {
4883 #if 0 /*JP:T*/
4884         pline_The("leash%s slip%s loose.", (i > 1) ? "es" : "",
4885                   (i > 1) ? "" : "s");
4886 #else
4887         pline("\95R\82ª\82ä\82é\82ñ\82¾\81D");
4888 #endif
4889         unleash_all();
4890     }
4891
4892     if (Amphibious || Swimming) {
4893         if (Amphibious) {
4894             if (flags.verbose)
4895 /*JP
4896                 pline("But you aren't drowning.");
4897 */
4898                 pline("\82µ\82©\82µ\81C\82 \82È\82½\82Í\93M\82ê\82È\82©\82Á\82½\81D");
4899             if (!Is_waterlevel(&u.uz)) {
4900                 if (Hallucination)
4901 /*JP
4902                     Your("keel hits the bottom.");
4903 */
4904                     You("\92ê\82É\83j\81[\83h\83\8d\83b\83v\82ð\8c\88\82ß\82½\81D");
4905                 else
4906 /*JP
4907                     You("touch bottom.");
4908 */
4909                     You("\92ê\82É\82Â\82¢\82½\81D");
4910             }
4911         }
4912         if (Punished) {
4913             unplacebc();
4914             placebc();
4915         }
4916         vision_recalc(2); /* unsee old position */
4917         u.uinwater = 1;
4918         under_water(1);
4919         vision_full_recalc = 1;
4920         return FALSE;
4921     }
4922     if ((Teleportation || can_teleport(youmonst.data)) && !Unaware
4923         && (Teleport_control || rn2(3) < Luck + 2)) {
4924 #if 0 /*JP:T*/
4925         You("attempt a teleport spell."); /* utcsri!carroll */
4926 #else
4927         You("\8fu\8aÔ\88Ú\93®\82Ì\8eô\95\82ð\8f¥\82¦\82Ä\82Ý\82½\81D");
4928 #endif
4929         if (!level.flags.noteleport) {
4930             (void) dotele(FALSE);
4931             if (!is_pool(u.ux, u.uy))
4932                 return TRUE;
4933         } else
4934 /*JP
4935             pline_The("attempted teleport spell fails.");
4936 */
4937             pline("\8fu\8aÔ\88Ú\93®\82Ì\8eô\95\82Í\8e¸\94s\82µ\82½\81D");
4938     }
4939     if (u.usteed) {
4940         dismount_steed(DISMOUNT_GENERIC);
4941         if (!is_pool(u.ux, u.uy))
4942             return TRUE;
4943     }
4944     crawl_ok = FALSE;
4945     x = y = 0; /* lint suppression */
4946     /* if sleeping, wake up now so that we don't crawl out of water
4947        while still asleep; we can't do that the same way that waking
4948        due to combat is handled; note unmul() clears u.usleep */
4949     if (u.usleep)
4950 /*JP
4951         unmul("Suddenly you wake up!");
4952 */
4953         unmul("\93Ë\91R\82 \82È\82½\82Í\96Ú\82ª\8ao\82ß\82½\81I");
4954     /* being doused will revive from fainting */
4955     if (is_fainted())
4956         reset_faint();
4957     /* can't crawl if unable to move (crawl_ok flag stays false) */
4958     if (multi < 0 || (Upolyd && !youmonst.data->mmove))
4959         goto crawl;
4960     /* look around for a place to crawl to */
4961     for (i = 0; i < 100; i++) {
4962         x = rn1(3, u.ux - 1);
4963         y = rn1(3, u.uy - 1);
4964         if (crawl_destination(x, y)) {
4965             crawl_ok = TRUE;
4966             goto crawl;
4967         }
4968     }
4969     /* one more scan */
4970     for (x = u.ux - 1; x <= u.ux + 1; x++)
4971         for (y = u.uy - 1; y <= u.uy + 1; y++)
4972             if (crawl_destination(x, y)) {
4973                 crawl_ok = TRUE;
4974                 goto crawl;
4975             }
4976 crawl:
4977     if (crawl_ok) {
4978         boolean lost = FALSE;
4979         /* time to do some strip-tease... */
4980         boolean succ = Is_waterlevel(&u.uz) ? TRUE : emergency_disrobe(&lost);
4981
4982 /*JP
4983         You("try to crawl out of the %s.", hliquid("water"));
4984 */
4985         You("%s\82©\82ç\82Í\82¢\82 \82ª\82ë\82¤\82Æ\82µ\82½\81D", hliquid("\90\85"));
4986         if (lost)
4987 /*JP
4988             You("dump some of your gear to lose weight...");
4989 */
4990             You("\91Ì\82ð\8cy\82­\82·\82é\82½\82ß\82¢\82­\82Â\82©\95¨\82ð\93\8a\82°\82·\82Ä\82½\81D\81D\81D");
4991         if (succ) {
4992 /*JP
4993             pline("Pheew!  That was close.");
4994 */
4995             pline("\83n\83@\83n\83@\81I\82 \82Ô\82È\82©\82Á\82½\81D");
4996             teleds(x, y, TRUE);
4997             return TRUE;
4998         }
4999         /* still too much weight */
5000 /*JP
5001         pline("But in vain.");
5002 */
5003         pline("\82ª\81C\96³\91Ê\82¾\82Á\82½\81D");
5004     }
5005     u.uinwater = 1;
5006 /*JP
5007     You("drown.");
5008 */
5009     You("\93M\82ê\82½\81D");
5010     for (i = 0; i < 5; i++) { /* arbitrary number of loops */
5011         /* killer format and name are reconstructed every iteration
5012            because lifesaving resets them */
5013         pool_of_water = waterbody_name(u.ux, u.uy);
5014         killer.format = KILLED_BY_AN;
5015 #if 0 /*JP*/
5016         /* avoid "drowned in [a] water" */
5017         if (!strcmp(pool_of_water, "water"))
5018             pool_of_water = "deep water", killer.format = KILLED_BY;
5019 #endif
5020         Strcpy(killer.name, pool_of_water);
5021         done(DROWNING);
5022         /* oops, we're still alive.  better get out of the water. */
5023         if (safe_teleds(TRUE))
5024             break; /* successful life-save */
5025         /* nowhere safe to land; repeat drowning loop... */
5026 /*JP
5027         pline("You're still drowning.");
5028 */
5029         You("\82Ü\82¾\93M\82ê\82Ä\82¢\82é\81D");
5030     }
5031     if (u.uinwater) {
5032         u.uinwater = 0;
5033 #if 0 /*JP:T*/
5034         You("find yourself back %s.",
5035             Is_waterlevel(&u.uz) ? "in an air bubble" : "on land");
5036 #else
5037         You("\82¢\82Â\82Ì\82Ü\82É\82©%s\82É\82¢\82é\82Ì\82É\8bC\82ª\82Â\82¢\82½\81D",
5038             Is_waterlevel(&u.uz) ? "\8bó\8bC\82Ì\96A\82Ì\92\86" : "\92n\96Ê");
5039 #endif
5040     }
5041     return TRUE;
5042 }
5043
5044 void
5045 drain_en(n)
5046 int n;
5047 {
5048     if (!u.uenmax) {
5049         /* energy is completely gone */
5050 /*JP
5051         You_feel("momentarily lethargic.");
5052 */
5053         You("\88ê\8fu\96³\8bC\97Í\8a´\82ð\8a´\82\82½\81D");
5054     } else {
5055         /* throttle further loss a bit when there's not much left to lose */
5056         if (n > u.uenmax || n > u.ulevel)
5057             n = rnd(n);
5058
5059 /*JP
5060         You_feel("your magical energy drain away%c", (n > u.uen) ? '!' : '.');
5061 */
5062         You("\96\82\96@\82Ì\83G\83l\83\8b\83M\81[\82ª\8bz\82¢\82Æ\82ç\82ê\82½\82æ\82¤\82È\8bC\82ª\82µ\82½%s", (n > u.uen) ? "\81I" : "\81D");
5063         u.uen -= n;
5064         if (u.uen < 0) {
5065             u.uenmax -= rnd(-u.uen);
5066             if (u.uenmax < 0)
5067                 u.uenmax = 0;
5068             u.uen = 0;
5069         }
5070         context.botl = 1;
5071     }
5072 }
5073
5074 /* disarm a trap */
5075 int
5076 dountrap()
5077 {
5078     if (near_capacity() >= HVY_ENCUMBER) {
5079 /*JP
5080         pline("You're too strained to do that.");
5081 */
5082         pline("ã©\82ð\89ð\8f\9c\82µ\82æ\82¤\82É\82à\95¨\82ð\8e\9d\82¿\82·\82¬\82Ä\82¢\82é\81D");
5083         return 0;
5084     }
5085     if ((nohands(youmonst.data) && !webmaker(youmonst.data))
5086         || !youmonst.data->mmove) {
5087 /*JP
5088         pline("And just how do you expect to do that?");
5089 */
5090         pline("\82¢\82Á\82½\82¢\89½\82ð\8aú\91Ò\82µ\82Ä\82¢\82é\82ñ\82¾\82¢\81H");
5091         return 0;
5092     } else if (u.ustuck && sticks(youmonst.data)) {
5093 /*JP
5094         pline("You'll have to let go of %s first.", mon_nam(u.ustuck));
5095 */
5096         pline("%s\82ð\8eè\97£\82³\82È\82¢\82±\82Æ\82É\82Í\82Å\82«\82È\82¢\81D", mon_nam(u.ustuck));
5097         return 0;
5098     }
5099     if (u.ustuck || (welded(uwep) && bimanual(uwep))) {
5100 /*JP
5101         Your("%s seem to be too busy for that.", makeplural(body_part(HAND)));
5102 */
5103         Your("\82»\82ñ\82È\82±\82Æ\82ð\82·\82é\97]\97T\82È\82ñ\82Ä\82È\82¢\81D");
5104         return 0;
5105     }
5106     return untrap(FALSE);
5107 }
5108
5109 /* Probability of disabling a trap.  Helge Hafting */
5110 STATIC_OVL int
5111 untrap_prob(ttmp)
5112 struct trap *ttmp;
5113 {
5114     int chance = 3;
5115
5116     /* Only spiders know how to deal with webs reliably */
5117     if (ttmp->ttyp == WEB && !webmaker(youmonst.data))
5118         chance = 30;
5119     if (Confusion || Hallucination)
5120         chance++;
5121     if (Blind)
5122         chance++;
5123     if (Stunned)
5124         chance += 2;
5125     if (Fumbling)
5126         chance *= 2;
5127     /* Your own traps are better known than others. */
5128     if (ttmp && ttmp->madeby_u)
5129         chance--;
5130     if (Role_if(PM_ROGUE)) {
5131         if (rn2(2 * MAXULEV) < u.ulevel)
5132             chance--;
5133         if (u.uhave.questart && chance > 1)
5134             chance--;
5135     } else if (Role_if(PM_RANGER) && chance > 1)
5136         chance--;
5137     return rn2(chance);
5138 }
5139
5140 /* Replace trap with object(s).  Helge Hafting */
5141 void
5142 cnv_trap_obj(otyp, cnt, ttmp, bury_it)
5143 int otyp;
5144 int cnt;
5145 struct trap *ttmp;
5146 boolean bury_it;
5147 {
5148     struct obj *otmp = mksobj(otyp, TRUE, FALSE);
5149
5150     otmp->quan = cnt;
5151     otmp->owt = weight(otmp);
5152     /* Only dart traps are capable of being poisonous */
5153     if (otyp != DART)
5154         otmp->opoisoned = 0;
5155     place_object(otmp, ttmp->tx, ttmp->ty);
5156     if (bury_it) {
5157         /* magical digging first disarms this trap, then will unearth it */
5158         (void) bury_an_obj(otmp, (boolean *) 0);
5159     } else {
5160         /* Sell your own traps only... */
5161         if (ttmp->madeby_u)
5162             sellobj(otmp, ttmp->tx, ttmp->ty);
5163         stackobj(otmp);
5164     }
5165     newsym(ttmp->tx, ttmp->ty);
5166     if (u.utrap && ttmp->tx == u.ux && ttmp->ty == u.uy)
5167         reset_utrap(TRUE);
5168     deltrap(ttmp);
5169 }
5170
5171 /* while attempting to disarm an adjacent trap, we've fallen into it */
5172 STATIC_OVL void
5173 move_into_trap(ttmp)
5174 struct trap *ttmp;
5175 {
5176     int bc = 0;
5177     xchar x = ttmp->tx, y = ttmp->ty, bx, by, cx, cy;
5178     boolean unused;
5179
5180     bx = by = cx = cy = 0; /* lint suppression */
5181     /* we know there's no monster in the way, and we're not trapped */
5182     if (!Punished
5183         || drag_ball(x, y, &bc, &bx, &by, &cx, &cy, &unused, TRUE)) {
5184         u.ux0 = u.ux, u.uy0 = u.uy;
5185         u.ux = x, u.uy = y;
5186         u.umoved = TRUE;
5187         newsym(u.ux0, u.uy0);
5188         vision_recalc(1);
5189         check_leash(u.ux0, u.uy0);
5190         if (Punished)
5191             move_bc(0, bc, bx, by, cx, cy);
5192         /* marking the trap unseen forces dotrap() to treat it like a new
5193            discovery and prevents pickup() -> look_here() -> check_here()
5194            from giving a redundant "there is a <trap> here" message when
5195            there are objects covering this trap */
5196         ttmp->tseen = 0; /* hack for check_here() */
5197         /* trigger the trap */
5198         iflags.failing_untrap++; /* spoteffects() -> dotrap(,FAILEDUNTRAP) */
5199         spoteffects(TRUE); /* pickup() + dotrap() */
5200         iflags.failing_untrap--;
5201         /* this should no longer be necessary; before the failing_untrap
5202            hack, Flying hero would not trigger an unseen bear trap and
5203            setting it not-yet-seen above resulted in leaving it hidden */
5204         if ((ttmp = t_at(u.ux, u.uy)) != 0)
5205             ttmp->tseen = 1;
5206         exercise(A_WIS, FALSE);
5207     }
5208 }
5209
5210 /* 0: doesn't even try
5211  * 1: tries and fails
5212  * 2: succeeds
5213  */
5214 STATIC_OVL int
5215 try_disarm(ttmp, force_failure)
5216 struct trap *ttmp;
5217 boolean force_failure;
5218 {
5219     struct monst *mtmp = m_at(ttmp->tx, ttmp->ty);
5220     int ttype = ttmp->ttyp;
5221     boolean under_u = (!u.dx && !u.dy);
5222     boolean holdingtrap = (ttype == BEAR_TRAP || ttype == WEB);
5223
5224     /* Test for monster first, monsters are displayed instead of trap. */
5225     if (mtmp && (!mtmp->mtrapped || !holdingtrap)) {
5226 /*JP
5227         pline("%s is in the way.", Monnam(mtmp));
5228 */
5229         pline("\82»\82±\82É\82Í%s\82ª\82¢\82é\81D", Monnam(mtmp));
5230         return 0;
5231     }
5232     /* We might be forced to move onto the trap's location. */
5233     if (sobj_at(BOULDER, ttmp->tx, ttmp->ty) && !Passes_walls && !under_u) {
5234 /*JP
5235         There("is a boulder in your way.");
5236 */
5237         pline("\82»\82±\82É\82Í\8aâ\82ª\82 \82é\81D");
5238         return 0;
5239     }
5240     /* duplicate tight-space checks from test_move */
5241     if (u.dx && u.dy && bad_rock(youmonst.data, u.ux, ttmp->ty)
5242         && bad_rock(youmonst.data, ttmp->tx, u.uy)) {
5243         if ((invent && (inv_weight() + weight_cap() > 600))
5244             || bigmonst(youmonst.data)) {
5245             /* don't allow untrap if they can't get thru to it */
5246 #if 0 /*JP:T*/
5247             You("are unable to reach the %s!",
5248                 defsyms[trap_to_defsym(ttype)].explanation);
5249 #else
5250             You("%s\82É\93Í\82©\82È\82¢\81I",
5251                 defsyms[trap_to_defsym(ttype)].explanation);
5252 #endif
5253             return 0;
5254         }
5255     }
5256     /* untrappable traps are located on the ground. */
5257     if (!can_reach_floor(under_u)) {
5258         if (u.usteed && P_SKILL(P_RIDING) < P_BASIC)
5259             rider_cant_reach();
5260         else
5261 #if 0 /*JP:T*/
5262             You("are unable to reach the %s!",
5263                 defsyms[trap_to_defsym(ttype)].explanation);
5264 #else
5265             You("%s\82É\93Í\82©\82È\82¢\81I",
5266                 defsyms[trap_to_defsym(ttype)].explanation);
5267 #endif
5268         return 0;
5269     }
5270
5271     /* Will our hero succeed? */
5272     if (force_failure || untrap_prob(ttmp)) {
5273         if (rnl(5)) {
5274 /*JP
5275             pline("Whoops...");
5276 */
5277             pline("\82¤\82í\82Á\81D\81D\81D");
5278             if (mtmp) { /* must be a trap that holds monsters */
5279                 if (ttype == BEAR_TRAP) {
5280                     if (mtmp->mtame)
5281                         abuse_dog(mtmp);
5282                     mtmp->mhp -= rnd(4);
5283                     if (DEADMONSTER(mtmp))
5284                         killed(mtmp);
5285                 } else if (ttype == WEB) {
5286                     if (!webmaker(youmonst.data)) {
5287                         struct trap *ttmp2 = maketrap(u.ux, u.uy, WEB);
5288
5289                         if (ttmp2) {
5290                             pline_The(
5291 /*JP
5292                                 "webbing sticks to you.  You're caught too!");
5293 */
5294                                 "\82­\82à\82Ì\91\83\82ª\82 \82È\82½\82É\82©\82ç\82ñ\82Å\82«\82½\81D\82Ü\82·\82Ü\82·\95ß\82Ü\82Á\82Ä\82µ\82Ü\82Á\82½\81I");
5295                             dotrap(ttmp2, NOWEBMSG);
5296                             if (u.usteed && u.utrap) {
5297                                 /* you, not steed, are trapped */
5298                                 dismount_steed(DISMOUNT_FELL);
5299                             }
5300                         }
5301                     } else
5302 /*JP
5303                         pline("%s remains entangled.", Monnam(mtmp));
5304 */
5305                         pline("%s\82Í\82©\82ç\82Ü\82Á\82½\82Ü\82Ü\82¾\81D", Monnam(mtmp));
5306                 }
5307             } else if (under_u) {
5308                 /* [don't need the iflags.failing_untrap hack here] */
5309                 dotrap(ttmp, FAILEDUNTRAP);
5310             } else {
5311                 move_into_trap(ttmp);
5312             }
5313         } else {
5314 #if 0 /*JP:T*/
5315             pline("%s %s is difficult to %s.",
5316                   ttmp->madeby_u ? "Your" : under_u ? "This" : "That",
5317                   defsyms[trap_to_defsym(ttype)].explanation,
5318                   (ttype == WEB) ? "remove" : "disarm");
5319 #else
5320             pline("%s%s\82ð\89ð\8f\9c\82·\82é\82Ì\82Í\8d¢\93ï\82¾\81D",
5321                   ttmp->madeby_u ? "\82 \82È\82½\82Ì\8ed\8a|\82¯\82½" : under_u ? "\82±\82Ì" : "\82»\82Ì",
5322                   defsyms[trap_to_defsym(ttype)].explanation);
5323 #endif
5324         }
5325         return 1;
5326     }
5327     return 2;
5328 }
5329
5330 STATIC_OVL void
5331 reward_untrap(ttmp, mtmp)
5332 struct trap *ttmp;
5333 struct monst *mtmp;
5334 {
5335     if (!ttmp->madeby_u) {
5336         if (rnl(10) < 8 && !mtmp->mpeaceful && !mtmp->msleeping
5337             && !mtmp->mfrozen && !mindless(mtmp->data)
5338             && mtmp->data->mlet != S_HUMAN) {
5339             mtmp->mpeaceful = 1;
5340             set_malign(mtmp); /* reset alignment */
5341 /*JP
5342             pline("%s is grateful.", Monnam(mtmp));
5343 */
5344             pline("%s\82Í\8aì\82ñ\82Å\82¢\82é\81D", Monnam(mtmp));
5345         }
5346         /* Helping someone out of a trap is a nice thing to do,
5347          * A lawful may be rewarded, but not too often.  */
5348         if (!rn2(3) && !rnl(8) && u.ualign.type == A_LAWFUL) {
5349             adjalign(1);
5350 /*JP
5351             You_feel("that you did the right thing.");
5352 */
5353             You("\90³\82µ\82¢\82±\82Æ\82ð\82µ\82½\82æ\82¤\82È\8bC\82ª\82µ\82½\81D");
5354         }
5355     }
5356 }
5357
5358 STATIC_OVL int
5359 disarm_holdingtrap(ttmp) /* Helge Hafting */
5360 struct trap *ttmp;
5361 {
5362     struct monst *mtmp;
5363     int fails = try_disarm(ttmp, FALSE);
5364
5365     if (fails < 2)
5366         return fails;
5367
5368     /* ok, disarm it. */
5369
5370     /* untrap the monster, if any.
5371        There's no need for a cockatrice test, only the trap is touched */
5372     if ((mtmp = m_at(ttmp->tx, ttmp->ty)) != 0) {
5373         mtmp->mtrapped = 0;
5374 #if 0 /*JP:T*/
5375         You("remove %s %s from %s.", the_your[ttmp->madeby_u],
5376             (ttmp->ttyp == BEAR_TRAP) ? "bear trap" : "webbing",
5377             mon_nam(mtmp));
5378 #else
5379         You("%s%s\82ð%s\82©\82ç\82Í\82¸\82µ\82½\81D", set_you[ttmp->madeby_u],
5380             (ttmp->ttyp == BEAR_TRAP) ? "\8cF\82Ìã©" : "\82­\82à\82Ì\91\83",
5381             mon_nam(mtmp));
5382 #endif
5383         reward_untrap(ttmp, mtmp);
5384     } else {
5385         if (ttmp->ttyp == BEAR_TRAP) {
5386 /*JP
5387             You("disarm %s bear trap.", the_your[ttmp->madeby_u]);
5388 */
5389             You("%s\8cF\82Ìã©\82ð\89ð\8f\9c\82µ\82½\81D", set_you[ttmp->madeby_u]);
5390             cnv_trap_obj(BEARTRAP, 1, ttmp, FALSE);
5391         } else /* if (ttmp->ttyp == WEB) */ {
5392 /*JP
5393             You("succeed in removing %s web.", the_your[ttmp->madeby_u]);
5394 */
5395             You("%s\82­\82à\82Ì\91\83\82ð\8eæ\82è\8f\9c\82¢\82½\81D", set_you[ttmp->madeby_u]);
5396             deltrap(ttmp);
5397         }
5398     }
5399     newsym(u.ux + u.dx, u.uy + u.dy);
5400     return 1;
5401 }
5402
5403 STATIC_OVL int
5404 disarm_landmine(ttmp) /* Helge Hafting */
5405 struct trap *ttmp;
5406 {
5407     int fails = try_disarm(ttmp, FALSE);
5408
5409     if (fails < 2)
5410         return fails;
5411 /*JP
5412     You("disarm %s land mine.", the_your[ttmp->madeby_u]);
5413 */
5414     You("%s\92n\97\8b\82ð\89ð\8f\9c\82µ\82½\81D", set_you[ttmp->madeby_u]);
5415     cnv_trap_obj(LAND_MINE, 1, ttmp, FALSE);
5416     return 1;
5417 }
5418
5419 /* getobj will filter down to cans of grease and known potions of oil */
5420 static NEARDATA const char oil[] = { ALL_CLASSES, TOOL_CLASS, POTION_CLASS,
5421                                      0 };
5422
5423 /* it may not make much sense to use grease on floor boards, but so what? */
5424 STATIC_OVL int
5425 disarm_squeaky_board(ttmp)
5426 struct trap *ttmp;
5427 {
5428     struct obj *obj;
5429     boolean bad_tool;
5430     int fails;
5431
5432     obj = getobj(oil, "untrap with");
5433     if (!obj)
5434         return 0;
5435
5436     bad_tool = (obj->cursed
5437                 || ((obj->otyp != POT_OIL || obj->lamplit)
5438                     && (obj->otyp != CAN_OF_GREASE || !obj->spe)));
5439     fails = try_disarm(ttmp, bad_tool);
5440     if (fails < 2)
5441         return fails;
5442
5443     /* successfully used oil or grease to fix squeaky board */
5444     if (obj->otyp == CAN_OF_GREASE) {
5445         consume_obj_charge(obj, TRUE);
5446     } else {
5447         useup(obj); /* oil */
5448         makeknown(POT_OIL);
5449     }
5450 #if 0 /*JP:T*/
5451     You("repair the squeaky board."); /* no madeby_u */
5452 #else
5453     You("\82«\82µ\82Þ\94Â\82ð\8fC\97\9d\82µ\82½\81D"); /* no madeby_u */
5454 #endif
5455     deltrap(ttmp);
5456     newsym(u.ux + u.dx, u.uy + u.dy);
5457     more_experienced(1, 5);
5458     newexplevel();
5459     return 1;
5460 }
5461
5462 /* removes traps that shoot arrows, darts, etc. */
5463 STATIC_OVL int
5464 disarm_shooting_trap(ttmp, otyp)
5465 struct trap *ttmp;
5466 int otyp;
5467 {
5468     int fails = try_disarm(ttmp, FALSE);
5469
5470     if (fails < 2)
5471         return fails;
5472 /*JP
5473     You("disarm %s trap.", the_your[ttmp->madeby_u]);
5474 */
5475     pline("%sã©\82ð\89ð\8f\9c\82µ\82½\81D", set_you[ttmp->madeby_u]);
5476     cnv_trap_obj(otyp, 50 - rnl(50), ttmp, FALSE);
5477     return 1;
5478 }
5479
5480 /* Is the weight too heavy?
5481  * Formula as in near_capacity() & check_capacity() */
5482 STATIC_OVL int
5483 try_lift(mtmp, ttmp, wt, stuff)
5484 struct monst *mtmp;
5485 struct trap *ttmp;
5486 int wt;
5487 boolean stuff;
5488 {
5489     int wc = weight_cap();
5490
5491     if (((wt * 2) / wc) >= HVY_ENCUMBER) {
5492 #if 0 /*JP:T*/
5493         pline("%s is %s for you to lift.", Monnam(mtmp),
5494               stuff ? "carrying too much" : "too heavy");
5495 #else
5496         pline("%s\82Í%s\8e\9d\82¿\82 \82°\82é\82±\82Æ\82ª\82Å\82«\82È\82¢\81D", Monnam(mtmp),
5497               stuff ? "\95¨\82ð\8e\9d\82¿\82·\82¬\82Ä\82¨\82è" : "\8fd\82·\82¬\82Ä");
5498 #endif
5499         if (!ttmp->madeby_u && !mtmp->mpeaceful && mtmp->mcanmove
5500             && !mindless(mtmp->data) && mtmp->data->mlet != S_HUMAN
5501             && rnl(10) < 3) {
5502             mtmp->mpeaceful = 1;
5503             set_malign(mtmp); /* reset alignment */
5504 /*JP
5505             pline("%s thinks it was nice of you to try.", Monnam(mtmp));
5506 */
5507             pline("%s\82Í\82 \82È\82½\82Ì\93w\97Í\82É\8a´\8eÓ\82µ\82Ä\82¢\82é\82æ\82¤\82¾\81D", Monnam(mtmp));
5508         }
5509         return 0;
5510     }
5511     return 1;
5512 }
5513
5514 /* Help trapped monster (out of a (spiked) pit) */
5515 STATIC_OVL int
5516 help_monster_out(mtmp, ttmp)
5517 struct monst *mtmp;
5518 struct trap *ttmp;
5519 {
5520     int wt;
5521     struct obj *otmp;
5522     boolean uprob;
5523
5524     /*
5525      * This works when levitating too -- consistent with the ability
5526      * to hit monsters while levitating.
5527      *
5528      * Should perhaps check that our hero has arms/hands at the
5529      * moment.  Helping can also be done by engulfing...
5530      *
5531      * Test the monster first - monsters are displayed before traps.
5532      */
5533     if (!mtmp->mtrapped) {
5534 /*JP
5535         pline("%s isn't trapped.", Monnam(mtmp));
5536 */
5537         pline("%s\82Íã©\82É\82©\82©\82Á\82Ä\82¢\82È\82¢\81D", Monnam(mtmp));
5538         return 0;
5539     }
5540     /* Do you have the necessary capacity to lift anything? */
5541     if (check_capacity((char *) 0))
5542         return 1;
5543
5544     /* Will our hero succeed? */
5545     if ((uprob = untrap_prob(ttmp)) && !mtmp->msleeping && mtmp->mcanmove) {
5546 #if 0 /*JP:T*/
5547         You("try to reach out your %s, but %s backs away skeptically.",
5548             makeplural(body_part(ARM)), mon_nam(mtmp));
5549 #else
5550         You("%s\82ð\8d·\82µ\89\84\82×\82æ\82¤\82Æ\82µ\82½\82ª%s\82Í\8cx\89ú\82µ\82Ä\82¢\82é\81D",
5551             body_part(ARM), mon_nam(mtmp));
5552 #endif
5553         return 1;
5554     }
5555
5556     /* is it a cockatrice?... */
5557     if (touch_petrifies(mtmp->data) && !uarmg && !Stone_resistance) {
5558 #if 0 /*JP:T*/
5559         You("grab the trapped %s using your bare %s.", mtmp->data->mname,
5560             makeplural(body_part(HAND)));
5561 #else
5562         You("ã©\82É\82©\82©\82Á\82Ä\82¢\82é%s\82ð\91f%s\82Å\92Í\82ñ\82¾\81D", mtmp->data->mname,
5563             body_part(HAND));
5564 #endif
5565
5566         if (poly_when_stoned(youmonst.data) && polymon(PM_STONE_GOLEM)) {
5567             display_nhwindow(WIN_MESSAGE, FALSE);
5568         } else {
5569             char kbuf[BUFSZ];
5570
5571 #if 0 /*JP:T*/
5572             Sprintf(kbuf, "trying to help %s out of a pit",
5573                     an(mtmp->data->mname));
5574 #else
5575             Sprintf(kbuf, "ã©\82É\82©\82©\82Á\82Ä\82¢\82é%s\82ð\8f\95\82¯\82æ\82¤\82Æ\82µ\82Ä",
5576                     a_monnam(mtmp));
5577 #endif
5578             instapetrify(kbuf);
5579             return 1;
5580         }
5581     }
5582     /* need to do cockatrice check first if sleeping or paralyzed */
5583     if (uprob) {
5584 /*JP
5585         You("try to grab %s, but cannot get a firm grasp.", mon_nam(mtmp));
5586 */
5587         You("%s\82ð\82Â\82©\82à\82¤\82Æ\82µ\82½\82ª\81C\82µ\82Á\82©\82è\82Æ\88¬\82ê\82È\82©\82Á\82½\81D", mon_nam(mtmp));
5588         if (mtmp->msleeping) {
5589             mtmp->msleeping = 0;
5590 /*JP
5591             pline("%s awakens.", Monnam(mtmp));
5592 */
5593             pline("%s\82Í\96Ú\82ð\8ao\82Ü\82µ\82½\81D", Monnam(mtmp));
5594         }
5595         return 1;
5596     }
5597
5598 #if 0 /*JP:T*/
5599     You("reach out your %s and grab %s.", makeplural(body_part(ARM)),
5600         mon_nam(mtmp));
5601 #else
5602     You("%s\82ð\90L\82Î\82µ\82Ä%s\82ð\82Â\82©\82ñ\82¾\81D", body_part(ARM),
5603         mon_nam(mtmp));
5604 #endif
5605
5606     if (mtmp->msleeping) {
5607         mtmp->msleeping = 0;
5608 /*JP
5609         pline("%s awakens.", Monnam(mtmp));
5610 */
5611         pline("%s\82Í\96Ú\82ð\8ao\82Ü\82µ\82½\81D", Monnam(mtmp));
5612     } else if (mtmp->mfrozen && !rn2(mtmp->mfrozen)) {
5613         /* After such manhandling, perhaps the effect wears off */
5614         mtmp->mcanmove = 1;
5615         mtmp->mfrozen = 0;
5616 /*JP
5617         pline("%s stirs.", Monnam(mtmp));
5618 */
5619         pline("%s\82Í\93®\82«\8en\82ß\82½\81D", Monnam(mtmp));
5620     }
5621
5622     /* is the monster too heavy? */
5623     wt = inv_weight() + mtmp->data->cwt;
5624     if (!try_lift(mtmp, ttmp, wt, FALSE))
5625         return 1;
5626
5627     /* is the monster with inventory too heavy? */
5628     for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj)
5629         wt += otmp->owt;
5630     if (!try_lift(mtmp, ttmp, wt, TRUE))
5631         return 1;
5632
5633 /*JP
5634     You("pull %s out of the pit.", mon_nam(mtmp));
5635 */
5636     You("%s\82ð\97\8e\82µ\8c\8a\82©\82ç\82Ð\82Á\82Ï\82Á\82½\81D", mon_nam(mtmp));
5637     mtmp->mtrapped = 0;
5638     reward_untrap(ttmp, mtmp);
5639     fill_pit(mtmp->mx, mtmp->my);
5640     return 1;
5641 }
5642
5643 int
5644 untrap(force)
5645 boolean force;
5646 {
5647     register struct obj *otmp;
5648     register int x, y;
5649     int ch;
5650     struct trap *ttmp;
5651     struct monst *mtmp;
5652     const char *trapdescr;
5653 #if 0 /*JP*/
5654     boolean here, useplural, deal_with_floor_trap,
5655             confused = (Confusion || Hallucination),
5656             trap_skipped = FALSE;
5657 #else
5658     boolean here, deal_with_floor_trap,
5659             confused = (Confusion || Hallucination),
5660             trap_skipped = FALSE;
5661 #endif
5662     int boxcnt = 0;
5663     char the_trap[BUFSZ], qbuf[QBUFSZ];
5664
5665     if (!getdir((char *) 0))
5666         return 0;
5667     x = u.ux + u.dx;
5668     y = u.uy + u.dy;
5669     if (!isok(x, y)) {
5670 /*JP
5671         pline_The("perils lurking there are beyond your grasp.");
5672 */
5673         pline_The("\82»\82±\82É\82 \82é\8aë\8c¯\82Í\82 \82È\82½\82Ì\8eè\82É\95\89\82¦\82È\82¢\81D");
5674         return 0;
5675     }
5676     /* 'force' is true for #invoke; make it be true for #untrap if
5677        carrying MKoT */
5678     if (!force && has_magic_key(&youmonst))
5679         force = TRUE;
5680
5681     ttmp = t_at(x, y);
5682     if (ttmp && !ttmp->tseen)
5683         ttmp = 0;
5684     trapdescr = ttmp ? defsyms[trap_to_defsym(ttmp->ttyp)].explanation : 0;
5685     here = (x == u.ux && y == u.uy); /* !u.dx && !u.dy */
5686
5687     if (here) /* are there are one or more containers here? */
5688         for (otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere)
5689             if (Is_box(otmp)) {
5690                 if (++boxcnt > 1)
5691                     break;
5692             }
5693
5694     deal_with_floor_trap = can_reach_floor(FALSE);
5695     if (!deal_with_floor_trap) {
5696         *the_trap = '\0';
5697         if (ttmp)
5698             Strcat(the_trap, an(trapdescr));
5699         if (ttmp && boxcnt)
5700 /*JP
5701             Strcat(the_trap, " and ");
5702 */
5703             Strcat(the_trap, "\82Æ");
5704         if (boxcnt)
5705 /*JP
5706             Strcat(the_trap, (boxcnt == 1) ? "a container" : "containers");
5707 */
5708             Strcat(the_trap, "\97e\8aí");
5709 #if 0 /*JP*/
5710         useplural = ((ttmp && boxcnt > 0) || boxcnt > 1);
5711 #endif
5712         /* note: boxcnt and useplural will always be 0 for !here case */
5713         if (ttmp || boxcnt)
5714 #if 0 /*JP:T*/
5715             There("%s %s %s but you can't reach %s%s.",
5716                   useplural ? "are" : "is", the_trap, here ? "here" : "there",
5717                   useplural ? "them" : "it",
5718                   u.usteed ? " while mounted" : "");
5719 #else
5720             pline("%s\82ª\82 \82é\82ª\81C%s\93Í\82©\82È\82¢\81D",
5721                   the_trap,
5722                   u.usteed ? "\8fæ\82Á\82Ä\82¢\82é\82Æ" : "");
5723 #endif
5724         trap_skipped = (ttmp != 0);
5725     } else { /* deal_with_floor_trap */
5726
5727         if (ttmp) {
5728             Strcpy(the_trap, the(trapdescr));
5729             if (boxcnt) {
5730                 if (is_pit(ttmp->ttyp)) {
5731 #if 0 /*JP:T*/
5732                     You_cant("do much about %s%s.", the_trap,
5733                              u.utrap ? " that you're stuck in"
5734                                      : " while standing on the edge of it");
5735 #else
5736                     pline("%s%s\82É\91Î\82µ\82Ä\82Í\82½\82¢\82µ\82½\82±\82Æ\82Í\82Å\82«\82È\82¢\81D",
5737                           u.utrap ? "\8e©\95ª\82ª\82Í\82Ü\82Á\82Ä\82¢\82é"
5738                                   : "\82·\82®\82»\82Î\82Ì",
5739                           the_trap);
5740 #endif
5741                     trap_skipped = TRUE;
5742                     deal_with_floor_trap = FALSE;
5743                 } else {
5744 #if 0 /*JP:T*/
5745                     Sprintf(
5746                         qbuf, "There %s and %s here.  %s %s?",
5747                         (boxcnt == 1) ? "is a container" : "are containers",
5748                         an(trapdescr),
5749                         (ttmp->ttyp == WEB) ? "Remove" : "Disarm", the_trap);
5750 #else
5751                     Sprintf(
5752                         qbuf, "\94 \82Æ%s\82ª\82 \82é\81D%s\81H",
5753                         trapdescr,
5754                         (ttmp->ttyp == WEB) ? "\8eæ\82è\8f\9c\82­" : "\89ð\8f\9c\82·\82é");
5755 #endif
5756                     switch (ynq(qbuf)) {
5757                     case 'q':
5758                         return 0;
5759                     case 'n':
5760                         trap_skipped = TRUE;
5761                         deal_with_floor_trap = FALSE;
5762                         break;
5763                     }
5764                 }
5765             }
5766             if (deal_with_floor_trap) {
5767                 if (u.utrap) {
5768 #if 0 /*JP*/
5769                     You("cannot deal with %s while trapped%s!", the_trap,
5770                         (x == u.ux && y == u.uy) ? " in it" : "");
5771 #else
5772                     pline("ã©\82É\82©\82©\82Á\82Ä\82¢\82é\8aÔ\82Íã©\82ð\89ð\8f\9c\82Å\82«\82È\82¢\81I");
5773 #endif
5774                     return 1;
5775                 }
5776                 if ((mtmp = m_at(x, y)) != 0
5777                     && (M_AP_TYPE(mtmp) == M_AP_FURNITURE
5778                         || M_AP_TYPE(mtmp) == M_AP_OBJECT)) {
5779                     stumble_onto_mimic(mtmp);
5780                     return 1;
5781                 }
5782                 switch (ttmp->ttyp) {
5783                 case BEAR_TRAP:
5784                 case WEB:
5785                     return disarm_holdingtrap(ttmp);
5786                 case LANDMINE:
5787                     return disarm_landmine(ttmp);
5788                 case SQKY_BOARD:
5789                     return disarm_squeaky_board(ttmp);
5790                 case DART_TRAP:
5791                     return disarm_shooting_trap(ttmp, DART);
5792                 case ARROW_TRAP:
5793                     return disarm_shooting_trap(ttmp, ARROW);
5794                 case PIT:
5795                 case SPIKED_PIT:
5796                     if (here) {
5797 /*JP
5798                         You("are already on the edge of the pit.");
5799 */
5800                         You("\82à\82¤\97\8e\82µ\8c\8a\82Ì\92[\82É\82¢\82é\81D");
5801                         return 0;
5802                     }
5803                     if (!mtmp) {
5804 /*JP
5805                         pline("Try filling the pit instead.");
5806 */
5807                         pline("\82È\82ñ\82Æ\82©\96\84\82ß\82é\82±\82Æ\82ð\8dl\82¦\82Ä\82Ý\82½\82ç\81H");
5808                         return 0;
5809                     }
5810                     return help_monster_out(mtmp, ttmp);
5811                 default:
5812 /*JP
5813                     You("cannot disable %s trap.", !here ? "that" : "this");
5814 */
5815                     pline("%sã©\82Í\89ð\8f\9c\82Å\82«\82È\82¢\81D", !here ? "\82»\82Ì" : "\82±\82Ì");
5816                     return 0;
5817                 }
5818             }
5819         } /* end if */
5820
5821         if (boxcnt) {
5822             for (otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere)
5823                 if (Is_box(otmp)) {
5824 #if 0 /*JP:T*/
5825                     (void) safe_qbuf(qbuf, "There is ",
5826                                      " here.  Check it for traps?", otmp,
5827                                      doname, ansimpleoname, "a box");
5828 #else
5829                     (void) safe_qbuf(qbuf, "",
5830                                      "\82ª\82 \82é\81Dã©\82ð\92²\82×\82Ü\82·\82©\81H", otmp,
5831                                      doname, ansimpleoname, "\94 ");
5832 #endif
5833                     switch (ynq(qbuf)) {
5834                     case 'q':
5835                         return 0;
5836                     case 'n':
5837                         continue;
5838                     }
5839
5840                     if ((otmp->otrapped
5841                          && (force || (!confused
5842                                        && rn2(MAXULEV + 1 - u.ulevel) < 10)))
5843                         || (!force && confused && !rn2(3))) {
5844 /*JP
5845                         You("find a trap on %s!", the(xname(otmp)));
5846 */
5847                         pline("%s\82Éã©\82ð\94­\8c©\82µ\82½\81I", the(xname(otmp)));
5848                         if (!confused)
5849                             exercise(A_WIS, TRUE);
5850
5851 /*JP
5852                         switch (ynq("Disarm it?")) {
5853 */
5854                         switch (ynq("\89ð\8f\9c\82µ\82Ü\82·\82©\81H")) {
5855                         case 'q':
5856                             return 1;
5857                         case 'n':
5858                             trap_skipped = TRUE;
5859                             continue;
5860                         }
5861
5862                         if (otmp->otrapped) {
5863                             exercise(A_DEX, TRUE);
5864                             ch = ACURR(A_DEX) + u.ulevel;
5865                             if (Role_if(PM_ROGUE))
5866                                 ch *= 2;
5867                             if (!force && (confused || Fumbling
5868                                            || rnd(75 + level_difficulty() / 2)
5869                                                   > ch)) {
5870                                 (void) chest_trap(otmp, FINGER, TRUE);
5871                             } else {
5872 /*JP
5873                                 You("disarm it!");
5874 */
5875                                 You("\89ð\8f\9c\82µ\82½\81I");
5876                                 otmp->otrapped = 0;
5877                             }
5878                         } else
5879 /*JP
5880                             pline("That %s was not trapped.", xname(otmp));
5881 */
5882                             pline("\82»\82Ì%s\82Éã©\82Í\82È\82¢\81D", xname(otmp));
5883                         return 1;
5884                     } else {
5885 /*JP
5886                         You("find no traps on %s.", the(xname(otmp)));
5887 */
5888                         pline("ã©\82ð\94­\8c©\82Å\82«\82È\82©\82Á\82½\81D");
5889                         return 1;
5890                     }
5891                 }
5892
5893 #if 0 /*JP:T*/
5894             You(trap_skipped ? "find no other traps here."
5895                              : "know of no traps here.");
5896 #else
5897             You(trap_skipped ? "\91¼\82Ìã©\82ð\8c©\82Â\82¯\82ç\82ê\82È\82©\82Á\82½\81D"
5898                              : "\82±\82±\82Éã©\82ª\82È\82¢\82±\82Æ\82ð\92m\82Á\82Ä\82¢\82é\81D");
5899 #endif
5900             return 0;
5901         }
5902
5903         if (stumble_on_door_mimic(x, y))
5904             return 1;
5905
5906     } /* deal_with_floor_trap */
5907     /* doors can be manipulated even while levitating/unskilled riding */
5908
5909     if (!IS_DOOR(levl[x][y].typ)) {
5910         if (!trap_skipped)
5911 /*JP
5912             You("know of no traps there.");
5913 */
5914             You("\82»\82±\82Éã©\82ª\82È\82¢\82±\82Æ\82ð\92m\82Á\82Ä\82¢\82é\81D");
5915         return 0;
5916     }
5917
5918     switch (levl[x][y].doormask) {
5919     case D_NODOOR:
5920 /*JP
5921         You("%s no door there.", Blind ? "feel" : "see");
5922 */
5923         pline("\82»\82±\82É\82Í\94à\82ª\82È\82¢%s\81D", Blind ? "\82æ\82¤\82¾" : "\82æ\82¤\82É\8c©\82¦\82é");
5924         return 0;
5925     case D_ISOPEN:
5926 /*JP
5927         pline("This door is safely open.");
5928 */
5929         pline("\82»\82Ì\94à\82Í\88À\91S\82É\8aJ\82¢\82Ä\82¢\82é\81D");
5930         return 0;
5931     case D_BROKEN:
5932 /*JP
5933         pline("This door is broken.");
5934 */
5935         pline("\82»\82Ì\94à\82Í\89ó\82ê\82Ä\82¢\82é\81D");
5936         return 0;
5937     }
5938
5939     if (((levl[x][y].doormask & D_TRAPPED) != 0
5940          && (force || (!confused && rn2(MAXULEV - u.ulevel + 11) < 10)))
5941         || (!force && confused && !rn2(3))) {
5942 /*JP
5943         You("find a trap on the door!");
5944 */
5945         pline("\94à\82Éã©\82ð\94­\8c©\82µ\82½\81I");
5946         exercise(A_WIS, TRUE);
5947 /*JP
5948         if (ynq("Disarm it?") != 'y')
5949 */
5950         if (ynq("\89ð\8f\9c\82µ\82Ü\82·\82©\81H") != 'y')
5951             return 1;
5952         if (levl[x][y].doormask & D_TRAPPED) {
5953             ch = 15 + (Role_if(PM_ROGUE) ? u.ulevel * 3 : u.ulevel);
5954             exercise(A_DEX, TRUE);
5955             if (!force && (confused || Fumbling
5956                            || rnd(75 + level_difficulty() / 2) > ch)) {
5957 /*JP
5958                 You("set it off!");
5959 */
5960                 You("\83X\83C\83b\83`\82ð\93ü\82ê\82Ä\82µ\82Ü\82Á\82½\81I");
5961 /*JP
5962                 b_trapped("door", FINGER);
5963 */
5964                 b_trapped("\94à", FINGER);
5965                 levl[x][y].doormask = D_NODOOR;
5966                 unblock_point(x, y);
5967                 newsym(x, y);
5968                 /* (probably ought to charge for this damage...) */
5969                 if (*in_rooms(x, y, SHOPBASE))
5970                     add_damage(x, y, 0L);
5971             } else {
5972 /*JP
5973                 You("disarm it!");
5974 */
5975                 You("\89ð\8f\9c\82µ\82½\81I");
5976                 levl[x][y].doormask &= ~D_TRAPPED;
5977             }
5978         } else
5979 /*JP
5980             pline("This door was not trapped.");
5981 */
5982             pline("\94à\82Éã©\82Í\82È\82©\82Á\82½\81D");
5983         return 1;
5984     } else {
5985 /*JP
5986         You("find no traps on the door.");
5987 */
5988         pline("\94à\82Éã©\82ð\94­\8c©\82Å\82«\82È\82©\82Á\82½\81D");
5989         return 1;
5990     }
5991 }
5992
5993 /* for magic unlocking; returns true if targetted monster (which might
5994    be hero) gets untrapped; the trap remains intact */
5995 boolean
5996 openholdingtrap(mon, noticed)
5997 struct monst *mon;
5998 boolean *noticed; /* set to true iff hero notices the effect; */
5999 {                 /* otherwise left with its previous value intact */
6000     struct trap *t;
6001     char buf[BUFSZ], whichbuf[20];
6002     const char *trapdescr = 0, *which = 0;
6003     boolean ishero = (mon == &youmonst);
6004
6005     if (!mon)
6006         return FALSE;
6007     if (mon == u.usteed)
6008         ishero = TRUE;
6009
6010     t = t_at(ishero ? u.ux : mon->mx, ishero ? u.uy : mon->my);
6011
6012     if (ishero && u.utrap) { /* all u.utraptype values are holding traps */
6013         which = the_your[(!t || !t->tseen || !t->madeby_u) ? 0 : 1];
6014         switch (u.utraptype) {
6015         case TT_LAVA:
6016 /*JP
6017             trapdescr = "molten lava";
6018 */
6019             trapdescr = "\82Ç\82ë\82Ç\82ë\82Ì\97n\8aâ";
6020             break;
6021         case TT_INFLOOR:
6022             /* solidified lava, so not "floor" even if within a room */
6023 /*JP
6024             trapdescr = "ground";
6025 */
6026             trapdescr = "\92n\96Ê";
6027             break;
6028         case TT_BURIEDBALL:
6029 /*JP
6030             trapdescr = "your anchor";
6031 */
6032             trapdescr = "\82­\82³\82Ñ";
6033             which = "";
6034             break;
6035         case TT_BEARTRAP:
6036         case TT_PIT:
6037         case TT_WEB:
6038             trapdescr = 0; /* use defsyms[].explanation */
6039             break;
6040         default:
6041             /* lint suppression in case 't' is unexpectedly Null
6042                or u.utraptype has new value we don't know about yet */
6043 /*JP
6044             trapdescr = "trap";
6045 */
6046             trapdescr = "ã©";
6047             break;
6048         }
6049     } else {
6050         /* if no trap here or it's not a holding trap, we're done */
6051         if (!t || (t->ttyp != BEAR_TRAP && t->ttyp != WEB))
6052             return FALSE;
6053     }
6054
6055     if (!trapdescr)
6056         trapdescr = defsyms[trap_to_defsym(t->ttyp)].explanation;
6057     if (!which)
6058 #if 0 /*JP*/
6059         which = t->tseen ? the_your[t->madeby_u]
6060                          : index(vowels, *trapdescr) ? "an" : "a";
6061 #else
6062         which = t->tseen ? set_you[t->madeby_u] : "";
6063 #endif
6064     if (*which)
6065         which = strcat(strcpy(whichbuf, which), " ");
6066
6067     if (ishero) {
6068         if (!u.utrap)
6069             return FALSE;
6070         *noticed = TRUE;
6071         if (u.usteed)
6072 /*JP
6073             Sprintf(buf, "%s is", noit_Monnam(u.usteed));
6074 */
6075             Strcpy(buf, noit_Monnam(u.usteed));
6076         else
6077 /*JP
6078             Strcpy(buf, "You are");
6079 */
6080             Strcpy(buf, "\82 \82È\82½");
6081         reset_utrap(TRUE);
6082         vision_full_recalc = 1; /* vision limits can change (pit escape) */
6083 /*JP
6084         pline("%s released from %s%s.", buf, which, trapdescr);
6085 */
6086         pline("%s\82Í%s%s\82©\82ç\89ð\95ú\82³\82ê\82½\81D", buf, which, trapdescr);
6087     } else {
6088         if (!mon->mtrapped)
6089             return FALSE;
6090         mon->mtrapped = 0;
6091         if (canspotmon(mon)) {
6092             *noticed = TRUE;
6093 #if 0 /*JP:T*/
6094             pline("%s is released from %s%s.", Monnam(mon), which,
6095                   trapdescr);
6096 #else
6097             pline("%s\82Í%s%s\82©\82ç\89ð\95ú\82³\82ê\82½\81D", Monnam(mon), which,
6098                   trapdescr);
6099 #endif
6100         } else if (cansee(t->tx, t->ty) && t->tseen) {
6101             *noticed = TRUE;
6102             if (t->ttyp == WEB)
6103 #if 0 /*JP:T*/
6104                 pline("%s is released from %s%s.", Something, which,
6105                       trapdescr);
6106 #else
6107                 pline("\89½\8eÒ\82©\82Í%s%s\82©\82ç\89ð\95ú\82³\82ê\82½\81D", which,
6108                       trapdescr);
6109 #endif
6110             else /* BEAR_TRAP */
6111 /*JP
6112                 pline("%s%s opens.", upstart(strcpy(buf, which)), trapdescr);
6113 */
6114                 pline("%s%s\82Í\8aJ\82¢\82½\81D", which, trapdescr);
6115         }
6116         /* might pacify monster if adjacent */
6117         if (rn2(2) && distu(mon->mx, mon->my) <= 2)
6118             reward_untrap(t, mon);
6119     }
6120     return TRUE;
6121 }
6122
6123 /* for magic locking; returns true if targetted monster (which might
6124    be hero) gets hit by a trap (might avoid actually becoming trapped) */
6125 boolean
6126 closeholdingtrap(mon, noticed)
6127 struct monst *mon;
6128 boolean *noticed; /* set to true iff hero notices the effect; */
6129 {                 /* otherwise left with its previous value intact */
6130     struct trap *t;
6131     unsigned dotrapflags;
6132     boolean ishero = (mon == &youmonst), result;
6133
6134     if (!mon)
6135         return FALSE;
6136     if (mon == u.usteed)
6137         ishero = TRUE;
6138     t = t_at(ishero ? u.ux : mon->mx, ishero ? u.uy : mon->my);
6139     /* if no trap here or it's not a holding trap, we're done */
6140     if (!t || (t->ttyp != BEAR_TRAP && t->ttyp != WEB))
6141         return FALSE;
6142
6143     if (ishero) {
6144         if (u.utrap)
6145             return FALSE; /* already trapped */
6146         *noticed = TRUE;
6147         dotrapflags = FORCETRAP;
6148         /* dotrap calls mintrap when mounted hero encounters a web */
6149         if (u.usteed)
6150             dotrapflags |= NOWEBMSG;
6151         ++force_mintrap;
6152         dotrap(t, dotrapflags);
6153         --force_mintrap;
6154         result = (u.utrap != 0);
6155     } else {
6156         if (mon->mtrapped)
6157             return FALSE; /* already trapped */
6158         /* you notice it if you see the trap close/tremble/whatever
6159            or if you sense the monster who becomes trapped */
6160         *noticed = cansee(t->tx, t->ty) || canspotmon(mon);
6161         ++force_mintrap;
6162         result = (mintrap(mon) != 0);
6163         --force_mintrap;
6164     }
6165     return result;
6166 }
6167
6168 /* for magic unlocking; returns true if targetted monster (which might
6169    be hero) gets hit by a trap (target might avoid its effect) */
6170 boolean
6171 openfallingtrap(mon, trapdoor_only, noticed)
6172 struct monst *mon;
6173 boolean trapdoor_only;
6174 boolean *noticed; /* set to true iff hero notices the effect; */
6175 {                 /* otherwise left with its previous value intact */
6176     struct trap *t;
6177     boolean ishero = (mon == &youmonst), result;
6178
6179     if (!mon)
6180         return FALSE;
6181     if (mon == u.usteed)
6182         ishero = TRUE;
6183     t = t_at(ishero ? u.ux : mon->mx, ishero ? u.uy : mon->my);
6184     /* if no trap here or it's not a falling trap, we're done
6185        (note: falling rock traps have a trapdoor in the ceiling) */
6186     if (!t || ((t->ttyp != TRAPDOOR && t->ttyp != ROCKTRAP)
6187                && (trapdoor_only || (t->ttyp != HOLE && !is_pit(t->ttyp)))))
6188         return FALSE;
6189
6190     if (ishero) {
6191         if (u.utrap)
6192             return FALSE; /* already trapped */
6193         *noticed = TRUE;
6194         dotrap(t, FORCETRAP);
6195         result = (u.utrap != 0);
6196     } else {
6197         if (mon->mtrapped)
6198             return FALSE; /* already trapped */
6199         /* you notice it if you see the trap close/tremble/whatever
6200            or if you sense the monster who becomes trapped */
6201         *noticed = cansee(t->tx, t->ty) || canspotmon(mon);
6202         /* monster will be angered; mintrap doesn't handle that */
6203         wakeup(mon, TRUE);
6204         ++force_mintrap;
6205         result = (mintrap(mon) != 0);
6206         --force_mintrap;
6207         /* mon might now be on the migrating monsters list */
6208     }
6209     return result;
6210 }
6211
6212 /* only called when the player is doing something to the chest directly */
6213 boolean
6214 chest_trap(obj, bodypart, disarm)
6215 register struct obj *obj;
6216 register int bodypart;
6217 boolean disarm;
6218 {
6219     register struct obj *otmp = obj, *otmp2;
6220     char buf[80];
6221     const char *msg;
6222     coord cc;
6223
6224     if (get_obj_location(obj, &cc.x, &cc.y, 0)) /* might be carried */
6225         obj->ox = cc.x, obj->oy = cc.y;
6226
6227     otmp->otrapped = 0; /* trap is one-shot; clear flag first in case
6228                            chest kills you and ends up in bones file */
6229 /*JP
6230     You(disarm ? "set it off!" : "trigger a trap!");
6231 */
6232     You(disarm ? "\83X\83C\83b\83`\82ð\93ü\82ê\82Ä\82µ\82Ü\82Á\82½\81I" : "ã©\82É\82Ð\82Á\82©\82©\82Á\82½\81I");
6233     display_nhwindow(WIN_MESSAGE, FALSE);
6234     if (Luck > -13 && rn2(13 + Luck) > 7) { /* saved by luck */
6235         /* trap went off, but good luck prevents damage */
6236         switch (rn2(13)) {
6237         case 12:
6238         case 11:
6239 /*JP
6240             msg = "explosive charge is a dud";
6241 */
6242             msg = "\94\9a\94­\82Í\95s\94­\82¾\82Á\82½";
6243             break;
6244         case 10:
6245         case 9:
6246 /*JP
6247             msg = "electric charge is grounded";
6248 */
6249             msg = "\93d\8c\82\82ª\95ú\8fo\82³\82ê\82½\82ª\83A\81[\83X\82³\82ê\82Ä\82¢\82½";
6250             break;
6251         case 8:
6252         case 7:
6253 /*JP
6254             msg = "flame fizzles out";
6255 */
6256             msg = "\89\8a\82Í\83V\83\85\81[\82Á\82Æ\8fÁ\82¦\82½";
6257             break;
6258         case 6:
6259         case 5:
6260         case 4:
6261 /*JP
6262             msg = "poisoned needle misses";
6263 */
6264             msg = "\93Å\90j\82Í\8eh\82³\82ç\82È\82©\82Á\82½";
6265             break;
6266         case 3:
6267         case 2:
6268         case 1:
6269         case 0:
6270 /*JP
6271             msg = "gas cloud blows away";
6272 */
6273             msg = "\83K\83X\89_\82Í\90\81\82«\94ò\82ñ\82¾";
6274             break;
6275         default:
6276             impossible("chest disarm bug");
6277             msg = (char *) 0;
6278             break;
6279         }
6280         if (msg)
6281 /*JP
6282             pline("But luckily the %s!", msg);
6283 */
6284             pline("\82µ\82©\82µ\89^\82Ì\82æ\82¢\82±\82Æ\82É%s\81I", msg);
6285     } else {
6286         switch (rn2(20) ? ((Luck >= 13) ? 0 : rn2(13 - Luck)) : rn2(26)) {
6287         case 25:
6288         case 24:
6289         case 23:
6290         case 22:
6291         case 21: {
6292             struct monst *shkp = 0;
6293             long loss = 0L;
6294             boolean costly, insider;
6295             register xchar ox = obj->ox, oy = obj->oy;
6296
6297             /* the obj location need not be that of player */
6298             costly = (costly_spot(ox, oy)
6299                       && (shkp = shop_keeper(*in_rooms(ox, oy, SHOPBASE)))
6300                              != (struct monst *) 0);
6301             insider = (*u.ushops && inside_shop(u.ux, u.uy)
6302                        && *in_rooms(ox, oy, SHOPBASE) == *u.ushops);
6303
6304 /*JP
6305             pline("%s!", Tobjnam(obj, "explode"));
6306 */
6307             pline("%s\82Í\94\9a\94­\82µ\82½\81I", xname(obj));
6308 /*JP
6309             Sprintf(buf, "exploding %s", xname(obj));
6310 */
6311             Sprintf(buf, "%s\82Ì\94\9a\94­\82Å", xname(obj));
6312
6313             if (costly)
6314                 loss += stolen_value(obj, ox, oy, (boolean) shkp->mpeaceful,
6315                                      TRUE);
6316             delete_contents(obj);
6317             /* unpunish() in advance if either ball or chain (or both)
6318                is going to be destroyed */
6319             if (Punished && ((uchain->ox == u.ux && uchain->oy == u.uy)
6320                              || (uball->where == OBJ_FLOOR
6321                                  && uball->ox == u.ux && uball->oy == u.uy)))
6322                 unpunish();
6323
6324             for (otmp = level.objects[u.ux][u.uy]; otmp; otmp = otmp2) {
6325                 otmp2 = otmp->nexthere;
6326                 if (costly)
6327                     loss += stolen_value(otmp, otmp->ox, otmp->oy,
6328                                          (boolean) shkp->mpeaceful, TRUE);
6329                 delobj(otmp);
6330             }
6331             wake_nearby();
6332             losehp(Maybe_Half_Phys(d(6, 6)), buf, KILLED_BY_AN);
6333             exercise(A_STR, FALSE);
6334             if (costly && loss) {
6335                 if (insider)
6336 #if 0 /*JP:T*/
6337                     You("owe %ld %s for objects destroyed.", loss,
6338                         currency(loss));
6339 #else
6340                     You("\8aí\95¨\94j\91¹\82Å%ld%s\82Ì\8eØ\82è\82ð\82Â\82­\82Á\82½\81D", loss,
6341                         currency(loss));
6342 #endif
6343                 else {
6344 #if 0 /*JP:T*/
6345                     You("caused %ld %s worth of damage!", loss,
6346                         currency(loss));
6347 #else
6348                     You("%ld%s\95ª\82Ì\91¹\8aQ\82ð\88ø\82«\82¨\82±\82µ\82½\81I", loss,
6349                         currency(loss));
6350 #endif
6351                     make_angry_shk(shkp, ox, oy);
6352                 }
6353             }
6354             return TRUE;
6355         } /* case 21 */
6356         case 20:
6357         case 19:
6358         case 18:
6359         case 17:
6360 /*JP
6361             pline("A cloud of noxious gas billows from %s.", the(xname(obj)));
6362 */
6363             pline("\97L\93Å\83K\83X\82ª%s\82©\82ç\89Q\82Ü\82¢\82½\81D", the(xname(obj)));
6364 /*JP
6365             poisoned("gas cloud", A_STR, "cloud of poison gas", 15, FALSE);
6366 */
6367             poisoned("\83K\83X\89_", A_STR, "\83K\83X\89_", 15, FALSE);
6368             exercise(A_CON, FALSE);
6369             break;
6370         case 16:
6371         case 15:
6372         case 14:
6373         case 13:
6374 /*JP
6375             You_feel("a needle prick your %s.", body_part(bodypart));
6376 */
6377             You("%s\83`\83N\83b\82Æ\82¢\82¤\92É\82Ý\82ð\8a´\82\82½\81D", body_part(bodypart));
6378 /*JP
6379             poisoned("needle", A_CON, "poisoned needle", 10, FALSE);
6380 */
6381             poisoned("\90j", A_CON, "\93Å\90j", 10, FALSE);
6382             exercise(A_CON, FALSE);
6383             break;
6384         case 12:
6385         case 11:
6386         case 10:
6387         case 9:
6388             dofiretrap(obj);
6389             break;
6390         case 8:
6391         case 7:
6392         case 6: {
6393             int dmg;
6394
6395 /*JP
6396             You("are jolted by a surge of electricity!");
6397 */
6398             You("\93d\8bC\83V\83\87\83b\83N\82ð\82­\82ç\82Á\82½\81I");
6399             if (Shock_resistance) {
6400                 shieldeff(u.ux, u.uy);
6401 /*JP
6402                 You("don't seem to be affected.");
6403 */
6404                 pline("\82µ\82©\82µ\82 \82È\82½\82Í\89e\8b¿\82ð\8eó\82¯\82È\82¢\81D");
6405                 dmg = 0;
6406             } else
6407                 dmg = d(4, 4);
6408             destroy_item(RING_CLASS, AD_ELEC);
6409             destroy_item(WAND_CLASS, AD_ELEC);
6410             if (dmg)
6411 /*JP
6412                 losehp(dmg, "electric shock", KILLED_BY_AN);
6413 */
6414                 losehp(dmg, "\93d\8bC\83V\83\87\83b\83N\82Å", KILLED_BY_AN);
6415             break;
6416         } /* case 6 */
6417         case 5:
6418         case 4:
6419         case 3:
6420             if (!Free_action) {
6421 /*JP
6422                 pline("Suddenly you are frozen in place!");
6423 */
6424                 pline("\93Ë\91R\82»\82Ì\8fê\82Å\93®\82¯\82È\82­\82È\82Á\82½\81I");
6425                 nomul(-d(5, 6));
6426 /*JP
6427                 multi_reason = "frozen by a trap";
6428 */
6429                 multi_reason = "ã©\82Å\8dd\92¼\82µ\82Ä\82¢\82é\8e\9e\82É";
6430                 exercise(A_DEX, FALSE);
6431                 nomovemsg = You_can_move_again;
6432             } else
6433 /*JP
6434                 You("momentarily stiffen.");
6435 */
6436                 You("\88ê\8fu\8dd\92¼\82µ\82½\81D");
6437             break;
6438         case 2:
6439         case 1:
6440         case 0:
6441 #if 0 /*JP:T*/
6442             pline("A cloud of %s gas billows from %s.",
6443                   Blind ? blindgas[rn2(SIZE(blindgas))] : rndcolor(),
6444                   the(xname(obj)));
6445 #else
6446             pline("%s\83K\83X\89_\82ª%s\82Ì\92ê\82Å\89Q\82Ü\82¢\82½\81D",
6447                   Blind ? blindgas[rn2(SIZE(blindgas))] :
6448                   jconj_adj(rndcolor()), xname(obj));
6449 #endif
6450             if (!Stunned) {
6451                 if (Hallucination)
6452 /*JP
6453                     pline("What a groovy feeling!");
6454 */
6455                     pline("\82È\82ñ\82Ä\91f\93G\82È\82ñ\82¾\81I");
6456                 else
6457 #if 0 /*JP:T*/
6458                     You("%s%s...", stagger(youmonst.data, "stagger"),
6459                         Halluc_resistance ? ""
6460                                           : Blind ? " and get dizzy"
6461                                                   : " and your vision blurs");
6462 #else
6463                     You("\82­\82ç\82­\82ç\82µ%s\82½...",
6464                         Halluc_resistance ? ""
6465                                           : Blind ? "\81C\82ß\82Ü\82¢\82ª\82µ"
6466                                                   : "\81C\8ci\90F\82ª\82Ú\82â\82¯\82Ä\82«");
6467 #endif
6468             }
6469             make_stunned((HStun & TIMEOUT) + (long) rn1(7, 16), FALSE);
6470             (void) make_hallucinated(
6471                 (HHallucination & TIMEOUT) + (long) rn1(5, 16), FALSE, 0L);
6472             break;
6473         default:
6474             impossible("bad chest trap");
6475             break;
6476         }
6477         bot(); /* to get immediate botl re-display */
6478     }
6479
6480     return FALSE;
6481 }
6482
6483 struct trap *
6484 t_at(x, y)
6485 register int x, y;
6486 {
6487     register struct trap *trap = ftrap;
6488
6489     while (trap) {
6490         if (trap->tx == x && trap->ty == y)
6491             return trap;
6492         trap = trap->ntrap;
6493     }
6494     return (struct trap *) 0;
6495 }
6496
6497 void
6498 deltrap(trap)
6499 register struct trap *trap;
6500 {
6501     register struct trap *ttmp;
6502
6503     clear_conjoined_pits(trap);
6504     if (trap == ftrap) {
6505         ftrap = ftrap->ntrap;
6506     } else {
6507         for (ttmp = ftrap; ttmp; ttmp = ttmp->ntrap)
6508             if (ttmp->ntrap == trap)
6509                 break;
6510         if (!ttmp)
6511             panic("deltrap: no preceding trap!");
6512         ttmp->ntrap = trap->ntrap;
6513     }
6514     if (Sokoban && (trap->ttyp == PIT || trap->ttyp == HOLE))
6515         maybe_finish_sokoban();
6516     dealloc_trap(trap);
6517 }
6518
6519 boolean
6520 conjoined_pits(trap2, trap1, u_entering_trap2)
6521 struct trap *trap2, *trap1;
6522 boolean u_entering_trap2;
6523 {
6524     int dx, dy, diridx, adjidx;
6525
6526     if (!trap1 || !trap2)
6527         return FALSE;
6528     if (!isok(trap2->tx, trap2->ty) || !isok(trap1->tx, trap1->ty)
6529         || !is_pit(trap2->ttyp)
6530         || !is_pit(trap1->ttyp)
6531         || (u_entering_trap2 && !(u.utrap && u.utraptype == TT_PIT)))
6532         return FALSE;
6533     dx = sgn(trap2->tx - trap1->tx);
6534     dy = sgn(trap2->ty - trap1->ty);
6535     for (diridx = 0; diridx < 8; diridx++)
6536         if (xdir[diridx] == dx && ydir[diridx] == dy)
6537             break;
6538     /* diridx is valid if < 8 */
6539     if (diridx < 8) {
6540         adjidx = (diridx + 4) % 8;
6541         if ((trap1->conjoined & (1 << diridx))
6542             && (trap2->conjoined & (1 << adjidx)))
6543             return TRUE;
6544     }
6545     return FALSE;
6546 }
6547
6548 STATIC_OVL void
6549 clear_conjoined_pits(trap)
6550 struct trap *trap;
6551 {
6552     int diridx, adjidx, x, y;
6553     struct trap *t;
6554
6555     if (trap && is_pit(trap->ttyp)) {
6556         for (diridx = 0; diridx < 8; ++diridx) {
6557             if (trap->conjoined & (1 << diridx)) {
6558                 x = trap->tx + xdir[diridx];
6559                 y = trap->ty + ydir[diridx];
6560                 if (isok(x, y)
6561                     && (t = t_at(x, y)) != 0
6562                     && is_pit(t->ttyp)) {
6563                     adjidx = (diridx + 4) % 8;
6564                     t->conjoined &= ~(1 << adjidx);
6565                 }
6566                 trap->conjoined &= ~(1 << diridx);
6567             }
6568         }
6569     }
6570 }
6571
6572 STATIC_OVL boolean
6573 adj_nonconjoined_pit(adjtrap)
6574 struct trap *adjtrap;
6575 {
6576     struct trap *trap_with_u = t_at(u.ux0, u.uy0);
6577
6578     if (trap_with_u && adjtrap && u.utrap && u.utraptype == TT_PIT
6579         && is_pit(trap_with_u->ttyp) && is_pit(adjtrap->ttyp)) {
6580         int idx;
6581
6582         for (idx = 0; idx < 8; idx++) {
6583             if (xdir[idx] == u.dx && ydir[idx] == u.dy)
6584                 return TRUE;
6585         }
6586     }
6587     return FALSE;
6588 }
6589
6590 #if 0
6591 /*
6592  * Mark all neighboring pits as conjoined pits.
6593  * (currently not called from anywhere)
6594  */
6595 STATIC_OVL void
6596 join_adjacent_pits(trap)
6597 struct trap *trap;
6598 {
6599     struct trap *t;
6600     int diridx, x, y;
6601
6602     if (!trap)
6603         return;
6604     for (diridx = 0; diridx < 8; ++diridx) {
6605         x = trap->tx + xdir[diridx];
6606         y = trap->ty + ydir[diridx];
6607         if (isok(x, y)) {
6608             if ((t = t_at(x, y)) != 0 && is_pit(t->ttyp)) {
6609                 trap->conjoined |= (1 << diridx);
6610                 join_adjacent_pits(t);
6611             } else
6612                 trap->conjoined &= ~(1 << diridx);
6613         }
6614     }
6615 }
6616 #endif /*0*/
6617
6618 /*
6619  * Returns TRUE if you escaped a pit and are standing on the precipice.
6620  */
6621 boolean
6622 uteetering_at_seen_pit(trap)
6623 struct trap *trap;
6624 {
6625     return (trap && is_pit(trap->ttyp) && trap->tseen
6626             && trap->tx == u.ux && trap->ty == u.uy
6627             && !(u.utrap && u.utraptype == TT_PIT));
6628 }
6629
6630 /*
6631  * Returns TRUE if you didn't fall through a hole or didn't
6632  * release a trap door
6633  */
6634 boolean
6635 uescaped_shaft(trap)
6636 struct trap *trap;
6637 {
6638     return (trap && is_hole(trap->ttyp) && trap->tseen
6639             && trap->tx == u.ux && trap->ty == u.uy);
6640 }
6641
6642 /* Destroy a trap that emanates from the floor. */
6643 boolean
6644 delfloortrap(ttmp)
6645 register struct trap *ttmp;
6646 {
6647     /* some of these are arbitrary -dlc */
6648     if (ttmp && ((ttmp->ttyp == SQKY_BOARD) || (ttmp->ttyp == BEAR_TRAP)
6649                  || (ttmp->ttyp == LANDMINE) || (ttmp->ttyp == FIRE_TRAP)
6650                  || is_pit(ttmp->ttyp)
6651                  || is_hole(ttmp->ttyp)
6652                  || (ttmp->ttyp == TELEP_TRAP) || (ttmp->ttyp == LEVEL_TELEP)
6653                  || (ttmp->ttyp == WEB) || (ttmp->ttyp == MAGIC_TRAP)
6654                  || (ttmp->ttyp == ANTI_MAGIC))) {
6655         register struct monst *mtmp;
6656
6657         if (ttmp->tx == u.ux && ttmp->ty == u.uy) {
6658             if (u.utraptype != TT_BURIEDBALL)
6659                 reset_utrap(TRUE);
6660         } else if ((mtmp = m_at(ttmp->tx, ttmp->ty)) != 0) {
6661             mtmp->mtrapped = 0;
6662         }
6663         deltrap(ttmp);
6664         return TRUE;
6665     }
6666     return FALSE;
6667 }
6668
6669 /* used for doors (also tins).  can be used for anything else that opens. */
6670 void
6671 b_trapped(item, bodypart)
6672 const char *item;
6673 int bodypart;
6674 {
6675     int lvl = level_difficulty(),
6676         dmg = rnd(5 + (lvl < 5 ? lvl : 2 + lvl / 2));
6677
6678 /*JP
6679     pline("KABOOM!!  %s was booby-trapped!", The(item));
6680 */
6681     pline("\82¿\82ã\82Ç\81[\82ñ\81I\81I%s\82É\83u\81[\83r\81[\83g\83\89\83b\83v\82ª\8ed\8a|\82¯\82ç\82ê\82Ä\82¢\82½\81I", item);
6682     wake_nearby();
6683 /*JP
6684     losehp(Maybe_Half_Phys(dmg), "explosion", KILLED_BY_AN);
6685 */
6686     losehp(Maybe_Half_Phys(dmg), "\83u\81[\83r\81[\83g\83\89\83b\83v\82Ì\94\9a\94­\82Å", KILLED_BY_AN);
6687     exercise(A_STR, FALSE);
6688     if (bodypart)
6689         exercise(A_CON, FALSE);
6690     make_stunned((HStun & TIMEOUT) + (long) dmg, TRUE);
6691 }
6692
6693 /* Monster is hit by trap. */
6694 /* Note: doesn't work if both obj and d_override are null */
6695 STATIC_OVL boolean
6696 thitm(tlev, mon, obj, d_override, nocorpse)
6697 int tlev;
6698 struct monst *mon;
6699 struct obj *obj;
6700 int d_override;
6701 boolean nocorpse;
6702 {
6703     int strike;
6704     boolean trapkilled = FALSE;
6705
6706     if (d_override)
6707         strike = 1;
6708     else if (obj)
6709         strike = (find_mac(mon) + tlev + obj->spe <= rnd(20));
6710     else
6711         strike = (find_mac(mon) + tlev <= rnd(20));
6712
6713     /* Actually more accurate than thitu, which doesn't take
6714      * obj->spe into account.
6715      */
6716     if (!strike) {
6717         if (obj && cansee(mon->mx, mon->my))
6718 /*JP
6719             pline("%s is almost hit by %s!", Monnam(mon), doname(obj));
6720 */
6721             pline("\82à\82¤\8f­\82µ\82Å%s\82ª%s\82É\96½\92\86\82·\82é\82Æ\82±\82ë\82¾\82Á\82½\81I", doname(obj), Monnam(mon));
6722     } else {
6723         int dam = 1;
6724
6725         if (obj && cansee(mon->mx, mon->my))
6726 /*JP
6727             pline("%s is hit by %s!", Monnam(mon), doname(obj));
6728 */
6729             pline("%s\82ª%s\82É\96½\92\86\82µ\82½\81I", doname(obj), Monnam(mon));
6730         if (d_override)
6731             dam = d_override;
6732         else if (obj) {
6733             dam = dmgval(obj, mon);
6734             if (dam < 1)
6735                 dam = 1;
6736         }
6737         mon->mhp -= dam;
6738         if (DEADMONSTER(mon)) {
6739             int xx = mon->mx, yy = mon->my;
6740
6741             monkilled(mon, "", nocorpse ? -AD_RBRE : AD_PHYS);
6742             if (DEADMONSTER(mon)) {
6743                 newsym(xx, yy);
6744                 trapkilled = TRUE;
6745             }
6746         }
6747     }
6748     if (obj && (!strike || d_override)) {
6749         place_object(obj, mon->mx, mon->my);
6750         stackobj(obj);
6751     } else if (obj)
6752         dealloc_obj(obj);
6753
6754     return trapkilled;
6755 }
6756
6757 boolean
6758 unconscious()
6759 {
6760     if (multi >= 0)
6761         return FALSE;
6762
6763 #if 0 /*JP:T*/
6764     return (boolean) (u.usleep
6765                       || (nomovemsg
6766                           && (!strncmp(nomovemsg, "You awake", 9)
6767                               || !strncmp(nomovemsg, "You regain con", 14)
6768                               || !strncmp(nomovemsg, "You are consci", 14))));
6769 #else
6770 /*JP 3.6.2 \82Å\82Ì\8fo\8c»\88Ê\92u/\89ñ\90\94
6771  "You awake"      : potion.c(1)
6772   "You regain con": eat.c(1)
6773   "You are consci": eat.c(1)
6774 */
6775     return (boolean) (u.usleep
6776                       || (nomovemsg
6777                           && (!strncmp(nomovemsg, "\96Ú\82ª\82³\82ß\82½\82ª\93ª\92É", 18)
6778                               || !strncmp(nomovemsg, "\82 \82È\82½\82Í\90³\8bC\82Ã\82¢\82½", 18)
6779                               || !strncmp(nomovemsg, "\82 \82È\82½\82Í\82Ü\82½\90³\8bC\82Ã", 18))));
6780 #endif
6781 }
6782
6783 /*JP
6784 static const char lava_killer[] = "molten lava";
6785 */
6786 static const char lava_killer[] = "\82Ç\82ë\82Ç\82ë\82Ì\97n\8aâ\82Å";
6787
6788 boolean
6789 lava_effects()
6790 {
6791     register struct obj *obj, *obj2;
6792     int dmg = d(6, 6); /* only applicable for water walking */
6793     boolean usurvive, boil_away;
6794
6795     feel_newsym(u.ux, u.uy); /* in case Blind, map the lava here */
6796     burn_away_slime();
6797     if (likes_lava(youmonst.data))
6798         return FALSE;
6799
6800     usurvive = Fire_resistance || (Wwalking && dmg < u.uhp);
6801     /*
6802      * A timely interrupt might manage to salvage your life
6803      * but not your gear.  For scrolls and potions this
6804      * will destroy whole stacks, where fire resistant hero
6805      * survivor only loses partial stacks via destroy_item().
6806      *
6807      * Flag items to be destroyed before any messages so
6808      * that player causing hangup at --More-- won't get an
6809      * emergency save file created before item destruction.
6810      */
6811     if (!usurvive)
6812         for (obj = invent; obj; obj = obj->nobj)
6813             if ((is_organic(obj) || obj->oclass == POTION_CLASS)
6814                 && !obj->oerodeproof
6815                 && objects[obj->otyp].oc_oprop != FIRE_RES
6816                 && obj->otyp != SCR_FIRE && obj->otyp != SPE_FIREBALL
6817                 && !obj_resists(obj, 0, 0)) /* for invocation items */
6818                 obj->in_use = 1;
6819
6820     /* Check whether we should burn away boots *first* so we know whether to
6821      * make the player sink into the lava. Assumption: water walking only
6822      * comes from boots.
6823      */
6824     if (uarmf && is_organic(uarmf) && !uarmf->oerodeproof) {
6825         obj = uarmf;
6826 /*JP
6827         pline("%s into flame!", Yobjnam2(obj, "burst"));
6828 */
6829         Your("%s\82Í\94R\82¦\82½\81I", xname(obj));
6830         iflags.in_lava_effects++; /* (see above) */
6831         (void) Boots_off();
6832         useup(obj);
6833         iflags.in_lava_effects--;
6834     }
6835
6836     if (!Fire_resistance) {
6837         if (Wwalking) {
6838 /*JP
6839             pline_The("%s here burns you!", hliquid("lava"));
6840 */
6841             pline("%s\82ª\82 \82È\82½\82ð\8fÄ\82«\82Â\82­\82µ\82½\81I", hliquid("\97n\8aâ"));
6842             if (usurvive) {
6843                 losehp(dmg, lava_killer, KILLED_BY); /* lava damage */
6844                 goto burn_stuff;
6845             }
6846         } else
6847 /*JP
6848             You("fall into the %s!", hliquid("lava"));
6849 */
6850             You("%s\82É\97\8e\82¿\82½\81I", hliquid("\97n\8aâ"));
6851
6852         usurvive = Lifesaved || discover;
6853         if (wizard)
6854             usurvive = TRUE;
6855
6856         /* prevent remove_worn_item() -> Boots_off(WATER_WALKING_BOOTS) ->
6857            spoteffects() -> lava_effects() recursion which would
6858            successfully delete (via useupall) the no-longer-worn boots;
6859            once recursive call returned, we would try to delete them again
6860            here in the outer call (and access stale memory, probably panic) */
6861         iflags.in_lava_effects++;
6862
6863         for (obj = invent; obj; obj = obj2) {
6864             obj2 = obj->nobj;
6865             /* above, we set in_use for objects which are to be destroyed */
6866             if (obj->otyp == SPE_BOOK_OF_THE_DEAD && !Blind) {
6867                 if (usurvive)
6868 #if 0 /*JP:T*/
6869                     pline("%s glows a strange %s, but remains intact.",
6870                           The(xname(obj)), hcolor("dark red"));
6871 #else
6872                     pline("%s\82Í\95s\8ev\8bc\82É%s\8bP\82¢\82½\82ª\81C\96³\8f\9d\82Ì\82æ\82¤\82¾\81D",
6873                           xname(obj), jconj_adj(hcolor("\88Ã\90Ô\90F\82Ì")));
6874 #endif
6875             } else if (obj->in_use) {
6876                 if (obj->owornmask) {
6877                     if (usurvive)
6878 /*JP
6879                         pline("%s into flame!", Yobjnam2(obj, "burst"));
6880 */
6881                         Your("%s\82Í\94R\82¦\82½\81I", xname(obj));
6882                     remove_worn_item(obj, TRUE);
6883                 }
6884                 useupall(obj);
6885             }
6886         }
6887
6888         iflags.in_lava_effects--;
6889
6890         /* s/he died... */
6891         boil_away = (u.umonnum == PM_WATER_ELEMENTAL
6892                      || u.umonnum == PM_STEAM_VORTEX
6893                      || u.umonnum == PM_FOG_CLOUD);
6894         for (;;) {
6895             u.uhp = -1;
6896             /* killer format and name are reconstructed every iteration
6897                because lifesaving resets them */
6898             killer.format = KILLED_BY;
6899             Strcpy(killer.name, lava_killer);
6900 /*JP
6901             You("%s...", boil_away ? "boil away" : "burn to a crisp");
6902 */
6903             You("%s\81D\81D\81D", boil_away ? "\95¦\93«\82µ\82½" : "\94R\82¦\82Ä\83p\83\8a\83p\83\8a\82É\82È\82Á\82½");
6904             done(BURNING);
6905             if (safe_teleds(TRUE))
6906                 break; /* successful life-save */
6907             /* nowhere safe to land; repeat burning loop */
6908 /*JP
6909             pline("You're still burning.");
6910 */
6911             You("\82Ü\82¾\94R\82¦\82Ä\82¢\82é\81D");
6912         }
6913 /*JP
6914         You("find yourself back on solid %s.", surface(u.ux, u.uy));
6915 */
6916         You("\82¢\82Â\82Ì\82Ü\82É\82©\8cÅ\82¢%s\82É\96ß\82Á\82Ä\82¢\82½\81D", surface(u.ux, u.uy));
6917         return TRUE;
6918     } else if (!Wwalking && (!u.utrap || u.utraptype != TT_LAVA)) {
6919         boil_away = !Fire_resistance;
6920         /* if not fire resistant, sink_into_lava() will quickly be fatal;
6921            hero needs to escape immediately */
6922         set_utrap((unsigned) (rn1(4, 4) + ((boil_away ? 2 : rn1(4, 12)) << 8)),
6923                   TT_LAVA);
6924 #if 0 /*JP:T*/
6925         You("sink into the %s%s!", hliquid("lava"),
6926             !boil_away ? ", but it only burns slightly"
6927                        : " and are about to be immolated");
6928 #else
6929         You("%s\82É\92¾\82ñ%s\82¾\81I", hliquid("\97n\8aâ"),
6930             !boil_away ? "\82¾\82ª\81C\82¿\82å\82Á\82Æ\8fÅ\82°\82½\82¾\82¯"
6931                        : "\82Å\8fÄ\82«\8eE\82³\82ê\82»\82¤");
6932 #endif
6933         if (u.uhp > 1)
6934             losehp(!boil_away ? 1 : (u.uhp / 2), lava_killer,
6935                    KILLED_BY); /* lava damage */
6936     }
6937
6938 burn_stuff:
6939     destroy_item(SCROLL_CLASS, AD_FIRE);
6940     destroy_item(SPBOOK_CLASS, AD_FIRE);
6941     destroy_item(POTION_CLASS, AD_FIRE);
6942     return FALSE;
6943 }
6944
6945 /* called each turn when trapped in lava */
6946 void
6947 sink_into_lava()
6948 {
6949 /*JP
6950     static const char sink_deeper[] = "You sink deeper into the lava.";
6951 */
6952     static const char sink_deeper[] = "\82 \82È\82½\82Í\82æ\82è\90[\82­\97n\8aâ\82É\92¾\82ñ\82¾\81D";
6953
6954     if (!u.utrap || u.utraptype != TT_LAVA) {
6955         ; /* do nothing; this usually won't happen but could after
6956            * polymorphing from a flier into a ceiling hider and then hiding;
6957            * allmain() only checks whether the hero is at a lava location,
6958            * not whether he or she is currently sinking */
6959     } else if (!is_lava(u.ux, u.uy)) {
6960         reset_utrap(FALSE); /* this shouldn't happen either */
6961     } else if (!u.uinvulnerable) {
6962         /* ordinarily we'd have to be fire resistant to survive long
6963            enough to become stuck in lava, but it can happen without
6964            resistance if water walking boots allow survival and then
6965            get burned up; u.utrap time will be quite short in that case */
6966         if (!Fire_resistance)
6967             u.uhp = (u.uhp + 2) / 3;
6968
6969         u.utrap -= (1 << 8);
6970         if (u.utrap < (1 << 8)) {
6971             killer.format = KILLED_BY;
6972 /*JP
6973             Strcpy(killer.name, "molten lava");
6974 */
6975             Strcpy(killer.name, "\82Ç\82ë\82Ç\82ë\82Ì\97n\8aâ\82Å");
6976 /*JP
6977             You("sink below the surface and die.");
6978 */
6979             You("\8a®\91S\82É\97n\8aâ\82Ì\92\86\82É\92¾\82ñ\82Å\81A\8e\80\82É\82Ü\82µ\82½\81D\81D\81D");
6980             burn_away_slime(); /* add insult to injury? */
6981             done(DISSOLVED);
6982             /* can only get here via life-saving; try to get away from lava */
6983             reset_utrap(TRUE);
6984             /* levitation or flight have become unblocked, otherwise Tport */
6985             if (!Levitation && !Flying)
6986                 (void) safe_teleds(TRUE);
6987         } else if (!u.umoved) {
6988             /* can't fully turn into slime while in lava, but might not
6989                have it be burned away until you've come awfully close */
6990             if (Slimed && rnd(10 - 1) >= (int) (Slimed & TIMEOUT)) {
6991                 pline(sink_deeper);
6992                 burn_away_slime();
6993             } else {
6994                 Norep(sink_deeper);
6995             }
6996             u.utrap += rnd(4);
6997         }
6998     }
6999 }
7000
7001 /* called when something has been done (breaking a boulder, for instance)
7002    which entails a luck penalty if performed on a sokoban level */
7003 void
7004 sokoban_guilt()
7005 {
7006     if (Sokoban) {
7007         change_luck(-1);
7008         /* TODO: issue some feedback so that player can learn that whatever
7009            he/she just did is a naughty thing to do in sokoban and should
7010            probably be avoided in future....
7011            Caveat: doing this might introduce message sequencing issues,
7012            depending upon feedback during the various actions which trigger
7013            Sokoban luck penalties. */
7014     }
7015 }
7016
7017 /* called when a trap has been deleted or had its ttyp replaced */
7018 STATIC_OVL void
7019 maybe_finish_sokoban()
7020 {
7021     struct trap *t;
7022
7023     if (Sokoban && !in_mklev) {
7024         /* scan all remaining traps, ignoring any created by the hero;
7025            if this level has no more pits or holes, the current sokoban
7026            puzzle has been solved */
7027         for (t = ftrap; t; t = t->ntrap) {
7028             if (t->madeby_u)
7029                 continue;
7030             if (t->ttyp == PIT || t->ttyp == HOLE)
7031                 break;
7032         }
7033         if (!t) {
7034             /* we've passed the last trap without finding a pit or hole;
7035                clear the sokoban_rules flag so that luck penalties for
7036                things like breaking boulders or jumping will no longer
7037                be given, and restrictions on diagonal moves are lifted */
7038             Sokoban = 0; /* clear level.flags.sokoban_rules */
7039             /* TODO: give some feedback about solving the sokoban puzzle
7040                (perhaps say "congratulations" in Japanese?) */
7041         }
7042     }
7043 }
7044
7045 /*trap.c*/