hit_chance
Calculates Diablo II attack hit chance before block, dodge, or avoid from attack rating, defense, and levels, or monster data; also finds the attack rating or defense needed to reach a target percent.
Instructions
The chance an attack hits, before block, dodge or avoid: 200% x AR / (AR + defence) x attacker level / (attacker level + defender level), worked in the game's own integer order (each step truncates, in 32 bits) and held to 5-95%. Read for this: the 1.10f source (D2MOO) and the 1.14d executable, which agree; 1.13c is assumed the same. 1.09 and earlier use the published formula, with the rounding not checked; Resurrected's code wasn't read. Two ways to use it: By numbers: attack_rating, defense, attacker_level and defender_level; the answer shows each step. Against a monster: monster (a MonStats Id or name, or a super unique), with difficulty, players, area, monster_type (normal, champion, unique, minion) and ladder as monster_stats takes them, gives its level and defence from the version's tables (version: default the server's). Then give attack_rating and attacker_level (your character level); defense or defender_level override the monster's. target: a whole percent. For player_vs_monster the answer is the smallest attack rating that reaches it (found by search on the exact integer formula, and the true minimum in the range searched: ratings up to about 21 million, or 1,048,576 with an attack_rating_percent, past which the game's arithmetic wraps or rounds differently; attack_rating may be left out), or says that nothing in that range reaches it. For monster_vs_player (direction) it is the smallest defence that keeps the monster's chance at or below target. direction: 'player_vs_monster' (default), or 'monster_vs_player': give the player's defense and defender_level (their character level); the monster's attack ratings come from its attacks as monster_stats lists them (a champion's attack rating bonus included), unless attack_rating is given. attack_rating_percent: percent added to the rating first, as the game does (0 if the figure already includes it). Not applied (change the defence or rating you give instead): auras and curses on the target; the defender's armorclass_vs_hth / armorclass_vs_missile bonus on top of its sheet defence; 'ignore target defense' (zeroes a monster's defence, but not a unique, super unique, boss or hireling's) and 'target defense -x%' (x% off, halved against players, bosses, super uniques and hirelings, in full against other monsters); unique monsters' modifiers. A monster's tables are only needed with monster; plain numbers work without any. State the version and the notes.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "hit_chance"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| area | No | ||
| ladder | No | ||
| target | No | ||
| defense | No | ||
| monster | No | ||
| players | No | ||
| version | No | ||
| direction | No | player_vs_monster | |
| difficulty | No | hell | |
| monster_type | No | normal | |
| attack_rating | No | ||
| attacker_level | No | ||
| defender_level | No | ||
| attack_rating_percent | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |