Source-first reverse engineering of a mainline Battle for Wesnoth campaign
19 — The Vanguard
A fog-covered beachhead defense where Haldric relinquishes the Ruby, Jessene leaves the field, a random chest is guaranteed at victory, and each weakened enemy front can trigger an adaptive undead wave.
Jessene catches Haldric on a fog-covered plain and reports the elven betrayal. She also confirms that Jevyan and his Familiar have reached the Great Continent. Haldric responds with a deception: he removes the Ruby from his own use and sends Jessene to hide it in the Troll Hole.
The immediate military objective is to destroy the orcish vanguard before it reaches the coast and captures the returning refugee fleet. Commander Aethyr confirms that the new orcs did not arrive aboard Haldric’s missing ships; they seized the remaining boats on the Green Isle.
Map description
The 37 × 37 map is a broad fog-covered inland battlefield. Haldric begins in the southeast at 33,34. Orcish Warlords occupy western and eastern keeps at 6,22 and 28,14, while Troll leader Thruf holds the northern keep at 16,6. The map combines open grassland, forests, hills, mountains, swamp pockets, villages, and several castle clusters.
Map system
Design role
Three distant enemy keeps
Creates independent fronts and three possible reinforcement triggers.
Fog
Conceals the randomized chest and adaptive undead arrivals.
Mountain-heavy northwest
Gives the Troll force a distinct geographic approach.
Random chest region, x 11–18 / y 2–6
Places bonus gold on ordinary grass near the northern objective.
Objectives and sides
Victory
Defeat all three enemy leaders.
Defeat
Death of Haldric or Commander Aethyr; turns expire.
Carryover
40%, with early-finish bonus.
Side
Leader / roster
Gold and income
Behavior
1 — Refugees
Haldric; Jessene and Aethyr initially recalled
280 / 240 / 200
Human controlled; 5 / 4 / 3 starting villages
2 — Orcs
Tan-Erirt, Orcish Warlord
120 / 150 / 180; income 6 / 10 / 14
Night aggression 0.71 / 0.73 / 0.75
3 — Orcs
Tan-Gagar, Orcish Warlord
120 / 150 / 180; income 6 / 10 / 14
Mirrors side 2
4 — Trolls
Thruf, Troll Warrior
100 / 150 / 200; income 6 / 10 / 14
No scouts; fighter-heavy recruitment
5 — Undead backup
No leader; hidden
No village economy
Hosts event-created reinforcement waves
Ruby and Jessene state transition
Action
Effect
[remove_object] object_id=ruby_of_fire
Removes Haldric’s permanent Ruby attack from his unit.
Jessene receives the Ruby in dialogue
The artifact’s magical signal is physically separated from Haldric.
[store_unit] variable=jessica_store kill=yes
Removes Lady Jessene from the battlefield and preserves her complete unit state for Scenario 20.
The campaign represents the deception mechanically rather than with a boolean alone: the attack object is actually removed from Haldric, and the carrier is actually absent.
Random chest with guaranteed recovery
During prestart, the scenario gathers grass hexes in the northern region, randomly selects one, places a closed chest, and records chest_obtained=no. Opening it grants 125 / 100 / 75 gold.
If the player wins without finding the chest, the victory event fires the same get chest event automatically. The reward is therefore spatially discoverable but not permanently missable.
Adaptive undead backup system
Each of enemy sides 2, 3, and 4 may trigger one undead reinforcement wave when its remaining unit count falls to half or less of the highest count recorded for that side.
A death event counts the side’s surviving units and updates its approximate peak count.
When the half-strength threshold is crossed, the side-specific trigger flag is set.
The scenario stores that side’s starting location.
A nested new turn event searches for a legal reinforcement hex.
The new force arrives on hidden side 5.
Spawn constraint
Purpose
Exactly 12 hexes from at least one player unit
Keeps the wave relevant but outside normal one-turn reach.
Not within 11 hexes of a player unit
Creates the exact distance ring.
As close as possible to the weakened side’s starting keep
Makes the backup feel attached to that front.
Path radius travels through grass, roads, castles, keeps, or swamp
Avoids selecting a geographically disconnected point.
Not adjacent to any existing unit
Prevents overlapping or instant engagement.
Wave order
The first, second, and third enemy sides to cross the half-strength threshold receive different global waves:
Wave
Named leader
Supporting units
1
Norte — Deathblade
One Chocobone on Easy; two above Easy
2
Rabbin — Banebow
Two Chocobones; three on Hard
3
General Kafka — Draug
Two Chocobones; four on Hard
Important architecture detail. Composition depends on the global order in which fronts weaken, not on which specific enemy side triggered the wave.
Delayed substitution
The nested event uses delayed_variable_substitution=no and escaped substitutions such as $|search_radius. This preserves the triggering side’s stored center while allowing working variables to be evaluated when the future turn actually begins.
Additional economy and events
Trigger
Effect
Tan-Erirt dies to side 1
Tan-Gagar’s side receives 60 / 70 / 80 gold.
Tan-Gagar dies to side 1
Tan-Erirt’s side receives 60 / 70 / 80 gold.
Burin attacks
He celebrates being home on the Great Continent.
Enemies defeated
Haldric races to meet the fleet; reinforcement flags are cleared.
Victory cleanup
Chest is collected if necessary; chest coordinates and state are cleared.
Lessons for campaign authors
Pattern
Reuse lesson
Remove a permanent object for story reasons
Artifact possession can be represented by actual unit modifications.
Trigger backup when a front is half depleted
Scale dramatic escalation to player progress instead of fixed turns.
Search a distance ring near a front’s origin
Place reinforcements fairly and contextually on a large map.
Global wave order across several triggers
Let the player’s attack order influence which reinforcement compositions appear first.
Guarantee optional chest reward at victory
Preserve exploration value without creating a harsh missable economy penalty.