OSDN Git Service

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