OSDN Git Service

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