OSDN Git Service

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