Skip to content

LevelDrainedEvent

An undead creature's touch has taken levels, or killed its victim.

Full documentation: LevelDrainedEvent. Wire type: level_drained.

Default visibility: player

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

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": "An undead creature's touch has taken levels, or killed its victim.\n\n`drain_levels` reports this for a character, and\n`drain_monster_hd` for a monster, which loses Hit Dice instead of\nlevels.\n\nWhen the victim has nothing left to lose, at level 1 or 1 Hit Die, the drain kills it instead. Then the code\nis `combat.drain.slain`, and a `DeathEvent` follows. The killing level\ncounts as lost, so when a spectre, which drains two levels, kills a level-2 fighter, the event shows two levels\nlost.",
  "properties": {
    "code": {
      "title": "Code",
      "type": "string",
      "description": "What happened, like `combat.attack.hit`: two or more lowercase parts separated by dots. The first part is\nthe area of the rules the event comes from, like `combat` or `magic`.\n\nBranch on it, and pass the event to `format_message` to turn it into English.\nBuilding an event with a code in any other format raises a pydantic `ValidationError`."
    },
    "visibility": {
      "$ref": "#/$defs/Visibility",
      "default": "player",
      "description": "Player visibility: the players know when a level is lost."
    },
    "event_type": {
      "const": "level_drained",
      "default": "level_drained",
      "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 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": "The victim's level, or Hit Dice, after the drain. 0 when the drain killed it."
    },
    "hp_lost": {
      "title": "Hp Lost",
      "type": "integer",
      "description": "How far the drain lowered the victim's maximum hit points: the maximum before the drain less the maximum\nafter it.\n\nWhile the victim has a level or a Hit Die left, maximum hit points don't drop below 1. So this can be less than\nthe hit points rolled for the lost levels. For example, a level-2 character with 3 maximum hit points who rolls a\n7 for the lost level is left with 1, so `hp_lost` is 2. A drain that kills doesn't lower the maximum for the\nlevel that kills, so `hp_lost` counts only the levels lost before that one."
    },
    "xp_after": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Xp After",
      "description": "The character's experience points after the drain. Depending on the draining monster, they're either\nhalfway between the old and new levels' thresholds, or at the new level's threshold. `None` for a monster, whose Hit\nDice 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": "What the rules say becomes of a character this undead creature kills, like rising as a wight in 1d4\ndays under the control of its killer. osrlib kills the victim, and playing out what it becomes is up to you.\n\nIt's set only on a `combat.drain.slain` event for a character, because it describes a victim the drain killed.\nIt's `None` on every `combat.drain.drained` event, for a monster victim, and when the undead creature's rules\nsay nothing about it."
    }
  },
  "required": [
    "code",
    "target_id",
    "levels_lost",
    "new_level",
    "hp_lost"
  ],
  "title": "LevelDrainedEvent",
  "type": "object"
}