]> granicus.if.org Git - nethack/commitdiff
fix #K119 - wishing for Amulet of Yendor
authorPatR <rankin@nethack.org>
Tue, 7 Jan 2020 10:59:25 +0000 (02:59 -0800)
committerPatR <rankin@nethack.org>
Tue, 7 Jan 2020 10:59:25 +0000 (02:59 -0800)
Wizard mode wishing for "Amulet of Yendor" has a 50% chance of
yielding a cheap plastic imitation.  Allow asking for "real Amulet
of Yendor" and "fake Amulet of Yendor" to provide precise control.
Asking for "real Amulet of Yendor" in normal play will be accepted
but then overridden with the fake amulet as usual.

Without the prefix, there's still a 50:50 chance for either amulet.
"real fake amulet of yendor" and "fake real amulet of yendor" both
yield a fake one.

When handling "amulet of yendor", any of "cheap", "plastic",
"imitation", "cheap plastic", "cheap imitation", and "plastic
imitation" are now recognized to mean "cheap plastic imitation".
Unlike prefixes such as "blessed rustproof" vs "rustproof blessed",
these two-word ones (or the three-word whole thing) need to be in
specific order and after the general prefixes.  Also, any of those
force "fake" even if an explicit "real" prefix came before them.

doc/fixes37.0
src/objnam.c

index 9f1b11c21bdef31c87e8c5d899b8075f37436708..296007d4faf8a1966d416845f203b1bad9e4027d 100644 (file)
@@ -1,4 +1,4 @@
-$NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.54 $ $NHDT-Date: 1578297243 2020/01/06 07:54:03 $
+$NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.55 $ $NHDT-Date: 1578394755 2020/01/07 10:59:15 $
 
 General Fixes and Modified Features
 -----------------------------------
@@ -32,6 +32,9 @@ drum of earthquake feedback reported various things (fountains, thrones, &c)
        falling into a chasm but they remained intact because trap creation
        had been changed to not clobber such things (so couldn't make pits)
 make earthquake which hits a secret door or a secret corridor reveal it
+wizard mode wishing for "Amulet of Yendor" has 50:50 chance for true Amulet
+       or a cheap plastic imitation; recognize "real Amulet of Yendor" and
+       "fake Amulet of Yendor" to precisely specify either of them
 
 
 Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
index df23fb57da6a906a14bc6dc215d50c190afc6b3b..05a8958ad3e66d1bef6b2de1b726c5fd7ce92df3 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 objnam.c        $NHDT-Date: 1578258724 2020/01/05 21:12:04 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.280 $ */
+/* NetHack 3.7 objnam.c        $NHDT-Date: 1578394756 2020/01/07 10:59:16 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.281 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2011. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -2962,7 +2962,7 @@ struct obj *no_wish;
     register struct obj *otmp;
     int cnt, spe, spesgn, typ, very, rechrg;
     int blessed, uncursed, iscursed, ispoisoned, isgreased;
-    int eroded, eroded2, erodeproof, locked, unlocked, broken;
+    int eroded, eroded2, erodeproof, locked, unlocked, broken, real, fake;
     int halfeaten, mntmp, contents;
     int islit, unlabeled, ishistoric, isdiluted, trapped;
     int tmp, tinv, tvariety;
@@ -2970,7 +2970,7 @@ struct obj *no_wish;
     struct fruit *f;
     int ftype = g.context.current_fruit;
     char fruitbuf[BUFSZ], globbuf[BUFSZ];
-    /* Fruits may not mess up the ability to wish for real objects (since
+    /* Fruits must not mess up the ability to wish for real objects (since
      * you can leave a fruit in a bones file and it will be added to
      * another person's game), so they must be checked for last, after
      * stripping all the possible prefixes and seeing if there's a real
@@ -2992,7 +2992,7 @@ struct obj *no_wish;
     very = rechrg = blessed = uncursed = iscursed = ispoisoned =
         isgreased = eroded = eroded2 = erodeproof = halfeaten =
         islit = unlabeled = ishistoric = isdiluted = trapped =
-        locked = unlocked = broken = 0;
+        locked = unlocked = broken = real = fake = 0;
     tvariety = RANDOM_TIN;
     mntmp = NON_PM;
 #define UNDEFINED 0
@@ -3135,6 +3135,15 @@ struct obj *no_wish;
                 break;
             /* "very large " had "very " peeled off on previous iteration */
             gsize = (very != 1) ? 3 : 4;
+        } else if (!strncmpi(bp, "real ", l = 5)) {
+            /* accept "real Amulet of Yendor" with "blessed" or "cursed"
+               or useless "erodeproof" before or after "real" ... */
+            real = 1; /* don't negate 'fake' here; "real fake amulet" and
+                       * "fake real amulet" will both yield fake amulet
+                       * (so will "real amulet" outside of wizard mode) */
+        } else if (!strncmpi(bp, "fake ", l = 5)) {
+            /* ... and "fake Amulet of Yendor" likewise */
+            fake = 1; /* doesn't matter whether 'real' is negated here */
         } else
             break;
         bp += l;
@@ -3231,6 +3240,33 @@ struct obj *no_wish;
         *p = 0;
         contents = SPINACH;
     }
+    /* this is only useful for wizard mode but we'll accept its parsing
+       in normal play (result is never the real Amulet for that case) */
+    if ((p = strstri(bp, OBJ_DESCR(objects[AMULET_OF_YENDOR]))) != 0
+        && (p == bp || p[-1] == ' ')) {
+        char *s = bp;
+
+        /* "Amulet of Yendor" matches two items; disambiguate via "real"
+           or "fake" prefix (parsed above so that both "blessed real"
+           and "real blessed" work); also accept partial specification of
+           the full name of the fake; unlike the prefix recognition loop
+           above, these have to be in the right order when more than one
+           is present (similar to glass gems below) */
+        if (!strncmpi(s, "cheap ", 6))
+            fake = 1, s += 6;
+        if (!strncmpi(s, "plastic ", 8))
+            fake = 1, s += 8;
+        if (!strncmpi(s, "imitation ", 10))
+            fake = 1, s += 10;
+        nhUse(s); /* suppress potential assigned-but-not-used complaint */
+        /* '(!real && !fake)' is the default, so 50:50 chance for either */
+        if (real && fake)
+            real = 0;
+        else if (!real && !fake && !rn2(2))
+            real = 1;
+        typ = real ? AMULET_OF_YENDOR : FAKE_AMULET_OF_YENDOR;
+        goto typfnd;
+    }
 
     /*
      * Skip over "pair of ", "pairs of", "set of" and "sets of".