SpellCastEvent
A spell was cast, from memory or from a scroll.
Full documentation: SpellCastEvent. Wire type: spell_cast.
Default visibility: player
Message codes: magic.cast.cast, magic.cast.no_effect
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 spell was cast, from memory or from a scroll.\n\n`cast_spell` reports this when a caster casts a memorized spell, which uses\nup the memorized copy, and `cast_from_scroll` reports it when a caster\nreads a spell from a scroll. What the spell did comes in the events after this one: saving throws, damage,\nconditions, effects, healing, and deaths.\n\nWhen a cast affects no one, the event has the code `magic.cast.no_effect`, and the spell is still used up. Refusing\nthe cast instead would show the player, at no cost, which targets the spell could affect, and the B/X rules don't\nreveal that.",
"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: everyone hears a spell cast aloud."
},
"event_type": {
"const": "spell_cast",
"default": "spell_cast",
"title": "Event Type",
"type": "string",
"description": "The fixed string that identifies this event class in a serialized event."
},
"caster_id": {
"title": "Caster Id",
"type": "string",
"description": "The entity id of the caster."
},
"spell_id": {
"title": "Spell Id",
"type": "string",
"description": "The spell's content id, like `\"magic_missile\"`."
},
"mode": {
"title": "Mode",
"type": "string",
"description": "The key of the spell mode that was cast. For a spell with more than one mode, like one that can harm or\nheal, it's the mode the caster chose."
},
"reversed": {
"default": false,
"title": "Reversed",
"type": "boolean",
"description": "True when the spell was cast in its reversed form."
},
"target_ids": {
"default": [],
"items": {
"type": "string"
},
"title": "Target Ids",
"type": "array",
"description": "The entity ids or locations the caster aimed the spell at. Empty for a spell with no target."
},
"manual": {
"default": false,
"title": "Manual",
"type": "boolean",
"description": "True when osrlib didn't resolve the spell's effect, because the rules leave that mode to the referee. The\ncopy is used up, and you play out the outcome from the spell's text."
}
},
"required": [
"code",
"caster_id",
"spell_id",
"mode"
],
"title": "SpellCastEvent",
"type": "object"
}