Source-first reverse engineering of a mainline Battle for Wesnoth campaign
06 — Temple in the Deep
A compact shrouded dungeon with two victory requirements, a protagonist-only artifact pickup, aggressive undead AI, and event-driven reanimation of fallen allies.
A single story panel follows Haldric into the catacombs beneath the forest temple. Lich-Lord Lenvan interprets the opening of the seal as his release and immediately raises his forces. Burin welcomes being underground again, while Haldric frames the task as giving the monsters their final rest.
The scenario’s story is carried primarily by mechanics rather than long conversation: the sealed enemy, the buried chest, the central pools and tentacles, the raising of dead allies, and the requirement that Haldric personally retrieve the Ruby all communicate the dungeon’s danger and artifact importance.
Story beat
Implementation
Descent into the roots of the world
One campaign-specific story image
Lenvan’s release
start dialogue and aggressive undead side
Unnatural pools
Tentacle sighting event
Ruby discovery
Haldric-only chest interaction with sound and narration
Necromantic threat
Fallen side-1 units are raised as hostile corpses while Lenvan lives
Map description
The compact 27 × 27 underground map places Lenvan’s keep near the upper center and Haldric’s keep near the lower center. Narrow cave passages, impassable cave walls, underground villages, rough cave ground, water, chasms, bridges, fungus, and a broad central pool produce a vertically oriented push toward the chest at hex 13,1.
Map element
Design role
Opposed top and bottom keeps
Creates a direct dungeon ascent toward the lich and artifact.
Central water complex
Houses the Tentacles of the Deep and interrupts the main route.
Shroud
Makes the dungeon reveal itself incrementally.
Chest flanked by dragon statues
Visually marks the Ruby objective at the map’s far end.
Holy-water pickup at 13,19
Supplies a core anti-undead tool near the player’s half of the map.
Objectives and victory logic
Type
Condition
Victory requirement 1
Defeat Lich-Lord Lenvan.
Victory requirement 2
Retrieve the Fire Ruby with Prince Haldric.
Defeat
Death of Prince Haldric; turns expire.
victory_when_enemies_defeated=no prevents the engine from ending the scenario when Lenvan dies. Victory can occur in either order:
Lenvan dies first
└── scenario continues until Haldric opens chest
└── victory
Haldric opens chest first
└── Have_Ruby = yes
└── Lenvan's later last-breath event ends scenario
Quest-design lesson. A compound objective is implemented as two independent completion events joined by one temporary state flag.
Sides and AI
Side
Leader / roster
Gold and income
AI
1 — Refugees
Haldric; Burin and Minister Edren recalled
160 / 140 / 120
Human controlled; shroud enabled
2 — Undead
Lich-Lord Lenvan; Revenant, Deathblade, Bone Shooter, Skeleton, Skeleton Archer
240 / 300 / 360; income 6 / 10 / 14
Aggression 1.0, NO_SCOUTS, fighter/archer pattern
The enemy AI is deliberately uncomplicated. Scenario identity comes from map structure, fixed tentacles, shroud, objective gating, and death events rather than a custom controller.
Difficulty scaling
Element
Easy
Normal
Hard
Turns
37
34
31
Player gold
160
140
120
Lenvan gold
240
300
360
Lenvan income
6
10
14
Fixed Tentacles of the Deep
4
6
8
Raised former allies
Walking Corpse
Walking Corpse
Soulless
Special events
Trigger
Behavior
prestart
Places difficulty-scaled tentacles, chest, dragon statues, and holy water; recalls Burin and Edren; installs compound objectives.
start
Lenvan celebrates his freedom and the party commits to destroying him.
First sighting of a Tentacle
The discovering unit comments on the pool.
Move to chest with non-Haldric unit
Plays a defensive animation, asks for somebody else, and permits undo.
Move to chest with Haldric
Sets Have_Ruby=yes, plays open-chest.wav, narrates the Ruby, and checks whether Lenvan is already dead.
Move to chest after Ruby obtained
Reports that Haldric already has it and permits undo.
Lenvan last breath
Ends the scenario only if Have_Ruby=yes.
Side-1 unit dies while Lenvan lives
Haldric comments once; repeatable event raises a hostile “Former Friend” when the killer lacks its own plague result.
victory
Confirms both tasks and clears the temporary Have_Ruby flag.
Campaign utility: RISE_UP_RISE_UP
The macro is defined in utils/trow-macros.cfg. At the fallen unit’s coordinates, it creates a loyal side-2 unit named “A Former Friend,” preserves the dead unit’s undead variation, disables its remaining moves and attacks for the current turn, and animates its arrival. The created type is Walking Corpse on Easy and Normal, and Soulless on Hard.
Why use an event instead of the normal plague special? The scenario wants Lenvan’s continuing presence to be the cause, wants a difficulty-dependent result, and wants the newly raised unit to inherit an appropriate visual variation.
Core utility reuse: holy water
OBJ_POTION_HOLY_ALT 13 19 (holy_helper) comes from the core item macros. It places a one-use holy-water pickup which can be taken by a side-1 unit with a non-arcane melee attack. For the current scenario, the macro appends the arcane weapon special to that unit’s melee attacks.
Have_Ruby is cleared at victory even though the Ruby remains in the story. That is intentional state minimization:
Need
State solution
Track whether both objectives are complete inside Scenario 06
Temporary boolean Have_Ruby
Track possession after Scenario 06
No variable required; every valid exit from the scenario guarantees the Ruby was taken.
Authoring principle. Do not persist a flag merely because an event matters narratively. Persist it only when later code must distinguish multiple possible states.