OSDN Git Service

update year to 2018
[jnethack/source.git] / src / do_wear.c
1 /* NetHack 3.6  do_wear.c       $NHDT-Date: 1514072526 2017/12/23 23:42:06 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.100 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /*-Copyright (c) Robert Patrick Rankin, 2012. */
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-2018            */
9 /* JNetHack may be freely redistributed.  See license for details. */
10
11 #include "hack.h"
12
13 #if 0 /*JP*//*\96¢\8eg\97p*/
14 static NEARDATA const char see_yourself[] = "see yourself";
15 #endif
16 static NEARDATA const char unknown_type[] = "Unknown type of %s (%d)";
17 #if 0 /*JP*/
18 static NEARDATA const char c_armor[] = "armor", c_suit[] = "suit",
19                            c_shirt[] = "shirt", c_cloak[] = "cloak",
20                            c_gloves[] = "gloves", c_boots[] = "boots",
21                            c_helmet[] = "helmet", c_shield[] = "shield",
22                            c_weapon[] = "weapon", c_sword[] = "sword",
23                            c_axe[] = "axe", c_that_[] = "that";
24 #else
25 static NEARDATA const char c_armor[]  = "\8aZ", c_suit[]   = "\95\9e",
26                            c_shirt[]  = "\83V\83\83\83c", c_cloak[]  = "\83N\83\8d\81[\83N",
27                            c_gloves[] = "\8f¬\8eè", c_boots[]  = "\8cC",
28                            c_helmet[] = "\8a\95", c_shield[] = "\8f\82",
29                            c_weapon[] = "\95\90\8aí", c_sword[]  = "\8c\95",
30                            c_axe[]    = "\95\80", c_that_[]  = "\82»\82ê";
31 #endif
32
33 static NEARDATA const long takeoff_order[] = {
34     WORN_BLINDF, W_WEP,      WORN_SHIELD, WORN_GLOVES, LEFT_RING,
35     RIGHT_RING,  WORN_CLOAK, WORN_HELMET, WORN_AMUL,   WORN_ARMOR,
36     WORN_SHIRT,  WORN_BOOTS, W_SWAPWEP,   W_QUIVER,    0L
37 };
38
39 STATIC_DCL void FDECL(on_msg, (struct obj *));
40 STATIC_DCL void FDECL(toggle_stealth, (struct obj *, long, BOOLEAN_P));
41 STATIC_DCL void FDECL(toggle_displacement, (struct obj *, long, BOOLEAN_P));
42 STATIC_PTR int NDECL(Armor_on);
43 /* int NDECL(Boots_on); -- moved to extern.h */
44 STATIC_PTR int NDECL(Cloak_on);
45 STATIC_PTR int NDECL(Helmet_on);
46 STATIC_PTR int NDECL(Gloves_on);
47 STATIC_DCL void FDECL(wielding_corpse, (struct obj *, BOOLEAN_P));
48 STATIC_PTR int NDECL(Shield_on);
49 STATIC_PTR int NDECL(Shirt_on);
50 STATIC_DCL void NDECL(Amulet_on);
51 STATIC_DCL void FDECL(learnring, (struct obj *, BOOLEAN_P));
52 STATIC_DCL void FDECL(Ring_off_or_gone, (struct obj *, BOOLEAN_P));
53 STATIC_PTR int FDECL(select_off, (struct obj *));
54 STATIC_DCL struct obj *NDECL(do_takeoff);
55 STATIC_PTR int NDECL(take_off);
56 STATIC_DCL int FDECL(menu_remarm, (int));
57 STATIC_DCL void FDECL(count_worn_stuff, (struct obj **, BOOLEAN_P));
58 STATIC_PTR int FDECL(armor_or_accessory_off, (struct obj *));
59 STATIC_PTR int FDECL(accessory_or_armor_on, (struct obj *));
60 #if 0 /*JP*/
61 STATIC_DCL void FDECL(already_wearing, (const char *));
62 #else
63 STATIC_DCL void FDECL(already_wearing, (const char*, struct obj *));
64 #endif
65 STATIC_DCL void FDECL(already_wearing2, (const char *, const char *));
66
67 void
68 off_msg(otmp)
69 struct obj *otmp;
70 {
71 #if 0 /*JP*/
72     if (flags.verbose)
73         You("were wearing %s.", doname(otmp));
74 #else
75     const char *j;
76     const char *m;
77     m = joffmsg(otmp, &j);
78     if(flags.verbose)
79         You("%s%s%s\81D", doname(otmp), j, jpast(m));
80 #endif
81 }
82
83 /* for items that involve no delay */
84 STATIC_OVL void
85 on_msg(otmp)
86 struct obj *otmp;
87 {
88     if (flags.verbose) {
89 #if 0 /*JP*/
90         char how[BUFSZ];
91         /* call xname() before obj_is_pname(); formatting obj's name
92            might set obj->dknown and that affects the pname test */
93         const char *otmp_name = xname(otmp);
94
95         how[0] = '\0';
96         if (otmp->otyp == TOWEL)
97             Sprintf(how, " around your %s", body_part(HEAD));
98         You("are now wearing %s%s.",
99             obj_is_pname(otmp) ? the(otmp_name) : an(otmp_name), how);
100 #else
101         const char *j;
102         const char *m;
103         m = jonmsg(otmp, &j);
104         You("%s%s%s\81D", xname(otmp), j, jpast(m));
105 #endif
106     }
107 }
108
109 /* starting equipment gets auto-worn at beginning of new game,
110    and we don't want stealth or displacement feedback then */
111 static boolean initial_don = FALSE; /* manipulated in set_wear() */
112
113 /* putting on or taking off an item which confers stealth;
114    give feedback and discover it iff stealth state is changing */
115 STATIC_OVL
116 void
117 toggle_stealth(obj, oldprop, on)
118 struct obj *obj;
119 long oldprop; /* prop[].extrinsic, with obj->owornmask stripped by caller */
120 boolean on;
121 {
122     if (on ? initial_don : context.takeoff.cancelled_don)
123         return;
124
125     if (!oldprop /* extrinsic stealth from something else */
126         && !HStealth /* intrinsic stealth */
127         && !BStealth) { /* stealth blocked by something */
128         if (obj->otyp == RIN_STEALTH)
129             learnring(obj, TRUE);
130         else
131             makeknown(obj->otyp);
132
133         if (on) {
134             if (!is_boots(obj))
135 /*JP
136                 You("move very quietly.");
137 */
138                 Your("\90Ã\82©\82É\93®\82¯\82é\82æ\82¤\82É\82È\82Á\82½\81D");
139             else if (Levitation || Flying)
140 /*JP
141                 You("float imperceptibly.");
142 */
143                 You("\82¢\82Â\82Ì\82Ü\82É\82©\95\82\82¢\82Ä\82¢\82½\81D");
144             else
145 /*JP
146                 You("walk very quietly.");
147 */
148                 Your("\91«\89¹\82Í\8f¬\82³\82­\82È\82Á\82½\81D");
149         } else {
150 /*JP
151             You("sure are noisy.");
152 */
153             Your("\91«\89¹\82Í\91å\82«\82­\82È\82Á\82½\81D");
154         }
155     }
156 }
157
158 /* putting on or taking off an item which confers displacement;
159    give feedback and discover it iff displacement state is changing *and*
160    hero is able to see self (or sense monsters) */
161 STATIC_OVL
162 void
163 toggle_displacement(obj, oldprop, on)
164 struct obj *obj;
165 long oldprop; /* prop[].extrinsic, with obj->owornmask stripped by caller */
166 boolean on;
167 {
168     if (on ? initial_don : context.takeoff.cancelled_don)
169         return;
170
171     if (!oldprop /* extrinsic displacement from something else */
172         && !(u.uprops[DISPLACED].intrinsic) /* (theoretical) */
173         && !(u.uprops[DISPLACED].blocked) /* (also theoretical) */
174         /* we don't use canseeself() here because it augments vision
175            with touch, which isn't appropriate for deciding whether
176            we'll notice that monsters have trouble spotting the hero */
177         && ((!Blind         /* see anything */
178              && !u.uswallow /* see surroundings */
179              && !Invisible) /* see self */
180             /* actively sensing nearby monsters via telepathy or extended
181                monster detection overrides vision considerations because
182                hero also senses self in this situation */
183             || (Unblind_telepat
184                 || (Blind_telepat && Blind)
185                 || Detect_monsters))) {
186         makeknown(obj->otyp);
187
188 #if 0 /*JP*/
189         You_feel("that monsters%s have difficulty pinpointing your location.",
190                  on ? "" : " no longer");
191 #else
192         You_feel("\89ö\95¨\82Í\82 \82È\82½\82Ì\88Ê\92u\82ª\82Í\82Á\82«\82è\82Æ\95ª\82©%s\82È\82Á\82½\82æ\82¤\82¾\81D",
193                  on ? "\82ç\82È\82­" : "\82é\82æ\82¤\82É");
194 #endif
195     }
196 }
197
198 /*
199  * The Type_on() functions should be called *after* setworn().
200  * The Type_off() functions call setworn() themselves.
201  * [Blindf_on() is an exception and calls setworn() itself.]
202  */
203
204 int
205 Boots_on(VOID_ARGS)
206 {
207     long oldprop =
208         u.uprops[objects[uarmf->otyp].oc_oprop].extrinsic & ~WORN_BOOTS;
209
210     switch (uarmf->otyp) {
211     case LOW_BOOTS:
212     case IRON_SHOES:
213     case HIGH_BOOTS:
214     case JUMPING_BOOTS:
215     case KICKING_BOOTS:
216         break;
217     case WATER_WALKING_BOOTS:
218         if (u.uinwater)
219             spoteffects(TRUE);
220         /* (we don't need a lava check here since boots can't be
221            put on while feet are stuck) */
222         break;
223     case SPEED_BOOTS:
224         /* Speed boots are still better than intrinsic speed, */
225         /* though not better than potion speed */
226         if (!oldprop && !(HFast & TIMEOUT)) {
227             makeknown(uarmf->otyp);
228 #if 0 /*JP*/
229             You_feel("yourself speed up%s.",
230                      (oldprop || HFast) ? " a bit more" : "");
231 #else
232             You("%s\91f\91\81\82­\82È\82Á\82½\82æ\82¤\82È\8bC\82ª\82µ\82½\81D",
233                      (oldprop  || HFast) ? "\82³\82ç\82É" : "");
234 #endif
235         }
236         break;
237     case ELVEN_BOOTS:
238         toggle_stealth(uarmf, oldprop, TRUE);
239         break;
240     case FUMBLE_BOOTS:
241         if (!oldprop && !(HFumbling & ~TIMEOUT))
242             incr_itimeout(&HFumbling, rnd(20));
243         break;
244     case LEVITATION_BOOTS:
245         if (!oldprop && !HLevitation && !BLevitation) {
246             makeknown(uarmf->otyp);
247             float_up();
248             spoteffects(FALSE);
249         } else {
250             float_vs_flight(); /* maybe toggle (BFlying & I_SPECIAL) */
251         }
252         break;
253     default:
254         impossible(unknown_type, c_boots, uarmf->otyp);
255     }
256     return 0;
257 }
258
259 int
260 Boots_off(VOID_ARGS)
261 {
262     struct obj *otmp = uarmf;
263     int otyp = otmp->otyp;
264     long oldprop = u.uprops[objects[otyp].oc_oprop].extrinsic & ~WORN_BOOTS;
265
266     context.takeoff.mask &= ~W_ARMF;
267     /* For levitation, float_down() returns if Levitation, so we
268      * must do a setworn() _before_ the levitation case.
269      */
270     setworn((struct obj *) 0, W_ARMF);
271     switch (otyp) {
272     case SPEED_BOOTS:
273         if (!Very_fast && !context.takeoff.cancelled_don) {
274             makeknown(otyp);
275 /*JP
276             You_feel("yourself slow down%s.", Fast ? " a bit" : "");
277 */
278             You("%s\82Ì\82ë\82­\82È\82Á\82½\82æ\82¤\82È\8bC\82ª\82µ\82½\81D", Fast ? "\82¿\82å\82Á\82Æ" : "");
279         }
280         break;
281     case WATER_WALKING_BOOTS:
282         /* check for lava since fireproofed boots make it viable */
283         if ((is_pool(u.ux, u.uy) || is_lava(u.ux, u.uy))
284             && !Levitation && !Flying && !is_clinger(youmonst.data)
285             && !context.takeoff.cancelled_don
286             /* avoid recursive call to lava_effects() */
287             && !iflags.in_lava_effects) {
288             /* make boots known in case you survive the drowning */
289             makeknown(otyp);
290             spoteffects(TRUE);
291         }
292         break;
293     case ELVEN_BOOTS:
294         toggle_stealth(otmp, oldprop, FALSE);
295         break;
296     case FUMBLE_BOOTS:
297         if (!oldprop && !(HFumbling & ~TIMEOUT))
298             HFumbling = EFumbling = 0;
299         break;
300     case LEVITATION_BOOTS:
301         if (!oldprop && !HLevitation && !BLevitation
302             && !context.takeoff.cancelled_don) {
303             (void) float_down(0L, 0L);
304             makeknown(otyp);
305         } else {
306             float_vs_flight(); /* maybe toggle (BFlying & I_SPECIAL) */
307         }
308         break;
309     case LOW_BOOTS:
310     case IRON_SHOES:
311     case HIGH_BOOTS:
312     case JUMPING_BOOTS:
313     case KICKING_BOOTS:
314         break;
315     default:
316         impossible(unknown_type, c_boots, otyp);
317     }
318     context.takeoff.cancelled_don = FALSE;
319     return 0;
320 }
321
322 STATIC_PTR int
323 Cloak_on(VOID_ARGS)
324 {
325     long oldprop =
326         u.uprops[objects[uarmc->otyp].oc_oprop].extrinsic & ~WORN_CLOAK;
327
328     switch (uarmc->otyp) {
329     case ORCISH_CLOAK:
330     case DWARVISH_CLOAK:
331     case CLOAK_OF_MAGIC_RESISTANCE:
332     case ROBE:
333     case LEATHER_CLOAK:
334         break;
335     case CLOAK_OF_PROTECTION:
336         makeknown(uarmc->otyp);
337         break;
338     case ELVEN_CLOAK:
339         toggle_stealth(uarmc, oldprop, TRUE);
340         break;
341     case CLOAK_OF_DISPLACEMENT:
342         toggle_displacement(uarmc, oldprop, TRUE);
343         break;
344     case MUMMY_WRAPPING:
345         /* Note: it's already being worn, so we have to cheat here. */
346         if ((HInvis || EInvis) && !Blind) {
347             newsym(u.ux, u.uy);
348 #if 0 /*JP*/
349             You("can %s!", See_invisible ? "no longer see through yourself"
350                                          : see_yourself);
351 #else
352             pline("%s\81I",
353                   See_invisible ? "\82 \82È\82½\82Í\93§\96¾\82Å\82È\82­\82È\82Á\82½" :
354                   "\8e©\95ª\8e©\90g\82ª\8c©\82¦\82é\82æ\82¤\82É\82È\82Á\82½");
355 #endif
356         }
357         break;
358     case CLOAK_OF_INVISIBILITY:
359         /* since cloak of invisibility was worn, we know mummy wrapping
360            wasn't, so no need to check `oldprop' against blocked */
361         if (!oldprop && !HInvis && !Blind) {
362             makeknown(uarmc->otyp);
363             newsym(u.ux, u.uy);
364 #if 0 /*JP*/
365             pline("Suddenly you can%s yourself.",
366                   See_invisible ? " see through" : "not see");
367 #else
368             pline("\93Ë\91R\81C%s\82È\82Á\82½\81D",
369                   See_invisible ? "\82 \82È\82½\82Í\93§\96¾\82É" : "\8e©\95ª\8e©\90g\82ª\8c©\82¦\82È\82­");
370 #endif
371         }
372         break;
373     case OILSKIN_CLOAK:
374 /*JP
375         pline("%s very tightly.", Tobjnam(uarmc, "fit"));
376 */
377         pline("%s\82Í\82Æ\82Ä\82à\82Ò\82Á\82¿\82è\8d\87\82¤\81D",xname(uarmc));
378         break;
379     /* Alchemy smock gives poison _and_ acid resistance */
380     case ALCHEMY_SMOCK:
381         EAcid_resistance |= WORN_CLOAK;
382         break;
383     default:
384         impossible(unknown_type, c_cloak, uarmc->otyp);
385     }
386     return 0;
387 }
388
389 int
390 Cloak_off(VOID_ARGS)
391 {
392     struct obj *otmp = uarmc;
393     int otyp = otmp->otyp;
394     long oldprop = u.uprops[objects[otyp].oc_oprop].extrinsic & ~WORN_CLOAK;
395
396     context.takeoff.mask &= ~W_ARMC;
397     /* For mummy wrapping, taking it off first resets `Invisible'. */
398     setworn((struct obj *) 0, W_ARMC);
399     switch (otyp) {
400     case ORCISH_CLOAK:
401     case DWARVISH_CLOAK:
402     case CLOAK_OF_PROTECTION:
403     case CLOAK_OF_MAGIC_RESISTANCE:
404     case OILSKIN_CLOAK:
405     case ROBE:
406     case LEATHER_CLOAK:
407         break;
408     case ELVEN_CLOAK:
409         toggle_stealth(otmp, oldprop, FALSE);
410         break;
411     case CLOAK_OF_DISPLACEMENT:
412         toggle_displacement(otmp, oldprop, FALSE);
413         break;
414     case MUMMY_WRAPPING:
415         if (Invis && !Blind) {
416             newsym(u.ux, u.uy);
417 #if 0 /*JP*/
418             You("can %s.", See_invisible ? "see through yourself"
419                                          : "no longer see yourself");
420 #else
421             pline("%s\81D", See_invisible ? "\82 \82È\82½\82Í\93§\96¾\82É\82È\82Á\82½"
422                                         : "\8e©\95ª\8e©\90g\82ª\8c©\82¦\82È\82­\82È\82Á\82½");
423 #endif
424         }
425         break;
426     case CLOAK_OF_INVISIBILITY:
427         if (!oldprop && !HInvis && !Blind) {
428             makeknown(CLOAK_OF_INVISIBILITY);
429             newsym(u.ux, u.uy);
430 #if 0 /*JP*/
431             pline("Suddenly you can %s.",
432                   See_invisible ? "no longer see through yourself"
433                                 : see_yourself);
434 #else
435             pline("\93Ë\91R\81C%s\81D",
436                   See_invisible ? "\82 \82È\82½\82Í\93§\96¾\82Å\82È\82­\82È\82Á\82½"
437                                 : "\8e©\95ª\8e©\90g\82ª\8c©\82¦\82é\82æ\82¤\82É\82È\82Á\82½");
438 #endif
439         }
440         break;
441     /* Alchemy smock gives poison _and_ acid resistance */
442     case ALCHEMY_SMOCK:
443         EAcid_resistance &= ~WORN_CLOAK;
444         break;
445     default:
446         impossible(unknown_type, c_cloak, otyp);
447     }
448     return 0;
449 }
450
451 STATIC_PTR
452 int
453 Helmet_on(VOID_ARGS)
454 {
455     switch (uarmh->otyp) {
456     case FEDORA:
457     case HELMET:
458     case DENTED_POT:
459     case ELVEN_LEATHER_HELM:
460     case DWARVISH_IRON_HELM:
461     case ORCISH_HELM:
462     case HELM_OF_TELEPATHY:
463         break;
464     case HELM_OF_BRILLIANCE:
465         adj_abon(uarmh, uarmh->spe);
466         break;
467     case CORNUTHAUM:
468         /* people think marked wizards know what they're talking
469          * about, but it takes trained arrogance to pull it off,
470          * and the actual enchantment of the hat is irrelevant.
471          */
472         ABON(A_CHA) += (Role_if(PM_WIZARD) ? 1 : -1);
473         context.botl = 1;
474         makeknown(uarmh->otyp);
475         break;
476     case HELM_OF_OPPOSITE_ALIGNMENT:
477         /* changing alignment can toggle off active artifact
478            properties, including levitation; uarmh could get
479            dropped or destroyed here */
480         uchangealign((u.ualign.type != A_NEUTRAL)
481                          ? -u.ualign.type
482                          : (uarmh->o_id % 2) ? A_CHAOTIC : A_LAWFUL,
483                      1);
484     /* makeknown(uarmh->otyp);   -- moved below, after xname() */
485     /*FALLTHRU*/
486     case DUNCE_CAP:
487         if (uarmh && !uarmh->cursed) {
488             if (Blind)
489 /*JP
490                 pline("%s for a moment.", Tobjnam(uarmh, "vibrate"));
491 */
492                 pline("%s\82Í\88ê\8fu\90k\82¦\82½\81D", xname(uarmh));
493             else
494 #if 0 /*JP*/
495                 pline("%s %s for a moment.", Tobjnam(uarmh, "glow"),
496                       hcolor(NH_BLACK));
497 #else
498                 pline("%s\82Í\88ê\8fu%s\8bP\82¢\82½\81D",
499                       xname(uarmh), jconj_adj(hcolor(NH_BLACK)));
500 #endif
501             curse(uarmh);
502         }
503         context.botl = 1; /* reveal new alignment or INT & WIS */
504         if (Hallucination) {
505 #if 0 /*JP*/
506             pline("My brain hurts!"); /* Monty Python's Flying Circus */
507 #else
508             pline("\82Ì\81[\82Ý\82»\83o\81[\83\93\81I"); /*\83\82\83\93\83e\83B\83p\83C\83\\83\93\82Æ\82Í\82¿\82å\82Á\82Æ\88á\82¤\82¯\82Ç*/
509 #endif
510         } else if (uarmh && uarmh->otyp == DUNCE_CAP) {
511 #if 0 /*JP*/
512             You_feel("%s.", /* track INT change; ignore WIS */
513                      ACURR(A_INT)
514                              <= (ABASE(A_INT) + ABON(A_INT) + ATEMP(A_INT))
515                          ? "like sitting in a corner"
516                          : "giddy");
517 #else
518             You("%s\82æ\82¤\82È\8bC\82ª\82µ\82½\81D",
519                      ACURR(A_INT)
520                              <= (ABASE(A_INT) + ABON(A_INT) + ATEMP(A_INT))
521                          ? "\8b÷\82Á\82±\82É\8dÀ\82Á\82Ä\82¢\82é"
522                          : "\96Ú\82ª\82Ü\82í\82Á\82½");
523 #endif
524         } else {
525             /* [message moved to uchangealign()] */
526             makeknown(HELM_OF_OPPOSITE_ALIGNMENT);
527         }
528         break;
529     default:
530         impossible(unknown_type, c_helmet, uarmh->otyp);
531     }
532     return 0;
533 }
534
535 int
536 Helmet_off(VOID_ARGS)
537 {
538     context.takeoff.mask &= ~W_ARMH;
539
540     switch (uarmh->otyp) {
541     case FEDORA:
542     case HELMET:
543     case DENTED_POT:
544     case ELVEN_LEATHER_HELM:
545     case DWARVISH_IRON_HELM:
546     case ORCISH_HELM:
547         break;
548     case DUNCE_CAP:
549         context.botl = 1;
550         break;
551     case CORNUTHAUM:
552         if (!context.takeoff.cancelled_don) {
553             ABON(A_CHA) += (Role_if(PM_WIZARD) ? -1 : 1);
554             context.botl = 1;
555         }
556         break;
557     case HELM_OF_TELEPATHY:
558         /* need to update ability before calling see_monsters() */
559         setworn((struct obj *) 0, W_ARMH);
560         see_monsters();
561         return 0;
562     case HELM_OF_BRILLIANCE:
563         if (!context.takeoff.cancelled_don)
564             adj_abon(uarmh, -uarmh->spe);
565         break;
566     case HELM_OF_OPPOSITE_ALIGNMENT:
567         /* changing alignment can toggle off active artifact
568            properties, including levitation; uarmh could get
569            dropped or destroyed here */
570         uchangealign(u.ualignbase[A_CURRENT], 2);
571         break;
572     default:
573         impossible(unknown_type, c_helmet, uarmh->otyp);
574     }
575     setworn((struct obj *) 0, W_ARMH);
576     context.takeoff.cancelled_don = FALSE;
577     return 0;
578 }
579
580 STATIC_PTR
581 int
582 Gloves_on(VOID_ARGS)
583 {
584     long oldprop =
585         u.uprops[objects[uarmg->otyp].oc_oprop].extrinsic & ~WORN_GLOVES;
586
587     switch (uarmg->otyp) {
588     case LEATHER_GLOVES:
589         break;
590     case GAUNTLETS_OF_FUMBLING:
591         if (!oldprop && !(HFumbling & ~TIMEOUT))
592             incr_itimeout(&HFumbling, rnd(20));
593         break;
594     case GAUNTLETS_OF_POWER:
595         makeknown(uarmg->otyp);
596         context.botl = 1; /* taken care of in attrib.c */
597         break;
598     case GAUNTLETS_OF_DEXTERITY:
599         adj_abon(uarmg, uarmg->spe);
600         break;
601     default:
602         impossible(unknown_type, c_gloves, uarmg->otyp);
603     }
604     return 0;
605 }
606
607 STATIC_OVL void
608 wielding_corpse(obj, voluntary)
609 struct obj *obj;
610 boolean voluntary; /* taking gloves off on purpose? */
611 {
612     char kbuf[BUFSZ];
613
614     if (!obj || obj->otyp != CORPSE)
615         return;
616     if (obj != uwep && (obj != uswapwep || !u.twoweap))
617         return;
618
619     if (touch_petrifies(&mons[obj->corpsenm]) && !Stone_resistance) {
620 #if 0 /*JP*/
621         You("now wield %s in your bare %s.",
622             corpse_xname(obj, (const char *) 0, CXN_ARTICLE),
623             makeplural(body_part(HAND)));
624 #else
625         You("%s\82ð\91f%s\82Å\8e\9d\82Á\82½\81D",
626             corpse_xname(obj, (const char *) 0, CXN_ARTICLE),
627             body_part(HAND));
628 #endif
629 #if 0 /*JP*/
630         Sprintf(kbuf, "%s gloves while wielding %s",
631                 voluntary ? "removing" : "losing", killer_xname(obj));
632 #else
633         Sprintf(kbuf, "%s\82ð\8e\9d\82Á\82Ä\82¢\82é\82Æ\82«\82É\8eè\91Ü\82ð%s",
634                 killer_xname(obj), voluntary ? "\8aO\82µ\82Ä" : "\8e¸\82Á\82Ä");
635 #endif
636         instapetrify(kbuf);
637         /* life-saved; can't continue wielding cockatrice corpse though */
638         remove_worn_item(obj, FALSE);
639     }
640 }
641
642 int
643 Gloves_off(VOID_ARGS)
644 {
645     long oldprop =
646         u.uprops[objects[uarmg->otyp].oc_oprop].extrinsic & ~WORN_GLOVES;
647     boolean on_purpose = !context.mon_moving && !uarmg->in_use;
648
649     context.takeoff.mask &= ~W_ARMG;
650
651     switch (uarmg->otyp) {
652     case LEATHER_GLOVES:
653         break;
654     case GAUNTLETS_OF_FUMBLING:
655         if (!oldprop && !(HFumbling & ~TIMEOUT))
656             HFumbling = EFumbling = 0;
657         break;
658     case GAUNTLETS_OF_POWER:
659         makeknown(uarmg->otyp);
660         context.botl = 1; /* taken care of in attrib.c */
661         break;
662     case GAUNTLETS_OF_DEXTERITY:
663         if (!context.takeoff.cancelled_don)
664             adj_abon(uarmg, -uarmg->spe);
665         break;
666     default:
667         impossible(unknown_type, c_gloves, uarmg->otyp);
668     }
669     setworn((struct obj *) 0, W_ARMG);
670     context.takeoff.cancelled_don = FALSE;
671     (void) encumber_msg(); /* immediate feedback for GoP */
672
673     /* prevent wielding cockatrice when not wearing gloves */
674     if (uwep && uwep->otyp == CORPSE)
675         wielding_corpse(uwep, on_purpose);
676
677     /* KMH -- ...or your secondary weapon when you're wielding it
678        [This case can't actually happen; twoweapon mode won't
679        engage if a corpse has been set up as the alternate weapon.] */
680     if (u.twoweap && uswapwep && uswapwep->otyp == CORPSE)
681         wielding_corpse(uswapwep, on_purpose);
682
683     return 0;
684 }
685
686 STATIC_PTR int
687 Shield_on(VOID_ARGS)
688 {
689     /* no shield currently requires special handling when put on, but we
690        keep this uncommented in case somebody adds a new one which does */
691     switch (uarms->otyp) {
692     case SMALL_SHIELD:
693     case ELVEN_SHIELD:
694     case URUK_HAI_SHIELD:
695     case ORCISH_SHIELD:
696     case DWARVISH_ROUNDSHIELD:
697     case LARGE_SHIELD:
698     case SHIELD_OF_REFLECTION:
699         break;
700     default:
701         impossible(unknown_type, c_shield, uarms->otyp);
702     }
703
704     return 0;
705 }
706
707 int
708 Shield_off(VOID_ARGS)
709 {
710     context.takeoff.mask &= ~W_ARMS;
711
712     /* no shield currently requires special handling when taken off, but we
713        keep this uncommented in case somebody adds a new one which does */
714     switch (uarms->otyp) {
715     case SMALL_SHIELD:
716     case ELVEN_SHIELD:
717     case URUK_HAI_SHIELD:
718     case ORCISH_SHIELD:
719     case DWARVISH_ROUNDSHIELD:
720     case LARGE_SHIELD:
721     case SHIELD_OF_REFLECTION:
722         break;
723     default:
724         impossible(unknown_type, c_shield, uarms->otyp);
725     }
726
727     setworn((struct obj *) 0, W_ARMS);
728     return 0;
729 }
730
731 STATIC_PTR int
732 Shirt_on(VOID_ARGS)
733 {
734     /* no shirt currently requires special handling when put on, but we
735        keep this uncommented in case somebody adds a new one which does */
736     switch (uarmu->otyp) {
737     case HAWAIIAN_SHIRT:
738     case T_SHIRT:
739         break;
740     default:
741         impossible(unknown_type, c_shirt, uarmu->otyp);
742     }
743
744     return 0;
745 }
746
747 int
748 Shirt_off(VOID_ARGS)
749 {
750     context.takeoff.mask &= ~W_ARMU;
751
752     /* no shirt currently requires special handling when taken off, but we
753        keep this uncommented in case somebody adds a new one which does */
754     switch (uarmu->otyp) {
755     case HAWAIIAN_SHIRT:
756     case T_SHIRT:
757         break;
758     default:
759         impossible(unknown_type, c_shirt, uarmu->otyp);
760     }
761
762     setworn((struct obj *) 0, W_ARMU);
763     return 0;
764 }
765
766 /* This must be done in worn.c, because one of the possible intrinsics
767  * conferred is fire resistance, and we have to immediately set
768  * HFire_resistance in worn.c since worn.c will check it before returning.
769  */
770 STATIC_PTR
771 int
772 Armor_on(VOID_ARGS)
773 {
774     return 0;
775 }
776
777 int
778 Armor_off(VOID_ARGS)
779 {
780     context.takeoff.mask &= ~W_ARM;
781     setworn((struct obj *) 0, W_ARM);
782     context.takeoff.cancelled_don = FALSE;
783     return 0;
784 }
785
786 /* The gone functions differ from the off functions in that if you die from
787  * taking it off and have life saving, you still die.
788  */
789 int
790 Armor_gone()
791 {
792     context.takeoff.mask &= ~W_ARM;
793     setnotworn(uarm);
794     context.takeoff.cancelled_don = FALSE;
795     return 0;
796 }
797
798 STATIC_OVL void
799 Amulet_on()
800 {
801     /* make sure amulet isn't wielded; can't use remove_worn_item()
802        here because it has already been set worn in amulet slot */
803     if (uamul == uwep)
804         setuwep((struct obj *) 0);
805     else if (uamul == uswapwep)
806         setuswapwep((struct obj *) 0);
807     else if (uamul == uquiver)
808         setuqwep((struct obj *) 0);
809
810     switch (uamul->otyp) {
811     case AMULET_OF_ESP:
812     case AMULET_OF_LIFE_SAVING:
813     case AMULET_VERSUS_POISON:
814     case AMULET_OF_REFLECTION:
815     case AMULET_OF_MAGICAL_BREATHING:
816     case FAKE_AMULET_OF_YENDOR:
817         break;
818     case AMULET_OF_UNCHANGING:
819         if (Slimed)
820             make_slimed(0L, (char *) 0);
821         break;
822     case AMULET_OF_CHANGE: {
823         int orig_sex = poly_gender();
824
825         if (Unchanging)
826             break;
827         change_sex();
828         /* Don't use same message as polymorph */
829         if (orig_sex != poly_gender()) {
830             makeknown(AMULET_OF_CHANGE);
831 #if 0 /*JP*/
832             You("are suddenly very %s!",
833                 flags.female ? "feminine" : "masculine");
834 #else
835             You("\93Ë\91R%s\82Á\82Û\82­\82È\82Á\82½\81I",
836                 flags.female ? "\8f\97" : "\92j");
837 #endif
838             context.botl = 1;
839         } else
840             /* already polymorphed into single-gender monster; only
841                changed the character's base sex */
842 /*JP
843             You("don't feel like yourself.");
844 */
845             You("\8e©\95ª\8e©\90g\82\82á\82È\82­\82È\82Á\82½\8bC\82ª\82µ\82½\81D");
846 /*JP
847         pline_The("amulet disintegrates!");
848 */
849         pline("\96\82\8f\9c\82¯\82Í\82±\82È\82²\82È\82É\82È\82Á\82½\81I");
850         if (orig_sex == poly_gender() && uamul->dknown
851             && !objects[AMULET_OF_CHANGE].oc_name_known
852             && !objects[AMULET_OF_CHANGE].oc_uname)
853             docall(uamul);
854         useup(uamul);
855         break;
856     }
857     case AMULET_OF_STRANGULATION:
858         if (can_be_strangled(&youmonst)) {
859             makeknown(AMULET_OF_STRANGULATION);
860             Strangled = 6L;
861             context.botl = TRUE;
862 /*JP
863             pline("It constricts your throat!");
864 */
865             pline("\96\82\8f\9c\82¯\82Í\82 \82È\82½\82Ì\8dA\82ð\8di\82ß\82Â\82¯\82½\81I");
866         }
867         break;
868     case AMULET_OF_RESTFUL_SLEEP: {
869         long newnap = (long) rnd(100), oldnap = (HSleepy & TIMEOUT);
870
871         /* avoid clobbering FROMOUTSIDE bit, which might have
872            gotten set by previously eating one of these amulets */
873         if (newnap < oldnap || oldnap == 0L)
874             HSleepy = (HSleepy & ~TIMEOUT) | newnap;
875     } break;
876     case AMULET_OF_YENDOR:
877         break;
878     }
879 }
880
881 void
882 Amulet_off()
883 {
884     context.takeoff.mask &= ~W_AMUL;
885
886     switch (uamul->otyp) {
887     case AMULET_OF_ESP:
888         /* need to update ability before calling see_monsters() */
889         setworn((struct obj *) 0, W_AMUL);
890         see_monsters();
891         return;
892     case AMULET_OF_LIFE_SAVING:
893     case AMULET_VERSUS_POISON:
894     case AMULET_OF_REFLECTION:
895     case AMULET_OF_CHANGE:
896     case AMULET_OF_UNCHANGING:
897     case FAKE_AMULET_OF_YENDOR:
898         break;
899     case AMULET_OF_MAGICAL_BREATHING:
900         if (Underwater) {
901             /* HMagical_breathing must be set off
902                 before calling drown() */
903             setworn((struct obj *) 0, W_AMUL);
904             if (!breathless(youmonst.data) && !amphibious(youmonst.data)
905                 && !Swimming) {
906 #if 0 /*JP*/
907                 You("suddenly inhale an unhealthy amount of %s!",
908                     hliquid("water"));
909 #else
910                 You("\93Ë\91R\81C\91å\97Ê\82Ì%s\82ð\88ù\82Ý\8d\9e\82ñ\82¾\81I",
911                     hliquid("\90\85"));
912 #endif
913                 (void) drown();
914             }
915             return;
916         }
917         break;
918     case AMULET_OF_STRANGULATION:
919         if (Strangled) {
920             Strangled = 0L;
921             context.botl = TRUE;
922             if (Breathless)
923 /*JP
924                 Your("%s is no longer constricted!", body_part(NECK));
925 */
926                 pline("%s\82ª\8ay\82É\82È\82Á\82½\81I", body_part(NECK));
927             else
928 /*JP
929                 You("can breathe more easily!");
930 */
931                 You("\8ay\82É\8cÄ\8bz\82Å\82«\82é\82æ\82¤\82É\82È\82Á\82½\81I");
932         }
933         break;
934     case AMULET_OF_RESTFUL_SLEEP:
935         setworn((struct obj *) 0, W_AMUL);
936         /* HSleepy = 0L; -- avoid clobbering FROMOUTSIDE bit */
937         if (!ESleepy && !(HSleepy & ~TIMEOUT))
938             HSleepy &= ~TIMEOUT; /* clear timeout bits */
939         return;
940     case AMULET_OF_YENDOR:
941         break;
942     }
943     setworn((struct obj *) 0, W_AMUL);
944     return;
945 }
946
947 /* handle ring discovery; comparable to learnwand() */
948 STATIC_OVL void
949 learnring(ring, observed)
950 struct obj *ring;
951 boolean observed;
952 {
953     int ringtype = ring->otyp;
954
955     /* if effect was observeable then we usually discover the type */
956     if (observed) {
957         /* if we already know the ring type which accomplishes this
958            effect (assumes there is at most one type for each effect),
959            mark this ring as having been seen (no need for makeknown);
960            otherwise if we have seen this ring, discover its type */
961         if (objects[ringtype].oc_name_known)
962             ring->dknown = 1;
963         else if (ring->dknown)
964             makeknown(ringtype);
965 #if 0 /* see learnwand() */
966         else
967             ring->eknown = 1;
968 #endif
969     }
970
971     /* make enchantment of charged ring known (might be +0) and update
972        perm invent window if we've seen this ring and know its type */
973     if (ring->dknown && objects[ringtype].oc_name_known) {
974         if (objects[ringtype].oc_charged)
975             ring->known = 1;
976         update_inventory();
977     }
978 }
979
980 void
981 Ring_on(obj)
982 register struct obj *obj;
983 {
984     long oldprop = u.uprops[objects[obj->otyp].oc_oprop].extrinsic;
985     int old_attrib, which;
986     boolean observable;
987
988     /* make sure ring isn't wielded; can't use remove_worn_item()
989        here because it has already been set worn in a ring slot */
990     if (obj == uwep)
991         setuwep((struct obj *) 0);
992     else if (obj == uswapwep)
993         setuswapwep((struct obj *) 0);
994     else if (obj == uquiver)
995         setuqwep((struct obj *) 0);
996
997     /* only mask out W_RING when we don't have both
998        left and right rings of the same type */
999     if ((oldprop & W_RING) != W_RING)
1000         oldprop &= ~W_RING;
1001
1002     switch (obj->otyp) {
1003     case RIN_TELEPORTATION:
1004     case RIN_REGENERATION:
1005     case RIN_SEARCHING:
1006     case RIN_HUNGER:
1007     case RIN_AGGRAVATE_MONSTER:
1008     case RIN_POISON_RESISTANCE:
1009     case RIN_FIRE_RESISTANCE:
1010     case RIN_COLD_RESISTANCE:
1011     case RIN_SHOCK_RESISTANCE:
1012     case RIN_CONFLICT:
1013     case RIN_TELEPORT_CONTROL:
1014     case RIN_POLYMORPH:
1015     case RIN_POLYMORPH_CONTROL:
1016     case RIN_FREE_ACTION:
1017     case RIN_SLOW_DIGESTION:
1018     case RIN_SUSTAIN_ABILITY:
1019     case MEAT_RING:
1020         break;
1021     case RIN_STEALTH:
1022         toggle_stealth(obj, oldprop, TRUE);
1023         break;
1024     case RIN_WARNING:
1025         see_monsters();
1026         break;
1027     case RIN_SEE_INVISIBLE:
1028         /* can now see invisible monsters */
1029         set_mimic_blocking(); /* do special mimic handling */
1030         see_monsters();
1031
1032         if (Invis && !oldprop && !HSee_invisible && !Blind) {
1033             newsym(u.ux, u.uy);
1034 /*JP
1035             pline("Suddenly you are transparent, but there!");
1036 */
1037             pline("\93Ë\91R\93§\96¾\82É\82È\82Á\82½\81D\82µ\82©\82µ\91\8dÝ\82Í\82µ\82Ä\82¢\82é\81I");
1038             learnring(obj, TRUE);
1039         }
1040         break;
1041     case RIN_INVISIBILITY:
1042         if (!oldprop && !HInvis && !BInvis && !Blind) {
1043             learnring(obj, TRUE);
1044             newsym(u.ux, u.uy);
1045             self_invis_message();
1046         }
1047         break;
1048     case RIN_LEVITATION:
1049         if (!oldprop && !HLevitation && !BLevitation) {
1050             float_up();
1051             learnring(obj, TRUE);
1052             spoteffects(FALSE); /* for sinks */
1053         } else {
1054             float_vs_flight(); /* maybe toggle (BFlying & I_SPECIAL) */
1055         }
1056         break;
1057     case RIN_GAIN_STRENGTH:
1058         which = A_STR;
1059         goto adjust_attrib;
1060     case RIN_GAIN_CONSTITUTION:
1061         which = A_CON;
1062         goto adjust_attrib;
1063     case RIN_ADORNMENT:
1064         which = A_CHA;
1065     adjust_attrib:
1066         old_attrib = ACURR(which);
1067         ABON(which) += obj->spe;
1068         observable = (old_attrib != ACURR(which));
1069         /* if didn't change, usually means ring is +0 but might
1070            be because nonzero couldn't go below min or above max;
1071            learn +0 enchantment if attribute value is not stuck
1072            at a limit [and ring has been seen and its type is
1073            already discovered, both handled by learnring()] */
1074         if (observable || !extremeattr(which))
1075             learnring(obj, observable);
1076         context.botl = 1;
1077         break;
1078     case RIN_INCREASE_ACCURACY: /* KMH */
1079         u.uhitinc += obj->spe;
1080         break;
1081     case RIN_INCREASE_DAMAGE:
1082         u.udaminc += obj->spe;
1083         break;
1084     case RIN_PROTECTION_FROM_SHAPE_CHAN:
1085         rescham();
1086         break;
1087     case RIN_PROTECTION:
1088         /* usually learn enchantment and discover type;
1089            won't happen if ring is unseen or if it's +0
1090            and the type hasn't been discovered yet */
1091         observable = (obj->spe != 0);
1092         learnring(obj, observable);
1093         if (obj->spe)
1094             find_ac(); /* updates botl */
1095         break;
1096     }
1097 }
1098
1099 STATIC_OVL void
1100 Ring_off_or_gone(obj, gone)
1101 register struct obj *obj;
1102 boolean gone;
1103 {
1104     long mask = (obj->owornmask & W_RING);
1105     int old_attrib, which;
1106     boolean observable;
1107
1108     context.takeoff.mask &= ~mask;
1109     if (!(u.uprops[objects[obj->otyp].oc_oprop].extrinsic & mask))
1110         impossible("Strange... I didn't know you had that ring.");
1111     if (gone)
1112         setnotworn(obj);
1113     else
1114         setworn((struct obj *) 0, obj->owornmask);
1115
1116     switch (obj->otyp) {
1117     case RIN_TELEPORTATION:
1118     case RIN_REGENERATION:
1119     case RIN_SEARCHING:
1120     case RIN_HUNGER:
1121     case RIN_AGGRAVATE_MONSTER:
1122     case RIN_POISON_RESISTANCE:
1123     case RIN_FIRE_RESISTANCE:
1124     case RIN_COLD_RESISTANCE:
1125     case RIN_SHOCK_RESISTANCE:
1126     case RIN_CONFLICT:
1127     case RIN_TELEPORT_CONTROL:
1128     case RIN_POLYMORPH:
1129     case RIN_POLYMORPH_CONTROL:
1130     case RIN_FREE_ACTION:
1131     case RIN_SLOW_DIGESTION:
1132     case RIN_SUSTAIN_ABILITY:
1133     case MEAT_RING:
1134         break;
1135     case RIN_STEALTH:
1136         toggle_stealth(obj, (EStealth & ~mask), FALSE);
1137         break;
1138     case RIN_WARNING:
1139         see_monsters();
1140         break;
1141     case RIN_SEE_INVISIBLE:
1142         /* Make invisible monsters go away */
1143         if (!See_invisible) {
1144             set_mimic_blocking(); /* do special mimic handling */
1145             see_monsters();
1146         }
1147
1148         if (Invisible && !Blind) {
1149             newsym(u.ux, u.uy);
1150 /*JP
1151             pline("Suddenly you cannot see yourself.");
1152 */
1153             pline("\93Ë\91R\81C\8e©\95ª\8e©\90g\82ª\8c©\82¦\82È\82­\82È\82Á\82½\81D");
1154             learnring(obj, TRUE);
1155         }
1156         break;
1157     case RIN_INVISIBILITY:
1158         if (!Invis && !BInvis && !Blind) {
1159             newsym(u.ux, u.uy);
1160 #if 0 /*JP*/
1161             Your("body seems to unfade%s.",
1162                  See_invisible ? " completely" : "..");
1163 #else
1164             Your("\91Ì\82ª%s\81D",
1165                  See_invisible ? "\8a®\91S\82É\8c»\82í\82ê\82½" : "\8e\9f\91æ\82É\8c»\82í\82ê\82Ä\82«\82½\81D\81D");
1166 #endif
1167             learnring(obj, TRUE);
1168         }
1169         break;
1170     case RIN_LEVITATION:
1171         if (!BLevitation) {
1172             (void) float_down(0L, 0L);
1173             if (!Levitation)
1174                 learnring(obj, TRUE);
1175         } else {
1176             float_vs_flight(); /* maybe toggle (BFlying & I_SPECIAL) */
1177         }
1178         break;
1179     case RIN_GAIN_STRENGTH:
1180         which = A_STR;
1181         goto adjust_attrib;
1182     case RIN_GAIN_CONSTITUTION:
1183         which = A_CON;
1184         goto adjust_attrib;
1185     case RIN_ADORNMENT:
1186         which = A_CHA;
1187     adjust_attrib:
1188         old_attrib = ACURR(which);
1189         ABON(which) -= obj->spe;
1190         observable = (old_attrib != ACURR(which));
1191         /* same criteria as Ring_on() */
1192         if (observable || !extremeattr(which))
1193             learnring(obj, observable);
1194         context.botl = 1;
1195         break;
1196     case RIN_INCREASE_ACCURACY: /* KMH */
1197         u.uhitinc -= obj->spe;
1198         break;
1199     case RIN_INCREASE_DAMAGE:
1200         u.udaminc -= obj->spe;
1201         break;
1202     case RIN_PROTECTION:
1203         /* might have been put on while blind and we can now see
1204            or perhaps been forgotten due to amnesia */
1205         observable = (obj->spe != 0);
1206         learnring(obj, observable);
1207         if (obj->spe)
1208             find_ac(); /* updates botl */
1209         break;
1210     case RIN_PROTECTION_FROM_SHAPE_CHAN:
1211         /* If you're no longer protected, let the chameleons
1212          * change shape again -dgk
1213          */
1214         restartcham();
1215         break;
1216     }
1217 }
1218
1219 void
1220 Ring_off(obj)
1221 struct obj *obj;
1222 {
1223     Ring_off_or_gone(obj, FALSE);
1224 }
1225
1226 void
1227 Ring_gone(obj)
1228 struct obj *obj;
1229 {
1230     Ring_off_or_gone(obj, TRUE);
1231 }
1232
1233 void
1234 Blindf_on(otmp)
1235 register struct obj *otmp;
1236 {
1237     boolean already_blind = Blind, changed = FALSE;
1238
1239     /* blindfold might be wielded; release it for wearing */
1240     if (otmp->owornmask & W_WEAPON)
1241         remove_worn_item(otmp, FALSE);
1242     setworn(otmp, W_TOOL);
1243     on_msg(otmp);
1244
1245     if (Blind && !already_blind) {
1246         changed = TRUE;
1247         if (flags.verbose)
1248 /*JP
1249             You_cant("see any more.");
1250 */
1251             You("\89½\82à\8c©\82¦\82È\82­\82È\82Á\82½\81D");
1252         /* set ball&chain variables before the hero goes blind */
1253         if (Punished)
1254             set_bc(0);
1255     } else if (already_blind && !Blind) {
1256         changed = TRUE;
1257         /* "You are now wearing the Eyes of the Overworld." */
1258         if (u.uroleplay.blind) {
1259             /* this can only happen by putting on the Eyes of the Overworld;
1260                that shouldn't actually produce a permanent cure, but we
1261                can't let the "blind from birth" conduct remain intact */
1262 /*JP
1263             pline("For the first time in your life, you can see!");
1264 */
1265             pline("\90l\90\82Å\8f\89\82ß\82Ä\81C\96Ú\82ª\8c©\82¦\82é\82æ\82¤\82É\82È\82Á\82½\81I");
1266             u.uroleplay.blind = FALSE;
1267         } else
1268 /*JP
1269             You("can see!");
1270 */
1271             You("\96Ú\82ª\8c©\82¦\82é\82æ\82¤\82É\82È\82Á\82½\81I");
1272     }
1273     if (changed) {
1274         /* blindness has just been toggled */
1275         if (Blind_telepat || Infravision)
1276             see_monsters();
1277         vision_full_recalc = 1; /* recalc vision limits */
1278         if (!Blind)
1279             learn_unseen_invent();
1280         context.botl = 1;
1281     }
1282 }
1283
1284 void
1285 Blindf_off(otmp)
1286 register struct obj *otmp;
1287 {
1288     boolean was_blind = Blind, changed = FALSE;
1289
1290     if (!otmp) {
1291         impossible("Blindf_off without otmp");
1292         return;
1293     }
1294     context.takeoff.mask &= ~W_TOOL;
1295     setworn((struct obj *) 0, otmp->owornmask);
1296     off_msg(otmp);
1297
1298     if (Blind) {
1299         if (was_blind) {
1300             /* "still cannot see" makes no sense when removing lenses
1301                since they can't have been the cause of your blindness */
1302             if (otmp->otyp != LENSES)
1303 /*JP
1304                 You("still cannot see.");
1305 */
1306                 You("\82Ü\82¾\96Ú\82ª\8c©\82¦\82È\82¢\81D");
1307         } else {
1308             changed = TRUE; /* !was_blind */
1309             /* "You were wearing the Eyes of the Overworld." */
1310 /*JP
1311             You_cant("see anything now!");
1312 */
1313             You("\8d¡\82Í\89½\82à\8c©\82é\82±\82Æ\82ª\82Å\82«\82È\82¢\81I");
1314             /* set ball&chain variables before the hero goes blind */
1315             if (Punished)
1316                 set_bc(0);
1317         }
1318     } else if (was_blind) {
1319         if (!gulp_blnd_check()) {
1320             changed = TRUE; /* !Blind */
1321 /*JP
1322             You("can see again.");
1323 */
1324             You("\82Ó\82½\82½\82Ñ\96Ú\82ª\8c©\82¦\82é\82æ\82¤\82É\82È\82Á\82½\81D");
1325         }
1326     }
1327     if (changed) {
1328         /* blindness has just been toggled */
1329         if (Blind_telepat || Infravision)
1330             see_monsters();
1331         vision_full_recalc = 1; /* recalc vision limits */
1332         if (!Blind)
1333             learn_unseen_invent();
1334         context.botl = 1;
1335     }
1336 }
1337
1338 /* called in moveloop()'s prologue to set side-effects of worn start-up items;
1339    also used by poly_obj() when a worn item gets transformed */
1340 void
1341 set_wear(obj)
1342 struct obj *obj; /* if null, do all worn items; otherwise just obj itself */
1343 {
1344     initial_don = !obj;
1345
1346     if (!obj ? ublindf != 0 : (obj == ublindf))
1347         (void) Blindf_on(ublindf);
1348     if (!obj ? uright != 0 : (obj == uright))
1349         (void) Ring_on(uright);
1350     if (!obj ? uleft != 0 : (obj == uleft))
1351         (void) Ring_on(uleft);
1352     if (!obj ? uamul != 0 : (obj == uamul))
1353         (void) Amulet_on();
1354
1355     if (!obj ? uarmu != 0 : (obj == uarmu))
1356         (void) Shirt_on();
1357     if (!obj ? uarm != 0 : (obj == uarm))
1358         (void) Armor_on();
1359     if (!obj ? uarmc != 0 : (obj == uarmc))
1360         (void) Cloak_on();
1361     if (!obj ? uarmf != 0 : (obj == uarmf))
1362         (void) Boots_on();
1363     if (!obj ? uarmg != 0 : (obj == uarmg))
1364         (void) Gloves_on();
1365     if (!obj ? uarmh != 0 : (obj == uarmh))
1366         (void) Helmet_on();
1367     if (!obj ? uarms != 0 : (obj == uarms))
1368         (void) Shield_on();
1369
1370     initial_don = FALSE;
1371 }
1372
1373 /* check whether the target object is currently being put on (or taken off--
1374    also checks for doffing--[why?]) */
1375 boolean
1376 donning(otmp)
1377 struct obj *otmp;
1378 {
1379     boolean result = FALSE;
1380
1381     /* 'W' (or 'P' used for armor) sets afternmv */
1382     if (doffing(otmp))
1383         result = TRUE;
1384     else if (otmp == uarm)
1385         result = (afternmv == Armor_on);
1386     else if (otmp == uarmu)
1387         result = (afternmv == Shirt_on);
1388     else if (otmp == uarmc)
1389         result = (afternmv == Cloak_on);
1390     else if (otmp == uarmf)
1391         result = (afternmv == Boots_on);
1392     else if (otmp == uarmh)
1393         result = (afternmv == Helmet_on);
1394     else if (otmp == uarmg)
1395         result = (afternmv == Gloves_on);
1396     else if (otmp == uarms)
1397         result = (afternmv == Shield_on);
1398
1399     return result;
1400 }
1401
1402 /* check whether the target object is currently being taken off,
1403    so that stop_donning() and steal() can vary messages */
1404 boolean
1405 doffing(otmp)
1406 struct obj *otmp;
1407 {
1408     long what = context.takeoff.what;
1409     boolean result = FALSE;
1410
1411     /* 'T' (or 'R' used for armor) sets afternmv, 'A' sets takeoff.what */
1412     if (otmp == uarm)
1413         result = (afternmv == Armor_off || what == WORN_ARMOR);
1414     else if (otmp == uarmu)
1415         result = (afternmv == Shirt_off || what == WORN_SHIRT);
1416     else if (otmp == uarmc)
1417         result = (afternmv == Cloak_off || what == WORN_CLOAK);
1418     else if (otmp == uarmf)
1419         result = (afternmv == Boots_off || what == WORN_BOOTS);
1420     else if (otmp == uarmh)
1421         result = (afternmv == Helmet_off || what == WORN_HELMET);
1422     else if (otmp == uarmg)
1423         result = (afternmv == Gloves_off || what == WORN_GLOVES);
1424     else if (otmp == uarms)
1425         result = (afternmv == Shield_off || what == WORN_SHIELD);
1426     /* these 1-turn items don't need 'afternmv' checks */
1427     else if (otmp == uamul)
1428         result = (what == WORN_AMUL);
1429     else if (otmp == uleft)
1430         result = (what == LEFT_RING);
1431     else if (otmp == uright)
1432         result = (what == RIGHT_RING);
1433     else if (otmp == ublindf)
1434         result = (what == WORN_BLINDF);
1435     else if (otmp == uwep)
1436         result = (what == W_WEP);
1437     else if (otmp == uswapwep)
1438         result = (what == W_SWAPWEP);
1439     else if (otmp == uquiver)
1440         result = (what == W_QUIVER);
1441
1442     return result;
1443 }
1444
1445 /* despite their names, cancel_don() and cancel_doff() both apply to both
1446    donning and doffing... */
1447 void
1448 cancel_doff(obj, slotmask)
1449 struct obj *obj;
1450 long slotmask;
1451 {
1452     /* Called by setworn() for old item in specified slot or by setnotworn()
1453      * for specified item.  We don't want to call cancel_don() if we got
1454      * here via <X>_off() -> setworn((struct obj *)0) -> cancel_doff()
1455      * because that would stop the 'A' command from continuing with next
1456      * selected item.  So do_takeoff() sets a flag in takeoff.mask for us.
1457      * [For taking off an individual item with 'T'/'R'/'w-', it doesn't
1458      * matter whether cancel_don() gets called here--the item has already
1459      * been removed by now.]
1460      */
1461     if (!(context.takeoff.mask & I_SPECIAL) && donning(obj))
1462         cancel_don(); /* applies to doffing too */
1463     context.takeoff.mask &= ~slotmask;
1464 }
1465
1466 /* despite their names, cancel_don() and cancel_doff() both apply to both
1467    donning and doffing... */
1468 void
1469 cancel_don()
1470 {
1471     /* the piece of armor we were donning/doffing has vanished, so stop
1472      * wasting time on it (and don't dereference it when donning would
1473      * otherwise finish)
1474      */
1475     context.takeoff.cancelled_don =
1476         (afternmv == Boots_on || afternmv == Helmet_on
1477          || afternmv == Gloves_on || afternmv == Armor_on);
1478     afternmv = (int NDECL((*))) 0;
1479     nomovemsg = (char *) 0;
1480     multi = 0;
1481     context.takeoff.delay = 0;
1482     context.takeoff.what = 0L;
1483 }
1484
1485 /* called by steal() during theft from hero; interrupt donning/doffing */
1486 int
1487 stop_donning(stolenobj)
1488 struct obj *stolenobj; /* no message if stolenobj is already being doffing */
1489 {
1490     char buf[BUFSZ];
1491     struct obj *otmp;
1492     boolean putting_on;
1493     int result = 0;
1494
1495     for (otmp = invent; otmp; otmp = otmp->nobj)
1496         if ((otmp->owornmask & W_ARMOR) && donning(otmp))
1497             break;
1498     /* at most one item will pass donning() test at any given time */
1499     if (!otmp)
1500         return 0;
1501
1502     /* donning() returns True when doffing too; doffing() is more specific */
1503     putting_on = !doffing(otmp);
1504     /* cancel_don() looks at afternmv; it can also cancel doffing */
1505     cancel_don();
1506     /* don't want <armor>_on() or <armor>_off() being called
1507        by unmul() since the on or off action isn't completing */
1508     afternmv = (int NDECL((*))) 0;
1509     if (putting_on || otmp != stolenobj) {
1510 #if 0 /*JP*/
1511         Sprintf(buf, "You stop %s %s.",
1512                 putting_on ? "putting on" : "taking off",
1513                 thesimpleoname(otmp));
1514 #else
1515         Sprintf(buf, "\82 \82È\82½\82Í%s\82ð%s\82Ì\82ð\8e~\82ß\82½\81D",
1516                 thesimpleoname(otmp),
1517                 putting_on ? "\90g\82É\82Â\82¯\82é" : "\8aO\82·");
1518 #endif
1519     } else {
1520         buf[0] = '\0';   /* silently stop doffing stolenobj */
1521         result = -multi; /* remember this before calling unmul() */
1522     }
1523     unmul(buf);
1524     /* while putting on, item becomes worn immediately but side-effects are
1525        deferred until the delay expires; when interrupted, make it unworn
1526        (while taking off, item stays worn until the delay expires; when
1527        interrupted, leave it worn) */
1528     if (putting_on)
1529         remove_worn_item(otmp, FALSE);
1530
1531     return result;
1532 }
1533
1534 /* both 'clothes' and 'accessories' now include both armor and accessories;
1535    TOOL_CLASS is for eyewear, FOOD_CLASS is for MEAT_RING */
1536 static NEARDATA const char clothes[] = {
1537     ARMOR_CLASS, RING_CLASS, AMULET_CLASS, TOOL_CLASS, FOOD_CLASS, 0
1538 };
1539 static NEARDATA const char accessories[] = {
1540     RING_CLASS, AMULET_CLASS, TOOL_CLASS, FOOD_CLASS, ARMOR_CLASS, 0
1541 };
1542 STATIC_VAR NEARDATA int Narmorpieces, Naccessories;
1543
1544 /* assign values to Narmorpieces and Naccessories */
1545 STATIC_OVL void
1546 count_worn_stuff(which, accessorizing)
1547 struct obj **which; /* caller wants this when count is 1 */
1548 boolean accessorizing;
1549 {
1550     struct obj *otmp;
1551
1552     Narmorpieces = Naccessories = 0;
1553
1554 #define MOREWORN(x,wtyp) do { if (x) { wtyp++; otmp = x; } } while (0)
1555     otmp = 0;
1556     MOREWORN(uarmh, Narmorpieces);
1557     MOREWORN(uarms, Narmorpieces);
1558     MOREWORN(uarmg, Narmorpieces);
1559     MOREWORN(uarmf, Narmorpieces);
1560     /* for cloak/suit/shirt, we only count the outermost item so that it
1561        can be taken off without confirmation if final count ends up as 1 */
1562     if (uarmc)
1563         MOREWORN(uarmc, Narmorpieces);
1564     else if (uarm)
1565         MOREWORN(uarm, Narmorpieces);
1566     else if (uarmu)
1567         MOREWORN(uarmu, Narmorpieces);
1568     if (!accessorizing)
1569         *which = otmp; /* default item iff Narmorpieces is 1 */
1570
1571     otmp = 0;
1572     MOREWORN(uleft, Naccessories);
1573     MOREWORN(uright, Naccessories);
1574     MOREWORN(uamul, Naccessories);
1575     MOREWORN(ublindf, Naccessories);
1576     if (accessorizing)
1577         *which = otmp; /* default item iff Naccessories is 1 */
1578 #undef MOREWORN
1579 }
1580
1581 /* take off one piece or armor or one accessory;
1582    shared by dotakeoff('T') and doremring('R') */
1583 STATIC_OVL int
1584 armor_or_accessory_off(obj)
1585 struct obj *obj;
1586 {
1587 #if 1 /*JP*/
1588     const char *j;
1589     const char *m;
1590 #endif
1591     if (!(obj->owornmask & (W_ARMOR | W_ACCESSORY))) {
1592 /*JP
1593         You("are not wearing that.");
1594 */
1595         You("\82»\82ê\82ð\90g\82É\82Â\82¯\82Ä\82¢\82È\82¢\81D");
1596         return 0;
1597     }
1598     if (obj == uskin
1599         || ((obj == uarm) && uarmc)
1600         || ((obj == uarmu) && (uarmc || uarm))) {
1601         char why[QBUFSZ], what[QBUFSZ];
1602
1603         why[0] = what[0] = '\0';
1604         if (obj != uskin) {
1605             if (uarmc)
1606                 Strcat(what, cloak_simple_name(uarmc));
1607             if ((obj == uarmu) && uarm) {
1608                 if (uarmc)
1609 #if 0 /*JP*/
1610                     Strcat(what, " and ");
1611 #else
1612                     Strcat(what, "\82Æ");
1613 #endif
1614                 Strcat(what, suit_simple_name(uarm));
1615             }
1616 #if 0 /*JP*/
1617             Sprintf(why, " without taking off your %s first", what);
1618 #else
1619             Sprintf(why, "\90æ\82É%s\82ð\82Í\82¸\82³\82È\82¢\82Æ", what);
1620 #endif
1621         } else {
1622 #if 0 /*JP*/
1623             Strcpy(why, "; it's embedded");
1624 #else
1625             Strcpy(why, "\82­\82Á\82Â\82¢\82Ä\82¢\82é\82Ì\82Å");
1626 #endif
1627         }
1628 #if 0 /*JP*/
1629         You_cant("take that off%s.", why);
1630 #else
1631         m = joffmsg(obj, &j);
1632         pline("%s\82»\82ê%s%s\82±\82Æ\82Í\82Å\82«\82È\82¢\81D", why, j, m);
1633 #endif
1634         return 0;
1635     }
1636
1637     reset_remarm(); /* clear context.takeoff.mask and context.takeoff.what */
1638     (void) select_off(obj);
1639     if (!context.takeoff.mask)
1640         return 0;
1641     /* none of armoroff()/Ring_/Amulet/Blindf_off() use context.takeoff.mask */
1642     reset_remarm();
1643
1644     if (obj->owornmask & W_ARMOR) {
1645         (void) armoroff(obj);
1646     } else if (obj == uright || obj == uleft) {
1647         /* Sometimes we want to give the off_msg before removing and
1648          * sometimes after; for instance, "you were wearing a moonstone
1649          * ring (on right hand)" is desired but "you were wearing a
1650          * square amulet (being worn)" is not because of the redundant
1651          * "being worn".
1652          */
1653         off_msg(obj);
1654         Ring_off(obj);
1655     } else if (obj == uamul) {
1656         Amulet_off();
1657         off_msg(obj);
1658     } else if (obj == ublindf) {
1659         Blindf_off(obj); /* does its own off_msg */
1660     } else {
1661         impossible("removing strange accessory?");
1662         if (obj->owornmask)
1663             remove_worn_item(obj, FALSE);
1664     }
1665     return 1;
1666 }
1667
1668 /* the 'T' command */
1669 int
1670 dotakeoff()
1671 {
1672     struct obj *otmp = (struct obj *) 0;
1673 #if 1 /*JP*/
1674     const char *j;
1675     const char *m;
1676 #endif
1677
1678     count_worn_stuff(&otmp, FALSE);
1679     if (!Narmorpieces && !Naccessories) {
1680         /* assert( GRAY_DRAGON_SCALES > YELLOW_DRAGON_SCALE_MAIL ); */
1681         if (uskin)
1682 #if 0 /*JP*/
1683             pline_The("%s merged with your skin!",
1684                       uskin->otyp >= GRAY_DRAGON_SCALES
1685                           ? "dragon scales are"
1686                           : "dragon scale mail is");
1687 #else
1688             pline("\83h\83\89\83S\83\93\82Ì\97Ø%s\82Í\82 \82È\82½\82Ì\94§\82Æ\97Z\8d\87\82µ\82Ä\82µ\82Ü\82Á\82Ä\82¢\82é\81I",
1689                       uskin->otyp >= GRAY_DRAGON_SCALES
1690                           ? "" : "\8aZ");
1691 #endif
1692         else
1693 /*JP
1694             pline("Not wearing any armor or accessories.");
1695 */
1696             pline("\8aZ\82â\91\95\8fü\95i\82ð\90g\82É\82Â\82¯\82Ä\82¢\82È\82¢\81D");
1697         return 0;
1698     }
1699     if (Narmorpieces != 1 || ParanoidRemove)
1700         otmp = getobj(clothes, "take off");
1701     if (!otmp)
1702         return 0;
1703
1704     return armor_or_accessory_off(otmp);
1705 }
1706
1707 /* the 'R' command */
1708 int
1709 doremring()
1710 {
1711     struct obj *otmp = 0;
1712
1713     count_worn_stuff(&otmp, TRUE);
1714     if (!Naccessories && !Narmorpieces) {
1715 /*JP
1716         pline("Not wearing any accessories or armor.");
1717 */
1718         pline("\91\95\8fü\95i\82â\8aZ\82ð\90g\82É\82Â\82¯\82Ä\82¢\82È\82¢\81D");
1719         return 0;
1720     }
1721     if (Naccessories != 1 || ParanoidRemove)
1722         otmp = getobj(accessories, "remove");
1723     if (!otmp)
1724         return 0;
1725
1726     return armor_or_accessory_off(otmp);
1727 }
1728
1729 /* Check if something worn is cursed _and_ unremovable. */
1730 int
1731 cursed(otmp)
1732 register struct obj *otmp;
1733 {
1734     if (!otmp) {
1735         impossible("cursed without otmp");
1736         return 0;
1737     }
1738     /* Curses, like chickens, come home to roost. */
1739     if ((otmp == uwep) ? welded(otmp) : (int) otmp->cursed) {
1740 #if 0 /*JP*/
1741         boolean use_plural = (is_boots(otmp) || is_gloves(otmp)
1742                               || otmp->otyp == LENSES || otmp->quan > 1L);
1743
1744         You("can't.  %s cursed.", use_plural ? "They are" : "It is");
1745 #else
1746         pline("\96³\97\9d\82¾\81D\82»\82ê\82Í\8eô\82í\82ê\82Ä\82¢\82é\81D");
1747 #endif
1748         otmp->bknown = TRUE;
1749         return 1;
1750     }
1751     return 0;
1752 }
1753
1754 int
1755 armoroff(otmp)
1756 register struct obj *otmp;
1757 {
1758     register int delay = -objects[otmp->otyp].oc_delay;
1759
1760     if (cursed(otmp))
1761         return 0;
1762     if (delay) {
1763         nomul(delay);
1764 /*JP
1765         multi_reason = "disrobing";
1766 */
1767         multi_reason = "\92E\82¢\82Å\82¢\82é\8e\9e\82É";
1768         if (is_helmet(otmp)) {
1769             /* ick... */
1770 /*JP
1771             nomovemsg = !strcmp(helm_simple_name(otmp), "hat")
1772 */
1773             nomovemsg = !strcmp(helm_simple_name(otmp), "\96X\8eq")
1774 /*JP
1775                             ? "You finish taking off your hat."
1776 */
1777                             ? "\82 \82È\82½\82Í\8a\95\82ð\92E\82¬\82¨\82¦\82½\81D"
1778 /*JP
1779                             : "You finish taking off your helmet.";
1780 */
1781                             : "\82 \82È\82½\82Í\96X\8eq\82ð\92E\82¬\82¨\82¦\82½\81D";
1782             afternmv = Helmet_off;
1783         } else if (is_gloves(otmp)) {
1784 /*JP
1785             nomovemsg = "You finish taking off your gloves.";
1786 */
1787             nomovemsg = "\82 \82È\82½\82Í\8f¬\8eè\82ð\92E\82¬\82¨\82¦\82½\81D";
1788             afternmv = Gloves_off;
1789         } else if (is_boots(otmp)) {
1790 /*JP
1791             nomovemsg = "You finish taking off your boots.";
1792 */
1793             nomovemsg = "\82 \82È\82½\82Í\8cC\82ð\92E\82¬\82¨\82¦\82½\81D";
1794             afternmv = Boots_off;
1795         } else {
1796 /*JP
1797             nomovemsg = "You finish taking off your suit.";
1798 */
1799             nomovemsg = "\82 \82È\82½\82Í\92\85\82Ä\82¢\82é\95¨\82ð\92E\82¬\82¨\82¦\82½\81D";
1800             afternmv = Armor_off;
1801         }
1802     } else {
1803         /* Be warned!  We want off_msg after removing the item to
1804          * avoid "You were wearing ____ (being worn)."  However, an
1805          * item which grants fire resistance might cause some trouble
1806          * if removed in Hell and lifesaving puts it back on; in this
1807          * case the message will be printed at the wrong time (after
1808          * the messages saying you died and were lifesaved).  Luckily,
1809          * no cloak, shield, or fast-removable armor grants fire
1810          * resistance, so we can safely do the off_msg afterwards.
1811          * Rings do grant fire resistance, but for rings we want the
1812          * off_msg before removal anyway so there's no problem.  Take
1813          * care in adding armors granting fire resistance; this code
1814          * might need modification.
1815          * 3.2 (actually 3.1 even): that comment is obsolete since
1816          * fire resistance is not required for Gehennom so setworn()
1817          * doesn't force the resistance granting item to be re-worn
1818          * after being lifesaved anymore.
1819          */
1820         if (is_cloak(otmp))
1821             (void) Cloak_off();
1822         else if (is_shield(otmp))
1823             (void) Shield_off();
1824         else
1825             setworn((struct obj *) 0, otmp->owornmask & W_ARMOR);
1826         off_msg(otmp);
1827     }
1828     context.takeoff.mask = context.takeoff.what = 0L;
1829     return 1;
1830 }
1831
1832 /*JP 
1833 ** \95¨\82É\82æ\82Á\82Ä\93®\8e\8c\82ª\95Ï\89»\82·\82é\82Ì\82Å otmp\82ð\92Ç\89Á
1834 */
1835 STATIC_OVL void
1836 #if 0 /*JP*/
1837 already_wearing(cc)
1838 const char *cc;
1839 #else
1840 already_wearing(cc, otmp)
1841 const char *cc;
1842 struct obj *otmp;
1843 #endif
1844 {
1845 #if 1 /*JP*/
1846     const char *j;
1847     const char *m;
1848     m = jconj(jonmsg(otmp, &j), "\82Ä\82¢\82é");
1849 #endif
1850 /*JP
1851     You("are already wearing %s%c", cc, (cc == c_that_) ? '!' : '.');
1852 */
1853     You("\82à\82¤%s%s%s%s", cc, j,  m, (cc == c_that_) ? "\81I" : "\81D");
1854 }
1855
1856 STATIC_OVL void
1857 already_wearing2(cc1, cc2)
1858 const char *cc1, *cc2;
1859 {
1860 /*JP
1861     You_cant("wear %s because you're wearing %s there already.", cc1, cc2);
1862 */
1863     You_cant("%s\82ð\90g\82É\95t\82¯\82Ä\82¢\82é\82Ì\82Å%s\82ð\90g\82É\82Â\82¯\82ç\82ê\82È\82¢\81D", cc2, cc1);
1864 }
1865
1866 /*
1867  * canwearobj checks to see whether the player can wear a piece of armor
1868  *
1869  * inputs: otmp (the piece of armor)
1870  *         noisy (if TRUE give error messages, otherwise be quiet about it)
1871  * output: mask (otmp's armor type)
1872  */
1873 int
1874 canwearobj(otmp, mask, noisy)
1875 struct obj *otmp;
1876 long *mask;
1877 boolean noisy;
1878 {
1879     int err = 0;
1880     const char *which;
1881 #if 1 /*JP*/
1882     const char *m;
1883     const char *j;
1884 #endif
1885
1886     /* this is the same check as for 'W' (dowear), but different message,
1887        in case we get here via 'P' (doputon) */
1888     if (verysmall(youmonst.data) || nohands(youmonst.data)) {
1889         if (noisy)
1890 /*JP
1891             You("can't wear any armor in your current form.");
1892 */
1893             You("\8c»\8dÝ\82Ì\8ep\82Å\82Í\96h\8bï\82ð\90g\82É\82Â\82¯\82é\82±\82Æ\82Í\82Å\82«\82È\82¢\81D");
1894         return 0;
1895     }
1896
1897     which = is_cloak(otmp)
1898                 ? c_cloak
1899                 : is_shirt(otmp)
1900                     ? c_shirt
1901                     : is_suit(otmp)
1902                         ? c_suit
1903                         : 0;
1904     if (which && cantweararm(youmonst.data)
1905         /* same exception for cloaks as used in m_dowear() */
1906         && (which != c_cloak || youmonst.data->msize != MZ_SMALL)
1907         && (racial_exception(&youmonst, otmp) < 1)) {
1908         if (noisy)
1909 /*JP
1910             pline_The("%s will not fit on your body.", which);
1911 */
1912             pline("%s\82Í\82 \82È\82½\82Ì\91Ì\82É\8d\87\82í\82È\82¢\81D", which);
1913         return 0;
1914     } else if (otmp->owornmask & W_ARMOR) {
1915         if (noisy)
1916 #if 0 /*JP*/
1917             already_wearing(c_that_);
1918 #else
1919             already_wearing(c_that_, otmp);
1920 #endif
1921         return 0;
1922     }
1923
1924     if (welded(uwep) && bimanual(uwep) && (is_suit(otmp) || is_shirt(otmp))) {
1925         if (noisy)
1926 /*JP
1927             You("cannot do that while holding your %s.",
1928 */
1929             pline("%s\82ð\8e\9d\82Á\82½\82Ü\82Ü\82Å\82Í\82»\82ê\82Í\8fo\97\88\82È\82¢\81D",
1930                 is_sword(uwep) ? c_sword : c_weapon);
1931         return 0;
1932     }
1933
1934     if (is_helmet(otmp)) {
1935         if (uarmh) {
1936             if (noisy)
1937 #if 0 /*JP*/
1938                 already_wearing(an(helm_simple_name(uarmh)));
1939 #else
1940                 already_wearing(helm_simple_name(uarmh), uarmh);
1941 #endif
1942             err++;
1943         } else if (Upolyd && has_horns(youmonst.data) && !is_flimsy(otmp)) {
1944             /* (flimsy exception matches polyself handling) */
1945             if (noisy)
1946 #if 0 /*JP*/
1947                 pline_The("%s won't fit over your horn%s.",
1948                           helm_simple_name(otmp),
1949                           plur(num_horns(youmonst.data)));
1950 #else
1951                 pline("\8ap\82ª\82\82á\82Ü\82Å%s\82ð\90g\82É\82Â\82¯\82ç\82ê\82È\82¢\81D",
1952                       helm_simple_name(otmp));
1953 #endif
1954             err++;
1955         } else
1956             *mask = W_ARMH;
1957     } else if (is_shield(otmp)) {
1958         if (uarms) {
1959             if (noisy)
1960 #if 0 /*JP*/
1961                 already_wearing(an(c_shield));
1962 #else
1963                 already_wearing(c_shield, uarms);
1964 #endif
1965             err++;
1966         } else if (uwep && bimanual(uwep)) {
1967             if (noisy)
1968 #if 0 /*JP*/
1969                 You("cannot wear a shield while wielding a two-handed %s.",
1970                     is_sword(uwep) ? c_sword : (uwep->otyp == BATTLE_AXE)
1971                                                    ? c_axe
1972                                                    : c_weapon);
1973 #else
1974                 {
1975                     m = jconj(jonmsg(uwep, &j), "\82Ä\82¢\82é");
1976                     You("\97¼\8eè\8e\9d\82¿\82Ì%s%s%s\82Ì\82Å\8f\82\82Å\90g\82ð\8eç\82ê\82È\82¢\81D",
1977                         is_sword(uwep) ? c_sword :
1978                         uwep->otyp == BATTLE_AXE ? c_axe : c_weapon,
1979                         j, m);
1980                 }
1981 #endif
1982             err++;
1983         } else if (u.twoweap) {
1984             if (noisy)
1985 /*JP
1986                 You("cannot wear a shield while wielding two weapons.");
1987 */
1988                 You("\93ñ\93\81\97¬\82ð\82µ\82Ä\82¢\82é\82Ì\82Å\8f\82\82Å\90g\82ð\8eç\82ê\82È\82¢\81D");
1989             err++;
1990         } else
1991             *mask = W_ARMS;
1992     } else if (is_boots(otmp)) {
1993         if (uarmf) {
1994             if (noisy)
1995 #if 0 /*JP*/
1996                 already_wearing(c_boots);
1997 #else
1998                 already_wearing(c_boots, uarmf);
1999 #endif
2000             err++;
2001         } else if (Upolyd && slithy(youmonst.data)) {
2002             if (noisy)
2003 #if 0 /*JP*/
2004                 You("have no feet..."); /* not body_part(FOOT) */
2005 #else
2006                 You("\91«\82ª\82È\82¢\81D\81D\81D");  /* not body_part(FOOT) */
2007 #endif
2008             err++;
2009         } else if (Upolyd && youmonst.data->mlet == S_CENTAUR) {
2010             /* break_armor() pushes boots off for centaurs,
2011                so don't let dowear() put them back on... */
2012             if (noisy)
2013 #if 0 /*JP*/
2014                 pline("You have too many hooves to wear %s.",
2015                       c_boots); /* makeplural(body_part(FOOT)) yields
2016                                    "rear hooves" which sounds odd */
2017 #else
2018                 pline("%s\82ð\97\9a\82­\82É\82Í\91«\82ª\91½\82·\82¬\82é\81D", c_boots);
2019 #endif
2020             err++;
2021         } else if (u.utrap
2022                    && (u.utraptype == TT_BEARTRAP || u.utraptype == TT_INFLOOR
2023                        || u.utraptype == TT_LAVA
2024                        || u.utraptype == TT_BURIEDBALL)) {
2025             if (u.utraptype == TT_BEARTRAP) {
2026                 if (noisy)
2027 /*JP
2028                     Your("%s is trapped!", body_part(FOOT));
2029 */
2030                     Your("%s\82Íã©\82É\82©\82©\82Á\82Ä\82¢\82é\81I", body_part(FOOT));
2031             } else if (u.utraptype == TT_INFLOOR || u.utraptype == TT_LAVA) {
2032                 if (noisy)
2033 #if 0 /*JP*/
2034                     Your("%s are stuck in the %s!",
2035                          makeplural(body_part(FOOT)), surface(u.ux, u.uy));
2036 #else
2037                     Your("%s\82Í%s\82É\82Í\82Ü\82Á\82Ä\82¢\82é\81I",
2038                          body_part(FOOT), surface(u.ux, u.uy));
2039 #endif
2040             } else { /*TT_BURIEDBALL*/
2041                 if (noisy)
2042 #if 0 /*JP*/
2043                     Your("%s is attached to the buried ball!",
2044                          body_part(LEG));
2045 #else
2046                     Your("%s\82Í\96\84\82Ü\82Á\82Ä\82¢\82é\8b\85\82É\82Â\82È\82ª\82Á\82Ä\82¢\82é\81I",
2047                          body_part(LEG));
2048 #endif
2049             }
2050             err++;
2051         } else
2052             *mask = W_ARMF;
2053     } else if (is_gloves(otmp)) {
2054         if (uarmg) {
2055             if (noisy)
2056 #if 0 /*JP*/
2057                 already_wearing(c_gloves);
2058 #else
2059                 already_wearing(c_gloves, uarmg);
2060 #endif
2061             err++;
2062         } else if (welded(uwep)) {
2063             if (noisy)
2064 /*JP
2065                 You("cannot wear gloves over your %s.",
2066 */
2067                 You("%s\82Ì\8fã\82©\82ç\8f¬\8eè\82ð\91\95\94õ\82Å\82«\82È\82¢\81D",
2068                     is_sword(uwep) ? c_sword : c_weapon);
2069             err++;
2070         } else
2071             *mask = W_ARMG;
2072     } else if (is_shirt(otmp)) {
2073         if (uarm || uarmc || uarmu) {
2074             if (uarmu) {
2075                 if (noisy)
2076 #if 0 /*JP*/
2077                     already_wearing(an(c_shirt));
2078 #else
2079                     already_wearing(c_shirt, uarmu);
2080 #endif
2081             } else {
2082                 if (noisy)
2083 /*JP
2084                     You_cant("wear that over your %s.",
2085 */
2086                     You("%s\82Ì\8fã\82©\82ç\92\85\82é\82±\82Æ\82Í\82Å\82«\82È\82¢\81D",
2087                              (uarm && !uarmc) ? c_armor
2088                                               : cloak_simple_name(uarmc));
2089             }
2090             err++;
2091         } else
2092             *mask = W_ARMU;
2093     } else if (is_cloak(otmp)) {
2094         if (uarmc) {
2095             if (noisy)
2096 /*JP
2097                 already_wearing(an(cloak_simple_name(uarmc)));
2098 */
2099                 already_wearing(cloak_simple_name(uarmc), otmp);
2100             err++;
2101         } else
2102             *mask = W_ARMC;
2103     } else if (is_suit(otmp)) {
2104         if (uarmc) {
2105             if (noisy)
2106 /*JP
2107                 You("cannot wear armor over a %s.", cloak_simple_name(uarmc));
2108 */
2109                 You("%s\82Ì\8fã\82©\82ç\92\85\82é\82±\82Æ\82Í\82Å\82«\82È\82¢\81D", cloak_simple_name(uarmc));
2110             err++;
2111         } else if (uarm) {
2112             if (noisy)
2113 /*JP
2114                 already_wearing("some armor");
2115 */
2116                 already_wearing("\8aZ", uarm);
2117             err++;
2118         } else
2119             *mask = W_ARM;
2120     } else {
2121         /* getobj can't do this after setting its allow_all flag; that
2122            happens if you have armor for slots that are covered up or
2123            extra armor for slots that are filled */
2124         if (noisy)
2125 /*JP
2126             silly_thing("wear", otmp);
2127 */
2128             silly_thing("\90g\82É\82Â\82¯\82é", otmp);
2129         err++;
2130     }
2131     /* Unnecessary since now only weapons and special items like pick-axes get
2132      * welded to your hand, not armor
2133         if (welded(otmp)) {
2134             if (!err++) {
2135                 if (noisy) weldmsg(otmp);
2136             }
2137         }
2138      */
2139     return !err;
2140 }
2141
2142 STATIC_OVL int
2143 accessory_or_armor_on(obj)
2144 struct obj *obj;
2145 {
2146     long mask = 0L;
2147     boolean armor, ring, eyewear;
2148
2149     if (obj->owornmask & (W_ACCESSORY | W_ARMOR)) {
2150 #if 0 /*JP*/
2151         already_wearing(c_that_);
2152 #else
2153         already_wearing(c_that_, obj);
2154 #endif
2155         return 0;
2156     }
2157     armor = (obj->oclass == ARMOR_CLASS);
2158     ring = (obj->oclass == RING_CLASS || obj->otyp == MEAT_RING);
2159     eyewear = (obj->otyp == BLINDFOLD || obj->otyp == TOWEL
2160                || obj->otyp == LENSES);
2161     /* checks which are performed prior to actually touching the item */
2162     if (armor) {
2163         if (!canwearobj(obj, &mask, TRUE))
2164             return 0;
2165
2166         if (obj->otyp == HELM_OF_OPPOSITE_ALIGNMENT
2167             && qstart_level.dnum == u.uz.dnum) { /* in quest */
2168             if (u.ualignbase[A_CURRENT] == u.ualignbase[A_ORIGINAL])
2169 /*JP
2170                 You("narrowly avoid losing all chance at your goal.");
2171 */
2172                 You("\96Ú\93I\82ð\92B\90¬\82·\82é\89Â\94\\90«\82ð\8e¸\82¤\82±\82Æ\82ð\82È\82ñ\82Æ\82©\89ñ\94ð\82µ\82½\81D");
2173             else /* converted */
2174 /*JP
2175                 You("are suddenly overcome with shame and change your mind.");
2176 */
2177                 You("\93Ë\91R\92p\82¸\82©\82µ\82­\82È\82Á\82Ä\8dl\82¦\82ð\95Ï\82¦\82½\81D");
2178             u.ublessed = 0; /* lose your god's protection */
2179             makeknown(obj->otyp);
2180             context.botl = 1; /*for AC after zeroing u.ublessed */
2181             return 1;
2182         }
2183     } else {
2184         /* accessory */
2185         if (ring) {
2186             char answer, qbuf[QBUFSZ];
2187             int res = 0;
2188
2189             if (nolimbs(youmonst.data)) {
2190 /*JP
2191                 You("cannot make the ring stick to your body.");
2192 */
2193                 You("\8ew\97Ö\82ð\82Í\82ß\82ç\82ê\82È\82¢\91Ì\82¾\81D");
2194                 return 0;
2195             }
2196             if (uleft && uright) {
2197 #if 0 /*JP*/
2198                 There("are no more %s%s to fill.",
2199                       humanoid(youmonst.data) ? "ring-" : "",
2200                       makeplural(body_part(FINGER)));
2201 #else
2202                 pline("\82Í\82ß\82é\82±\82Æ\82Ì\82Å\82«\82é%s%s\82ª\82È\82¢\81D",
2203                       humanoid(youmonst.data) ? "\96ò" : "",
2204                       body_part(FINGER));
2205 #endif
2206                 return 0;
2207             }
2208             if (uleft) {
2209                 mask = RIGHT_RING;
2210             } else if (uright) {
2211                 mask = LEFT_RING;
2212             } else {
2213                 do {
2214 #if 0 /*JP*/
2215                     Sprintf(qbuf, "Which %s%s, Right or Left?",
2216                             humanoid(youmonst.data) ? "ring-" : "",
2217                             body_part(FINGER));
2218 #else
2219                     Sprintf(qbuf, "\82Ç\82¿\82ç\82Ì%s%s\81C\89E(r)\82»\82ê\82Æ\82à\8d¶(l)\81H",
2220                             humanoid(youmonst.data) ? "\96ò" : "",
2221                             body_part(FINGER));
2222 #endif
2223                     answer = yn_function(qbuf, "rl", '\0');
2224                     switch (answer) {
2225                     case '\0':
2226                         return 0;
2227                     case 'l':
2228                     case 'L':
2229                         mask = LEFT_RING;
2230                         break;
2231                     case 'r':
2232                     case 'R':
2233                         mask = RIGHT_RING;
2234                         break;
2235                     }
2236                 } while (!mask);
2237             }
2238             if (uarmg && uarmg->cursed) {
2239                 res = !uarmg->bknown;
2240                 uarmg->bknown = 1;
2241 /*JP
2242                 You("cannot remove your gloves to put on the ring.");
2243 */
2244                 You("\8ew\97Ö\82ð\82Í\82ß\82æ\82¤\82Æ\82µ\82½\82ª\8f¬\8eè\82ª\92E\82°\82È\82¢\81D");
2245                 return res; /* uses move iff we learned gloves are cursed */
2246             }
2247             if (uwep) {
2248                 res = !uwep->bknown; /* check this before calling welded() */
2249                 if ((mask == RIGHT_RING || bimanual(uwep)) && welded(uwep)) {
2250                     const char *hand = body_part(HAND);
2251
2252                     /* welded will set bknown */
2253                     if (bimanual(uwep))
2254                         hand = makeplural(hand);
2255 /*JP
2256                     You("cannot free your weapon %s to put on the ring.",
2257 */
2258                     You("\8ew\97Ö\82ð\82Í\82ß\82æ\82¤\82Æ\82µ\82½\82ª\97\98%s\82Ì\8e©\97R\82ª\82«\82©\82È\82¢\81D",
2259                         hand);
2260                     return res; /* uses move iff we learned weapon is cursed */
2261                 }
2262             }
2263         } else if (obj->oclass == AMULET_CLASS) {
2264             if (uamul) {
2265 #if 0 /*JP*/
2266                 already_wearing("an amulet");
2267 #else
2268                 already_wearing("\96\82\8f\9c\82¯", uamul);
2269 #endif
2270                 return 0;
2271             }
2272         } else if (eyewear) {
2273             if (ublindf) {
2274                 if (ublindf->otyp == TOWEL)
2275 #if 0 /*JP:T*/
2276                     Your("%s is already covered by a towel.",
2277                          body_part(FACE));
2278 #else
2279                     You("\8aù\82É\83^\83I\83\8b\82ð\90g\82É\82Â\82¯\82Ä\82¢\82é\81D");
2280 #endif
2281                 else if (ublindf->otyp == BLINDFOLD) {
2282                     if (obj->otyp == LENSES)
2283 /*JP
2284                         already_wearing2("lenses", "a blindfold");
2285 */
2286                         already_wearing2("\83\8c\83\93\83Y", "\96Ú\89B\82µ");
2287                     else
2288 #if 0 /*JP*/
2289                         already_wearing("a blindfold");
2290 #else
2291                         already_wearing("\96Ú\89B\82µ", ublindf);
2292 #endif
2293                 } else if (ublindf->otyp == LENSES) {
2294                     if (obj->otyp == BLINDFOLD)
2295 /*JP
2296                         already_wearing2("a blindfold", "some lenses");
2297 */
2298                         already_wearing2("\96Ú\89B\82µ", "\83\8c\83\93\83Y");
2299                     else
2300 #if 0 /*JP*/
2301                         already_wearing("some lenses");
2302 #else
2303                         already_wearing("\83\8c\83\93\83Y", ublindf);
2304 #endif
2305                 } else {
2306 #if 0 /*JP*/
2307                     already_wearing(something); /* ??? */
2308 #else
2309                     already_wearing("\89½\82©", ublindf); /* ??? */
2310 #endif
2311                 }
2312                 return 0;
2313             }
2314         } else {
2315             /* neither armor nor accessory */
2316 /*JP
2317             You_cant("wear that!");
2318 */
2319             You_cant("\82»\82ê\82ð\90g\82É\82Â\82¯\82ç\82ê\82È\82¢\81I");
2320             return 0;
2321         }
2322     }
2323
2324     if (!retouch_object(&obj, FALSE))
2325         return 1; /* costs a turn even though it didn't get worn */
2326
2327     if (armor) {
2328         int delay;
2329
2330         obj->known = 1; /* since AC is shown on the status line */
2331         /* if the armor is wielded, release it for wearing */
2332         if (obj->owornmask & W_WEAPON)
2333             remove_worn_item(obj, FALSE);
2334         setworn(obj, mask);
2335         delay = -objects[obj->otyp].oc_delay;
2336         if (delay) {
2337             nomul(delay);
2338 /*JP
2339             multi_reason = "dressing up";
2340 */
2341             multi_reason = "\91\95\94õ\82µ\82Ä\82¢\82é\8e\9e\82É";
2342             if (is_boots(obj))
2343                 afternmv = Boots_on;
2344             if (is_helmet(obj))
2345                 afternmv = Helmet_on;
2346             if (is_gloves(obj))
2347                 afternmv = Gloves_on;
2348             if (obj == uarm)
2349                 afternmv = Armor_on;
2350 /*JP
2351             nomovemsg = "You finish your dressing maneuver.";
2352 */
2353             nomovemsg = "\91\95\94õ\82µ\8fI\82¦\82½\81D";
2354         } else {
2355             if (is_cloak(obj))
2356                 (void) Cloak_on();
2357             if (is_shield(obj))
2358                 (void) Shield_on();
2359             if (is_shirt(obj))
2360                 (void) Shirt_on();
2361             on_msg(obj);
2362         }
2363         context.takeoff.mask = context.takeoff.what = 0L;
2364     } else { /* not armor */
2365         boolean give_feedback = FALSE;
2366
2367         /* [releasing wielded accessory handled in Xxx_on()] */
2368         if (ring) {
2369             setworn(obj, mask);
2370             Ring_on(obj);
2371             give_feedback = TRUE;
2372         } else if (obj->oclass == AMULET_CLASS) {
2373             setworn(obj, W_AMUL);
2374             Amulet_on();
2375             /* no feedback here if amulet of change got used up */
2376             give_feedback = (uamul != 0);
2377         } else if (eyewear) {
2378             /* setworn() handled by Blindf_on() */
2379             Blindf_on(obj);
2380             /* message handled by Blindf_on(); leave give_feedback False */
2381         }
2382         /* feedback for ring or for amulet other than 'change' */
2383         if (give_feedback && is_worn(obj))
2384             prinv((char *) 0, obj, 0L);
2385     }
2386     return 1;
2387 }
2388
2389 /* the 'W' command */
2390 int
2391 dowear()
2392 {
2393     struct obj *otmp;
2394
2395     /* cantweararm() checks for suits of armor, not what we want here;
2396        verysmall() or nohands() checks for shields, gloves, etc... */
2397     if (verysmall(youmonst.data) || nohands(youmonst.data)) {
2398 /*JP
2399         pline("Don't even bother.");
2400 */
2401         pline("\82»\82ñ\82È\82Â\82Ü\82ç\82È\82¢\82±\82Æ\82É\82±\82¾\82í\82é\82È\81D");
2402         return 0;
2403     }
2404     if (uarm && uarmu && uarmc && uarmh && uarms && uarmg && uarmf
2405         && uleft && uright && uamul && ublindf) {
2406         /* 'W' message doesn't mention accessories */
2407 /*JP
2408         You("are already wearing a full complement of armor.");
2409 */
2410         You("\82·\82Å\82É\8a®\91S\91\95\94õ\82µ\82Ä\82¢\82é\81D");
2411         return 0;
2412     }
2413     otmp = getobj(clothes, "wear");
2414     return otmp ? accessory_or_armor_on(otmp) : 0;
2415 }
2416
2417 /* the 'P' command */
2418 int
2419 doputon()
2420 {
2421     struct obj *otmp;
2422
2423     if (uleft && uright && uamul && ublindf
2424         && uarm && uarmu && uarmc && uarmh && uarms && uarmg && uarmf) {
2425         /* 'P' message doesn't mention armor */
2426 #if 0 /*JP*/
2427         Your("%s%s are full, and you're already wearing an amulet and %s.",
2428              humanoid(youmonst.data) ? "ring-" : "",
2429              makeplural(body_part(FINGER)),
2430              (ublindf->otyp == LENSES) ? "some lenses" : "a blindfold");
2431 #else
2432         Your("%s%s\82Í\82Ó\82³\82ª\82Á\82Ä\82é\82µ\81C\82·\82Å\82É\96\82\8f\9c\82¯\82Æ%s\82à\90g\82É\82Â\82¯\82Ä\82¢\82é\81D",
2433              humanoid(youmonst.data) ? "\96ò" : "",
2434              body_part(FINGER),
2435              ublindf->otyp==LENSES ? "\83\8c\83\93\83Y" : "\96Ú\89B\82µ");
2436 #endif
2437         return 0;
2438     }
2439     otmp = getobj(accessories, "put on");
2440     return otmp ? accessory_or_armor_on(otmp) : 0;
2441 }
2442
2443 /* calculate current armor class */
2444 void
2445 find_ac()
2446 {
2447     int uac = mons[u.umonnum].ac; /* base armor class for current form */
2448
2449     /* armor class from worn gear */
2450     if (uarm)
2451         uac -= ARM_BONUS(uarm);
2452     if (uarmc)
2453         uac -= ARM_BONUS(uarmc);
2454     if (uarmh)
2455         uac -= ARM_BONUS(uarmh);
2456     if (uarmf)
2457         uac -= ARM_BONUS(uarmf);
2458     if (uarms)
2459         uac -= ARM_BONUS(uarms);
2460     if (uarmg)
2461         uac -= ARM_BONUS(uarmg);
2462     if (uarmu)
2463         uac -= ARM_BONUS(uarmu);
2464     if (uleft && uleft->otyp == RIN_PROTECTION)
2465         uac -= uleft->spe;
2466     if (uright && uright->otyp == RIN_PROTECTION)
2467         uac -= uright->spe;
2468
2469     /* armor class from other sources */
2470     if (HProtection & INTRINSIC)
2471         uac -= u.ublessed;
2472     uac -= u.uspellprot;
2473
2474     /* [The magic binary numbers 127 and -128 should be replaced with the
2475      * mystic decimal numbers 99 and -99 which require no explanation to
2476      * the uninitiated and would cap the width of a status line value at
2477      * one less character.]
2478      */
2479     if (uac < -128)
2480         uac = -128; /* u.uac is an schar */
2481     else if (uac > 127)
2482         uac = 127; /* for completeness */
2483
2484     if (uac != u.uac) {
2485         u.uac = uac;
2486         context.botl = 1;
2487     }
2488 }
2489
2490 void
2491 glibr()
2492 {
2493     register struct obj *otmp;
2494     int xfl = 0;
2495     boolean leftfall, rightfall, wastwoweap = FALSE;
2496     const char *otherwep = 0, *thiswep, *which, *hand;
2497
2498     leftfall = (uleft && !uleft->cursed
2499                 && (!uwep || !welded(uwep) || !bimanual(uwep)));
2500     rightfall = (uright && !uright->cursed && (!welded(uwep)));
2501     if (!uarmg && (leftfall || rightfall) && !nolimbs(youmonst.data)) {
2502         /* changed so cursed rings don't fall off, GAN 10/30/86 */
2503 #if 0 /*JP*/
2504         Your("%s off your %s.",
2505              (leftfall && rightfall) ? "rings slip" : "ring slips",
2506              (leftfall && rightfall) ? makeplural(body_part(FINGER))
2507                                      : body_part(FINGER));
2508 #else
2509         Your("\8ew\97Ö\82Í%s\82©\82ç\8a\8a\82è\97\8e\82¿\82½\81D", body_part(FINGER));
2510 #endif
2511         xfl++;
2512         if (leftfall) {
2513             otmp = uleft;
2514             Ring_off(uleft);
2515             dropx(otmp);
2516         }
2517         if (rightfall) {
2518             otmp = uright;
2519             Ring_off(uright);
2520             dropx(otmp);
2521         }
2522     }
2523
2524     otmp = uswapwep;
2525     if (u.twoweap && otmp) {
2526         /* secondary weapon doesn't need nearly as much handling as
2527            primary; when in two-weapon mode, we know it's one-handed
2528            with something else in the other hand and also that it's
2529            a weapon or weptool rather than something unusual, plus
2530            we don't need to compare its type with the primary */
2531         otherwep = is_sword(otmp) ? c_sword : weapon_descr(otmp);
2532         if (otmp->quan > 1L)
2533             otherwep = makeplural(otherwep);
2534         hand = body_part(HAND);
2535         which = "left ";
2536 #if 0 /*JP*/
2537         Your("%s %s%s from your %s%s.", otherwep, xfl ? "also " : "",
2538              otense(otmp, "slip"), which, hand);
2539 #else
2540         You("%s%s%s\82©\82ç\8a\8a\82è\97\8e\82Æ\82µ\82½\81D", otherwep, xfl ? "\82à\82Ü\82½" : "\82ð",
2541             body_part(HAND));
2542 #endif
2543         xfl++;
2544         wastwoweap = TRUE;
2545         setuswapwep((struct obj *) 0); /* clears u.twoweap */
2546         if (canletgo(otmp, ""))
2547             dropx(otmp);
2548     }
2549     otmp = uwep;
2550     if (otmp && !welded(otmp)) {
2551         long savequan = otmp->quan;
2552
2553         /* nice wording if both weapons are the same type */
2554         thiswep = is_sword(otmp) ? c_sword : weapon_descr(otmp);
2555         if (otherwep && strcmp(thiswep, makesingular(otherwep)))
2556             otherwep = 0;
2557         if (otmp->quan > 1L) {
2558             /* most class names for unconventional wielded items
2559                are ok, but if wielding multiple apples or rations
2560                we don't want "your foods slip", so force non-corpse
2561                food to be singular; skipping makeplural() isn't
2562                enough--we need to fool otense() too */
2563             if (!strcmp(thiswep, "food"))
2564                 otmp->quan = 1L;
2565             else
2566                 thiswep = makeplural(thiswep);
2567         }
2568         hand = body_part(HAND);
2569         which = "";
2570         if (bimanual(otmp))
2571             hand = makeplural(hand);
2572         else if (wastwoweap)
2573             which = "right "; /* preceding msg was about left */
2574 #if 0 /*JP*/
2575         pline("%s %s%s %s%s from your %s%s.",
2576               !strncmp(thiswep, "corpse", 6) ? "The" : "Your",
2577               otherwep ? "other " : "", thiswep, xfl ? "also " : "",
2578               otense(otmp, "slip"), which, hand);
2579 #else
2580         You("%s%s%s%s\82©\82ç\8a\8a\82è\97\8e\82Æ\82µ\82½\81D",
2581             otherwep ? "\82à\82¤\82Ð\82Æ\82Â\82Ì" : "", thiswep,
2582             xfl ? "\82à\82Ü\82½" : "\82ð",
2583             body_part(HAND));
2584 #endif
2585         /* xfl++; */
2586         otmp->quan = savequan;
2587         setuwep((struct obj *) 0);
2588         if (canletgo(otmp, ""))
2589             dropx(otmp);
2590     }
2591 }
2592
2593 struct obj *
2594 some_armor(victim)
2595 struct monst *victim;
2596 {
2597     register struct obj *otmph, *otmp;
2598
2599     otmph = (victim == &youmonst) ? uarmc : which_armor(victim, W_ARMC);
2600     if (!otmph)
2601         otmph = (victim == &youmonst) ? uarm : which_armor(victim, W_ARM);
2602     if (!otmph)
2603         otmph = (victim == &youmonst) ? uarmu : which_armor(victim, W_ARMU);
2604
2605     otmp = (victim == &youmonst) ? uarmh : which_armor(victim, W_ARMH);
2606     if (otmp && (!otmph || !rn2(4)))
2607         otmph = otmp;
2608     otmp = (victim == &youmonst) ? uarmg : which_armor(victim, W_ARMG);
2609     if (otmp && (!otmph || !rn2(4)))
2610         otmph = otmp;
2611     otmp = (victim == &youmonst) ? uarmf : which_armor(victim, W_ARMF);
2612     if (otmp && (!otmph || !rn2(4)))
2613         otmph = otmp;
2614     otmp = (victim == &youmonst) ? uarms : which_armor(victim, W_ARMS);
2615     if (otmp && (!otmph || !rn2(4)))
2616         otmph = otmp;
2617     return otmph;
2618 }
2619
2620 /* used for praying to check and fix levitation trouble */
2621 struct obj *
2622 stuck_ring(ring, otyp)
2623 struct obj *ring;
2624 int otyp;
2625 {
2626     if (ring != uleft && ring != uright) {
2627         impossible("stuck_ring: neither left nor right?");
2628         return (struct obj *) 0;
2629     }
2630
2631     if (ring && ring->otyp == otyp) {
2632         /* reasons ring can't be removed match those checked by select_off();
2633            limbless case has extra checks because ordinarily it's temporary */
2634         if (nolimbs(youmonst.data) && uamul
2635             && uamul->otyp == AMULET_OF_UNCHANGING && uamul->cursed)
2636             return uamul;
2637         if (welded(uwep) && (ring == uright || bimanual(uwep)))
2638             return uwep;
2639         if (uarmg && uarmg->cursed)
2640             return uarmg;
2641         if (ring->cursed)
2642             return ring;
2643     }
2644     /* either no ring or not right type or nothing prevents its removal */
2645     return (struct obj *) 0;
2646 }
2647
2648 /* also for praying; find worn item that confers "Unchanging" attribute */
2649 struct obj *
2650 unchanger()
2651 {
2652     if (uamul && uamul->otyp == AMULET_OF_UNCHANGING)
2653         return uamul;
2654     return 0;
2655 }
2656
2657 STATIC_PTR
2658 int
2659 select_off(otmp)
2660 register struct obj *otmp;
2661 {
2662     struct obj *why;
2663     char buf[BUFSZ];
2664
2665     if (!otmp)
2666         return 0;
2667     *buf = '\0'; /* lint suppression */
2668
2669     /* special ring checks */
2670     if (otmp == uright || otmp == uleft) {
2671         if (nolimbs(youmonst.data)) {
2672 #if 0 /*JP*/
2673             pline_The("ring is stuck.");
2674 #else
2675             pline("\8ew\97Ö\82Í\91Ì\82É\96\84\82Ü\82Á\82Ä\82µ\82Ü\82Á\82Ä\82¢\82é\81D");
2676 #endif
2677             return 0;
2678         }
2679         why = 0; /* the item which prevents ring removal */
2680         if (welded(uwep) && (otmp == uright || bimanual(uwep))) {
2681 /*JP
2682             Sprintf(buf, "free a weapon %s", body_part(HAND));
2683 */
2684             Sprintf(buf, "\97\98\98r\82Ì\8e©\97R\82ª\82«\82©\82È\82¢");
2685             why = uwep;
2686         } else if (uarmg && uarmg->cursed) {
2687 /*JP
2688             Sprintf(buf, "take off your %s", c_gloves);
2689 */
2690             Sprintf(buf, "%s\82ª\92E\82°\82È\82¢", c_gloves);
2691             why = uarmg;
2692         }
2693         if (why) {
2694 /*JP
2695             You("cannot %s to remove the ring.", buf);
2696 */
2697             You("\8ew\97Ö\82ð\82Í\82¸\82»\82¤\82Æ\82µ\82½\82ª%s\81D", buf);
2698             why->bknown = TRUE;
2699             return 0;
2700         }
2701     }
2702     /* special glove checks */
2703     if (otmp == uarmg) {
2704         if (welded(uwep)) {
2705 #if 0 /*JP*/
2706             You("are unable to take off your %s while wielding that %s.",
2707                 c_gloves, is_sword(uwep) ? c_sword : c_weapon);
2708 #else
2709             You("%s\82ð\8e\9d\82Á\82½\82Ü\82Ü%s\82ð\82Í\82¸\82·\82±\82Æ\82Í\82Å\82«\82È\82¢\81D",
2710                 is_sword(uwep) ? c_sword : c_weapon, c_gloves);
2711 #endif
2712             uwep->bknown = TRUE;
2713             return 0;
2714         } else if (Glib) {
2715 #if 0 /*JP*/
2716             You_cant("take off the slippery %s with your slippery %s.",
2717                      c_gloves, makeplural(body_part(FINGER)));
2718 #else
2719             You_cant("\8a\8a\82è\82â\82·\82¢%s\82ð\8a\8a\82è\82â\82·\82¢%s\82Å\82Í\82¸\82¹\82È\82¢\81D",
2720                      c_gloves, body_part(FINGER));
2721 #endif
2722             return 0;
2723         }
2724     }
2725     /* special boot checks */
2726     if (otmp == uarmf) {
2727         if (u.utrap && u.utraptype == TT_BEARTRAP) {
2728 /*JP
2729             pline_The("bear trap prevents you from pulling your %s out.",
2730 */
2731             pline("%s\82ª\8cF\82Ìã©\82É\82Â\82©\82Ü\82Á\82Ä\82¢\82é\82Ì\82Å\92E\82®\82±\82Æ\82ª\82Å\82«\82È\82¢\81D",
2732                       body_part(FOOT));
2733             return 0;
2734         } else if (u.utrap && u.utraptype == TT_INFLOOR) {
2735 /*JP
2736             You("are stuck in the %s, and cannot pull your %s out.",
2737 */
2738             You("%s\82ª%s\82É\82Í\82Ü\82Á\82Ä\82¢\82é\82Ì\82Å\92E\82®\82±\82Æ\82ª\82Å\82«\82È\82¢\81D",
2739                 surface(u.ux, u.uy), makeplural(body_part(FOOT)));
2740             return 0;
2741         }
2742     }
2743     /* special suit and shirt checks */
2744     if (otmp == uarm || otmp == uarmu) {
2745         why = 0; /* the item which prevents disrobing */
2746         if (uarmc && uarmc->cursed) {
2747 /*JP
2748             Sprintf(buf, "remove your %s", cloak_simple_name(uarmc));
2749 */
2750             Sprintf(buf, "%s\82ª\92E\82°\82È\82¢", cloak_simple_name(uarmc));
2751             why = uarmc;
2752         } else if (otmp == uarmu && uarm && uarm->cursed) {
2753 /*JP
2754             Sprintf(buf, "remove your %s", c_suit);
2755 */
2756             Sprintf(buf, "%s\82ª\92E\82°\82È\82¢", c_suit);
2757             why = uarm;
2758         } else if (welded(uwep) && bimanual(uwep)) {
2759 #if 0 /*JP*/
2760             Sprintf(buf, "release your %s",
2761                     is_sword(uwep) ? c_sword : (uwep->otyp == BATTLE_AXE)
2762                                                    ? c_axe
2763                                                    : c_weapon);
2764 #else
2765             Sprintf(buf, "%s\82ª\8eè\95ú\82¹\82È\82¢",
2766                     is_sword(uwep) ? c_sword : (uwep->otyp == BATTLE_AXE)
2767                                                    ? c_axe
2768                                                    : c_weapon);
2769 #endif
2770             why = uwep;
2771         }
2772         if (why) {
2773 /*JP
2774             You("cannot %s to take off %s.", buf, the(xname(otmp)));
2775 */
2776             You("%s\82ð\82Í\82¸\82»\82¤\82Æ\82µ\82½\82ª%s\81D", xname(otmp), buf);
2777             why->bknown = TRUE;
2778             return 0;
2779         }
2780     }
2781     /* basic curse check */
2782     if (otmp == uquiver || (otmp == uswapwep && !u.twoweap)) {
2783         ; /* some items can be removed even when cursed */
2784     } else {
2785         /* otherwise, this is fundamental */
2786         if (cursed(otmp))
2787             return 0;
2788     }
2789
2790     if (otmp == uarm)
2791         context.takeoff.mask |= WORN_ARMOR;
2792     else if (otmp == uarmc)
2793         context.takeoff.mask |= WORN_CLOAK;
2794     else if (otmp == uarmf)
2795         context.takeoff.mask |= WORN_BOOTS;
2796     else if (otmp == uarmg)
2797         context.takeoff.mask |= WORN_GLOVES;
2798     else if (otmp == uarmh)
2799         context.takeoff.mask |= WORN_HELMET;
2800     else if (otmp == uarms)
2801         context.takeoff.mask |= WORN_SHIELD;
2802     else if (otmp == uarmu)
2803         context.takeoff.mask |= WORN_SHIRT;
2804     else if (otmp == uleft)
2805         context.takeoff.mask |= LEFT_RING;
2806     else if (otmp == uright)
2807         context.takeoff.mask |= RIGHT_RING;
2808     else if (otmp == uamul)
2809         context.takeoff.mask |= WORN_AMUL;
2810     else if (otmp == ublindf)
2811         context.takeoff.mask |= WORN_BLINDF;
2812     else if (otmp == uwep)
2813         context.takeoff.mask |= W_WEP;
2814     else if (otmp == uswapwep)
2815         context.takeoff.mask |= W_SWAPWEP;
2816     else if (otmp == uquiver)
2817         context.takeoff.mask |= W_QUIVER;
2818
2819     else
2820         impossible("select_off: %s???", doname(otmp));
2821
2822     return 0;
2823 }
2824
2825 STATIC_OVL struct obj *
2826 do_takeoff()
2827 {
2828     struct obj *otmp = (struct obj *) 0;
2829     struct takeoff_info *doff = &context.takeoff;
2830
2831     context.takeoff.mask |= I_SPECIAL; /* set flag for cancel_doff() */
2832     if (doff->what == W_WEP) {
2833         if (!cursed(uwep)) {
2834             setuwep((struct obj *) 0);
2835 /*JP
2836             You("are empty %s.", body_part(HANDED));
2837 */
2838             You("\89½\82à%s\82É\82µ\82Ä\82¢\82È\82¢\81D", body_part(HAND));
2839             u.twoweap = FALSE;
2840         }
2841     } else if (doff->what == W_SWAPWEP) {
2842         setuswapwep((struct obj *) 0);
2843 /*JP
2844         You("no longer have a second weapon readied.");
2845 */
2846         You("\97\\94õ\82Ì\95\90\8aí\82ð\82¨\82³\82ß\82½\81D");
2847         u.twoweap = FALSE;
2848     } else if (doff->what == W_QUIVER) {
2849         setuqwep((struct obj *) 0);
2850 /*JP
2851         You("no longer have ammunition readied.");
2852 */
2853         You("\8f\80\94õ\82µ\82½\96î\92e\82ð\82¨\82³\82ß\82½\81D");
2854     } else if (doff->what == WORN_ARMOR) {
2855         otmp = uarm;
2856         if (!cursed(otmp))
2857             (void) Armor_off();
2858     } else if (doff->what == WORN_CLOAK) {
2859         otmp = uarmc;
2860         if (!cursed(otmp))
2861             (void) Cloak_off();
2862     } else if (doff->what == WORN_BOOTS) {
2863         otmp = uarmf;
2864         if (!cursed(otmp))
2865             (void) Boots_off();
2866     } else if (doff->what == WORN_GLOVES) {
2867         otmp = uarmg;
2868         if (!cursed(otmp))
2869             (void) Gloves_off();
2870     } else if (doff->what == WORN_HELMET) {
2871         otmp = uarmh;
2872         if (!cursed(otmp))
2873             (void) Helmet_off();
2874     } else if (doff->what == WORN_SHIELD) {
2875         otmp = uarms;
2876         if (!cursed(otmp))
2877             (void) Shield_off();
2878     } else if (doff->what == WORN_SHIRT) {
2879         otmp = uarmu;
2880         if (!cursed(otmp))
2881             (void) Shirt_off();
2882     } else if (doff->what == WORN_AMUL) {
2883         otmp = uamul;
2884         if (!cursed(otmp))
2885             Amulet_off();
2886     } else if (doff->what == LEFT_RING) {
2887         otmp = uleft;
2888         if (!cursed(otmp))
2889             Ring_off(uleft);
2890     } else if (doff->what == RIGHT_RING) {
2891         otmp = uright;
2892         if (!cursed(otmp))
2893             Ring_off(uright);
2894     } else if (doff->what == WORN_BLINDF) {
2895         if (!cursed(ublindf))
2896             Blindf_off(ublindf);
2897     } else {
2898         impossible("do_takeoff: taking off %lx", doff->what);
2899     }
2900     context.takeoff.mask &= ~I_SPECIAL; /* clear cancel_doff() flag */
2901
2902     return otmp;
2903 }
2904
2905 /* occupation callback for 'A' */
2906 STATIC_PTR
2907 int
2908 take_off(VOID_ARGS)
2909 {
2910     register int i;
2911     register struct obj *otmp;
2912     struct takeoff_info *doff = &context.takeoff;
2913
2914     if (doff->what) {
2915         if (doff->delay > 0) {
2916             doff->delay--;
2917             return 1; /* still busy */
2918         }
2919         if ((otmp = do_takeoff()) != 0)
2920             off_msg(otmp);
2921         doff->mask &= ~doff->what;
2922         doff->what = 0L;
2923     }
2924
2925     for (i = 0; takeoff_order[i]; i++)
2926         if (doff->mask & takeoff_order[i]) {
2927             doff->what = takeoff_order[i];
2928             break;
2929         }
2930
2931     otmp = (struct obj *) 0;
2932     doff->delay = 0;
2933
2934     if (doff->what == 0L) {
2935 /*JP
2936         You("finish %s.", doff->disrobing);
2937 */
2938         You("\91\95\94õ\82ð\89ð\82«\82¨\82¦\82½\81D");
2939         return 0;
2940     } else if (doff->what == W_WEP) {
2941         doff->delay = 1;
2942     } else if (doff->what == W_SWAPWEP) {
2943         doff->delay = 1;
2944     } else if (doff->what == W_QUIVER) {
2945         doff->delay = 1;
2946     } else if (doff->what == WORN_ARMOR) {
2947         otmp = uarm;
2948         /* If a cloak is being worn, add the time to take it off and put
2949          * it back on again.  Kludge alert! since that time is 0 for all
2950          * known cloaks, add 1 so that it actually matters...
2951          */
2952         if (uarmc)
2953             doff->delay += 2 * objects[uarmc->otyp].oc_delay + 1;
2954     } else if (doff->what == WORN_CLOAK) {
2955         otmp = uarmc;
2956     } else if (doff->what == WORN_BOOTS) {
2957         otmp = uarmf;
2958     } else if (doff->what == WORN_GLOVES) {
2959         otmp = uarmg;
2960     } else if (doff->what == WORN_HELMET) {
2961         otmp = uarmh;
2962     } else if (doff->what == WORN_SHIELD) {
2963         otmp = uarms;
2964     } else if (doff->what == WORN_SHIRT) {
2965         otmp = uarmu;
2966         /* add the time to take off and put back on armor and/or cloak */
2967         if (uarm)
2968             doff->delay += 2 * objects[uarm->otyp].oc_delay;
2969         if (uarmc)
2970             doff->delay += 2 * objects[uarmc->otyp].oc_delay + 1;
2971     } else if (doff->what == WORN_AMUL) {
2972         doff->delay = 1;
2973     } else if (doff->what == LEFT_RING) {
2974         doff->delay = 1;
2975     } else if (doff->what == RIGHT_RING) {
2976         doff->delay = 1;
2977     } else if (doff->what == WORN_BLINDF) {
2978         /* [this used to be 2, but 'R' (and 'T') only require 1 turn to
2979            remove a blindfold, so 'A' shouldn't have been requiring 2] */
2980         doff->delay = 1;
2981     } else {
2982         impossible("take_off: taking off %lx", doff->what);
2983         return 0; /* force done */
2984     }
2985
2986     if (otmp)
2987         doff->delay += objects[otmp->otyp].oc_delay;
2988
2989     /* Since setting the occupation now starts the counter next move, that
2990      * would always produce a delay 1 too big per item unless we subtract
2991      * 1 here to account for it.
2992      */
2993     if (doff->delay > 0)
2994         doff->delay--;
2995
2996     set_occupation(take_off, doff->disrobing, 0);
2997     return 1; /* get busy */
2998 }
2999
3000 /* clear saved context to avoid inappropriate resumption of interrupted 'A' */
3001 void
3002 reset_remarm()
3003 {
3004     context.takeoff.what = context.takeoff.mask = 0L;
3005     context.takeoff.disrobing[0] = '\0';
3006 }
3007
3008 /* the 'A' command -- remove multiple worn items */
3009 int
3010 doddoremarm()
3011 {
3012     int result = 0;
3013
3014     if (context.takeoff.what || context.takeoff.mask) {
3015 /*JP
3016         You("continue %s.", context.takeoff.disrobing);
3017 */
3018         You("\91\95\94õ\82ð\89ð\82­\82Ì\82ð\8dÄ\8aJ\82µ\82½\81D");
3019 /*JP
3020         set_occupation(take_off, context.takeoff.disrobing, 0);
3021 */
3022         set_occupation(take_off, "\91\95\94õ\82ð\89ð\82­", 0);
3023         return 0;
3024     } else if (!uwep && !uswapwep && !uquiver && !uamul && !ublindf && !uleft
3025                && !uright && !wearing_armor()) {
3026 /*JP
3027         You("are not wearing anything.");
3028 */
3029         You("\89½\82à\91\95\94õ\82µ\82Ä\82¢\82È\82¢\81D");
3030         return 0;
3031     }
3032
3033     add_valid_menu_class(0); /* reset */
3034     if (flags.menu_style != MENU_TRADITIONAL
3035         || (result = ggetobj("take off", select_off, 0, FALSE,
3036                              (unsigned *) 0)) < -1)
3037         result = menu_remarm(result);
3038
3039     if (context.takeoff.mask) {
3040 #if 0 /*JP*//*\93ú\96{\8cê\82Å\82Í\8eg\82í\82È\82¢*/
3041         /* default activity for armor and/or accessories,
3042            possibly combined with weapons */
3043         (void) strncpy(context.takeoff.disrobing, "disrobing", CONTEXTVERBSZ);
3044         /* specific activity when handling weapons only */
3045         if (!(context.takeoff.mask & ~W_WEAPON))
3046             (void) strncpy(context.takeoff.disrobing, "disarming",
3047                            CONTEXTVERBSZ);
3048 #endif
3049         (void) take_off();
3050     }
3051     /* The time to perform the command is already completely accounted for
3052      * in take_off(); if we return 1, that would add an extra turn to each
3053      * disrobe.
3054      */
3055     return 0;
3056 }
3057
3058 STATIC_OVL int
3059 menu_remarm(retry)
3060 int retry;
3061 {
3062     int n, i = 0;
3063     menu_item *pick_list;
3064     boolean all_worn_categories = TRUE;
3065
3066     if (retry) {
3067         all_worn_categories = (retry == -2);
3068     } else if (flags.menu_style == MENU_FULL) {
3069         all_worn_categories = FALSE;
3070 /*JP
3071         n = query_category("What type of things do you want to take off?",
3072 */
3073         n = query_category("\82Ç\82Ì\83^\83C\83v\82Ì\95¨\82Ì\91\95\94õ\82ð\89ð\82«\82Ü\82·\82©\81H",
3074                            invent, (WORN_TYPES | ALL_TYPES
3075                                     | UNPAID_TYPES | BUCX_TYPES),
3076                            &pick_list, PICK_ANY);
3077         if (!n)
3078             return 0;
3079         for (i = 0; i < n; i++) {
3080             if (pick_list[i].item.a_int == ALL_TYPES_SELECTED)
3081                 all_worn_categories = TRUE;
3082             else
3083                 add_valid_menu_class(pick_list[i].item.a_int);
3084         }
3085         free((genericptr_t) pick_list);
3086     } else if (flags.menu_style == MENU_COMBINATION) {
3087         unsigned ggofeedback = 0;
3088
3089         i = ggetobj("take off", select_off, 0, TRUE, &ggofeedback);
3090         if (ggofeedback & ALL_FINISHED)
3091             return 0;
3092         all_worn_categories = (i == -2);
3093     }
3094     if (menu_class_present('u')
3095         || menu_class_present('B') || menu_class_present('U')
3096         || menu_class_present('C') || menu_class_present('X'))
3097         all_worn_categories = FALSE;
3098
3099 #if 0 /*JP:T*/
3100     n = query_objlist("What do you want to take off?", &invent,
3101                       (SIGNAL_NOMENU | USE_INVLET | INVORDER_SORT),
3102                       &pick_list, PICK_ANY,
3103                       all_worn_categories ? is_worn : is_worn_by_type);
3104 #else
3105     n = query_objlist("\82Ç\82Ì\91\95\94õ\82ð\89ð\82«\82Ü\82·\82©\81H", &invent,
3106                       (SIGNAL_NOMENU | USE_INVLET | INVORDER_SORT),
3107                       &pick_list, PICK_ANY,
3108                       all_worn_categories ? is_worn : is_worn_by_type);
3109 #endif
3110     if (n > 0) {
3111         for (i = 0; i < n; i++)
3112             (void) select_off(pick_list[i].item.a_obj);
3113         free((genericptr_t) pick_list);
3114     } else if (n < 0 && flags.menu_style != MENU_COMBINATION) {
3115 /*JP
3116         There("is nothing else you can remove or unwield.");
3117 */
3118         pline("\91\95\94õ\82ð\89ð\82¯\82é\82à\82Ì\82Í\89½\82à\82È\82¢\81D");
3119     }
3120     return 0;
3121 }
3122
3123 /* hit by destroy armor scroll/black dragon breath/monster spell */
3124 int
3125 destroy_arm(atmp)
3126 register struct obj *atmp;
3127 {
3128     register struct obj *otmp;
3129 #define DESTROY_ARM(o)                            \
3130     ((otmp = (o)) != 0 && (!atmp || atmp == otmp) \
3131              && (!obj_resists(otmp, 0, 90))       \
3132          ? (otmp->in_use = TRUE)                  \
3133          : FALSE)
3134
3135     if (DESTROY_ARM(uarmc)) {
3136         if (donning(otmp))
3137             cancel_don();
3138 /*JP
3139         Your("%s crumbles and turns to dust!", cloak_simple_name(uarmc));
3140 */
3141         Your("%s\82Í\95²\81X\82É\82È\82Á\82½\81I", cloak_simple_name(uarmc));
3142         (void) Cloak_off();
3143         useup(otmp);
3144     } else if (DESTROY_ARM(uarm)) {
3145         if (donning(otmp))
3146             cancel_don();
3147 /*JP
3148         Your("armor turns to dust and falls to the %s!", surface(u.ux, u.uy));
3149 */
3150         Your("\8aZ\82Í\90o\82Æ\82È\82è%s\82É\97\8e\82¿\82½\81I", surface(u.ux,u.uy));
3151         (void) Armor_gone();
3152         useup(otmp);
3153     } else if (DESTROY_ARM(uarmu)) {
3154         if (donning(otmp))
3155             cancel_don();
3156 /*JP
3157         Your("shirt crumbles into tiny threads and falls apart!");
3158 */
3159         Your("\83V\83\83\83c\82Í\83Y\83^\83Y\83^\82É\97ô\82¯\81C\8f¬\82³\82È\8e\85\8bû\82Æ\82È\82è\97\8e\82¿\82½\81I");
3160         (void) Shirt_off();
3161         useup(otmp);
3162     } else if (DESTROY_ARM(uarmh)) {
3163         if (donning(otmp))
3164             cancel_don();
3165 /*JP
3166         Your("%s turns to dust and is blown away!", helm_simple_name(uarmh));
3167 */
3168         Your("%s\82Í\90o\82Æ\82È\82è\90\81\82«\82Æ\82ñ\82¾\81I", helm_simple_name(uarmh));
3169         (void) Helmet_off();
3170         useup(otmp);
3171     } else if (DESTROY_ARM(uarmg)) {
3172         if (donning(otmp))
3173             cancel_don();
3174 /*JP
3175         Your("gloves vanish!");
3176 */
3177                 Your("\8f¬\8eè\82Í\8fÁ\82¦\82½\81I");
3178         (void) Gloves_off();
3179         useup(otmp);
3180 /*JP
3181         selftouch("You");
3182 */
3183         selftouch("\82»\82Ì\82Æ\82«\82 \82È\82½\82Í");
3184     } else if (DESTROY_ARM(uarmf)) {
3185         if (donning(otmp))
3186             cancel_don();
3187 /*JP
3188         Your("boots disintegrate!");
3189 */
3190         Your("\8cC\82Í\95²\81X\82É\8dÓ\82¯\82½\81I");
3191         (void) Boots_off();
3192         useup(otmp);
3193     } else if (DESTROY_ARM(uarms)) {
3194         if (donning(otmp))
3195             cancel_don();
3196 /*JP
3197         Your("shield crumbles away!");
3198 */
3199         Your("\8f\82\82Í\8dÓ\82¯\8eU\82Á\82½\81I");
3200         (void) Shield_off();
3201         useup(otmp);
3202     } else {
3203         return 0; /* could not destroy anything */
3204     }
3205
3206 #undef DESTROY_ARM
3207     stop_occupation();
3208     return 1;
3209 }
3210
3211 void
3212 adj_abon(otmp, delta)
3213 register struct obj *otmp;
3214 register schar delta;
3215 {
3216     if (uarmg && uarmg == otmp && otmp->otyp == GAUNTLETS_OF_DEXTERITY) {
3217         if (delta) {
3218             makeknown(uarmg->otyp);
3219             ABON(A_DEX) += (delta);
3220         }
3221         context.botl = 1;
3222     }
3223     if (uarmh && uarmh == otmp && otmp->otyp == HELM_OF_BRILLIANCE) {
3224         if (delta) {
3225             makeknown(uarmh->otyp);
3226             ABON(A_INT) += (delta);
3227             ABON(A_WIS) += (delta);
3228         }
3229         context.botl = 1;
3230     }
3231 }
3232
3233 /* decide whether a worn item is covered up by some other worn item,
3234    used for dipping into liquid and applying grease;
3235    some criteria are different than select_off()'s */
3236 boolean
3237 inaccessible_equipment(obj, verb, only_if_known_cursed)
3238 struct obj *obj;
3239 const char *verb; /* "dip" or "grease", or null to avoid messages */
3240 /*JP:\93ú\96{\8cê\82Å\82Í "\82ð\90Z\82·", "\82É\8e\89\82ð\93h\82é", null \82Ì\82¢\82¸\82ê\82©*/
3241 boolean only_if_known_cursed; /* ignore covering unless known to be cursed */
3242 {
3243 #if 0 /*JP*/
3244     static NEARDATA const char need_to_take_off_outer_armor[] =
3245         "need to take off %s to %s %s.";
3246 #else /*JP:\88ø\90\94\82ª\8c´\95\82Æ\95Ï\82í\82Á\82Ä\82¢\82é\82±\82Æ\82É\92\8d\88Ó*/
3247     static NEARDATA const char need_to_take_off_outer_armor[] =
3248         "%s%s\82É\82Í%s\82ð%s\95K\97v\82ª\82 \82é\81D";
3249 #endif
3250     char buf[BUFSZ];
3251     boolean anycovering = !only_if_known_cursed; /* more comprehensible... */
3252 #define BLOCKSACCESS(x) (anycovering || ((x)->cursed && (x)->bknown))
3253
3254     if (!obj || !obj->owornmask)
3255         return FALSE; /* not inaccessible */
3256
3257     /* check for suit covered by cloak */
3258     if (obj == uarm && uarmc && BLOCKSACCESS(uarmc)) {
3259         if (verb) {
3260             Strcpy(buf, yname(uarmc));
3261 #if 0 /*JP*/
3262             You(need_to_take_off_outer_armor, buf, verb, yname(obj));
3263 #else /*JP:\91Î\8fÛ\82Í\83N\83\8d\81[\83N\82È\82Ì\82Åjoffmsg\82ð\8eg\82í\82¸\8c\88\82ß\8c\82\82¿*/
3264             You(need_to_take_off_outer_armor, xname(obj), verb, buf, "\92E\82®");
3265 #endif
3266         }
3267         return TRUE;
3268     }
3269     /* check for shirt covered by suit and/or cloak */
3270     if (obj == uarmu
3271         && ((uarm && BLOCKSACCESS(uarm)) || (uarmc && BLOCKSACCESS(uarmc)))) {
3272         if (verb) {
3273             char cloaktmp[QBUFSZ], suittmp[QBUFSZ];
3274             /* if sameprefix, use yname and xname to get "your cloak and suit"
3275                or "Manlobbi's cloak and suit"; otherwise, use yname and yname
3276                to get "your cloak and Manlobbi's suit" or vice versa */
3277             boolean sameprefix = (uarm && uarmc
3278                                   && !strcmp(shk_your(cloaktmp, uarmc),
3279                                              shk_your(suittmp, uarm)));
3280
3281             *buf = '\0';
3282             if (uarmc)
3283                 Strcat(buf, yname(uarmc));
3284             if (uarm && uarmc)
3285 /*JP
3286                 Strcat(buf, " and ");
3287 */
3288                 Strcat(buf, "\82Æ");
3289             if (uarm)
3290                 Strcat(buf, sameprefix ? xname(uarm) : yname(uarm));
3291 #if 0 /*JP*/
3292             You(need_to_take_off_outer_armor, buf, verb, yname(obj));
3293 #else /*JP:\91Î\8fÛ\82Í\83N\83\8d\81[\83N\82©\8aZ\82È\82Ì\82Åjoffmsg\82ð\8eg\82í\82¸\8c\88\82ß\8c\82\82¿*/
3294             You(need_to_take_off_outer_armor, xname(obj), verb, buf, "\92E\82®");
3295 #endif
3296         }
3297         return TRUE;
3298     }
3299     /* check for ring covered by gloves */
3300     if ((obj == uleft || obj == uright) && uarmg && BLOCKSACCESS(uarmg)) {
3301         if (verb) {
3302             Strcpy(buf, yname(uarmg));
3303 #if 0 /*JP*/
3304             You(need_to_take_off_outer_armor, buf, verb, yname(obj));
3305 #else /*JP:\91Î\8fÛ\82Í\8f¬\8eè\82È\82Ì\82Åjoffmsg\82ð\8eg\82í\82¸\8c\88\82ß\8c\82\82¿*/
3306             You(need_to_take_off_outer_armor, xname(obj), verb, buf, "\82Í\82¸\82·");
3307 #endif
3308         }
3309         return TRUE;
3310     }
3311     /* item is not inaccessible */
3312     return FALSE;
3313 }
3314
3315 /*do_wear.c*/