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

    name= _ "Choice in the Fog"
    next_scenario=6a_Tidings_Good_And_Ill
    [music]
        name=underground.ogg
        ms_before=500
    [/music]
    # 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}
    
    {VICTORY_AND_DEFEAT_MUSIC}

    [side]
        side=1
        type=Horseman Commander
        description=Deoran
        user_description= _ "Deoran"
        unrenamable=yes

        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
        description=Urza Afalas
        user_description= _ "Urza Afalas"
        profile=portraits/urza-afalas-masked.png

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

        team_name=bandits
        controller=ai

        canrecruit=yes
        [ai]
            recruitment_pattern= fighter, mixed fighter, scout, scout
            {QUANTITY aggression 0.3 0.4 0.5}
            {ATTACK_DEPTH 3 4 5}
        [/ai]
#ifdef EASY
        recruit=Thug
#endif

#ifdef NORMAL
        recruit=Footpad, Thug
#endif

#ifdef HARD
        recruit=Footpad, Thug, Outlaw, Bandit
#endif
    [/side]

    # The Undead Hordes

    [side]
        side=3
        type=Soulless
        description=Gruth
        user_description= _ "Gruth"

        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
        description="Mal M'brin"
        user_description= _ "Mal M'brin"
        profile=portraits/mal-mbrin.png
        facing=sw

        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]
            description=Sir Gerrick
        [/recall]
        [recall]
            description=Ethiliel
        [/recall]
        [recall]
            description=Minister Hylas
        [/recall]
        [recall]
            description=Jarek
        [/recall]

        [message]
            description=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]
            description=Minister Hylas
            message= _ "I fear the fog emanates from some powerful lord of the undead. We may be overmatched..."
        [/message]

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

        [message]
            description=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="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="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]
            description=Deoran
            message= _ "Why did we stop and make camp here?"
        [/message]

        [message]
            description=Ethiliel
            message= _ "The great 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]
            description=Sir Gerrick
            message= _ "I fear no forests. Let us find this river and whatever enemies lie beyond."
        [/message]

        [message]
            description=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]
        [/objectives]
    [/event]

    # The adventurers defeat the zombie leader

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

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

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

        [message]
            description=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 (description=Urza Afalas) moves 0}
            [/then]
        [/if]
    [/event]

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

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

        [music]
            immediate=yes
            name=knolls.ogg
            ms_before=500
        [/music]

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

        [redraw]
            side=1
        [/redraw]

        [music]
            name=wanderer.ogg
            ms_before=500
            append=yes
        [/music]

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

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

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

        [message]
            description=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]
            description=Deoran
            message= _ "What of them?"
        [/message]

        [message]
            description=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]
            description=Ethiliel
            message= _ "You imprisoned Mebrin!? For that you must surely pay. Speak swiftly so that we may end this parlay and dispatch you quickly! We will have vengeance!"
        [/message]

        [message]
            description=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]
            description=Ethiliel
            image=portraits/ethiliel-mad.png
            message= _ "Lies! Mebrin would never fight for the undead, much less lead them!"
        [/message]

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

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

        [message]
            description=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]
            description=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]
            description=Deoran
            message= _ "Hmm...I have to consider this..."
            [option]
                id=accept_bandits
                message= _ "Very well. All men must unite against the undead."
                [command]
                    {MODIFY_UNIT side=2 side 1}

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

                        kill=yes
                        variable=stored_Urza_Afalas
                    [/store_unit]

                    [unit]
                        side=1
                        type=Outlaw
                        description=Urza Afalas
                        user_description= _ "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
                        [modifications]
                            {TRAIT_LOYAL}
                            {TRAIT_STRONG}
                        [/modifications]
                    [/unit]

                    {CLEAR_VARIABLE stored_Urza_Afalas}

                    [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}

                    [redraw]
                        side=1
                    [/redraw]

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

                    [message]
                        description=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]
                        description=Sir Gerrick
                        message= _ "The elves have abandoned us in this accursed forest! We are surely lost!"
                    [/message]

                    [message]
                        description=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]

                    [remove_shroud]
                        side=1
                        x,y=0-99,0-99
                    [/remove_shroud]

                    [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]
                    [/objectives]
                [/command]
            [/option]

            [option]
                id=reject_bandits
                message= _ "Your crimes are too great. You will fall with the rest of the foul undead!"
                [command]
                    [message]
                        description=Urza Afalas
                        message= _ "Then this parlay is over! You may have sounded the doom of all of us!"
                    [/message]

                    [message]
                        description=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 the last of the bandit leaders."
                            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]
                    [/objectives]
                [/command]
            [/option]
        [/message]
    [/event]

    # Urza Afalas is killed

    [event]
        name=die
        [filter]
            description=Urza Afalas
        [/filter]

        [if]
            [variable]
                name=side_with_bandits
                equals=yes
            [/variable]
            [then]
                [message]
                    description=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]
                    description=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
            description=Beast of the Lake
            user_description= _ "Beast of the Lake"
            x,y=15,39
        [/unit]

        [message]
            description=Beast of the Lake
            message= _ "Graar!"
        [/message]
    [/event]

    # Someone attacks Mal M'brin and he vanishes!

    [event]
        name=die

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

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

        [if]
            [variable]
                name=side_with_bandits
                equals=yes
            [/variable]
            [then]
                [message]
                    description=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]
                    description=Deoran
                    image=portraits/deoran-glad.png
                    message= _ "Indeed. The dark king has fallen. Now that the elves have abandoned us, our lives depend on Urza Afalas. Will you lead us from this accursed forest?"
                [/message]
                [message]
                    description=Urza Afalas
                    message= _ "What choice do I have? My life is in as much danger as yours. I will lead you and your men back to the lands of Wesnoth if you will grant me pardon."
                [/message]
                [message]
                    description=Deoran
                    message= _ "I cannot promise clemency, as that decision must be made by the council at Westin, but I will plead your case."
                [/message]
                [message]
                    description=Urza Afalas
                    message= _ "More than that I cannot ask."
                [/message]
                [endlevel]
                    result=victory
                    next_scenario=6b_The_Long_March
                    bonus=yes
                [/endlevel]
            [/then]
            [else]
                [message]
                    description=Sir Gerrick
                    message= _ "We have beaten them both, criminals and undead!"
                [/message]
                [message]
                    description=Deoran
                    image=portraits/deoran-glad.png
                    message= _ "We should make haste to return to Wesnoth before the harvest. Fall has already been upon us for some time."
                [/message]
                [message]
                    description=Ethiliel
                    message= _ "Do not be so hasty; great mages are no mere tricksters to be defeated so easily. I fear that there are tunnels and catacombs buried beneath his fortress and that we have merely defeated a spectre. If we wish to cleanse the land of his evil, we must enter the darkness and root him out from within."
                [/message]
                [message]
                    description=Deoran
                    image=portraits/deoran-sad.png
                    message= _ "My men are not dwarves! How are we to fight in catacombs and tunnels?"
                [/message]
                [message]
                    description=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]
                    description=Deoran
                    message= _ "Go, Sir Gerrick, and take with you an escort of elves, if Ethiliel will permit it."
                [/message]
                [message]
                    description=Ethiliel
                    message= _ "Indeed I do. My kinsfolk will protect you and your message!"
                [/message]
                [message]
                    description=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
                [/endlevel]
            [/else]
        [/if]
    [/event]
[/scenario]
