OSDN Git Service

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