#textdomain wesnoth-ei
[scenario]
    id=01_The_Outpost
    name= _ "The Outpost"
    next_scenario=02_The_Escape_Tunnel
    map_data="{campaigns/Eastern_Invasion/maps/01_The_Outpost.map}"
    turns=16
    {DEFAULT_SCHEDULE}

    {INTRO_AND_SCENARIO_MUSIC knolls.ogg loyalists.ogg}
    {EXTRA_SCENARIO_MUSIC nunc_dimittis.ogg}
    {EXTRA_SCENARIO_MUSIC suspense.ogg}

    [story]
        [part]
            # It is 625 YW. Konrad II is king, having reigned since 612.
            story= _ "It was the thirteenth year of Konrad II’s reign when the strange occurrences in the Estmark Hills on the eastern border of Wesnoth began."
            {EI_BIGMAP}
        [/part]
        [part]
            story= _ "Cattle and beasts of burden were found dead in the fields, and men went missing from their houses, with no clues but a thin stream of black blood. At first the settlers suspected raiders from the great desert, but when they sent scouts east they found nothing but a small mountain range and miles of swamp."
            {EI_BIGMAP}
        [/part]
        [part]
            story= _ "The disappearances did not stop, and every day the terror grew greater. Eventually, the people living in the eastern villages sent a messenger to the King, asking for help. The messenger rode hard for many days and nights, and finally reached the city of Weldyn."
            {EI_BIGMAP}
        [/part]
        [part]
            story= _ "When the King received news of the problem, his advisor Dacyn had much to say. Apparently, these attacks were connected to similar ones that occurred earlier on the far southern border, attacks by undead. Dacyn outlined a plan to combat these intrusions."
            {EI_BIGMAP}
        [/part]
        [part]
            # The River Guard posts had been built in 470 YW.  They were
            # abandoned in 544 YW; the wave of colonization had begun around
            # 530 YW.
            story= _ "In the days of the king Garard I, two strong-points had been built along the near bank of the Weldyn, south of Soradoc, to stop bandits and orcish raiders out of the Estmarks from entering Wesnoth. But in later years the River Guard posts had been abandoned, as colonists spread into the Estmarks and the orcs were driven in retreat north of the Great River."
            {EI_BIGMAP}
        [/part]
        [part]
            story= _ "With unknown enemies pressing Wesnoth from the East, Konrad II decided to re-build and re-man the River Guard outposts, and use them to keep the Crown’s eye and hand firmly on the settled country to either side of the lower Weldyn. He sent two of the most promising young officers to them."
            {EI_BIGMAP}
        [/part]
        [part]
            story= _ "To the northern outpost he sent Owaec, a clan noble. To the southern outpost, he sent Gweddry, who would be accompanied by Dacyn the mage. Our story begins there."
            {EI_BIGMAP}
        [/part]
        [part]
            story= _ "All went well once the King’s forces arrived. There were no attacks for several weeks, and Gweddry’s men started to grow incautious. Then, at dawn one day, Gweddry and his men were roused by the startled cries of the night watchmen..."
            show_title=yes
            {EI_BIGMAP}
        [/part]
    [/story]

    {BIGMAP_01}

    {campaigns/Eastern_Invasion/utils/deaths.cfg}

    [side]
        type=Sergeant
        id=Gweddry
        name= _ "Gweddry"
        facing=se
        side=1
        canrecruit=yes
        recruit=Spearman,Cavalryman,Mage,Heavy Infantryman
        controller=human
        profile=portraits/gweddry.png
        {GOLD 180 130 120}
        team_name=wesnothians
        user_team_name=_"Wesnothians"
        [unit]
            type=White Mage
            id=Dacyn
            name= _ "Dacyn"
            {IS_HERO}
            side=1
            x=9
            y=16
            facing=se
            profile=portraits/dacyn.png
            random_traits=no
            [modifications]
                {TRAIT_LOYAL}
            [/modifications]
        [/unit]
        {FLAG_VARIANT loyalist}
    [/side]

    # The intent here is that Gweddry starts with control of all
    # villages west of the river (e.g. within Wesnoth) and those very
    # close to the outpost east of the river. This will be worth
    # about unit-build per turn. But he won't keep all of these
    # for long...
    {STARTING_VILLAGES 1 9}
    {STARTING_VILLAGES_AREA 1 15 2 7}
    {STARTING_VILLAGES_AREA 1 5 4 4}

