monster name formatting

While testing monster summoning by using a debugger to force the
outcome, I saw "the renegade Angel of <foo> appears in a cloud of
smoke" as if only one such creature existed.  Trying to change
that to "a renegate Angel" pointed out some problems:  type names
like Angel, Green-elf, and Uruk-hai fool an() into using "the"
because of their capital letter.  Fixing that was a bit of a hack
and worked for Green-elf and Uruk-hai but not for Angel because
it has the eminion extension so uses priestname() instead of the
guts of x_monnam().  Fixing that involved more hackery and now I
feel unclean, but it seems to be working.

It wasn't as noticeable as it might have been because most of the
time that "the Angel of <foo>" or "the priest of <bar>" was shown,
the caller is requesting "the" rather than "a/an".
This commit is contained in:
PatR
2021-06-21 17:44:35 -07:00
parent 3af1cc79e6
commit fa7980c585
4 changed files with 58 additions and 19 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 priest.c $NHDT-Date: 1597931337 2020/08/20 13:48:57 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.63 $ */
/* NetHack 3.7 priest.c $NHDT-Date: 1624322670 2021/06/22 00:44:30 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.70 $ */
/* Copyright (c) Izchak Miller, Steve Linhart, 1989. */
/* NetHack may be freely redistributed. See license for details. */
@@ -291,26 +291,48 @@ mon_aligntyp(struct monst *mon)
* the true name even when under that influence
*/
char *
priestname(struct monst *mon,
char *pname) /* caller-supplied output buffer */
priestname(
struct monst *mon,
int article,
char *pname) /* caller-supplied output buffer */
{
boolean do_hallu = Hallucination,
aligned_priest = mon->data == &mons[PM_ALIGNED_CLERIC],
high_priest = mon->data == &mons[PM_HIGH_CLERIC];
char whatcode = '\0';
const char *what = do_hallu ? rndmonnam(&whatcode)
: pmname(mon->data, Mgender(mon));
const char *what = do_hallu ? rndmonnam(&whatcode) : mon_pmname(mon);
if (!mon->ispriest && !mon->isminion) /* should never happen... */
return strcpy(pname, what); /* caller must be confused */
*pname = '\0';
if (!do_hallu || !bogon_is_pname(whatcode))
Strcat(pname, "the ");
if (mon->minvis)
if (article != ARTICLE_NONE && (!do_hallu || !bogon_is_pname(whatcode))) {
if (article == ARTICLE_YOUR || (article == ARTICLE_A && high_priest))
article = ARTICLE_THE;
if (article == ARTICLE_THE) {
Strcat(pname, "the ");
} else {
char buf2[BUFSZ];
/* don't let "Angel of <foo>" fool an() into using "the " */
Strcpy(buf2, pname);
*buf2 = lowc(*buf2);
(void) just_an(pname, buf2);
}
}
/* pname[] contains "" or {"a ","an ","the "} */
if (mon->minvis) {
/* avoid "a invisible priest" */
if (!strcmp(pname, "a "))
Strcpy(pname, "an ");
Strcat(pname, "invisible ");
if (mon->isminion && EMIN(mon)->renegade)
}
if (mon->isminion && EMIN(mon)->renegade) {
/* avoid "an renegade Angel" */
if (!strcmp(pname, "an ")) /* will fail for "an invisible " */
Strcpy(pname, "a ");
Strcat(pname, "renegade ");
}
if (mon->ispriest || aligned_priest) { /* high_priest implies ispriest */
if (!aligned_priest && !high_priest) {