#textdomain wesnoth-ei
[scenario]
    id=The_Outpost
    name= _ "The Outpost"
    next_scenario=Escape_Tunnel
    map_data="{campaigns/Eastern_Invasion/maps/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, and there were strange occurrences in the Estmark Hills on the eastern border of Wesnoth."
            background=eastern-invasion-map.png
        [/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."
            background=eastern-invasion-map.png
        [/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."
            background=eastern-invasion-map.png
        [/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."
            background=eastern-invasion-map.png
        [/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."
            background=eastern-invasion-map.png
        [/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."
            background=eastern-invasion-map.png
        [/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. It is with them this story is concerned."
            background=eastern-invasion-map.png
        [/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
            {TO_THE_OUTPOST}
        [/part]
    [/story]

    {campaigns/Eastern_Invasion/utils/deaths.cfg}

    [side]
        type=Sergeant
        id=Gweddry
        name= _ "Gweddry"
        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
            profile=portraits/dacyn.png
            random_traits=no
            [modifications]
                {TRAIT_LOYAL}
            [/modifications]
        [/unit]
    [/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

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

        [objectives]
            side=1
            [objective]
#ifdef EASY
                description= _ "Resist until Dacyn's return tomorrow night"
#else
                description= _ "Resist until Dacyn's return in two days"
#endif
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Gweddry"
                condition=lose
            [/objective]

            note={EARLY_FINISH_BONUS_NOTE}+{NEW_GOLD_CARRYOVER_NOTE_40}
        [/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! But wait... I sense something... They must not see me..."
        [/message]
        [store_unit]
            [filter]
                id=Dacyn
            [/filter]

            kill=yes
            variable=stored_Dacyn
        [/store_unit]
        [move_unit_fake]
            type=Ancient Lich
            side=2
            x=39,34
            y=16,14
        [/move_unit_fake]
        [unit]
            type=Ancient Lich
            id=Mal-Ravanal
            name= _ "Mal-Ravanal"
            x,y=34,14
            side=2
            facing=sw
            profile=portraits/mal-ravanal.png
        [/unit]
        [message]
            speaker=Mal-Ravanal
            message= _ "Hm. I do not sense anything out of the ordinary here. My scouts must have deceived me. Very well; destroy them."
        [/message]
        [message]
            speaker=Mal-Sakkat
            # wmllint: local spelling Archon
            message= _ "Very well, Dark Archon. They will die. And then?"
        [/message]
        [message]
            speaker=Mal-Ravanal
            message= _ "On with the search. I trust you can defeat these men yourself? I have no time to waste here."
        [/message]
        [kill]
            id=Mal-Ravanal
        [/kill]
        [move_unit_fake]
            type=Ancient Lich
            side=2
            x=34,39
            y=14,16
        [/move_unit_fake]
        [message]
            speaker=Gweddry
            message= _ "What?! Men, to arms! And where did Dacyn go?!"
        [/message]
        [message]
            speaker=Gweddry
            message= _ "There are too many undead, I cannot defeat them... but my orders are to hold this outpost at all costs. It may be we will die this day."
        [/message]
        [message]
            speaker=Gweddry
            message= _ "But... somehow, I do not think Dacyn has abandoned us. He must have had a reason for leaving."
        [/message]
    [/event]

    #Dacyn pops out on keep and gives message about trapdoor.
    [event]
#define WIN_SCENARIO
    [message]
        speaker=Gweddry
        message= _ "Follow me, men! Through the trapdoor!"
    [/message]
    [hide_unit]
        x,y=9,16
    [/hide_unit]
    [redraw]
    [/redraw]
    [endlevel]
        result=victory
        bonus=yes
        {NEW_GOLD_CARRYOVER 40}
    [/endlevel]
#enddef

#ifdef EASY
        name=turn 10
#else
        name=turn 12
#endif
        [item]
            x=9
            y=16
            image=scenery/trapdoor-open.png
        [/item]
        [unstore_unit]
            variable=stored_Dacyn
            find_vacant=yes
        [/unstore_unit]
        {CLEAR_VARIABLE stored_Dacyn}
        [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= _ "It is pointless to try to defend it. Now, come on, we do not have much time to spare!"
        [/message]
        [if]
            [have_unit]
                id=Gweddry
                x,y=9,16
            [/have_unit]
            [then]
                {WIN_SCENARIO}
            [/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]
                    [objective]
                        description= _ "Turns run out"
                        condition=lose
                    [/objective]

                    note={EARLY_FINISH_BONUS_NOTE}+{NEW_GOLD_CARRYOVER_NOTE_40}
                [/objectives]
            [/else]
        [/if]
        #you win when you move to the trapdoor
        [event]
            name=moveto
            [filter]
                x=9
                y=16
                id=Gweddry
            [/filter]
            {WIN_SCENARIO}
        [/event]
    [/event]

    #you are urged to hurry
    [event]
        name=turn 14
        [message]
            speaker=Dacyn
            message= _ "Hurry! Before long enemy reinforcements will arrive, and we will all die! Go to the trapdoor!"
        [/message]
    [/event]

    {EARLY_DEFEAT}
[/scenario]
