more artifact tracking

Move some code that was used to decide whether to call distant_name
or doname into distant_name so that the places which were doing that
don't need to anymore and fewer places can care about whether an
artifact is being found.  There were two or three instances of
distant_name maybe being called, based on distance from hero, and
yesterday's artifact livelog change added two or three more and made
all of them override the distance limit for artifacts.

After that change to distant_name, make sure that conditional calls
to it become unconditional--just not displayed for the cases where
!flags.verbose had been excluding them.  That way distant_name can
decide whether an item is up close and arrange for xname to find it
if it as an artifact.

Also, implement an old TODO.  Wearing the Eyes of the Overworld
extends the distance that an item can be from the hero and still be
considered near anough to be seen "up close" when monsters pick it
up or drop it.  The explicit cases were using distu(x,y) <= 5, the
distance of a knight's jump.  Each quadrant around the hero is a 2x2
square with the diagonal corner chopped off.  The replacement code in
distant_name calculates a value of 6, which is functionally equivalent
since the next value of interest beyond 5 is 8.  Wearing the Eyes
(deduced by having Xray vision) extends that threshold an extra step
in addition to overriding blindness and seeing through walls:  15,
a 3x3 square in each quadrant, still with the far diagonal corner (16)
treated as out of range.
This commit is contained in:
PatR
2022-03-07 13:21:17 -08:00
parent cceef37c8b
commit 809232914e
9 changed files with 151 additions and 106 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 steal.c $NHDT-Date: 1646652771 2022/03/07 11:32:51 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.97 $ */
/* NetHack 3.7 steal.c $NHDT-Date: 1646688070 2022/03/07 21:21:10 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.98 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
@@ -678,14 +678,9 @@ mdrop_obj(
{
int omx = mon->mx, omy = mon->my;
long unwornmask = obj->owornmask;
/* if an artifact, find dropped item 'carried by a monster' rather
than later finding it on the floor, even if not very close to the
drop and even if the monster itself can't be seen */
if (obj->oartifact && cansee(omx, omy)) {
obj->dknown = 1;
find_artifact(obj);
}
/* call distant_name() for its possible side-effects even if the result
might not be printed, and do it before extracing obj from minvent */
char *obj_name = distant_name(obj, doname);
extract_from_minvent(mon, obj, FALSE, TRUE);
/* don't charge for an owned saddle on dead steed (provided
@@ -698,7 +693,7 @@ mdrop_obj(
}
/* obj_no_longer_held(obj); -- done by place_object */
if (verbosely && cansee(omx, omy))
pline("%s drops %s.", Monnam(mon), distant_name(obj, doname));
pline("%s drops %s.", Monnam(mon), obj_name);
if (!flooreffects(obj, omx, omy, "fall")) {
place_object(obj, omx, omy);
stackobj(obj);