OSDN Git Service

update year to 2022
[jnethack/source.git] / src / mthrowu.c
index 64fad35..9683145 100644 (file)
@@ -1,11 +1,11 @@
-/* NetHack 3.6 mthrowu.c       $NHDT-Date: 1514152830 2017/12/24 22:00:30 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.73 $ */
+/* NetHack 3.6 mthrowu.c       $NHDT-Date: 1573688695 2019/11/13 23:44:55 $  $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.86 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Pasi Kallinen, 2016. */
 /* 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-2016            */
+/* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2022            */
 /* JNetHack may be freely redistributed.  See license for details. */
 
 #include "hack.h"
@@ -26,7 +26,7 @@ STATIC_DCL boolean FDECL(m_lined_up, (struct monst *, struct monst *));
  * Keep consistent with breath weapons in zap.c, and AD_* in monattk.h.
  */
 STATIC_OVL NEARDATA const char *breathwep[] = {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
     "fragments", "fire", "frost", "sleep gas", "a disintegration blast",
     "lightning", "poison gas", "acid", "strange breath #8",
     "strange breath #9"
@@ -89,7 +89,10 @@ const char *name; /* if null, then format `*objp' */
         } else if (u.uac + tlev <= dieroll - 2) {
             if (onm != onmbuf)
                 Strcpy(onmbuf, onm); /* [modifiable buffer for upstart()] */
+/*JP
             pline("%s %s you.", upstart(onmbuf), vtense(onmbuf, "miss"));
+*/
+            pline("%s\82Í\8dU\8c\82\82ð\82Í\82¸\82µ\82½\81D", upstart(onmbuf));
         } else
 /*JP
             You("are almost hit by %s.", onm);
@@ -123,9 +126,9 @@ const char *name; /* if null, then format `*objp' */
                 && Hate_silver) {
                 /* extra damage already applied by dmgval() */
 /*JP
-            pline_The("silver sears your flesh!");
+                pline_The("silver sears your flesh!");
 */
-            pline("\82 \82È\82½\82Ì\91Ì\82Í\8bâ\82Å\8fÄ\82©\82ê\82½\81I");
+                pline("\82 \82È\82½\82Ì\91Ì\82Í\8bâ\82Å\8fÄ\82©\82ê\82½\81I");
                 exercise(A_CON, FALSE);
             }
             if (is_acid)
