#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

    {SCENARIO_MUSIC wanderer.ogg}
    {EXTRA_SCENARIO_MUSIC knolls.ogg}

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

            note={EARLY_FINISH_BONUS_NOTE}+{NEW_GOLD_CARRYOVER_NOTE_40}
        [/objectives]
    [/event]

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

#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
        id=Tharzo Kalain
        # wmllint: local spelling Tharzo
        profile=portraits/tharzo-kalain.png
        name= _ "Tharzo Kalain"

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

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

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

        canrecruit=yes
        [ai]
            passive_leader=yes
#ifdef EASY
            recruitment_pattern=fighter
#endif
#ifdef NORMAL
            recruitment_pattern=scout,fighter,fighter
#endif
#ifdef HARD
            recruitment_pattern=scout,fighter,fighter,mixed fighter
#endif
            {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
        id=Plynry
        name= _ "Plynry"
        unrenamable=yes
        [ai]
            passive_leader=yes
        [/ai]
        team_name=South_Guard
        user_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]
            [filter]
                id=Deoran
            [/filter]

            kill=no
            variable=deoran_store
        [/store_unit]

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

                {TRANSFORM_UNIT id=Deoran $deoran_type}
            [/then]
        [/if]

        {CLEAR_VARIABLE deoran_store}
    [/event]

    [event]
        name=start

        {GENERIC_UNIT 2 Trapper 6 43}
        {NAMED_GENERIC_UNIT 3 (Spearman)  8 6 () (_"Border Guard")} {GUARDIAN}
        {NAMED_GENERIC_UNIT 3 (Spearman) 10 6 () (_"Border Guard")} {GUARDIAN}
        {NAMED_GENERIC_UNIT 3 (Bowman)   10 2 () (_"Border Guard")} {GUARDIAN}
        {NAMED_GENERIC_UNIT 3 (Bowman)   10 3 () (_"Border Guard")} {GUARDIAN}
        {NAMED_GENERIC_UNIT 3 (Bowman)   11 3 () (_"Border Guard")} {GUARDIAN}

        [recall]
            id=Ethiliel
        [/recall]

        [recall]
            id=Minister Hylas
        [/recall]

        [message]
            side=2
            canrecruit=no
            image="portraits/humans/outlaw.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
            id=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
            {NEW_GOLD_CARRYOVER 40}
        [/endlevel]
    [/event]
[/scenario]
