#textdomain wesnoth-tsg
[scenario]
    id=05_Choice_in_the_Fog

    name= _ "Choice in the Fog"
    next_scenario=07a_Into_the_Depths

    {SCENARIO_MUSIC the_deep_path.ogg}
    {EXTRA_SCENARIO_MUSIC suspense.ogg}
    {EXTRA_SCENARIO_MUSIC northerners.ogg}
    {EXTRA_SCENARIO_MUSIC heroes_rite.ogg}

    map_data="{campaigns/The_South_Guard/maps/05_Choice_in_the_Fog.map}"

    {campaigns/The_South_Guard/utils/sg_deaths.cfg}

    {DEFAULT_SCHEDULE}

    {SG_CHOICE_IN_THE_FOG}
    {TSG_BIGMAP {JOURNEY_05_NEW} }

    victory_when_enemies_defeated=yes
    {TURNS 46 42 38}

    [side]
        side=1
        type=Horseman Commander
        id=Deoran
        name= _ "Deoran"
        profile=portraits/deoran.png
        unrenamable=yes
        team_name=South_Guard
        user_team_name=_"South Guard"
        controller=human

        {CUSTOM_SG_FLAG}

        {GOLD 120 110 100}
        {INCOME 2 1 0}

        fog=yes
        shroud=yes
        canrecruit=yes
        recruit=Bowman, Spearman, Cavalryman, Elvish Shaman, Elvish Fighter
    [/side]

    {STARTING_VILLAGES 1 8}

    # The Bandit Armies

    [side]
        side=2
        type=Outlaw
        id=Urza Afalas
        name= _ "Urza Afalas"
        unrenamable=yes
        profile=portraits/urza-afalas-masked.png

        # activate side 2 a little late so it doesn't fight side 3 too much
        gold=0
        {INCOME 4 5 6}

        team_name=bandits
        user_team_name=_"Bandits"
        controller=ai

        canrecruit=yes
        [ai]
            recruitment_pattern=fighter,scout,scout
            {QUANTITY aggression 0.3 0.4 0.5}
            {ATTACK_DEPTH 3 4 5}
            # In case a unit is there when they sitch to side 1 it would trigger
            # the lich sighted event. Quick Footpads can see up to 9 hexes ahead.
            [avoid]
                location_id=4
                radius=9
            [/avoid]
        [/ai]
        recruit=Footpad, Thug, Poacher
        {FLAG_VARIANT6 ragged}
    [/side]

    {STARTING_VILLAGES 2 7}

    # The Undead Hordes

    [side]
        side=3
        type=Soulless
        id=Gruth
        name= _ "Gruth"
        canrecruit=yes
        overlays="misc/leader-expendable.png"
        facing=sw

        team_name=undead
        user_team_name=_"Undead"
        controller=ai

        {GOLD 45 60 75}
        {INCOME 5 8 11}

        # Second leader:
        [unit]
            type=Soulless
            id=Gerd
            name=_ "Gerd"
            canrecruit=yes
            overlays="misc/leader-expendable.png"
            facing=ne
            x,y=11,26
        [/unit]
        [ai]
            recruitment_pattern=fighter
            {NO_SCOUTS}
            {ATTACK_DEPTH 1 2 3}
        [/ai]

#ifdef EASY
        recruit=Walking Corpse
#endif
#ifdef NORMAL
        recruit=Walking Corpse, Soulless
#endif
#ifdef HARD
        recruit=Walking Corpse, Soulless, Ghoul
#endif
        {FLAG_VARIANT undead}
    [/side]

    {STARTING_VILLAGES 3 8}

    # The Undead Hordes

    [side]
        side=4
        type=Lich
        id="Mal M'Brin"
        name= _ "?"
        profile=portraits/mal-mbrin.png

        team_name=undead
        user_team_name=_"Undead"
        controller=ai

        # side 4 starts with no gold just in case it tries to kill the bandits and also to avoid having you fight through so many units in the forests, then have no enemies when you reach the lich
        gold=0
        {INCOME 4 7 10}

        canrecruit=yes

#ifdef EASY
        recruit=Skeleton, Skeleton Archer, Ghoul
#endif
#ifdef NORMAL
        recruit=Skeleton, Revenant, Deathblade, Skeleton Archer, Ghoul
