Skip to content

DamageDealtEvent

Damage landed on a creature.

Full documentation: DamageDealtEvent. Wire type: damage_dealt.

Default visibility: player

Message codes: combat.damage.dealt

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": "Damage landed on a creature.\n\n`deal_damage` emits one of these for every packet of damage, whether it\ncame from a weapon, a spell, or an effect like burning oil.\n\nIt says how much was dealt and never how much the target has left, because B/X hides monster hit points. The\nremaining total rides the referee-visible\n`HitPointsReportedEvent` that follows it.",
  "properties": {
    "code": {
      "default": "combat.damage.dealt",
      "title": "Code",
      "type": "string",
      "description": "Fixed at `combat.damage.dealt`."
    },
    "visibility": {
      "$ref": "#/$defs/Visibility",
      "default": "player",
      "description": "Player visibility: how hard something was hit is plain to see."
    },
    "event_type": {
      "const": "damage_dealt",
      "default": "damage_dealt",
      "title": "Event Type",
      "type": "string",
      "description": "The wire name for this event type."
    },
    "target_id": {
      "title": "Target Id",
      "type": "string",
      "description": "The entity id of whoever took the damage."
    },
    "attacker_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Attacker Id",
      "description": "The entity id of whoever dealt it, or `None` when nothing did: a fall, a trap, a hazard."
    },
    "amount": {
      "title": "Amount",
      "type": "integer",
      "description": "The hit points actually taken off, after every resistance and reduction."
    },
    "rolls": {
      "default": [],
      "items": {
        "type": "integer"
      },
      "title": "Rolls",
      "type": "array",
      "description": "The individual dice the damage was rolled on, before modifiers. Empty for damage that was not rolled."
    },
    "keys": {
      "default": [],
      "items": {
        "type": "string"
      },
      "title": "Keys",
      "type": "array",
      "description": "What the damage presented to the target's defenses: material and enchantment keys like `silver`,\n`magic`, or `holy`, plus the energy element when there was one."
    },
    "non_regenerable": {
      "default": false,
      "title": "Non Regenerable",
      "type": "boolean",
      "description": "True when this damage cannot be regenerated away, which happens when its element is one the target's\nregeneration is blocked by, as fire and acid are for a troll."
    }
  },
  "required": [
    "target_id",
    "amount"
  ],
  "title": "DamageDealtEvent",
  "type": "object"
}