^G (trunk only)

Change controlled monster creation to support specifying monster
by class name in addition to by class letter and the usual type name.
This commit is contained in:
nethack.rankin
2007-04-10 04:24:17 +00:00
parent 4777c898f8
commit 38fc7d0ba1

View File

@@ -1971,16 +1971,17 @@ struct obj *from_obj;
boolean boolean
create_particular() create_particular()
{ {
char buf[BUFSZ], *bufp, monclass = MAXMCLASSES; char buf[BUFSZ], *bufp, monclass;
int which, tries, i, firstchoice = NON_PM; int which, tryct, i, firstchoice = NON_PM;
struct permonst *whichpm; struct permonst *whichpm;
struct monst *mtmp; struct monst *mtmp;
boolean madeany = FALSE; boolean madeany = FALSE;
boolean maketame, makepeaceful, makehostile; boolean maketame, makepeaceful, makehostile;
boolean randmonst = FALSE; boolean randmonst = FALSE;
tries = 0; tryct = 5;
do { do {
monclass = MAXMCLASSES;
which = urole.malenum; /* an arbitrary index into mons[] */ which = urole.malenum; /* an arbitrary index into mons[] */
maketame = makepeaceful = makehostile = FALSE; maketame = makepeaceful = makehostile = FALSE;
getlin("Create what kind of monster? [type the name or symbol]", getlin("Create what kind of monster? [type the name or symbol]",
@@ -1999,24 +2000,27 @@ create_particular()
makehostile = TRUE; makehostile = TRUE;
} }
/* decide whether a valid monster was chosen */ /* decide whether a valid monster was chosen */
if (strlen(bufp) == 1) {
#ifdef WIZARD #ifdef WIZARD
if (wizard && *bufp == '*') { if (wizard && (!strcmp(bufp, "*") || !strcmp(bufp, "random"))) {
randmonst = TRUE; randmonst = TRUE;
break; break;
} }
#endif #endif
monclass = def_char_to_monclass(*bufp); which = name_to_mon(bufp);
if (monclass != MAXMCLASSES) break; /* got one */ if (which >= LOW_PM) break; /* got one */
} else { monclass = name_to_monclass(bufp, &which);
which = name_to_mon(bufp); if (which >= LOW_PM) {
if (which >= LOW_PM) break; /* got one */ monclass = MAXMCLASSES; /* matters below */
break;
} else if (monclass > 0) {
which = urole.malenum; /* reset from NON_PM */
break;
} }
/* no good; try again... */ /* no good; try again... */
pline("I've never heard of such monsters."); pline("I've never heard of such monsters.");
} while (++tries < 5); } while (--tryct > 0);
if (tries == 5) { if (!tryct) {
pline(thats_enough_tries); pline(thats_enough_tries);
} else { } else {
if (!randmonst) { if (!randmonst) {