#textdomain wesnoth-tsg
[scenario]
    id=8a_Return_To_Kerlath
    name= _ "Return To Kerlath"
    map_data="{campaigns/The_South_Guard/maps/8a_Return_To_Kerlath.map}"
    next_scenario=9a_Vengeance
#ifdef EASY
    turns=22
#endif
#ifdef NORMAL
    turns=20
#endif
#ifdef HARD
    turns=18
#endif
    victory_when_enemies_defeated=no

    [music]
        name=elf-land.ogg
        ms_before=500
    [/music]
    [music]
        name=knolls.ogg
        ms_before=500
        append=yes
    [/music]
    [music]
        name=wanderer.ogg
        ms_before=500
        append=yes
    [/music]

    {campaigns/The_South_Guard/utils/sg_deaths.cfg}

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

    {SG_RETURN_TO_KERLATH}

    [event]
        name=prestart
        [objectives]
            side=1
            [objective]
                description= _ "Move Deoran into Kerlath Province"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Deoran"
                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]

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

        team_name=South_Guard
        controller=human
        {CUSTOM_SG_FLAG}

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

    [side]
        side=2
        type=Outlaw
        description=Tharzo Kalain
        profile=portraits/tharzo-kalain.png
        user_description= _ "Tharzo Kalain"

        [modifications]
            {TRAIT_STRONG}
            {TRAIT_INTELLIGENT}
        [/modifications]

        {GOLD 60 80 100}
        {INCOME 2 3 5}

        team_name=bandits
        controller=ai

        canrecruit=yes
        [ai]
            passive_leader=yes
            recruitment_pattern= scout, fighter, fighter, mixed fighter
            {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]

    [side]
        side=3
        type=Lieutenant
        description=Plynry
        user_description= _ "Plynry"
        unrenamable=yes
        [ai]
            passive_leader=yes
        [/ai]
        team_name=South_Guard
        controller=ai
        {CUSTOM_SG_FLAG}

        {GOLD 125 100 80}
        {INCOME 4 2 0}

        fog=no
        shroud=no
        recruit=
        canrecruit=yes
    [/side]

    [event]
        name=prestart

        [store_unit]
            variable=deoran_store
            kill=yes
            [filter]
                description=Deoran
            [/filter]
        [/store_unit]

        [if]
            [variable]
                name=deoran_store.type
                equals=Dismounted Commander 1
            [/variable]
            [then]
                {VARIABLE deoran_store.type "Junior Commander"}
                {VARIABLE deoran_store.moves 6}
            [/then]
        [/if]
        [if]
            [variable]
                name=deoran_store.type
                equals=Dismounted Commander 2
            [/variable]
            [then]
                {VARIABLE deoran_store.type "Horseman Commander"}
                {VARIABLE deoran_store.moves 7}
            [/then]
        [/if]
        [if]
            [variable]
                name=deoran_store.type
                equals=Dismounted Commander 3
            [/variable]
            [then]
                {VARIABLE deoran_store.type "Mounted General"}
                {VARIABLE deoran_store.moves 8}
            [/then]
        [/if]

        [unstore_unit]
            variable=deoran_store
            find_vacant=yes
        [/unstore_unit]

        [store_unit]
            [filter]
                description=Deoran
            [/filter]

            kill=yes
            variable=deoran_store
        [/store_unit]

        [unstore_unit]
            variable=deoran_store
            find_vacant=no
        [/unstore_unit]

        {CLEAR_VARIABLE deoran_store}

        {FULL_HEAL description=Deoran}

        {GENERIC_UNIT 2 Trapper 6 43}
    [/event]

    [event]
        name=start

        {SG_GUARD (Spearman) (Border Guard) (_"Border Guard") 3 8 6}
        {SG_GUARD (Spearman) (Border Guard) (_"Border Guard") 3 10 6}
        {SG_GUARD (Bowman) (Border Guard) (_"Border Guard") 3 10 2}
        {SG_GUARD (Bowman) (Border Guard) (_"Border Guard") 3 10 3}
        {SG_GUARD (Bowman) (Border Guard) (_"Border Guard") 3 11 3}

        [recall]
            description=Ethiliel
        [/recall]

        [recall]
            description=Minister Hylas
        [/recall]

        [message]
            side=2
            canrecruit=no
            image="portraits/Nicholas_Kerpan/human-poacher.png"
            message= _ "Tharzo! That meddler who killed the Urza brothers approaches from the south. His men and horses look worn out."
        [/message]

        [message]
            speaker="Tharzo Kalain"
            message= _ "The dark gods have put revenge in our laps. Destroy them all before they reach the border fort!"
        [/message]
    [/event]

    [event]
        name=moveto
        [filter]
            side=1
            x=1-19
            y=1-3
            description=Deoran
        [/filter]

        [message]
            speaker="Plynry"
            message= _ "Halt! Who comes to the border of Wesnoth?"
        [/message]

        [message]
            speaker="Deoran"
            message= _ "It is I, Deoran, commander of the South Guard, and my men."
        [/message]

        [message]
            speaker="Plynry"
            message= _ "Deoran? You had been thought lost long since. But I see by your men's gear and drill that they are of the South Guard indeed. Pass.."
        [/message]

        [message]
            speaker="Deoran"
            message= _ "We, and our elvish allies, have won a great battle against a lich."
        [/message]

        [message]
            speaker="Plynry"
            message= _ "Elvish allies? I think you had best make haste to Westin. There are rumors of trouble with the elves of the Aethenwood."
        [/message]

        # Unstore Sir Gerrick and his troops back so that everyone will be happily
        # reunited at the beginning of the next scenario.

        {VARIABLE stored_Sir_Gerrick.x "recall"}
        {VARIABLE stored_Sir_Gerrick.y "recall"}

        [unstore_unit]
            variable=stored_Sir_Gerrick
        [/unstore_unit]

        {FOREACH stored_Sir_Gerrick_army i}
        {VARIABLE stored_Sir_Gerrick_army[$i].x "recall"}
        {VARIABLE stored_Sir_Gerrick_army[$i].y "recall"}

        [unstore_unit]
            variable=stored_Sir_Gerrick_army[$i]
        [/unstore_unit]
        {NEXT i}

        {CLEAR_VARIABLE stored_Sir_Gerrick_army}

        [endlevel]
            result=victory
            bonus=yes
        [/endlevel]
    [/event]
[/scenario]
