#textdomain wesnoth-tsg
[scenario]
    id=03_A_Desperate_Errand

    name= _ "A Desperate Errand"
    next_scenario=04_Vale_of_Tears

    {SCENARIO_MUSIC wanderer.ogg}
    {EXTRA_SCENARIO_MUSIC breaking_the_chains.ogg}

    map_data="{campaigns/The_South_Guard/maps/03_A_Desperate_Errand.map}"

    {campaigns/The_South_Guard/utils/sg_deaths.cfg}

    {DUSK}
    {FIRST_WATCH}
    {SECOND_WATCH}
    {DAWN}
    {MORNING}
    {AFTERNOON}

    victory_when_enemies_defeated=no
    {TURNS 30 24 20}

    # The South Guard

    [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 120 105 75}

        canrecruit=yes
        recruit=Bowman, Spearman

        [village]
            x,y=40,32
        [/village]
    [/side]

    {STARTING_VILLAGES 1 4}

    # The Bandit Armies

    [side]
        side=2
        type=Rogue
        id=Urza Fastik
        name= _ "Urza Fastik"

        team_name=bandits
        user_team_name=_"Bandits"
        controller=ai

        {GOLD 20 40 70}

        canrecruit=yes
        [ai]
#ifdef EASY
            recruitment_pattern=fighter,scout,scout
#else
            recruitment_pattern=fighter,scout,archer,scout
#endif
            {QUANTITY aggression 0.55 0.75 0.85}
            {ATTACK_DEPTH 3 4 5}
            village_value=0.1
            villages_per_scout=10
            [target]
                id=Deoran
                value=10.0
            [/target]
            [protect_location]
                x,y=28,16
                radius=10
                value=5.0
            [/protect_location]
            [avoid]
                x,y=1-24,1-9
            [/avoid]
        [/ai]

#ifdef EASY
        recruit=Ruffian,Thug,Footpad,Vampire Bat
#endif
#ifdef NORMAL
        recruit=Ruffian,Thug,Thief,Poacher,Vampire Bat,Skeleton
#endif
#ifdef HARD
        recruit=Footpad,Thief,Poacher,Vampire Bat,Skeleton,Skeleton Archer
#endif
        {FLAG_VARIANT ragged}
    [/side]

    {STARTING_VILLAGES_AREA 2 28 21 5}
    {STARTING_VILLAGES_AREA 2 12 27 10}

    [event]
        name=prestart

        # Reduce the size of the enemy camp on 'trivial' difficulty
#ifdef EASY
        {MODIFY_TERRAIN Gg 16 21}
        {MODIFY_TERRAIN Gg 15 21}
#endif
    [/event]

    #start
    [event]
        name=start
        [recall]
            id=Sir Gerrick
        [/recall]
        [recall]
            id=Minister Hylas
        [/recall]

        [message]
            speaker=narrator
            message= _ "Deoran and his men came to the eastern border of the Aethenwood..."
            image=wesnoth-icon.png
        [/message]

        [message]
            speaker=Deoran
            message= _ "Look, men! There is the forest of the Elves to the northwest. Let us hasten across the river and the hills."
        [/message]

        [message]
            speaker=Minister Hylas
            message= _ "Be careful, Deoran. No man has set foot in the elvish woods for many a year. We do not know how they will receive us. Sir Loris thought that it was some trick of theirs trying to bring him into the woods..."
        [/message]

        [message]
            speaker=Deoran
            message= _ "But if we do not discover the source of these undead warriors, the whole province shall surely be swallowed up by them, and then their bandit masters will fare no better. We cannot allow it!"
        [/message]

        [message]
            speaker=Urza Fastik
            message= _ "I have lost two brothers to Deoran — I shall not allow him to reach the accursed elves! Deoran will die before he reaches the western forest!"
        [/message]

        {HIGHLIGHT_IMAGE 17 7 items/gohere.png ()}

#ifdef EASY
        [message]
            speaker=narrator
            message= _ "You must move Deoran to the center of the elvish citadel. Be sure to recruit a force strong enough to drive off the bandits before moving Deoran from his encampment!"
            image=wesnoth-icon.png
        [/message]
#endif

        [scroll_to_unit]
            id=Deoran
        [/scroll_to_unit]

        [objectives]
            side=1
            [objective]
                description= _ "Move Deoran to the elvish city in the northern woods"
                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]

            {TURNS_RUN_OUT}

            [gold_carryover]
                bonus=yes
                carryover_percentage=40
            [/gold_carryover]
        [/objectives]
    [/event]

    [event]
        name=turn 2

        [message]
            speaker=Deoran
            message= _ "There is so much ground to cover. If only our riders would arrive!"
        [/message]
    [/event]

    [event]
        name=turn 3

        [unit]
            side=1
            id=Jarek
            name= _ "Jarek"
            {QUANTITY type Cavalier Dragoon Cavalryman}
            x,y=41,33
            facing=sw
            upkeep=full
            [modifications]
                {TRAIT_STRONG}
                {TRAIT_QUICK}
            [/modifications]
        [/unit]

        [message]
            speaker=Jarek
            message= _ "Commander, I received your request for reinforcements, and I have brought my riders with me!"
        [/message]

        [message]
            speaker=narrator
            image="units/human-loyalists/cavalryman-attack.png~RC(magenta>red)"
