Migration guide: v0.7 → v0.8
v0.8.0 is a minor release of dnd5e-engine, dnd5e-srd-data and
nat20-bridge, in lockstep. Every new name and field is additive and
defaulted, and a payload a host stored under 0.7.0 (specs, intents, an
outcome, an event log) still validates on the 0.8.0 models. What a host can
notice is a handful of behaviour changes: a move takes a detour, the monster
AI's closing walk no longer shares cells, an item that casts a spell targets as
that spell, kills are credited to the creature that dealt them, and the new
KnockedOut event. The dataset does not change.
Upgrade checklist
Upgrade the three packages together: dnd5e-engine requires
dnd5e-srd-data>=0.8.0, and nat20-bridge requires both at >=0.8.0.
Then:
- Handle
KnockedOutif you matchCombatEventexhaustively: it is a new member of the closed union. It is emitted only when a host asks for a knock-out. - Handle
knock_out_not_meleeif you matchIntentRejectedError.RejectionReasonexhaustively. - Stop mirroring the old
blocked_pathrefusal. Amoveto an adjacent cell behind a wall now walks around it when it can; a host that rejects such a move up front (a move preview, a destination filter) needs the same change. - List an item that casts a spell with the spell's own targeting. A Wand of Fireballs now places Fireball's Sphere and a Wand of Magic Missiles splits its darts; a host that catalogued such items as single-target should stop.
- Read
DeathRecord.killer_idas the creature that dealt the blow, not the creature whose turn it was. - Optionally adopt the new features: party-side allies
(
EncounterMemberSpec.side), a host-chosen monster target (advance_monster_turn(target_id=...)) and knock-outs (PlayerIntent.knock_out).
Grid movement
What a host has to do
Nothing, unless it mirrors the engine's movement rules: see the checklist.
Behaviour changes
- A
movetakes a detour. When the direct step to an adjacent destination crosses a wall or cuts a blocked corner, the move takes the shortest legal route around, priced and walked like any other route: it pays the longer route's movement and can provoke opportunity attacks on the way. The refusals are now:blocked_path: the destination is adjacent, the direct step is illegal, and no route goes around;insufficient_movement: the detour costs more than the movement left; nothing moves;unreachable: no legal route, as before.
- The monster AI's closing walk honours occupancy. It passes through allies, never ends on another creature and never enters an enemy's cell. It stops on the first cell of its route that is in range with line of sight when that cell is free, else on the cheapest free cell in range; with no creature in the way the walk is the same cell for cell as before. It walks before it Dashes: it takes the Dash only when no free cell in range is within its remaining movement, and the Dash is priced to the cell it stops on, not to the target's own cell. When no free cell in range is reachable even with a Dash, it walks as far as its movement goes and stops on the last free cell; with no route to the target at all it stays where it is. An opportunity attack that stops it part-way can still leave it on an ally's cell it was passing through (BACKLOG.md).
- Walled maps are faster. Wall segments are indexed by the cells they touch, so a step or sight test reads only nearby walls. Every answer is unchanged; the cost per step no longer grows with the number of walls.
Item casts
What a host has to do
List an item whose use casts a spell with that spell's targeting (checklist item 4).
Behaviour changes
- A
use_itemwhose one resolved activity is acasttargets the way the spell it casts does. The spell's area is placed, withAreaTargeted, and catches whoever the spell would, allies and the caster included. A count that scales (Magic Missile's darts, extra targets) is read at the item's cast level: the level its extra charges buy, else the item's printed level, else the spell's own. Moretarget_idsthan the count allows is refused withCastFailed(reason="target_invalid")before any charge is spent. - A spell with an attack roll still places no area, a feature's cast is
unchanged, and an item with several activities and no
activity_idstill places nothing. - Item text that changes the spell's area or targets (the Wand of Fear's 60-foot Cone) is not honoured yet, and an item's cast is not range-gated (BACKLOG.md).
Sides
What a host has to do
Nothing, unless it seats allies. With no side on any spec a combat runs
exactly as on 0.7.
New behaviour
EncounterMemberSpec.sideis"encounter"(the default) or"party". A party-side member joinsparty_ids: foes target it, it fights foes, and every ally rule reads it as the party's. On its own turnadvance_monster_turnruns the AI for it, or the host commands it throughsubmit_player_intentas it would a summon.- It is not a character: at 0 Hit Points it dies as a monster does, and its
DeathRecord.target_kindis"npc"or"monster". A host that assumed a party-side death is always a character's must accept those kinds. - XP is divided among the surviving characters only; an ally takes no share.
residual_hpreports an ally's Hit Points with the party's. start_combatraisesValueErrorunless at least one encounter member fights on the encounter side.- A standing ally keeps the party in the fight: a combat closed after every
character has died while an ally still stands reads
ended_reason"forced"(or"flee"when every foe still in the fight has fled), not"defeat_tpk".
A host-chosen monster target
What a host has to do
Nothing: target_id=None keeps the engine's lowest-HP pick.
New behaviour
advance_monster_turn(handle, target_id=...)names the creature the acting monster attacks, or targets with a stat-block cast. The monster walks toward it, Dashing when it must, and never substitutes another creature.- The id must be in the monster's own target pool: an enemy in the initiative
order, alive, not knocked out, not its charmer. Any other id, and any id on a
summon's turn, raises
IntentRejectedError("target_invalid")before the turn starts: no die is rolled, nothing is spent, no event is emitted, and the turn stays where it was. On a character's turnnot_actor_turnis raised first. - An area action keeps the engine's own aim. With
legendary=Truethe keyword names the legendary action's target, checked beforeLegendaryActionUsed.
Knocking out a creature
What a host has to do
Handle KnockedOut and knock_out_not_melee (checklist items 1 and 2). Every
default leaves the 0.7 behaviour in place.
New behaviour
PlayerIntent.knock_out=Trueon anattackpulls every melee blow of the intent (SRD 5.2 Knocking Out a Creature). A blow that would drop a creature to 0 Hit Points leaves it at 1 instead:DamageApplied(knock_out=True),KnockedOut(target_id, attacker_id),ConditionApplied("unconscious"). It is not dying: noUnconsciousmarker and no death saves.- The intent is refused with
knock_out_not_melee, before anything is spent, unless every attack it resolves is a melee attack. Only the attack's own damage is pulled: a rider resolved by a saving throw after the hit can still kill. Other intent types ignore the flag, so a melee spell attack kills. - A creature immune to Unconscious is left at 1 Hit Point and stays conscious; a summon still leaves at 0.
- A knocked-out creature stays out until it regains Hit Points (any healing,
Regeneration included, wakes it Prone) or drops to 0 Hit Points. While out it
is in
LiveCombatView.knocked_out_ids, no monster targets it, a host may not name it astarget_id, and the end reason counts it with the dead on its side. - At
end_combat,CombatOutcome.knock_outslists the creatures still out, in the order they went down, asKnockOutRecords. A foe still knocked out is worth its XP, as a dead one is. - First aid as an action, a knock-out by a melee spell attack, and a monster-driven turn pulling its blow are not modelled (BACKLOG.md).
Kill attribution
Behaviour changes
DeathRecord.killer_idnames the creature that dealt the killing damage, whoever's turn it was. On 0.7 it named the creature whose turn it was, so an opportunity attack that killed the mover recorded nobody and a legendary action recorded whoever's turn it interrupted. A spell construct's kill names its caster; a summon's kill names the summon. A death save the dying creature fails on its own turn, and a creature that killed itself, name nobody; damage that adds the third failure names the creature that dealt it.KnockedOut.attacker_idandKnockOutRecord.attacker_idfollow the same rule.Combatant.last_damaged_byfollows the same source, so a reaction that answers damage (Hellish Rebuke) can target an opportunity attack's reactor.LiveCombatView.deathslists the deaths so far, in order, with that attribution: the recordsCombatOutcome.deathswill hold.
Smaller changes
- A character already Unconscious from an effect (a sleep) that drops to 0 Hit
Points now emits the
Unconsciousdying marker, as any character at 0 Hit Points does, and stays Unconscious when that effect ends; it used to wake at 0 Hit Points. end_combatandLiveCombatView.final_outcomereturn a copy of the kept outcome each time, so mutating one no longer changes what a later call returns.
nat20-bridge
New behaviour
POST /v1/combattakesallies, a list of monster slugs seated on the party's side; they share the foes' numbering. Allies alone answer 422.POST /v1/combat/{cid}/advance-monstertakes an optional body{"target_id": "<entity id>"}. No body,{}or{"target_id": null}keeps the engine's pick; an illegal target answers 409target_invalid; any other key answers 422.- An intent body accepts
knock_out; a non-melee attack answers 409knock_out_not_melee. A knock-out narrates as a line. GET /v1/combat/{cid}addsparty_ids,encounter_ids,knocked_out_idsanddeaths.
New API
EncounterMemberSpec.sideandSide(dnd5e_engine.specs).advance_monster_turn(..., target_id=None).PlayerIntent.knock_outand theknock_out_not_meleerejection reason.KnockOutRecord(top level) andCombatOutcome.knock_outs.LiveCombatView.knocked_out_idsandLiveCombatView.deaths.KnockedOutandDamageApplied.knock_out(dnd5e_engine.events).- For hosts that resolve activities themselves:
ActivityResolutionContext.knock_outandknock_out_exempt_ids, the same two keywords onbuild_activity_context, theknock_outkeyword ofapply_damage, andis_melee_attack(dnd5e_engine.activities.attack). dnd5e_engine.testing.rng_factory: a test-support context manager that scripts or records a combat's dice, Initiative included. It is process-wide for the block and not for production code.
Moved seeded pins
With no side, no target_id and no knock_out, seeded fights produce the
same event logs as on 0.7, except where a monster's closing walk used to end on
or pass through another creature's cell, and where a move used to be refused
with a detour available. Three engine pins moved, each to the detour:
tests/test_c16_orchestrator.py: theblocked_pathpin is now a 10 ft detour; a walled-in destination still answersblocked_path, and a detour that costs too much answersinsufficient_movement.tests/test_orchestrator_grid_combat.py: the wall between two adjacent cells is now a 25 ft detour.tests/e2e/test_c16_spatial_targeting.py, the cut-corner scene: one 10 ft move around the corner instead of a refusal.
DeathRecord.killer_id changes where a kill came from a creature other than
the current actor.