AttackRolledEvent
One attack roll and everything that went into it.
Full documentation: AttackRolledEvent. Wire type: attack_rolled.
Default visibility: player
Message codes: combat.attack.auto_hit, combat.attack.hit, combat.attack.missed
JSON Schema
{
"$defs": {
"Visibility": {
"description": "Who is allowed to see an event.\n\nEvery event has one of these two values, and the split exists because B/X keeps some rolls behind the\nreferee's screen. Filter a log on it before you show anything to a player, or call\n`GameSession.view`, which builds the player's and the referee's\nviews for you. A narrator playing referee reads both.\n\nThe values are the lowercase strings and they serialize into every event, so a renamed value is a\n`schema_version` bump.\n\nExamples:\n ```python\n from osrlib.core.events import DamageDealtEvent, HitPointsReportedEvent, Visibility\n\n log = [\n DamageDealtEvent(target_id=\"monster-0001\", amount=5),\n HitPointsReportedEvent(target_id=\"monster-0001\", current_hp=2, max_hp=7),\n ]\n shown = [event.code for event in log if event.visibility is Visibility.PLAYER]\n assert shown == [\"combat.damage.dealt\"] # the goblin's remaining hit points stay hidden\n ```",
"enum": [
"player",
"referee"
],
"title": "Visibility",
"type": "string"
}
},
"description": "One attack roll and everything that went into it.\n\n`attack_roll` emits one of these for every swing, and\n`resolve_attack` passes it on with the damage that followed. Read `code`\nfor the outcome. The numeric fields are there so you can show the arithmetic.\n\nAn attack against a helpless target needs no roll, and then `roll`, `total`, and `required` are all `None`.",
"properties": {
"code": {
"title": "Code",
"type": "string",
"description": "What happened, as two or more lowercase segments separated by dots and namespaced by subsystem, like\n`combat.attack.hit`. This is what you branch on and what\n`format_message` looks up. Anything else raises a validation error."
},
"visibility": {
"$ref": "#/$defs/Visibility",
"default": "player",
"description": "Player visibility: attack rolls happen in the open."
},
"event_type": {
"const": "attack_rolled",
"default": "attack_rolled",
"title": "Event Type",
"type": "string",
"description": "The wire name for this event type."
},
"attacker_id": {
"title": "Attacker Id",
"type": "string",
"description": "The entity id of whoever attacked."
},
"defender_id": {
"title": "Defender Id",
"type": "string",
"description": "The entity id of whoever was attacked."
},
"attack_name": {
"title": "Attack Name",
"type": "string",
"description": "What was attacked with, by name: a weapon, a monster's natural attack, or `\"unarmed\"`."
},
"roll": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Roll",
"description": "The d20 as it landed, before modifiers. `None` on an automatic hit."
},
"modifier": {
"default": 0,
"title": "Modifier",
"type": "integer",
"description": "Everything added to the roll: strength, range band, magic, spells, the situation you attested."
},
"total": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Total",
"description": "The roll plus the modifier, which is the number compared against `required`. `None` on an automatic\nhit."
},
"required": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Required",
"description": "The total the attacker needed for a hit, worked out from its attack table and the defender's armour\nclass. `None` on an automatic hit."
},
"defender_ac": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Defender Ac",
"description": "The defender's armour class as the attack saw it, after shields, spells, and the situation."
},
"natural": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Natural",
"description": "Set to 1 or 20 when the unmodified d20 settled the outcome against what the total said, since a natural\n20 always hits and a natural 1 always misses. `None` otherwise, including when the natural roll and the total\nagreed."
}
},
"required": [
"code",
"attacker_id",
"defender_id",
"attack_name"
],
"title": "AttackRolledEvent",
"type": "object"
}