From: PatR Date: Thu, 6 May 2021 19:36:32 +0000 (-0700) Subject: fix github issue #493 - hero item knowledge X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ad7f2afef9907ef6e52a17dd446b44d1dc774dbe;p=nethack fix github issue #493 - hero item knowledge 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 --- diff --git a/doc/fixes37.0 b/doc/fixes37.0 index fe805db69..9908c1cc3 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -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 diff --git a/include/extern.h b/include/extern.h index fb167cb17..515954004 100644 --- a/include/extern.h +++ b/include/extern.h @@ -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 *); diff --git a/src/invent.c b/src/invent.c index 4da50ea8d..5b9358dad 100644 --- a/src/invent.c +++ b/src/invent.c @@ -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: */ diff --git a/src/mthrowu.c b/src/mthrowu.c index 9b50fb1da..827f661f4 100644 --- a/src/mthrowu.c +++ b/src/mthrowu.c @@ -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) diff --git a/src/muse.c b/src/muse.c index a4eea23cb..58bbf75cd 100644 --- a/src/muse.c +++ b/src/muse.c @@ -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); diff --git a/src/steal.c b/src/steal.c index b4427ee78..0094fe420 100644 --- a/src/steal.c +++ b/src/steal.c @@ -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],