OSDN Git Service

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