#ifdef EASY
            message= _ "You may now recruit Cavalrymen. They are fast and deadly on grassland, but weak in forests and hills. They can keep up with Deoran, so use them to guard him!"
#else
            message= _ "You may now recruit Cavalrymen."
#endif
        [/message]

        [allow_recruit]
            side=1
            type=Cavalryman
        [/allow_recruit]
    [/event]

    [event]
        name=last breath
        [filter]
            speaker=Urza Fastik
        [/filter]

        [message]
            speaker=unit
            message= _ "What have we done?! Even our undead allies cannot stand against this commander!"
        [/message]

        [kill]
            x,y=$x1,$y1
            animate=yes
        [/kill]

        [role]
            role=second
            type=Spearman,Swordsman,Pikeman,Javelineer,Bowman,Longbowman,Cavalryman,Dragoon
        [/role]

        [message]
            role=second
            message= _ "I hope that’s the last of the bandits! How many more of these foul undead must we fight?"
        [/message]

        # Deoran arrives at the elvish citadel

        [message]
            speaker=Deoran
            message= _ "If we are to check the advance of the dead, I must reach the home of the elves!"
        [/message]
    [/event]

    [event]
        name=moveto
        [filter]
            id=Deoran
            x,y=17,7
        [/filter]

        [remove_item]
            x,y=17,7
        [/remove_item]

        {NAMED_LOYAL_UNIT 1 (Elvish Ranger) 15 4 (Linderion) (_"Linderion")}
        {NAMED_LOYAL_UNIT 1 (Elvish Marksman) 19 4 (Mithalwe) (_"Mithalwe")}
        {NAMED_LOYAL_UNIT 1 (Elvish Ranger) 13 7 (Sidaurios) (_"Sidaurios")}
        {NAMED_LOYAL_UNIT 1 (Elvish Avenger) 21 7 (Eltenmir) (_"Eltenmir")}
        {NAMED_LOYAL_UNIT 1 (Elvish Hero) 15 10 (Vardanos) (_"Vardanos")}
        {NAMED_LOYAL_UNIT 1 (Elvish Outrider) 19 10 (Talchar) (_"Talchar")}

        [unit]
#ifdef EASY
            type=Elvish Shyde
#else
            type=Elvish Druid
#endif
            id=Ethiliel
            name= _ "Ethiliel"
            profile=portraits/ethiliel.png
            {IS_HERO}
            side=1
            x,y=18,6
            facing=sw
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_QUICK}
            [/modifications]
        [/unit]

        [message]
            speaker=Linderion
            message= _ "Halt! Who has entered our citadel without leave?"
        [/message]

        [message]
            speaker=Deoran
            message= _ "De..."  # wmllint: no spellcheck
        [/message]

        [message]
            speaker=Linderion
            message= _ "Speak carefully, for the penalty for trespass on our lands is death, and your life is thus forfeit."
        [/message]

        [message]
            speaker=Deoran
            image=portraits/deoran-mad.png
            message= _ "Deora..."   # wmllint: no spellcheck
        [/message]

        [message]
            speaker=Ethiliel
            # wmllint: local spelling Elrath
            message= _ "Stay a moment. This man wears the colors of Wesnoth, and Kalenz told us not all the folk of Wesnoth are foes of the elves. Tell us, then, what brings you to the hallowed citadel of Elrath?"
        [/message]

        [message]
            speaker=Deoran
            message= _ "My lady, we have come to the elves to seek guidance. Bandits and criminals in our land have summoned the dead to help them plunder our farms and villages. They are coming across the river from the great forest to the south of our lands, where no man has yet traveled."
        [/message]

        [message]
            speaker=Ethiliel
            message= _ "The elves know of the great southern forest, and have walked its paths many times. What would you do, Deoran?"
        [/message]

        [message]
            speaker=Deoran
            message= _ "I would lead my men south of the river to find the source of these beings of darkness that we might destroy it. For surely, ere that be done, we cannot stand against them for long."
        [/message]

        [message]
            speaker=Ethiliel
            message= _ "Indeed you are brave to face such foes. But I fear that alone you will fail and fall. One elf now lives who remembers the secrets of the undead that we learned when Haldric I came to our land. His name is Mebrin, and he lives, secluded in the hills, near here. I will take you to him."
        [/message]

        [message]
            speaker=Deoran
            image=portraits/deoran-glad.png
            message= _ "My thanks, lady."
        [/message]

        [kill]
            type=Elvish Ranger,Elvish Avenger,Elvish Outrider,Elvish Hero,Elvish Marksman
            animate=no
            fire_event=no
        [/kill]

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