OSDN Git Service

update year to 2019
[jnethack/source.git] / src / lock.c
1 /* NetHack 3.6  lock.c  $NHDT-Date: 1521499715 2018/03/19 22:48:35 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.80 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /*-Copyright (c) Robert Patrick Rankin, 2011. */
4 /* NetHack may be freely redistributed.  See license for details. */
5
6 /* JNetHack Copyright */
7 /* (c) Issei Numata, Naoki Hamada, Shigehiro Miyashita, 1994-2000  */
8 /* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2019            */
9 /* JNetHack may be freely redistributed.  See license for details. */
10
11 #include "hack.h"
12
13 /* at most one of `door' and `box' should be non-null at any given time */
14 STATIC_VAR NEARDATA struct xlock_s {
15     struct rm *door;
16     struct obj *box;
17     int picktyp, /* key|pick|card for unlock, sharp vs blunt for #force */
18         chance, usedtime;
19     boolean magic_key;
20 } xlock;
21
22 /* occupation callbacks */
23 STATIC_PTR int NDECL(picklock);
24 STATIC_PTR int NDECL(forcelock);
25
26 STATIC_DCL const char *NDECL(lock_action);
27 STATIC_DCL boolean FDECL(obstructed, (int, int, BOOLEAN_P));
28 STATIC_DCL void FDECL(chest_shatter_msg, (struct obj *));
29
30 boolean
31 picking_lock(x, y)
32 int *x, *y;
33 {
34     if (occupation == picklock) {
35         *x = u.ux + u.dx;
36         *y = u.uy + u.dy;
37         return TRUE;
38     } else {
39         *x = *y = 0;
40         return FALSE;
41     }
42 }
43
44 boolean
45 picking_at(x, y)
46 int x, y;
47 {
48     return (boolean) (occupation == picklock && xlock.door == &levl[x][y]);
49 }
50
51 /* produce an occupation string appropriate for the current activity */
52 STATIC_OVL const char *
53 lock_action()
54 {
55     /* "unlocking"+2 == "locking" */
56     static const char *actions[] = {
57 #if 0 /*JP*/
58         "unlocking the door",   /* [0] */
59         "unlocking the chest",  /* [1] */
60         "unlocking the box",    /* [2] */
61         "picking the lock"      /* [3] */
62 #else 
63         "\94à\82Ì\8c®\82ð\82Í\82¸\82·", 
64         "\95ó\94 \82Ì\8c®\82ð\82Í\82¸\82·",
65         "\94 \82Ì\8c®\82ð\82Í\82¸\82·",
66         "\8c®\82ð\82Í\82¸\82·"
67 #endif
68     };
69
70     /* if the target is currently unlocked, we're trying to lock it now */
71     if (xlock.door && !(xlock.door->doormask & D_LOCKED))
72 #if 0 /*JP*/
73         return actions[0] + 2; /* "locking the door" */
74 #else /* \89p\8cê\82Í un \82ð\8eæ\82ê\82Î\8bt\82Ì\88Ó\96¡\82É\82È\82é\82ª\81C\93ú\96{\8cê\82Í\82»\82¤\82Í\82¢\82©\82È\82¢\82Ì\82Å\83\8a\83e\83\89\83\8b\82ð\8f\91\82­ */
75         return "\94à\82É\8c®\82ð\82©\82¯\82é";
76 #endif
77     else if (xlock.box && !xlock.box->olocked)
78 #if 0 /*JP*/
79         return xlock.box->otyp == CHEST ? actions[1] + 2 : actions[2] + 2;
80 #else
81         return xlock.box->otyp == CHEST ? "\95ó\94 \82É\8c®\82ð\82©\82¯\82é" : "\94 \82É\8c®\82ð\82©\82¯\82é";
82 #endif
83     /* otherwise we're trying to unlock it */
84     else if (xlock.picktyp == LOCK_PICK)
85         return actions[3]; /* "picking the lock" */
86     else if (xlock.picktyp == CREDIT_CARD)
87         return actions[3]; /* same as lock_pick */
88     else if (xlock.door)
89         return actions[0]; /* "unlocking the door" */
90     else if (xlock.box)
91         return xlock.box->otyp == CHEST ? actions[1] : actions[2];
92     else
93         return actions[3];
94 }
95
96 /* try to open/close a lock */
97 STATIC_PTR int
98 picklock(VOID_ARGS)
99 {
100     if (xlock.box) {
101         if (xlock.box->where != OBJ_FLOOR
102             || xlock.box->ox != u.ux || xlock.box->oy != u.uy) {
103             return ((xlock.usedtime = 0)); /* you or it moved */
104         }
105     } else { /* door */
106         if (xlock.door != &(levl[u.ux + u.dx][u.uy + u.dy])) {
107             return ((xlock.usedtime = 0)); /* you moved */
108         }
109         switch (xlock.door->doormask) {
110         case D_NODOOR:
111 /*JP
112             pline("This doorway has no door.");
113 */
114             pline("\8fo\93ü\8cû\82É\82Í\94à\82ª\82È\82¢\81D");
115             return ((xlock.usedtime = 0));
116         case D_ISOPEN:
117 /*JP
118             You("cannot lock an open door.");
119 */
120             pline("\8aJ\82¢\82Ä\82é\94à\82É\8c®\82ð\82©\82¯\82ç\82ê\82È\82¢\81D");
121             return ((xlock.usedtime = 0));
122         case D_BROKEN:
123 /*JP
124             pline("This door is broken.");
125 */
126             pline("\94à\82Í\89ó\82ê\82Ä\82¢\82é\81D");
127             return ((xlock.usedtime = 0));
128         }
129     }
130
131     if (xlock.usedtime++ >= 50 || nohands(youmonst.data)) {
132 /*JP
133         You("give up your attempt at %s.", lock_action());
134 */
135         pline("%s\82Ì\82ð\82 \82«\82ç\82ß\82½\81D", lock_action());
136         exercise(A_DEX, TRUE); /* even if you don't succeed */
137         return ((xlock.usedtime = 0));
138     }
139
140     if (rn2(100) >= xlock.chance)
141         return 1; /* still busy */
142
143     /* using the Master Key of Thievery finds traps if its bless/curse
144        state is adequate (non-cursed for rogues, blessed for others;
145        checked when setting up 'xlock') */
146     if ((!xlock.door ? (int) xlock.box->otrapped
147                      : (xlock.door->doormask & D_TRAPPED) != 0)
148         && xlock.magic_key) {
149         xlock.chance += 20; /* less effort needed next time */
150         /* unfortunately we don't have a 'tknown' flag to record
151            "known to be trapped" so declining to disarm and then
152            retrying lock manipulation will find it all over again */
153 /*JP
154         if (yn("You find a trap!  Do you want to try to disarm it?") == 'y') {
155 */
156         if (yn("ã©\82ð\8c©\82Â\82¯\82½\81I\8aO\82µ\82Ü\82·\82©\81H") == 'y') {
157             const char *what;
158             boolean alreadyunlocked;
159
160             /* disarming while using magic key always succeeds */
161             if (xlock.door) {
162                 xlock.door->doormask &= ~D_TRAPPED;
163 /*JP
164                 what = "door";
165 */
166                 what = "\94à";
167                 alreadyunlocked = !(xlock.door->doormask & D_LOCKED);
168             } else {
169                 xlock.box->otrapped = 0;
170 /*JP
171                 what = (xlock.box->otyp == CHEST) ? "chest" : "box";
172 */
173                 what = (xlock.box->otyp == CHEST) ? "\95ó\94 " : "\94 ";
174                 alreadyunlocked = !xlock.box->olocked;
175             }
176 #if 0 /*JP*/
177             You("succeed in disarming the trap.  The %s is still %slocked.",
178                 what, alreadyunlocked ? "un" : "");
179 #else
180             You("ã©\82ð\8aO\82µ\82½\81D%s\82Í\8c®\82ª%s\82Ü\82Ü\82¾\81D",
181                 what, alreadyunlocked ? "\8aJ\82¢\82½" : "\82©\82©\82Á\82½");
182 #endif
183             exercise(A_WIS, TRUE);
184         } else {
185 /*JP
186             You("stop %s.", lock_action());
187 */
188             You("%s\82Ì\82ð\82â\82ß\82½\81D", lock_action());
189             exercise(A_WIS, FALSE);
190         }
191         return ((xlock.usedtime = 0));
192     }
193
194 /*JP
195     You("succeed in %s.", lock_action());
196 */
197     You("%s\82Ì\82É\90¬\8c÷\82µ\82½\81D", lock_action());
198     if (xlock.door) {
199         if (xlock.door->doormask & D_TRAPPED) {
200 /*JP
201             b_trapped("door", FINGER);
202 */
203             b_trapped("\94à", FINGER);
204             xlock.door->doormask = D_NODOOR;
205             unblock_point(u.ux + u.dx, u.uy + u.dy);
206             if (*in_rooms(u.ux + u.dx, u.uy + u.dy, SHOPBASE))
207                 add_damage(u.ux + u.dx, u.uy + u.dy, SHOP_DOOR_COST);
208             newsym(u.ux + u.dx, u.uy + u.dy);
209         } else if (xlock.door->doormask & D_LOCKED)
210             xlock.door->doormask = D_CLOSED;
211         else
212             xlock.door->doormask = D_LOCKED;
213     } else {
214         xlock.box->olocked = !xlock.box->olocked;
215         xlock.box->lknown = 1;
216         if (xlock.box->otrapped)
217             (void) chest_trap(xlock.box, FINGER, FALSE);
218     }
219     exercise(A_DEX, TRUE);
220     return ((xlock.usedtime = 0));
221 }
222
223 void
224 breakchestlock(box, destroyit)
225 struct obj *box;
226 boolean destroyit;
227 {
228     if (!destroyit) { /* bill for the box but not for its contents */
229         struct obj *hide_contents = box->cobj;
230
231         box->cobj = 0;
232         costly_alteration(box, COST_BRKLCK);
233         box->cobj = hide_contents;
234         box->olocked = 0;
235         box->obroken = 1;
236         box->lknown = 1;
237     } else { /* #force has destroyed this box (at <u.ux,u.uy>) */
238         struct obj *otmp;
239         struct monst *shkp = (*u.ushops && costly_spot(u.ux, u.uy))
240                                  ? shop_keeper(*u.ushops)
241                                  : 0;
242         boolean costly = (boolean) (shkp != 0),
243                 peaceful_shk = costly && (boolean) shkp->mpeaceful;
244         long loss = 0L;
245
246 /*JP
247         pline("In fact, you've totally destroyed %s.", the(xname(box)));
248 */
249         pline("\8eÀ\8dÛ\82Ì\82Æ\82±\82ë\81C%s\82ð\8a®\91S\82É\89ó\82µ\82Ä\82µ\82Ü\82Á\82½\81D", xname(xlock.box));
250         /* Put the contents on ground at the hero's feet. */
251         while ((otmp = box->cobj) != 0) {
252             obj_extract_self(otmp);
253             if (!rn2(3) || otmp->oclass == POTION_CLASS) {
254                 chest_shatter_msg(otmp);
255                 if (costly)
256                     loss +=
257                         stolen_value(otmp, u.ux, u.uy, peaceful_shk, TRUE);
258                 if (otmp->quan == 1L) {
259                     obfree(otmp, (struct obj *) 0);
260                     continue;
261                 }
262                 useup(otmp);
263             }
264             if (box->otyp == ICE_BOX && otmp->otyp == CORPSE) {
265                 otmp->age = monstermoves - otmp->age; /* actual age */
266                 start_corpse_timeout(otmp);
267             }
268             place_object(otmp, u.ux, u.uy);
269             stackobj(otmp);
270         }
271         if (costly)
272             loss += stolen_value(box, u.ux, u.uy, peaceful_shk, TRUE);
273         if (loss)
274 /*JP
275             You("owe %ld %s for objects destroyed.", loss, currency(loss));
276 */
277             You("\8aí\95¨\94j\91¹\82Å%ld%s\82Ì\8eØ\82è\82ð\82Â\82­\82Á\82½\81D", loss, currency(loss));
278         delobj(box);
279     }
280 }
281
282 /* try to force a locked chest */
283 STATIC_PTR int
284 forcelock(VOID_ARGS)
285 {
286     if ((xlock.box->ox != u.ux) || (xlock.box->oy != u.uy))
287         return ((xlock.usedtime = 0)); /* you or it moved */
288
289     if (xlock.usedtime++ >= 50 || !uwep || nohands(youmonst.data)) {
290 /*JP
291         You("give up your attempt to force the lock.");
292 */
293         pline("\8c®\82ð\82±\82\8aJ\82¯\82é\82Ì\82ð\82 \82«\82ç\82ß\82½\81D");
294         if (xlock.usedtime >= 50) /* you made the effort */
295             exercise((xlock.picktyp) ? A_DEX : A_STR, TRUE);
296         return ((xlock.usedtime = 0));
297     }
298
299     if (xlock.picktyp) { /* blade */
300         if (rn2(1000 - (int) uwep->spe) > (992 - greatest_erosion(uwep) * 10)
301             && !uwep->cursed && !obj_resists(uwep, 0, 99)) {
302             /* for a +0 weapon, probability that it survives an unsuccessful
303              * attempt to force the lock is (.992)^50 = .67
304              */
305 #if 0 /*JP*/
306             pline("%sour %s broke!", (uwep->quan > 1L) ? "One of y" : "Y",
307                   xname(uwep));
308 #else
309             pline("%s\82Í\89ó\82ê\82Ä\82µ\82Ü\82Á\82½\81I",xname(uwep));
310 #endif
311             useup(uwep);
312 /*JP
313             You("give up your attempt to force the lock.");
314 */
315             pline("\8c®\82ð\82±\82\8aJ\82¯\82é\82Ì\82ð\82 \82«\82ç\82ß\82½\81D");
316             exercise(A_DEX, TRUE);
317             return ((xlock.usedtime = 0));
318         }
319     } else             /* blunt */
320         wake_nearby(); /* due to hammering on the container */
321
322     if (rn2(100) >= xlock.chance)
323         return 1; /* still busy */
324
325 /*JP
326     You("succeed in forcing the lock.");
327 */
328     pline("\8c®\82ð\82±\82\8aJ\82¯\82½\81D");
329     breakchestlock(xlock.box, (boolean) (!xlock.picktyp && !rn2(3)));
330
331     exercise((xlock.picktyp) ? A_DEX : A_STR, TRUE);
332     return ((xlock.usedtime = 0));
333 }
334
335 void
336 reset_pick()
337 {
338     xlock.usedtime = xlock.chance = xlock.picktyp = 0;
339     xlock.magic_key = FALSE;
340     xlock.door = 0;
341     xlock.box = 0;
342 }
343
344 /* level change; don't reset if hero is carrying xlock.box with him/her */
345 void
346 maybe_reset_pick()
347 {
348     if (!xlock.box || !carried(xlock.box))
349         reset_pick();
350 }
351
352 /* for doapply(); if player gives a direction or resumes an interrupted
353    previous attempt then it costs hero a move even if nothing ultimately
354    happens; when told "can't do that" before being asked for direction
355    or player cancels with ESC while giving direction, it doesn't */
356 #define PICKLOCK_LEARNED_SOMETHING (-1) /* time passes */
357 #define PICKLOCK_DID_NOTHING 0          /* no time passes */
358 #define PICKLOCK_DID_SOMETHING 1
359
360 /* player is applying a key, lock pick, or credit card */
361 int
362 pick_lock(pick)
363 struct obj *pick;
364 {
365     int picktyp, c, ch;
366     coord cc;
367     struct rm *door;
368     struct obj *otmp;
369     char qbuf[QBUFSZ];
370
371     picktyp = pick->otyp;
372
373     /* check whether we're resuming an interrupted previous attempt */
374     if (xlock.usedtime && picktyp == xlock.picktyp) {
375 /*JP
376         static char no_longer[] = "Unfortunately, you can no longer %s %s.";
377 */
378         static char no_longer[] = "\82´\82ñ\82Ë\82ñ\82È\82ª\82ç\81C\82 \82È\82½\82Í%s%s";
379
380         if (nohands(youmonst.data)) {
381 /*JP
382             const char *what = (picktyp == LOCK_PICK) ? "pick" : "key";
383 */
384             const char *what = (picktyp == LOCK_PICK) ? "\8c®\8aJ\82¯\8aí\8bï" : "\8c®";
385
386             if (picktyp == CREDIT_CARD)
387 /*JP
388                 what = "card";
389 */
390                 what = "\83J\81[\83h";
391 /*JP
392             pline(no_longer, "hold the", what);
393 */
394             pline(no_longer, what, "\82ð\82Â\82©\82ß\82È\82¢");
395             reset_pick();
396             return PICKLOCK_LEARNED_SOMETHING;
397         } else if (u.uswallow || (xlock.box && !can_reach_floor(TRUE))) {
398 /*JP
399             pline(no_longer, "reach the", "lock");
400 */
401             pline(no_longer, "\8c®\82É", "\93Í\82©\82È\82¢");
402             reset_pick();
403             return PICKLOCK_LEARNED_SOMETHING;
404         } else {
405             const char *action = lock_action();
406
407 /*JP
408             You("resume your attempt at %s.", action);
409 */
410             pline("%s\82Ì\82ð\8dÄ\8aJ\82µ\82½\81D", action);
411             xlock.magic_key = is_magic_key(&youmonst, pick);
412             set_occupation(picklock, action, 0);
413             return PICKLOCK_DID_SOMETHING;
414         }
415     }
416
417     if (nohands(youmonst.data)) {
418 /*JP
419         You_cant("hold %s -- you have no hands!", doname(pick));
420 */
421         You("%s\82ð\82Â\82©\82Þ\82±\82Æ\82ª\82Å\82«\82È\82¢\81I\8eè\82ª\82È\82¢\82ñ\82¾\82à\82Ì\81I", xname(pick));
422         return PICKLOCK_DID_NOTHING;
423     } else if (u.uswallow) {
424 #if 0 /*JP*/
425         You_cant("%sunlock %s.", (picktyp == CREDIT_CARD) ? "" : "lock or ",
426                  mon_nam(u.ustuck));
427 #else
428         You_cant("%s\82ð%s\82È\82¢\81D", mon_nam(u.ustuck),
429                  (picktyp == CREDIT_CARD) ? "\8aJ\82¯\82ç\82ê" : "\8aJ\82¯\95Â\82ß\82Å\82«");
430 #endif
431         return PICKLOCK_DID_NOTHING;
432     }
433
434     if (picktyp != LOCK_PICK
435         && picktyp != CREDIT_CARD
436         && picktyp != SKELETON_KEY) {
437         impossible("picking lock with object %d?", picktyp);
438         return PICKLOCK_DID_NOTHING;
439     }
440     ch = 0; /* lint suppression */
441
442 /*JP
443     if (!get_adjacent_loc((char *) 0, "Invalid location!", u.ux, u.uy, &cc))
444 */
445     if (!get_adjacent_loc((char *) 0, "\88Ê\92u\82ª\82¨\82©\82µ\82¢\81I", u.ux, u.uy, &cc))
446         return PICKLOCK_DID_NOTHING;
447
448     if (cc.x == u.ux && cc.y == u.uy) { /* pick lock on a container */
449         const char *verb;
450         char qsfx[QBUFSZ];
451 #if 0 /*JP*/
452         boolean it;
453 #endif
454         int count;
455
456         if (u.dz < 0) {
457 #if 0 /*JP*/
458             There("isn't any sort of lock up %s.",
459                   Levitation ? "here" : "there");
460 #else
461             pline("%s\82É\82Í\8c®\82ð\82©\82¯\82é\82æ\82¤\82È\95¨\82Í\82È\82¢\81D",
462                   Levitation ? "\82±\82±" : "\89º\95û");
463 #endif
464             return PICKLOCK_LEARNED_SOMETHING;
465         } else if (is_lava(u.ux, u.uy)) {
466 /*JP
467             pline("Doing that would probably melt %s.", yname(pick));
468 */
469             pline("\82»\82ñ\82È\82±\82Æ\82ð\82µ\82½\82ç%s\82ª\97n\82¯\82Ä\82µ\82Ü\82¤\81D", yname(pick));
470             return PICKLOCK_LEARNED_SOMETHING;
471         } else if (is_pool(u.ux, u.uy) && !Underwater) {
472 /*JP
473             pline_The("%s has no lock.", hliquid("water"));
474 */
475             pline_The("%s\82É\8fù\91O\82Í\82È\82¢\81D", hliquid("\90\85"));
476             return PICKLOCK_LEARNED_SOMETHING;
477         }
478
479         count = 0;
480         c = 'n'; /* in case there are no boxes here */
481         for (otmp = level.objects[cc.x][cc.y]; otmp; otmp = otmp->nexthere)
482             if (Is_box(otmp)) {
483                 ++count;
484                 if (!can_reach_floor(TRUE)) {
485 /*JP
486                     You_cant("reach %s from up here.", the(xname(otmp)));
487 */
488                     You("\82±\82±\82©\82ç%s\82É\93Í\82©\82È\82¢\81D", the(xname(otmp)));
489                     return PICKLOCK_LEARNED_SOMETHING;
490                 }
491 #if 0 /*JP*/
492                 it = 0;
493 #endif
494                 if (otmp->obroken)
495 /*JP
496                     verb = "fix";
497 */
498                     verb = "\8fC\95\9c\82·\82é";
499                 else if (!otmp->olocked)
500 /*JP
501                     verb = "lock", it = 1;
502 */
503                     verb = "\8c®\82ð\82©\82¯\82é";
504                 else if (picktyp != LOCK_PICK)
505 /*JP
506                     verb = "unlock", it = 1;
507 */
508                     verb = "\8c®\82ð\82Í\82¸\82·";
509                 else
510 /*JP
511                     verb = "pick";
512 */
513                     verb = "\82±\82\82 \82¯\82é";
514
515                 /* "There is <a box> here; <verb> <it|its lock>?" */
516 /*JP
517                 Sprintf(qsfx, " here; %s %s?", verb, it ? "it" : "its lock");
518 */
519                 Sprintf(qsfx, "\82ª\82 \82é\81D%s\81H", verb);
520 #if 0 /*JP*/
521                 (void) safe_qbuf(qbuf, "There is ", qsfx, otmp, doname,
522                                  ansimpleoname, "a box");
523 #else
524                 (void) safe_qbuf(qbuf, "\82±\82±\82É\82Í", qsfx, otmp, doname,
525                                  ansimpleoname, "\94 ");
526 #endif
527                 otmp->lknown = 1;
528
529                 c = ynq(qbuf);
530                 if (c == 'q')
531                     return 0;
532                 if (c == 'n')
533                     continue;
534
535                 if (otmp->obroken) {
536 /*JP
537                     You_cant("fix its broken lock with %s.", doname(pick));
538 */
539                     You("\89ó\82ê\82½\8c®\82ð%s\82Å\8fC\95\9c\82Å\82«\82È\82¢\81D", doname(pick));
540                     return PICKLOCK_LEARNED_SOMETHING;
541                 } else if (picktyp == CREDIT_CARD && !otmp->olocked) {
542                     /* credit cards are only good for unlocking */
543 #if 0 /*JP*/
544                     You_cant("do that with %s.",
545                              an(simple_typename(picktyp)));
546 #else
547                     pline("%s\82\82á\82»\82ñ\82È\82±\82Æ\82Í\82Å\82«\82È\82¢\81D",
548                           simple_typename(picktyp));
549 #endif
550                     return PICKLOCK_LEARNED_SOMETHING;
551                 }
552                 switch (picktyp) {
553                 case CREDIT_CARD:
554                     ch = ACURR(A_DEX) + 20 * Role_if(PM_ROGUE);
555                     break;
556                 case LOCK_PICK:
557                     ch = 4 * ACURR(A_DEX) + 25 * Role_if(PM_ROGUE);
558                     break;
559                 case SKELETON_KEY:
560                     ch = 75 + ACURR(A_DEX);
561                     break;
562                 default:
563                     ch = 0;
564                 }
565                 if (otmp->cursed)
566                     ch /= 2;
567
568                 xlock.box = otmp;
569                 xlock.door = 0;
570                 break;
571             }
572         if (c != 'y') {
573             if (!count)
574 /*JP
575                 There("doesn't seem to be any sort of lock here.");
576 */
577                 pline("\82±\82±\82É\82Í\8c®\82ð\82©\82¯\82é\82æ\82¤\82È\95¨\82Í\82È\82¢\82æ\82¤\82¾\81D");
578             return PICKLOCK_LEARNED_SOMETHING; /* decided against all boxes */
579         }
580     } else { /* pick the lock in a door */
581         struct monst *mtmp;
582
583         if (u.utrap && u.utraptype == TT_PIT) {
584 /*JP
585             You_cant("reach over the edge of the pit.");
586 */
587             pline("\97\8e\82µ\8c\8a\82Ì\92\86\82©\82ç\82Å\82Í\93Í\82©\82È\82¢\81D");
588             return PICKLOCK_LEARNED_SOMETHING;
589         }
590
591         door = &levl[cc.x][cc.y];
592         mtmp = m_at(cc.x, cc.y);
593         if (mtmp && canseemon(mtmp) && mtmp->m_ap_type != M_AP_FURNITURE
594             && mtmp->m_ap_type != M_AP_OBJECT) {
595             if (picktyp == CREDIT_CARD
596                 && (mtmp->isshk || mtmp->data == &mons[PM_ORACLE]))
597 /*JP
598                 verbalize("No checks, no credit, no problem.");
599 */
600                 verbalize("\82¢\82Â\82à\83j\83R\83j\83R\8c»\8bà\95¥\82¢\81D");
601             else
602 #if 0 /*JP*/
603                 pline("I don't think %s would appreciate that.",
604                       mon_nam(mtmp));
605 #else
606                 pline("%s\82ª\82»\82Ì\89¿\92l\82ð\94F\82ß\82é\82Æ\82Í\8ev\82¦\82È\82¢\81D", mon_nam(mtmp));
607 #endif
608             return PICKLOCK_LEARNED_SOMETHING;
609         } else if (mtmp && is_door_mappear(mtmp)) {
610             /* "The door actually was a <mimic>!" */
611             stumble_onto_mimic(mtmp);
612             /* mimic might keep the key (50% chance, 10% for PYEC or MKoT) */
613             maybe_absorb_item(mtmp, pick, 50, 10);
614             return PICKLOCK_LEARNED_SOMETHING;
615         }
616         if (!IS_DOOR(door->typ)) {
617             if (is_drawbridge_wall(cc.x, cc.y) >= 0)
618 /*JP
619                 You("%s no lock on the drawbridge.", Blind ? "feel" : "see");
620 */
621                 pline("\92µ\82Ë\8b´\82É\82Í\8c®\82ª\82È\82¢%s\81D", Blind ? "\82æ\82¤\82¾" : "\82æ\82¤\82É\8c©\82¦\82é");
622             else
623 /*JP
624                 You("%s no door there.", Blind ? "feel" : "see");
625 */
626                 pline("\82±\82±\82É\82Í\94à\82ª\82È\82¢%s\81D", Blind ? "\82æ\82¤\82¾" : "\82æ\82¤\82É\8c©\82¦\82é");
627             return PICKLOCK_LEARNED_SOMETHING;
628         }
629         switch (door->doormask) {
630         case D_NODOOR:
631 /*JP
632             pline("This doorway has no door.");
633 */
634             pline("\82±\82Ì\8fo\93ü\8cû\82É\82Í\94à\82ª\82È\82¢\81D");
635             return PICKLOCK_LEARNED_SOMETHING;
636         case D_ISOPEN:
637 /*JP
638             You("cannot lock an open door.");
639 */
640             pline("\8aJ\82¢\82Ä\82é\94à\82É\82Í\8c®\82ð\82©\82¯\82ç\82ê\82È\82¢\81D");
641             return PICKLOCK_LEARNED_SOMETHING;
642         case D_BROKEN:
643 /*JP
644             pline("This door is broken.");
645 */
646             pline("\82±\82Ì\94à\82Í\89ó\82ê\82Ä\82¢\82é\81D");
647             return PICKLOCK_LEARNED_SOMETHING;
648         default:
649             /* credit cards are only good for unlocking */
650             if (picktyp == CREDIT_CARD && !(door->doormask & D_LOCKED)) {
651 /*JP
652                 You_cant("lock a door with a credit card.");
653 */
654                 You("\83N\83\8c\83W\83b\83g\83J\81[\83h\82Å\94à\82É\8c®\82ð\82©\82¯\82é\82±\82Æ\82Í\82Å\82«\82È\82¢\81D");
655                 return PICKLOCK_LEARNED_SOMETHING;
656             }
657
658 #if 0 /*JP*/
659             Sprintf(qbuf, "%s it?",
660                     (door->doormask & D_LOCKED) ? "Unlock" : "Lock");
661 #else
662             Sprintf(qbuf, "%s\82Ü\82·\82©\81H",
663                     (door->doormask & D_LOCKED) ? "\82Í\82¸\82µ" : "\82©\82¯" );
664 #endif
665
666             c = yn(qbuf);
667             if (c == 'n')
668                 return 0;
669
670             switch (picktyp) {
671             case CREDIT_CARD:
672                 ch = 2 * ACURR(A_DEX) + 20 * Role_if(PM_ROGUE);
673                 break;
674             case LOCK_PICK:
675                 ch = 3 * ACURR(A_DEX) + 30 * Role_if(PM_ROGUE);
676                 break;
677             case SKELETON_KEY:
678                 ch = 70 + ACURR(A_DEX);
679                 break;
680             default:
681                 ch = 0;
682             }
683             xlock.door = door;
684             xlock.box = 0;
685         }
686     }
687     context.move = 0;
688     xlock.chance = ch;
689     xlock.picktyp = picktyp;
690     xlock.magic_key = is_magic_key(&youmonst, pick);
691     xlock.usedtime = 0;
692     set_occupation(picklock, lock_action(), 0);
693     return PICKLOCK_DID_SOMETHING;
694 }
695
696 /* try to force a chest with your weapon */
697 int
698 doforce()
699 {
700     register struct obj *otmp;
701     register int c, picktyp;
702     char qbuf[QBUFSZ];
703
704     if (u.uswallow) {
705 /*JP
706         You_cant("force anything from inside here.");
707 */
708         You_cant("\93à\91¤\82©\82ç\82±\82\8aJ\82¯\82é\82±\82Æ\82Í\82Å\82«\82È\82¢\81D");
709         return 0;
710     }
711     if (!uwep /* proper type test */
712         || ((uwep->oclass == WEAPON_CLASS || is_weptool(uwep))
713                ? (objects[uwep->otyp].oc_skill < P_DAGGER
714                   || objects[uwep->otyp].oc_skill == P_FLAIL
715                   || objects[uwep->otyp].oc_skill > P_LANCE)
716                : uwep->oclass != ROCK_CLASS)) {
717 #if 0 /*JP*/
718         You_cant("force anything %s weapon.",
719                  !uwep ? "when not wielding a"
720                        : (uwep->oclass != WEAPON_CLASS && !is_weptool(uwep))
721                              ? "without a proper"
722                              : "with that");
723 #else
724         You_cant("%s\95\90\8aí\82È\82µ\82Å\8c®\82ð\82±\82\8aJ\82¯\82é\82±\82Æ\82Í\82Å\82«\82È\82¢\81D",
725                  !uwep ? "\91\95\94õ\82µ\82Ä\82¢\82é"
726                        : (uwep->oclass != WEAPON_CLASS && !is_weptool(uwep))
727                              ? "\93K\90Ø\82È"
728                              : "");
729 #endif
730         return 0;
731     }
732     if (!can_reach_floor(TRUE)) {
733         cant_reach_floor(u.ux, u.uy, FALSE, TRUE);
734         return 0;
735     }
736
737     picktyp = is_blade(uwep) && !is_pick(uwep);
738     if (xlock.usedtime && xlock.box && picktyp == xlock.picktyp) {
739 /*JP
740         You("resume your attempt to force the lock.");
741 */
742         pline("\8c®\82ð\82±\82\82 \82¯\82é\82Ì\82ð\8dÄ\8aJ\82µ\82½\81D");
743 /*JP
744         set_occupation(forcelock, "forcing the lock", 0);
745 */
746         set_occupation(forcelock, "\8c®\82ð\82±\82\82 \82¯\82é", 0);
747         return 1;
748     }
749
750     /* A lock is made only for the honest man, the thief will break it. */
751     xlock.box = (struct obj *) 0;
752     for (otmp = level.objects[u.ux][u.uy]; otmp; otmp = otmp->nexthere)
753         if (Is_box(otmp)) {
754             if (otmp->obroken || !otmp->olocked) {
755                 /* force doname() to omit known "broken" or "unlocked"
756                    prefix so that the message isn't worded redundantly;
757                    since we're about to set lknown, there's no need to
758                    remember and then reset its current value */
759                 otmp->lknown = 0;
760 #if 0 /*JP*/
761                 There("is %s here, but its lock is already %s.",
762                       doname(otmp), otmp->obroken ? "broken" : "unlocked");
763 #else
764                 pline("\82±\82±\82É\82Í%s\82ª\82 \82é\81D\82µ\82©\82µ\82»\82Ì\8c®\82Í\82à\82¤%s\81D",
765                       doname(otmp),
766                       otmp->obroken ? "\89ó\82ê\82Ä\82¢\82é" : "\82Í\82¸\82³\82ê\82Ä\82¢\82é");
767 #endif
768                 otmp->lknown = 1;
769                 continue;
770             }
771 #if 0 /*JP*/
772             (void) safe_qbuf(qbuf, "There is ", " here; force its lock?",
773                              otmp, doname, ansimpleoname, "a box");
774 #else
775             (void) safe_qbuf(qbuf, "\82±\82±\82É\82Í", "\82ª\82 \82é\81D\8c®\82ð\82±\82\8aJ\82¯\82Ü\82·\82©\81H",
776                              otmp, doname, ansimpleoname, "\94 ");
777 #endif
778             otmp->lknown = 1;
779
780             c = ynq(qbuf);
781             if (c == 'q')
782                 return 0;
783             if (c == 'n')
784                 continue;
785
786             if (picktyp)
787 /*JP
788                 You("force %s into a crack and pry.", yname(uwep));
789 */
790                 You("%s\82ð\82·\82«\8aÔ\82É\8d·\82µ\82±\82ñ\82Å\82±\82\82 \82¯\82æ\82¤\82Æ\82µ\82½\81D",xname(uwep));
791             else
792 /*JP
793                 You("start bashing it with %s.", yname(uwep));
794 */
795                 pline("%s\82Å\89£\82è\82Â\82¯\82½\81D", xname(uwep));
796             xlock.box = otmp;
797             xlock.chance = objects[uwep->otyp].oc_wldam * 2;
798             xlock.picktyp = picktyp;
799             xlock.magic_key = FALSE;
800             xlock.usedtime = 0;
801             break;
802         }
803
804     if (xlock.box)
805 /*JP
806         set_occupation(forcelock, "forcing the lock", 0);
807 */
808         set_occupation(forcelock, "\8c®\82ð\82±\82\82 \82¯\82é", 0);
809     else
810 /*JP
811         You("decide not to force the issue.");
812 */
813         pline("\82»\82ê\82Í\96³\88Ó\96¡\82È\8ds\88×\82¾\81D");
814     return 1;
815 }
816
817 boolean
818 stumble_on_door_mimic(x, y)
819 int x, y;
820 {
821     struct monst *mtmp;
822
823     if ((mtmp = m_at(x, y)) && is_door_mappear(mtmp)
824         && !Protection_from_shape_changers) {
825         stumble_onto_mimic(mtmp);
826         return TRUE;
827     }
828     return FALSE;
829 }
830
831 /* the 'O' command - try to open a door */
832 int
833 doopen()
834 {
835     return doopen_indir(0, 0);
836 }
837
838 /* try to open a door in direction u.dx/u.dy */
839 int
840 doopen_indir(x, y)
841 int x, y;
842 {
843     coord cc;
844     register struct rm *door;
845     boolean portcullis;
846     int res = 0;
847
848     if (nohands(youmonst.data)) {
849 /*JP
850         You_cant("open anything -- you have no hands!");
851 */
852         You("\89½\82à\8aJ\82¯\82é\82±\82Æ\82ª\82Å\82«\82È\82¢\81I\8eè\82ª\82È\82¢\82ñ\82¾\82à\82Ì\81I");
853         return 0;
854     }
855
856     if (u.utrap && u.utraptype == TT_PIT) {
857 /*JP
858         You_cant("reach over the edge of the pit.");
859 */
860         pline("\97\8e\82µ\8c\8a\82Ì\92\86\82©\82ç\93Í\82©\82È\82¢\81D");
861         return 0;
862     }
863
864     if (x > 0 && y > 0) {
865         cc.x = x;
866         cc.y = y;
867     } else if (!get_adjacent_loc((char *) 0, (char *) 0, u.ux, u.uy, &cc))
868         return 0;
869
870     /* open at yourself/up/down */
871     if ((cc.x == u.ux) && (cc.y == u.uy))
872         return doloot();
873
874     if (stumble_on_door_mimic(cc.x, cc.y))
875         return 1;
876
877     /* when choosing a direction is impaired, use a turn
878        regardless of whether a door is successfully targetted */
879     if (Confusion || Stunned)
880         res = 1;
881
882     door = &levl[cc.x][cc.y];
883     portcullis = (is_drawbridge_wall(cc.x, cc.y) >= 0);
884     if (Blind) {
885         int oldglyph = door->glyph;
886         schar oldlastseentyp = lastseentyp[cc.x][cc.y];
887
888         feel_location(cc.x, cc.y);
889         if (door->glyph != oldglyph
890             || lastseentyp[cc.x][cc.y] != oldlastseentyp)
891             res = 1; /* learned something */
892     }
893
894     if (portcullis || !IS_DOOR(door->typ)) {
895         /* closed portcullis or spot that opened bridge would span */
896         if (is_db_wall(cc.x, cc.y) || door->typ == DRAWBRIDGE_UP)
897 /*JP
898             There("is no obvious way to open the drawbridge.");
899 */
900             pline("\92µ\82Ë\8b´\82ð\8d~\82ë\82·\96¾\94\92\82È\95û\96@\82Í\82È\82¢\81D");
901         else if (portcullis || door->typ == DRAWBRIDGE_DOWN)
902 /*JP
903             pline_The("drawbridge is already open.");
904 */
905             pline_The("\92µ\82Ë\8b´\82Í\82à\82¤\8aJ\82¢\82Ä\82¢\82é\81D");
906         else if (container_at(cc.x, cc.y, TRUE))
907 #if 0 /*JP*/
908             pline("%s like something lootable over there.",
909                   Blind ? "Feels" : "Seems");
910 #else
911             pline("\82±\82±\82É\82Í\89½\82©\93ü\82ê\95¨\82ª\82 \82é\82æ\82¤\82¾\81D");
912 #endif
913         else
914 /*JP
915             You("%s no door there.", Blind ? "feel" : "see");
916 */
917             pline("\82»\82±\82É\82Í\94à\82Í\82È\82¢\82æ\82¤%s\81D", Blind ? "\82¾" : "\82É\8c©\82¦\82é");
918         return res;
919     }
920
921     if (!(door->doormask & D_CLOSED)) {
922         const char *mesg;
923
924         switch (door->doormask) {
925         case D_BROKEN:
926 /*JP
927             mesg = " is broken";
928 */
929             mesg = "\94à\82Í\89ó\82ê\82Ä\82¢\82é";
930             break;
931         case D_NODOOR:
932 /*JP
933             mesg = "way has no door";
934 */
935             mesg = "\8fo\93ü\8cû\82É\82Í\94à\82ª\82È\82¢";
936             break;
937         case D_ISOPEN:
938 /*JP
939             mesg = " is already open";
940 */
941             mesg = "\94à\82Í\82à\82¤\8aJ\82¢\82Ä\82¢\82é";
942             break;
943         default:
944 /*JP
945             mesg = " is locked";
946 */
947             mesg = "\94à\82É\82Í\8c®\82ª\8a|\82©\82Á\82Ä\82¢\82é";
948             break;
949         }
950 /*JP
951         pline("This door%s.", mesg);
952 */
953         pline("%s\81D", mesg);
954         return res;
955     }
956
957     if (verysmall(youmonst.data)) {
958 /*JP
959         pline("You're too small to pull the door open.");
960 */
961         You("\94à\82ð\89\9f\82·\82É\82Í\8f¬\82³\82·\82¬\82é\81D");
962         return res;
963     }
964
965     /* door is known to be CLOSED */
966     if (rnl(20) < (ACURRSTR + ACURR(A_DEX) + ACURR(A_CON)) / 3) {
967 /*JP
968         pline_The("door opens.");
969 */
970         pline("\94à\82Í\8aJ\82¢\82½\81D");
971         if (door->doormask & D_TRAPPED) {
972 /*JP
973             b_trapped("door", FINGER);
974 */
975             b_trapped("\94à", FINGER);
976             door->doormask = D_NODOOR;
977             if (*in_rooms(cc.x, cc.y, SHOPBASE))
978                 add_damage(cc.x, cc.y, SHOP_DOOR_COST);
979         } else
980             door->doormask = D_ISOPEN;
981         feel_newsym(cc.x, cc.y); /* the hero knows she opened it */
982         unblock_point(cc.x, cc.y); /* vision: new see through there */
983     } else {
984         exercise(A_STR, TRUE);
985 /*JP
986         pline_The("door resists!");
987 */
988         pline("\82È\82©\82È\82©\8aJ\82©\82È\82¢\81I");
989     }
990
991     return 1;
992 }
993
994 STATIC_OVL boolean
995 obstructed(x, y, quietly)
996 register int x, y;
997 boolean quietly;
998 {
999     register struct monst *mtmp = m_at(x, y);
1000
1001     if (mtmp && mtmp->m_ap_type != M_AP_FURNITURE) {
1002         if (mtmp->m_ap_type == M_AP_OBJECT)
1003             goto objhere;
1004         if (!quietly) {
1005             if ((mtmp->mx != x) || (mtmp->my != y)) {
1006                 /* worm tail */
1007 #if 0 /*JP*/
1008                 pline("%s%s blocks the way!",
1009                       !canspotmon(mtmp) ? Something : s_suffix(Monnam(mtmp)),
1010                       !canspotmon(mtmp) ? "" : " tail");
1011 #else
1012                 pline("%s%s\82ª\97§\82¿\82Ó\82³\82ª\82Á\82Ä\82¢\82é\81I",
1013                       !canspotmon(mtmp) ? "\89½\82©" : Monnam(mtmp),
1014                       !canspotmon(mtmp) ? "" : "\82Ì\90K\94ö");
1015 #endif
1016             } else {
1017 #if 0 /*JP*/
1018                 pline("%s blocks the way!",
1019                       !canspotmon(mtmp) ? "Some creature" : Monnam(mtmp));
1020 #else
1021                 pline("%s\82ª\97§\82¿\82Ó\82³\82ª\82Á\82Ä\82¢\82é\81I",
1022                       !canspotmon(mtmp) ? "\89½\8eÒ\82©" : Monnam(mtmp));
1023 #endif
1024             }
1025         }
1026         if (!canspotmon(mtmp))
1027             map_invisible(x, y);
1028         return TRUE;
1029     }
1030     if (OBJ_AT(x, y)) {
1031     objhere:
1032         if (!quietly)
1033 /*JP
1034             pline("%s's in the way.", Something);
1035 */
1036             pline("\89½\82©\82ª\8fo\93ü\8cû\82É\82 \82é\81D");
1037         return TRUE;
1038     }
1039     return FALSE;
1040 }
1041
1042 /* the 'C' command - try to close a door */
1043 int
1044 doclose()
1045 {
1046     register int x, y;
1047     register struct rm *door;
1048     boolean portcullis;
1049     int res = 0;
1050
1051     if (nohands(youmonst.data)) {
1052 /*JP
1053         You_cant("close anything -- you have no hands!");
1054 */
1055         You("\95Â\82ß\82é\82±\82Æ\82ª\82Å\82«\82È\82¢\81I\8eè\82ª\82È\82¢\82ñ\82¾\82à\82Ì\81I");
1056         return 0;
1057     }
1058
1059     if (u.utrap && u.utraptype == TT_PIT) {
1060 /*JP
1061         You_cant("reach over the edge of the pit.");
1062 */
1063         pline("\97\8e\82µ\8c\8a\82Ì\92\86\82©\82ç\93Í\82©\82È\82¢\81D");
1064         return 0;
1065     }
1066
1067     if (!getdir((char *) 0))
1068         return 0;
1069
1070     x = u.ux + u.dx;
1071     y = u.uy + u.dy;
1072     if ((x == u.ux) && (y == u.uy)) {
1073 /*JP
1074         You("are in the way!");
1075 */
1076         pline("\82 \82È\82½\82ª\8fo\93ü\8cû\82É\82¢\82é\82Ì\82Å\95Â\82Ü\82ç\82È\82¢\81I");
1077         return 1;
1078     }
1079
1080     if (!isok(x, y))
1081         goto nodoor;
1082
1083     if (stumble_on_door_mimic(x, y))
1084         return 1;
1085
1086     /* when choosing a direction is impaired, use a turn
1087        regardless of whether a door is successfully targetted */
1088     if (Confusion || Stunned)
1089         res = 1;
1090
1091     door = &levl[x][y];
1092     portcullis = (is_drawbridge_wall(x, y) >= 0);
1093     if (Blind) {
1094         int oldglyph = door->glyph;
1095         schar oldlastseentyp = lastseentyp[x][y];
1096
1097         feel_location(x, y);
1098         if (door->glyph != oldglyph || lastseentyp[x][y] != oldlastseentyp)
1099             res = 1; /* learned something */
1100     }
1101
1102     if (portcullis || !IS_DOOR(door->typ)) {
1103         /* is_db_wall: closed portcullis */
1104         if (is_db_wall(x, y) || door->typ == DRAWBRIDGE_UP)
1105 /*JP
1106             pline_The("drawbridge is already closed.");
1107 */
1108             pline_The("\92µ\82Ë\8b´\82Í\82à\82¤\95Â\82\82Ä\82¢\82é\81D");
1109         else if (portcullis || door->typ == DRAWBRIDGE_DOWN)
1110 /*JP
1111             There("is no obvious way to close the drawbridge.");
1112 */
1113             pline("\92µ\82Ë\8b´\82ð\95Â\82ß\82é\96¾\94\92\82È\95û\96@\82Í\82È\82¢\81D");
1114         else {
1115         nodoor:
1116 /*JP
1117             You("%s no door there.", Blind ? "feel" : "see");
1118 */
1119             pline("\82»\82±\82É\94à\82Í\82È\82¢\82æ\82¤%s\81D", Blind ? "\82¾" : "\82É\8c©\82¦\82é");
1120         }
1121         return res;
1122     }
1123
1124     if (door->doormask == D_NODOOR) {
1125 /*JP
1126         pline("This doorway has no door.");
1127 */
1128         pline("\8fo\93ü\8cû\82É\82Í\94à\82ª\82È\82¢\81D");
1129         return res;
1130     } else if (obstructed(x, y, FALSE)) {
1131         return res;
1132     } else if (door->doormask == D_BROKEN) {
1133 /*JP
1134         pline("This door is broken.");
1135 */
1136         pline("\94à\82Í\89ó\82ê\82Ä\82¢\82é\81D");
1137         return res;
1138     } else if (door->doormask & (D_CLOSED | D_LOCKED)) {
1139 /*JP
1140         pline("This door is already closed.");
1141 */
1142         pline("\94à\82Í\82à\82¤\95Â\82\82Ä\82¢\82é\81D");
1143         return res;
1144     }
1145
1146     if (door->doormask == D_ISOPEN) {
1147         if (verysmall(youmonst.data) && !u.usteed) {
1148 /*JP
1149             pline("You're too small to push the door closed.");
1150 */
1151             You("\8f¬\82³\82·\82¬\82Ä\94à\82ð\95Â\82ß\82ç\82ê\82È\82¢\81D");
1152             return res;
1153         }
1154         if (u.usteed
1155             || rn2(25) < (ACURRSTR + ACURR(A_DEX) + ACURR(A_CON)) / 3) {
1156 /*JP
1157             pline_The("door closes.");
1158 */
1159             pline("\94à\82Í\95Â\82\82½\81D");
1160             door->doormask = D_CLOSED;
1161             feel_newsym(x, y); /* the hero knows she closed it */
1162             block_point(x, y); /* vision:  no longer see there */
1163         } else {
1164             exercise(A_STR, TRUE);
1165 /*JP
1166             pline_The("door resists!");
1167 */
1168             pline("\82È\82©\82È\82©\95Â\82Ü\82ç\82È\82¢\81I");
1169         }
1170     }
1171
1172     return 1;
1173 }
1174
1175 /* box obj was hit with spell or wand effect otmp;
1176    returns true if something happened */
1177 boolean
1178 boxlock(obj, otmp)
1179 struct obj *obj, *otmp; /* obj *is* a box */
1180 {
1181     boolean res = 0;
1182
1183     switch (otmp->otyp) {
1184     case WAN_LOCKING:
1185     case SPE_WIZARD_LOCK:
1186         if (!obj->olocked) { /* lock it; fix if broken */
1187 /*JP
1188             pline("Klunk!");
1189 */
1190             pline("\83J\83`\81I");
1191             obj->olocked = 1;
1192             obj->obroken = 0;
1193             if (Role_if(PM_WIZARD))
1194                 obj->lknown = 1;
1195             else
1196                 obj->lknown = 0;
1197             res = 1;
1198         } /* else already closed and locked */
1199         break;
1200     case WAN_OPENING:
1201     case SPE_KNOCK:
1202         if (obj->olocked) { /* unlock; couldn't be broken */
1203 /*JP
1204             pline("Klick!");
1205 */
1206             pline("\83R\83\93\83R\83\93\81I");
1207             obj->olocked = 0;
1208             res = 1;
1209             if (Role_if(PM_WIZARD))
1210                 obj->lknown = 1;
1211             else
1212                 obj->lknown = 0;
1213         } else /* silently fix if broken */
1214             obj->obroken = 0;
1215         break;
1216     case WAN_POLYMORPH:
1217     case SPE_POLYMORPH:
1218         /* maybe start unlocking chest, get interrupted, then zap it;
1219            we must avoid any attempt to resume unlocking it */
1220         if (xlock.box == obj)
1221             reset_pick();
1222         break;
1223     }
1224     return res;
1225 }
1226
1227 /* Door/secret door was hit with spell or wand effect otmp;
1228    returns true if something happened */
1229 boolean
1230 doorlock(otmp, x, y)
1231 struct obj *otmp;
1232 int x, y;
1233 {
1234     register struct rm *door = &levl[x][y];
1235     boolean res = TRUE;
1236     int loudness = 0;
1237     const char *msg = (const char *) 0;
1238 /*JP
1239     const char *dustcloud = "A cloud of dust";
1240 */
1241     const char *dustcloud = "\82Ù\82±\82è";
1242 /*JP
1243     const char *quickly_dissipates = "quickly dissipates";
1244 */
1245     const char *quickly_dissipates = "\82 \82Á\82Æ\8c¾\82¤\82Ü\82É\94ò\82Ñ\8eU\82Á\82½";
1246     boolean mysterywand = (otmp->oclass == WAND_CLASS && !otmp->dknown);
1247
1248     if (door->typ == SDOOR) {
1249         switch (otmp->otyp) {
1250         case WAN_OPENING:
1251         case SPE_KNOCK:
1252         case WAN_STRIKING:
1253         case SPE_FORCE_BOLT:
1254             door->typ = DOOR;
1255             door->doormask = D_CLOSED | (door->doormask & D_TRAPPED);
1256             newsym(x, y);
1257             if (cansee(x, y))
1258 /*JP
1259                 pline("A door appears in the wall!");
1260 */
1261                 pline("\95Ç\82©\82ç\94à\82ª\8c»\82ê\82½\81I");
1262             if (otmp->otyp == WAN_OPENING || otmp->otyp == SPE_KNOCK)
1263                 return TRUE;
1264             break; /* striking: continue door handling below */
1265         case WAN_LOCKING:
1266         case SPE_WIZARD_LOCK:
1267         default:
1268             return FALSE;
1269         }
1270     }
1271
1272     switch (otmp->otyp) {
1273     case WAN_LOCKING:
1274     case SPE_WIZARD_LOCK:
1275         if (Is_rogue_level(&u.uz)) {
1276             boolean vis = cansee(x, y);
1277             /* Can't have real locking in Rogue, so just hide doorway */
1278             if (vis)
1279 /*JP
1280                 pline("%s springs up in the older, more primitive doorway.",
1281 */
1282                 pline("\8cÃ\82­\82³\82¢\81C\8c´\8en\93I\82È\8fo\93ü\8cû\82É%s\82ª\97§\82¿\82±\82ß\82½\81D",
1283                       dustcloud);
1284             else
1285 /*JP
1286                 You_hear("a swoosh.");
1287 */
1288                 You_hear("\83V\83\85\81[\83b\82Æ\82¢\82¤\89¹\82ð\95·\82¢\82½\81D");
1289             if (obstructed(x, y, mysterywand)) {
1290                 if (vis)
1291 /*JP
1292                     pline_The("cloud %s.", quickly_dissipates);
1293 */
1294                     pline("\82Ù\82±\82è\82Í%s\81D",quickly_dissipates);
1295                 return FALSE;
1296             }
1297             block_point(x, y);
1298             door->typ = SDOOR;
1299             if (vis)
1300 /*JP
1301                 pline_The("doorway vanishes!");
1302 */
1303                 pline("\8fo\93ü\8cû\82Í\8fÁ\82¦\82½\81I");
1304             newsym(x, y);
1305             return TRUE;
1306         }
1307         if (obstructed(x, y, mysterywand))
1308             return FALSE;
1309         /* Don't allow doors to close over traps.  This is for pits */
1310         /* & trap doors, but is it ever OK for anything else? */
1311         if (t_at(x, y)) {
1312             /* maketrap() clears doormask, so it should be NODOOR */
1313 #if 0 /*JP*/
1314             pline("%s springs up in the doorway, but %s.", dustcloud,
1315                   quickly_dissipates);
1316 #else
1317             pline("%s\82ª\8fo\93ü\8cû\82É\97§\82¿\82±\82ß\82½\81C\82µ\82©\82µ%s", dustcloud,
1318                   quickly_dissipates);
1319 #endif
1320             return FALSE;
1321         }
1322
1323         switch (door->doormask & ~D_TRAPPED) {
1324         case D_CLOSED:
1325 /*JP
1326             msg = "The door locks!";
1327 */
1328                 msg = "\94à\82É\8c®\82ª\82©\82©\82Á\82½\81I";
1329             break;
1330         case D_ISOPEN:
1331 /*JP
1332             msg = "The door swings shut, and locks!";
1333 */
1334             msg = "\94à\82Í\90¨\82¢\82æ\82­\95Â\82Ü\82è\81C\8c®\82ª\82©\82©\82Á\82½\81I";
1335             break;
1336         case D_BROKEN:
1337 /*JP
1338             msg = "The broken door reassembles and locks!";
1339 */
1340             msg = "\89ó\82ê\82½\94à\82ª\8dÄ\8d\\90¬\82³\82ê\81C\8c®\82ª\82©\82©\82Á\82½\81I";
1341             break;
1342         case D_NODOOR:
1343             msg =
1344 /*JP
1345                "A cloud of dust springs up and assembles itself into a door!";
1346 */
1347                 "\82Ù\82±\82è\82ª\82½\82¿\82±\82ß\81C\8fW\82Ü\82Á\82Ä\94à\82É\82È\82Á\82½\81I";
1348             break;
1349         default:
1350             res = FALSE;
1351             break;
1352         }
1353         block_point(x, y);
1354         door->doormask = D_LOCKED | (door->doormask & D_TRAPPED);
1355         newsym(x, y);
1356         break;
1357     case WAN_OPENING:
1358     case SPE_KNOCK:
1359         if (door->doormask & D_LOCKED) {
1360 /*JP
1361             msg = "The door unlocks!";
1362 */
1363             msg = "\94à\82Ì\8c®\82Í\82Í\82¸\82ê\82½\81I";
1364             door->doormask = D_CLOSED | (door->doormask & D_TRAPPED);
1365         } else
1366             res = FALSE;
1367         break;
1368     case WAN_STRIKING:
1369     case SPE_FORCE_BOLT:
1370         if (door->doormask & (D_LOCKED | D_CLOSED)) {
1371             if (door->doormask & D_TRAPPED) {
1372                 if (MON_AT(x, y))
1373                     (void) mb_trapped(m_at(x, y));
1374                 else if (flags.verbose) {
1375                     if (cansee(x, y))
1376 /*JP
1377                         pline("KABOOM!!  You see a door explode.");
1378 */
1379                         pline("\82¿\82ã\82Ç\81[\82ñ\81I\94à\82ª\94\9a\94­\82µ\82½\81D");
1380                     else
1381 /*JP
1382                         You_hear("a distant explosion.");
1383 */
1384                         You_hear("\89\93\82­\82Ì\94\9a\94­\89¹\82ð\95·\82¢\82½\81D");
1385                 }
1386                 door->doormask = D_NODOOR;
1387                 unblock_point(x, y);
1388                 newsym(x, y);
1389                 loudness = 40;
1390                 break;
1391             }
1392             door->doormask = D_BROKEN;
1393             if (flags.verbose) {
1394                 if (cansee(x, y))
1395 /*JP
1396                     pline_The("door crashes open!");
1397 */
1398                     pline("\94à\82Í\89ó\82ê\8aJ\82¢\82½\81I");
1399                 else
1400 /*JP
1401                     You_hear("a crashing sound.");
1402 */
1403                     You_hear("\89½\82©\82ª\89ó\82ê\82é\89¹\82ð\95·\82¢\82½\81D");
1404             }
1405             unblock_point(x, y);
1406             newsym(x, y);
1407             /* force vision recalc before printing more messages */
1408             if (vision_full_recalc)
1409                 vision_recalc(0);
1410             loudness = 20;
1411         } else
1412             res = FALSE;
1413         break;
1414     default:
1415         impossible("magic (%d) attempted on door.", otmp->otyp);
1416         break;
1417     }
1418     if (msg && cansee(x, y))
1419         pline1(msg);
1420     if (loudness > 0) {
1421         /* door was destroyed */
1422         wake_nearto(x, y, loudness);
1423         if (*in_rooms(x, y, SHOPBASE))
1424             add_damage(x, y, 0L);
1425     }
1426
1427     if (res && picking_at(x, y)) {
1428         /* maybe unseen monster zaps door you're unlocking */
1429         stop_occupation();
1430         reset_pick();
1431     }
1432     return res;
1433 }
1434
1435 STATIC_OVL void
1436 chest_shatter_msg(otmp)
1437 struct obj *otmp;
1438 {
1439     const char *disposition;
1440     const char *thing;
1441     long save_Blinded;
1442
1443     if (otmp->oclass == POTION_CLASS) {
1444 #if 0 /*JP*/
1445         You("%s %s shatter!", Blind ? "hear" : "see", an(bottlename()));
1446 #else
1447         if (Blind)
1448             You_hear("%s\82ª\8a\84\82ê\82é\89¹\82ð\95·\82¢\82½\81I", bottlename());
1449         else
1450             pline("%s\82ª\8a\84\82ê\82½\81I", bottlename());
1451 #endif
1452         if (!breathless(youmonst.data) || haseyes(youmonst.data))
1453             potionbreathe(otmp);
1454         return;
1455     }
1456     /* We have functions for distant and singular names, but not one */
1457     /* which does _both_... */
1458     save_Blinded = Blinded;
1459     Blinded = 1;
1460     thing = singular(otmp, xname);
1461     Blinded = save_Blinded;
1462     switch (objects[otmp->otyp].oc_material) {
1463     case PAPER:
1464 /*JP
1465         disposition = "is torn to shreds";
1466 */
1467         disposition = "\82Í\90¡\92f\82³\82ê\82½";
1468         break;
1469     case WAX:
1470 /*JP
1471         disposition = "is crushed";
1472 */
1473         disposition = "\82ð\8f°\82É\82Ô\82¿\82Ü\82¯\82½";
1474         break;
1475     case VEGGY:
1476 /*JP
1477         disposition = "is pulped";
1478 */
1479         disposition = "\82Í\82Ç\82ë\82Ç\82ë\82É\82È\82Á\82½";
1480         break;
1481     case FLESH:
1482 /*JP
1483         disposition = "is mashed";
1484 */
1485         disposition = "\82Í\82Ç\82ë\82Ç\82ë\82É\82È\82Á\82½";
1486         break;
1487     case GLASS:
1488 /*JP
1489         disposition = "shatters";
1490 */
1491         disposition = "\82Í\8a\84\82ê\82½";
1492         break;
1493     case WOOD:
1494 /*JP
1495         disposition = "splinters to fragments";
1496 */
1497         disposition = "\82Í\82©\82¯\82ç\82É\82È\82Á\82½";
1498         break;
1499     default:
1500 /*JP
1501         disposition = "is destroyed";
1502 */
1503         disposition = "\82Í\89ó\82ê\82½";
1504         break;
1505     }
1506 /*JP
1507     pline("%s %s!", An(thing), disposition);
1508 */
1509     pline("%s%s\81I", thing, disposition);
1510 }
1511
1512 /*lock.c*/