Skip to content

DamageDealtEvent

Damage dealt to a creature.

Full documentation: DamageDealtEvent. Wire type: damage_dealt.

Default visibility: player

Message codes: combat.damage.dealt

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": "Damage dealt to a creature.\n\n`deal_damage` reports one of these each time it deals damage, whether the\ndamage came from a weapon, a spell, or an effect like burning oil.\n\nIt reports how much damage was dealt and never how many hit points the target has left, because in B/X only\nthe referee sees monster hit points. The hit points left are in the\n`HitPointsReportedEvent` that follows it, which only the referee\nsees.",
  "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: everyone sees how hard a creature was hit."
    },
    "event_type": {
      "const": "damage_dealt",
      "default": "damage_dealt",
      "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 that took the damage."
    },
    "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, as for a fall or a trap."
    },
    "amount": {
      "title": "Amount",
      "type": "integer",
      "description": "The hit points the target lost, after all its reductions."
    },
    "rolls": {
      "default": [],
      "items": {
        "type": "integer"
      },
      "title": "Rolls",
      "type": "array",
      "description": "Each damage die as rolled, before modifiers. Empty for damage that wasn't rolled, like a dragon's breath."
    },
    "keys": {
      "default": [],
      "items": {
        "type": "string"
      },
      "title": "Keys",
      "type": "array",
      "description": "The keys of the damage that the target's defenses check: keys like `silver`, `magic`, or `holy`, then the\ndamage's element, like `fire`, when it had one."
    },
    "non_regenerable": {
      "default": false,
      "title": "Non Regenerable",
      "type": "boolean",
      "description": "True when the target regenerates and this damage's element stops its regeneration.\n\nFire and acid do that to a troll, and to a character who wears a ring of regeneration. The target's regeneration\ncan't heal this damage. Once enough of it adds up, a troll stays dead."
    }
  },
  "required": [
    "target_id",
    "amount"
  ],
  "title": "DamageDealtEvent",
  "type": "object"
}