OSDN Git Service

update year to 2023
[jnethack/source.git] / src / wield.c
index 296ca78..d45ed86 100644 (file)
@@ -1,11 +1,11 @@
-/* NetHack 3.6 wield.c $NHDT-Date: 1496959480 2017/06/08 22:04:40 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.54 $ */
+/* NetHack 3.6 wield.c $NHDT-Date: 1559670611 2019/06/04 17:50:11 $  $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.59 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2009. */
 /* NetHack may be freely redistributed.  See license for details. */
 
 /* JNetHack Copyright */
 /* (c) Issei Numata, Naoki Hamada, Shigehiro Miyashita, 1994-2000  */
-/* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2018            */
+/* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2023            */
 /* JNetHack may be freely redistributed.  See license for details. */
 
 #include "hack.h"
@@ -120,7 +120,6 @@ register struct obj *obj;
                        : !is_weptool(obj) && !is_wet_towel(obj);
     } else
         unweapon = TRUE; /* for "bare hands" message */
-    update_inventory();
 }
 
 STATIC_OVL boolean
@@ -134,7 +133,7 @@ struct obj *obj;
         return FALSE;
 
     /* Prevent wielding cockatrice when not wearing gloves --KAA */
-#if 0 /*JP*/
+#if 0 /*JP:T*/
     You("wield %s in your bare %s.",
         corpse_xname(obj, (const char *) 0, CXN_PFX_THE),
         makeplural(body_part(HAND)));
@@ -176,7 +175,7 @@ struct obj *wep;
         /* hero must have been life-saved to get here; use a turn */
         res++; /* corpse won't be wielded */
     } else if (uarms && bimanual(wep)) {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
         You("cannot wield a two-handed %s while wearing a shield.",
             is_sword(wep) ? "sword" : wep->otyp == BATTLE_AXE ? "axe"
                                                               : "weapon");
@@ -208,7 +207,7 @@ struct obj *wep;
             pline("%s\82Í\8f\9f\8eè\82É\82 \82È\82½\82Ì%s\82É\91\95\94õ\82³\82ê\82½\81D",
                   xname(wep), body_part(HAND));
 #endif
-            wep->bknown = TRUE;
+            set_bknown(wep, 1);
         } else {
             /* The message must be printed before setuwep (since
              * you might die and be revived from changing weapons),
@@ -223,6 +222,11 @@ struct obj *wep;
             long dummy = wep->owornmask;
 
             wep->owornmask |= W_WEP;
+            if (wep->otyp == AKLYS && (wep->owornmask & W_WEP) != 0)
+/*JP
+                You("secure the tether.");
+*/
+                You("\82Ð\82à\82ð\82µ\82Á\82©\82è\82Æ\8cÅ\92è\82µ\82½\81D");
             prinv((char *) 0, wep, 0L);
             wep->owornmask = dummy;
         }
