[rec.games.hack] Fix to

gil@svax.cs.cornell.edu (Gil Neiger) (10/16/87)

Here is the beginning of my hack.makemon.c; modifying nethack's
makemon.c in a similar way should fix the standard "makemon" panic.
However, this will not generate bats if KOPS is turned on.  To fix
this, in the file monst.c the monster "Keystone Kop" (bracketed by
"#ifdef KOPS" and "#endif KOPS") should be make the FIRST monster in
the array permonst; the monster "Kobold" (bracketed by "#ifndef KOPS"
and "#endif KOPS") should be left where it is.


					- Gil
====================================
/* $Header: hack.makemon.c,v 2.3 87/05/29 10:18:36 gil Exp $ */

/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* hack.makemon.c - version 1.0.2 */

#include	"hack.h"
extern char fut_geno[];
extern char *index();
extern struct obj *mkobj_at();
struct monst zeromonst;

/*
 * called with [x,y] = coordinates;
 *	[0,0] means anyplace
 *	[u.ux,u.uy] means: call mnexto (if !in_mklev)
 *
 *	In case we make an Orc or killer bee, we make an entire horde (swarm);
 *	note that in this case we return only one of them (the one at [x,y]).
 */
struct monst *
makemon(ptr,x,y)
register struct permonst *ptr;
{
	register struct monst *mtmp;
	register tmp, ct;
	boolean anything = (!ptr);
#ifdef KOPS
	int kopsoffset = 1;
#else KOPS
	int kopsoffset = 0;
#endif KOPS

	if(x != 0 || y != 0) if(m_at(x,y)) return((struct monst *) 0);
	if(ptr){
		if(index(fut_geno, ptr->mlet)) return((struct monst *) 0);
	} else {
		ct = CMNUM - strlen(fut_geno);
		if(index(fut_geno, 'm')) ct++;  /* make only 1 minotaur */
		if(index(fut_geno, '@')) ct++;
		if(ct <= 0) return(0); 		  /* no more monsters! */
		tmp = 7;		/* changed 3/31/87 as per mods */

		tmp -= kopsoffset;
#ifdef ROCKMOLE
                if(dlevel<4)tmp--;
#endif ROCKMOLE
                tmp = rn2(ct*dlevel/24 + tmp);
		if(tmp < dlevel - 4) tmp = rn2(ct*dlevel/24 + 12);
		if(tmp >= ct - kopsoffset)
			tmp = rn1(ct - ct/2, ct/2 - kopsoffset);
		ct = kopsoffset;

		for(; ct < CMNUM; ct++){
			ptr = &mons[ct];
			if(index(fut_geno, ptr->mlet))
				continue;
			if(!tmp--) goto gotmon;
		}
		impossible("Couldn't make a monster");
		return((struct monst *) 0);
	}
gotmon:
	...