Skip to main content
Glama

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

NameRequiredDescriptionDefault
areaNo
ladderNo
targetNo
defenseNo
monsterNo
playersNo
versionNo
directionNoplayer_vs_monster
difficultyNohell
monster_typeNonormal
attack_ratingNo
attacker_levelNo
defender_levelNo
attack_rating_percentNo

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.9/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are supplied, so the description carries the full burden and does so thoroughly: it discloses data sources (1.10f D2MOO, 1.14d executable, 1.13c assumed, 1.09 rounding unverified, Resurrected unread) and the exact search-range limits where arithmetic wraps (~21M, or 1,048,576 with attack_rating_percent). For a mutation-free calculation tool that is more transparency than required.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the formula and purpose before details, and nearly every clause is substantive rather than filler. However, the writing is dense and run-on (long parentheticals, semicolon-heavy sentences), which hurts scannability for an agent parsing the guidance quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given an output schema exists, return-value detail is appropriately omitted ('the answer shows each step'). The description still covers version selection, both directions, override precedence, and edge cases like the search-bound behavior, making it complete for a complex 14-parameter tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0% across 14 parameters, yet the description defines every one: attack_rating, defense, attacker_level, defender_level, direction, target, attack_rating_percent, monster, difficulty, players, area, monster_type, ladder and version, including override precedence (defense/defender_level override the monster's) and default behavior for version.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The opening sentence names a specific quantity (chance an attack hits, before block/dodge/avoid) and gives the exact formula and clamping range, so an agent knows precisely what computation it gets. It also anchors the tool among siblings by referencing monster_stats for the table-driven path, clearly separating the calc from the data-lookup tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly lays out two usage modes ('by numbers' vs 'against a monster'), documents the direction parameter's two values and what to supply for each, and explains the target-driven search versus direct computation. It also states what is NOT applied (auras, curses, ITD, target defense -x%) and the remedy ('change the defence or rating you give instead'), leaving little to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.