#endif
#ifdef HARD
        recruit=Skeleton, Revenant, Deathblade, Skeleton Archer, Bone Shooter, Ghoul
#endif

        [ai]
            recruitment_pattern=fighter,archer
            {QUANTITY aggression 0.2 0.4 0.6}
            {NO_SCOUTS}
            {ATTACK_DEPTH 3 4 5}
        [/ai]

        # On hard, the fake M'Brin is a normal lich, on other difficulties he's
        # weaker

#ifndef HARD
        [modifications]
            [object]
                [effect]
                    apply_to=attack
                    increase_damage=-2
                [/effect]

                [effect]
                    apply_to=hitpoints
                    increase_total=-20
                [/effect]
            [/object]
        [/modifications]
#endif
        {FLAG_VARIANT undead}
    [/side]

    {STARTING_VILLAGES 4 15}

    [side]
        no_leader=yes
        side=5
        controller=ai
        team_name=monster
        # po: only a single one
        user_team_name= _ "Monster"
        hidden=yes
        color=black
        defeat_condition=always
        income=-2
        gold=0
        village_gold=0
        village_support=0
        {FLAG_VARIANT6 ragged}
    [/side]

    # Scenario Start
    [event]
        name=start
        [recall]
            id=Sir Gerrick
        [/recall]
        [redraw]
            side=1
        [/redraw]
        [recall]
            id=Ethiliel
        [/recall]
        [redraw]
            side=1
        [/redraw]
        [recall]
            id=Minister Hylas
        [/recall]
        [redraw]
            side=1
        [/redraw]
        [recall]
            id=Jarek
        [/recall]
        [redraw]
            side=1
        [/redraw]

        [message]
            speaker=Deoran
            message= _ "It’s so cold here! And this fog is so thick. This cannot be natural for a forest like this."
        [/message]

        [message]
            speaker=Minister Hylas
            message= _ "I fear this is the effects of powerful, black magics."
        [/message]

        [message]
            speaker=Sir Gerrick
            message= _ "This is quite a change from fighting bandits in the farmlands near Westin!"
        [/message]

        [message]
            speaker=Ethiliel
            message= _ "So, even you humans are being affected by the dark sorcery that taints this land. Then, there is no better place than here. We should stop and rest before we proceed."
        [/message]

        [message]
            speaker=Deoran
            message= _ "This place is indeed foreboding, but why do we need to stop and make camp specifically here?"
        [/message]

        [message]
            speaker=Ethiliel
            message= _ "The Black River is before us. Few elves have crossed it, and fewer still have explored the dark forest beyond. If the undead come from across the river, we must exercise great caution in our search for them."
        [/message]

        [message]
            speaker=Deoran
            message= _ "Even if this forest is decidedly grim, we must not fear its inhabitants so much so that we dare not even confront them. I am ready and willing to fight!"
        [/message]

        [message]
            speaker=Ethiliel
            message= _ "Caution, not fear, human. Anxious as I am to find the whereabouts of our great sage, it would do us no good to charge straight into the trap of the enemy. We will need help to scour woods as dangerous as these, and so I have asked some of my people to aid us. My soldiers and shamans will fight at your command."
        [/message]

#ifdef EASY
        [message]
            speaker=narrator
            image="units/elves-wood/fighter-melee-2.png~RC(magenta>red)"
            {TUTOR: _"You may now recruit Elvish Fighters. Elvish Fighters are mixed fighters who skillfully wield both a sword and a bow. They are fast warriors and especially effective in forests."}
        [/message]
        [message]
            speaker=narrator
            image="units/elves-wood/shaman-heal7.png~RC(magenta>red)"
            {TUTOR: _"You may now recruit Elvish Shamans. Elvish Shamans are ranged support units who heal adjacent allies every turn and slow their enemies. Use them to heal wounded soldiers and weaken enemy units."}
        [/message]
