OSDN Git Service

set trivial flags
[jnethack/source.git] / src / minion.c
index c28556e..5a0c5ad 100644 (file)
@@ -1,11 +1,11 @@
-/* NetHack 3.6 minion.c        $NHDT-Date: 1432512773 2015/05/25 00:12:53 $  $NHDT-Branch: master $:$NHDT-Revision: 1.33 $ */
+/* NetHack 3.6 minion.c        $NHDT-Date: 1544998886 2018/12/16 22:21:26 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.40 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2008. */
 /* 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-2019            */
 /* JNetHack may be freely redistributed.  See license for details. */
 
 #include "hack.h"
@@ -66,7 +66,10 @@ struct monst *mon;
 
         if (uwep && uwep->oartifact == ART_DEMONBANE && is_demon(ptr)) {
             if (canseemon(mon))
+/*JP
                 pline("%s looks puzzled for a moment.", Monnam(mon));
+*/
+                pline("%s\82Í\8f­\82µ\8d¢\98f\82µ\82Ä\82¢\82é\82æ\82¤\82¾\81D", Monnam(mon));
             return 0;
         }
 
@@ -148,6 +151,8 @@ struct monst *mon;
                 EMIN(mtmp)->renegade =
                     (atyp != u.ualign.type) ^ !mtmp->mpeaceful;
             }
+            if (is_demon(ptr) && canseemon(mtmp))
+                pline("%s appears in a cloud of smoke!", Amonnam(mtmp));
         }
         cnt--;
     }
@@ -272,7 +277,7 @@ register struct monst *mtmp;
         newsym(mtmp->mx, mtmp->my);
     }
     if (youmonst.data->mlet == S_DEMON) { /* Won't blackmail their own. */
-#if 0 /*JP*/
+#if 0 /*JP:T*/
         pline("%s says, \"Good hunting, %s.\"", Amonnam(mtmp),
               flags.female ? "Sister" : "Brother");
 #else
@@ -281,7 +286,7 @@ register struct monst *mtmp;
 #endif
         if (!tele_restrict(mtmp))
             (void) rloc(mtmp, TRUE);
-        return (1);
+        return 1;
     }
     cash = money_cnt(invent);
     demand =
@@ -299,7 +304,7 @@ register struct monst *mtmp;
         if (mon_has_amulet(mtmp))
             demand = cash + (long) rn1(1000, 40);
 
-#if 0 /*JP*/
+#if 0 /*JP:T*/
         pline("%s demands %ld %s for safe passage.", Amonnam(mtmp), demand,
               currency(demand));
 #else
@@ -331,7 +336,7 @@ register struct monst *mtmp;
         }
     }
     mongone(mtmp);
-    return (1);
+    return 1;
 }
 
 long
@@ -377,7 +382,7 @@ struct monst *mtmp;
     }
     (void) money2mon(mtmp, offer);
     context.botl = 1;
-    return (offer);
+    return offer;
 }
 
 int
@@ -390,9 +395,9 @@ aligntyp atyp;
         pm = rn1(PM_DEMOGORGON + 1 - PM_ORCUS, PM_ORCUS);
         if (!(mvitals[pm].mvflags & G_GONE)
             && (atyp == A_NONE || sgn(mons[pm].maligntyp) == sgn(atyp)))
-            return (pm);
+            return pm;
     }
-    return (dlord(atyp)); /* approximate */
+    return dlord(atyp); /* approximate */
 }
 
 int
@@ -405,9 +410,9 @@ aligntyp atyp;
         pm = rn1(PM_YEENOGHU + 1 - PM_JUIBLEX, PM_JUIBLEX);
         if (!(mvitals[pm].mvflags & G_GONE)
             && (atyp == A_NONE || sgn(mons[pm].maligntyp) == sgn(atyp)))
-            return (pm);
+            return pm;
     }
-    return (ndemon(atyp)); /* approximate */
+    return ndemon(atyp); /* approximate */
 }
 
 /* create lawful (good) lord */
@@ -415,9 +420,9 @@ int
 llord()
 {
     if (!(mvitals[PM_ARCHON].mvflags & G_GONE))
-        return (PM_ARCHON);
+        return PM_ARCHON;
 
-    return (lminion()); /* approximate */
+    return lminion(); /* approximate */
 }
 
 int
@@ -429,7 +434,7 @@ lminion()
     for (tryct = 0; tryct < 20; tryct++) {
         ptr = mkclass(S_ANGEL, 0);
         if (ptr && !is_lord(ptr))
-            return (monsndx(ptr));
+            return monsndx(ptr);
     }
 
     return NON_PM;
@@ -437,19 +442,26 @@ lminion()
 
 int
 ndemon(atyp)
-aligntyp atyp;
+aligntyp atyp; /* A_NONE is used for 'any alignment' */
 {
-    int tryct;
     struct permonst *ptr;
 
-    for (tryct = 0; tryct < 20; tryct++) {
-        ptr = mkclass(S_DEMON, 0);
-        if (ptr && is_ndemon(ptr)
-            && (atyp == A_NONE || sgn(ptr->maligntyp) == sgn(atyp)))
-            return (monsndx(ptr));
-    }
-
-    return NON_PM;
+    /*
+     * 3.6.2:  [fix #H2204, 22-Dec-2010, eight years later...]
+     * pick a correctly aligned demon in one try.  This used to
+     * use mkclass() to choose a random demon type and keep trying
+     * (up to 20 times) until it got one with the desired alignment.
+     * mkclass_aligned() skips wrongly aligned potential candidates.
+     * [The only neutral demons are djinni and mail daemon and
+     * mkclass() won't pick them, but call it anyway in case either
+     * aspect of that changes someday.]
+     */
+#if 0
+    if (atyp == A_NEUTRAL)
+        return NON_PM;
+#endif
+    ptr = mkclass_aligned(S_DEMON, 0, atyp);
+    return (ptr && is_ndemon(ptr)) ? monsndx(ptr) : NON_PM;
 }
 
 /* guardian angel has been affected by conflict so is abandoning hero */