There is much information about how the player attacks (or attempts to attack) in the weapon spoiler. But there is no information on how monsters attack.

How is the monsters value of to-Hit* calculated?

*) alias 'chance to hit' or 'toHit'

The damage and effects of successful hits is described in the monster spoiler from the spoiler page.

  • The page you have linked seems pretty comprehensive to me. What exactly is it that you are asking for?
    – OrangeDog
    Commented Apr 25 at 8:57
  • it is very clear how the player makes an attack, but when it is the monsters turn, what is the mosnters toHit chance? i only see explanation about the players toHit Commented Apr 25 at 9:02
  • 1
    None of them say toHit anywhere, so I assume you mean "chance to hit". Presumably you also want to know how it chooses which attack to use when there are multiple available?
    – OrangeDog
    Commented Apr 25 at 9:05
  • the weapon.txt dokument is not so strict when using the terms chance to hit and toHit since the core mecahinc is explained on line 512: A die from 1 to 20 is rolled and compared to the to-hit total. If the die roll is less than the to-hit total (or equal when throwing or kicking), you hit the monster and inflict damage as described below; whereas (as you mentioned) on the headline (line 389) it is called Calculating the chance to hit Commented Apr 25 at 9:15
  • 1
    Presumably the monster's to-hit total is determined in the same way as the player's.
    – OrangeDog
    Commented Apr 25 at 9:23

1 Answer 1


The to-hit formula is covered in detail on the wiki's Armor Class page. The source ref for much of this is in mhitu.c.

I'll summarize the to-hit; there are a lot of special cases based on visibility, attack type, situation, and consecutive monster attacks.

The basic formula is: 10 + AC + Level, where "AC" is the player's current AC (i.e. Armor Class - it is lowered primarily by equipping armor; lower is better), and Level is the monster level of the attacker. This value is compared against a random number between 1 and 20; if the roll is lower than this formula, the attack hits.

If the player's AC is below 0, it is instead treated as a random number between -1 and their displayed AC. Lower AC is always better, but even at -100 AC it is possible to get a very unlucky roll and still get hit.

The wiki includes tables showing statistically expected damage for differing armor class values from various attackers; this can give a general idea of how much AC protects you, but this also includes the damage resistance from having negative AC.

  • 1
    i didn't expect people to remember nethack - thanks Commented Apr 26 at 5:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .