OSDN Git Service

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