Difference between revisions of "User:Ion frigate/difficulty"

From NetHackWiki
Jump to navigation Jump to search
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
==From makedefs.c for SLASH'EM==
+
{{monster
/*
+
|name = small abomination
ranged_attk(ptr) /* returns TRUE if monster can attack at range */
+
|tile = [[Image:Xan.png]]
register struct permonst *ptr;
+
|symbol = {{purple|x}}
{
+
|attacks = claw 11d2, claw 11d2
register int i, j;
+
|level = 3
register int atk_mask = (1<<AT_BREA) | (1<<AT_SPIT) | (1<<AT_GAZE);
+
|AC = -15
 
+
|MR = 100
for(i = 0; i < NATTK; i++) {
+
|speed = 30
    if((j=ptr->mattk[i].aatyp) >= AT_WEAP || (atk_mask & (1<<j)))
+
|difficulty = 5
return TRUE;
+
|align = 0
}
+
|experience = 80
 
+
|resistances = [[fire]], [[cold]], [[sleep]], [[poison]], [[shock]], [[death ray|death magic]], [[drain life]], [[disintegration]], [[stoning]]
return(FALSE);
+
|resistances conveyed = none
}
+
|nutr = 0
 
+
|weight = 5
/* This routine is designed to return an integer value which represents
+
|size = Tiny
* an approximation of monster strength. It uses a similar method of
+
|frequency = Common
* determination as "experience()" to arrive at the strength.
+
|genocidable = No
*/
+
|attributes = {{attributes|A small abomination|=|nocorpse = 1|regen = 1|seeinvis = 1|hostile = 1|stalk = 1}}
static int
+
}}
mstrength(ptr)
+
From source code found [http://www.koders.com/cpp/fid53CE3B8D7938E4B74C71CD552F97FB03DEAFA430.aspx?s=game#L1421 here], I infer that, in SLASH'EM, difficulty is computed as follows:
struct permonst *ptr;
+
We have an integer, n
{
+
===Generation in groups===
int i, tmp2, n, tmp = ptr->mlevel;
+
*+1 for small groups
 
+
*+2 for large groups
if(tmp > 49) /* special fixed hp monster */
+
*+4 for very large groups
    tmp = 2*(tmp - 6) / 4;
+
===Ranged attacks===
 
+
*+1 for any gaze, spit, breath, weapon or magic attack (all can be ranged)
/* For creation in groups */
+
===Armor class===
n = (!!(ptr->geno & G_SGROUP));
+
*+1 for base AC < 4
n += (!!(ptr->geno & G_LGROUP)) << 1;
+
*+1 for base AC < 0 (these two combine)
n += (!!(ptr->geno & G_VLGROUP)) << 2;
+
===Speed===
 
+
*+1 if speed >= 18
/* For ranged attacks */
+
===Attacks===
if (ranged_attk(ptr)) n++;
+
For each attack:
 
+
*+1 if it is not passive
/* For higher ac values */
+
*+1 if it is a magic (AT_MAGC) attack
n += (ptr->ac < 4);
+
*+1 if it is a weapon (AT_WEAP) attack, and monster has the M2_STRONG flag
n += (ptr->ac < 0);
+
*+2 if it is poisonous (AD_DRST, AD_DRDX, AD_DRCO), drain life (AD_DRLI), stoning (AD_STON) or lycanthropy (AD_WERE)
 
+
*+1 if it is not one of the immediate above, and is also not pure physical damage (AD_PHYS)
/* For very fast monsters */
+
*+1 if it can do 24 or more "damage" (specifically, if it is ndm, if nm > 23); does not have to be physical damage
n += (ptr->mmove >= 18);
+
===Nastiness===
 
+
*+5 if it has the M2_NASTY flag (note that this does not seem to be true for vanilla NetHack, from checking monsters both with and without it, this formula matches for those without, but is off by the correct amount for those with that flag to mean that it is not factored into its calculations)
/* 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);
+
==Difficulty==
}
+
Then, we have tmp; if mlevel <= 49, tmp = mlevel; otherwise tmp = .5 * (mlevel - 6)
*/
+
Now, what is difficulty?
If I read this correctly, it goes, with n = 0
+
*If n = 0, difficulty is tmp - 1
+1 for small groups
+
*If 0 < n < 6, difficulty is tmp + 1 + n/3
+2 for large groups
+
*If n >= 6, difficulty is tmp + n/2
+4 for very large groups (do they exist?)
+
Rounding down for integer division
+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 (can do 24 or more damage)
 
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
 

Latest revision as of 21:59, 27 July 2010

From source code found here, I infer that, in SLASH'EM, difficulty is computed as follows: We have an integer, n

Generation in groups

  • +1 for small groups
  • +2 for large groups
  • +4 for very large groups

Ranged attacks

  • +1 for any gaze, spit, breath, weapon or magic attack (all can be ranged)

Armor class

  • +1 for base AC < 4
  • +1 for base AC < 0 (these two combine)

Speed

  • +1 if speed >= 18

Attacks

For each attack:

  • +1 if it is not passive
  • +1 if it is a magic (AT_MAGC) attack
  • +1 if it is a weapon (AT_WEAP) attack, and monster has the M2_STRONG flag
  • +2 if it is poisonous (AD_DRST, AD_DRDX, AD_DRCO), drain life (AD_DRLI), stoning (AD_STON) or lycanthropy (AD_WERE)
  • +1 if it is not one of the immediate above, and is also not pure physical damage (AD_PHYS)
  • +1 if it can do 24 or more "damage" (specifically, if it is ndm, if nm > 23); does not have to be physical damage

Nastiness

  • +5 if it has the M2_NASTY flag (note that this does not seem to be true for vanilla NetHack, from checking monsters both with and without it, this formula matches for those without, but is off by the correct amount for those with that flag to mean that it is not factored into its calculations)

Difficulty

Then, we have tmp; if mlevel <= 49, tmp = mlevel; otherwise tmp = .5 * (mlevel - 6) Now, what is difficulty?

  • If n = 0, difficulty is tmp - 1
  • If 0 < n < 6, difficulty is tmp + 1 + n/3
  • If n >= 6, difficulty is tmp + n/2

Rounding down for integer division