Skip to content

LevelDrainedEvent

An undead creature's touch has taken levels, or taken everything.

Full documentation: LevelDrainedEvent. Wire type: level_drained.

Default visibility: player

Message codes: combat.drain.drained, combat.drain.slain

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": "An undead creature's touch has taken levels, or taken everything.\n\n`drain_levels` emits this for a character and\n`drain_monster_hd` for a monster, whose Hit Dice drain the same way.\n\nWhen the victim has nothing left to lose, at level 1 or one Hit Die, the drain kills instead, the code says\nslain, and a `DeathEvent` follows. The killing level counts as lost, so a\nspectre draining a level-2 fighter reports two levels gone.",
  "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: losing a level is the players' to know."
    },
    "event_type": {
      "const": "level_drained",
      "default": "level_drained",
      "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 the victim."
    },
    "levels_lost": {
      "title": "Levels Lost",
      "type": "integer",
      "description": "How many levels, or Hit Dice, the drain took."
    },
    "new_level": {
      "title": "New Level",
      "type": "integer",
      "description": "What the victim is now, and 0 when the drain killed it."
    },
    "hp_lost": {
      "title": "Hp Lost",
      "type": "integer",
      "description": "The maximum hit points that went with the levels."
    },
    "xp_after": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Xp After",
      "description": "The character's experience points after the drain, set by the draining monster's own experience policy:\nhalfway between the old and new level thresholds, or the new level's minimum. `None` for a monster, whose\nHit Dice are worth no experience points, and for a victim the drain killed."
    },
    "spawn_consequence": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Spawn Consequence",
      "description": "The printed consequence of dying to this particular undead, like becoming a wight in 1d4 days under the\ncontrol of the one that killed you. osrlib kills the victim, and turning them into something is yours to\nplay. `None` when the source has no such consequence."
    }
  },
  "required": [
    "code",
    "target_id",
    "levels_lost",
    "new_level",
    "hp_lost"
  ],
  "title": "LevelDrainedEvent",
  "type": "object"
}