]> granicus.if.org Git - nethack/commitdiff
livelog event for crowning gift
authorPatR <rankin@nethack.org>
Sat, 5 Mar 2022 23:14:18 +0000 (15:14 -0800)
committerPatR <rankin@nethack.org>
Sat, 5 Mar 2022 23:14:18 +0000 (15:14 -0800)
There is an event for being crowned "Hand of Elebereth" and so forth
and an event for being given an artifact (any, not just the first) as
reward for #offer, but there wasn't one for the item usually given
along with being crowned.

Now there is.  It's not something that an observer (of the events
being logged) can deduce since sometimes an alternative is given
(wizard and monk) and other times nothing is given (artifact already
exists or lawful character isn't wielding non-artifact long sword).

I flagged the spellbook given to a wizard or a monk as
'divinegift | artifact | spoiler'.  'artifact' since even though it
isn't actually an artifact, it is standing in the place for one.  And
'spoiler', to hide from #chronicle, in case the hero doesn't know the
spellbook yet.

include/extern.h
src/objnam.c
src/pray.c

index f1b638c7e7b9dd0eabcb1ba2a83241c1ace803ea..d18f5b1000429fbb028c6d174b6a48ff46a4fc7f 100644 (file)
@@ -1864,6 +1864,7 @@ extern char *Ysimple_name2(struct obj *);
 extern char *simpleonames(struct obj *);
 extern char *ansimpleoname(struct obj *);
 extern char *thesimpleoname(struct obj *);
+extern char *actualoname(struct obj *);
 extern char *bare_artifactname(struct obj *);
 extern char *makeplural(const char *);
 extern char *makesingular(const char *);
index d342fff051ccacfb4378e1e640401b139d53764c..c7a6519376b577d675d0ce232aa589f3dfa17d3e 100644 (file)
@@ -854,7 +854,9 @@ minimal_xname(struct obj *obj)
     objects[otyp].oc_uname = 0;
     /* suppress actual name if object's description is unknown */
     saveobcls.oc_name_known = objects[otyp].oc_name_known;
-    if (!obj->dknown)
+    if (iflags.override_ID)
+        objects[otyp].oc_name_known = 1;
+    else if (!obj->dknown)
         objects[otyp].oc_name_known = 0;
 
     /* caveat: this makes a lot of assumptions about which fields
@@ -862,7 +864,7 @@ minimal_xname(struct obj *obj)
     bareobj = cg.zeroobj;
     bareobj.otyp = otyp;
     bareobj.oclass = obj->oclass;
-    bareobj.dknown = obj->dknown;
+    bareobj.dknown = (obj->dknown || iflags.override_ID) ? 1 : 0;
     /* suppress known except for amulets (needed for fakes and real A-of-Y) */
     bareobj.known = (obj->oclass == AMULET_CLASS)
                         ? obj->known
@@ -2085,7 +2087,7 @@ ansimpleoname(struct obj* obj)
 
 /* "the scroll" or "the scrolls" */
 char *
-thesimpleoname(struct objobj)
+thesimpleoname(struct obj *obj)
 {
     char *obufp, *simpleoname = simpleonames(obj);
 
@@ -2095,9 +2097,24 @@ thesimpleoname(struct obj* obj)
     return simpleoname;
 }
 
+/* basic name of obj, as if it has been discovered; for some types of
+   items, we can't just use OBJ_NAME() because it doesn't always include
+   the class (for instance "light" when we want "spellbook of light");
+   minimal_xname() uses xname() to get that */
+char *
+actualoname(struct obj *obj)
+{
+    char *res;
+
+    iflags.override_ID = TRUE;
+    res = minimal_xname(obj);
+    iflags.override_ID = FALSE;
+    return res;
+}
+
 /* artifact's name without any object type or known/dknown/&c feedback */
 char *
-bare_artifactname(struct objobj)
+bare_artifactname(struct obj *obj)
 {
     char *outbuf;
 
index b1bc82913ca7033bcce92e90db6c46ae83d8ef80..85247bb0f1c147317f2eacc0d768d75152175097 100644 (file)
@@ -758,6 +758,7 @@ static void
 gcrownu(void)
 {
     struct obj *obj;
+    const char *what;
     boolean already_exists, in_hand;
     short class_gift;
 #define ok_wep(o) ((o) && ((o)->oclass == WEAPON_CLASS || is_weptool(o)))
@@ -791,13 +792,14 @@ gcrownu(void)
         u.uevent.uhand_of_elbereth = 1;
         verbalize("I crown thee...  The Hand of Elbereth!");
         livelog_printf(LL_DIVINEGIFT,
-                       "was crowned \"The Hand of Elbereth\" by %s", u_gname());
+                       "was crowned \"The Hand of Elbereth\" by %s",
+                       u_gname());
         break;
     case A_NEUTRAL:
         u.uevent.uhand_of_elbereth = 2;
         in_hand = (uwep && uwep->oartifact == ART_VORPAL_BLADE);
-        already_exists =
-            exist_artifact(LONG_SWORD, artiname(ART_VORPAL_BLADE));
+        already_exists = exist_artifact(LONG_SWORD,
+                                        artiname(ART_VORPAL_BLADE));
         verbalize("Thou shalt be my Envoy of Balance!");
         livelog_printf(LL_DIVINEGIFT, "became %s Envoy of Balance",
                        s_suffix(u_gname()));
@@ -805,27 +807,35 @@ gcrownu(void)
     case A_CHAOTIC:
         u.uevent.uhand_of_elbereth = 3;
         in_hand = (uwep && uwep->oartifact == ART_STORMBRINGER);
-        already_exists =
-            exist_artifact(RUNESWORD, artiname(ART_STORMBRINGER));
-        verbalize("Thou art chosen to %s for My Glory!",
-                  ((already_exists && !in_hand)
-                   || class_gift != STRANGE_OBJECT) ? "take lives"
-                  : "steal souls");
-        livelog_printf(LL_DIVINEGIFT, "was chosen to %s for the Glory of %s",
-                       ((already_exists && !in_hand)
-                        || class_gift != STRANGE_OBJECT) ? "take lives"
-                       : "steal souls",
-                       u_gname());
+        already_exists = exist_artifact(RUNESWORD, artiname(ART_STORMBRINGER));
+        what = (((already_exists && !in_hand) || class_gift != STRANGE_OBJECT)
+                ? "take lives"
+                : "steal souls");
+        verbalize("Thou art chosen to %s for My Glory!", what);
+        livelog_printf(LL_DIVINEGIFT, "chosen to %s for the Glory of %s",
+                       what, u_gname());
         break;
     }
 
     if (objects[class_gift].oc_class == SPBOOK_CLASS) {
+        char bbuf[BUFSZ];
+
         obj = mksobj(class_gift, TRUE, FALSE);
+        /* get book type before dropping (don't think that could destroy
+           the book because we need to be on an altar in order to become
+           crowned, but be paranoid about it) */
+        Strcpy(bbuf, actualoname(obj)); /* for livelog; "spellbook of <foo>"
+                                         * even if hero doesn't know book */
         bless(obj);
         obj->bknown = 1; /* ok to skip set_bknown() */
         at_your_feet("A spellbook");
         dropy(obj);
         u.ugifts++;
+        /* not an artifact, but treat like one for this situation;
+           classify as a spoiler in case player hasn't IDed the book yet */
+        livelog_printf(LL_DIVINEGIFT | LL_ARTIFACT | LL_SPOILER,
+                       "bestowed with %s", bbuf);
+
         /* when getting a new book for known spell, enhance
            currently wielded weapon rather than the book */
         if (known_spell(class_gift) && ok_wep(uwep))
@@ -837,11 +847,18 @@ gcrownu(void)
         if (class_gift != STRANGE_OBJECT) {
             ; /* already got bonus above */
         } else if (obj && obj->otyp == LONG_SWORD && !obj->oartifact) {
+            char lbuf[BUFSZ];
+
+            Strcpy(lbuf, simpleonames(obj)); /* before transformation */
             if (!Blind)
                 Your("sword shines brightly for a moment.");
             obj = oname(obj, artiname(ART_EXCALIBUR));
-            if (obj && obj->oartifact == ART_EXCALIBUR)
+            if (obj && obj->oartifact == ART_EXCALIBUR) {
                 u.ugifts++;
+                livelog_printf(LL_DIVINEGIFT | LL_ARTIFACT,
+                               "wielded %s transformed into %s",
+                               lbuf, artiname(ART_EXCALIBUR));
+            }
         }
         /* acquire Excalibur's skill regardless of weapon or gift */
         unrestrict_weapon_skill(P_LONG_SWORD);
@@ -861,6 +878,8 @@ gcrownu(void)
             at_your_feet("A sword");
             dropy(obj);
             u.ugifts++;
+            livelog_printf(LL_DIVINEGIFT | LL_ARTIFACT,
+                           "bestowed with %s", artiname(ART_VORPAL_BLADE));
         }
         /* acquire Vorpal Blade's skill regardless of weapon or gift */
         unrestrict_weapon_skill(P_LONG_SWORD);
@@ -883,6 +902,8 @@ gcrownu(void)
             at_your_feet(An(swordbuf));
             dropy(obj);
             u.ugifts++;
+            livelog_printf(LL_DIVINEGIFT | LL_ARTIFACT,
+                           "bestowed with %s", artiname(ART_STORMBRINGER));
         }
         /* acquire Stormbringer's skill regardless of weapon or gift */
         unrestrict_weapon_skill(P_BROAD_SWORD);
@@ -1798,10 +1819,10 @@ dosacrifice(void)
                     u.ugifts++;
                     u.ublesscnt = rnz(300 + (50 * nartifacts));
                     exercise(A_WIS, TRUE);
-                    livelog_printf (LL_DIVINEGIFT|LL_ARTIFACT,
-                                    "had %s bestowed upon %s by %s",
+                    livelog_printf (LL_DIVINEGIFT | LL_ARTIFACT,
+                                    "bestowed with %s by %s",
                                     artiname(otmp->oartifact),
-                                    uhim(), align_gname(u.ualign.type));
+                                    align_gname(u.ualign.type));
                     /* make sure we can use this weapon */
                     unrestrict_weapon_skill(weapon_type(otmp));
                     if (!Hallucination && !Blind) {