#endif

        [message]
            speaker=Ethiliel
            message= _ "Now, so long as you feel prepared to brave the perils beyond the river, we can continue onward."
        [/message]

        [message]
            speaker=Deoran
            message= _ "Thank you for your help, my lady. I am ready for whatever lies in wait for us, be it man, beast, or skeleton. Sir Gerrick, Minister Hylas?"
        [/message]

        [message]
            speaker=Sir Gerrick
            message= _ "On your order, Sir Deoran."
        [/message]

        [message]
            speaker=Minister Hylas
            message= _ "Evil never rests — nor does the light that seeks to exterminate it."
        [/message]

        [message]
            speaker=Deoran
            message= _ "Very well then. Come, men, let us gather our wits and probe the forest for its secrets."
        [/message]

        [objectives]
            side=1
            [objective]
                description= _ "Investigate the areas to the south of the Black River"
                condition=win
                [show_if]
                    [variable]
                        name=found_urza_afalas
                        boolean_equals=no
                    [/variable]
                [/show_if]
            [/objective]
            [objective]
                description= _ "Find the source of the undead and destroy it"
                condition=win
                [show_if]
                    [variable]
                        name=found_urza_afalas
                        boolean_equals=yes
                    [/variable]
                    # Don't show this objective when the player sides with the
                    # elves and kills the lich before killing the bandit leader.
                    [have_unit]
                        id="Mal M'Brin"
                    [/have_unit]
                [/show_if]
            [/objective]
            [objective]
                description= _ "Defeat Urza Afalas"
                condition=win
                [show_if]
                    [variable]
                        name=found_urza_afalas
                        boolean_equals=yes
                    [/variable]
                    [variable]
                        name=side_with_bandits
                        boolean_equals=no
                    [/variable]
                    [have_unit]
                        id=Urza Afalas
                    [/have_unit]
                [/show_if]
            [/objective]
            [objective]
                description= _ "Death of Deoran"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Sir Gerrick"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Minister Hylas"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Ethiliel"
                condition=lose
                [show_if]
                    [variable]
                        name=found_urza_afalas
                        boolean_equals=no
                    [/variable]
                    [or]
                        [variable]
                            name=side_with_bandits
                            boolean_equals=no
                        [/variable]
                    [/or]
                [/show_if]
            [/objective]
            [objective]
                description= _ "Death of Urza Afalas"
                condition=lose
                [show_if]
                    [variable]
                        name=side_with_bandits
                        boolean_equals=yes
                    [/variable]
                [/show_if]
            [/objective]

            {TURNS_RUN_OUT}

            [gold_carryover]
                bonus=yes
                carryover_percentage=40
            [/gold_carryover]
        [/objectives]
    [/event]

    # The adventurers defeat the first zombie leader

    [event]
        name=die
        [filter]
            side=3
            canrecruit=yes
        [/filter]
        [filter_second]
            side=1
        [/filter_second]
        [filter_condition]
            [have_unit]
                side=3
                canrecruit=yes
            [/have_unit]
        [/filter_condition]

        [message]
            speaker=second_unit
            # po: This message is shown when the frist zombie leader died.
            # po: There is a second one, a few hexes next to him, the player most likely saw him already.
            message= _ "He was not alone."
        [/message]
    [/event]

    # The adventurers defeat the second zombie leader

    [event]
        name=die
        [filter]
            side=3
            canrecruit=yes
        [/filter]
        [filter_second]
            side=1
        [/filter_second]
        [filter_condition]
            [not]
                [have_unit]
                    side=3
                    canrecruit=yes
                [/have_unit]
            [/not]
        [/filter_condition]

        [if]
            [variable]
                name=know_about_lich
                boolean_equals=no
            [/variable]

            [then]
                [if]
                    [have_unit]
                        x,y=$x2,$y2
                        [not]
                            id=Ethiliel,Minister Hylas,Deoran
                        [/not]
                    [/have_unit]

                    [then]
                        [message]
                            speaker=second_unit
                            # po: Note that masters is in plural.
                            message= _ "The masters of the undead are defeated!"
                        [/message]
                    [/then]

                    [else]
                        [message]
                            speaker=Sir Gerrick
                            message= _ "The masters of the undead are defeated!"
                        [/message]
                    [/else]
                [/if]

                [message]
                    speaker=Minister Hylas
                    # po: Shown if the player defeated the zombies, but doesn't know yet about the real enemy.
                    message= _ "No... I fear there is still much evil present. These were merely servants of a far more powerful force."
                [/message]
            [/then]

            [elseif]
                [have_unit]
                    id="Mal M'Brin"
                [/have_unit]

                [then]
                    [if]
                        [have_unit]
                            x,y=$x2,$y2

                            [not]
                                id=Ethiliel,Minister Hylas
                            [/not]
                        [/have_unit]

                        [then]
                            [message]
                                speaker=second_unit
                                # po: In this case, the player knows that there is one more enemy.
                                message= _ "Two undead leaders have fallen."
                            [/message]
                            [message]
                                speaker=Minister Hylas
                                # po: In this case, the player knows that there is one more enemy.
                                message= _ "Indeed, though we have merely destroyed the servants of a far more powerful master."
                            [/message]
                        [/then]

                        [else]
                            [message]
                                speaker=Minister Hylas
                                # po: In this case, the player knows that there is one more enemy.
                                message= _ "These were merely servants of a far more powerful master."
                            [/message]
                        [/else]
                    [/if]
                [/then]
            [/elseif]
            # This is to handle the theoretical case that the bandits killed the Lich in case this
            # scenario went not as planned.
            # Can't happen, as the bandits avoid the Lich due to the AI settings as well.
            [else]
                [message]
                    speaker=second_unit
                    message= _ "One fewer evil in this forest."
                [/message]
            [/else]
        [/if]
    [/event]

    # Activate side 2 on turn 3
    [event]
        name=turn 3

        [gold]
            side=2
            {QUANTITY amount 80 95 110}
        [/gold]
    [/event]

    # The adventurers see the Lich, or the Lich moves in their vision area.
    [event]
        name=sighted

        [filter]
            id="Mal M'Brin"
        [/filter]
        [filter_second]
            side=1
        [/filter_second]

        [scroll_to]
            x,y=$x1,$y1
        [/scroll_to]

        [message]
            speaker=second_unit
            scroll=no
            message= _ "We found the lich!"
        [/message]

        # give side 4 some more gold
        [gold]
            side=4
            {QUANTITY amount 70 85 100}
        [/gold]

        {VARIABLE know_about_lich yes}
    [/event]

    # The adventurers locate the bandits: a choice must be made.
    [event]
        name=moveto

        [filter]
            side=1
        [/filter]
        [filter_condition]
            [have_location]
                x=28,28,29,29,30
                y=14,15,15,16,15
                [filter_vision]
                    side=1
                [/filter_vision]
            [/have_location]
        [/filter_condition]

        [if]
            [variable]
                name=found_urza_afalas
                boolean_equals=no
            [/variable]
            [then]
                [message]
                    speaker=unit
                    message= _ "I think I see something moving in the fog... it looks like an encampment!"
                [/message]
            [/then]
        [/if]
    [/event]

    [event]
        name=sighted
        [filter]
            id=Urza Afalas
        [/filter]
        [filter_second]
            side=1
        [/filter_second]

        {VARIABLE found_urza_afalas yes}

        [remove_shroud]
            [filter_side]
                side=1
            [/filter_side]
            x,y=$x1,$y1
            radius=1
        [/remove_shroud]

        [lift_fog]
            [filter_side]
                side=1
            [/filter_side]
            x,y=$x1,$y1
            radius=1
            multiturn=yes # To allow resetting the fog at the end of this event
        [/lift_fog]

        [redraw]
            side=1
        [/redraw]

        [message]
            speaker=Urza Afalas
            message= _ "Thank the light, you’re alive!"
        [/message]

        [message]
            speaker=Ethiliel
            message= _ "You need not thank anyone that we are alive, wretched criminals! We know of your alliance with the undead and the evil you have brought to this land!"
        [/message]

        [message]
            speaker=Sir Gerrick
            message= _ "Aye, prepare to be slain, you abominable scum! You will pay for what you have done to our home!"
        [/message]

        [message]
            speaker=Urza Afalas
            message= _ "Please, please, just hear me out. I know of these undead that you seek, and I know that you seek to destroy both them and us out of revenge. I am sorry my brothers attacked you. It was never my intention to cause everyone so much suffering."
        [/message]

        [message]
            speaker=Deoran
            message= _ "Tell us what you know of these undead. Make one wrong move and we will not hesitate to attack!"
        [/message]

        [message]
            speaker=Urza Afalas
            message= _ "I swear that I am not your enemy! I will gladly tell you what I know. A year ago, we ventured into the land of the elves in secret and we captured a great sage. We forced him to teach us the secrets of this forest."
        [/message]

        [message]
            speaker=Ethiliel
            message= _ "You imprisoned Mebrin?! You loathsome vermin!"
        [/message]

        [message]
            speaker=Urza Afalas
            message= _ "Wait, wait, hear me out! He told us that in the woods to the south of here, there was a powerful nexus of dark energy. He took us there and taught us to summon the dead to fight for us. I saw the folly in doing such a thing, but my brothers were weak and foolish and soon fell under the sway of the corrupting magic. They summoned undead that they could not control, and soon, they became slaves of the power they had sought to master!"
        [/message]

        [message]
            speaker=Ethiliel
            message= _ "A complete and utter lie from complete and utter scum."
        [/message]

        [message]
            speaker=Deoran
            message= _ "Please, Ethiliel, let us hear him out. What happened to Mebrin?"
        [/message]

        [message]
            speaker=Urza Afalas
            message= _ "I am not sure... he must have known that the undead would corrupt and enslave us."
        [/message]

        [message]
            speaker=Sir Gerrick
            message= _ "Stop stalling and tell us what happened!"
        [/message]

        [message]
            speaker=Urza Afalas
            message= _ "Mebrin was more powerful than any of the undead we summoned, and yet he did not resist them. He allowed them to make him one of them and became a lich of formidable power. He took control of the other undead lords and now leads them from the depths."
        [/message]

        [message]
            speaker=Ethiliel
            image=portraits/ethiliel-mad.png
            message= _ "You dare spew such falsities! Mebrin would never fight for the undead, much less lead them!"
        [/message]

        [message]
            speaker=Minister Hylas
            message= _ "<i>Sir Deoran, sages and mystics of great skill and age are often the first to succumb to the taint of black magic. Wisdom and power are not enough to master undeath — the only way to conquer it is to resist the temptation altogether. If this Mebrin played a part in the summoning of these undead, I do not doubt that he was corrupted as well.</i>"
        [/message]

        [message]
            speaker=Sir Gerrick
            message= _ "<i>Indeed, these elves are not as incorruptible and pure as they like to believe they are. I suspect that this sage's pride led him to believe that he could master a power that is uncontrollable.</i>"
        [/message]

        # In the unlikely case that the player did defeat Mal M'Brin, but not sight Urza Afalas
        # before, he has no choice now, as that would not fit with the storytext anymore.
        [if]
            [have_unit]
                id="Mal M'Brin"
            [/have_unit]
            [then]
                [message]
                    speaker=Deoran
                    message= _ "Very well, but even supposing your story is true, you are still criminals!"
                [/message]

                [message]
                    speaker=Urza Afalas
                    message= _ "We have committed wrongdoings in the past, but at least in the fight against the undead, we can be your friends! They are as much our enemies as they are yours, and we know the secrets of their lair and their powers. We can be of great aid in your battle against them!"
                [/message]

                [message]
                    speaker=Ethiliel
                    image=portraits/ethiliel-mad.png
                    message= _ "Think of the destruction they wrought on your land! Think of how they trespassed on our lands and kidnapped our wisest sage! No matter what they know of these undead, you cannot ally yourself with these thugs. They are as evil as the undead!"
                [/message]

                [message]
                    speaker=Deoran
                    message= _ "Peace, let me think! <i>I must consider this carefully... If I ally with the elves, I must fight the bandits, but if I ally with the bandits I will make enemies of the elves...</i>"
                    [option]
                        label= _ "Your crimes are too great. You will fall with the foul undead!"
                        [command]
                            [message]
                                speaker=Urza Afalas
                                message= _ "Then this parley is over! You may have caused the doom of all of us!"
                            [/message]

                            [message]
                                speaker=Ethiliel
                                image=portraits/ethiliel-mad.png
                                message= _ "You will pay for taking Mebrin from us! If he is harmed..."
                            [/message]

                            [set_variable]
                                name=side_with_bandits
                                value=no
                            [/set_variable]

                            [show_objectives][/show_objectives]

                            # give side 4 some gold
                            [gold]
                                side=4
                                {QUANTITY amount 60 80 100}
                            [/gold]
                        [/command]
                    [/option]

                    [option]
                        label= _ "Very well. All men must unite against the undead."
                        [command]
                            [store_villages]
                                owner_side=2

                                variable=side_2_villages
                            [/store_villages]

                            [foreach]
                                array=side_2_villages
                                [do]
                                    [capture_village]
                                        side=1
                                        x,y=$this_item.x,$this_item.y
                                    [/capture_village]
                                [/do]
                            [/foreach]

                            {CLEAR_VARIABLE side_2_villages}

                            [modify_unit]
                                [filter]
                                    id=Urza Afalas
                                [/filter]
                                side=1
                                moves=$this_unit.max_moves
                                profile=portraits/urza-afalas.png
                                canrecruit=no
                                {IS_HERO}
                                [modifications]
                                    {TRAIT_LOYAL}
                                [/modifications]
                            [/modify_unit]

                            [modify_unit]
                                [filter]
                                    side=2
                                [/filter]
                                side=1
                                moves=$this_unit.max_moves
                            [/modify_unit]

                            [modify_side]
                                side=2
                                hidden=yes
                            [/modify_side]

                            [redraw]
                                side=1
                            [/redraw]

                            [message]
                                speaker=Urza Afalas
                                message= _ "Excellent, we will fight with you. Come, my thugs and footpads, rally to me!"
                            [/message]

                            [message]
                                speaker=Ethiliel
                                image=portraits/ethiliel-mad.png
                                message= _ "So it comes to this. All humans are the same! You are no better than these criminals, the very pigs who sacked your towns and burned your villages! If you are brave enough to spurn the aid of the elves, then you are brave enough to find your own way in this forest! Come, my people, let us return to our lands. We were foolish to ever have any dealings with these men. Do not set foot in our land ever again, humans, for you have brought us nothing but grief."
                            [/message]

                            [kill]
                                side=1
                                race=elf
                                animate=no
                                fire_event=no
                            [/kill]

                            [message]
                                speaker=Sir Gerrick
                                message= _ "The elves have abandoned us in this accursed forest! We are surely lost!"
                            [/message]

                            [message]
                                speaker=Urza Afalas
                                message= _ "Do not fear! I know the way out and can lead you back to your homes after we defeat the undead."
                            [/message]

                            {VARIABLE side_with_bandits yes}

                            [allow_recruit]
                                side=1
                                type=Thug,Footpad
                            [/allow_recruit]

                            [disallow_recruit]
                                side=1
                                type=Elvish Shaman,Elvish Fighter
                            [/disallow_recruit]

                            [modify_side]
                                side=1
                                shroud=no
                            [/modify_side]

                            [show_objectives][/show_objectives]

                            [store_unit]
                                [filter]
                                    id=Urza Afalas
                                [/filter]
                                variable=Afalas
                                kill=no
                            [/store_unit]
                            {CLEAR_VARIABLE Afalas.upkeep}
                            [unstore_unit]
                                variable=Afalas
                            [/unstore_unit]
                            {CLEAR_VARIABLE Afalas}

                            # give side 4 some gold
                            [gold]
                                side=4
                                {QUANTITY amount 40 50 60}
                            [/gold]

                            [message]
                                speaker=narrator
                                image=wesnoth-icon.png
                                {NARRATOR: _"Urza Afalas’s troops are exhausted from battle and cannot attack this turn, but are still able to withdraw and reposition themselves."}
                            [/message]
                        [/command]
                    [/option]
                [/message]
            [/then]
        [/if]
        [reset_fog]
            [filter_side]
                side=1
            [/filter_side]
            x,y=$x1,$y1
            radius=1
        [/reset_fog]
    [/event]

    # Urza Afalas is killed

    [event]
        name=last breath
        [filter]
            id=Urza Afalas
        [/filter]

        [if]
            [variable]
                name=side_with_bandits
                boolean_equals=yes
            [/variable]
            [then]
                [message]
                    speaker=Urza Afalas
                    message= _ "I pay for my crimes, but without me, you cannot fight the undead..."
                [/message]
                [endlevel]
                    result=defeat
                [/endlevel]
            [/then]
            [elseif]
                [have_unit]
                    id="Mal M'Brin"
                [/have_unit]
                [then]
                    [message]
                        speaker=Urza Afalas
                        message= _ "Fools! That lich will be the death of us all! Now we are all doomed!"
                    [/message]
                    # Questionable if this should be enough to change the talk
                    # when killing the zombie leaders (it is currently set when
                    # sighting the lich before killing the zombies)
                    # {VARIABLE know_about_lich yes}
                [/then]
            [/elseif]
            [else]
                [fire_event]
                    name=bandits_and_lich_defeated
                [/fire_event]
            [/else]
        [/if]
    [/event]

    # A Water Serpent in the Deep

    [event]
        name=moveto
        [filter]
            side=1
            x,y=6,26
        [/filter]

        [unit]
            side=5
            type=Water Serpent
            id=Beast of the Lake
            name= _ "Beast of the Lake"
            x,y=2,25
            upkeep=loyal
            [status]
                slowed=yes
            [/status]
        [/unit]

        [message]
            speaker=Beast of the Lake
            message= _ "Graar!" # wmllint: no spellcheck
            # It's likely under fog.
            highlight=no
            scroll=no
            sound=bite-small.ogg
        [/message]
    [/event]

    # time over events

    [event]
        name=turn 30

        [sound]
            name=magic-dark-big.ogg
        [/sound]

        [message]
            speaker=Deoran
            message= _ "Ouch! Did anyone feel that?"
        [/message]
        [message]
            speaker=Sir Gerrick
            message= _ "Aye, I felt it too. A dreadful chill of perverse origin."
        [/message]
        [message]
            speaker=Ethiliel
            message= _ "It is the work of the undead. They have begun to cast a spell on us to drain our energy and trap us in these forests. We must hurry before they complete their dark magic, or we will not be able to escape this harrowing place, much less find and defeat them."
        [/message]
    [/event]
    [event]
        name=turn 35

        [sound]
            name=magic-dark-big.ogg
        [/sound]

        [message]
            speaker=Minister Hylas
            message= _ "Foul magic pervades these forests."
        [/message]
        [message]
            speaker=Ethiliel
            message= _ "The spell grows stronger by the moment."
        [/message]
    [/event]
    [event]
        name=turn 40

        [sound]
            name=magic-dark-big.ogg
        [/sound]

        [message]
            speaker=Deoran
            message= _ "The darkness is so heavy... I do not know how much longer I can go on..."
        [/message]
    [/event]
    [event]
        name=time over

        [sound]
            name=magic-dark-big.ogg
            repeat=1
        [/sound]

        [message]
            speaker=Deoran
            message= _ "It is... so cold..."
        [/message]
        [message]
            speaker=Ethiliel
            message= _ "The undead have ensnared us in their spell... we will not be able to escape now..."
        [/message]
    [/event]

    [event]
        name=die

        [filter]
            id="Mal M'Brin"
        [/filter]

        [sound]
            name=lightning.ogg
        [/sound]

        [if]
            [variable]
                name=side_with_bandits
                boolean_equals=yes
            [/variable]
            [then]
                [message]
                    speaker=Sir Gerrick
                    message= _ "Well! That was easier than I thought it would be."
                [/message]
                [message]
                    speaker=Deoran
                    image=portraits/deoran-glad.png
                    message= _ "Indeed. The lich has fallen. Looks like the corrupted sage was no match for us!"
                [/message]
                [message]
                    speaker=Urza Afalas
                    message= _ "I’m afraid it is not so. This was merely a phantom of the true Mebrin. He resides in catacombs deep underneath the castle, but they cannot be entered without magical means. We would require elvish magic in order to dispel the barrier he has erected."
                [/message]
                [message]
                    speaker=Deoran
                    image=portraits/deoran-mad.png
                    message= _ "What?! You knew this all along and yet you still brought us here? You misled us!"
                [/message]
                [message]
                    speaker=Urza Afalas
                    message= _ "If I had told you, you and the elves would have killed me! I had no choice!"
                [/message]
                [message]
                    speaker=Sir Gerrick
                    message= _ "Perhaps we should correct that error now."
                [/message]
                [message]
                    speaker=Urza Afalas
                    message= _ "Then you would surely be lost in these woods, hounded by the undead and made into their slaves. I can lead you and your men back to the lands of Wesnoth, but only if you promise to grant me pardon."
                [/message]
                [message]
                    speaker=Deoran
                    image=portraits/deoran-mad.png
                    message= _ "Ethiliel could have dispelled these magical wards if we had not fallen for your lies! But I foolishly spurned her advice and all the aid she had offered. I am of a mind to terminate your life here and now, but since elves have abandoned us... that would seem to be our only choice. But what about Mebrin? The undead will keep attacking our homes unless we root them out at the source."
                [/message]
                [message]
                    speaker=Urza Afalas
                    message= _ "You would never make it back on your own."
                [/message]
                [message]
                    speaker=Deoran
                    message= _ "Bah, it is not like we have a choice. Very well, you will lead us back to Westin, and we will grant your pardon so long as you do not try any more trickery. But this does not solve the problem of the undead!"
                [/message]
                [message]
                    speaker=Urza Afalas
                    message= _ "I know that Mebrin intends to lead the undead to Westin and raze the city. While his power is great and his army vast, we have fought the undead before and know that they can be defeated. Deoran—"
                [/message]
                [message]
                    speaker=Deoran
                    image=portraits/deoran-mad.png
                    message= _ "That’s <i>Sir</i> Deoran to the likes of you!"
                [/message]
                [message]
                    speaker=Urza Afalas
                    message= _ "Yes, yes, Sir Deoran! If we fight against the undead on open plains or in the forests, we will surely be slaughtered. But, if we prepare our defenses and fortify the city walls, we may be able to hold back the undead and even strike at the lich-sage himself."
                [/message]
                [message]
                    speaker=Deoran
                    image=portraits/deoran-sad.png
                    message= _ "Then we shall retreat towards Westin and prepare for the oncoming battle. I pray our only chance at victory was not lost today."
                [/message]
                {CLEAR_VARIABLE side_with_bandits,found_urza_afalas,know_about_lich}
                [endlevel]
                    result=victory
                    next_scenario=06b_The_Long_March
                    bonus=yes
                    {NEW_GOLD_CARRYOVER 40}
                [/endlevel]
            [/then]
            [elseif]
                [have_unit]
                    id=Urza Afalas
                [/have_unit]
                [then]
                    [message]
                        speaker=Sir Gerrick
                        message= _ "Now to defeat those bandits!"
                    [/message]
                    # It is unlikely that the player did not yet find Urza Afalas.
                    # If he did not yet, the player loses the possibility to side
                    # with him, as it fits storywise not anymore.
                    [if]
                        [variable]
                            name=found_urza_afalas
                            boolean_equals=no
                        [/variable]
                        [then]
                            {VARIABLE side_with_bandits no}
                            {VARIABLE found_urza_afalas yes}
                            [show_objectives][/show_objectives]
                        [/then]
                    [/if]
                [/then]
            [/elseif]
            [else]
                [fire_event]
                    name=bandits_and_lich_defeated
                [/fire_event]
            [/else]
        [/if]
    [/event]

    [event]
        name=bandits_and_lich_defeated

        [message]
            speaker=Sir Gerrick
            message= _ "We have beaten them both, outlaws and undead!"
        [/message]
        [message]
            speaker=Deoran
            image=portraits/deoran-glad.png
            message= _ "We should make haste to return to Wesnoth. I think the fall harvest should be soon!"
        [/message]
        [message]
            speaker=Ethiliel
            message= _ "Do not be so hasty. Powerful mages are not so easily defeated, and those skilled in the dark arts are especially adept at misdirection. There are many tunnels and catacombs buried beneath this fortress which emanate a great, dark energy. If we wish to cleanse the land of this evil, we must enter the crypt and root it out from within."
        [/message]
        [message]
            speaker=Deoran
            message= _ "Very well, but where is the entrance?"
        [/message]
        [message]
            speaker=Ethiliel
            message= _ "There are strong magical wards that have hidden the way and bar our entry, but I am capable of dispelling them. It will take some time so stand back and get what rest you can. We are likely to face fierce opposition once we enter the caverns."
        [/message]
        [message]
            speaker=Deoran
            message= _ "Indeed. We will leave you to your work and prepare ourselves for the coming battle."
        [/message]
        {CLEAR_VARIABLE side_with_bandits,found_urza_afalas,know_about_lich}
        [endlevel]
            result=victory
            next_scenario=07a_Into_the_Depths
            bonus=yes
            {NEW_GOLD_CARRYOVER 40}
        [/endlevel]
    [/event]
[/scenario]
