From 49b2ea1b89bda33b369a82478ebd8c4b9230b89d Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 28 Oct 2021 12:55:32 -0700 Subject: [PATCH] "someone"/"something" instead of "it" I thought there were more places that checked for "it" and substituted "someone" or "something". Perhaps there are and I'm just not finding them now. Anyway, this extends x_monnam() and adds some_mon_nam() and Some_Monnam() to do that during monster name formatting instead of having various bits of code try fix it up after the fact. The fixups could be fooled by monsters given the name "it" or "It"; x_monnam() won't be. --- include/decl.h | 3 ++- include/extern.h | 2 ++ src/do_name.c | 38 +++++++++++++++++++++++++++++++++----- src/mthrowu.c | 4 +--- src/muse.c | 10 +--------- src/vault.c | 7 +------ 6 files changed, 40 insertions(+), 24 deletions(-) diff --git a/include/decl.h b/include/decl.h index 204d1d867..7aae881dd 100644 --- a/include/decl.h +++ b/include/decl.h @@ -310,13 +310,14 @@ E char emptystr[]; #define ARTICLE_A 2 #define ARTICLE_YOUR 3 -/* Monster name suppress masks */ +/* x_monnam() monster name suppress masks */ #define SUPPRESS_IT 0x01 #define SUPPRESS_INVISIBLE 0x02 #define SUPPRESS_HALLUCINATION 0x04 #define SUPPRESS_SADDLE 0x08 #define EXACT_NAME 0x0F #define SUPPRESS_NAME 0x10 +#define AUGMENT_IT 0x20 /* use "someone" or "something" instead of "it" */ /* Window system stuff */ E NEARDATA winid WIN_MESSAGE; diff --git a/include/extern.h b/include/extern.h index cba3270fd..6520b9d83 100644 --- a/include/extern.h +++ b/include/extern.h @@ -438,8 +438,10 @@ extern char *x_monnam(struct monst *, int, const char *, int, boolean); extern char *l_monnam(struct monst *); extern char *mon_nam(struct monst *); extern char *noit_mon_nam(struct monst *); +extern char *some_mon_nam(struct monst *); extern char *Monnam(struct monst *); extern char *noit_Monnam(struct monst *); +extern char *Some_Monnam(struct monst *); extern char *noname_monnam(struct monst *, int); extern char *m_monnam(struct monst *); extern char *y_monnam(struct monst *); diff --git a/src/do_name.c b/src/do_name.c index 029938c84..f42251f25 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -1669,9 +1669,13 @@ rndghostname(void) * seen unseen detected named * mon_nam: the newt it the invisible orc Fido * noit_mon_nam:the newt (as if detected) the invisible orc Fido + * some_mon_nam:the newt someone the invisible orc Fido + * or something * l_monnam: newt it invisible orc dog called Fido * Monnam: The newt It The invisible orc Fido * noit_Monnam: The newt (as if detected) The invisible orc Fido + * Some_Monnam: The newt Someone The invisible orc Fido + * or Something * Adjmonnam: The poor newt It The poor invisible orc The poor Fido * Amonnam: A newt It An invisible orc Fido * a_monnam: a newt it an invisible orc Fido @@ -1711,7 +1715,7 @@ x_monnam( char *buf = nextmbuf(); struct permonst *mdat = mtmp->data; const char *pm_name = mon_pmname(mtmp); - boolean do_hallu, do_invis, do_it, do_saddle, do_name; + boolean do_hallu, do_invis, do_it, do_saddle, do_name, augment_it; boolean name_at_start, has_adjectives, falseCap = (*pm_name != lowc(*pm_name)); char *bp; @@ -1728,12 +1732,16 @@ x_monnam( && !(u.uswallow && mtmp == u.ustuck) && !(suppress & SUPPRESS_IT); do_saddle = !(suppress & SUPPRESS_SADDLE); do_name = !(suppress & SUPPRESS_NAME) || type_is_pname(mdat); + augment_it = (suppress & AUGMENT_IT) != 0; buf[0] = '\0'; - /* unseen monsters, etc. Use "it" */ + /* unseen monsters, etc.; usually "it" but sometimes more specific; + when hallucinating, the more specific values might be inverted */ if (do_it) { - Strcpy(buf, "it"); + Strcpy(buf, !augment_it ? "it" + : (!do_hallu ? humanoid(mdat) : !rn2(2)) ? "someone" + : "something"); return buf; } @@ -1908,8 +1916,19 @@ char * noit_mon_nam(struct monst *mtmp) { return x_monnam(mtmp, ARTICLE_THE, (char *) 0, - (has_mgivenname(mtmp)) ? (SUPPRESS_SADDLE | SUPPRESS_IT) - : SUPPRESS_IT, + (has_mgivenname(mtmp) ? (SUPPRESS_SADDLE | SUPPRESS_IT) + : SUPPRESS_IT), + FALSE); +} + +/* in between noit_mon_nam() and mon_nam(); if the latter would pick "it", + use "someone" (for humanoids) or "something" (for others) instead */ +char * +some_mon_nam(struct monst *mtmp) +{ + return x_monnam(mtmp, ARTICLE_THE, (char *) 0, + (has_mgivenname(mtmp) ? (SUPPRESS_SADDLE | AUGMENT_IT) + : AUGMENT_IT), FALSE); } @@ -1931,6 +1950,15 @@ noit_Monnam(struct monst *mtmp) return bp; } +char * +Some_Monnam(struct monst *mtmp) +{ + char *bp = some_mon_nam(mtmp); + + *bp = highc(*bp); + return bp; +} + /* return "a dog" rather than "Fido", honoring hallucination and visibility */ char * noname_monnam(struct monst *mtmp, int article) diff --git a/src/mthrowu.c b/src/mthrowu.c index b8c3ba174..3442fb674 100644 --- a/src/mthrowu.c +++ b/src/mthrowu.c @@ -247,9 +247,7 @@ monshoot(struct monst* mtmp, struct obj* otmp, struct obj* mwep) onm = obj_is_pname(otmp) ? the(onm) : an(onm); } g.m_shot.s = ammo_and_launcher(otmp, mwep) ? TRUE : FALSE; - Strcpy(trgbuf, mtarg ? mon_nam(mtarg) : ""); - if (!strcmp(trgbuf, "it")) - Strcpy(trgbuf, humanoid(mtmp->data) ? "someone" : something); + Strcpy(trgbuf, mtarg ? some_mon_nam(mtarg) : ""); pline("%s %s %s%s%s!", Monnam(mtmp), g.m_shot.s ? "shoots" : "throws", onm, mtarg ? " at " : "", trgbuf); diff --git a/src/muse.c b/src/muse.c index 2c8e8f456..2839dfd0b 100644 --- a/src/muse.c +++ b/src/muse.c @@ -2166,15 +2166,7 @@ use_misc(struct monst* mtmp) if (vis || vistrapspot) seetrap(t); if (vismon || vistrapspot) { - const char *Mnam = Monnam(mtmp); - - /* when the trap is seen but the monster isn't, Monnam() - will yield "It"; change that to "Someone" or "Something"; - the canspotmon() check is to avoid making the change if - mtmp has been explicitly named "It" */ - if (!strcmp(Mnam, "It") && !canspotmon(mtmp)) - Mnam = humanoid(mtmp->data) ? "Someone" : "Something"; - pline("%s deliberately %s onto a %s trap!", Mnam, + pline("%s deliberately %s onto a %s trap!", Some_Monnam(mtmp), vtense(fakename[0], locomotion(mtmp->data, "jump")), t->tseen ? "polymorph" : "hidden"); /* note: if mtmp is unseen because it is invisible, its new diff --git a/src/vault.c b/src/vault.c index 9430cb9e5..2c3ce3012 100644 --- a/src/vault.c +++ b/src/vault.c @@ -745,12 +745,7 @@ gd_pick_corridor_gold(struct monst *grd, int goldx, int goldy) } if (see_it) { /* cansee(goldx, goldy) */ - char monnambuf[BUFSZ]; - - Strcpy(monnambuf, Monnam(grd)); - if (!strcmpi(monnambuf, "It")) - Strcpy(monnambuf, "Someone"); - pline("%s%s picks up the gold%s.", monnambuf, + pline("%s%s picks up the gold%s.", Some_Monnam(grd), (grd->mpeaceful && EGD(grd)->warncnt > 5) ? " calms down and" : "", under_u ? " from beneath you" : "");