[comp.sources.d] nethack - panic in makemon

mjr@osiris.UUCP (Marcus J. Ranum) (08/15/87)

	Okay, so there I am in hell, level 30, just about to cruise upstairs
	to get my potions of levitation and confusion - I go up the stairs and:
	"ERROR - panic in makemon() !"
	"do you want your posessions identified ?"

	Could someone more familiar with the hack code look into this ??
	Ain't nothing can kill 290Hit Points, -4AC, and +8katana like a
	damn panic...  Any they move so FAST!

--mjr();
-- 
If they think you're crude, go technical; if they think you're technical,
go crude. I'm a very technical boy. So I get as crude as possible. These
days, though, you have to be pretty technical before you can even aspire
to crudeness...			         -Johnny Mnemonic

kimcm@ambush.UUCP (08/17/87)

In article <1348@osiris.UUCP> mjr@osiris.UUCP (Marcus J. Ranum) writes:

>	Okay, so there I am in hell, level 30, just about to cruise upstairs
>	to get my potions of levitation and confusion - I go up the stairs and:
>	"ERROR - panic in makemon() !"
>	"do you want your posessions identified ?"

>	Could someone more familiar with the hack code look into this ??
>	Ain't nothing can kill 290Hit Points, -4AC, and +8katana like a
>	damn panic...  Any they move so FAST!

Below is an intercept from the makemon.c file with the changes I've made
to prevent the panic. It is somewhat obscure code, but what seems to happen
is that it runs dry of guessing and generates a panic instead of just not
generating a monster. The chances of this increases if you have genocided
a lot of monsters.

					Kim Chr. Madsen.

struct monst *makemon(ptr,x,y)
int x,y;
register struct permonst *ptr;
{
	register struct monst	*mtmp;
	register int		tmp, ct;
	boolean			anything = (!ptr);

	if(x != 0 || y != 0) {
		if(m_at(x,y))			/* Already monster at loc */
			return((struct monst *) 0); 
	}
	if(ptr){
		if(index(fut_geno, ptr->mlet))	/* Monster Genocided? */
			return((struct monst *) 0);
	} else {				/* Find a monster */
		ct = CMNUM - strlen(fut_geno);
		if(index(fut_geno, 'm')) ct++;  /* make only 1 minotaur */
		if(index(fut_geno, '@')) ct++;	/* Don't make humans */
		if(ct <= 0)			/* No more monsters! */
			return((struct monst *) 0);
		tmp = 7;
#ifdef KOPS
		tmp--;
#endif
#ifdef ROCKMOLE
		if(dlevel<4) tmp--;
#endif
		tmp = rn2(ct*dlevel/24 + 7);
		if(tmp < dlevel - 4) tmp = rn2(ct*dlevel/24 + 12);
		if(tmp >= ct) tmp = rn1(ct - ct/2, ct/2);
		ct = 0;
#ifdef KOPS
		ct++;
#endif
		while(!(tmp + 1 <= CMNUM - ct))	tmp--;
		for (; ct < CMNUM; ct++) {
			ptr = &mons[ct];
#ifdef KOPS
			if (ptr->mlet == 'K') {	/* Don't make random Kops */
				tmp--;
				continue;
			}
#endif
			if(index(fut_geno, ptr->mlet)) /* Monster Genocided */
				continue;
			if(tmp-- <= 0) goto gotmon;
		}
/*		panic("makemon?");		/* Don't just panic */
		return((struct monst *) 0);	/* but don't make a monster */
	}