#textdomain wesnoth-tsg
[scenario]
    id=5_Choice_In_The_Fog

    name= _ "Choice in the Fog"
    next_scenario=6a_Tidings_Good_And_Ill

    {SCENARIO_MUSIC the_deep_path.ogg}
    {EXTRA_SCENARIO_MUSIC nunc_dimittis.ogg}

    # music changes when bandits are encountered

    map_data="{campaigns/The_South_Guard/maps/5_Choice_In_The_Fog.map}"

    {campaigns/The_South_Guard/utils/sg_deaths.cfg}

    {DEFAULT_SCHEDULE}

    {SG_CHOICE_IN_THE_FOG}

    victory_when_enemies_defeated=yes
    {TURNS 50 40 35}

    [side]
        side=1
        type=Horseman Commander
        id=Deoran
        name= _ "Deoran"
        unrenamable=yes

        team_name=South_Guard
        user_team_name=_"South Guard"
        controller=human
        {CUSTOM_SG_FLAG}

        {GOLD 150 125 80}
        {INCOME 6 4 2}

#ifdef EASY
        fog=yes
        shroud=no
#endif
#ifdef NORMAL
        fog=yes
        shroud=yes
#endif
#ifdef HARD
        fog=yes
        shroud=yes
#endif

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

    # The Bandit Armies

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

        {GOLD 50 70 90}
        {INCOME 2 3 5}

        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}
        [/ai]
        recruit=Footpad, Thug
    [/side]

    # The Undead Hordes

    [side]
        side=3
        type=Soulless
        id=Gruth
        name= _ "Gruth"

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

        {GOLD 30 50 80}
        {INCOME 5 10 15}

        canrecruit=yes
        [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
    [/side]

    # The Undead Hordes

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

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

        {GOLD 60 90 120}
        {INCOME 3 5 6}

        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]
                silent=yes

                [effect]
                    apply_to=attack
                    increase_damage=-2
                [/effect]

                [effect]
                    apply_to=hitpoints
                    increase_total=-20
                [/effect]
            [/object]
        [/modifications]
#endif
    [/side]

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

        [message]
            speaker=Deoran
            image=portraits/deoran-mad.png
            message= _ "The heat in this forest is oppressive, and this fog cannot be natural. I wonder what evil lurks nearby?"
        [/message]

        [message]
            speaker=Minister Hylas
            message= _ "I fear the fog emanates from some powerful lord of the undead. We may be overmatched..."
        [/message]

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

        [message]
            speaker=Ethiliel
            message= _ "I have brought many of my people along to aid us. My soldiers and shamans will now fight at your command."
        [/message]
#ifdef EASY
        [message]
            speaker=narrator
            image="units/elves-wood/fighter-melee-2.png~RC(magenta>red)"
            message= _ "Elvish Fighters are at home in the thick forests. They have both a sword and a bow and are deadly with both. They are quick and can hold their own against just about anything."
        [/message]
        [message]
            speaker=narrator
            image="units/elves-wood/shaman-heal7.png~RC(magenta>red)"
            message= _ "Elvish Shamans are no match for most enemies in single combat. They do, however, heal units next to them every turn. Use them to bolster your weakening lines and heal wounded soldiers."
        [/message]
