found_artifact() groundwork

Lay groundwork for generating a log event when finding an artifact
on the floor or carried by a monster.  This part should not produce
any change in behavior.

Move g.artidisco[] and g.artiexist[] out of the instance_globals
struct back to local within artifact.c.  They are both initialized
at the start of a game (and only used in that file) so don't need
to be part of any bulk reinitialization if restart-instead-of-exit
ever gets implemented.

Convert artiexist[] from an array of booleans to an array of structs
containing a pair of bitfields.  artiexist[].exists is a direct
replacement for the boolean; artiexist[].found is new but not put to
any significant use yet.  If will be used to suppress the future
found-an-artifact event for cases where a more specific event (like
crowning or divine gift as #offer reward) is already produced.

Remove g.via_naming altogether and add an extra argument to oname()
calls to replace it.

Add an extra argument to artifact_exists() calls.
This commit is contained in:
PatR
2022-03-07 02:06:55 -08:00
parent 90fc7402b8
commit d37fa4138a
20 changed files with 137 additions and 85 deletions

View File

@@ -852,7 +852,7 @@ gcrownu(void)
Strcpy(lbuf, simpleonames(obj)); /* before transformation */
if (!Blind)
Your("sword shines brightly for a moment.");
obj = oname(obj, artiname(ART_EXCALIBUR));
obj = oname(obj, artiname(ART_EXCALIBUR), ONAME_FOUND_ARTI);
if (obj && obj->oartifact == ART_EXCALIBUR) {
u.ugifts++;
livelog_printf(LL_DIVINEGIFT | LL_ARTIFACT,
@@ -870,10 +870,10 @@ gcrownu(void)
; /* already got bonus above */
} else if (obj && in_hand) {
Your("%s goes snicker-snack!", xname(obj));
obj->dknown = TRUE;
obj->dknown = 1;
} else if (!already_exists) {
obj = mksobj(LONG_SWORD, FALSE, FALSE);
obj = oname(obj, artiname(ART_VORPAL_BLADE));
obj = oname(obj, artiname(ART_VORPAL_BLADE), ONAME_FOUND_ARTI);
obj->spe = 1;
at_your_feet("A sword");
dropy(obj);
@@ -894,10 +894,10 @@ gcrownu(void)
; /* already got bonus above */
} else if (obj && in_hand) {
Your("%s hums ominously!", swordbuf);
obj->dknown = TRUE;
obj->dknown = 1;
} else if (!already_exists) {
obj = mksobj(RUNESWORD, FALSE, FALSE);
obj = oname(obj, artiname(ART_STORMBRINGER));
obj = oname(obj, artiname(ART_STORMBRINGER), ONAME_FOUND_ARTI);
obj->spe = 1;
at_your_feet(An(swordbuf));
dropy(obj);