OSDN Git Service

update year to 2020
[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-2020            */
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ð\91\95\94õ\82µ\82Ä\82¢\82é\81D\82»\82Ì\82¤\82¿ %ld \82ð\8f\80\94õ\82·\82é\81H",
501                     uwep->quan, simpleonames(uwep), uwep->quan - 1L);
502 #endif
503             switch (ynq(qbuf)) {
504             case 'q':
505                 return 0;
506             case 'y':
507                 /* leave 1 wielded, split rest off and put into quiver */
508                 newquiver = splitobj(uwep, uwep->quan - 1L);
509                 finish_splitting = TRUE;
510                 goto quivering;
511             default:
512                 break;
513             }
514 /*JP
515             Strcpy(qbuf, "Ready all of them instead?");
516 */
517             Strcpy(qbuf, "\91ã\82í\82è\82É\82±\82ê\82ç\91S\95\94\82ð\8f\80\94õ\82·\82é\81H");
518         } else {
519 #if 0 /*JP*/
520             boolean use_plural = (is_plural(uwep) || pair_of(uwep));
521
522             Sprintf(qbuf, "You are wielding %s.  Ready %s instead?",
523                     !use_plural ? "that" : "those",
524                     !use_plural ? "it" : "them");
525 #else /* \95s\8e©\91R\82¾\82¯\82Ç\82Æ\82è\82 \82¦\82¸\82±\82ê\82Å\82æ\82µ\82Æ\82·\82é */
526             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");
527 #endif
528         }
529         /* require confirmation to ready the main weapon */
530         if (ynq(qbuf) != 'y') {
531             (void) Shk_Your(qbuf, uwep); /* replace qbuf[] contents */
532 #if 0 /*JP:T*/
533             pline("%s%s %s wielded.", qbuf,
534                   simpleonames(uwep), otense(uwep, "remain"));
535 #else
536             pline("%s%s\82ð\91\95\94õ\82µ\82½\82Ü\82Ü\82É\82µ\82½\81D", qbuf,
537                   simpleonames(uwep));
538 #endif
539             return 0;
540         }
541         /* quivering main weapon, so no longer wielding it */
542         setuwep((struct obj *) 0);
543         untwoweapon();
544         was_uwep = TRUE;
545     } else if (newquiver == uswapwep) {
546         if (uswapwep->quan > 1L && inv_cnt(FALSE) < 52
547             && splittable(uswapwep)) {
548 #if 0 /*JP*/
549             Sprintf(qbuf, "%s %ld %s.  Ready %ld of them?",
550                     u.twoweap ? "You are dual wielding"
551                               : "Your alternate weapon is",
552                     uswapwep->quan, simpleonames(uswapwep),
553                     uswapwep->quan - 1L);
554 #else /*TODO:\93ñ\93\81\97¬\82Ì\82Æ\82«\82Í\82©\82È\82è\95s\8e©\91R */
555             Sprintf(qbuf, "%s %ld %s\82¾\81D\82»\82Ì\82¤\82¿%ld\82ð\8f\80\94õ\82·\82é\81H",
556                     u.twoweap ? "\82 \82È\82½\82ª\82»\82ê\82¼\82ê\91\95\94õ\82µ\82Ä\82¢\82é\82Ì\82Í"
557                               : "\82 \82È\82½\82Ì\97\\94õ\82Ì\95\90\8aí\82Í",
558                     uswapwep->quan, simpleonames(uswapwep),
559                     uswapwep->quan - 1L);
560 #endif
561             switch (ynq(qbuf)) {
562             case 'q':
563                 return 0;
564             case 'y':
565                 /* leave 1 alt-wielded, split rest off and put into quiver */
566                 newquiver = splitobj(uswapwep, uswapwep->quan - 1L);
567                 finish_splitting = TRUE;
568                 goto quivering;
569             default:
570                 break;
571             }
572 /*JP
573             Strcpy(qbuf, "Ready all of them instead?");
574 */
575             Strcpy(qbuf, "\91ã\82í\82è\82É\82±\82ê\82ç\91S\95\94\82ð\8f\80\94õ\82·\82é\81H");
576         } else {
577 #if 0 /*JP*/
578             boolean use_plural = (is_plural(uswapwep) || pair_of(uswapwep));
579
580             Sprintf(qbuf, "%s your %s weapon.  Ready %s instead?",
581                     !use_plural ? "That is" : "Those are",
582                     u.twoweap ? "second" : "alternate",
583                     !use_plural ? "it" : "them");
584 #else
585             Sprintf(qbuf, "\82»\82ê\82Í%s\95\90\8aí\82¾\81D\91ã\82í\82è\82É\82»\82ê\82ð\8f\80\94õ\82·\82é\81H",
586                     u.twoweap ? "\93ñ\94Ô\96Ú\82Ì" : "\97\\94õ\82Ì");
587 #endif
588         }
589         /* require confirmation to ready the alternate weapon */
590         if (ynq(qbuf) != 'y') {
591             (void) Shk_Your(qbuf, uswapwep); /* replace qbuf[] contents */
592 #if 0 /*JP:T*/
593             pline("%s%s %s %s.", qbuf,
594                   simpleonames(uswapwep), otense(uswapwep, "remain"),
595                   u.twoweap ? "wielded" : "as secondary weapon");
596 #else
597             pline("%s%s\82ð%s\82Ü\82Ü\82É\82µ\82½\81D", qbuf,
598                   simpleonames(uswapwep),
599                   u.twoweap ? "\91\95\94õ\82µ\82½" : "\93ñ\94Ô\96Ú\82Ì\95\90\8aí\82Ì");
600 #endif
601             return 0;
602         }
603         /* quivering alternate weapon, so no more uswapwep */
604         setuswapwep((struct obj *) 0);
605         untwoweapon();
606     }
607
608  quivering:
609     if (finish_splitting) {
610         freeinv(newquiver);
611         newquiver->nomerge = 1;
612         addinv(newquiver);
613         newquiver->nomerge = 0;
614     }
615     /* place item in quiver before printing so that inventory feedback
616        includes "(at the ready)" */
617     setuqwep(newquiver);
618     prinv((char *) 0, newquiver, 0L);
619
620     /* quiver is a convenience slot and manipulating it ordinarily
621        consumes no time, but unwielding primary or secondary weapon
622        should take time (perhaps we're adjacent to a rust monster
623        or disenchanter and want to hit it immediately, but not with
624        something we're wielding that's vulnerable to its damage) */
625     res = 0;
626     if (was_uwep) {
627 /*JP
628         You("are now empty %s.", body_part(HANDED));
629 */
630         You("\95\90\8aí\82ð\8e\9d\82½\82È\82­\82È\82Á\82½\81D");
631         res = 1;
632     } else if (was_twoweap && !u.twoweap) {
633 /*JP
634         You("are no longer wielding two weapons at once.");
635 */
636         You("\93ñ\93\81\97¬\82ð\82â\82ß\82½\81D");
637         res = 1;
638     }
639     return res;
640 }
641
642 /* used for #rub and for applying pick-axe, whip, grappling hook or polearm */
643 boolean
644 wield_tool(obj, verb)
645 struct obj *obj;
646 const char *verb; /* "rub",&c */
647 {
648 #if 0 /*JP*/
649     const char *what;
650     boolean more_than_1;
651 #endif
652
653     if (obj == uwep)
654         return TRUE; /* nothing to do if already wielding it */
655
656 #if 0 /*JP*/
657     if (!verb)
658         verb = "wield";
659     what = xname(obj);
660     more_than_1 = (obj->quan > 1L || strstri(what, "pair of ") != 0
661                    || strstri(what, "s of ") != 0);
662 #endif
663
664     if (obj->owornmask & (W_ARMOR | W_ACCESSORY)) {
665 #if 0 /*JP:T*/
666         You_cant("%s %s while wearing %s.", verb, yname(obj),
667                  more_than_1 ? "them" : "it");
668 #else
669         pline("\90g\82É\82Â\82¯\82½\82Ü\82Ü\82Å\82Í%s\82Í\8eg\82¦\82È\82¢\81D", yname(obj));
670 #endif
671         return FALSE;
672     }
673     if (welded(uwep)) {
674         if (flags.verbose) {
675 #if 0 /*JP*/
676             const char *hand = body_part(HAND);
677
678             if (bimanual(uwep))
679                 hand = makeplural(hand);
680             if (strstri(what, "pair of ") != 0)
681                 more_than_1 = FALSE;
682             pline(
683                "Since your weapon is welded to your %s, you cannot %s %s %s.",
684                   hand, verb, more_than_1 ? "those" : "that", xname(obj));
685 #else
686             pline("\95\90\8aí\82ð\8eè\82É\82µ\82Ä\82¢\82é\82Ì\82Å\81C%s\82ð\8eg\82¦\82È\82¢\81D", xname(obj));
687 #endif
688         } else {
689 /*JP
690             You_cant("do that.");
691 */
692             pline("\82»\82ê\82Í\82Å\82«\82È\82¢\81D");
693         }
694         return FALSE;
695     }
696     if (cantwield(youmonst.data)) {
697 /*JP
698         You_cant("hold %s strongly enough.", more_than_1 ? "them" : "it");
699 */
700         You("\82»\82ê\82ð\8e\9d\82Â\82Ù\82Ç\97Í\82ª\82È\82¢\81D");
701         return FALSE;
702     }
703     /* check shield */
704     if (uarms && bimanual(obj)) {
705 #if 0 /*JP:T*/
706         You("cannot %s a two-handed %s while wearing a shield.", verb,
707             (obj->oclass == WEAPON_CLASS) ? "weapon" : "tool");
708 #else
709         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",
710               (obj->oclass == WEAPON_CLASS) ? "\95\90\8aí" : "\93¹\8bï");
711 #endif
712         return FALSE;
713     }
714
715     if (uquiver == obj)
716         setuqwep((struct obj *) 0);
717     if (uswapwep == obj) {
718         (void) doswapweapon();
719         /* doswapweapon might fail */
720         if (uswapwep == obj)
721             return FALSE;
722     } else {
723         struct obj *oldwep = uwep;
724
725         if (will_weld(obj)) {
726             /* hope none of ready_weapon()'s early returns apply here... */
727             (void) ready_weapon(obj);
728         } else {
729 /*JP
730             You("now wield %s.", doname(obj));
731 */
732             You("%s\82ð\91\95\94õ\82µ\82½\81D", doname(obj));
733             setuwep(obj);
734         }
735         if (flags.pushweapon && oldwep && uwep != oldwep)
736             setuswapwep(oldwep);
737     }
738     if (uwep != obj)
739         return FALSE; /* rewielded old object after dying */
740     /* applying weapon or tool that gets wielded ends two-weapon combat */
741     if (u.twoweap)
742         untwoweapon();
743     if (obj->oclass != WEAPON_CLASS)
744         unweapon = TRUE;
745     return TRUE;
746 }
747
748 int
749 can_twoweapon()
750 {
751     struct obj *otmp;
752
753 #define NOT_WEAPON(obj) (!is_weptool(obj) && obj->oclass != WEAPON_CLASS)
754     if (!could_twoweap(youmonst.data)) {
755         if (Upolyd)
756 /*JP
757             You_cant("use two weapons in your current form.");
758 */
759             pline("\8c»\8dÝ\82Ì\8ep\82Å\82Í\93ñ\93\81\97¬\82Í\8eg\82¦\82È\82¢\81D");
760         else
761 /*JP
762             pline("%s aren't able to use two weapons at once.",
763 */
764             pline("%s\82Í\93ñ\82Â\82Ì\95\90\8aí\82ð\93¯\8e\9e\82É\88µ\82¦\82È\82¢\81D",
765                   makeplural((flags.female && urole.name.f) ? urole.name.f
766                                                             : urole.name.m));
767     } else if (!uwep || !uswapwep)
768 #if 0 /*JP*/
769         Your("%s%s%s empty.", uwep ? "left " : uswapwep ? "right " : "",
770              body_part(HAND), (!uwep && !uswapwep) ? "s are" : " is");
771 #else
772         Your("%s%s\82Í\8bó\82Á\82Û\82¾\81D", uwep ? "\8d\82Ì" : uswapwep ? "\89E\82Ì" : "",
773              body_part(HAND));
774 #endif
775     else if (NOT_WEAPON(uwep) || NOT_WEAPON(uswapwep)) {
776         otmp = NOT_WEAPON(uwep) ? uwep : uswapwep;
777 #if 0 /*JP*/
778         pline("%s %s.", Yname2(otmp),
779               is_plural(otmp) ? "aren't weapons" : "isn't a weapon");
780 #else
781         pline("%s\82Í\95\90\8aí\82\82á\82È\82¢\81D", Yname2(otmp));
782 #endif
783     } else if (bimanual(uwep) || bimanual(uswapwep)) {
784         otmp = bimanual(uwep) ? uwep : uswapwep;
785 /*JP
786         pline("%s isn't one-handed.", Yname2(otmp));
787 */
788         pline("%s\82Í\95Ð\8eè\8e\9d\82¿\82Ì\95\90\8aí\82\82á\82È\82¢\81D", Yname2(otmp));
789     } else if (uarms)
790 /*JP
791         You_cant("use two weapons while wearing a shield.");
792 */
793         You("\8f\82\82ð\8e\9d\82Á\82Ä\82¢\82é\8aÔ\82Í\97¼\8eè\8e\9d\82¿\82Å\82«\82È\82¢\81D");
794     else if (uswapwep->oartifact)
795 #if 0 /*JP:T*/
796         pline("%s being held second to another weapon!",
797               Yobjnam2(uswapwep, "resist"));
798 #else
799         pline("%s\82Í\97\\94õ\82Ì\95\90\8aí\82Æ\82µ\82Ä\88µ\82í\82ê\82é\82±\82Æ\82ð\8b\91\82ñ\82¾\81I",
800               Yname2(uswapwep));
801 #endif
802     else if (uswapwep->otyp == CORPSE && cant_wield_corpse(uswapwep)) {
803         /* [Note: NOT_WEAPON() check prevents ever getting here...] */
804         ; /* must be life-saved to reach here; return FALSE */
805     } else if (Glib || uswapwep->cursed) {
806         if (!Glib)
807             set_bknown(uswapwep, 1);
808         drop_uswapwep();
809     } else
810         return TRUE;
811     return FALSE;
812 }
813
814 void
815 drop_uswapwep()
816 {
817     char str[BUFSZ];
818     struct obj *obj = uswapwep;
819
820     /* Avoid trashing makeplural's static buffer */
821     Strcpy(str, makeplural(body_part(HAND)));
822 /*JP
823     pline("%s from your %s!", Yobjnam2(obj, "slip"), str);
824 */
825     You("%s\82ð\97\8e\82µ\82Ä\82µ\82Ü\82Á\82½\81I", xname(obj));
826     dropx(obj);
827 }
828
829 int
830 dotwoweapon()
831 {
832     /* You can always toggle it off */
833     if (u.twoweap) {
834 /*JP
835         You("switch to your primary weapon.");
836 */
837         You("\88ê\82Â\82Ì\95\90\8aí\82Å\90í\93¬\82·\82é\82±\82Æ\82É\82µ\82½\81D");
838         u.twoweap = 0;
839         update_inventory();
840         return 0;
841     }
842
843     /* May we use two weapons? */
844     if (can_twoweapon()) {
845         /* Success! */
846 /*JP
847         You("begin two-weapon combat.");
848 */
849         You("\93ñ\93\81\97¬\82Å\90í\93¬\82·\82é\82±\82Æ\82É\82µ\82½\81D");
850         u.twoweap = 1;
851         update_inventory();
852         return (rnd(20) > ACURR(A_DEX));
853     }
854     return 0;
855 }
856
857 /*** Functions to empty a given slot ***/
858 /* These should be used only when the item can't be put back in
859  * the slot by life saving.  Proper usage includes:
860  * 1.  The item has been eaten, stolen, burned away, or rotted away.
861  * 2.  Making an item disappear for a bones pile.
862  */
863 void
864 uwepgone()
865 {
866     if (uwep) {
867         if (artifact_light(uwep) && uwep->lamplit) {
868             end_burn(uwep, FALSE);
869             if (!Blind)
870 /*JP
871                 pline("%s shining.", Tobjnam(uwep, "stop"));
872 */
873                 pline("%s\82Í\8bP\82«\82ð\8e~\82ß\82½\81D", xname(uwep));
874         }
875         setworn((struct obj *) 0, W_WEP);
876         unweapon = TRUE;
877         update_inventory();
878     }
879 }
880
881 void
882 uswapwepgone()
883 {
884     if (uswapwep) {
885         setworn((struct obj *) 0, W_SWAPWEP);
886         update_inventory();
887     }
888 }
889
890 void
891 uqwepgone()
892 {
893     if (uquiver) {
894         setworn((struct obj *) 0, W_QUIVER);
895         update_inventory();
896     }
897 }
898
899 void
900 untwoweapon()
901 {
902     if (u.twoweap) {
903 /*JP
904         You("can no longer use two weapons at once.");
905 */
906         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");
907         u.twoweap = FALSE;
908         update_inventory();
909     }
910     return;
911 }
912
913 int
914 chwepon(otmp, amount)
915 register struct obj *otmp;
916 register int amount;
917 {
918     const char *color = hcolor((amount < 0) ? NH_BLACK : NH_BLUE);
919     const char *xtime, *wepname = "";
920     boolean multiple;
921     int otyp = STRANGE_OBJECT;
922
923     if (!uwep || (uwep->oclass != WEAPON_CLASS && !is_weptool(uwep))) {
924         char buf[BUFSZ];
925
926         if (amount >= 0 && uwep && will_weld(uwep)) { /* cursed tin opener */
927             if (!Blind) {
928 #if 0 /*JP:T*/
929                 Sprintf(buf, "%s with %s aura.",
930                         Yobjnam2(uwep, "glow"), an(hcolor(NH_AMBER)));
931 #else
932                 Sprintf(buf, "%s\82Í%s\83I\81[\83\89\82É\82Â\82Â\82Ü\82ê\82½\81D",
933                         xname(uwep), hcolor(NH_AMBER));
934 #endif
935                 uwep->bknown = !Hallucination; /* ok to bypass set_bknown() */
936             } else {
937                 /* cursed tin opener is wielded in right hand */
938 /*JP
939                 Sprintf(buf, "Your right %s tingles.", body_part(HAND));
940 */
941                 Sprintf(buf, "\82 \82È\82½\82Ì\89E%s\82Í\82¿\82­\82¿\82­\82µ\82½\81D", body_part(HAND));
942             }
943             uncurse(uwep);
944             update_inventory();
945         } else {
946 #if 0 /*JP:T*/
947             Sprintf(buf, "Your %s %s.", makeplural(body_part(HAND)),
948                     (amount >= 0) ? "twitch" : "itch");
949 #else
950             Sprintf(buf, "\82 \82È\82½\82Ì%s\82Í%s\81D", makeplural(body_part(HAND)),
951                     (amount >= 0) ? "\82Ð\82«\82Â\82Á\82½" : "\83\80\83Y\83\80\83Y\82µ\82½");
952 #endif
953         }
954         strange_feeling(otmp, buf); /* pline()+docall()+useup() */
955         exercise(A_DEX, (boolean) (amount >= 0));
956         return 0;
957     }
958
959     if (otmp && otmp->oclass == SCROLL_CLASS)
960         otyp = otmp->otyp;
961
962     if (uwep->otyp == WORM_TOOTH && amount >= 0) {
963         multiple = (uwep->quan > 1L);
964         /* order: message, transformation, shop handling */
965 #if 0 /*JP:T*/
966         Your("%s %s much sharper now.", simpleonames(uwep),
967              multiple ? "fuse, and become" : "is");
968 #else
969         Your("%s\82Í%s\82æ\82è\89s\82³\82ð\91\9d\82µ\82½\82æ\82¤\82¾\81D", simpleonames(uwep),
970              multiple ? "\97Z\8d\87\82µ\82Ä\81C" : "");
971 #endif
972         uwep->otyp = CRYSKNIFE;
973         uwep->oerodeproof = 0;
974         if (multiple) {
975             uwep->quan = 1L;
976             uwep->owt = weight(uwep);
977         }
978         if (uwep->cursed)
979             uncurse(uwep);
980         /* update shop bill to reflect new higher value */
981         if (uwep->unpaid)
982             alter_cost(uwep, 0L);
983         if (otyp != STRANGE_OBJECT)
984             makeknown(otyp);
985         if (multiple)
986             encumber_msg();
987         return 1;
988     } else if (uwep->otyp == CRYSKNIFE && amount < 0) {
989         multiple = (uwep->quan > 1L);
990         /* order matters: message, shop handling, transformation */
991 #if 0 /*JP:T*/
992         Your("%s %s much duller now.", simpleonames(uwep),
993              multiple ? "fuse, and become" : "is");
994 #else
995         Your("%s\82Í%s\82æ\82è\93Ý\82­\82È\82Á\82Ä\82µ\82Ü\82Á\82½\82æ\82¤\82¾\81D", simpleonames(uwep),
996              multiple ? "\97Z\8d\87\82µ\82Ä\81C" : "");
997 #endif
998         costly_alteration(uwep, COST_DEGRD); /* DECHNT? other? */
999         uwep->otyp = WORM_TOOTH;
1000         uwep->oerodeproof = 0;
1001         if (multiple) {
1002             uwep->quan = 1L;
1003             uwep->owt = weight(uwep);
1004         }
1005         if (otyp != STRANGE_OBJECT && otmp->bknown)
1006             makeknown(otyp);
1007         if (multiple)
1008             encumber_msg();
1009         return 1;
1010     }
1011
1012     if (has_oname(uwep))
1013         wepname = ONAME(uwep);
1014     if (amount < 0 && uwep->oartifact && restrict_name(uwep, wepname)) {
1015         if (!Blind)
1016 /*JP
1017             pline("%s %s.", Yobjnam2(uwep, "faintly glow"), color);
1018 */
1019             Your("%s\82Í\82í\82¸\82©\82É%s\8bP\82¢\82½\81D", xname(uwep),jconj_adj(color));
1020         return 1;
1021     }
1022     /* there is a (soft) upper and lower limit to uwep->spe */
1023     if (((uwep->spe > 5 && amount >= 0) || (uwep->spe < -5 && amount < 0))
1024         && rn2(3)) {
1025         if (!Blind)
1026 #if 0 /*JP:T*/
1027             pline("%s %s for a while and then %s.",
1028                   Yobjnam2(uwep, "violently glow"), color,
1029                   otense(uwep, "evaporate"));
1030 #else
1031             Your("%s\82Í\82µ\82Î\82ç\82­\8c\83\82µ\82­%s\8bP\82«\81C\8fö\94­\82µ\82½\81D",
1032                  xname(uwep), jconj_adj(color));
1033 #endif
1034         else
1035 /*JP
1036             pline("%s.", Yobjnam2(uwep, "evaporate"));
1037 */
1038             Your("%s\82Í\8fö\94­\82µ\82½\81D", xname(uwep));
1039
1040         useupall(uwep); /* let all of them disappear */
1041         return 1;
1042     }
1043     if (!Blind) {
1044 /*JP
1045         xtime = (amount * amount == 1) ? "moment" : "while";
1046 */
1047         xtime = (amount*amount == 1) ? "\88ê\8fu" : "\82µ\82Î\82ç\82­\82Ì\8aÔ";
1048 #if 0 /*JP:T*/
1049         pline("%s %s for a %s.",
1050               Yobjnam2(uwep, amount == 0 ? "violently glow" : "glow"), color,
1051               xtime);
1052 #else
1053         Your("%s\82Í%s%s%s\8bP\82¢\82½\81D",
1054              xname(uwep), xtime, jconj_adj(color), 
1055              amount == 0 ? "\8c\83\82µ\82­" : "");
1056 #endif
1057         if (otyp != STRANGE_OBJECT && uwep->known
1058             && (amount > 0 || (amount < 0 && otmp->bknown)))
1059             makeknown(otyp);
1060     }
1061     if (amount < 0)
1062         costly_alteration(uwep, COST_DECHNT);
1063     uwep->spe += amount;
1064     if (amount > 0) {
1065         if (uwep->cursed)
1066             uncurse(uwep);
1067         /* update shop bill to reflect new higher price */
1068         if (uwep->unpaid)
1069             alter_cost(uwep, 0L);
1070     }
1071
1072     /*
1073      * Enchantment, which normally improves a weapon, has an
1074      * addition adverse reaction on Magicbane whose effects are
1075      * spe dependent.  Give an obscure clue here.
1076      */
1077     if (uwep->oartifact == ART_MAGICBANE && uwep->spe >= 0) {
1078 #if 0 /*JP:T*/
1079         Your("right %s %sches!", body_part(HAND),
1080              (((amount > 1) && (uwep->spe > 1)) ? "flin" : "it"));
1081 #else
1082         Your("\89E%s\82Í%s\81I",
1083              body_part(HAND),
1084              (((amount > 1) && (uwep->spe > 1)) ? "\82Ð\82è\82Ð\82è\82µ\82½" : "\83\80\83Y\83\80\83Y\82µ\82½"));
1085 #endif
1086     }
1087
1088     /* an elven magic clue, cookie@keebler */
1089     /* elven weapons vibrate warningly when enchanted beyond a limit */
1090     if ((uwep->spe > 5)
1091         && (is_elven_weapon(uwep) || uwep->oartifact || !rn2(7)))
1092 /*JP
1093         pline("%s unexpectedly.", Yobjnam2(uwep, "suddenly vibrate"));
1094 */
1095         Your("%s\82Í\93Ë\91R\90k\82¦\82¾\82µ\82½\81D", xname(uwep));
1096
1097     return 1;
1098 }
1099
1100 int
1101 welded(obj)
1102 register struct obj *obj;
1103 {
1104     if (obj && obj == uwep && will_weld(obj)) {
1105         set_bknown(obj, 1);
1106         return 1;
1107     }
1108     return 0;
1109 }
1110
1111 void
1112 weldmsg(obj)
1113 register struct obj *obj;
1114 {
1115     long savewornmask;
1116
1117     savewornmask = obj->owornmask;
1118 #if 0 /*JP*/
1119     pline("%s welded to your %s!", Yobjnam2(obj, "are"),
1120           bimanual(obj) ? (const char *) makeplural(body_part(HAND))
1121                         : body_part(HAND));
1122 #else
1123     You("%s\82ð%s\82É\8d\\82¦\82½\81I", xname(obj), body_part(HAND));
1124 #endif
1125     obj->owornmask = savewornmask;
1126 }
1127
1128 /* test whether monster's wielded weapon is stuck to hand/paw/whatever */
1129 boolean
1130 mwelded(obj)
1131 struct obj *obj;
1132 {
1133     /* caller is responsible for making sure this is a monster's item */
1134     if (obj && (obj->owornmask & W_WEP) && will_weld(obj))
1135         return TRUE;
1136     return FALSE;
1137 }
1138
1139 /*wield.c*/