OSDN Git Service

fix #36659
[jnethack/source.git] / src / wield.c
1 /* NetHack 3.6  wield.c $NHDT-Date: 1446887539 2015/11/07 09:12:19 $  $NHDT-Branch: master $:$NHDT-Revision: 1.47 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed.  See license for details. */
4
5 /* JNetHack Copyright */
6 /* (c) Issei Numata, Naoki Hamada, Shigehiro Miyashita, 1994-2000  */
7 /* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2016            */
8 /* JNetHack may be freely redistributed.  See license for details. */
9
10 #include "hack.h"
11
12 /* KMH -- Differences between the three weapon slots.
13  *
14  * The main weapon (uwep):
15  * 1.  Is filled by the (w)ield command.
16  * 2.  Can be filled with any type of item.
17  * 3.  May be carried in one or both hands.
18  * 4.  Is used as the melee weapon and as the launcher for
19  *     ammunition.
20  * 5.  Only conveys intrinsics when it is a weapon, weapon-tool,
21  *     or artifact.
22  * 6.  Certain cursed items will weld to the hand and cannot be
23  *     unwielded or dropped.  See erodeable_wep() and will_weld()
24  *     below for the list of which items apply.
25  *
26  * The secondary weapon (uswapwep):
27  * 1.  Is filled by the e(x)change command, which swaps this slot
28  *     with the main weapon.  If the "pushweapon" option is set,
29  *     the (w)ield command will also store the old weapon in the
30  *     secondary slot.
31  * 2.  Can be filled with anything that will fit in the main weapon
32  *     slot; that is, any type of item.
33  * 3.  Is usually NOT considered to be carried in the hands.
34  *     That would force too many checks among the main weapon,
35  *     second weapon, shield, gloves, and rings; and it would
36  *     further be complicated by bimanual weapons.  A special
37  *     exception is made for two-weapon combat.
38  * 4.  Is used as the second weapon for two-weapon combat, and as
39  *     a convenience to swap with the main weapon.
40  * 5.  Never conveys intrinsics.
41  * 6.  Cursed items never weld (see #3 for reasons), but they also
42  *     prevent two-weapon combat.
43  *
44  * The quiver (uquiver):
45  * 1.  Is filled by the (Q)uiver command.
46  * 2.  Can be filled with any type of item.
47  * 3.  Is considered to be carried in a special part of the pack.
48  * 4.  Is used as the item to throw with the (f)ire command.
49  *     This is a convenience over the normal (t)hrow command.
50  * 5.  Never conveys intrinsics.
51  * 6.  Cursed items never weld; their effect is handled by the normal
52  *     throwing code.
53  * 7.  The autoquiver option will fill it with something deemed
54  *     suitable if (f)ire is used when it's empty.
55  *
56  * No item may be in more than one of these slots.
57  */
58
59 STATIC_DCL boolean FDECL(cant_wield_corpse, (struct obj *));
60 STATIC_DCL int FDECL(ready_weapon, (struct obj *));
61
62 /* used by will_weld() */
63 /* probably should be renamed */
64 #define erodeable_wep(optr)                             \
65     ((optr)->oclass == WEAPON_CLASS || is_weptool(optr) \
66      || (optr)->otyp == HEAVY_IRON_BALL || (optr)->otyp == IRON_CHAIN)
67
68 /* used by welded(), and also while wielding */
69 #define will_weld(optr) \
70     ((optr)->cursed && (erodeable_wep(optr) || (optr)->otyp == TIN_OPENER))
71
72 /*** Functions that place a given item in a slot ***/
73 /* Proper usage includes:
74  * 1.  Initializing the slot during character generation or a
75  *     restore.
76  * 2.  Setting the slot due to a player's actions.
77  * 3.  If one of the objects in the slot are split off, these
78  *     functions can be used to put the remainder back in the slot.
79  * 4.  Putting an item that was thrown and returned back into the slot.
80  * 5.  Emptying the slot, by passing a null object.  NEVER pass
81  *     zeroobj!
82  *
83  * If the item is being moved from another slot, it is the caller's
84  * responsibility to handle that.  It's also the caller's responsibility
85  * to print the appropriate messages.
86  */
87 void
88 setuwep(obj)
89 register struct obj *obj;
90 {
91     struct obj *olduwep = uwep;
92
93     if (obj == uwep)
94         return; /* necessary to not set unweapon */
95     /* This message isn't printed in the caller because it happens
96      * *whenever* Sunsword is unwielded, from whatever cause.
97      */
98     setworn(obj, W_WEP);
99     if (uwep == obj && artifact_light(olduwep) && olduwep->lamplit) {
100         end_burn(olduwep, FALSE);
101         if (!Blind)
102 /*JP
103             pline("%s shining.", Tobjnam(olduwep, "stop"));
104 */
105             pline("%s\82Í\8bP\82«\82ð\8e~\82ß\82½\81D", xname(olduwep));
106     }
107     /* Note: Explicitly wielding a pick-axe will not give a "bashing"
108      * message.  Wielding one via 'a'pplying it will.
109      * 3.2.2:  Wielding arbitrary objects will give bashing message too.
110      */
111     if (obj) {
112         unweapon = (obj->oclass == WEAPON_CLASS)
113                        ? is_launcher(obj) || is_ammo(obj) || is_missile(obj)
114                              || (is_pole(obj) && !u.usteed)
115                        : !is_weptool(obj) && !is_wet_towel(obj);
116     } else
117         unweapon = TRUE; /* for "bare hands" message */
118     update_inventory();
119 }
120
121 STATIC_OVL boolean
122 cant_wield_corpse(obj)
123 struct obj *obj;
124 {
125     char kbuf[BUFSZ];
126
127     if (uarmg || obj->otyp != CORPSE || !touch_petrifies(&mons[obj->corpsenm])
128         || Stone_resistance)
129         return FALSE;
130
131     /* Prevent wielding cockatrice when not wearing gloves --KAA */
132 #if 0 /*JP*/
133     You("wield %s in your bare %s.",
134         corpse_xname(obj, (const char *) 0, CXN_PFX_THE),
135         makeplural(body_part(HAND)));
136 #else
137     You("%s\82ð%s\82É\82µ\82½\81D",
138         corpse_xname(obj, (const char *) 0, CXN_PFX_THE),
139         body_part(HAND));
140 #endif
141 /*JP
142     Sprintf(kbuf, "wielding %s bare-handed", killer_xname(obj));
143 */
144     Sprintf(kbuf, "%s\82ð\91f\8eè\82Å\8eè\82É\82µ\82Ä", killer_xname(obj));
145     instapetrify(kbuf);
146     return TRUE;
147 }
148
149 STATIC_OVL int
150 ready_weapon(wep)
151 struct obj *wep;
152 {
153     /* Separated function so swapping works easily */
154     int res = 0;
155
156     if (!wep) {
157         /* No weapon */
158         if (uwep) {
159 /*JP
160             You("are empty %s.", body_part(HANDED));
161 */
162             You("%s\82ð\8bó\82¯\82½\81D", body_part(HAND));
163             setuwep((struct obj *) 0);
164             res++;
165         } else
166 /*JP
167             You("are already empty %s.", body_part(HANDED));
168 */
169             You("\89½\82à%s\82É\82µ\82Ä\82¢\82È\82¢\81I", body_part(HAND));
170     } else if (wep->otyp == CORPSE && cant_wield_corpse(wep)) {
171         /* hero must have been life-saved to get here; use a turn */
172         res++; /* corpse won't be wielded */
173     } else if (uarms && bimanual(wep)) {
174 #if 0 /*JP*/
175         You("cannot wield a two-handed %s while wearing a shield.",
176             is_sword(wep) ? "sword" : wep->otyp == BATTLE_AXE ? "axe"
177                                                               : "weapon");
178 #else
179         pline("\8f\82\82ð\91\95\94õ\82µ\82Ä\82¢\82é\82Æ\82«\82É\97¼\8eè\8e\9d\82¿\82Ì%s\82ð\91\95\94õ\82Å\82«\82È\82¢\81D",
180               is_sword(wep) ? "\8c\95" : wep->otyp == BATTLE_AXE ? "\95\80"
181                                                              : "\95\90\8aí");
182 #endif
183     } else if (!retouch_object(&wep, FALSE)) {
184         res++; /* takes a turn even though it doesn't get wielded */
185     } else {
186         /* Weapon WILL be wielded after this point */
187         res++;
188         if (will_weld(wep)) {
189 #if 0 /*JP*//*\8eg\82í\82È\82¢*/
190             const char *tmp = xname(wep), *thestr = "The ";
191
192             if (strncmp(tmp, thestr, 4) && !strncmp(The(tmp), thestr, 4))
193                 tmp = thestr;
194             else
195                 tmp = "";
196 #endif
197 #if 0 /*JP*/
198             pline("%s%s %s to your %s!", tmp, aobjnam(wep, "weld"),
199                   (wep->quan == 1L) ? "itself" : "themselves", /* a3 */
200                   bimanual(wep) ? (const char *) makeplural(body_part(HAND))
201                                 : body_part(HAND));
202 #else
203             pline("%s\82Í\8f\9f\8eè\82É\82 \82È\82½\82Ì%s\82É\91\95\94õ\82³\82ê\82½\81D",
204                   xname(wep), body_part(HAND));
205 #endif
206             wep->bknown = TRUE;
207         } else {
208             /* The message must be printed before setuwep (since
209              * you might die and be revived from changing weapons),
210              * and the message must be before the death message and
211              * Lifesaved rewielding.  Yet we want the message to
212              * say "weapon in hand", thus this kludge.
213              */
214             long dummy = wep->owornmask;
215
216             wep->owornmask |= W_WEP;
217             prinv((char *) 0, wep, 0L);
218             wep->owornmask = dummy;
219         }
220         setuwep(wep);
221
222         /* KMH -- Talking artifacts are finally implemented */
223         arti_speak(wep);
224
225         if (artifact_light(wep) && !wep->lamplit) {
226             begin_burn(wep, FALSE);
227             if (!Blind)
228 #if 0 /*JP*/
229                 pline("%s to shine %s!", Tobjnam(wep, "begin"),
230                       arti_light_description(wep));
231 #else
232                 pline("%s\82Í%s\8bP\82«\82Í\82\82ß\82½\81I", xname(wep),
233                       arti_light_description(wep));
234 #endif
235         }
236 #if 0
237         /* we'll get back to this someday, but it's not balanced yet */
238         if (Race_if(PM_ELF) && !wep->oartifact
239             && objects[wep->otyp].oc_material == IRON) {
240             /* Elves are averse to wielding cold iron */
241 /*JP
242             You("have an uneasy feeling about wielding cold iron.");
243 */
244             You("\97â\82½\82¢\93S\82ð\91\95\94õ\82·\82é\82±\82Æ\82É\95s\88À\82È\8bC\8e\9d\82É\82È\82Á\82½.");
245             change_luck(-1);
246         }
247 #endif
248         if (wep->unpaid) {
249             struct monst *this_shkp;
250
251             if ((this_shkp = shop_keeper(inside_shop(u.ux, u.uy)))
252                 != (struct monst *) 0) {
253 #if 0 /*JP*/
254                 pline("%s says \"You be careful with my %s!\"",
255                       shkname(this_shkp), xname(wep));
256 #else
257                 pline("%s\82Í\8fq\82×\82½\81u%s\82Ì\88µ\82¢\82Í\8bC\82ð\82Â\82¯\82Ä\82­\82ê\82æ\81I\81v",
258                       shkname(this_shkp), xname(wep));
259 #endif
260             }
261         }
262     }
263     return res;
264 }
265
266 void
267 setuqwep(obj)
268 register struct obj *obj;
269 {
270     setworn(obj, W_QUIVER);
271     update_inventory();
272 }
273
274 void
275 setuswapwep(obj)
276 register struct obj *obj;
277 {
278     setworn(obj, W_SWAPWEP);
279     update_inventory();
280 }
281
282 /*** Commands to change particular slot(s) ***/
283
284 static NEARDATA const char wield_objs[] = { ALL_CLASSES, ALLOW_NONE,
285                                             WEAPON_CLASS, TOOL_CLASS, 0 };
286 static NEARDATA const char ready_objs[] = { COIN_CLASS, ALL_CLASSES,
287                                             ALLOW_NONE, WEAPON_CLASS, 0 };
288 static NEARDATA const char bullets[] = /* (note: different from dothrow.c) */
289     { COIN_CLASS, ALL_CLASSES, ALLOW_NONE, GEM_CLASS, WEAPON_CLASS, 0 };
290
291 int
292 dowield()
293 {
294     register struct obj *wep, *oldwep;
295     int result;
296
297     /* May we attempt this? */
298     multi = 0;
299     if (cantwield(youmonst.data)) {
300 /*JP
301         pline("Don't be ridiculous!");
302 */
303         pline("\82Î\82©\82Î\82©\82µ\82¢\81I");
304         return 0;
305     }
306
307     /* Prompt for a new weapon */
308     if (!(wep = getobj(wield_objs, "wield")))
309         /* Cancelled */
310         return 0;
311     else if (wep == uwep) {
312 /*JP
313         You("are already wielding that!");
314 */
315         You("\82à\82¤\82»\82ê\82ð%s\82É\82µ\82Ä\82¢\82é\81I", body_part(HAND));
316         if (is_weptool(wep) || is_wet_towel(wep))
317             unweapon = FALSE; /* [see setuwep()] */
318         return 0;
319     } else if (welded(uwep)) {
320         weldmsg(uwep);
321         /* previously interrupted armor removal mustn't be resumed */
322         reset_remarm();
323         return 0;
324     }
325
326     /* Handle no object, or object in other slot */
327     if (wep == &zeroobj)
328         wep = (struct obj *) 0;
329     else if (wep == uswapwep)
330         return doswapweapon();
331     else if (wep == uquiver)
332         setuqwep((struct obj *) 0);
333     else if (wep->owornmask & (W_ARMOR | W_ACCESSORY | W_SADDLE)) {
334 /*JP
335         You("cannot wield that!");
336 */
337         You("\82»\82ê\82ð\91\95\94õ\82Å\82«\82È\82¢\81I");
338         return 0;
339     }
340
341     /* Set your new primary weapon */
342     oldwep = uwep;
343     result = ready_weapon(wep);
344     if (flags.pushweapon && oldwep && uwep != oldwep)
345         setuswapwep(oldwep);
346     untwoweapon();
347
348     return result;
349 }
350
351 int
352 doswapweapon()
353 {
354     register struct obj *oldwep, *oldswap;
355     int result = 0;
356
357     /* May we attempt this? */
358     multi = 0;
359     if (cantwield(youmonst.data)) {
360 /*JP
361         pline("Don't be ridiculous!");
362 */
363         pline("\82Î\82©\82Î\82©\82µ\82¢\81I");
364         return 0;
365     }
366     if (welded(uwep)) {
367         weldmsg(uwep);
368         return 0;
369     }
370
371     /* Unwield your current secondary weapon */
372     oldwep = uwep;
373     oldswap = uswapwep;
374     setuswapwep((struct obj *) 0);
375
376     /* Set your new primary weapon */
377     result = ready_weapon(oldswap);
378
379     /* Set your new secondary weapon */
380     if (uwep == oldwep)
381         /* Wield failed for some reason */
382         setuswapwep(oldswap);
383     else {
384         setuswapwep(oldwep);
385         if (uswapwep)
386             prinv((char *) 0, uswapwep, 0L);
387         else
388 /*JP
389             You("have no secondary weapon readied.");
390 */
391             You("\97\\94õ\82Ì\95\90\8aí\82Ì\97p\88Ó\82ð\82â\82ß\82½\81D");
392     }
393
394     if (u.twoweap && !can_twoweapon())
395         untwoweapon();
396
397     return result;
398 }
399
400 int
401 dowieldquiver()
402 {
403     register struct obj *newquiver;
404     const char *quivee_types =
405         (uslinging()
406          || (uswapwep && objects[uswapwep->otyp].oc_skill == P_SLING))
407             ? bullets
408             : ready_objs;
409
410     /* Since the quiver isn't in your hands, don't check cantwield(), */
411     /* will_weld(), touch_petrifies(), etc. */
412     multi = 0;
413
414     /* Prompt for a new quiver */
415     if (!(newquiver = getobj(quivee_types, "ready")))
416         /* Cancelled */
417         return 0;
418
419     /* Handle no object, or object in other slot */
420     /* Any type is okay, since we give no intrinsics anyways */
421     if (newquiver == &zeroobj) {
422         /* Explicitly nothing */
423         if (uquiver) {
424 /*JP
425             You("now have no ammunition readied.");
426 */
427             pline("\91\95\93U\82·\82é\82½\82ß\82Ì\96î\92e\82ª\82È\82­\82È\82Á\82½\81D");
428             setuqwep(newquiver = (struct obj *) 0);
429         } else {
430 /*JP
431             You("already have no ammunition readied!");
432 */
433             pline("\91\95\93U\82·\82é\82½\82ß\82Ì\96î\92e\82ª\82È\82¢\81D");
434             return 0;
435         }
436     } else if (newquiver == uquiver) {
437 /*JP
438         pline("That ammunition is already readied!");
439 */
440         pline("\82à\82¤\91\95\93U\82³\82ê\82Ä\82¢\82é\81I");
441         return 0;
442     } else if (newquiver == uwep) {
443         /* Prevent accidentally readying the main weapon */
444 #if 0 /*JP*/
445         pline("%s already being used as a weapon!",
446               !is_plural(uwep) ? "That is" : "They are");
447 #else
448         pline("\82à\82¤\95\90\8aí\82Æ\82µ\82Ä\8eg\82í\82ê\82Ä\82¢\82é\81I");
449 #endif
450         return 0;
451     } else if (newquiver->owornmask & (W_ARMOR | W_ACCESSORY | W_SADDLE)) {
452 /*JP
453         You("cannot ready that!");
454 */
455         You("\82»\82ê\82Í\8eg\82¦\82È\82¢\81I");
456         return 0;
457     } else {
458         long dummy;
459
460         /* Check if it's the secondary weapon */
461         if (newquiver == uswapwep) {
462             setuswapwep((struct obj *) 0);
463             untwoweapon();
464         }
465
466         /* Okay to put in quiver; print it */
467         dummy = newquiver->owornmask;
468         newquiver->owornmask |= W_QUIVER;
469         prinv((char *) 0, newquiver, 0L);
470         newquiver->owornmask = dummy;
471     }
472
473     /* Finally, place it in the quiver */
474     setuqwep(newquiver);
475     /* Take no time since this is a convenience slot */
476     return 0;
477 }
478
479 /* used for #rub and for applying pick-axe, whip, grappling hook or polearm */
480 boolean
481 wield_tool(obj, verb)
482 struct obj *obj;
483 const char *verb; /* "rub",&c */
484 {
485     const char *what;
486     boolean more_than_1;
487
488     if (obj == uwep)
489         return TRUE; /* nothing to do if already wielding it */
490
491 #if 0 /*JP*/
492     if (!verb)
493         verb = "wield";
494 #endif
495     what = xname(obj);
496 #if 0 /*JP*/
497     more_than_1 = (obj->quan > 1L || strstri(what, "pair of ") != 0
498                    || strstri(what, "s of ") != 0);
499 #endif
500
501     if (obj->owornmask & (W_ARMOR | W_ACCESSORY)) {
502 #if 0 /*JP*/
503         You_cant("%s %s while wearing %s.", verb, yname(obj),
504                  more_than_1 ? "them" : "it");
505 #else
506         pline("\90g\82É\82Â\82¯\82½\82Ü\82Ü\82Å\82Í%s\82Í\8eg\82¦\82È\82¢\81D", yname(obj));
507 #endif
508         return FALSE;
509     }
510     if (welded(uwep)) {
511         if (flags.verbose) {
512 #if 0 /*JP*/
513             const char *hand = body_part(HAND);
514
515             if (bimanual(uwep))
516                 hand = makeplural(hand);
517             if (strstri(what, "pair of ") != 0)
518                 more_than_1 = FALSE;
519             pline(
520                "Since your weapon is welded to your %s, you cannot %s %s %s.",
521                   hand, verb, more_than_1 ? "those" : "that", xname(obj));
522 #else
523             pline("\95\90\8aí\82ð\8eè\82É\82µ\82Ä\82¢\82é\82Ì\82Å\81C%s\82ð\8eg\82¦\82È\82¢\81D", xname(obj));
524 #endif
525         } else {
526 /*JP
527             You_cant("do that.");
528 */
529             pline("\82»\82ê\82Í\82Å\82«\82È\82¢\81D");
530         }
531         return FALSE;
532     }
533     if (cantwield(youmonst.data)) {
534 /*JP
535         You_cant("hold %s strongly enough.", more_than_1 ? "them" : "it");
536 */
537         You("\82»\82ê\82ð\8e\9d\82Â\82Ù\82Ç\97Í\82ª\82È\82¢\81D");
538         return FALSE;
539     }
540     /* check shield */
541     if (uarms && bimanual(obj)) {
542 #if 0 /*JP*/
543         You("cannot %s a two-handed %s while wearing a shield.", verb,
544             (obj->oclass == WEAPON_CLASS) ? "weapon" : "tool");
545 #else
546         pline("\8f\82\82ð\91\95\94õ\82µ\82½\82Ü\82Ü\97¼\8eè\8e\9d\82¿\82Ì%s\82ð\91\95\94õ\82Å\82«\82È\82¢\81D",
547               (obj->oclass == WEAPON_CLASS) ? "\95\90\8aí" : "\93¹\8bï");
548 #endif
549         return FALSE;
550     }
551
552     if (uquiver == obj)
553         setuqwep((struct obj *) 0);
554     if (uswapwep == obj) {
555         (void) doswapweapon();
556         /* doswapweapon might fail */
557         if (uswapwep == obj)
558             return FALSE;
559     } else {
560         struct obj *oldwep = uwep;
561
562 /*JP
563         You("now wield %s.", doname(obj));
564 */
565         You("%s\82ð\91\95\94õ\82µ\82½\81D", doname(obj));
566         setuwep(obj);
567         if (flags.pushweapon && oldwep && uwep != oldwep)
568             setuswapwep(oldwep);
569     }
570     if (uwep != obj)
571         return FALSE; /* rewielded old object after dying */
572     /* applying weapon or tool that gets wielded ends two-weapon combat */
573     if (u.twoweap)
574         untwoweapon();
575     if (obj->oclass != WEAPON_CLASS)
576         unweapon = TRUE;
577     return TRUE;
578 }
579
580 int
581 can_twoweapon()
582 {
583     struct obj *otmp;
584
585 #define NOT_WEAPON(obj) (!is_weptool(obj) && obj->oclass != WEAPON_CLASS)
586     if (!could_twoweap(youmonst.data)) {
587         if (Upolyd)
588 /*JP
589             You_cant("use two weapons in your current form.");
590 */
591             pline("\8c»\8dÝ\82Ì\8ep\82Å\82Í\93ñ\93\81\97¬\82Í\8eg\82¦\82È\82¢\81D");
592         else
593 /*JP
594             pline("%s aren't able to use two weapons at once.",
595 */
596             pline("%s\82Í\93ñ\82Â\82Ì\95\90\8aí\82ð\93¯\8e\9e\82É\88µ\82¦\82È\82¢\81D",
597                   makeplural((flags.female && urole.name.f) ? urole.name.f
598                                                             : urole.name.m));
599     } else if (!uwep || !uswapwep)
600 #if 0 /*JP*/
601         Your("%s%s%s empty.", uwep ? "left " : uswapwep ? "right " : "",
602              body_part(HAND), (!uwep && !uswapwep) ? "s are" : " is");
603 #else
604         Your("%s%s\82Í\8bó\82Á\82Û\82¾\81D", uwep ? "\8d\82Ì" : uswapwep ? "\89E\82Ì" : "",
605              body_part(HAND));
606 #endif
607     else if (NOT_WEAPON(uwep) || NOT_WEAPON(uswapwep)) {
608         otmp = NOT_WEAPON(uwep) ? uwep : uswapwep;
609 #if 0 /*JP*/
610         pline("%s %s.", Yname2(otmp),
611               is_plural(otmp) ? "aren't weapons" : "isn't a weapon");
612 #else
613         pline("%s\82Í\95\90\8aí\82\82á\82È\82¢\81D", Yname2(otmp));
614 #endif
615     } else if (bimanual(uwep) || bimanual(uswapwep)) {
616         otmp = bimanual(uwep) ? uwep : uswapwep;
617 /*JP
618         pline("%s isn't one-handed.", Yname2(otmp));
619 */
620         pline("%s\82Í\95Ð\8eè\8e\9d\82¿\82Ì\95\90\8aí\82\82á\82È\82¢\81D", Yname2(otmp));
621     } else if (uarms)
622 /*JP
623         You_cant("use two weapons while wearing a shield.");
624 */
625         You("\8f\82\82ð\8e\9d\82Á\82Ä\82¢\82é\8aÔ\82Í\97¼\8eè\8e\9d\82¿\82Å\82«\82È\82¢\81D");
626     else if (uswapwep->oartifact)
627 #if 0 /*JP*/
628         pline("%s being held second to another weapon!",
629               Yobjnam2(uswapwep, "resist"));
630 #else
631         pline("%s\82Í\97\\94õ\82Ì\95\90\8aí\82Æ\82µ\82Ä\88µ\82í\82ê\82é\82±\82Æ\82ð\8b\91\82ñ\82¾\81I",
632               Yname2(uswapwep));
633 #endif
634     else if (uswapwep->otyp == CORPSE && cant_wield_corpse(uswapwep)) {
635         /* [Note: NOT_WEAPON() check prevents ever getting here...] */
636         ; /* must be life-saved to reach here; return FALSE */
637     } else if (Glib || uswapwep->cursed) {
638         if (!Glib)
639             uswapwep->bknown = TRUE;
640         drop_uswapwep();
641     } else
642         return TRUE;
643     return FALSE;
644 }
645
646 void
647 drop_uswapwep()
648 {
649     char str[BUFSZ];
650     struct obj *obj = uswapwep;
651
652     /* Avoid trashing makeplural's static buffer */
653     Strcpy(str, makeplural(body_part(HAND)));
654 /*JP
655     pline("%s from your %s!", Yobjnam2(obj, "slip"), str);
656 */
657     You("%s\82ð\97\8e\82µ\82Ä\82µ\82Ü\82Á\82½\81I", xname(obj));
658     dropx(obj);
659 }
660
661 int
662 dotwoweapon()
663 {
664     /* You can always toggle it off */
665     if (u.twoweap) {
666 /*JP
667         You("switch to your primary weapon.");
668 */
669         You("\88ê\82Â\82Ì\95\90\8aí\82Å\90í\93¬\82·\82é\82±\82Æ\82É\82µ\82½\81D");
670         u.twoweap = 0;
671         update_inventory();
672         return 0;
673     }
674
675     /* May we use two weapons? */
676     if (can_twoweapon()) {
677         /* Success! */
678 /*JP
679         You("begin two-weapon combat.");
680 */
681         You("\93ñ\93\81\97¬\82Å\90í\93¬\82·\82é\82±\82Æ\82É\82µ\82½\81D");
682         u.twoweap = 1;
683         update_inventory();
684         return (rnd(20) > ACURR(A_DEX));
685     }
686     return 0;
687 }
688
689 /*** Functions to empty a given slot ***/
690 /* These should be used only when the item can't be put back in
691  * the slot by life saving.  Proper usage includes:
692  * 1.  The item has been eaten, stolen, burned away, or rotted away.
693  * 2.  Making an item disappear for a bones pile.
694  */
695 void
696 uwepgone()
697 {
698     if (uwep) {
699         if (artifact_light(uwep) && uwep->lamplit) {
700             end_burn(uwep, FALSE);
701             if (!Blind)
702 /*JP
703                 pline("%s shining.", Tobjnam(uwep, "stop"));
704 */
705                 pline("%s\82Í\8bP\82«\82ð\8e~\82ß\82½\81D", xname(uwep));
706         }
707         setworn((struct obj *) 0, W_WEP);
708         unweapon = TRUE;
709         update_inventory();
710     }
711 }
712
713 void
714 uswapwepgone()
715 {
716     if (uswapwep) {
717         setworn((struct obj *) 0, W_SWAPWEP);
718         update_inventory();
719     }
720 }
721
722 void
723 uqwepgone()
724 {
725     if (uquiver) {
726         setworn((struct obj *) 0, W_QUIVER);
727         update_inventory();
728     }
729 }
730
731 void
732 untwoweapon()
733 {
734     if (u.twoweap) {
735 /*JP
736         You("can no longer use two weapons at once.");
737 */
738         You("\82à\82¤\82Q\82Â\82Ì\95\90\8aí\82ð\93¯\8e\9e\82É\8eg\97p\82·\82é\82±\82Æ\82Í\82Å\82«\82È\82¢\81D");
739         u.twoweap = FALSE;
740         update_inventory();
741     }
742     return;
743 }
744
745 int
746 chwepon(otmp, amount)
747 register struct obj *otmp;
748 register int amount;
749 {
750     const char *color = hcolor((amount < 0) ? NH_BLACK : NH_BLUE);
751     const char *xtime, *wepname = "";
752     boolean multiple;
753     int otyp = STRANGE_OBJECT;
754
755     if (!uwep || (uwep->oclass != WEAPON_CLASS && !is_weptool(uwep))) {
756         char buf[BUFSZ];
757
758 #if 0 /*JP*/
759         Sprintf(buf, "Your %s %s.", makeplural(body_part(HAND)),
760                 (amount >= 0) ? "twitch" : "itch");
761 #else
762         Sprintf(buf, "\82 \82È\82½\82Ì%s\82Í%s\81D", makeplural(body_part(HAND)),
763                 (amount >= 0) ? "\82Ð\82«\82Â\82Á\82½" : "\83\80\83Y\83\80\83Y\82µ\82½");
764 #endif
765         strange_feeling(otmp, buf);
766         exercise(A_DEX, (boolean) (amount >= 0));
767         return 0;
768     }
769
770     if (otmp && otmp->oclass == SCROLL_CLASS)
771         otyp = otmp->otyp;
772
773     if (uwep->otyp == WORM_TOOTH && amount >= 0) {
774         multiple = (uwep->quan > 1L);
775         /* order: message, transformation, shop handling */
776 #if 0 /*JP*/
777         Your("%s %s much sharper now.", simpleonames(uwep),
778              multiple ? "fuse, and become" : "is");
779 #else
780         Your("%s\82Í%s\82æ\82è\89s\82³\82ð\91\9d\82µ\82½\82æ\82¤\82¾\81D", simpleonames(uwep),
781              multiple ? "\97Z\8d\87\82µ\82Ä\81C" : "");
782 #endif
783         uwep->otyp = CRYSKNIFE;
784         uwep->oerodeproof = 0;
785         if (multiple) {
786             uwep->quan = 1L;
787             uwep->owt = weight(uwep);
788         }
789         if (uwep->cursed)
790             uncurse(uwep);
791         /* update shop bill to reflect new higher value */
792         if (uwep->unpaid)
793             alter_cost(uwep, 0L);
794         if (otyp != STRANGE_OBJECT)
795             makeknown(otyp);
796         if (multiple)
797             encumber_msg();
798         return 1;
799     } else if (uwep->otyp == CRYSKNIFE && amount < 0) {
800         multiple = (uwep->quan > 1L);
801         /* order matters: message, shop handling, transformation */
802 #if 0 /*JP*/
803         Your("%s %s much duller now.", simpleonames(uwep),
804              multiple ? "fuse, and become" : "is");
805 #else
806         Your("%s\82Í%s\82æ\82è\93Ý\82­\82È\82Á\82Ä\82µ\82Ü\82Á\82½\82æ\82¤\82¾\81D", simpleonames(uwep),
807              multiple ? "\97Z\8d\87\82µ\82Ä\81C" : "");
808 #endif
809         costly_alteration(uwep, COST_DEGRD); /* DECHNT? other? */
810         uwep->otyp = WORM_TOOTH;
811         uwep->oerodeproof = 0;
812         if (multiple) {
813             uwep->quan = 1L;
814             uwep->owt = weight(uwep);
815         }
816         if (otyp != STRANGE_OBJECT && otmp->bknown)
817             makeknown(otyp);
818         if (multiple)
819             encumber_msg();
820         return 1;
821     }
822
823     if (has_oname(uwep))
824         wepname = ONAME(uwep);
825     if (amount < 0 && uwep->oartifact && restrict_name(uwep, wepname)) {
826         if (!Blind)
827 /*JP
828             pline("%s %s.", Yobjnam2(uwep, "faintly glow"), color);
829 */
830             Your("%s\82Í\82í\82¸\82©\82É%s\8bP\82¢\82½\81D", xname(uwep),jconj_adj(color));
831         return 1;
832     }
833     /* there is a (soft) upper and lower limit to uwep->spe */
834     if (((uwep->spe > 5 && amount >= 0) || (uwep->spe < -5 && amount < 0))
835         && rn2(3)) {
836         if (!Blind)
837 #if 0 /*JP*/
838             pline("%s %s for a while and then %s.",
839                   Yobjnam2(uwep, "violently glow"), color,
840                   otense(uwep, "evaporate"));
841 #else
842             Your("%s\82Í\82µ\82Î\82ç\82­\8c\83\82µ\82­%s\8bP\82«\81C\8fö\94­\82µ\82½\81D",
843                  xname(uwep), jconj_adj(color));
844 #endif
845         else
846 /*JP
847             pline("%s.", Yobjnam2(uwep, "evaporate"));
848 */
849             Your("%s\82Í\8fö\94­\82µ\82½\81D", xname(uwep));
850
851         useupall(uwep); /* let all of them disappear */
852         return 1;
853     }
854     if (!Blind) {
855 /*JP
856         xtime = (amount * amount == 1) ? "moment" : "while";
857 */
858         xtime = (amount*amount == 1) ? "\88ê\8fu" : "\82µ\82Î\82ç\82­\82Ì\8aÔ";
859 #if 0 /*JP*/
860         pline("%s %s for a %s.",
861               Yobjnam2(uwep, amount == 0 ? "violently glow" : "glow"), color,
862               xtime);
863 #else
864         Your("%s\82Í%s%s%s\8bP\82¢\82½\81D",
865              xname(uwep), xtime, jconj_adj(color), 
866              amount == 0 ? "\8c\83\82µ\82­" : "");
867 #endif
868         if (otyp != STRANGE_OBJECT && uwep->known
869             && (amount > 0 || (amount < 0 && otmp->bknown)))
870             makeknown(otyp);
871     }
872     if (amount < 0)
873         costly_alteration(uwep, COST_DECHNT);
874     uwep->spe += amount;
875     if (amount > 0) {
876         if (uwep->cursed)
877             uncurse(uwep);
878         /* update shop bill to reflect new higher price */
879         if (uwep->unpaid)
880             alter_cost(uwep, 0L);
881     }
882
883     /*
884      * Enchantment, which normally improves a weapon, has an
885      * addition adverse reaction on Magicbane whose effects are
886      * spe dependent.  Give an obscure clue here.
887      */
888     if (uwep->oartifact == ART_MAGICBANE && uwep->spe >= 0) {
889 #if 0 /*JP*/
890         Your("right %s %sches!", body_part(HAND),
891              (((amount > 1) && (uwep->spe > 1)) ? "flin" : "it"));
892 #else
893         Your("\89E%s\82Í%s\81I",
894              body_part(HAND),
895              (((amount > 1) && (uwep->spe > 1)) ? "\82Ð\82è\82Ð\82è\82µ\82½" : "\83\80\83Y\83\80\83Y\82µ\82½"));
896 #endif
897     }
898
899     /* an elven magic clue, cookie@keebler */
900     /* elven weapons vibrate warningly when enchanted beyond a limit */
901     if ((uwep->spe > 5)
902         && (is_elven_weapon(uwep) || uwep->oartifact || !rn2(7)))
903 /*JP
904         pline("%s unexpectedly.", Yobjnam2(uwep, "suddenly vibrate"));
905 */
906         Your("%s\82Í\93Ë\91R\90k\82¦\82¾\82µ\82½\81D", xname(uwep));
907
908     return 1;
909 }
910
911 int
912 welded(obj)
913 register struct obj *obj;
914 {
915     if (obj && obj == uwep && will_weld(obj)) {
916         obj->bknown = TRUE;
917         return 1;
918     }
919     return 0;
920 }
921
922 void
923 weldmsg(obj)
924 register struct obj *obj;
925 {
926     long savewornmask;
927
928     savewornmask = obj->owornmask;
929 #if 0 /*JP*/
930     pline("%s welded to your %s!", Yobjnam2(obj, "are"),
931           bimanual(obj) ? (const char *) makeplural(body_part(HAND))
932                         : body_part(HAND));
933 #else
934     You("%s\82ð%s\82É\8d\\82¦\82½\81I", xname(obj), body_part(HAND));
935 #endif
936     obj->owornmask = savewornmask;
937 }
938
939 /* test whether monster's wielded weapon is stuck to hand/paw/whatever */
940 boolean
941 mwelded(obj)
942 struct obj *obj;
943 {
944     /* caller is responsible for making sure this is a monster's item */
945     if (obj && (obj->owornmask & W_WEP) && will_weld(obj))
946         return TRUE;
947     return FALSE;
948 }
949
950 /*wield.c*/