User:Ion frigate/difficulty

From NetHackWiki
< User:Ion frigate
Revision as of 23:52, 31 December 2009 by Ion frigate (talk | contribs) (Created page with '==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 …')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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<<AT_BREA) | (1<<AT_SPIT) | (1<<AT_GAZE);

for(i = 0; i < NATTK; i++) { if((j=ptr->mattk[i].aatyp) >= AT_WEAP || (atk_mask & (1<<j))) return TRUE; }

return(FALSE); }

/* This routine is designed to return an integer value which represents

* an approximation of monster strength.  It uses a similar method of
* determination as "experience()" to arrive at the strength.
*/

static int mstrength(ptr) struct permonst *ptr; { int i, tmp2, n, tmp = ptr->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<n<6, difficulty is monster's level + 1 + n/3 Exception; substitute .5*(mlevel-6) for mlevel if mlevel > 49 - only would be relevant to high-level demons, no randomly generated monster has a level greater than 39