#endif
        [message]
            speaker=Deoran
            message= _ "Why did we stop and make camp here?"
        [/message]

        [message]
            speaker=Ethiliel
            message= _ "The Black River is before us. No elf, still living, has crossed it. If the undead come from across the river, then we must search for them carefully, for I know not the way."
        [/message]

        [message]
            speaker=Sir Gerrick
            message= _ "I fear no forests. Let us find this river and whatever enemies lie beyond."
        [/message]

        [message]
            speaker=Deoran
            message= _ "Very well. We will seek the river and probe its secrets."
        [/message]

        [objectives]
            side=1
            [objective]
                description= _ "Investigate the areas to the south of the Black River"
                condition=win
            [/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
            [/objective]
            [objective]
                description= _ "Time runs out"
                condition=lose
            [/objective]

            note={EARLY_FINISH_BONUS_NOTE}+{NEW_GOLD_CARRYOVER_NOTE_40}
        [/objectives]
    [/event]

    # The adventurers defeat the zombie leader

    [event]
        name=die
        [filter]
            id=Gruth
        [/filter]

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

                [not]
                    id=Ethiliel
                [/not]

                [not]
                    id=Minister Hylas
                [/not]

                [not]
                    id=Deoran
                [/not]
            [/have_unit]

            [then]
                [message]
                    speaker=second_unit
                    message= _ "The master of the undead is defeated!"
                [/message]
            [/then]

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

        [message]
            speaker=Minister Hylas
            message= _ "No... I fear there is still much evil present. "
        [/message]

        [message]
            speaker=Deoran
            message= _ "Surely the undead infestation cannot be dispatched so easily. We have merely destroyed a servant of a far darker master."
        [/message]
    [/event]

    # This event prevents the AI-controlled Urza from moving before he's
    # sighted. Should be removed if there is no problem with his sighted event
    # when he's allowed to move

    [event]
        name=ai turn
        first_time_only=no

        [if]
            [variable]
                name=side_number
                equals=2
            [/variable]

            [variable]
                name=side_with_bandits
                not_equals=no
            [/variable]

            [variable]
                name=side_with_bandits
                not_equals=yes
            [/variable]

            [then]
                {MODIFY_UNIT (id=Urza Afalas) moves 0}
            [/then]
        [/if]
    [/event]

    # The adventurers locate the bandits: a choice must be made

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

        [message]
            speaker=second_unit
            message= _ "I think I see something moving in the fog... it looks like an encampment!"
        [/message]

        [redraw]
            side=1
        [/redraw]

        [message]
            speaker=Urza Afalas
            message= _ "Thank heaven! You're alive!"
        [/message]

        [message]
            speaker=Ethiliel
            message= _ "Save your thanks! We are here to root out all the evil from these woods, and that means you!"
        [/message]

        [message]
            speaker=Sir Gerrick
            message= _ "Draw your swords and say your prayers! You cannot stand against us! You will pay for your crimes!"
        [/message]

        [message]
            speaker=Urza Afalas
            message= _ "But have you not seen the undead in these forests? I know you have seen them under the control of the many bandit leaders before..."
        [/message]

        [message]
            speaker=Deoran
            message= _ "What of them?"
        [/message]

        [message]
            speaker=Urza Afalas
            message= _ "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 and of the undead."
        [/message]

        [message]
            speaker=Ethiliel
            message= _ "You imprisoned Mebrin!? For that you must surely pay. Speak swiftly so that we may end this parley and dispatch you quickly! We will have vengeance!"
        [/message]

        [message]
            speaker=Urza Afalas
            message= _ "Hear me out! He taught us to summon the dead to fight for us. We were weak and foolish and soon summoned undead that we could not control. Mebrin too fell sway to the influence of the undead, and now he leads them. For a time he served us, but now he has gone mad and is attacking us as well!"
        [/message]

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

        [message]
            speaker=Deoran
            message= _ "But what do you want us to do about it? You are criminals!"
        [/message]

        [message]
            speaker=Urza Afalas
            message= _ "Join us in the fight! Together we can drive off these cruel undead and restore peace to the land."
        [/message]

        [message]
            speaker=Sir Gerrick
            message= _ "My lord, they could be valuable allies, and the undead are a greater threat to our lands. Justice can wait until we are all safely in Westin."
        [/message]

        [message]
            speaker=Ethiliel
            image=portraits/ethiliel-mad.png
            message= _ "But think of the destruction they wrought on your borders! You cannot ally yourselves with these evil men! Vengeance!"
        [/message]

        [message]
            speaker=Deoran
            message= _ "Hmm...I have to consider this..."
            [option]
                message= _ "Very well. All men must unite against the undead."
                [command]
                    [music]
                        name=knalgan_theme.ogg
                        immediate=no
                        append=yes
                    [/music]

                    [store_villages]
                        owner_side=2

                        variable=side_2_villages
                    [/store_villages]

                    {FOREACH side_2_villages i}
                        [capture_village]
                            side=1
                            x,y=$side_2_villages[$i].x,$side_2_villages[$i].y
                        [/capture_village]
                    {NEXT i}

                    {CLEAR_VARIABLE side_2_villages}

                    [store_unit]
                        [filter]
                            speaker=Urza Afalas
                        [/filter]

                        kill=yes
                        variable=stored_Urza_Afalas
                    [/store_unit]

                    [unit]
                        side=1
                        type=Outlaw
                        id=Urza Afalas
                        name= _ "Urza Afalas"
                        x,y=$stored_Urza_Afalas.x,$stored_Urza_Afalas.y
                        profile=portraits/urza-afalas.png
                        {IS_HERO}
                        facing=$stored_Urza_Afalas.facing
                        experience=$stored_Urza_Afalas.experience
                        random_traits=no
                        [modifications]
                            {TRAIT_LOYAL}
                        [/modifications]
                    [/unit]

                    {CLEAR_VARIABLE stored_Urza_Afalas}

                    {MODIFY_UNIT side=2 side 1}

                    [redraw]
                        side=1
                    [/redraw]

                    [message]
                        speaker=Urza Afalas
                        message= _ "We will now fight alongside you, come my thugs and footpads, rally to me!"
                    [/message]

                    [message]
                        speaker=Ethiliel
                        image=portraits/ethiliel-mad.png
                        message= _ "You are no better than these criminals! We shall see if you can find your own way out of the forest! Come, my people, let us return to our lands. We were foolish to ever have any dealings with these humans. Do not set foot in our land ever again, Deoran, 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 can lead you out when the time is right."
                    [/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]

                    [objectives]
                        side=1
                        [objective]
                            description= _ "Find the source of the undead and destroy it"
                            condition=win
                        [/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 Urza Afalas"
                            condition=lose
                        [/objective]
                        [objective]
                            description= _ "Time runs out"
                            condition=lose
                        [/objective]

                        note={EARLY_FINISH_BONUS_NOTE}+{NEW_GOLD_CARRYOVER_NOTE_40}
                    [/objectives]
                [/command]
            [/option]

            [option]
                message= _ "Your crimes are too great. You will fall with the rest of the foul undead!"
                [command]
                    [music]
                        name=knolls.ogg
                        immediate=no
                        append=no
                    [/music]
                    [music]
                        name=nunc_dimittis.ogg
                        append=yes
                    [/music]

                    [message]
                        speaker=Urza Afalas
                        message= _ "Then this parley is over! You may have sounded 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]

                    [objectives]
                        side=1
                        [objective]
                            description= _ "Find the source of the undead and destroy it"
                            condition=win
                        [/objective]
                        [objective]
                            description= _ "Defeat Urza Afalas"
                            condition=win
                        [/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
                        [/objective]
                        [objective]
                            description= _ "Time runs out"
                            condition=lose
                        [/objective]

                        note={EARLY_FINISH_BONUS_NOTE}+{NEW_GOLD_CARRYOVER_NOTE_40}
                    [/objectives]
                [/command]
            [/option]
        [/message]
    [/event]

    # Urza Afalas is killed

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

        [if]
            [variable]
                name=side_with_bandits
                equals=yes
            [/variable]
            [then]
                [message]
                    speaker=Urza Afalas
                    message= _ "Now I pay for my crimes. But how many others will also suffer for them?"
                [/message]
                [endlevel]
                    result=defeat
                [/endlevel]
            [/then]
            [else]
                [message]
                    speaker=Urza Afalas
                    message= _ "Fools! That lich will be the death of us all! You have sealed our doom!"
                [/message]
            [/else]
        [/if]
    [/event]

    # A Sea Serpent in the Deep

    [event]
        name=moveto
        [filter]
            side=1
            x,y=16,39
        [/filter]

        [unit]
            side=3
            type=Sea Serpent
            id=Beast of the Lake
            name= _ "Beast of the Lake"
            x,y=15,39
        [/unit]

        [message]
            speaker=Beast of the Lake
            message= _ "Graar!"	# wmllint: no spellcheck
        [/message]
    [/event]

    [event]
        name=die

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

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

        [if]
            [variable]
                name=side_with_bandits
                equals=yes
            [/variable]
            [then]
                [message]
                    speaker=Sir Gerrick
                    message= _ "Well! That was easier than I thought it'd be. Looks like the undead aren't so tough after all!"
                [/message]
                [message]
                    speaker=Deoran
                    image=portraits/deoran-glad.png
                    message= _ "Indeed. The dark king has fallen."
                [/message]
                [message]
                    speaker=Urza Afalas
                    message= _ "I'm afraid it is not so. This was not the real Mebrin we destroyed, but a mere phantom. He resides in catacombs deep underneath the castle, but they cannot be entered without magical means."
                [/message]
                [message]
                    speaker=Deoran
                    image=portraits/deoran-mad.png
                    message= _ "We spared your life in order to defeat the source of these undead, and now you tell us we cannot even reach it?! Ethiliel could have dispelled these magical wards if we hadn't fallen for your lies!"
                [/message]
                [message]
                    speaker=Urza Afalas
                    message= _ "If I had told you, you and the elves would have killed me! I didn't have a 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 forever at the mercy of the undead. I can lead you and your men back to the lands of Wesnoth if you will grant me pardon."
                [/message]
                [message]
                    speaker=Deoran
                    image=portraits/deoran-mad.png
                    message= _ "Now that the 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= _ "I do not know. But if we cannot storm his underground fastness we must either flee or wait here and certainly perish fighting him on his own terms. I know that he will march to ravage your city of Westin with all his might soon, and that the city cannot hold out against such a force unprepared."
                [/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]
                [endlevel]
                    result=victory
                    next_scenario=6b_The_Long_March
                    bonus=yes
                    {NEW_GOLD_CARRYOVER 40}
                [/endlevel]
            [/then]
            [else]
                [message]
                    speaker=Sir Gerrick
                    message= _ "We have beaten them both, criminals and undead!"
                [/message]
                [message]
                    speaker=Deoran
                    image=portraits/deoran-glad.png
                    message= _ "We should make haste to return to Wesnoth before the harvest. Fall arrived some time ago."
                [/message]
                [message]
                    speaker=Ethiliel
                    message= _ "Do not be so hasty; great mages are no mere tricksters to be easily defeated. I fear that there are tunnels and catacombs buried beneath his fortress and that we have merely defeated a specter. If we wish to cleanse the land of his evil, we must enter the darkness and root him out from within."
                [/message]
                [message]
                    speaker=Ethiliel
                    message= _ "There are strong magical wards placed here that would prevent you from entering, but I am capable of opening them to let us all pass."
                [/message]
                [message]
                    speaker=Deoran
                    image=portraits/deoran-sad.png
                    message= _ "My men are not dwarves! How are we to fight in catacombs and tunnels?"
                [/message]
                [message]
                    speaker=Sir Gerrick
                    message= _ "Someone must take news back to Wesnoth of this new evil that lurks near our borders. Who knows how many more of these undead are hiding in the forest?"
                [/message]
                [message]
                    speaker=Deoran
                    message= _ "Go, Sir Gerrick, and take with you an escort of elves, if Ethiliel will permit it."
                [/message]
                [message]
                    speaker=Ethiliel
                    message= _ "Indeed I will. My kinsfolk will protect you and your message!"
                [/message]
                [message]
                    speaker=Sir Gerrick
                    message= _ "Fare well, Deoran! I will be there to greet you when you return to Kerlath Province."
                [/message]
                [endlevel]
                    result=victory
                    next_scenario=6a_Tidings_Good_And_Ill
                    bonus=yes
                    {NEW_GOLD_CARRYOVER 40}
                [/endlevel]
            [/else]
        [/if]
    [/event]
[/scenario]
