Unify monster gender setting

This commit is contained in:
Pasi Kallinen
2015-04-22 08:58:04 +03:00
parent 3bf2d17e2c
commit 171e8284cd
3 changed files with 18 additions and 15 deletions

View File

@@ -1308,6 +1308,7 @@ E boolean FDECL(hideunder, (struct monst*));
E void FDECL(hide_monst, (struct monst *));
E void FDECL(mon_animal_list, (BOOLEAN_P));
E int FDECL(select_newcham_form, (struct monst *));
E void FDECL(mgender_from_permonts, (struct monst *, struct permonst *));
E int FDECL(newcham, (struct monst *,struct permonst *,BOOLEAN_P,BOOLEAN_P));
E int FDECL(can_be_hatched, (int));
E int FDECL(egg_type_from_parent, (int,BOOLEAN_P));

View File

@@ -2745,6 +2745,20 @@ int mndx;
return polyok(mdat) ? mdat : 0;
}
void
mgender_from_permonst(mtmp, mdat)
struct monst *mtmp;
struct permonst *mdat;
{
if(is_male(mdat)) {
if(mtmp->female) mtmp->female = FALSE;
} else if (is_female(mdat)) {
if(!mtmp->female) mtmp->female = TRUE;
} else if (!is_neuter(mdat)) {
if(!rn2(10)) mtmp->female = !mtmp->female;
}
}
/* make a chameleon take on another shape, or a polymorph target
(possibly self-infliced) become a different monster;
returns 1 if it actually changes form */
@@ -2784,13 +2798,7 @@ boolean msg; /* "The oldmon turns into a newmon!" */
} else if (mvitals[monsndx(mdat)].mvflags & G_GENOD)
return(0); /* passed in mdat is genocided */
if(is_male(mdat)) {
if(mtmp->female) mtmp->female = FALSE;
} else if (is_female(mdat)) {
if(!mtmp->female) mtmp->female = TRUE;
} else if (!is_neuter(mdat)) {
if(!rn2(10)) mtmp->female = !mtmp->female;
}
mgender_from_permonst(mtmp, mdat);
if (In_endgame(&u.uz) && is_mplayer(olddata) && has_mname(mtmp)) {
/* mplayers start out as "Foo the Bar", but some of the

View File

@@ -1499,14 +1499,8 @@ struct mkroom *croom;
if ((mndx != NON_PM) && (&mons[mndx] != mtmp->data)) {
struct permonst *mdat = &mons[mndx];
struct permonst *olddata = mtmp->data;
/* this code duplicated from newcham() */
if(is_male(mdat)) {
if(mtmp->female) mtmp->female = FALSE;
} else if (is_female(mdat)) {
if(!mtmp->female) mtmp->female = TRUE;
} else if (!is_neuter(mdat)) {
if(!rn2(10)) mtmp->female = !mtmp->female;
}
mgender_from_permonst(mtmp, mdat);
set_mon_data(mtmp, mdat, 0);
if (emits_light(olddata) != emits_light(mtmp->data)) {
/* used to give light, now doesn't, or vice versa,