#textdomain wesnoth-ei

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

    {DEFAULT_SCHEDULE}

    {SETUP_CAMPFIRES}

    {SCENARIO_MUSIC       loyalists.ogg}
    {EXTRA_SCENARIO_MUSIC nunc_dimittis.ogg}

    [story]
        [part]
            music=knolls.ogg
            # 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]

    {EI_TRACK {JOURNEY_01_NEW} }

    # wmllint: validate-off
    [side]
        side=1
        controller=human
        recruit=Spearman,Cavalryman,Mage,Heavy Infantryman
        {GOLD 180 130 120}
        team_name=wesnothians
        user_team_name= _ "Wesnothians"
        {FLAG_VARIANT loyalist}

        # wmlint: recognize Gweddry
        {CHARACTER_STATS_GWEDDRY}

        facing=se

        [unit]
            x,y=9,16
            facing=se

            # wmllint: recognize Dacyn
            {CHARACTER_STATS_DACYN}
        [/unit]
    [/side]
    # wmllint: validate-on

    [side]
        side=2
        controller=ai
#ifdef EASY
        recruit=Walking Corpse,Skeleton Archer
#else
        recruit=Walking Corpse,Skeleton,Skeleton Archer
#endif
        {GOLD 40 60 80}
        team_name=undead
        user_team_name= _ "Undead"
        {FLAG_VARIANT undead}

        type=Dark Sorcerer
        id=Mal-Sakkat
        name= _ "Mal-Sakkat"
        canrecruit=yes

        facing=sw

        [ai]
            recruitment_pattern=fighter, fighter, archer, fighter
            passive_leader=yes
            grouping=no
            aggression=0.8 # Sakkat is the more aggressive side
        [/ai]
    [/side]

    [side]
        side=3
        controller=ai
#ifdef EASY
        recruit=Vampire Bat,Skeleton Archer
#else
        recruit=Vampire Bat,Skeleton,Skeleton Archer
#endif
        {GOLD 50 70 100}
        team_name=undead
        user_team_name= _ "Undead"
        {FLAG_VARIANT undead}

        type=Dark Sorcerer
        id=Mal-Talar
        name= _ "Mal-Talar"
        canrecruit=yes

        facing=sw

        [ai]
            passive_leader=yes
            grouping=no
            aggression=0.6
            scout_village_targeting=0.9 # Most combat-oriented side. Don't go for villages as much
            [goal]
                name=target
                [criteria]
                    id=Gweddry
                [/criteria]
                value=3
            [/goal]
        [/ai]
    [/side]

    [side]
        side=4
        controller=ai
#ifdef EASY
        recruit=Vampire Bat,Revenant,Skeleton
#else
        recruit=Vampire Bat,Revenant,Bone Shooter,Skeleton,Skeleton Archer
#endif
        {GOLD 80 110 130}
        team_name=undead
        user_team_name= _ "Undead"
        {FLAG_VARIANT undead}

        type=Lich
        id=Mal-Uldhar
        name= _ "Mal-Uldhar"
        canrecruit=yes

        facing=sw

        [ai]
            passive_leader=yes
            grouping=no
            aggression=0.6
            [goal]
                name=target
                [criteria]
                    id=Dacyn
                [/criteria]
                value=2
            [/goal]
        [/ai]
    [/side]

    {LIMIT_CONTEMPORANEOUS_RECRUITS 4 Revenant 1}

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

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

    {STARTING_VILLAGES 2 6}

    {STARTING_VILLAGES 3 5}

    {STARTING_VILLAGES 4 8}

    [event]
        name=prestart

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

    [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

        {REPLACE_SCENARIO_MUSIC silence.ogg}

        [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]
            # wmllint: who CHARACTER_STATS_RAVANAL is Mal-Ravanal
            {CHARACTER_STATS_RAVANAL}
            x,y=34,14
            side=2
            facing=sw
            animate=yes
        [/unit]

        [delay]
            time=1000
        [/delay]

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

        [gold]
            side=2,3,4
            amount=25
        [/gold]

        {REPLACE_SCENARIO_MUSIC the_dangerous_symphony.ogg}
        {APPEND_MUSIC           knalgan_theme.ogg}

        [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,y=9,16
            image=scenery/trapdoor-open.png
        [/item]

        {VARIABLE stored_Dacyn.resting no}

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

        [modify_side]
            side=2,3,4

            {INCOME 5 6 7}
        [/modify_side]

        [if]
            [have_unit]
                id=Gweddry
                x,y=9,16
            [/have_unit]
            [then]
                [endlevel]
                    result=victory
                    bonus=no
                    {NEW_GOLD_CARRYOVER 40}
                [/endlevel]
            [/then]
            [else]
                [objectives]
                    side=1
                    [objective]
                        description= _ "Move Gweddry to the trapdoor"
                        condition=win
                    [/objective]
                    [objective]
                        {ALTERNATIVE_OBJECTIVE_CAPTION}
                        condition=win
                        description= _ "Defeat all enemy leaders" + {EARLY_FINISH_BONUS_FOOTNOTE}
                    [/objective]
                    [objective]
                        description= _ "Death of Gweddry"
                        condition=lose
                    [/objective]
                    [objective]
                        description= _ "Death of Dacyn"
                        condition=lose
                    [/objective]

                    {TURNS_RUN_OUT}

                    [gold_carryover]
                        bonus=no
                        carryover_percentage=40
                    [/gold_carryover]
                [/objectives]
            [/else]
        [/if]

        #you win when you move to the trapdoor
        [event]
            name=moveto
            [filter]
                x,y=9,16
                id=Gweddry
            [/filter]

            [endlevel]
                result=victory
                bonus=no
                {NEW_GOLD_CARRYOVER 40}
            [/endlevel]
        [/event]
    [/event]

    [event]
        name=enemies defeated

        [endlevel]
            result=victory
            bonus=yes
            {NEW_GOLD_CARRYOVER 40}
        [/endlevel]
    [/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}

    {HERODEATH_GWEDDRY}
    {HERODEATH_DACYN}
[/scenario]
