Dialogue, cinematics and difficulty

A mission talks to the player with the aqua4/dialog package, frames a scene with aqua4/cinematic, and reads the chosen difficulty with campaign.Difficulty(). None of it changes the simulation by itself, and every answer the player gives is a recorded input, so a replay and every computer of an online game see the same thing at the same step.

Subtitles

dialog.Say(player.Everyone, "Mira", "The bridge is out.", 4)

A line stays for the seconds you give (game time). A newer line replaces the older one.

A question

dialog.Choice(player.Red, "road", "Which road?", []string{"The pass", "The marsh"},
    func(p player.ID, i int) {
        campaign.SetFlag("marsh", i == 1)
    })

A question is a single-use decision, as in Warcraft III's campaigns: the first answer wins, the other buttons vanish, and the function is called once. Asking again under the same id replaces the old question. dialog.Open("road") tells whether it is still waiting.

The answer is a click on a button of the map's own interface, which the game records like any other input.

A scene with Skip

cinematic.Begin(player.Everyone, func() { openTheGate() })
dialog.Say(player.Everyone, "Mira", "Now!", 3)
event.After(3, func() { cinematic.Finish(player.Everyone) })

Begin puts black bars at the top and bottom and a Skip button. If the player skips, the bars go and the function you gave runs: it should leave the game in the state the scene would have ended in, because your timers may still fire. Check cinematic.Skipped() before doing a step twice. The simulation keeps running behind the bars.

Difficulty

switch campaign.Difficulty() {
case campaign.Easy:   // 0
case campaign.Hard:   // 2
case campaign.Heroic: // 3
}

The player picks easy, normal, hard or heroic when a campaign starts (if the author allows it). The level is an input of the mission, so it is part of the replay. A map that is not part of a campaign is always Normal. Scale waves, gold or health with it as you like; the engine applies no handicap by itself.