#define OUTPOST_AI_STUFF
    [ai]
        passive_leader=yes
        grouping=no
        aggression=0.6
    [/ai]
#enddef

    [side]
        type=Dark Sorcerer
        id=Mal-Sakkat
        name= _ "Mal-Sakkat"
        side=2
        canrecruit=yes
        facing=sw
#ifdef EASY
        recruit=Walking Corpse,Skeleton Archer
#else
        recruit=Walking Corpse,Skeleton,Skeleton Archer
#endif
        [ai]
            recruitment_pattern=fighter, fighter, archer, fighter
        [/ai]
        team_name=undead
        user_team_name=_"Undead"
        {GOLD 40 60 80}
        {FLAG_VARIANT undead}
        {OUTPOST_AI_STUFF}
    [/side]

    {STARTING_VILLAGES 2 5}

    [side]
        type=Dark Sorcerer
        id=Mal-Talar
        name= _ "Mal-Talar"
        facing=sw
#ifdef EASY
        recruit=Vampire Bat,Skeleton Archer
#else
        recruit=Vampire Bat,Skeleton,Skeleton Archer
#endif
        side=3
        canrecruit=yes

        team_name=undead
        user_team_name=_"Undead"
        {GOLD 50 70 100}
        {FLAG_VARIANT undead}
        {OUTPOST_AI_STUFF}
    [/side]

    {STARTING_VILLAGES 3 5}

    [side]
        type=Lich
        id=Mal-Uldhar
        name= _ "Mal-Uldhar"
        facing=sw
#ifdef EASY
        recruit=Vampire Bat,Revenant
#else
        recruit=Vampire Bat,Revenant,Bone Shooter
#endif
        side=4
        canrecruit=yes
        team_name=undead
        user_team_name=_"Undead"
        {GOLD 80 110 130}
        {FLAG_VARIANT undead}
        {OUTPOST_AI_STUFF}
    [/side]

    {LIMIT_CONTEMPORANEOUS_RECRUITS 4 Revenant 1}

#ifndef EASY
    {LIMIT_CONTEMPORANEOUS_RECRUITS 4 (Bone Shooter) 2}
#endif

    {STARTING_VILLAGES 4 8}

    [event]
        name=prestart

        {TEAM_COLOR_OVERRIDE id=Dacyn teal}

        # {SCATTER_IMAGE (terrain=Gs^Fp) 20 scenery/pine1.png}
        # {SCATTER_IMAGE (terrain=Gg) 4 scenery/oak-leaning.png}

        [objectives]
            side=1
            [objective]
                description= _ "Defend the outpost"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Gweddry"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Dacyn"
                condition=lose
            [/objective]
            [gold_carryover]
                bonus=yes
                carryover_percentage=40
            [/gold_carryover]
        [/objectives]
#ifdef EASY
        [terrain]
            x,y=4,13
            terrain=Gg
        [/terrain]
        [terrain]
            x,y=5,14
            terrain=Gg^Ve
        [/terrain]
