User:Ion frigate/difficulty

From makedefs.c for SLASH'EM
ranged_attk(ptr)	/* returns TRUE if monster can attack at range */ register struct permonst *ptr; {	register int	i, j;	register int atk_mask = (1<mattk[i].aatyp) >= AT_WEAP || (atk_mask & (1<mlevel;

if(tmp > 49)		/* special fixed hp monster */ tmp = 2*(tmp - 6) / 4;

/*	For creation in groups */ n = (!!(ptr->geno & G_SGROUP)); n += (!!(ptr->geno & G_LGROUP)) << 1; n += (!!(ptr->geno & G_VLGROUP)) << 2;

/*	For ranged attacks */ if (ranged_attk(ptr)) n++;

/*	For higher ac values */ n += (ptr->ac < 4); n += (ptr->ac < 0);

/*	For very fast monsters */ n += (ptr->mmove >= 18);

/*	For each attack and "special" attack */ for(i = 0; i < NATTK; i++) {

tmp2 = ptr->mattk[i].aatyp; n += (tmp2 > 0); n += (tmp2 == AT_MAGC); n += (tmp2 == AT_WEAP && (ptr->mflags2 & M2_STRONG)); }

/*	For each "special" damage type */ for(i = 0; i < NATTK; i++) {

tmp2 = ptr->mattk[i].adtyp; if ((tmp2 == AD_DRLI) || (tmp2 == AD_STON) || (tmp2 == AD_DRST)		|| (tmp2 == AD_DRDX) || (tmp2 == AD_DRCO) || (tmp2 == AD_WERE)) n += 2; else if (strcmp(ptr->mname, "grid bug")) n += (tmp2 != AD_PHYS); n += ((int) (ptr->mattk[i].damd * ptr->mattk[i].damn) > 23); }	/* tom's nasties */ if (extra_nasty(ptr)) n += 5;

/*	Leprechauns are special cases. They have many hit dice so they can hit and are hard to kill, but they don't really do much damage. */	if (!strcmp(ptr->mname, "leprechaun")) n -= 2;

/*	Finally, adjust the monster level 0 <= n <= 24 (approx.) */ if(n == 0) tmp--; else if(n >= 6) tmp += ( n / 2 ); else tmp += ( n / 3 + 1);

return((tmp >= 0) ? tmp : 0); }

If I read this correctly, it goes, with n = 0 +1 for small groups +1 for large groups +1 for very large groups (do they exist?) +1 for ranged (breath, spit, gaze) attack +1 for AC < 4 +1 for AC < 0 +1 for speed > 18 For each attack: +1 if it exists +1 if it is a spellcasting attack +1 if it is a weapon attack and the monster is strong +2 if it is poison (dexterity, const. or strength), drain life, stoning or lycanthrope +1 if it is read as kdx, if kx > 23 Then +5 for extra-nasty monsters (M2_NASTY) If n=0, difficulty is monster's level - 1 if n>=6, difficulty is monster's level + n/2 if 0 49 - only would be relevant to high-level demons, no randomly generated monster has a level greater than 39