# How do monsters in NetHack attack?

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? 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
• 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? 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
• Presumably the monster's to-hit total is determined in the same way as the player's. Commented Apr 25 at 9:23

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.