]> granicus.if.org Git - nethack/commitdiff
fix github issue #493 - hero item knowledge
authorPatR <rankin@nethack.org>
Thu, 6 May 2021 19:36:32 +0000 (12:36 -0700)
committerPatR <rankin@nethack.org>
Thu, 6 May 2021 19:36:32 +0000 (12:36 -0700)
Issue was about being asked what to call a previously seen potion
which has been picked up and thrown by an unseen monster.  Hero
shouldn't remember what the item description was.  This is a much
more general change than just fixing that.  Any item picked up by
an unseen non-tame monster will have all its *known flags cleared
since the hero can't see what that monster does to it.  Same if an
item is picked up while seen but then used when unseen.

Unseen pets are excluded from the pick up case--but not the use
case--because they pick up and drop stuff continually and players
would just slaughter them if they caused item information to be
forgotten.

Fixes #493

doc/fixes37.0
include/extern.h
src/invent.c
src/mthrowu.c
src/muse.c
src/steal.c

index fe805db692a3df0e07071228a4c4d0e7636cf0a4..9908c1cc335e5e6e9a5f63a952dd8417169d6a9c 100644 (file)
@@ -1,4 +1,4 @@
-NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.524 $ $NHDT-Date: 1620326528 2021/05/06 18:42:08 $
+NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.525 $ $NHDT-Date: 1620329775 2021/05/06 19:36:15 $
 
 General Fixes and Modified Features
 -----------------------------------
@@ -499,6 +499,9 @@ Entering a special room, only wake up the monsters in that room instead of
        doing a level-wide wake-up
 any blessed key was behaving as if was the rogue's Master Key when unlocking
        a trapped chest or box
+when an unseen non-pet picks up or uses an item, hero loses known/dknown/
+       bknown/cknown/lknown memory of that item (so becomes unidentified; in
+       particular, player won't be asked what to call unseen thrown potion)
 
 
 Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
index fb167cb1706203ab4e65e062882ef7322ab1ad81..515954004940c64ad6e1b6989cb2a39e3c096549 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 extern.h        $NHDT-Date: 1611445282 2021/01/23 23:41:22 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.947 $ */
+/* NetHack 3.7 extern.h        $NHDT-Date: 1620329773 2021/05/06 19:36:13 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.968 $ */
 /* Copyright (c) Steve Creps, 1988.                              */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1013,6 +1013,7 @@ extern int ggetobj(const char *, int(*)(struct obj *), int, boolean,
                    unsigned *);
 extern int askchain(struct obj **, const char *, int, int(*)(struct obj *),
                     int(*)(struct obj *), int, const char *);
+extern void unknow_object(struct obj *);
 extern void set_cknown_lknown(struct obj *);
 extern void fully_identify_obj(struct obj *);
 extern int identify(struct obj *);
index 4da50ea8dd26cb384a613ee551f9694801c4bc79..5b9358dad4391a17e1fbe4c5a03c9267cadce4e8 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 invent.c        $NHDT-Date: 1615794750 2021/03/15 07:52:30 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.324 $ */
+/* NetHack 3.7 invent.c        $NHDT-Date: 1620329776 2021/05/06 19:36:16 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.330 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Derek S. Ray, 2015. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -2150,6 +2150,19 @@ askchain(struct obj **objchn, /* *objchn might change */
     return cnt;
 }
 
+/* hero is losing access to previously known info about an object
+   (called when an unseen monster picks up or uses the object) */
+void
+unknow_object(struct obj *obj)
+{
+    obj->dknown = 0;
+    obj->bknown = obj->rknown = 0;
+    obj->cknown = obj->lknown = 0;
+    /* awareness of charges or enchantment has gone poof... */
+    if (objects[obj->otyp].oc_uses_known)
+        obj->known = 0;
+}
+
 /*
  *      Object identification routines:
  */
index 9b50fb1da0d8676a46b128a0ee326b099d47acc9..827f661f4a64d5dc828c804cfcb963e92b7a564e 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 mthrowu.c       $NHDT-Date: 1613258169 2021/02/13 23:16:09 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.112 $ */
+/* NetHack 3.7 mthrowu.c       $NHDT-Date: 1620329778 2021/05/06 19:36:18 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.113 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Pasi Kallinen, 2016. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -292,6 +292,8 @@ ohitmon(
     g.notonhead = (g.bhitpos.x != mtmp->mx || g.bhitpos.y != mtmp->my);
     ismimic = M_AP_TYPE(mtmp) && M_AP_TYPE(mtmp) != M_AP_MONSTER;
     vis = cansee(g.bhitpos.x, g.bhitpos.y);
+    if (vis)
+        otmp->dknown = 1;
 
     tmp = 5 + find_mac(mtmp) + omon_adj(mtmp, otmp, FALSE);
     /* High level monsters will be more likely to hit */
@@ -318,8 +320,6 @@ ohitmon(
         if (ismimic)
             seemimic(mtmp);
         mtmp->msleeping = 0;
-        if (vis)
-            otmp->dknown = 1;
         /* probably thrown by a monster rather than 'other', but the
            distinction only matters when hitting the hero */
         potionhit(mtmp, otmp, POTHIT_OTHER_THROW);
@@ -504,6 +504,8 @@ m_throw(
     }
 
     singleobj->owornmask = 0; /* threw one of multiple weapons in hand? */
+    if (!canseemon(mon))
+        singleobj->dknown = 0;
 
     if ((singleobj->cursed || singleobj->greased) && (dx || dy) && !rn2(7)) {
         if (canseemon(mon) && flags.verbose) {
@@ -537,6 +539,9 @@ m_throw(
     while (range-- > 0) { /* Actually the loop is always exited by break */
         g.bhitpos.x += dx;
         g.bhitpos.y += dy;
+        if (cansee(g.bhitpos.x, g.bhitpos.y))
+            singleobj->dknown = 1;
+
         mtmp = m_at(g.bhitpos.x, g.bhitpos.y);
         if (mtmp && shade_miss(mon, mtmp, singleobj, TRUE, TRUE)) {
             /* if mtmp is a shade and missile passes harmlessly through it,
@@ -570,11 +575,10 @@ m_throw(
                 break;
             }
             if (singleobj->oclass == POTION_CLASS) {
-                if (!Blind)
-                    singleobj->dknown = 1;
                 potionhit(&g.youmonst, singleobj, POTHIT_MONST_THROW);
                 break;
             }
+
             oldumort = u.umortality;
             switch (singleobj->otyp) {
                 int dam, hitv;
@@ -585,7 +589,7 @@ m_throw(
                     hitu = 0;
                     break;
                 }
-            /* fall through */
+                /*FALLTHRU*/
             case CREAM_PIE:
             case BLINDING_VENOM:
                 hitu = thitu(8, 0, &singleobj, (char *) 0);
@@ -657,6 +661,7 @@ m_throw(
                 break;
             }
         }
+
         if (!range || MT_FLIGHTCHECK(FALSE)) { /* end of path or blocked */
             if (singleobj) { /* hits_bars might have destroyed it */
                 /* note: pline(The(missile)) rather than pline_The(missile)
index a4eea23cb38d0476e991adfc1281272ef5dc0ad3..58bbf75cd884f7226f0fb237ff16f2b7ecf684c1 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 muse.c  $NHDT-Date: 1607734843 2020/12/12 01:00:43 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.136 $ */
+/* NetHack 3.7 muse.c  $NHDT-Date: 1620329779 2021/05/06 19:36:19 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.143 $ */
 /*      Copyright (C) 1990 by Ken Arromdee                         */
 /* NetHack may be freely redistributed.  See license for details.  */
 
@@ -163,7 +163,7 @@ mzapwand(
 
         You_hear("a %s zap.", (distu(mtmp->mx, mtmp->my) <= range * range)
                                  ? "nearby" : "distant");
-        otmp->known = 0;
+        unknow_object(otmp); /* hero loses info when unseen obj is used */
     } else if (self) {
         pline("%s with %s!",
               monverbself(mtmp, Monnam(mtmp), "zap", (char *) 0),
@@ -191,7 +191,7 @@ mplayhorn(
         You_hear("a horn being played %s.",
                  (distu(mtmp->mx, mtmp->my) <= range * range)
                  ? "nearby" : "in the distance");
-        otmp->known = 0; /* hero doesn't know how many charges are left */
+        unknow_object(otmp); /* hero loses info when unseen obj is used */
     } else if (self) {
         otmp->dknown = 1;
         objnamp = xname(otmp);
index b4427ee78b9fa52a07331a24b8ed8238544ee6b0..0094fe4208cbd6fe662f18d8af92cab7473e65dd 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 steal.c $NHDT-Date: 1596498213 2020/08/03 23:43:33 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.84 $ */
+/* NetHack 3.7 steal.c $NHDT-Date: 1620329782 2021/05/06 19:36:22 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.90 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2012. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -527,6 +527,11 @@ mpickobj(register struct monst* mtmp, register struct obj* otmp)
        and if it's eventually dropped in a shop, shk will claim it */
     if (!mtmp->mtame)
         otmp->no_charge = 0;
+    /* if monster is unseen, info hero knows about this object becomes lost;
+       continual pickup and drop by pets makes this too annoying if it is
+       applied to them */
+    if (!mtmp->mtame && !canseemon(mtmp))
+        unknow_object(otmp);
     /* Must do carrying effects on object prior to add_to_minv() */
     carry_obj_effects(otmp);
     /* add_to_minv() might free otmp [if merged with something else],