Persistent and temporary state

NameIntroduced/readMeaningLifecycle
wesfolk_leader_storeWritten in 01; read and cleared in 02Preserves the Wesfolk leader’s unit state, especially experience, across the transition.Temporary cross-scenario storage.
have_ladyWritten in 02; also changed by TROW_DEATHSWhether Lady Outlaw is currently part of the refugee party.Persistent campaign decision/state flag.
lady_storePrepared in 02 when the rejected leader still existsConverted Lady Outlaw identity and side metadata for later campaign logic.Persistent stored-unit data.
escape_choiceWritten at the end of 03Records the selected route: 1 for Swamp of Esten, 2 for Midlands.Persistent branch flag.

State-machine view of Lady Outlaw

Wesfolk Leader stored after Scenario 01 │ ▼ experience restored in Scenario 02 │ ├── accepted ──► recreated as side-1 Lady Outlaw ──► have_lady = 1 │ └── rejected ──► escapes / stored for later logic ──► have_lady = 0 TROW_DEATHS can later set have_lady = 0 and store her if she vanishes on last breath.

Authoring lessons

PracticeWhy it helps
Use explicit scalar flags for major choicesEasy to filter later dialogue, recalls, and branches.
Use stored units when experience and other unit fields matterA boolean alone cannot preserve advancement state.
Clear temporary storage when consumedReduces accidental reuse and save-file clutter.
Keep route state separate from party stateIndependent choices remain composable.

Scenario 02 source · Scenario 03 source · Death utility

Scenario 04 state additions

NameRoutePurposeLifecycle
last_doneBothRecords "River" or "Midlands" after branch completion.Short-lived route-transition marker; cleared at Scenario 05 prestart.
randomSwampSelects one of three temple-role arrangements.Temporary; cleared at victory.
triggered_scorpion_locsSwampTracks which ambush regions have fired.Scenario temporary; cleared at victory.
player_vision_edge, possible_scorpion_locs, search_radius, tempSwampWorking variables for adaptive ambush placement.Cleared after each spawn search.

The route flag escape_choice chooses which scenario loads; last_done records which route was actually completed after both branches converge.

Oldwood arc state lifecycle

NameUsed inPurposeCleanup
escape_choice03 → 04 route selectionLoads Swamp or Midlands.Cleared at Scenario 05 prestart.
last_done04 victory transitionLabels the branch just completed.Cleared at Scenario 05 prestart.
Have_Ruby06 onlyJoins the lich-kill and chest objectives.Cleared at Scenario 06 victory.
lady_store02/05 → 07Preserves the Wesfolk companion’s type, experience, facing, and position through absence.Cleared after Lady Jessene is reconstructed.
have_lady02 → 07Controls dialogue and whether outlaw recruitment needs repair.Cleared after the identity reveal.
State-design contrast. The Ruby uses a temporary boolean because successful scenario completion guarantees later possession. Jessene uses stored-unit state because later code must preserve variable progression data.

Scenarios 08–10 state

Name or queryScenarioPurposeLifecycle
previous_ai_position08Tracks allied garrison posture.Cleared at victory.
First_Ship, Second_Ship, Third_Ship08Marks each ship’s boarding window.Cleared on departure, boarding, or victory.
lich_free09Prevents repeat release choices and represents undead activation.Cleared at scenario end.
have_book09Gates the sewer exit.Cleared at scenario end because victory guarantees possession.
Killed_an_Orc09Temporary scenario bookkeeping declared elsewhere in the file.Cleared at scenario end.
Leader-existence query10Determines standard versus bonus exit.No stored variable required.
State-economy lesson. Scenario 10 derives its reward directly from living leader units. This is preferable to maintaining redundant kill flags when current game state already answers the question.

Southbay departure state design

MechanicState approachWhy
Book translationNo new variable in Scenario 11The dialogue establishes a guaranteed process before Scenario 12.
Ruby possession and attackPermanent unit object on HaldricThe mechanical fact belongs to the unit, not global campaign state.
Merfolk alliancePersistent recruit-list modificationRecruit access itself is the required future state.
Addroran’s defensive postureNo variableRecalculated from current unit positions each side-2 turn.
Optional Storm TridentCore pickup state plus permanent unit objectCore macro manages one-use interaction and bearer modification.
Bitey coordinatesxx1, yy1Temporary random spawn coordinates, cleared after creation.

Ka’lian hub state

NameInitializedRead by Scenario 16Final cleanup
num_done15: 0Selects initial, intermediate, or final council dialogue.16 when value reaches 4
the_dragon15: 0Shows Dragon description and option while incomplete.16 final visit
a_beach15: 0Shows Lizard Beach description and option while incomplete.16 final visit
troll_hole15: 0Shows Troll Hole description and option while incomplete.16 final visit
cursed_isle15: 0Shows Cursed Isle description and option while incomplete.16 final visit
last_done15: "none"Selects the quest-specific return greeting.16 final visit

Rough Landing temporary state

NamePurpose
side_2_serpent_triggered, side_3_serpent_triggered, side_4_serpent_triggeredGuarantee at most one casualty-triggered serpent per enemy side.
serpent_spawn_delaySpaces scheduled spawns according to trigger order.
possible_serpent_locs, serpent_loc_iTemporary candidate list and selected random location.

Scenario 17 branch state contract

BranchPersistent writesLocal temporary state
17a Dragonnum_done+=1, the_dragon=1, last_done="Dragon"dragon_awake, dragon_dead, got_enemies, got_treasure; all cleared
17b Beachnum_done+=1, a_beach=1, last_done="Beach"No branch-specific scalar state required
17c Holenum_done+=1, troll_hole=1, last_done="Hole"random; cleared at victory
17d Islenum_done+=1, cursed_isle=1, last_done="Isle"random and queen_awake; cleared during setup/victory
Contract lesson. Every branch exposes the same three-field interface to the hub even though its internal implementation state differs substantially.

Scenarios 18–20 state lifecycle

NameScenarioPurposeCleanup
stored_Jessene18Temporary duplicate renamed “Jessene in Hiding.”Cleared before cutscene ends.
jessica_store19 → 20Canonical Lady Jessene removed and preserved across scenarios.Cleared after turn-7 unstore.
xx1, yy1, chest_obtained19Random chest location and collection state.Cleared at victory.
side_N_undead_backup_triggered19One proportional reinforcement trigger per enemy front.Cleared after enemies are defeated.
side_N_top_enemy_count19Approximate peak size used for the half-strength threshold.Cleared after that side triggers.
undead_spawns_so_far19Selects first, second, or third global wave composition.Cleared after victory.

Endgame temporary state

Name / representationPurposeLifecycle
aethyr_storeStores Aethyr’s current type for his Scenario 21 fake entrance.Cleared immediately.
Treaty unit overlayMarks Aethyr as the forged-document carrier.Lives on Aethyr until his required death.
last_orc_leaderStores the one surviving orc for escape routing.Used at final victory.
escape_boatStores side-specific ship coordinates.Used during final escape.
next_corpse_spawn_turn, next_skeleton_spawn_turnRandomize recurring pressure windows.Cleared after each scheduled spawn.
wc_loc, skele_loc, skele_from, skele_typeWorking state for random undead placement.Cleared after each spawn event.
haldric_sPreserves Haldric’s current type for the epilogue entrance.Cleared after unstore.

Lifecycle-oriented view

The State Lifecycle Atlas reorganizes these scenario notes by persistence mechanism, representation, ownership, and cleanup contract.