Skip to content

DamageAbsorbedEvent

A hit that did nothing, because the target can't be harmed by what hit it.

Full documentation: DamageAbsorbedEvent. Wire type: damage_absorbed.

Default visibility: player

Message codes: combat.damage.absorbed

JSON Schema

{
  "$defs": {
    "Visibility": {
      "description": "Who may see an event: the players, or only the referee.\n\nEvery event has one of these values, because in B/X the referee makes some rolls behind a screen. Filter\na log on it before you show anything to a player, or call\n`GameSession.view`, which builds the players' view and the referee's\nview for you. A narrator that plays the referee reads every event.\n\nA serialized event contains the lowercase value. The values stay fixed within a `schema_version`, the version\nstamp of the saved format.\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": "A hit that did nothing, because the target can't be harmed by what hit it.\n\nThis comes instead of a `DamageDealtEvent` when the target is immune to\nthe damage, like a creature that only silver or magic can harm hit by a steel sword, or a creature immune to\nthe breath's element. No damage was rolled. Treat it as a hit that did nothing, not as a miss.",
  "properties": {
    "code": {
      "default": "combat.damage.absorbed",
      "title": "Code",
      "type": "string",
      "description": "Fixed at `combat.damage.absorbed`."
    },
    "visibility": {
      "$ref": "#/$defs/Visibility",
      "default": "player",
      "description": "Player visibility: the players see the hit land and do nothing."
    },
    "event_type": {
      "const": "damage_absorbed",
      "default": "damage_absorbed",
      "title": "Event Type",
      "type": "string",
      "description": "The fixed string that identifies this event class in a serialized event."
    },
    "target_id": {
      "title": "Target Id",
      "type": "string",
      "description": "The entity id of the creature the attack couldn't harm."
    },
    "attacker_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Attacker Id",
      "description": "The entity id of the attacker, or `None` when there was no attacker."
    },
    "keys": {
      "default": [],
      "items": {
        "type": "string"
      },
      "title": "Keys",
      "type": "array",
      "description": "What the target's defenses absorbed: the attack's keys, like `silver` or `magic`, then its element, like `fire`.\n\nA torch and a dragon's fire breath both give `(\"fire\",)`. A steel sword against a werewolf gives `()`, because\nsteel has no key."
    }
  },
  "required": [
    "target_id"
  ],
  "title": "DamageAbsorbedEvent",
  "type": "object"
}