diff --git a/include/extern.h b/include/extern.h index 94567f8d9..0f62485d6 100644 --- a/include/extern.h +++ b/include/extern.h @@ -2882,6 +2882,7 @@ extern void topten(int, time_t); extern void prscore(int, char **); extern struct toptenentry *get_rnd_toptenentry(void); extern struct obj *tt_oname(struct obj *); +extern int tt_doppel(struct monst *); /* ### track.c ### */ diff --git a/src/mon.c b/src/mon.c index 571ef9254..201092d90 100644 --- a/src/mon.c +++ b/src/mon.c @@ -4605,7 +4605,7 @@ select_newcham_form(struct monst* mon) if (!rn2(7)) { mndx = pick_nasty(mons[PM_JABBERWOCK].difficulty - 1); } else if (rn2(3)) { /* role monsters */ - mndx = rn1(PM_WIZARD - PM_ARCHEOLOGIST + 1, PM_ARCHEOLOGIST); + mndx = tt_doppel(mon); } else if (!rn2(3)) { /* quest guardians */ mndx = rn1(PM_APPRENTICE - PM_STUDENT + 1, PM_STUDENT); /* avoid own role's guardian */ diff --git a/src/topten.c b/src/topten.c index 6877e55db..992979e0a 100644 --- a/src/topten.c +++ b/src/topten.c @@ -1432,6 +1432,29 @@ tt_oname(struct obj *otmp) return otmp; } +/* Randomly select a topten entry to mimic */ +int +tt_doppel(struct monst *mon) { + struct toptenentry *tt = get_rnd_toptenentry(); + int ret; + + if (!tt) + ret = rn1(PM_WIZARD - PM_ARCHEOLOGIST + 1, PM_ARCHEOLOGIST); + else { + if (tt->plgend[0] == 'F') + mon->female = 1; + else if (tt->plgend[0] == 'M') + mon->female = 0; + ret = classmon(tt->plrole); + /* Only take on a name if the player can see + the doppelganger, otherwise we end up with + named monsters spoiling the fun - Kes */ + if (canseemon(mon)) + christen_monst(mon, tt->name); + } + return ret; +} + #ifdef NO_SCAN_BRACK /* Lattice scanf isn't up to reading the scorefile. What */ /* follows deals with that; I admit it's ugly. (KL) */