OSDN Git Service

update year to 2019
[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-2019            */
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         pline("\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
1674     count_worn_stuff(&otmp, FALSE);
1675     if (!Narmorpieces && !Naccessories) {
1676         /* assert( GRAY_DRAGON_SCALES > YELLOW_DRAGON_SCALE_MAIL ); */
1677         if (uskin)
1678 #if 0 /*JP*/
1679             pline_The("%s merged with your skin!",
1680                       uskin->otyp >= GRAY_DRAGON_SCALES
1681                           ? "dragon scales are"
1682                           : "dragon scale mail is");
1683 #else
1684             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",
1685                       uskin->otyp >= GRAY_DRAGON_SCALES
1686                           ? "" : "\8aZ");
1687 #endif
1688         else
1689 /*JP
1690             pline("Not wearing any armor or accessories.");
1691 */
1692             pline("\8aZ\82â\91\95\8fü\95i\82ð\90g\82É\82Â\82¯\82Ä\82¢\82È\82¢\81D");
1693         return 0;
1694     }
1695     if (Narmorpieces != 1 || ParanoidRemove)
1696         otmp = getobj(clothes, "take off");
1697     if (!otmp)
1698         return 0;
1699
1700     return armor_or_accessory_off(otmp);
1701 }
1702
1703 /* the 'R' command */
1704 int
1705 doremring()
1706 {
1707     struct obj *otmp = 0;
1708
1709     count_worn_stuff(&otmp, TRUE);
1710     if (!Naccessories && !Narmorpieces) {
1711 /*JP
1712         pline("Not wearing any accessories or armor.");
1713 */
1714         pline("\91\95\8fü\95i\82â\8aZ\82ð\90g\82É\82Â\82¯\82Ä\82¢\82È\82¢\81D");
1715         return 0;
1716     }
1717     if (Naccessories != 1 || ParanoidRemove)
1718         otmp = getobj(accessories, "remove");
1719     if (!otmp)
1720         return 0;
1721
1722     return armor_or_accessory_off(otmp);
1723 }
1724
1725 /* Check if something worn is cursed _and_ unremovable. */
1726 int
1727 cursed(otmp)
1728 register struct obj *otmp;
1729 {
1730     if (!otmp) {
1731         impossible("cursed without otmp");
1732         return 0;
1733     }
1734     /* Curses, like chickens, come home to roost. */
1735     if ((otmp == uwep) ? welded(otmp) : (int) otmp->cursed) {
1736 #if 0 /*JP*/
1737         boolean use_plural = (is_boots(otmp) || is_gloves(otmp)
1738                               || otmp->otyp == LENSES || otmp->quan > 1L);
1739
1740         You("can't.  %s cursed.", use_plural ? "They are" : "It is");
1741 #else
1742         pline("\96³\97\9d\82¾\81D\82»\82ê\82Í\8eô\82í\82ê\82Ä\82¢\82é\81D");
1743 #endif
1744         otmp->bknown = TRUE;
1745         return 1;
1746     }
1747     return 0;
1748 }
1749
1750 int
1751 armoroff(otmp)
1752 register struct obj *otmp;
1753 {
1754     register int delay = -objects[otmp->otyp].oc_delay;
1755
1756     if (cursed(otmp))
1757         return 0;
1758     if (delay) {
1759         nomul(delay);
1760 /*JP
1761         multi_reason = "disrobing";
1762 */
1763         multi_reason = "\92E\82¢\82Å\82¢\82é\8e\9e\82É";
1764         if (is_helmet(otmp)) {
1765             /* ick... */
1766 /*JP
1767             nomovemsg = !strcmp(helm_simple_name(otmp), "hat")
1768 */
1769             nomovemsg = !strcmp(helm_simple_name(otmp), "\96X\8eq")
1770 /*JP
1771                             ? "You finish taking off your hat."
1772 */
1773                             ? "\82 \82È\82½\82Í\8a\95\82ð\92E\82¬\82¨\82¦\82½\81D"
1774 /*JP
1775                             : "You finish taking off your helmet.";
1776 */
1777                             : "\82 \82È\82½\82Í\96X\8eq\82ð\92E\82¬\82¨\82¦\82½\81D";
1778             afternmv = Helmet_off;
1779         } else if (is_gloves(otmp)) {
1780 /*JP
1781             nomovemsg = "You finish taking off your gloves.";
1782 */
1783             nomovemsg = "\82 \82È\82½\82Í\8f¬\8eè\82ð\92E\82¬\82¨\82¦\82½\81D";
1784             afternmv = Gloves_off;
1785         } else if (is_boots(otmp)) {
1786 /*JP
1787             nomovemsg = "You finish taking off your boots.";
1788 */
1789             nomovemsg = "\82 \82È\82½\82Í\8cC\82ð\92E\82¬\82¨\82¦\82½\81D";
1790             afternmv = Boots_off;
1791         } else {
1792 /*JP
1793             nomovemsg = "You finish taking off your suit.";
1794 */
1795             nomovemsg = "\82 \82È\82½\82Í\92\85\82Ä\82¢\82é\95¨\82ð\92E\82¬\82¨\82¦\82½\81D";
1796             afternmv = Armor_off;
1797         }
1798     } else {
1799         /* Be warned!  We want off_msg after removing the item to
1800          * avoid "You were wearing ____ (being worn)."  However, an
1801          * item which grants fire resistance might cause some trouble
1802          * if removed in Hell and lifesaving puts it back on; in this
1803          * case the message will be printed at the wrong time (after
1804          * the messages saying you died and were lifesaved).  Luckily,
1805          * no cloak, shield, or fast-removable armor grants fire
1806          * resistance, so we can safely do the off_msg afterwards.
1807          * Rings do grant fire resistance, but for rings we want the
1808          * off_msg before removal anyway so there's no problem.  Take
1809          * care in adding armors granting fire resistance; this code
1810          * might need modification.
1811          * 3.2 (actually 3.1 even): that comment is obsolete since
1812          * fire resistance is not required for Gehennom so setworn()
1813          * doesn't force the resistance granting item to be re-worn
1814          * after being lifesaved anymore.
1815          */
1816         if (is_cloak(otmp))
1817             (void) Cloak_off();
1818         else if (is_shield(otmp))
1819             (void) Shield_off();
1820         else
1821             setworn((struct obj *) 0, otmp->owornmask & W_ARMOR);
1822         off_msg(otmp);
1823     }
1824     context.takeoff.mask = context.takeoff.what = 0L;
1825     return 1;
1826 }
1827
1828 /*JP 
1829 ** \95¨\82É\82æ\82Á\82Ä\93®\8e\8c\82ª\95Ï\89»\82·\82é\82Ì\82Å otmp\82ð\92Ç\89Á
1830 */
1831 STATIC_OVL void
1832 #if 0 /*JP*/
1833 already_wearing(cc)
1834 const char *cc;
1835 #else
1836 already_wearing(cc, otmp)
1837 const char *cc;
1838 struct obj *otmp;
1839 #endif
1840 {
1841 #if 1 /*JP*/
1842     const char *j;
1843     const char *m;
1844     m = jconj(jonmsg(otmp, &j), "\82Ä\82¢\82é");
1845 #endif
1846 /*JP
1847     You("are already wearing %s%c", cc, (cc == c_that_) ? '!' : '.');
1848 */
1849     You("\82à\82¤%s%s%s%s", cc, j,  m, (cc == c_that_) ? "\81I" : "\81D");
1850 }
1851
1852 STATIC_OVL void
1853 already_wearing2(cc1, cc2)
1854 const char *cc1, *cc2;
1855 {
1856 /*JP
1857     You_cant("wear %s because you're wearing %s there already.", cc1, cc2);
1858 */
1859     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);
1860 }
1861
1862 /*
1863  * canwearobj checks to see whether the player can wear a piece of armor
1864  *
1865  * inputs: otmp (the piece of armor)
1866  *         noisy (if TRUE give error messages, otherwise be quiet about it)
1867  * output: mask (otmp's armor type)
1868  */
1869 int
1870 canwearobj(otmp, mask, noisy)
1871 struct obj *otmp;
1872 long *mask;
1873 boolean noisy;
1874 {
1875     int err = 0;
1876     const char *which;
1877 #if 1 /*JP*/
1878     const char *m;
1879     const char *j;
1880 #endif
1881
1882     /* this is the same check as for 'W' (dowear), but different message,
1883        in case we get here via 'P' (doputon) */
1884     if (verysmall(youmonst.data) || nohands(youmonst.data)) {
1885         if (noisy)
1886 /*JP
1887             You("can't wear any armor in your current form.");
1888 */
1889             You("\8c»\8dÝ\82Ì\8ep\82Å\82Í\96h\8bï\82ð\90g\82É\82Â\82¯\82é\82±\82Æ\82Í\82Å\82«\82È\82¢\81D");
1890         return 0;
1891     }
1892
1893     which = is_cloak(otmp)
1894                 ? c_cloak
1895                 : is_shirt(otmp)
1896                     ? c_shirt
1897                     : is_suit(otmp)
1898                         ? c_suit
1899                         : 0;
1900     if (which && cantweararm(youmonst.data)
1901         /* same exception for cloaks as used in m_dowear() */
1902         && (which != c_cloak || youmonst.data->msize != MZ_SMALL)
1903         && (racial_exception(&youmonst, otmp) < 1)) {
1904         if (noisy)
1905 /*JP
1906             pline_The("%s will not fit on your body.", which);
1907 */
1908             pline("%s\82Í\82 \82È\82½\82Ì\91Ì\82É\8d\87\82í\82È\82¢\81D", which);
1909         return 0;
1910     } else if (otmp->owornmask & W_ARMOR) {
1911         if (noisy)
1912 #if 0 /*JP*/
1913             already_wearing(c_that_);
1914 #else
1915             already_wearing(c_that_, otmp);
1916 #endif
1917         return 0;
1918     }
1919
1920     if (welded(uwep) && bimanual(uwep) && (is_suit(otmp) || is_shirt(otmp))) {
1921         if (noisy)
1922 /*JP
1923             You("cannot do that while holding your %s.",
1924 */
1925             pline("%s\82ð\8e\9d\82Á\82½\82Ü\82Ü\82Å\82Í\82»\82ê\82Í\8fo\97\88\82È\82¢\81D",
1926                 is_sword(uwep) ? c_sword : c_weapon);
1927         return 0;
1928     }
1929
1930     if (is_helmet(otmp)) {
1931         if (uarmh) {
1932             if (noisy)
1933 #if 0 /*JP*/
1934                 already_wearing(an(helm_simple_name(uarmh)));
1935 #else
1936                 already_wearing(helm_simple_name(uarmh), uarmh);
1937 #endif
1938             err++;
1939         } else if (Upolyd && has_horns(youmonst.data) && !is_flimsy(otmp)) {
1940             /* (flimsy exception matches polyself handling) */
1941             if (noisy)
1942 #if 0 /*JP*/
1943                 pline_The("%s won't fit over your horn%s.",
1944                           helm_simple_name(otmp),
1945                           plur(num_horns(youmonst.data)));
1946 #else
1947                 pline("\8ap\82ª\82\82á\82Ü\82Å%s\82ð\90g\82É\82Â\82¯\82ç\82ê\82È\82¢\81D",
1948                       helm_simple_name(otmp));
1949 #endif
1950             err++;
1951         } else
1952             *mask = W_ARMH;
1953     } else if (is_shield(otmp)) {
1954         if (uarms) {
1955             if (noisy)
1956 #if 0 /*JP*/
1957                 already_wearing(an(c_shield));
1958 #else
1959                 already_wearing(c_shield, uarms);
1960 #endif
1961             err++;
1962         } else if (uwep && bimanual(uwep)) {
1963             if (noisy)
1964 #if 0 /*JP*/
1965                 You("cannot wear a shield while wielding a two-handed %s.",
1966                     is_sword(uwep) ? c_sword : (uwep->otyp == BATTLE_AXE)
1967                                                    ? c_axe
1968                                                    : c_weapon);
1969 #else
1970                 {
1971                     m = jconj(jonmsg(uwep, &j), "\82Ä\82¢\82é");
1972                     You("\97¼\8eè\8e\9d\82¿\82Ì%s%s%s\82Ì\82Å\8f\82\82Å\90g\82ð\8eç\82ê\82È\82¢\81D",
1973                         is_sword(uwep) ? c_sword :
1974                         uwep->otyp == BATTLE_AXE ? c_axe : c_weapon,
1975                         j, m);
1976                 }
1977 #endif
1978             err++;
1979         } else if (u.twoweap) {
1980             if (noisy)
1981 /*JP
1982                 You("cannot wear a shield while wielding two weapons.");
1983 */
1984                 You("\93ñ\93\81\97¬\82ð\82µ\82Ä\82¢\82é\82Ì\82Å\8f\82\82Å\90g\82ð\8eç\82ê\82È\82¢\81D");
1985             err++;
1986         } else
1987             *mask = W_ARMS;
1988     } else if (is_boots(otmp)) {
1989         if (uarmf) {
1990             if (noisy)
1991 #if 0 /*JP*/
1992                 already_wearing(c_boots);
1993 #else
1994                 already_wearing(c_boots, uarmf);
1995 #endif
1996             err++;
1997         } else if (Upolyd && slithy(youmonst.data)) {
1998             if (noisy)
1999 #if 0 /*JP*/
2000                 You("have no feet..."); /* not body_part(FOOT) */
2001 #else
2002                 You("\91«\82ª\82È\82¢\81D\81D\81D");  /* not body_part(FOOT) */
2003 #endif
2004             err++;
2005         } else if (Upolyd && youmonst.data->mlet == S_CENTAUR) {
2006             /* break_armor() pushes boots off for centaurs,
2007                so don't let dowear() put them back on... */
2008             if (noisy)
2009 #if 0 /*JP*/
2010                 pline("You have too many hooves to wear %s.",
2011                       c_boots); /* makeplural(body_part(FOOT)) yields
2012                                    "rear hooves" which sounds odd */
2013 #else
2014                 pline("%s\82ð\97\9a\82­\82É\82Í\91«\82ª\91½\82·\82¬\82é\81D", c_boots);
2015 #endif
2016             err++;
2017         } else if (u.utrap
2018                    && (u.utraptype == TT_BEARTRAP || u.utraptype == TT_INFLOOR
2019                        || u.utraptype == TT_LAVA
2020                        || u.utraptype == TT_BURIEDBALL)) {
2021             if (u.utraptype == TT_BEARTRAP) {
2022                 if (noisy)
2023 /*JP
2024                     Your("%s is trapped!", body_part(FOOT));
2025 */
2026                     Your("%s\82Íã©\82É\82©\82©\82Á\82Ä\82¢\82é\81I", body_part(FOOT));
2027             } else if (u.utraptype == TT_INFLOOR || u.utraptype == TT_LAVA) {
2028                 if (noisy)
2029 #if 0 /*JP*/
2030                     Your("%s are stuck in the %s!",
2031                          makeplural(body_part(FOOT)), surface(u.ux, u.uy));
2032 #else
2033                     Your("%s\82Í%s\82É\82Í\82Ü\82Á\82Ä\82¢\82é\81I",
2034                          body_part(FOOT), surface(u.ux, u.uy));
2035 #endif
2036             } else { /*TT_BURIEDBALL*/
2037                 if (noisy)
2038 #if 0 /*JP*/
2039                     Your("%s is attached to the buried ball!",
2040                          body_part(LEG));
2041 #else
2042                     Your("%s\82Í\96\84\82Ü\82Á\82Ä\82¢\82é\8b\85\82É\82Â\82È\82ª\82Á\82Ä\82¢\82é\81I",
2043                          body_part(LEG));
2044 #endif
2045             }
2046             err++;
2047         } else
2048             *mask = W_ARMF;
2049     } else if (is_gloves(otmp)) {
2050         if (uarmg) {
2051             if (noisy)
2052 #if 0 /*JP*/
2053                 already_wearing(c_gloves);
2054 #else
2055                 already_wearing(c_gloves, uarmg);
2056 #endif
2057             err++;
2058         } else if (welded(uwep)) {
2059             if (noisy)
2060 /*JP
2061                 You("cannot wear gloves over your %s.",
2062 */
2063                 You("%s\82Ì\8fã\82©\82ç\8f¬\8eè\82ð\91\95\94õ\82Å\82«\82È\82¢\81D",
2064                     is_sword(uwep) ? c_sword : c_weapon);
2065             err++;
2066         } else
2067             *mask = W_ARMG;
2068     } else if (is_shirt(otmp)) {
2069         if (uarm || uarmc || uarmu) {
2070             if (uarmu) {
2071                 if (noisy)
2072 #if 0 /*JP*/
2073                     already_wearing(an(c_shirt));
2074 #else
2075                     already_wearing(c_shirt, uarmu);
2076 #endif
2077             } else {
2078                 if (noisy)
2079 /*JP
2080                     You_cant("wear that over your %s.",
2081 */
2082                     You("%s\82Ì\8fã\82©\82ç\92\85\82é\82±\82Æ\82Í\82Å\82«\82È\82¢\81D",
2083                              (uarm && !uarmc) ? c_armor
2084                                               : cloak_simple_name(uarmc));
2085             }
2086             err++;
2087         } else
2088             *mask = W_ARMU;
2089     } else if (is_cloak(otmp)) {
2090         if (uarmc) {
2091             if (noisy)
2092 /*JP
2093                 already_wearing(an(cloak_simple_name(uarmc)));
2094 */
2095                 already_wearing(cloak_simple_name(uarmc), otmp);
2096             err++;
2097         } else
2098             *mask = W_ARMC;
2099     } else if (is_suit(otmp)) {
2100         if (uarmc) {
2101             if (noisy)
2102 /*JP
2103                 You("cannot wear armor over a %s.", cloak_simple_name(uarmc));
2104 */
2105                 You("%s\82Ì\8fã\82©\82ç\92\85\82é\82±\82Æ\82Í\82Å\82«\82È\82¢\81D", cloak_simple_name(uarmc));
2106             err++;
2107         } else if (uarm) {
2108             if (noisy)
2109 /*JP
2110                 already_wearing("some armor");
2111 */
2112                 already_wearing("\8aZ", uarm);
2113             err++;
2114         } else
2115             *mask = W_ARM;
2116     } else {
2117         /* getobj can't do this after setting its allow_all flag; that
2118            happens if you have armor for slots that are covered up or
2119            extra armor for slots that are filled */
2120         if (noisy)
2121 /*JP
2122             silly_thing("wear", otmp);
2123 */
2124             silly_thing("\90g\82É\82Â\82¯\82é", otmp);
2125         err++;
2126     }
2127     /* Unnecessary since now only weapons and special items like pick-axes get
2128      * welded to your hand, not armor
2129         if (welded(otmp)) {
2130             if (!err++) {
2131                 if (noisy) weldmsg(otmp);
2132             }
2133         }
2134      */
2135     return !err;
2136 }
2137
2138 STATIC_OVL int
2139 accessory_or_armor_on(obj)
2140 struct obj *obj;
2141 {
2142     long mask = 0L;
2143     boolean armor, ring, eyewear;
2144
2145     if (obj->owornmask & (W_ACCESSORY | W_ARMOR)) {
2146 #if 0 /*JP*/
2147         already_wearing(c_that_);
2148 #else
2149         already_wearing(c_that_, obj);
2150 #endif
2151         return 0;
2152     }
2153     armor = (obj->oclass == ARMOR_CLASS);
2154     ring = (obj->oclass == RING_CLASS || obj->otyp == MEAT_RING);
2155     eyewear = (obj->otyp == BLINDFOLD || obj->otyp == TOWEL
2156                || obj->otyp == LENSES);
2157     /* checks which are performed prior to actually touching the item */
2158     if (armor) {
2159         if (!canwearobj(obj, &mask, TRUE))
2160             return 0;
2161
2162         if (obj->otyp == HELM_OF_OPPOSITE_ALIGNMENT
2163             && qstart_level.dnum == u.uz.dnum) { /* in quest */
2164             if (u.ualignbase[A_CURRENT] == u.ualignbase[A_ORIGINAL])
2165 /*JP
2166                 You("narrowly avoid losing all chance at your goal.");
2167 */
2168                 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");
2169             else /* converted */
2170 /*JP
2171                 You("are suddenly overcome with shame and change your mind.");
2172 */
2173                 You("\93Ë\91R\92p\82¸\82©\82µ\82­\82È\82Á\82Ä\8dl\82¦\82ð\95Ï\82¦\82½\81D");
2174             u.ublessed = 0; /* lose your god's protection */
2175             makeknown(obj->otyp);
2176             context.botl = 1; /*for AC after zeroing u.ublessed */
2177             return 1;
2178         }
2179     } else {
2180         /* accessory */
2181         if (ring) {
2182             char answer, qbuf[QBUFSZ];
2183             int res = 0;
2184
2185             if (nolimbs(youmonst.data)) {
2186 /*JP
2187                 You("cannot make the ring stick to your body.");
2188 */
2189                 You("\8ew\97Ö\82ð\82Í\82ß\82ç\82ê\82È\82¢\91Ì\82¾\81D");
2190                 return 0;
2191             }
2192             if (uleft && uright) {
2193 #if 0 /*JP*/
2194                 There("are no more %s%s to fill.",
2195                       humanoid(youmonst.data) ? "ring-" : "",
2196                       makeplural(body_part(FINGER)));
2197 #else
2198                 pline("\82Í\82ß\82é\82±\82Æ\82Ì\82Å\82«\82é%s%s\82ª\82È\82¢\81D",
2199                       humanoid(youmonst.data) ? "\96ò" : "",
2200                       body_part(FINGER));
2201 #endif
2202                 return 0;
2203             }
2204             if (uleft) {
2205                 mask = RIGHT_RING;
2206             } else if (uright) {
2207                 mask = LEFT_RING;
2208             } else {
2209                 do {
2210 #if 0 /*JP*/
2211                     Sprintf(qbuf, "Which %s%s, Right or Left?",
2212                             humanoid(youmonst.data) ? "ring-" : "",
2213                             body_part(FINGER));
2214 #else
2215                     Sprintf(qbuf, "\82Ç\82¿\82ç\82Ì%s%s\81C\89E(r)\82»\82ê\82Æ\82à\8d¶(l)\81H",
2216                             humanoid(youmonst.data) ? "\96ò" : "",
2217                             body_part(FINGER));
2218 #endif
2219                     answer = yn_function(qbuf, "rl", '\0');
2220                     switch (answer) {
2221                     case '\0':
2222                         return 0;
2223                     case 'l':
2224                     case 'L':
2225                         mask = LEFT_RING;
2226                         break;
2227                     case 'r':
2228                     case 'R':
2229                         mask = RIGHT_RING;
2230                         break;
2231                     }
2232                 } while (!mask);
2233             }
2234             if (uarmg && uarmg->cursed) {
2235                 res = !uarmg->bknown;
2236                 uarmg->bknown = 1;
2237 /*JP
2238                 You("cannot remove your gloves to put on the ring.");
2239 */
2240                 You("\8ew\97Ö\82ð\82Í\82ß\82æ\82¤\82Æ\82µ\82½\82ª\8f¬\8eè\82ª\92E\82°\82È\82¢\81D");
2241                 return res; /* uses move iff we learned gloves are cursed */
2242             }
2243             if (uwep) {
2244                 res = !uwep->bknown; /* check this before calling welded() */
2245                 if ((mask == RIGHT_RING || bimanual(uwep)) && welded(uwep)) {
2246                     const char *hand = body_part(HAND);
2247
2248                     /* welded will set bknown */
2249                     if (bimanual(uwep))
2250                         hand = makeplural(hand);
2251 /*JP
2252                     You("cannot free your weapon %s to put on the ring.",
2253 */
2254                     You("\8ew\97Ö\82ð\82Í\82ß\82æ\82¤\82Æ\82µ\82½\82ª\97\98%s\82Ì\8e©\97R\82ª\82«\82©\82È\82¢\81D",
2255                         hand);
2256                     return res; /* uses move iff we learned weapon is cursed */
2257                 }
2258             }
2259         } else if (obj->oclass == AMULET_CLASS) {
2260             if (uamul) {
2261 #if 0 /*JP*/
2262                 already_wearing("an amulet");
2263 #else
2264                 already_wearing("\96\82\8f\9c\82¯", uamul);
2265 #endif
2266                 return 0;
2267             }
2268         } else if (eyewear) {
2269             if (ublindf) {
2270                 if (ublindf->otyp == TOWEL)
2271 #if 0 /*JP:T*/
2272                     Your("%s is already covered by a towel.",
2273                          body_part(FACE));
2274 #else
2275                     You("\8aù\82É\83^\83I\83\8b\82ð\90g\82É\82Â\82¯\82Ä\82¢\82é\81D");
2276 #endif
2277                 else if (ublindf->otyp == BLINDFOLD) {
2278                     if (obj->otyp == LENSES)
2279 /*JP
2280                         already_wearing2("lenses", "a blindfold");
2281 */
2282                         already_wearing2("\83\8c\83\93\83Y", "\96Ú\89B\82µ");
2283                     else
2284 #if 0 /*JP*/
2285                         already_wearing("a blindfold");
2286 #else
2287                         already_wearing("\96Ú\89B\82µ", ublindf);
2288 #endif
2289                 } else if (ublindf->otyp == LENSES) {
2290                     if (obj->otyp == BLINDFOLD)
2291 /*JP
2292                         already_wearing2("a blindfold", "some lenses");
2293 */
2294                         already_wearing2("\96Ú\89B\82µ", "\83\8c\83\93\83Y");
2295                     else
2296 #if 0 /*JP*/
2297                         already_wearing("some lenses");
2298 #else
2299                         already_wearing("\83\8c\83\93\83Y", ublindf);
2300 #endif
2301                 } else {
2302 #if 0 /*JP*/
2303                     already_wearing(something); /* ??? */
2304 #else
2305                     already_wearing("\89½\82©", ublindf); /* ??? */
2306 #endif
2307                 }
2308                 return 0;
2309             }
2310         } else {
2311             /* neither armor nor accessory */
2312 /*JP
2313             You_cant("wear that!");
2314 */
2315             You_cant("\82»\82ê\82ð\90g\82É\82Â\82¯\82ç\82ê\82È\82¢\81I");
2316             return 0;
2317         }
2318     }
2319
2320     if (!retouch_object(&obj, FALSE))
2321         return 1; /* costs a turn even though it didn't get worn */
2322
2323     if (armor) {
2324         int delay;
2325
2326         obj->known = 1; /* since AC is shown on the status line */
2327         /* if the armor is wielded, release it for wearing */
2328         if (obj->owornmask & W_WEAPON)
2329             remove_worn_item(obj, FALSE);
2330         setworn(obj, mask);
2331         delay = -objects[obj->otyp].oc_delay;
2332         if (delay) {
2333             nomul(delay);
2334 /*JP
2335             multi_reason = "dressing up";
2336 */
2337             multi_reason = "\91\95\94õ\82µ\82Ä\82¢\82é\8e\9e\82É";
2338             if (is_boots(obj))
2339                 afternmv = Boots_on;
2340             if (is_helmet(obj))
2341                 afternmv = Helmet_on;
2342             if (is_gloves(obj))
2343                 afternmv = Gloves_on;
2344             if (obj == uarm)
2345                 afternmv = Armor_on;
2346 /*JP
2347             nomovemsg = "You finish your dressing maneuver.";
2348 */
2349             nomovemsg = "\91\95\94õ\82µ\8fI\82¦\82½\81D";
2350         } else {
2351             if (is_cloak(obj))
2352                 (void) Cloak_on();
2353             if (is_shield(obj))
2354                 (void) Shield_on();
2355             if (is_shirt(obj))
2356                 (void) Shirt_on();
2357             on_msg(obj);
2358         }
2359         context.takeoff.mask = context.takeoff.what = 0L;
2360     } else { /* not armor */
2361         boolean give_feedback = FALSE;
2362
2363         /* [releasing wielded accessory handled in Xxx_on()] */
2364         if (ring) {
2365             setworn(obj, mask);
2366             Ring_on(obj);
2367             give_feedback = TRUE;
2368         } else if (obj->oclass == AMULET_CLASS) {
2369             setworn(obj, W_AMUL);
2370             Amulet_on();
2371             /* no feedback here if amulet of change got used up */
2372             give_feedback = (uamul != 0);
2373         } else if (eyewear) {
2374             /* setworn() handled by Blindf_on() */
2375             Blindf_on(obj);
2376             /* message handled by Blindf_on(); leave give_feedback False */
2377         }
2378         /* feedback for ring or for amulet other than 'change' */
2379         if (give_feedback && is_worn(obj))
2380             prinv((char *) 0, obj, 0L);
2381     }
2382     return 1;
2383 }
2384
2385 /* the 'W' command */
2386 int
2387 dowear()
2388 {
2389     struct obj *otmp;
2390
2391     /* cantweararm() checks for suits of armor, not what we want here;
2392        verysmall() or nohands() checks for shields, gloves, etc... */
2393     if (verysmall(youmonst.data) || nohands(youmonst.data)) {
2394 /*JP
2395         pline("Don't even bother.");
2396 */
2397         pline("\82»\82ñ\82È\82Â\82Ü\82ç\82È\82¢\82±\82Æ\82É\82±\82¾\82í\82é\82È\81D");
2398         return 0;
2399     }
2400     if (uarm && uarmu && uarmc && uarmh && uarms && uarmg && uarmf
2401         && uleft && uright && uamul && ublindf) {
2402         /* 'W' message doesn't mention accessories */
2403 /*JP
2404         You("are already wearing a full complement of armor.");
2405 */
2406         You("\82·\82Å\82É\8a®\91S\91\95\94õ\82µ\82Ä\82¢\82é\81D");
2407         return 0;
2408     }
2409     otmp = getobj(clothes, "wear");
2410     return otmp ? accessory_or_armor_on(otmp) : 0;
2411 }
2412
2413 /* the 'P' command */
2414 int
2415 doputon()
2416 {
2417     struct obj *otmp;
2418
2419     if (uleft && uright && uamul && ublindf
2420         && uarm && uarmu && uarmc && uarmh && uarms && uarmg && uarmf) {
2421         /* 'P' message doesn't mention armor */
2422 #if 0 /*JP*/
2423         Your("%s%s are full, and you're already wearing an amulet and %s.",
2424              humanoid(youmonst.data) ? "ring-" : "",
2425              makeplural(body_part(FINGER)),
2426              (ublindf->otyp == LENSES) ? "some lenses" : "a blindfold");
2427 #else
2428         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",
2429              humanoid(youmonst.data) ? "\96ò" : "",
2430              body_part(FINGER),
2431              ublindf->otyp==LENSES ? "\83\8c\83\93\83Y" : "\96Ú\89B\82µ");
2432 #endif
2433         return 0;
2434     }
2435     otmp = getobj(accessories, "put on");
2436     return otmp ? accessory_or_armor_on(otmp) : 0;
2437 }
2438
2439 /* calculate current armor class */
2440 void
2441 find_ac()
2442 {
2443     int uac = mons[u.umonnum].ac; /* base armor class for current form */
2444
2445     /* armor class from worn gear */
2446     if (uarm)
2447         uac -= ARM_BONUS(uarm);
2448     if (uarmc)
2449         uac -= ARM_BONUS(uarmc);
2450     if (uarmh)
2451         uac -= ARM_BONUS(uarmh);
2452     if (uarmf)
2453         uac -= ARM_BONUS(uarmf);
2454     if (uarms)
2455         uac -= ARM_BONUS(uarms);
2456     if (uarmg)
2457         uac -= ARM_BONUS(uarmg);
2458     if (uarmu)
2459         uac -= ARM_BONUS(uarmu);
2460     if (uleft && uleft->otyp == RIN_PROTECTION)
2461         uac -= uleft->spe;
2462     if (uright && uright->otyp == RIN_PROTECTION)
2463         uac -= uright->spe;
2464
2465     /* armor class from other sources */
2466     if (HProtection & INTRINSIC)
2467         uac -= u.ublessed;
2468     uac -= u.uspellprot;
2469
2470     /* [The magic binary numbers 127 and -128 should be replaced with the
2471      * mystic decimal numbers 99 and -99 which require no explanation to
2472      * the uninitiated and would cap the width of a status line value at
2473      * one less character.]
2474      */
2475     if (uac < -128)
2476         uac = -128; /* u.uac is an schar */
2477     else if (uac > 127)
2478         uac = 127; /* for completeness */
2479
2480     if (uac != u.uac) {
2481         u.uac = uac;
2482         context.botl = 1;
2483     }
2484 }
2485
2486 void
2487 glibr()
2488 {
2489     register struct obj *otmp;
2490     int xfl = 0;
2491     boolean leftfall, rightfall, wastwoweap = FALSE;
2492     const char *otherwep = 0, *thiswep, *which, *hand;
2493
2494     leftfall = (uleft && !uleft->cursed
2495                 && (!uwep || !welded(uwep) || !bimanual(uwep)));
2496     rightfall = (uright && !uright->cursed && (!welded(uwep)));
2497     if (!uarmg && (leftfall || rightfall) && !nolimbs(youmonst.data)) {
2498         /* changed so cursed rings don't fall off, GAN 10/30/86 */
2499 #if 0 /*JP*/
2500         Your("%s off your %s.",
2501              (leftfall && rightfall) ? "rings slip" : "ring slips",
2502              (leftfall && rightfall) ? makeplural(body_part(FINGER))
2503                                      : body_part(FINGER));
2504 #else
2505         Your("\8ew\97Ö\82Í%s\82©\82ç\8a\8a\82è\97\8e\82¿\82½\81D", body_part(FINGER));
2506 #endif
2507         xfl++;
2508         if (leftfall) {
2509             otmp = uleft;
2510             Ring_off(uleft);
2511             dropx(otmp);
2512         }
2513         if (rightfall) {
2514             otmp = uright;
2515             Ring_off(uright);
2516             dropx(otmp);
2517         }
2518     }
2519
2520     otmp = uswapwep;
2521     if (u.twoweap && otmp) {
2522         /* secondary weapon doesn't need nearly as much handling as
2523            primary; when in two-weapon mode, we know it's one-handed
2524            with something else in the other hand and also that it's
2525            a weapon or weptool rather than something unusual, plus
2526            we don't need to compare its type with the primary */
2527         otherwep = is_sword(otmp) ? c_sword : weapon_descr(otmp);
2528         if (otmp->quan > 1L)
2529             otherwep = makeplural(otherwep);
2530         hand = body_part(HAND);
2531 /*JP
2532         which = "left ";
2533 */
2534         which = "\8d¶";
2535 #if 0 /*JP*/
2536         Your("%s %s%s from your %s%s.", otherwep, xfl ? "also " : "",
2537              otense(otmp, "slip"), which, hand);
2538 #else
2539         You("%s%s%s%s\82©\82ç\8a\8a\82è\97\8e\82Æ\82µ\82½\81D", otherwep, xfl ? "\82à\82Ü\82½" : "\82ð",
2540             which, body_part(HAND));
2541 #endif
2542         xfl++;
2543         wastwoweap = TRUE;
2544         setuswapwep((struct obj *) 0); /* clears u.twoweap */
2545         if (canletgo(otmp, ""))
2546             dropx(otmp);
2547     }
2548     otmp = uwep;
2549     if (otmp && !welded(otmp)) {
2550         long savequan = otmp->quan;
2551
2552         /* nice wording if both weapons are the same type */
2553         thiswep = is_sword(otmp) ? c_sword : weapon_descr(otmp);
2554         if (otherwep && strcmp(thiswep, makesingular(otherwep)))
2555             otherwep = 0;
2556         if (otmp->quan > 1L) {
2557             /* most class names for unconventional wielded items
2558                are ok, but if wielding multiple apples or rations
2559                we don't want "your foods slip", so force non-corpse
2560                food to be singular; skipping makeplural() isn't
2561                enough--we need to fool otense() too */
2562             if (!strcmp(thiswep, "food"))
2563                 otmp->quan = 1L;
2564             else
2565                 thiswep = makeplural(thiswep);
2566         }
2567         hand = body_part(HAND);
2568         which = "";
2569         if (bimanual(otmp))
2570             hand = makeplural(hand);
2571         else if (wastwoweap)
2572 #if 0 /*JP*/
2573             which = "right "; /* preceding msg was about left */
2574 #else
2575             which = "\89E"; /* preceding msg was about left */
2576 #endif
2577 #if 0 /*JP*/
2578         pline("%s %s%s %s%s from your %s%s.",
2579               !strncmp(thiswep, "corpse", 6) ? "The" : "Your",
2580               otherwep ? "other " : "", thiswep, xfl ? "also " : "",
2581               otense(otmp, "slip"), which, hand);
2582 #else
2583         You("%s%s%s%s%s\82©\82ç\8a\8a\82è\97\8e\82Æ\82µ\82½\81D",
2584             otherwep ? "\82à\82¤\82Ð\82Æ\82Â\82Ì" : "", thiswep,
2585             xfl ? "\82à\82Ü\82½" : "\82ð",
2586             which, body_part(HAND));
2587 #endif
2588         /* xfl++; */
2589         otmp->quan = savequan;
2590         setuwep((struct obj *) 0);
2591         if (canletgo(otmp, ""))
2592             dropx(otmp);
2593     }
2594 }
2595
2596 struct obj *
2597 some_armor(victim)
2598 struct monst *victim;
2599 {
2600     register struct obj *otmph, *otmp;
2601
2602     otmph = (victim == &youmonst) ? uarmc : which_armor(victim, W_ARMC);
2603     if (!otmph)
2604         otmph = (victim == &youmonst) ? uarm : which_armor(victim, W_ARM);
2605     if (!otmph)
2606         otmph = (victim == &youmonst) ? uarmu : which_armor(victim, W_ARMU);
2607
2608     otmp = (victim == &youmonst) ? uarmh : which_armor(victim, W_ARMH);
2609     if (otmp && (!otmph || !rn2(4)))
2610         otmph = otmp;
2611     otmp = (victim == &youmonst) ? uarmg : which_armor(victim, W_ARMG);
2612     if (otmp && (!otmph || !rn2(4)))
2613         otmph = otmp;
2614     otmp = (victim == &youmonst) ? uarmf : which_armor(victim, W_ARMF);
2615     if (otmp && (!otmph || !rn2(4)))
2616         otmph = otmp;
2617     otmp = (victim == &youmonst) ? uarms : which_armor(victim, W_ARMS);
2618     if (otmp && (!otmph || !rn2(4)))
2619         otmph = otmp;
2620     return otmph;
2621 }
2622
2623 /* used for praying to check and fix levitation trouble */
2624 struct obj *
2625 stuck_ring(ring, otyp)
2626 struct obj *ring;
2627 int otyp;
2628 {
2629     if (ring != uleft && ring != uright) {
2630         impossible("stuck_ring: neither left nor right?");
2631         return (struct obj *) 0;
2632     }
2633
2634     if (ring && ring->otyp == otyp) {
2635         /* reasons ring can't be removed match those checked by select_off();
2636            limbless case has extra checks because ordinarily it's temporary */
2637         if (nolimbs(youmonst.data) && uamul
2638             && uamul->otyp == AMULET_OF_UNCHANGING && uamul->cursed)
2639             return uamul;
2640         if (welded(uwep) && (ring == uright || bimanual(uwep)))
2641             return uwep;
2642         if (uarmg && uarmg->cursed)
2643             return uarmg;
2644         if (ring->cursed)
2645             return ring;
2646     }
2647     /* either no ring or not right type or nothing prevents its removal */
2648     return (struct obj *) 0;
2649 }
2650
2651 /* also for praying; find worn item that confers "Unchanging" attribute */
2652 struct obj *
2653 unchanger()
2654 {
2655     if (uamul && uamul->otyp == AMULET_OF_UNCHANGING)
2656         return uamul;
2657     return 0;
2658 }
2659
2660 STATIC_PTR
2661 int
2662 select_off(otmp)
2663 register struct obj *otmp;
2664 {
2665     struct obj *why;
2666     char buf[BUFSZ];
2667
2668     if (!otmp)
2669         return 0;
2670     *buf = '\0'; /* lint suppression */
2671
2672     /* special ring checks */
2673     if (otmp == uright || otmp == uleft) {
2674         if (nolimbs(youmonst.data)) {
2675 #if 0 /*JP*/
2676             pline_The("ring is stuck.");
2677 #else
2678             pline("\8ew\97Ö\82Í\91Ì\82É\96\84\82Ü\82Á\82Ä\82µ\82Ü\82Á\82Ä\82¢\82é\81D");
2679 #endif
2680             return 0;
2681         }
2682         why = 0; /* the item which prevents ring removal */
2683         if (welded(uwep) && (otmp == uright || bimanual(uwep))) {
2684 /*JP
2685             Sprintf(buf, "free a weapon %s", body_part(HAND));
2686 */
2687             Sprintf(buf, "\97\98\98r\82Ì\8e©\97R\82ª\82«\82©\82È\82¢");
2688             why = uwep;
2689         } else if (uarmg && uarmg->cursed) {
2690 /*JP
2691             Sprintf(buf, "take off your %s", c_gloves);
2692 */
2693             Sprintf(buf, "%s\82ª\92E\82°\82È\82¢", c_gloves);
2694             why = uarmg;
2695         }
2696         if (why) {
2697 /*JP
2698             You("cannot %s to remove the ring.", buf);
2699 */
2700             You("\8ew\97Ö\82ð\82Í\82¸\82»\82¤\82Æ\82µ\82½\82ª%s\81D", buf);
2701             why->bknown = TRUE;
2702             return 0;
2703         }
2704     }
2705     /* special glove checks */
2706     if (otmp == uarmg) {
2707         if (welded(uwep)) {
2708 #if 0 /*JP*/
2709             You("are unable to take off your %s while wielding that %s.",
2710                 c_gloves, is_sword(uwep) ? c_sword : c_weapon);
2711 #else
2712             You("%s\82ð\8e\9d\82Á\82½\82Ü\82Ü%s\82ð\82Í\82¸\82·\82±\82Æ\82Í\82Å\82«\82È\82¢\81D",
2713                 is_sword(uwep) ? c_sword : c_weapon, c_gloves);
2714 #endif
2715             uwep->bknown = TRUE;
2716             return 0;
2717         } else if (Glib) {
2718 #if 0 /*JP*/
2719             You_cant("take off the slippery %s with your slippery %s.",
2720                      c_gloves, makeplural(body_part(FINGER)));
2721 #else
2722             You_cant("\8a\8a\82è\82â\82·\82¢%s\82ð\8a\8a\82è\82â\82·\82¢%s\82Å\82Í\82¸\82¹\82È\82¢\81D",
2723                      c_gloves, body_part(FINGER));
2724 #endif
2725             return 0;
2726         }
2727     }
2728     /* special boot checks */
2729     if (otmp == uarmf) {
2730         if (u.utrap && u.utraptype == TT_BEARTRAP) {
2731 /*JP
2732             pline_The("bear trap prevents you from pulling your %s out.",
2733 */
2734             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",
2735                       body_part(FOOT));
2736             return 0;
2737         } else if (u.utrap && u.utraptype == TT_INFLOOR) {
2738 /*JP
2739             You("are stuck in the %s, and cannot pull your %s out.",
2740 */
2741             You("%s\82ª%s\82É\82Í\82Ü\82Á\82Ä\82¢\82é\82Ì\82Å\92E\82®\82±\82Æ\82ª\82Å\82«\82È\82¢\81D",
2742                 surface(u.ux, u.uy), makeplural(body_part(FOOT)));
2743             return 0;
2744         }
2745     }
2746     /* special suit and shirt checks */
2747     if (otmp == uarm || otmp == uarmu) {
2748         why = 0; /* the item which prevents disrobing */
2749         if (uarmc && uarmc->cursed) {
2750 /*JP
2751             Sprintf(buf, "remove your %s", cloak_simple_name(uarmc));
2752 */
2753             Sprintf(buf, "%s\82ª\92E\82°\82È\82¢", cloak_simple_name(uarmc));
2754             why = uarmc;
2755         } else if (otmp == uarmu && uarm && uarm->cursed) {
2756 /*JP
2757             Sprintf(buf, "remove your %s", c_suit);
2758 */
2759             Sprintf(buf, "%s\82ª\92E\82°\82È\82¢", c_suit);
2760             why = uarm;
2761         } else if (welded(uwep) && bimanual(uwep)) {
2762 #if 0 /*JP*/
2763             Sprintf(buf, "release your %s",
2764                     is_sword(uwep) ? c_sword : (uwep->otyp == BATTLE_AXE)
2765                                                    ? c_axe
2766                                                    : c_weapon);
2767 #else
2768             Sprintf(buf, "%s\82ª\8eè\95ú\82¹\82È\82¢",
2769                     is_sword(uwep) ? c_sword : (uwep->otyp == BATTLE_AXE)
2770                                                    ? c_axe
2771                                                    : c_weapon);
2772 #endif
2773             why = uwep;
2774         }
2775         if (why) {
2776 /*JP
2777             You("cannot %s to take off %s.", buf, the(xname(otmp)));
2778 */
2779             You("%s\82ð\82Í\82¸\82»\82¤\82Æ\82µ\82½\82ª%s\81D", xname(otmp), buf);
2780             why->bknown = TRUE;
2781             return 0;
2782         }
2783     }
2784     /* basic curse check */
2785     if (otmp == uquiver || (otmp == uswapwep && !u.twoweap)) {
2786         ; /* some items can be removed even when cursed */
2787     } else {
2788         /* otherwise, this is fundamental */
2789         if (cursed(otmp))
2790             return 0;
2791     }
2792
2793     if (otmp == uarm)
2794         context.takeoff.mask |= WORN_ARMOR;
2795     else if (otmp == uarmc)
2796         context.takeoff.mask |= WORN_CLOAK;
2797     else if (otmp == uarmf)
2798         context.takeoff.mask |= WORN_BOOTS;
2799     else if (otmp == uarmg)
2800         context.takeoff.mask |= WORN_GLOVES;
2801     else if (otmp == uarmh)
2802         context.takeoff.mask |= WORN_HELMET;
2803     else if (otmp == uarms)
2804         context.takeoff.mask |= WORN_SHIELD;
2805     else if (otmp == uarmu)
2806         context.takeoff.mask |= WORN_SHIRT;
2807     else if (otmp == uleft)
2808         context.takeoff.mask |= LEFT_RING;
2809     else if (otmp == uright)
2810         context.takeoff.mask |= RIGHT_RING;
2811     else if (otmp == uamul)
2812         context.takeoff.mask |= WORN_AMUL;
2813     else if (otmp == ublindf)
2814         context.takeoff.mask |= WORN_BLINDF;
2815     else if (otmp == uwep)
2816         context.takeoff.mask |= W_WEP;
2817     else if (otmp == uswapwep)
2818         context.takeoff.mask |= W_SWAPWEP;
2819     else if (otmp == uquiver)
2820         context.takeoff.mask |= W_QUIVER;
2821
2822     else
2823         impossible("select_off: %s???", doname(otmp));
2824
2825     return 0;
2826 }
2827
2828 STATIC_OVL struct obj *
2829 do_takeoff()
2830 {
2831     struct obj *otmp = (struct obj *) 0;
2832     struct takeoff_info *doff = &context.takeoff;
2833
2834     context.takeoff.mask |= I_SPECIAL; /* set flag for cancel_doff() */
2835     if (doff->what == W_WEP) {
2836         if (!cursed(uwep)) {
2837             setuwep((struct obj *) 0);
2838 /*JP
2839             You("are empty %s.", body_part(HANDED));
2840 */
2841             You("\89½\82à%s\82É\82µ\82Ä\82¢\82È\82¢\81D", body_part(HAND));
2842             u.twoweap = FALSE;
2843         }
2844     } else if (doff->what == W_SWAPWEP) {
2845         setuswapwep((struct obj *) 0);
2846 /*JP
2847         You("no longer have a second weapon readied.");
2848 */
2849         You("\97\\94õ\82Ì\95\90\8aí\82ð\82¨\82³\82ß\82½\81D");
2850         u.twoweap = FALSE;
2851     } else if (doff->what == W_QUIVER) {
2852         setuqwep((struct obj *) 0);
2853 /*JP
2854         You("no longer have ammunition readied.");
2855 */
2856         You("\8f\80\94õ\82µ\82½\96î\92e\82ð\82¨\82³\82ß\82½\81D");
2857     } else if (doff->what == WORN_ARMOR) {
2858         otmp = uarm;
2859         if (!cursed(otmp))
2860             (void) Armor_off();
2861     } else if (doff->what == WORN_CLOAK) {
2862         otmp = uarmc;
2863         if (!cursed(otmp))
2864             (void) Cloak_off();
2865     } else if (doff->what == WORN_BOOTS) {
2866         otmp = uarmf;
2867         if (!cursed(otmp))
2868             (void) Boots_off();
2869     } else if (doff->what == WORN_GLOVES) {
2870         otmp = uarmg;
2871         if (!cursed(otmp))
2872             (void) Gloves_off();
2873     } else if (doff->what == WORN_HELMET) {
2874         otmp = uarmh;
2875         if (!cursed(otmp))
2876             (void) Helmet_off();
2877     } else if (doff->what == WORN_SHIELD) {
2878         otmp = uarms;
2879         if (!cursed(otmp))
2880             (void) Shield_off();
2881     } else if (doff->what == WORN_SHIRT) {
2882         otmp = uarmu;
2883         if (!cursed(otmp))
2884             (void) Shirt_off();
2885     } else if (doff->what == WORN_AMUL) {
2886         otmp = uamul;
2887         if (!cursed(otmp))
2888             Amulet_off();
2889     } else if (doff->what == LEFT_RING) {
2890         otmp = uleft;
2891         if (!cursed(otmp))
2892             Ring_off(uleft);
2893     } else if (doff->what == RIGHT_RING) {
2894         otmp = uright;
2895         if (!cursed(otmp))
2896             Ring_off(uright);
2897     } else if (doff->what == WORN_BLINDF) {
2898         if (!cursed(ublindf))
2899             Blindf_off(ublindf);
2900     } else {
2901         impossible("do_takeoff: taking off %lx", doff->what);
2902     }
2903     context.takeoff.mask &= ~I_SPECIAL; /* clear cancel_doff() flag */
2904
2905     return otmp;
2906 }
2907
2908 /* occupation callback for 'A' */
2909 STATIC_PTR
2910 int
2911 take_off(VOID_ARGS)
2912 {
2913     register int i;
2914     register struct obj *otmp;
2915     struct takeoff_info *doff = &context.takeoff;
2916
2917     if (doff->what) {
2918         if (doff->delay > 0) {
2919             doff->delay--;
2920             return 1; /* still busy */
2921         }
2922         if ((otmp = do_takeoff()) != 0)
2923             off_msg(otmp);
2924         doff->mask &= ~doff->what;
2925         doff->what = 0L;
2926     }
2927
2928     for (i = 0; takeoff_order[i]; i++)
2929         if (doff->mask & takeoff_order[i]) {
2930             doff->what = takeoff_order[i];
2931             break;
2932         }
2933
2934     otmp = (struct obj *) 0;
2935     doff->delay = 0;
2936
2937     if (doff->what == 0L) {
2938 /*JP
2939         You("finish %s.", doff->disrobing);
2940 */
2941         You("\91\95\94õ\82ð\89ð\82«\82¨\82¦\82½\81D");
2942         return 0;
2943     } else if (doff->what == W_WEP) {
2944         doff->delay = 1;
2945     } else if (doff->what == W_SWAPWEP) {
2946         doff->delay = 1;
2947     } else if (doff->what == W_QUIVER) {
2948         doff->delay = 1;
2949     } else if (doff->what == WORN_ARMOR) {
2950         otmp = uarm;
2951         /* If a cloak is being worn, add the time to take it off and put
2952          * it back on again.  Kludge alert! since that time is 0 for all
2953          * known cloaks, add 1 so that it actually matters...
2954          */
2955         if (uarmc)
2956             doff->delay += 2 * objects[uarmc->otyp].oc_delay + 1;
2957     } else if (doff->what == WORN_CLOAK) {
2958         otmp = uarmc;
2959     } else if (doff->what == WORN_BOOTS) {
2960         otmp = uarmf;
2961     } else if (doff->what == WORN_GLOVES) {
2962         otmp = uarmg;
2963     } else if (doff->what == WORN_HELMET) {
2964         otmp = uarmh;
2965     } else if (doff->what == WORN_SHIELD) {
2966         otmp = uarms;
2967     } else if (doff->what == WORN_SHIRT) {
2968         otmp = uarmu;
2969         /* add the time to take off and put back on armor and/or cloak */
2970         if (uarm)
2971             doff->delay += 2 * objects[uarm->otyp].oc_delay;
2972         if (uarmc)
2973             doff->delay += 2 * objects[uarmc->otyp].oc_delay + 1;
2974     } else if (doff->what == WORN_AMUL) {
2975         doff->delay = 1;
2976     } else if (doff->what == LEFT_RING) {
2977         doff->delay = 1;
2978     } else if (doff->what == RIGHT_RING) {
2979         doff->delay = 1;
2980     } else if (doff->what == WORN_BLINDF) {
2981         /* [this used to be 2, but 'R' (and 'T') only require 1 turn to
2982            remove a blindfold, so 'A' shouldn't have been requiring 2] */
2983         doff->delay = 1;
2984     } else {
2985         impossible("take_off: taking off %lx", doff->what);
2986         return 0; /* force done */
2987     }
2988
2989     if (otmp)
2990         doff->delay += objects[otmp->otyp].oc_delay;
2991
2992     /* Since setting the occupation now starts the counter next move, that
2993      * would always produce a delay 1 too big per item unless we subtract
2994      * 1 here to account for it.
2995      */
2996     if (doff->delay > 0)
2997         doff->delay--;
2998
2999     set_occupation(take_off, doff->disrobing, 0);
3000     return 1; /* get busy */
3001 }
3002
3003 /* clear saved context to avoid inappropriate resumption of interrupted 'A' */
3004 void
3005 reset_remarm()
3006 {
3007     context.takeoff.what = context.takeoff.mask = 0L;
3008     context.takeoff.disrobing[0] = '\0';
3009 }
3010
3011 /* the 'A' command -- remove multiple worn items */
3012 int
3013 doddoremarm()
3014 {
3015     int result = 0;
3016
3017     if (context.takeoff.what || context.takeoff.mask) {
3018 /*JP
3019         You("continue %s.", context.takeoff.disrobing);
3020 */
3021         You("\91\95\94õ\82ð\89ð\82­\82Ì\82ð\8dÄ\8aJ\82µ\82½\81D");
3022 /*JP
3023         set_occupation(take_off, context.takeoff.disrobing, 0);
3024 */
3025         set_occupation(take_off, "\91\95\94õ\82ð\89ð\82­", 0);
3026         return 0;
3027     } else if (!uwep && !uswapwep && !uquiver && !uamul && !ublindf && !uleft
3028                && !uright && !wearing_armor()) {
3029 /*JP
3030         You("are not wearing anything.");
3031 */
3032         You("\89½\82à\91\95\94õ\82µ\82Ä\82¢\82È\82¢\81D");
3033         return 0;
3034     }
3035
3036     add_valid_menu_class(0); /* reset */
3037     if (flags.menu_style != MENU_TRADITIONAL
3038         || (result = ggetobj("take off", select_off, 0, FALSE,
3039                              (unsigned *) 0)) < -1)
3040         result = menu_remarm(result);
3041
3042     if (context.takeoff.mask) {
3043 #if 0 /*JP*//*\93ú\96{\8cê\82Å\82Í\8eg\82í\82È\82¢*/
3044         /* default activity for armor and/or accessories,
3045            possibly combined with weapons */
3046         (void) strncpy(context.takeoff.disrobing, "disrobing", CONTEXTVERBSZ);
3047         /* specific activity when handling weapons only */
3048         if (!(context.takeoff.mask & ~W_WEAPON))
3049             (void) strncpy(context.takeoff.disrobing, "disarming",
3050                            CONTEXTVERBSZ);
3051 #endif
3052         (void) take_off();
3053     }
3054     /* The time to perform the command is already completely accounted for
3055      * in take_off(); if we return 1, that would add an extra turn to each
3056      * disrobe.
3057      */
3058     return 0;
3059 }
3060
3061 STATIC_OVL int
3062 menu_remarm(retry)
3063 int retry;
3064 {
3065     int n, i = 0;
3066     menu_item *pick_list;
3067     boolean all_worn_categories = TRUE;
3068
3069     if (retry) {
3070         all_worn_categories = (retry == -2);
3071     } else if (flags.menu_style == MENU_FULL) {
3072         all_worn_categories = FALSE;
3073 /*JP
3074         n = query_category("What type of things do you want to take off?",
3075 */
3076         n = query_category("\82Ç\82Ì\83^\83C\83v\82Ì\95¨\82Ì\91\95\94õ\82ð\89ð\82«\82Ü\82·\82©\81H",
3077                            invent, (WORN_TYPES | ALL_TYPES
3078                                     | UNPAID_TYPES | BUCX_TYPES),
3079                            &pick_list, PICK_ANY);
3080         if (!n)
3081             return 0;
3082         for (i = 0; i < n; i++) {
3083             if (pick_list[i].item.a_int == ALL_TYPES_SELECTED)
3084                 all_worn_categories = TRUE;
3085             else
3086                 add_valid_menu_class(pick_list[i].item.a_int);
3087         }
3088         free((genericptr_t) pick_list);
3089     } else if (flags.menu_style == MENU_COMBINATION) {
3090         unsigned ggofeedback = 0;
3091
3092         i = ggetobj("take off", select_off, 0, TRUE, &ggofeedback);
3093         if (ggofeedback & ALL_FINISHED)
3094             return 0;
3095         all_worn_categories = (i == -2);
3096     }
3097     if (menu_class_present('u')
3098         || menu_class_present('B') || menu_class_present('U')
3099         || menu_class_present('C') || menu_class_present('X'))
3100         all_worn_categories = FALSE;
3101
3102 #if 0 /*JP:T*/
3103     n = query_objlist("What do you want to take off?", &invent,
3104                       (SIGNAL_NOMENU | USE_INVLET | INVORDER_SORT),
3105                       &pick_list, PICK_ANY,
3106                       all_worn_categories ? is_worn : is_worn_by_type);
3107 #else
3108     n = query_objlist("\82Ç\82Ì\91\95\94õ\82ð\89ð\82«\82Ü\82·\82©\81H", &invent,
3109                       (SIGNAL_NOMENU | USE_INVLET | INVORDER_SORT),
3110                       &pick_list, PICK_ANY,
3111                       all_worn_categories ? is_worn : is_worn_by_type);
3112 #endif
3113     if (n > 0) {
3114         for (i = 0; i < n; i++)
3115             (void) select_off(pick_list[i].item.a_obj);
3116         free((genericptr_t) pick_list);
3117     } else if (n < 0 && flags.menu_style != MENU_COMBINATION) {
3118 /*JP
3119         There("is nothing else you can remove or unwield.");
3120 */
3121         pline("\91\95\94õ\82ð\89ð\82¯\82é\82à\82Ì\82Í\89½\82à\82È\82¢\81D");
3122     }
3123     return 0;
3124 }
3125
3126 /* hit by destroy armor scroll/black dragon breath/monster spell */
3127 int
3128 destroy_arm(atmp)
3129 register struct obj *atmp;
3130 {
3131     register struct obj *otmp;
3132 #define DESTROY_ARM(o)                            \
3133     ((otmp = (o)) != 0 && (!atmp || atmp == otmp) \
3134              && (!obj_resists(otmp, 0, 90))       \
3135          ? (otmp->in_use = TRUE)                  \
3136          : FALSE)
3137
3138     if (DESTROY_ARM(uarmc)) {
3139         if (donning(otmp))
3140             cancel_don();
3141 /*JP
3142         Your("%s crumbles and turns to dust!", cloak_simple_name(uarmc));
3143 */
3144         Your("%s\82Í\95²\81X\82É\82È\82Á\82½\81I", cloak_simple_name(uarmc));
3145         (void) Cloak_off();
3146         useup(otmp);
3147     } else if (DESTROY_ARM(uarm)) {
3148         if (donning(otmp))
3149             cancel_don();
3150 /*JP
3151         Your("armor turns to dust and falls to the %s!", surface(u.ux, u.uy));
3152 */
3153         Your("\8aZ\82Í\90o\82Æ\82È\82è%s\82É\97\8e\82¿\82½\81I", surface(u.ux,u.uy));
3154         (void) Armor_gone();
3155         useup(otmp);
3156     } else if (DESTROY_ARM(uarmu)) {
3157         if (donning(otmp))
3158             cancel_don();
3159 /*JP
3160         Your("shirt crumbles into tiny threads and falls apart!");
3161 */
3162         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");
3163         (void) Shirt_off();
3164         useup(otmp);
3165     } else if (DESTROY_ARM(uarmh)) {
3166         if (donning(otmp))
3167             cancel_don();
3168 /*JP
3169         Your("%s turns to dust and is blown away!", helm_simple_name(uarmh));
3170 */
3171         Your("%s\82Í\90o\82Æ\82È\82è\90\81\82«\82Æ\82ñ\82¾\81I", helm_simple_name(uarmh));
3172         (void) Helmet_off();
3173         useup(otmp);
3174     } else if (DESTROY_ARM(uarmg)) {
3175         if (donning(otmp))
3176             cancel_don();
3177 /*JP
3178         Your("gloves vanish!");
3179 */
3180                 Your("\8f¬\8eè\82Í\8fÁ\82¦\82½\81I");
3181         (void) Gloves_off();
3182         useup(otmp);
3183 /*JP
3184         selftouch("You");
3185 */
3186         selftouch("\82»\82Ì\82Æ\82«\82 \82È\82½\82Í");
3187     } else if (DESTROY_ARM(uarmf)) {
3188         if (donning(otmp))
3189             cancel_don();
3190 /*JP
3191         Your("boots disintegrate!");
3192 */
3193         Your("\8cC\82Í\95²\81X\82É\8dÓ\82¯\82½\81I");
3194         (void) Boots_off();
3195         useup(otmp);
3196     } else if (DESTROY_ARM(uarms)) {
3197         if (donning(otmp))
3198             cancel_don();
3199 /*JP
3200         Your("shield crumbles away!");
3201 */
3202         Your("\8f\82\82Í\8dÓ\82¯\8eU\82Á\82½\81I");
3203         (void) Shield_off();
3204         useup(otmp);
3205     } else {
3206         return 0; /* could not destroy anything */
3207     }
3208
3209 #undef DESTROY_ARM
3210     stop_occupation();
3211     return 1;
3212 }
3213
3214 void
3215 adj_abon(otmp, delta)
3216 register struct obj *otmp;
3217 register schar delta;
3218 {
3219     if (uarmg && uarmg == otmp && otmp->otyp == GAUNTLETS_OF_DEXTERITY) {
3220         if (delta) {
3221             makeknown(uarmg->otyp);
3222             ABON(A_DEX) += (delta);
3223         }
3224         context.botl = 1;
3225     }
3226     if (uarmh && uarmh == otmp && otmp->otyp == HELM_OF_BRILLIANCE) {
3227         if (delta) {
3228             makeknown(uarmh->otyp);
3229             ABON(A_INT) += (delta);
3230             ABON(A_WIS) += (delta);
3231         }
3232         context.botl = 1;
3233     }
3234 }
3235
3236 /* decide whether a worn item is covered up by some other worn item,
3237    used for dipping into liquid and applying grease;
3238    some criteria are different than select_off()'s */
3239 boolean
3240 inaccessible_equipment(obj, verb, only_if_known_cursed)
3241 struct obj *obj;
3242 const char *verb; /* "dip" or "grease", or null to avoid messages */
3243 /*JP:\93ú\96{\8cê\82Å\82Í "\82ð\90Z\82·", "\82É\8e\89\82ð\93h\82é", null \82Ì\82¢\82¸\82ê\82©*/
3244 boolean only_if_known_cursed; /* ignore covering unless known to be cursed */
3245 {
3246 #if 0 /*JP*/
3247     static NEARDATA const char need_to_take_off_outer_armor[] =
3248         "need to take off %s to %s %s.";
3249 #else /*JP:\88ø\90\94\82ª\8c´\95\82Æ\95Ï\82í\82Á\82Ä\82¢\82é\82±\82Æ\82É\92\8d\88Ó*/
3250     static NEARDATA const char need_to_take_off_outer_armor[] =
3251         "%s%s\82É\82Í%s\82ð%s\95K\97v\82ª\82 \82é\81D";
3252 #endif
3253     char buf[BUFSZ];
3254     boolean anycovering = !only_if_known_cursed; /* more comprehensible... */
3255 #define BLOCKSACCESS(x) (anycovering || ((x)->cursed && (x)->bknown))
3256
3257     if (!obj || !obj->owornmask)
3258         return FALSE; /* not inaccessible */
3259
3260     /* check for suit covered by cloak */
3261     if (obj == uarm && uarmc && BLOCKSACCESS(uarmc)) {
3262         if (verb) {
3263             Strcpy(buf, yname(uarmc));
3264 #if 0 /*JP*/
3265             You(need_to_take_off_outer_armor, buf, verb, yname(obj));
3266 #else /*JP:\91Î\8fÛ\82Í\83N\83\8d\81[\83N\82È\82Ì\82Åjoffmsg\82ð\8eg\82í\82¸\8c\88\82ß\8c\82\82¿*/
3267             You(need_to_take_off_outer_armor, xname(obj), verb, buf, "\92E\82®");
3268 #endif
3269         }
3270         return TRUE;
3271     }
3272     /* check for shirt covered by suit and/or cloak */
3273     if (obj == uarmu
3274         && ((uarm && BLOCKSACCESS(uarm)) || (uarmc && BLOCKSACCESS(uarmc)))) {
3275         if (verb) {
3276             char cloaktmp[QBUFSZ], suittmp[QBUFSZ];
3277             /* if sameprefix, use yname and xname to get "your cloak and suit"
3278                or "Manlobbi's cloak and suit"; otherwise, use yname and yname
3279                to get "your cloak and Manlobbi's suit" or vice versa */
3280             boolean sameprefix = (uarm && uarmc
3281                                   && !strcmp(shk_your(cloaktmp, uarmc),
3282                                              shk_your(suittmp, uarm)));
3283
3284             *buf = '\0';
3285             if (uarmc)
3286                 Strcat(buf, yname(uarmc));
3287             if (uarm && uarmc)
3288 /*JP
3289                 Strcat(buf, " and ");
3290 */
3291                 Strcat(buf, "\82Æ");
3292             if (uarm)
3293                 Strcat(buf, sameprefix ? xname(uarm) : yname(uarm));
3294 #if 0 /*JP*/
3295             You(need_to_take_off_outer_armor, buf, verb, yname(obj));
3296 #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¿*/
3297             You(need_to_take_off_outer_armor, xname(obj), verb, buf, "\92E\82®");
3298 #endif
3299         }
3300         return TRUE;
3301     }
3302     /* check for ring covered by gloves */
3303     if ((obj == uleft || obj == uright) && uarmg && BLOCKSACCESS(uarmg)) {
3304         if (verb) {
3305             Strcpy(buf, yname(uarmg));
3306 #if 0 /*JP*/
3307             You(need_to_take_off_outer_armor, buf, verb, yname(obj));
3308 #else /*JP:\91Î\8fÛ\82Í\8f¬\8eè\82È\82Ì\82Åjoffmsg\82ð\8eg\82í\82¸\8c\88\82ß\8c\82\82¿*/
3309             You(need_to_take_off_outer_armor, xname(obj), verb, buf, "\82Í\82¸\82·");
3310 #endif
3311         }
3312         return TRUE;
3313     }
3314     /* item is not inaccessible */
3315     return FALSE;
3316 }
3317
3318 /*do_wear.c*/