@@ -234,7 +238,7 @@ struct obj *wep;
         if (artifact_light(wep) && !wep->lamplit) {
             begin_burn(wep, FALSE);
             if (!Blind)
-#if 0 /*JP*/
+#if 0 /*JP:T*/
                 pline("%s to shine %s!", Tobjnam(wep, "begin"),
                       arti_light_description(wep));
 #else
@@ -259,7 +263,7 @@ struct obj *wep;
 
             if ((this_shkp = shop_keeper(inside_shop(u.ux, u.uy)))
                 != (struct monst *) 0) {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
                 pline("%s says \"You be careful with my %s!\"",
                       shkname(this_shkp), xname(wep));
 #else
@@ -277,7 +281,9 @@ setuqwep(obj)
 register struct obj *obj;
 {
     setworn(obj, W_QUIVER);
-    update_inventory();
+    /* no extra handling needed; this used to include a call to
+       update_inventory() but that's already performed by setworn() */
+    return;
 }
 
 void
@@ -285,7 +291,7 @@ setuswapwep(obj)
 register struct obj *obj;
 {
     setworn(obj, W_SWAPWEP);
-    update_inventory();
+    return;
 }
 
 /*** Commands to change particular slot(s) ***/
@@ -491,8 +497,9 @@ dowieldquiver()
             Sprintf(qbuf, "You are wielding %ld %s.  Ready %ld of them?",
                     uwep->quan, simpleonames(uwep), uwep->quan - 1L);
 #else
-            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",
-                    uwep->quan, simpleonames(uwep), uwep->quan - 1L);
+            Sprintf(qbuf, "\82 \82È\82½\82Í%ld%s\82Ì%s\82ð\91\95\94õ\82µ\82Ä\82¢\82é\81D\82»\82Ì\82¤\82¿%ld%s\82ð\8f\80\94õ\82·\82é\81H",
+                    uwep->quan, numeral(uwep), simpleonames(uwep),
+                    uwep->quan - 1L, numeral(uwep));
 #endif
             switch (ynq(qbuf)) {
             case 'q':
@@ -523,7 +530,7 @@ dowieldquiver()
         /* require confirmation to ready the main weapon */
         if (ynq(qbuf) != 'y') {
             (void) Shk_Your(qbuf, uwep); /* replace qbuf[] contents */
-#if 0 /*JP*/
+#if 0 /*JP:T*/
             pline("%s%s %s wielded.", qbuf,
                   simpleonames(uwep), otense(uwep, "remain"));
 #else
@@ -545,12 +552,12 @@ dowieldquiver()
                               : "Your alternate weapon is",
                     uswapwep->quan, simpleonames(uswapwep),
                     uswapwep->quan - 1L);
-#else /*TODO:\93ñ\93\81\97¬\82Ì\82Æ\82«\82Í\82©\82È\82è\95s\8e©\91R */
-            Sprintf(qbuf, "%s %ld %s\82¾\81D\82»\82Ì\82¤\82¿%ld\82ð\8f\80\94õ\82·\82é\81H",
-                    u.twoweap ? "\82 \82È\82½\82ª\82»\82ê\82¼\82ê\91\95\94õ\82µ\82Ä\82¢\82é\82Ì\82Í"
-                              : "\82 \82È\82½\82Ì\97\\94õ\82Ì\95\90\8aí\82Í",
-                    uswapwep->quan, simpleonames(uswapwep),
-                    uswapwep->quan - 1L);
+#else
+            Sprintf(qbuf, "\82 \82È\82½%s\82Í%ld%s\82Ì%s\82¾\81D\82»\82Ì\82¤\82¿%ld%s\82ð\8f\80\94õ\82·\82é\81H",
+                    u.twoweap ? "\82ª\93ñ\93\81\97¬\82Å\91\95\94õ\82µ\82Ä\82¢\82é\82Ì"
+                              : "\82Ì\97\\94õ\82Ì\95\90\8aí",
+                    uswapwep->quan, numeral(uswapwep), simpleonames(uswapwep),
+                    uswapwep->quan - 1L, numeral(uswapwep));
 #endif
             switch (ynq(qbuf)) {
             case 'q':
@@ -583,7 +590,7 @@ dowieldquiver()
         /* require confirmation to ready the alternate weapon */
         if (ynq(qbuf) != 'y') {
             (void) Shk_Your(qbuf, uswapwep); /* replace qbuf[] contents */
-#if 0 /*JP*/
+#if 0 /*JP:T*/
             pline("%s%s %s %s.", qbuf,
                   simpleonames(uswapwep), otense(uswapwep, "remain"),
                   u.twoweap ? "wielded" : "as secondary weapon");
@@ -656,7 +663,7 @@ const char *verb; /* "rub",&c */
 #endif
 
     if (obj->owornmask & (W_ARMOR | W_ACCESSORY)) {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
         You_cant("%s %s while wearing %s.", verb, yname(obj),
                  more_than_1 ? "them" : "it");
 #else
@@ -696,7 +703,7 @@ const char *verb; /* "rub",&c */
     }
     /* check shield */
     if (uarms && bimanual(obj)) {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
         You("cannot %s a two-handed %s while wearing a shield.", verb,
             (obj->oclass == WEAPON_CLASS) ? "weapon" : "tool");
 #else
@@ -716,11 +723,16 @@ const char *verb; /* "rub",&c */
     } else {
         struct obj *oldwep = uwep;
 
+        if (will_weld(obj)) {
+            /* hope none of ready_weapon()'s early returns apply here... */
+            (void) ready_weapon(obj);
+        } else {
 /*JP
-        You("now wield %s.", doname(obj));
+            You("now wield %s.", doname(obj));
 */
-        You("%s\82ð\91\95\94õ\82µ\82½\81D", doname(obj));
-        setuwep(obj);
+            You("%s\82ð\91\95\94õ\82µ\82½\81D", doname(obj));
+            setuwep(obj);
+        }
         if (flags.pushweapon && oldwep && uwep != oldwep)
             setuswapwep(oldwep);
     }
@@ -781,7 +793,7 @@ can_twoweapon()
 */
         You("\8f\82\82ð\8e\9d\82Á\82Ä\82¢\82é\8aÔ\82Í\97¼\8eè\8e\9d\82¿\82Å\82«\82È\82¢\81D");
     else if (uswapwep->oartifact)
-#if 0 /*JP*/
+#if 0 /*JP:T*/
         pline("%s being held second to another weapon!",
               Yobjnam2(uswapwep, "resist"));
 #else
@@ -793,7 +805,7 @@ can_twoweapon()
         ; /* must be life-saved to reach here; return FALSE */
     } else if (Glib || uswapwep->cursed) {
         if (!Glib)
-            uswapwep->bknown = TRUE;
+            set_bknown(uswapwep, 1);
         drop_uswapwep();
     } else
         return TRUE;
@@ -904,7 +916,11 @@ chwepon(otmp, amount)
 register struct obj *otmp;
 register int amount;
 {
+#if 0 /*JP*/
     const char *color = hcolor((amount < 0) ? NH_BLACK : NH_BLUE);
+#else
+    const char *color = hcolor_adv((amount < 0) ? NH_BLACK : NH_BLUE);
+#endif
     const char *xtime, *wepname = "";
     boolean multiple;
     int otyp = STRANGE_OBJECT;
@@ -914,17 +930,25 @@ register int amount;
 
         if (amount >= 0 && uwep && will_weld(uwep)) { /* cursed tin opener */
             if (!Blind) {
+#if 0 /*JP:T*/
                 Sprintf(buf, "%s with %s aura.",
                         Yobjnam2(uwep, "glow"), an(hcolor(NH_AMBER)));
-                uwep->bknown = !Hallucination;
+#else
+                Sprintf(buf, "%s\82Í%s\83I\81[\83\89\82É\82Â\82Â\82Ü\82ê\82½\81D",
+                        xname(uwep), hcolor(NH_AMBER));
+#endif
+                uwep->bknown = !Hallucination; /* ok to bypass set_bknown() */
             } else {
                 /* cursed tin opener is wielded in right hand */
+/*JP
                 Sprintf(buf, "Your right %s tingles.", body_part(HAND));
+*/
+                Sprintf(buf, "\82 \82È\82½\82Ì\89E%s\82Í\82¿\82­\82¿\82­\82µ\82½\81D", body_part(HAND));
             }
             uncurse(uwep);
             update_inventory();
         } else {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
             Sprintf(buf, "Your %s %s.", makeplural(body_part(HAND)),
                     (amount >= 0) ? "twitch" : "itch");
 #else
@@ -943,7 +967,7 @@ register int amount;
     if (uwep->otyp == WORM_TOOTH && amount >= 0) {
         multiple = (uwep->quan > 1L);
         /* order: message, transformation, shop handling */
-#if 0 /*JP*/
+#if 0 /*JP:T*/
         Your("%s %s much sharper now.", simpleonames(uwep),
              multiple ? "fuse, and become" : "is");
 #else
@@ -969,7 +993,7 @@ register int amount;
     } else if (uwep->otyp == CRYSKNIFE && amount < 0) {
         multiple = (uwep->quan > 1L);
         /* order matters: message, shop handling, transformation */
-#if 0 /*JP*/
+#if 0 /*JP:T*/
         Your("%s %s much duller now.", simpleonames(uwep),
              multiple ? "fuse, and become" : "is");
 #else
@@ -997,20 +1021,20 @@ register int amount;
 /*JP
             pline("%s %s.", Yobjnam2(uwep, "faintly glow"), color);
 */
-            Your("%s\82Í\82í\82¸\82©\82É%s\8bP\82¢\82½\81D", xname(uwep),jconj_adj(color));
+            Your("%s\82Í\82í\82¸\82©\82É%s\8bP\82¢\82½\81D", xname(uwep), color);
         return 1;
     }
     /* there is a (soft) upper and lower limit to uwep->spe */
     if (((uwep->spe > 5 && amount >= 0) || (uwep->spe < -5 && amount < 0))
         && rn2(3)) {
         if (!Blind)
-#if 0 /*JP*/
+#if 0 /*JP:T*/
             pline("%s %s for a while and then %s.",
                   Yobjnam2(uwep, "violently glow"), color,
                   otense(uwep, "evaporate"));
 #else
             Your("%s\82Í\82µ\82Î\82ç\82­\8c\83\82µ\82­%s\8bP\82«\81C\8fö\94­\82µ\82½\81D",
-                 xname(uwep), jconj_adj(color));
+                 xname(uwep), color);
 #endif
         else
 /*JP
@@ -1026,13 +1050,13 @@ register int amount;
         xtime = (amount * amount == 1) ? "moment" : "while";
 */
         xtime = (amount*amount == 1) ? "\88ê\8fu" : "\82µ\82Î\82ç\82­\82Ì\8aÔ";
-#if 0 /*JP*/
+#if 0 /*JP:T*/
         pline("%s %s for a %s.",
               Yobjnam2(uwep, amount == 0 ? "violently glow" : "glow"), color,
               xtime);
 #else
         Your("%s\82Í%s%s%s\8bP\82¢\82½\81D",
-             xname(uwep), xtime, jconj_adj(color)
+             xname(uwep), xtime, color
              amount == 0 ? "\8c\83\82µ\82­" : "");
 #endif
         if (otyp != STRANGE_OBJECT && uwep->known
@@ -1056,7 +1080,7 @@ register int amount;
      * spe dependent.  Give an obscure clue here.
      */
     if (uwep->oartifact == ART_MAGICBANE && uwep->spe >= 0) {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
         Your("right %s %sches!", body_part(HAND),
              (((amount > 1) && (uwep->spe > 1)) ? "flin" : "it"));
 #else
@@ -1083,7 +1107,7 @@ welded(obj)
 register struct obj *obj;
 {
     if (obj && obj == uwep && will_weld(obj)) {
-        obj->bknown = TRUE;
+        set_bknown(obj, 1);
         return 1;
     }
     return 0;