]> granicus.if.org Git - nethack/commitdiff
probing vs Schroedinger's Cat (trunk only)
authornethack.rankin <nethack.rankin>
Sun, 18 Feb 2007 02:20:59 +0000 (02:20 +0000)
committernethack.rankin <nethack.rankin>
Sun, 18 Feb 2007 02:20:59 +0000 (02:20 +0000)
     Someone in the newsgroup complained about zapping probing at a large
box dropped by a quantum mechanic and being told that it was empty rather
than that it held a corpse or live cat.  This sidesteps the issue by
reporting "the box seems empty" instead of "the box is empty", and not
setting its contents-known flag.  (That message is the main difference
between probing and the assorted other methods of observation [telepathy
and monster detection and possibly Warning for live cat, object detection
and food detection for dead cat's corpse] which might be expected to
trigger the cat's fate but don't.)  This also makes probing of self and
of monsters set the contents-known and locking-known flags for containers
in inventory, same as is done for probing which hits objects.  (Display of
container contents still only occurs for loose objects, not in inventory.)

include/obj.h
src/end.c
src/mkobj.c
src/pickup.c
src/zap.c

index 180771d3cc940083bfcfd87b5ec88c65e603ce3b..2757b53fef1764e138c7f0224dbade04b1ec0bbf 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)obj.h      3.5     2006/12/14      */
+/*     SCCS Id: @(#)obj.h      3.5     2007/02/17      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -242,6 +242,7 @@ struct obj {
 #define Is_box(otmp)   (otmp->otyp == LARGE_BOX || otmp->otyp == CHEST)
 #define Is_mbag(otmp)  (otmp->otyp == BAG_OF_HOLDING || \
                         otmp->otyp == BAG_OF_TRICKS)
+#define SchroedingersBox(o)    ((o)->otyp == LARGE_BOX && (o)->spe == 1)
 
 /* dragon gear */
 #define Is_dragon_scales(obj)  ((obj)->otyp >= GRAY_DRAGON_SCALES && \
index 0bc1e0114ff52b454896629ef7a4378d9fd161b1..80b1b5cac8f989325c23a300a52fdf3f63ae440b 100644 (file)
--- a/src/end.c
+++ b/src/end.c
@@ -515,7 +515,7 @@ int what;
        switch(what) {
                case CAT_CHECK:                  /* Schroedinger's Cat */
                        /* Ascending is deterministic */
-                       if (otmp->otyp == LARGE_BOX && otmp->spe == 1)
+                       if (SchroedingersBox(otmp))
                                return rn2(2);
                        break;
        }
@@ -972,8 +972,7 @@ boolean identified, all_containers, reportempty;
                box->cknown = 1;        /* we're looking at the contents now */
                if (identified) box->lknown = 1;
                cat = deadcat = FALSE;
-               if (box->otyp == LARGE_BOX &&
-                   box->spe == 1 && !Schroedingers_cat) {
+               if (SchroedingersBox(box) && !Schroedingers_cat) {
                        /* Schroedinger's Cat? */
                        cat = odds_and_ends(box, CAT_CHECK);
                        if (cat) Schroedingers_cat = TRUE;
index 7bc7e39477e52ec537a76e2269964a5d08541c81..647222b96841f0a418479ed25ca4ee5b51727870 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)mkobj.c    3.5     2007/01/02      */
+/*     SCCS Id: @(#)mkobj.c    3.5     2007/02/17      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1082,7 +1082,7 @@ register struct obj *obj;
 {
        int wt = objects[obj->otyp].oc_weight;
 
-       if (obj->otyp == LARGE_BOX && obj->spe == 1) /* Schroedinger's Cat */
+       if (SchroedingersBox(obj))
                wt += mons[PM_HOUSECAT].cwt;
        if (Is_container(obj) || obj->otyp == STATUE) {
                struct obj *contents;
index b67a2de1c1e4166f08346e130d9fff0d3d5f6d99..6a4c3f4e3f3fcbaebc68e879303117c21db3ec05 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)pickup.c   3.5     2007/01/02      */
+/*     SCCS Id: @(#)pickup.c   3.5     2007/02/17      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -2166,7 +2166,7 @@ int held;
        /* from here on out, all early returns go through containerdone */
 
        /* check for Schroedinger's Cat */
-       quantum_cat = (current_container->spe == 1); /* "it's _now_ empty" */
+       quantum_cat = SchroedingersBox(current_container);
        if (quantum_cat) {
            observe_quantum_cat(current_container);
            used = 1;
@@ -2706,7 +2706,7 @@ struct obj *box;  /* or bag */
        }
        if (maybeshopgoods && !box->no_charge)
            subfrombill(box, shop_keeper(*in_rooms(ox, oy, SHOPBASE)));
-    } else if (box->spe) {
+    } else if (SchroedingersBox(box)) {
        char yourbuf[BUFSZ];
 
        observe_quantum_cat(box);
index e56f582a11efb0f6528129c52c03a85c6d9c47d5..7b2065a3c8d71c222c4b8f5681cd91f3636f2d9f 100644 (file)
--- a/src/zap.c
+++ b/src/zap.c
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)zap.c      3.5     2007/01/27      */
+/*     SCCS Id: @(#)zap.c      3.5     2007/02/17      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -434,9 +434,14 @@ struct monst *mtmp;
 #else
        if (mtmp->minvent) {
 #endif
-           for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj)
+           for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj) {
                otmp->dknown = 1;       /* treat as "seen" */
-           (void) display_minventory(mtmp, MINV_ALL, (char *)0);
+               if (Is_container(otmp) || otmp->otyp == STATUE) {
+                   otmp->lknown = 1;
+                   if (!SchroedingersBox(otmp)) otmp->cknown = 1;
+               }
+           }
+           (void) display_minventory(mtmp, MINV_ALL|MINV_NOLET, (char *)0);
        } else {
            pline("%s is not carrying anything.", noit_Monnam(mtmp));
        }
@@ -1614,9 +1619,16 @@ struct obj *obj, *otmp;
                obj->dknown = 1;
                if (Is_container(obj) || obj->otyp == STATUE) {
                    obj->cknown = obj->lknown = 1;
-                   if (!obj->cobj)
-                       pline("%s empty.", Tobjnam(obj, "are"));
-                   else {
+                   if (!obj->cobj) {
+                       boolean catbox = SchroedingersBox(obj);
+
+                       /* we don't want to force alive vs dead
+                          determination for Schroedinger's Cat here,
+                          so just make probing be inconclusive for it */
+                       if (catbox) obj->cknown = 0;
+                       pline("%s empty.",
+                             Tobjnam(obj, catbox ? "seem" : "are"));
+                   } else {
                        struct obj *o;
                        /* view contents (not recursively) */
                        for (o = obj->cobj; o; o = o->nobj)
@@ -2243,8 +2255,13 @@ boolean ordinary;
                  {
                    struct obj *otmp;
 
-                   for (otmp = invent; otmp; otmp = otmp->nobj)
+                   for (otmp = invent; otmp; otmp = otmp->nobj) {
                        otmp->dknown = 1;
+                       if (Is_container(otmp) || otmp->otyp == STATUE) {
+                           otmp->lknown = 1;
+                           if (!SchroedingersBox(otmp)) otmp->cknown = 1;
+                       }
+                   }
                    learn_it = TRUE;
                    ustatusline();
                    break;