#endif
    [/event]

    #start event
    [event]
        name=start
        [message]
            speaker=Gweddry
            message= _ "What? What is going on?"
        [/message]
        [message]
            speaker=Dacyn
            message= _ "Look. To the east. Undead approach!"
        [/message]
        [message]
            speaker=Mal-Talar
            message= _ "Ah, interesting..."
        [/message]
        [message]
            speaker=Gweddry
            message= _ "Men, to arms!"
        [/message]
    [/event]

    #Dacyn's disappearance and Mal-Ravanal's appearance
    #(turn refresh to be nice and let Dacyn heal everyone first)
    [event]
        name=side 1 turn 7 refresh

        [message]
            speaker=Dacyn
            message= _ "I sense a great evil... Can it be? Gweddry, I must not be seen."
        [/message]

        {LIGHT_SHIELD_EFFECT_OBJECT_ID Dacyn}

        [animate_unit]
            [filter]
                id=Dacyn
            [/filter]
            flag=disappear
        [/animate_unit]

        [store_unit]
            [filter]
                id=Dacyn
            [/filter]

            kill=yes
            variable=stored_Dacyn
        [/store_unit]

        [delay]
            time=100
        [/delay]

        [unit]
            type=Lich Lord
            id=Mal-Ravanal
            name= _ "Mal-Ravanal"
            x,y=34,14
            side=2
            facing=sw
            profile=portraits/mal-ravanal.png
            animate=yes
        [/unit]
        [message]
            speaker=Mal-Ravanal
            message= _ "This is the resistance you spoke of, an untrained commander and a few fresh recruits? You will suffer for your incompetence. Destroy them, and dare not bother me again."
        [/message]
        [message]
            speaker=Mal-Talar
            # wmllint: local spelling Archon
            message= _ "Apologies, Dark Archon. They will die. And then?"
        [/message]
        [message]
            speaker=Mal-Ravanal
            message= _ "Slaughter the villagers and march onwards. You have wasted enough time here already."
        [/message]
        [animate_unit]
            [filter]
                id=Mal-Ravanal
            [/filter]
            flag=pre_teleport
        [/animate_unit]
        [kill]
            id=Mal-Ravanal
        [/kill]

        [message]
            speaker=Gweddry
            message= _ "What?! We must hold the outpost! And where did Dacyn go?!"
        [/message]
    [/event]

    #Dacyn pops out on keep and gives message about trapdoor.
    [event]
#ifdef EASY
        name=turn 10
#else
        name=turn 12
#endif
        [scroll_to]
            x,y=9,16
        [/scroll_to]
        [item]
            x=9
            y=16
            image=scenery/trapdoor-open.png
        [/item]
        [unstore_unit]
            variable=stored_Dacyn
            x,y=10,15
            find_vacant=yes
        [/unstore_unit]
        {CLEAR_VARIABLE stored_Dacyn}
        [animate_unit]
            [filter]
                id=Dacyn
            [/filter]
            flag=reappear
        [/animate_unit]
        [message]
            speaker=Dacyn
            message= _ "Gweddry? Good! You are still alive. Quickly, we must leave this place!"
        [/message]
        [message]
            speaker=Gweddry
            message= _ "Where did you go?! And where did you come from?"
        [/message]
        [message]
            speaker=Dacyn
            message= _ "There is no time to explain. If you wish to survive, you will escape through this trapdoor."
        [/message]
        [message]
            speaker=Gweddry
            message= _ "But what about the outpost?"
        [/message]
        [message]
            speaker=Dacyn
            message= _ "This outpost is already lost. We must defeat this evil if Wesnoth is to survive. Now, come on, we do not have much time to spare!"
        [/message]
        [gold]
            side=2,3,4
            amount=100
        [/gold]
        [if]
            [have_unit]
                id=Gweddry
                x,y=9,16
            [/have_unit]
            [then]
                [endlevel]
                    result=victory
                    bonus=yes
                    {NEW_GOLD_CARRYOVER 40}
                [/endlevel]
            [/then]
            [else]
                [objectives]
                    side=1
                    [objective]
                        description= _ "Move Gweddry to the trapdoor"
                        condition=win
                    [/objective]
                    [objective]
                        description= _ "Death of Gweddry"
                        condition=lose
                    [/objective]
                    [objective]
                        description= _ "Death of Dacyn"
                        condition=lose
                    [/objective]

                    {TURNS_RUN_OUT}

                    [gold_carryover]
                        bonus=yes
                        carryover_percentage=40
                    [/gold_carryover]
                [/objectives]
            [/else]
        [/if]
        #you win when you move to the trapdoor
        [event]
            name=moveto
            [filter]
                x=9
                y=16
                id=Gweddry
            [/filter]
            [endlevel]
                result=victory
                bonus=yes
                {NEW_GOLD_CARRYOVER 40}
            [/endlevel]
        [/event]
    [/event]

    #you are urged to hurry
    [event]
        name=turn 14
        [message]
            speaker=Dacyn
            message= _ "Hurry! We cannot defeat this evil today! We must escape!"
        [/message]
    [/event]

    [event]
        name=victory
        [message]
            speaker=Gweddry
            message= _ "Follow me, men! Through the trapdoor!"
        [/message]
        [hide_unit]
            x,y=9,16
        [/hide_unit]
        [redraw]
        [/redraw]
    [/event]

    {EARLY_DEFEAT}
[/scenario]