@@ -165,7 +168,7 @@ int x, y;
 
     if (create && !((mtmp = m_at(x, y)) != 0 && mtmp->mtrapped
                     && (t = t_at(x, y)) != 0
-                    && (t->ttyp == PIT || t->ttyp == SPIKED_PIT))) {
+                    && is_pit(t->ttyp))) {
         int objgone = 0;
 
         if (down_gate(x, y) != -1)
@@ -226,7 +229,10 @@ struct obj *otmp, *mwep;
         /* Elven Craftsmanship makes for light, quick bows */
         if (otmp->otyp == ELVEN_ARROW && !otmp->cursed)
             multishot++;
-        if (ammo_and_launcher(otmp, uwep) && mwep->otyp == ELVEN_BOW
+        /* for arrow, we checked bow&arrow when entering block, but for
+           bow, so far we've only validated that otmp is a weapon stack;
+           need to verify that it's a stack of arrows rather than darts */
+        if (mwep && mwep->otyp == ELVEN_BOW && ammo_and_launcher(otmp, mwep)
             && !mwep->cursed)
             multishot++;
         /* 1/3 of launcher enchantment */
@@ -315,16 +321,19 @@ struct obj *otmp, *mwep;
         }
         m_shot.s = ammo_and_launcher(otmp, mwep) ? TRUE : FALSE;
         Strcpy(trgbuf, mtarg ? mon_nam(mtarg) : "");
+#if 0 /*JP*//*\93ú\96{\8cê\82Å\82Ímon_nam\82Í\81u\89½\8eÒ\82©\81v\82ð\95Ô\82·\82Ì\82Å\95Ï\8dX\95s\97v*/
         if (!strcmp(trgbuf, "it"))
             Strcpy(trgbuf, humanoid(mtmp->data) ? "someone" : something);
-#if 0 /*JP*/
+#endif
+#if 0 /*JP:T*/
         pline("%s %s %s%s%s!", Monnam(mtmp),
               m_shot.s ? "shoots" : "throws", onm,
               mtarg ? " at " : "", trgbuf);
 #else
-        pline("%s\82Í%s\82ð%s\82É%s\81I", Monnam(mtmp),
+        pline("%s\82Í%s\82ð%s%s%s\81I", Monnam(mtmp),
               onm,
               trgbuf,
+              mtarg ? "\82É" : "",
               m_shot.s ? "\8c\82\82Á\82½" : "\93\8a\82°\82½");
 #endif
         m_shot.o = otmp->otyp;
@@ -338,7 +347,7 @@ struct obj *otmp, *mwep;
            if mtmp gets killed (shot kills adjacent gas spore and
            triggers explosion, perhaps), inventory will be dropped
            and otmp might go away via merging into another stack */
-        if (mtmp->mhp <= 0 && m_shot.i < m_shot.n)
+        if (DEADMONSTER(mtmp) && m_shot.i < m_shot.n)
             /* cancel pending shots (perhaps ought to give a message here
                since we gave one above about throwing/shooting N missiles) */
             break; /* endmultishot(FALSE); */
@@ -366,7 +375,7 @@ boolean verbose;    /* give message(s) even when you can't see what happened */
     struct obj *mon_launcher = archer ? MON_WEP(archer) : NULL;
 
     notonhead = (bhitpos.x != mtmp->mx || bhitpos.y != mtmp->my);
-    ismimic = mtmp->m_ap_type && mtmp->m_ap_type != M_AP_MONSTER;
+    ismimic = M_AP_TYPE(mtmp) && M_AP_TYPE(mtmp) != M_AP_MONSTER;
     vis = cansee(bhitpos.x, bhitpos.y);
 
     tmp = 5 + find_mac(mtmp) + omon_adj(mtmp, otmp, FALSE);
@@ -407,18 +416,27 @@ boolean verbose;    /* give message(s) even when you can't see what happened */
         damage = dmgval(otmp, mtmp);
         if (otmp->otyp == ACID_VENOM && resists_acid(mtmp))
             damage = 0;
+#if 0 /* can't use this because we don't have the attacker */
+        if (is_orc(mtmp->data) && is_elf(?magr?))
+            damage++;
+#endif
         if (ismimic)
             seemimic(mtmp);
         mtmp->msleeping = 0;
         if (vis) {
             if (otmp->otyp == EGG)
-                pline("Splat! %s is hit with %s egg!", Monnam(mtmp),
+#if 0 /*JP:T*/
+                pline("Splat!  %s is hit with %s egg!", Monnam(mtmp),
                       otmp->known ? an(mons[otmp->corpsenm].mname) : "an");
+#else
+                pline("\83r\83`\83\83\83b\81I%s\82Í%s\97\91\82É\93\96\82½\82Á\82½\81I", Monnam(mtmp),
+                      otmp->known ? s_suffix(mons[otmp->corpsenm].mname) : "");
+#endif
             else
                 hit(distant_name(otmp, mshot_xname), mtmp, exclam(damage));
         } else if (verbose && !target)
 #if 0 /*JP:T*/
-            pline("%s%s is hit%s", (otmp->otyp == EGG) ? "Splat! " : "",
+            pline("%s%s is hit%s", (otmp->otyp == EGG) ? "Splat!  " : "",
                   Monnam(mtmp), exclam(damage));
 #else
             pline("%s%s\82É\96½\92\86\82µ\82½%s", (otmp->otyp == EGG) ? "\83r\83`\83\83\83b\81I" : "",
@@ -448,16 +466,28 @@ boolean verbose;    /* give message(s) even when you can't see what happened */
         }
         if (objects[otmp->otyp].oc_material == SILVER
             && mon_hates_silver(mtmp)) {
-            if (vis)
+            boolean flesh = (!noncorporeal(mtmp->data)
+                             && !amorphous(mtmp->data));
+
+            /* note: extra silver damage is handled by dmgval() */
+            if (vis) {
+                char *m_name = mon_nam(mtmp);
+
+                if (flesh) /* s_suffix returns a modifiable buffer */
 /*JP
-                pline_The("silver sears %s flesh!", s_suffix(mon_nam(mtmp)));
+                    m_name = strcat(s_suffix(m_name), " flesh");
 */
-                pline("%s\82Ì\91Ì\82Í\8bâ\82Å\8fÄ\82©\82ê\82½\81I", mon_nam(mtmp));
-            else if (verbose && !target)
+                    m_name = strcat(s_suffix(m_name), "\82Ì\91Ì");
+/*JP
+                pline_The("silver sears %s!", m_name);
+*/
+                pline("%s\82Í\8bâ\82Å\8fÄ\82©\82ê\82½\81I", m_name);
+            } else if (verbose && !target) {
 /*JP
-                pline("Its flesh is seared!");
+                pline("%s is seared!", flesh ? "Its flesh" : "It");
 */
-                pline("\89½\8eÒ\82©\82Ì\91Ì\82Í\8fÄ\82©\82ê\82½\81I");
+                pline("\89½%s\82Í\8fÄ\82©\82ê\82½\81I", flesh ? "\8eÒ\82©\82Ì\91Ì" : "\82©");
+            }
         }
         if (otmp->otyp == ACID_VENOM && cansee(mtmp->mx, mtmp->my)) {
             if (resists_acid(mtmp)) {
@@ -486,9 +516,9 @@ boolean verbose;    /* give message(s) even when you can't see what happened */
                 damage = 0;
         }
 
-        if (mtmp->mhp > 0) { /* might already be dead (if petrified) */
+        if (!DEADMONSTER(mtmp)) { /* might already be dead (if petrified) */
             mtmp->mhp -= damage;
-            if (mtmp->mhp < 1) {
+            if (DEADMONSTER(mtmp)) {
                 if (vis || (verbose && !target))
 #if 0 /*JP:T*/
                     pline("%s is %s!", Monnam(mtmp),
@@ -510,7 +540,7 @@ boolean verbose;    /* give message(s) even when you can't see what happened */
 
         /* blinding venom and cream pie do 0 damage, but verify
            that the target is still alive anyway */
-        if (mtmp->mhp > 0
+        if (!DEADMONSTER(mtmp)
             && can_blnd((struct monst *) 0, mtmp,
                         (uchar) ((otmp->otyp == BLINDING_VENOM) ? AT_SPIT
                                                                 : AT_WEAP),
@@ -603,7 +633,7 @@ struct obj *obj;         /* missile (or stack providing it) */
 */
                 pline("%s\82Í\82Í\82¸\82µ\82½\81I", Monnam(mon));
             else
-#if 0 /*JP*/
+#if 0 /*JP:T*/
                 pline("%s as %s throws it!", Tobjnam(singleobj, "slip"),
                       mon_nam(mon));
 #else
@@ -631,11 +661,16 @@ struct obj *obj;         /* missile (or stack providing it) */
      * be careful not to use either one after it's been freed.
      */
     if (sym)
-        tmp_at(DISP_FLASH, obj_to_glyph(singleobj));
+        tmp_at(DISP_FLASH, obj_to_glyph(singleobj, rn2_on_display_rng));
     while (range-- > 0) { /* Actually the loop is always exited by break */
         bhitpos.x += dx;
         bhitpos.y += dy;
-        if ((mtmp = m_at(bhitpos.x, bhitpos.y)) != 0) {
+        mtmp = m_at(bhitpos.x, bhitpos.y);
+        if (mtmp && shade_miss(mon, mtmp, singleobj, TRUE, TRUE)) {
+            /* if mtmp is a shade and missile passes harmlessly through it,
+               give message and skip it in order to keep going */
+            mtmp = (struct monst *) 0;
+        } else if (mtmp) {
             if (ohitmon(mtmp, singleobj, range, TRUE))
                 break;
         } else if (bhitpos.x == u.ux && bhitpos.y == u.uy) {
@@ -650,7 +685,7 @@ struct obj *obj;         /* missile (or stack providing it) */
                     You("catch the %s.", xname(singleobj));
 */
                     You("%s\82ð\82Â\82©\82Ü\82¦\82½\81D", xname(singleobj));
-#if 0 /*JP*/
+#if 0 /*JP:T*/
                     You("are not interested in %s junk.",
                         s_suffix(mon_nam(mon)));
 #else
@@ -666,7 +701,7 @@ struct obj *obj;         /* missile (or stack providing it) */
 */
                      "\82±\82ê\82ª\97~\82µ\82©\82Á\82½\82ñ\82¾\82Æ\8ev\82¢\82È\82ª\82ç%s\82Ì\91¡\82è\95¨\82ð\8eó\82¯\82Æ\82Á\82½\81D",
                         s_suffix(mon_nam(mon)));
-#if 0 /*JP*/
+#if 0 /*JP:T*/
                     (void) hold_another_object(singleobj,
                                                "You catch, but drop, %s.",
                                                xname(singleobj),
@@ -744,7 +779,7 @@ struct obj *obj;         /* missile (or stack providing it) */
 */
                         pline("\83E\83F\81[\81D\83N\83\8a\81[\83\80\82ð\82©\82Ô\82Á\82½\81D");
                     else
-#if 0 /*JP*/
+#if 0 /*JP:T*/
                         pline("There's %s sticky all over your %s.",
                               something, body_part(FACE));
 #else
@@ -790,7 +825,10 @@ struct obj *obj;         /* missile (or stack providing it) */
                     && (!mesg_given || bhitpos.x != u.ux || bhitpos.y != u.uy)
                     && (cansee(bhitpos.x, bhitpos.y)
                         || (archer && canseemon(archer))))
+/*JP
                     pline("%s misses.", The(mshot_xname(singleobj)));
+*/
+                    pline("%s\82Í\82Í\82¸\82ê\82½\81D", mshot_xname(singleobj));
                 (void) drop_throw(singleobj, 0, bhitpos.x, bhitpos.y);
             }
             break;
@@ -888,7 +926,7 @@ struct attack *mattk;
             break;
         default:
             impossible("bad attack type in spitmu");
-            /* fall through */
+            /*FALLTHRU*/
         case AD_ACID:
             otmp = mksobj(ACID_VENOM, TRUE, FALSE);
             break;
@@ -949,8 +987,11 @@ struct attack  *mattk;
         if (!mtmp->mspec_used && rn2(3)) {
             if ((typ >= AD_MAGM) && (typ <= AD_ACID)) {
                 if (canseemon(mtmp))
+/*JP
                     pline("%s breathes %s!", Monnam(mtmp), breathwep[typ - 1]);
-                dobuzz((int) (-20 - (typ - 1)), (int)mattk->damn,
+*/
+                    pline("%s\82Í%s\82ð\82Í\82¢\82½\81I", Monnam(mtmp), breathwep[typ - 1]);
+                dobuzz((int) (-20 - (typ - 1)), (int) mattk->damn,
                        mtmp->mx, mtmp->my, sgn(tbx), sgn(tby), FALSE);
                 nomul(0);
                 /* breath runs out sometimes. Also, give monster some
@@ -1040,7 +1081,7 @@ struct monst *mtmp;
 
         if (canseemon(mtmp)) {
             onm = xname(otmp);
-#if 0 /*JP*/
+#if 0 /*JP:T*/
             pline("%s thrusts %s.", Monnam(mtmp),
                   obj_is_pname(otmp) ? the(onm) : an(onm));
 #else
@@ -1090,8 +1131,13 @@ struct attack *mattk;
 
     if (mtmp->mcan) {
         if (!Deaf)
+#if 0 /*JP:T*/
             pline("A dry rattle comes from %s throat.",
                   s_suffix(mon_nam(mtmp)));
+#else
+            pline("\8a£\82¢\82½\83K\83\89\83K\83\89\89¹\82ª%s\82Ì\82Ì\82Ç\82©\82ç\95·\82±\82¦\82Ä\82«\82½\81D",
+                  mon_nam(mtmp));
+#endif
         return 0;
     }
     if (lined_up(mtmp)) {
@@ -1110,7 +1156,10 @@ struct attack *mattk;
         if (!rn2(BOLT_LIM
                  - distmin(mtmp->mx, mtmp->my, mtmp->mux, mtmp->muy))) {
             if (canseemon(mtmp))
+/*JP
                 pline("%s spits venom!", Monnam(mtmp));
+*/
+                pline("%s\82Í\93Å\89t\82ð\93f\82¢\82½\81I", Monnam(mtmp));
             m_throw(mtmp, mtmp->mx, mtmp->my, sgn(tbx), sgn(tby),
                     distmin(mtmp->mx, mtmp->my, mtmp->mux, mtmp->muy), otmp);
             nomul(0);
@@ -1136,16 +1185,22 @@ struct attack *mattk;
         if (mtmp->mcan) {
             if (!Deaf) {
                 if (canseemon(mtmp))
+/*JP
                     pline("%s coughs.", Monnam(mtmp));
+*/
+                    pline("%s\82Í\82¹\82«\82ð\82µ\82½\81D", Monnam(mtmp));
                 else
+/*JP
                     You_hear("a cough.");
+*/
+                    You_hear("\82¹\82«\82Ì\89¹\82ð\95·\82¢\82½\81D");
             }
             return 0;
         }
         if (!mtmp->mspec_used && rn2(3)) {
             if ((typ >= AD_MAGM) && (typ <= AD_ACID)) {
                 if (canseemon(mtmp))
-#if 0 /*JP*/
+#if 0 /*JP:T*/
                     pline("%s breathes %s!", Monnam(mtmp),
                           breathwep[typ - 1]);
 #else
@@ -1228,8 +1283,8 @@ register struct monst *mtmp;
 
     /* hero concealment usually trumps monst awareness of being lined up */
     if (Upolyd && rn2(25)
-        && (u.uundetected || (youmonst.m_ap_type != M_AP_NOTHING
-                              && youmonst.m_ap_type != M_AP_MONSTER)))
+        && (u.uundetected || (U_AP_TYPE != M_AP_NOTHING
+                              && U_AP_TYPE != M_AP_MONSTER)))
         return FALSE;
 
     ignore_boulders = (throws_rocks(mtmp->data)
@@ -1269,30 +1324,36 @@ boolean your_fault, from_invent;
         /* breakage makes its own noises */
         if (obj_type == POT_ACID) {
             if (cansee(barsx, barsy) && !unbreakable)
+/*JP
                 pline_The("iron bars are dissolved!");
+*/
+                pline_The("\93S\82Ì\96_\82Í\97Z\82¯\82½\81I");
             else
+/*JP
                 You_hear(Hallucination ? "angry snakes!" : "a hissing noise.");
+*/
+                You_hear(Hallucination ? "\93{\82Á\82½\82Ö\82Ñ\82Ì\90º\82ð\95·\82¢\82½\81I" : "\83V\81[\83b\82Æ\82¢\82¤\89¹\82ð\95·\82¢\82½\81D");
             if (!unbreakable)
                 dissolve_bars(barsx, barsy);
         }
     }
     else if (obj_type == BOULDER || obj_type == HEAVY_IRON_BALL)
 /*JP
-            pline("Whang!");
+        pline("Whang!");
 */
-            pline("\82®\82í\81[\82ñ\81I");
+        pline("\82®\82í\81[\82ñ\81I");
     else if (otmp->oclass == COIN_CLASS
              || objects[obj_type].oc_material == GOLD
              || objects[obj_type].oc_material == SILVER)
 /*JP
-            pline("Clink!");
+        pline("Clink!");
 */
-            pline("\83`\83\83\83\8a\83\93\81I");
+        pline("\83`\83\83\83\8a\83\93\81I");
     else
 /*JP
-            pline("Clonk!");
+        pline("Clonk!");
 */
-            pline("\83S\83c\83\93\81I");
+        pline("\83S\83c\83\93\81I");
 }
 
 /* TRUE iff thrown/kicked/rolled object doesn't pass through iron bars */