gender for figurines

Use (obj->spe & CORPSTAT_GENDER) for figurines as well as for
statues and corpses.

Support wishing for
 "{female,male,neuter} {corpse,statue,figurine} [of <monster>]".
and
 "{female,male,neuter} <monster> {corpse,statue,figurine}".
Also
 "{corpse,statue,figurine} of {female,male,neuter} <monster>"
where the qualifier might be in the middle instead of a prefix.
This commit is contained in:
PatR
2021-06-17 16:03:45 -07:00
parent 0aaafd19be
commit 0b5a112b0c
5 changed files with 76 additions and 15 deletions
+3 -2
View File
@@ -55,8 +55,9 @@ struct obj {
* candy bar wrapper index; * candy bar wrapper index;
* scroll of mail (normal==0, bones or wishing==1, written==2); * scroll of mail (normal==0, bones or wishing==1, written==2);
* splash of venom (normal==0, wishing==1); * splash of venom (normal==0, wishing==1);
* gender for corpses and statues (0..3, CORPSTAT_GENDER), * gender for corpses, statues, and figurines (0..3,
* historic flag (4, CORPSTAT_HISTORIC) for statues */ * CORPSTAT_GENDER),
* historic flag for statues (4, CORPSTAT_HISTORIC) */
char oclass; /* object class */ char oclass; /* object class */
char invlet; /* designation in inventory */ char invlet; /* designation in inventory */
char oartifact; /* artifact array index */ char oartifact; /* artifact array index */
+10 -3
View File
@@ -71,9 +71,11 @@ make_familiar(struct obj *otmp, xchar x, xchar y, boolean quietly)
int chance, trycnt = 100; int chance, trycnt = 100;
do { do {
if (otmp) { /* figurine; otherwise spell */ long mmflags;
int mndx = otmp->corpsenm; int cgend, mndx;
if (otmp) { /* figurine; otherwise spell */
mndx = otmp->corpsenm;
pm = &mons[mndx]; pm = &mons[mndx];
/* activating a figurine provides one way to exceed the /* activating a figurine provides one way to exceed the
maximum number of the target critter created--unless maximum number of the target critter created--unless
@@ -97,7 +99,12 @@ make_familiar(struct obj *otmp, xchar x, xchar y, boolean quietly)
} }
} }
mtmp = makemon(pm, x, y, MM_EDOG | MM_IGNOREWATER | NO_MINVENT); mmflags = MM_EDOG | MM_IGNOREWATER | NO_MINVENT;
cgend = otmp ? (otmp->spe & CORPSTAT_GENDER) : 0;
mmflags |= ((cgend == CORPSTAT_FEMALE) ? MM_FEMALE
: (cgend == CORPSTAT_MALE) ? MM_MALE : 0L);
mtmp = makemon(pm, x, y, mmflags);
if (otmp && !mtmp) { /* monster was genocided or square occupied */ if (otmp && !mtmp) { /* monster was genocided or square occupied */
if (!quietly) if (!quietly)
pline_The("figurine writhes and then shatters into pieces!"); pline_The("figurine writhes and then shatters into pieces!");
+8
View File
@@ -1055,6 +1055,14 @@ mksobj(int otyp, boolean init, boolean artif)
case FIGURINE: case FIGURINE:
if (otmp->corpsenm == NON_PM) if (otmp->corpsenm == NON_PM)
otmp->corpsenm = rndmonnum(); otmp->corpsenm = rndmonnum();
if (otmp->corpsenm != NON_PM) {
struct permonst *ptr = &mons[otmp->corpsenm];
otmp->spe = (is_neuter(ptr) ? CORPSTAT_NEUTER
: is_female(ptr) ? CORPSTAT_FEMALE
: is_male(ptr) ? CORPSTAT_MALE
: rn2(2) ? CORPSTAT_FEMALE : CORPSTAT_MALE);
}
/*FALLTHRU*/ /*FALLTHRU*/
case EGG: case EGG:
/* case TIN: */ /* case TIN: */
+7 -5
View File
@@ -686,13 +686,11 @@ name_to_monplus(
register int mntmp = NON_PM; register int mntmp = NON_PM;
register char *s, *str, *term; register char *s, *str, *term;
char buf[BUFSZ]; char buf[BUFSZ];
int len, slen, mgend, matchgend = NEUTRAL; int len, slen, mgend, matchgend = -1;
boolean exact_match = FALSE; boolean exact_match = FALSE;
if (remainder_p) if (remainder_p)
*remainder_p = (const char *) 0; *remainder_p = (const char *) 0;
if (gender_name_var)
*gender_name_var = matchgend; /* NEUTRAL */
str = strcpy(buf, in_str); str = strcpy(buf, in_str);
@@ -848,8 +846,12 @@ name_to_monplus(
mntmp = title_to_mon(str, (int *) 0, &len); mntmp = title_to_mon(str, (int *) 0, &len);
if (len && remainder_p) if (len && remainder_p)
*remainder_p = in_str + (&str[len] - buf); *remainder_p = in_str + (&str[len] - buf);
if (gender_name_var) if (gender_name_var && matchgend != -1) {
*gender_name_var = matchgend; /* don't override with neuter if caller has already specified male
or female and we've matched the neuter name */
if (*gender_name_var == -1 || matchgend != NEUTRAL)
*gender_name_var = matchgend;
}
return mntmp; return mntmp;
} }
+48 -5
View File
@@ -515,7 +515,7 @@ xname_flags(
if (typ == FIGURINE && omndx != NON_PM) { if (typ == FIGURINE && omndx != NON_PM) {
char anbuf[10]; /* [4] would be enough: 'a','n',' ','\0' */ char anbuf[10]; /* [4] would be enough: 'a','n',' ','\0' */
const char *pm_name = mons[omndx].pmnames[NEUTRAL]; const char *pm_name = obj_pmname(obj);
Sprintf(eos(buf), " of %s%s", just_an(anbuf, pm_name), pm_name); Sprintf(eos(buf), " of %s%s", just_an(anbuf, pm_name), pm_name);
} else if (is_wet_towel(obj)) { } else if (is_wet_towel(obj)) {
@@ -3261,7 +3261,7 @@ readobjnam_init(char *bp, struct _readobjnam_data *d)
= d->looted /* wizard mode fountain/sink/throne/tree and grave */ = d->looted /* wizard mode fountain/sink/throne/tree and grave */
= d->real = d->fake = 0; /* Amulet */ = d->real = d->fake = 0; /* Amulet */
d->tvariety = RANDOM_TIN; d->tvariety = RANDOM_TIN;
d->mgend = NEUTRAL; d->mgend = -1; /* not specified, aka random */
d->mntmp = NON_PM; d->mntmp = NON_PM;
d->contents = UNDEFINED; d->contents = UNDEFINED;
d->oclass = 0; d->oclass = 0;
@@ -3276,14 +3276,20 @@ readobjnam_init(char *bp, struct _readobjnam_data *d)
(void) memset(d->fruitbuf, '\0', sizeof d->globbuf); (void) memset(d->fruitbuf, '\0', sizeof d->globbuf);
} }
/* return 1 if d->bp is empty or contains only various qualifiers like
"blessed", "rustproof", and so on, or 0 if anything else is present */
static int static int
readobjnam_preparse(struct _readobjnam_data *d) readobjnam_preparse(struct _readobjnam_data *d)
{ {
char *save_bp = 0;
int more_l = 0, res = 1;
for (;;) { for (;;) {
register int l; register int l;
if (!d->bp || !*d->bp) if (!d->bp || !*d->bp)
return 1; break;
if (!strncmpi(d->bp, "an ", l = 3) || !strncmpi(d->bp, "a ", l = 2)) { if (!strncmpi(d->bp, "an ", l = 3) || !strncmpi(d->bp, "a ", l = 2)) {
d->cnt = 1; d->cnt = 1;
} else if (!strncmpi(d->bp, "the ", l = 4)) { } else if (!strncmpi(d->bp, "the ", l = 4)) {
@@ -3430,11 +3436,47 @@ readobjnam_preparse(struct _readobjnam_data *d)
d->fake = 1, d->real = 0; d->fake = 1, d->real = 0;
/* ['real' isn't actually needed (unless we someday add /* ['real' isn't actually needed (unless we someday add
"real gem" for random non-glass, non-stone)] */ "real gem" for random non-glass, non-stone)] */
} else } else if (!strncmpi(d->bp, "female ", l = 7)) {
d->mgend = FEMALE;
/* if after "corpse/statue/figurine of", remove from string */
if (save_bp)
strsubst(d->bp, "female ", ""), l = 0;
} else if (!strncmpi(d->bp, "male ", l = 5)) {
d->mgend = MALE;
if (save_bp)
strsubst(d->bp, "male ", ""), l = 0;
} else if (!strncmpi(d->bp, "neuter ", l = 7)) {
d->mgend = NEUTRAL;
if (save_bp)
strsubst(d->bp, "neuter ", ""), l = 0;
/*
* Corpse/statue/figurine gender hack: in order to accept
* "statue of a female gnome ruler" for gnome queen we need
* to recognize and skip over "statue of [a ]". Otherwise
* we would only accept "female gnome ruler statue" and the
* viable but silly "female statue of a gnome ruler".
*/
} else if ((!strncmpi(d->bp, "corpse ", l = 7)
|| !strncmpi(d->bp, "statue ", l = 7)
|| !strncmpi(d->bp, "figurine ", l = 9))
&& !strncmpi(d->bp + l, "of ", more_l = 3)) {
save_bp = d->bp; /* we'll backtrack to here later */
l += more_l, more_l = 0;
if (!strncmpi(d->bp + l, "a ", more_l = 2)
|| !strncmpi(d->bp + l, "an ", more_l = 3)
|| !strncmpi(d->bp + l, "the ", more_l = 4))
l += more_l;
res = 0;
} else {
res = 0;
break; break;
}
d->bp += l; d->bp += l;
} }
return 0; if (save_bp)
d->bp = save_bp;
return res;
} }
static void static void
@@ -4301,6 +4343,7 @@ readobjnam(char *bp, struct obj *no_wish)
case IRON_CHAIN: case IRON_CHAIN:
break; break;
case STATUE: /* otmp->cobj already done in mksobj() */ case STATUE: /* otmp->cobj already done in mksobj() */
case FIGURINE:
case CORPSE: { case CORPSE: {
struct permonst *P = (d.mntmp >= LOW_PM) ? &mons[d.mntmp] : 0; struct permonst *P = (d.mntmp >= LOW_PM) ? &mons[d.mntmp] : 0;