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:
+19
-10
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.7 artifact.c $NHDT-Date: 1646652747 2022/03/07 11:32:27 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.180 $ */
|
/* NetHack 3.7 artifact.c $NHDT-Date: 1646688062 2022/03/07 21:21:02 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.181 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/*-Copyright (c) Robert Patrick Rankin, 2013. */
|
/*-Copyright (c) Robert Patrick Rankin, 2013. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
@@ -285,7 +285,7 @@ artifact_exists(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make an artifact as 'found' */
|
/* mark an artifact as 'found' */
|
||||||
void
|
void
|
||||||
found_artifact(int a)
|
found_artifact(int a)
|
||||||
{
|
{
|
||||||
@@ -1427,13 +1427,16 @@ artifact_hit(struct monst *magr, struct monst *mdef, struct obj *otmp,
|
|||||||
drain = (mhpmax > m_lev) ? (mhpmax - (m_lev + 1)) : 0;
|
drain = (mhpmax > m_lev) ? (mhpmax - (m_lev + 1)) : 0;
|
||||||
|
|
||||||
if (vis) {
|
if (vis) {
|
||||||
|
/* call distant_name() for possible side-effects even if
|
||||||
|
the result won't be printed */
|
||||||
|
char *otmpname = distant_name(otmp, xname);
|
||||||
|
|
||||||
if (otmp->oartifact == ART_STORMBRINGER)
|
if (otmp->oartifact == ART_STORMBRINGER)
|
||||||
pline_The("%s blade draws the %s from %s!",
|
pline_The("%s blade draws the %s from %s!",
|
||||||
hcolor(NH_BLACK), life, mon_nam(mdef));
|
hcolor(NH_BLACK), life, mon_nam(mdef));
|
||||||
else
|
else
|
||||||
pline("%s draws the %s from %s!",
|
pline("%s draws the %s from %s!",
|
||||||
The(distant_name(otmp, xname)), life,
|
The(otmpname), life, mon_nam(mdef));
|
||||||
mon_nam(mdef));
|
|
||||||
}
|
}
|
||||||
if (mdef->m_lev == 0) {
|
if (mdef->m_lev == 0) {
|
||||||
/* losing a level when at 0 is fatal */
|
/* losing a level when at 0 is fatal */
|
||||||
@@ -1459,17 +1462,23 @@ artifact_hit(struct monst *magr, struct monst *mdef, struct obj *otmp,
|
|||||||
} else { /* youdefend */
|
} else { /* youdefend */
|
||||||
int oldhpmax = u.uhpmax;
|
int oldhpmax = u.uhpmax;
|
||||||
|
|
||||||
if (Blind)
|
if (Blind) {
|
||||||
You_feel("an %s drain your %s!",
|
You_feel("an %s drain your %s!",
|
||||||
(otmp->oartifact == ART_STORMBRINGER)
|
(otmp->oartifact == ART_STORMBRINGER)
|
||||||
? "unholy blade"
|
? "unholy blade"
|
||||||
: "object",
|
: "object",
|
||||||
life);
|
life);
|
||||||
else if (otmp->oartifact == ART_STORMBRINGER)
|
} else {
|
||||||
pline_The("%s blade drains your %s!", hcolor(NH_BLACK), life);
|
/* call distant_name() for possible side-effects even if
|
||||||
else
|
the result won't be printed */
|
||||||
pline("%s drains your %s!", The(distant_name(otmp, xname)),
|
char *otmpname = distant_name(otmp, xname);
|
||||||
life);
|
|
||||||
|
if (otmp->oartifact == ART_STORMBRINGER)
|
||||||
|
pline_The("%s blade drains your %s!",
|
||||||
|
hcolor(NH_BLACK), life);
|
||||||
|
else
|
||||||
|
pline("%s drains your %s!", The(otmpname), life);
|
||||||
|
}
|
||||||
losexp("life drainage");
|
losexp("life drainage");
|
||||||
if (magr && magr->mhp < magr->mhpmax) {
|
if (magr && magr->mhp < magr->mhpmax) {
|
||||||
magr->mhp += (oldhpmax - u.uhpmax + 1) / 2;
|
magr->mhp += (oldhpmax - u.uhpmax + 1) / 2;
|
||||||
|
|||||||
+25
-18
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.7 dogmove.c $NHDT-Date: 1646652766 2022/03/07 11:32:46 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.111 $ */
|
/* NetHack 3.7 dogmove.c $NHDT-Date: 1646688063 2022/03/07 21:21:03 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.112 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/*-Copyright (c) Robert Patrick Rankin, 2012. */
|
/*-Copyright (c) Robert Patrick Rankin, 2012. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
@@ -222,7 +222,7 @@ dog_eat(struct monst *mtmp,
|
|||||||
boolean poly, grow, heal, eyes, slimer, deadmimic;
|
boolean poly, grow, heal, eyes, slimer, deadmimic;
|
||||||
int nutrit, res, corpsenm;
|
int nutrit, res, corpsenm;
|
||||||
long oprice;
|
long oprice;
|
||||||
char objnambuf[BUFSZ];
|
char objnambuf[BUFSZ], *obj_name;
|
||||||
|
|
||||||
objnambuf[0] = '\0';
|
objnambuf[0] = '\0';
|
||||||
if (edog->hungrytime < g.moves)
|
if (edog->hungrytime < g.moves)
|
||||||
@@ -288,14 +288,18 @@ dog_eat(struct monst *mtmp,
|
|||||||
pet as "it". However, we want "it" if invisible/unsensed
|
pet as "it". However, we want "it" if invisible/unsensed
|
||||||
pet eats visible food. */
|
pet eats visible food. */
|
||||||
if (sawpet || (seeobj && canspotmon(mtmp))) {
|
if (sawpet || (seeobj && canspotmon(mtmp))) {
|
||||||
|
/* call distant_name() for possible side-effects even if the
|
||||||
|
result won't be printed */
|
||||||
|
obj_name = distant_name(obj, doname);
|
||||||
if (tunnels(mtmp->data))
|
if (tunnels(mtmp->data))
|
||||||
pline("%s digs in.", noit_Monnam(mtmp));
|
pline("%s digs in.", noit_Monnam(mtmp));
|
||||||
else
|
else
|
||||||
pline("%s %s %s.", noit_Monnam(mtmp),
|
pline("%s %s %s.", noit_Monnam(mtmp),
|
||||||
devour ? "devours" : "eats", distant_name(obj, doname));
|
devour ? "devours" : "eats", obj_name);
|
||||||
} else if (seeobj)
|
} else if (seeobj) {
|
||||||
pline("It %s %s.", devour ? "devours" : "eats",
|
obj_name = distant_name(obj, doname);
|
||||||
distant_name(obj, doname));
|
pline("It %s %s.", devour ? "devours" : "eats", obj_name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (obj->unpaid) {
|
if (obj->unpaid) {
|
||||||
Strcpy(objnambuf, xname(obj));
|
Strcpy(objnambuf, xname(obj));
|
||||||
@@ -316,9 +320,11 @@ dog_eat(struct monst *mtmp,
|
|||||||
costly_alteration(obj, COST_DEGRD);
|
costly_alteration(obj, COST_DEGRD);
|
||||||
obj->oerodeproof = 0;
|
obj->oerodeproof = 0;
|
||||||
mtmp->mstun = 1;
|
mtmp->mstun = 1;
|
||||||
if (canseemon(mtmp) && flags.verbose) {
|
if (canseemon(mtmp)) {
|
||||||
pline("%s spits %s out in disgust!", Monnam(mtmp),
|
obj_name = distant_name(obj, doname); /* (see above) */
|
||||||
distant_name(obj, doname));
|
if (flags.verbose)
|
||||||
|
pline("%s spits %s out in disgust!",
|
||||||
|
Monnam(mtmp), obj_name);
|
||||||
}
|
}
|
||||||
} else if (obj == uball) {
|
} else if (obj == uball) {
|
||||||
unpunish();
|
unpunish();
|
||||||
@@ -417,7 +423,7 @@ dog_hunger(struct monst *mtmp, struct edog *edog)
|
|||||||
static int
|
static int
|
||||||
dog_invent(struct monst *mtmp, struct edog *edog, int udist)
|
dog_invent(struct monst *mtmp, struct edog *edog, int udist)
|
||||||
{
|
{
|
||||||
register int omx, omy, carryamt = 0;
|
int omx, omy, carryamt = 0;
|
||||||
struct obj *obj, *otmp;
|
struct obj *obj, *otmp;
|
||||||
|
|
||||||
if (mtmp->msleeping || !mtmp->mcanmove)
|
if (mtmp->msleeping || !mtmp->mcanmove)
|
||||||
@@ -465,15 +471,16 @@ dog_invent(struct monst *mtmp, struct edog *edog, int udist)
|
|||||||
if (carryamt != obj->quan)
|
if (carryamt != obj->quan)
|
||||||
otmp = splitobj(obj, carryamt);
|
otmp = splitobj(obj, carryamt);
|
||||||
if (cansee(omx, omy)) {
|
if (cansee(omx, omy)) {
|
||||||
if (otmp->oartifact) {
|
/* call distant_name() for possible side-effects
|
||||||
otmp->dknown = 1; /* see mpickstuff() */
|
even if the result won't be printed; should be
|
||||||
find_artifact(otmp);
|
done before extract+pickup for distant_name()
|
||||||
}
|
-> doname() -> xname() -> find_artifact()
|
||||||
|
while otmp is still on floor */
|
||||||
|
char *otmpname = distant_name(otmp, doname);
|
||||||
|
|
||||||
if (flags.verbose)
|
if (flags.verbose)
|
||||||
pline("%s picks up %s.", Monnam(mtmp),
|
pline("%s picks up %s.",
|
||||||
((distu(omx, omy) <= 5)
|
Monnam(mtmp), otmpname);
|
||||||
? doname(otmp)
|
|
||||||
: distant_name(otmp, doname)));
|
|
||||||
}
|
}
|
||||||
obj_extract_self(otmp);
|
obj_extract_self(otmp);
|
||||||
newsym(omx, omy);
|
newsym(omx, omy);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.7 mon.c $NHDT-Date: 1646652768 2022/03/07 11:32:48 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.414 $ */
|
/* NetHack 3.7 mon.c $NHDT-Date: 1646688064 2022/03/07 21:21:04 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.415 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/*-Copyright (c) Derek S. Ray, 2015. */
|
/*-Copyright (c) Derek S. Ray, 2015. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
@@ -1097,10 +1097,11 @@ movemon(void)
|
|||||||
* has young and old forms).
|
* has young and old forms).
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
meatmetal(register struct monst* mtmp)
|
meatmetal(struct monst *mtmp)
|
||||||
{
|
{
|
||||||
register struct obj *otmp;
|
struct obj *otmp;
|
||||||
struct permonst *ptr;
|
struct permonst *ptr;
|
||||||
|
char *otmpname;
|
||||||
int poly, grow, heal, mstone, vis = canseemon(mtmp);
|
int poly, grow, heal, mstone, vis = canseemon(mtmp);
|
||||||
|
|
||||||
/* If a pet, eating is handled separately, in dog.c */
|
/* If a pet, eating is handled separately, in dog.c */
|
||||||
@@ -1118,24 +1119,33 @@ meatmetal(register struct monst* mtmp)
|
|||||||
if (is_metallic(otmp) && !obj_resists(otmp, 5, 95)
|
if (is_metallic(otmp) && !obj_resists(otmp, 5, 95)
|
||||||
&& touch_artifact(otmp, mtmp)) {
|
&& touch_artifact(otmp, mtmp)) {
|
||||||
if (mtmp->data == &mons[PM_RUST_MONSTER] && otmp->oerodeproof) {
|
if (mtmp->data == &mons[PM_RUST_MONSTER] && otmp->oerodeproof) {
|
||||||
if (vis && flags.verbose) {
|
if (vis) {
|
||||||
pline("%s eats %s!", Monnam(mtmp),
|
/* call distant_name() for its side-effects even when
|
||||||
distant_name(otmp, doname));
|
!verbose so won't be printed */
|
||||||
|
otmpname = distant_name(otmp, doname);
|
||||||
|
if (flags.verbose)
|
||||||
|
pline("%s eats %s!", Monnam(mtmp), otmpname);
|
||||||
}
|
}
|
||||||
/* The object's rustproofing is gone now */
|
/* The object's rustproofing is gone now */
|
||||||
otmp->oerodeproof = 0;
|
otmp->oerodeproof = 0;
|
||||||
mtmp->mstun = 1;
|
mtmp->mstun = 1;
|
||||||
if (vis && flags.verbose) {
|
if (vis) {
|
||||||
pline("%s spits %s out in disgust!", Monnam(mtmp),
|
/* (see above; format even if it won't be printed) */
|
||||||
distant_name(otmp, doname));
|
otmpname = distant_name(otmp, doname);
|
||||||
|
if (flags.verbose)
|
||||||
|
pline("%s spits %s out in disgust!",
|
||||||
|
Monnam(mtmp), otmpname);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* [should this be canseemon()?] */
|
if (cansee(mtmp->mx, mtmp->my)) {
|
||||||
if (cansee(mtmp->mx, mtmp->my) && flags.verbose)
|
/* (see above; format even if it won't be printed) */
|
||||||
pline("%s eats %s!", Monnam(mtmp),
|
otmpname = distant_name(otmp, doname);
|
||||||
distant_name(otmp, doname));
|
if (flags.verbose)
|
||||||
else if (flags.verbose)
|
pline("%s eats %s!", Monnam(mtmp), otmpname);
|
||||||
You_hear("a crunching sound.");
|
} else {
|
||||||
|
if (flags.verbose)
|
||||||
|
You_hear("a crunching sound.");
|
||||||
|
}
|
||||||
mtmp->meating = otmp->owt / 2 + 1;
|
mtmp->meating = otmp->owt / 2 + 1;
|
||||||
/* Heal up to the object's weight in hp */
|
/* Heal up to the object's weight in hp */
|
||||||
if (mtmp->mhp < mtmp->mhpmax) {
|
if (mtmp->mhp < mtmp->mhpmax) {
|
||||||
@@ -1200,7 +1210,7 @@ meatobj(struct monst* mtmp) /* for gelatinous cubes */
|
|||||||
struct obj *otmp, *otmp2;
|
struct obj *otmp, *otmp2;
|
||||||
struct permonst *ptr, *original_ptr = mtmp->data;
|
struct permonst *ptr, *original_ptr = mtmp->data;
|
||||||
int poly, grow, heal, eyes, count = 0, ecount = 0, vis = canseemon(mtmp);
|
int poly, grow, heal, eyes, count = 0, ecount = 0, vis = canseemon(mtmp);
|
||||||
char buf[BUFSZ];
|
char buf[BUFSZ], *otmpname;
|
||||||
|
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
/* If a pet, eating is handled separately, in dog.c */
|
/* If a pet, eating is handled separately, in dog.c */
|
||||||
@@ -1261,9 +1271,11 @@ meatobj(struct monst* mtmp) /* for gelatinous cubes */
|
|||||||
&& !slimeproof(mtmp->data))) {
|
&& !slimeproof(mtmp->data))) {
|
||||||
/* engulf */
|
/* engulf */
|
||||||
++ecount;
|
++ecount;
|
||||||
|
/* call distant_name() for its possible side-effects even if
|
||||||
|
the result won't be printed */
|
||||||
|
otmpname = distant_name(otmp, doname);
|
||||||
if (ecount == 1)
|
if (ecount == 1)
|
||||||
Sprintf(buf, "%s engulfs %s.", Monnam(mtmp),
|
Sprintf(buf, "%s engulfs %s.", Monnam(mtmp), otmpname);
|
||||||
distant_name(otmp, doname));
|
|
||||||
else if (ecount == 2)
|
else if (ecount == 2)
|
||||||
Sprintf(buf, "%s engulfs several objects.", Monnam(mtmp));
|
Sprintf(buf, "%s engulfs several objects.", Monnam(mtmp));
|
||||||
obj_extract_self(otmp);
|
obj_extract_self(otmp);
|
||||||
@@ -1274,9 +1286,10 @@ meatobj(struct monst* mtmp) /* for gelatinous cubes */
|
|||||||
/* devour */
|
/* devour */
|
||||||
++count;
|
++count;
|
||||||
if (cansee(mtmp->mx, mtmp->my)) {
|
if (cansee(mtmp->mx, mtmp->my)) {
|
||||||
|
/* (see above; distant_name() sometimes has side-effects */
|
||||||
|
otmpname = distant_name(otmp, doname);
|
||||||
if (flags.verbose)
|
if (flags.verbose)
|
||||||
pline("%s eats %s!", Monnam(mtmp),
|
pline("%s eats %s!", Monnam(mtmp), otmpname);
|
||||||
distant_name(otmp, doname));
|
|
||||||
/* give this one even if !verbose */
|
/* give this one even if !verbose */
|
||||||
if (otmp->oclass == SCROLL_CLASS
|
if (otmp->oclass == SCROLL_CLASS
|
||||||
&& objdescr_is(otmp, "YUM YUM"))
|
&& objdescr_is(otmp, "YUM YUM"))
|
||||||
@@ -1389,8 +1402,12 @@ meatcorpse(struct monst* mtmp) /* for purple worms and other voracious monsters
|
|||||||
otmp = splitobj(otmp, 1L);
|
otmp = splitobj(otmp, 1L);
|
||||||
|
|
||||||
if (cansee(x, y) && canseemon(mtmp)) {
|
if (cansee(x, y) && canseemon(mtmp)) {
|
||||||
|
/* call distant_name() for its possible side-effects even if
|
||||||
|
the result won't be printed */
|
||||||
|
char *otmpname = distant_name(otmp, doname);
|
||||||
|
|
||||||
if (flags.verbose)
|
if (flags.verbose)
|
||||||
pline("%s eats %s!", Monnam(mtmp), distant_name(otmp, doname));
|
pline("%s eats %s!", Monnam(mtmp), otmpname);
|
||||||
} else {
|
} else {
|
||||||
if (flags.verbose)
|
if (flags.verbose)
|
||||||
You_hear("a masticating sound.");
|
You_hear("a masticating sound.");
|
||||||
@@ -1553,24 +1570,13 @@ mpickstuff(struct monst *mtmp, const char *str)
|
|||||||
otmp3 = splitobj(otmp, carryamt);
|
otmp3 = splitobj(otmp, carryamt);
|
||||||
}
|
}
|
||||||
if (cansee(mtmp->mx, mtmp->my)) {
|
if (cansee(mtmp->mx, mtmp->my)) {
|
||||||
/* find an artifact as monster picks it up if its location
|
/* call distant_name() for its possible side-effects even
|
||||||
can be seen, even if monster itself can't be seen or
|
if the result won't be printed; do it before the extract
|
||||||
is far away at the time; the longer distance than for
|
from floor and subsequent pickup by mtmp */
|
||||||
seeing item "up close" is mostly for pets rummaging in
|
char *otmpname = distant_name(otmp, doname);
|
||||||
shops; we prefer to have an artifact in such situation
|
|
||||||
described as 'found in a shop' or 'found on floor' now
|
|
||||||
rather than 'carried by a monster' when later dropped */
|
|
||||||
if (otmp3->oartifact) {
|
|
||||||
otmp3->dknown = 1;
|
|
||||||
find_artifact(otmp3);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flags.verbose)
|
if (flags.verbose)
|
||||||
/* see 'otmp3' "up close" if within a knight's jump */
|
pline("%s picks up %s.", Monnam(mtmp), otmpname);
|
||||||
pline("%s picks up %s.", Monnam(mtmp),
|
|
||||||
((distu(mtmp->mx, mtmp->my) <= 5)
|
|
||||||
? doname(otmp3)
|
|
||||||
: distant_name(otmp3, doname)));
|
|
||||||
}
|
}
|
||||||
obj_extract_self(otmp3); /* remove from floor */
|
obj_extract_self(otmp3); /* remove from floor */
|
||||||
(void) mpickobj(mtmp, otmp3); /* may merge and free otmp3 */
|
(void) mpickobj(mtmp, otmp3); /* may merge and free otmp3 */
|
||||||
|
|||||||
+6
-6
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.7 muse.c $NHDT-Date: 1620329779 2021/05/06 19:36:19 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.143 $ */
|
/* NetHack 3.7 muse.c $NHDT-Date: 1646688066 2022/03/07 21:21:06 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.159 $ */
|
||||||
/* Copyright (C) 1990 by Ken Arromdee */
|
/* Copyright (C) 1990 by Ken Arromdee */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
|
|
||||||
@@ -1993,7 +1993,8 @@ mloot_container(
|
|||||||
container->cknown = 0; /* hero no longer knows container's contents
|
container->cknown = 0; /* hero no longer knows container's contents
|
||||||
* even if [attempted] removal is observed */
|
* even if [attempted] removal is observed */
|
||||||
if (!*contnr_nam) {
|
if (!*contnr_nam) {
|
||||||
/* xname sets dknown, distant_name doesn't */
|
/* xname sets dknown, distant_name might depending on its own
|
||||||
|
idea about nearness */
|
||||||
Strcpy(contnr_nam, an(nearby ? xname(container)
|
Strcpy(contnr_nam, an(nearby ? xname(container)
|
||||||
: distant_name(container, xname)));
|
: distant_name(container, xname)));
|
||||||
}
|
}
|
||||||
@@ -2563,10 +2564,9 @@ mon_consume_unstone(
|
|||||||
|
|
||||||
obj->quan = 1L;
|
obj->quan = 1L;
|
||||||
pline("%s %s %s.", Monnam(mon),
|
pline("%s %s %s.", Monnam(mon),
|
||||||
(obj->oclass == POTION_CLASS)
|
((obj->oclass == POTION_CLASS) ? "quaffs"
|
||||||
? "quaffs"
|
: (obj->otyp == TIN) ? "opens and eats the contents of"
|
||||||
: (obj->otyp == TIN) ? "opens and eats the contents of"
|
: "eats"),
|
||||||
: "eats",
|
|
||||||
distant_name(obj, doname));
|
distant_name(obj, doname));
|
||||||
obj->quan = save_quan;
|
obj->quan = save_quan;
|
||||||
} else if (!Deaf)
|
} else if (!Deaf)
|
||||||
|
|||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.7 music.c $NHDT-Date: 1596498191 2020/08/03 23:43:11 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.69 $ */
|
/* NetHack 3.7 music.c $NHDT-Date: 1646688067 2022/03/07 21:21:07 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.77 $ */
|
||||||
/* Copyright (c) 1989 by Jean-Christophe Collet */
|
/* Copyright (c) 1989 by Jean-Christophe Collet */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
|
|
||||||
@@ -701,7 +701,7 @@ do_play_instrument(struct obj* instr)
|
|||||||
|| instr->otyp == TOOLED_HORN || instr->otyp == FROST_HORN
|
|| instr->otyp == TOOLED_HORN || instr->otyp == FROST_HORN
|
||||||
|| instr->otyp == FIRE_HORN || instr->otyp == BUGLE)
|
|| instr->otyp == FIRE_HORN || instr->otyp == BUGLE)
|
||||||
&& !can_blow(&g.youmonst)) {
|
&& !can_blow(&g.youmonst)) {
|
||||||
You("are incapable of playing %s.", the(distant_name(instr, xname)));
|
You("are incapable of playing %s.", thesimpleoname(instr));
|
||||||
return ECMD_OK;
|
return ECMD_OK;
|
||||||
}
|
}
|
||||||
if (instr->otyp != LEATHER_DRUM && instr->otyp != DRUM_OF_EARTHQUAKE
|
if (instr->otyp != LEATHER_DRUM && instr->otyp != DRUM_OF_EARTHQUAKE
|
||||||
|
|||||||
+46
-17
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.7 objnam.c $NHDT-Date: 1646652769 2022/03/07 11:32:49 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.347 $ */
|
/* NetHack 3.7 objnam.c $NHDT-Date: 1646688068 2022/03/07 21:21:08 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.348 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/*-Copyright (c) Robert Patrick Rankin, 2011. */
|
/*-Copyright (c) Robert Patrick Rankin, 2011. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
@@ -294,24 +294,52 @@ obj_is_pname(struct obj* obj)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Give the name of an object seen at a distance. Unlike xname/doname,
|
/* Give the name of an object seen at a distance. Unlike xname/doname,
|
||||||
* we don't want to set dknown if it's not set already.
|
we usually don't want to set dknown if it's not set already. */
|
||||||
*/
|
|
||||||
char *
|
char *
|
||||||
distant_name(struct obj* obj, char* (*func)(OBJ_P))
|
distant_name(
|
||||||
|
struct obj *obj, /* object to be formatted */
|
||||||
|
char *(*func)(OBJ_P)) /* formatting routine (usually xname or doname) */
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
|
xchar ox = 0, oy = 0;
|
||||||
|
/*
|
||||||
|
* (r * r): square of the x or y distance;
|
||||||
|
* (r * r) * 2: sum of squares of both x and y distances
|
||||||
|
* (r * r) * 2 - r: instead of a square extending from the hero,
|
||||||
|
* round the corners (so shorter distance imposed for diagonal).
|
||||||
|
*
|
||||||
|
* distu() matrix convering a range of 3+ for one quadrant:
|
||||||
|
* 16 17 - - -
|
||||||
|
* 9 10 13 18 -
|
||||||
|
* 4 5 8 13 -
|
||||||
|
* 1 2 5 10 17
|
||||||
|
* @ 1 4 9 16
|
||||||
|
* Theoretical r==1 would yield 1.
|
||||||
|
* r==2 yields 6, functionally equivalent to 5, a knight's jump,
|
||||||
|
* r==3, the xray range of the Eyes of the Overworld, yields 15.
|
||||||
|
*/
|
||||||
|
int r = (u.xray_range > 2) ? u.xray_range : 2,
|
||||||
|
neardist = (r * r) * 2 - r; /* same as r*r + r*(r-1) */
|
||||||
|
|
||||||
/* 3.6.1: this used to save Blind, set it, make the call, then restore
|
/* this maybe-nearby part used to be replicated in multiple callers */
|
||||||
* the saved value; but the Eyes of the Overworld override blindness
|
if (get_obj_location(obj, &ox, &oy, 0) && cansee(ox, oy)
|
||||||
* and let characters wearing them get dknown set for distant items.
|
&& (obj->oartifact || distu(ox, oy) <= neardist)) {
|
||||||
*
|
/* side-effects: treat as having been seen up close;
|
||||||
* TODO? if the hero is wearing those Eyes, figure out whether the
|
cansee() is True hence hero isn't Blind so if 'func' is
|
||||||
* object is within X-ray radius and only treat it as distant when
|
the usual doname or xname, obj->dknown will become set
|
||||||
* beyond that radius. Logic is iffy but result might be interesting.
|
and then for an artifact, find_artifact() will be called */
|
||||||
*/
|
str = (*func)(obj);
|
||||||
++g.distantname;
|
} else {
|
||||||
str = (*func)(obj);
|
/* prior to 3.6.1, this used to save current blindness state,
|
||||||
--g.distantname;
|
explicitly set state to hero-is-blind, make the call (which
|
||||||
|
won't set obj->dknown when blind), then restore the saved
|
||||||
|
value; but the Eyes of the Overworld override blindness and
|
||||||
|
would let characters wearing them get obj->dknown set for
|
||||||
|
distant items, so the external flag was added */
|
||||||
|
++g.distantname;
|
||||||
|
str = (*func)(obj);
|
||||||
|
--g.distantname;
|
||||||
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -902,9 +930,10 @@ minimal_xname(struct obj *obj)
|
|||||||
bareobj.spe = obj->spe;
|
bareobj.spe = obj->spe;
|
||||||
|
|
||||||
/* bufp will be an obuf[] and a pointer into middle of that is viable */
|
/* bufp will be an obuf[] and a pointer into middle of that is viable */
|
||||||
bufp = distant_name(&bareobj, xname); /* xname(&bareobj) */
|
bufp = distant_name(&bareobj, xname);
|
||||||
|
/* undo forced setting of bareobj.blessed for cleric (preist[ess]) */
|
||||||
if (!strncmp(bufp, "uncursed ", 9))
|
if (!strncmp(bufp, "uncursed ", 9))
|
||||||
bufp += 9; /* Role_if(PM_CLERIC) */
|
bufp += 9;
|
||||||
|
|
||||||
objects[otyp].oc_uname = saveobcls.oc_uname;
|
objects[otyp].oc_uname = saveobcls.oc_uname;
|
||||||
objects[otyp].oc_name_known = saveobcls.oc_name_known;
|
objects[otyp].oc_name_known = saveobcls.oc_name_known;
|
||||||
|
|||||||
+5
-10
@@ -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) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/*-Copyright (c) Robert Patrick Rankin, 2012. */
|
/*-Copyright (c) Robert Patrick Rankin, 2012. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
@@ -678,14 +678,9 @@ mdrop_obj(
|
|||||||
{
|
{
|
||||||
int omx = mon->mx, omy = mon->my;
|
int omx = mon->mx, omy = mon->my;
|
||||||
long unwornmask = obj->owornmask;
|
long unwornmask = obj->owornmask;
|
||||||
|
/* call distant_name() for its possible side-effects even if the result
|
||||||
/* if an artifact, find dropped item 'carried by a monster' rather
|
might not be printed, and do it before extracing obj from minvent */
|
||||||
than later finding it on the floor, even if not very close to the
|
char *obj_name = distant_name(obj, doname);
|
||||||
drop and even if the monster itself can't be seen */
|
|
||||||
if (obj->oartifact && cansee(omx, omy)) {
|
|
||||||
obj->dknown = 1;
|
|
||||||
find_artifact(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
extract_from_minvent(mon, obj, FALSE, TRUE);
|
extract_from_minvent(mon, obj, FALSE, TRUE);
|
||||||
/* don't charge for an owned saddle on dead steed (provided
|
/* 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 */
|
/* obj_no_longer_held(obj); -- done by place_object */
|
||||||
if (verbosely && cansee(omx, omy))
|
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")) {
|
if (!flooreffects(obj, omx, omy, "fall")) {
|
||||||
place_object(obj, omx, omy);
|
place_object(obj, omx, omy);
|
||||||
stackobj(obj);
|
stackobj(obj);
|
||||||
|
|||||||
+3
-2
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.7 weapon.c $NHDT-Date: 1629243070 2021/08/17 23:31:10 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.95 $ */
|
/* NetHack 3.7 weapon.c $NHDT-Date: 1646688071 2022/03/07 21:21:11 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.100 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/*-Copyright (c) Robert Patrick Rankin, 2011. */
|
/*-Copyright (c) Robert Patrick Rankin, 2011. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
@@ -703,11 +703,12 @@ possibly_unwield(struct monst *mon, boolean polyspot)
|
|||||||
if (!attacktype(mon->data, AT_WEAP)) {
|
if (!attacktype(mon->data, AT_WEAP)) {
|
||||||
setmnotwielded(mon, mw_tmp);
|
setmnotwielded(mon, mw_tmp);
|
||||||
mon->weapon_check = NO_WEAPON_WANTED;
|
mon->weapon_check = NO_WEAPON_WANTED;
|
||||||
obj_extract_self(obj);
|
/* if we're going to call distant_name(), do so before extract_self */
|
||||||
if (cansee(mon->mx, mon->my)) {
|
if (cansee(mon->mx, mon->my)) {
|
||||||
pline("%s drops %s.", Monnam(mon), distant_name(obj, doname));
|
pline("%s drops %s.", Monnam(mon), distant_name(obj, doname));
|
||||||
newsym(mon->mx, mon->my);
|
newsym(mon->mx, mon->my);
|
||||||
}
|
}
|
||||||
|
obj_extract_self(obj);
|
||||||
/* might be dropping object into water or lava */
|
/* might be dropping object into water or lava */
|
||||||
if (!flooreffects(obj, mon->mx, mon->my, "drop")) {
|
if (!flooreffects(obj, mon->mx, mon->my, "drop")) {
|
||||||
if (polyspot)
|
if (polyspot)
|
||||||
|
|||||||
+2
-4
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.7 wizard.c $NHDT-Date: 1596498229 2020/08/03 23:43:49 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.68 $ */
|
/* NetHack 3.7 wizard.c $NHDT-Date: 1646688073 2022/03/07 21:21:13 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.85 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/*-Copyright (c) Robert Patrick Rankin, 2016. */
|
/*-Copyright (c) Robert Patrick Rankin, 2016. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
@@ -414,9 +414,7 @@ tactics(struct monst *mtmp)
|
|||||||
if ((otmp = on_ground(which_arti(targ))) != 0) {
|
if ((otmp = on_ground(which_arti(targ))) != 0) {
|
||||||
if (cansee(mtmp->mx, mtmp->my))
|
if (cansee(mtmp->mx, mtmp->my))
|
||||||
pline("%s picks up %s.", Monnam(mtmp),
|
pline("%s picks up %s.", Monnam(mtmp),
|
||||||
(distu(mtmp->mx, mtmp->my) <= 5)
|
distant_name(otmp, doname));
|
||||||
? doname(otmp)
|
|
||||||
: distant_name(otmp, doname));
|
|
||||||
obj_extract_self(otmp);
|
obj_extract_self(otmp);
|
||||||
(void) mpickobj(mtmp, otmp);
|
(void) mpickobj(mtmp, otmp);
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user