OSDN Git Service

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