#textdomain wesnoth-sotbe
[scenario]
    id=14_Back_Home
    name= _ "Back Home"
    map_data="{campaigns/Son_Of_The_Black_Eye/maps/14_Back_Home.map}"
    turns=24

    {DEFAULT_SCHEDULE}

    next_scenario=15_Civil_War

    {SCENARIO_MUSIC "knolls.ogg"}
    {EXTRA_SCENARIO_MUSIC "the_city_falls.ogg"}
    {EXTRA_SCENARIO_MUSIC "elvish-theme.ogg"}

    [event]
        name=prestart
        [objectives]
            side=1,4
            [objective]
                description= _ "Defeat all enemy leaders"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Kapou’e"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Grüü"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Al’Brock"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Flar’Tar"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

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

            {AI_CONTROLLER_NOTE}

            {GREAT_HORDE_NOTE}
        [/objectives]
    [/event]

    [side]
        side=1
        id="Kapou'e"
        type=Orcish Leader
        controller=human
        team_name=Kapoue
        user_team_name=_ "Kapou’e"
        gold=300
        {BLACK_FLAG}
    [/side]

    {STARTING_VILLAGES 1 2}

    {AI_CONTROLLER () 1 2,3 ()}

    [side]
        {ALBROCK_SIDE}
        {GOLD 200 175 150}
    [/side]

    [side]
        {FLARTAR_SIDE}
        {GOLD 150 125 100}
    [/side]

    [side]
        side=4
        id=Grüü
        name=" "
        type=Great Troll
        canrecruit=yes
        team_name=Kapoue
        user_team_name=_ "Kapou’e"
        controller=human
    [/side]

    # Pre-declare some castle spans where allies will appear so
    # we can make AIs avoid them.  Otherwise they may be blocked
    # from appearing by stray units.
#define CASTLE_OF_FLARTAR
    x=27,27,27,26,26,28,28
    y=5,6,7,5,6,5,6
#enddef

#define CASTLE_OF_GRUU
    x=5,5,5,4,4,6,6
    y=3,4,5,3,4,3,4
#enddef

#define AVOID_ALLIES
    [ai]
        [avoid]
            {CASTLE_OF_FLARTAR}
        [/avoid]
        [avoid]
            {CASTLE_OF_GRUU}
        [/avoid]
    [/ai]
#enddef

    [side]
        type=General
        id=Telthys
        name= _ "Telthys"
        recruit=Spearman,Bowman,Mage,Cavalryman, Swordsman, Pikeman, Longbowman
        side=5
        canrecruit=yes
        facing=sw
        team_name=villains
        user_team_name=_"Villains"
        {GOLD 250 300 350}
        income=12
        {AVOID_ALLIES}
        {FLAG_VARIANT loyalist}
    [/side]

    {STARTING_VILLAGES 5 8}
    {STARTING_VILLAGES_AREA 5 23 36 5}

    [side]
        type=Elvish Champion
        id=Thelarion
        name= _ "Thelarion"
        recruit=Elvish Captain, Elvish Fighter, Elvish Archer, Elvish Marksman, Elvish Druid, Elvish Scout, Elvish Hero, Elvish Ranger
        side=6
        canrecruit=yes
        facing=sw
        team_name=villains
        user_team_name=_"Villains"
        {GOLD 250 300 350}
        income=12
        {AVOID_ALLIES}
        {FLAG_VARIANT wood-elvish}
    [/side]

    {STARTING_VILLAGES 6 10}

    [side]
        type=General
        id=Fredor
        name= _ "Fredor"
        recruit=Spearman,Bowman,Mage,Cavalryman, Swordsman, Pikeman, Longbowman
        side=7
        canrecruit=yes
        facing=sw
        team_name=villains
        user_team_name=_"Villains"
        {GOLD 250 300 350}
        income=12
        {AVOID_ALLIES}
        {FLAG_VARIANT loyalist}
    [/side]

    {STARTING_VILLAGES_AREA 7 27 20 8}

    [side]
        type=General
        id=Georan
        name= _ "Georan"
        recruit=Spearman,Bowman,Mage,Cavalryman, Swordsman, Pikeman, Longbowman
        side=8
        canrecruit=yes
        facing=sw
        team_name=villains
        user_team_name=_"Villains"
        {GOLD 250 300 350}
        income=12
        {AVOID_ALLIES}
        {FLAG_VARIANT loyalist}
    [/side]

    {STARTING_VILLAGES 8 10}

    [story]
        [part]
            story= _ "Having broken the dwarvish blockade, the horde continued on through the mountain pass. Kapou’e began to recognize the lands about them and sure enough, they soon found themselves back in the tribe’s homeland."
            {SOTBE_BIGMAP}
            {JOURNEY_13_OLD}
        [/part]
    [/story]

    {SOTBE_TRACK {JOURNEY_14_NEW} }

    [event]
        name=prestart

        {RENAME_IF_DEAD thelarion_dead Thelarion (_"Valan")}

        [kill]
            id=Grüü
            side=4
        [/kill]
    [/event]

    {GOT_THE_GREAT_HORDE 1,2,3,4}

    # This helps prevent the allies from suiciding themselves by preventing them
    # from leaving their castles and surrounding defensive terrain
    [event]
        name=side 2 turn refresh, side 3 turn refresh
        first_time_only=no

        [modify_unit]
            [filter]
                side=$side_number
                canrecruit=yes
            [/filter]

            [movement_costs]
                frozen=99
            [/movement_costs]
        [/modify_unit]

        [event]
            name=side turn end

            [modify_unit]
                [filter]
                    side=$side_number
                    canrecruit=yes
                [/filter]

                [movement_costs]
                    frozen=2
                [/movement_costs]
            [/modify_unit]
        [/event]
    [/event]

    [event]
        name=start

        [recall]
            id=Grüü
        [/recall]
        [recall]
            id=Jetto
        [/recall]
        [recall]
            id=Inarix
        [/recall]

        [role]
            type=Orcish Warlord,Orcish Warrior,Orcish Grunt,Direwolf Rider,Goblin Pillager,Goblin Knight,Wolf Rider
            x,y=recall,recall
            side=1
            role=army
        [/role]

        [recall]
            role=army
        [/recall]

        [message]
            speaker="Kapou'e"
            image=portraits/kapoue.png~FL()~RIGHT()
            message= _ "Well, boys, we’re home. I told you we would return one day."
        [/message]

        {STORE_UNIT_VAR role=army profile army_profile}
        [message]
            role=army
            image=$army_profile~FL()~RIGHT()
            message= _ "Boy, have they ever built this place up."
        [/message]

        [message]
            speaker="Kapou'e"
            image=portraits/kapoue.png~FL()~RIGHT()
            message= _ "Listen up, orcs. Our main objective is to rescue the shamans. It won’t work to take the human runts head-on while they sneak the shamans out the back door."
        [/message]

        [message]
            speaker="Flar'Tar"
            image=portraits/flartar.png~FL()~RIGHT()
            message= _ "What are you thinking, Chief?"
        [/message]

        [message]
            speaker="Kapou'e"
            image=portraits/kapoue.png~FL()~RIGHT()
            message= _ "My men know the land well. Flar’Tar and Al’Brock, both of you take a scout and circle around to the Northeast and Southeast respectively. Grüü, you take your trolls and circle around to the Northwest. If all goes well we shall surround them."
        [/message]

        [message]
            speaker=Grüü
            image=portraits/gruu.png~FL()~RIGHT()
            message= _ "I like this plan, Chief!"
        [/message]

        [message]
            role=army
            image=$army_profile~FL()~RIGHT()
            message= _ "You always like his plans, Grüü."
        [/message]

        [message]
            speaker=Grüü
            image=portraits/gruu.png~FL()~RIGHT()
            message= _ "Of course. Squash elves, squash undead, squash dwarves, squash humans. Squash them all, very good plan!"
        [/message]

        [message]
            role=army
            image=$army_profile~FL()~RIGHT()
            message= _ "Well, he has the right idea, anyway."
        [/message]
        {CLEAR_VARIABLE army_profile}

        [message]
            speaker="Kapou'e"
            image=portraits/kapoue.png~FL()~RIGHT()
            message= _ "Good, everyone move out. I will begin the attack from here. I want everyone to be in position by first watch at the latest. Is that clear?"
        [/message]

        [message]
            speaker="Flar'Tar"
            image=portraits/flartar.png~FL()~RIGHT()
            message= _ "Yes, Chief."
        [/message]

        [message]
            speaker="Al'Brock"
            image=portraits/albrock.png~FL()~RIGHT()
            message= _ "Understood."
        [/message]

        [store_unit]
            [filter]
                id="Al'Brock"
            [/filter]
            variable=stored_AlBrock
            kill=yes
        [/store_unit]

        [store_unit]
            [filter]
                id="Flar'Tar"
            [/filter]
            variable=stored_FlarTar
            kill=yes
        [/store_unit]

        [message]
            speaker=Grüü
            image=portraits/gruu.png~FL()~RIGHT()
            message= _ "Uh, Chief..."
        [/message]

        [message]
            speaker="Kapou'e"
            image=portraits/kapoue.png~FL()~RIGHT()
            message= _ "... Yes, Grüü?"
        [/message]

        [message]
            speaker=Grüü
            image=portraits/gruu.png~FL()~RIGHT()
            message= _ "Can I get some gold with me?"
        [/message]

        [message]
            speaker="Kapou'e"
            image=portraits/kapoue.png~FL()~RIGHT()
            message= _ "Fine, take a hundred. Don’t lose it."
        [/message]

        [gold]
            side=1
            amount=-100
        [/gold]

        [store_unit]
            [filter]
                id=Grüü
            [/filter]

            kill=yes
            variable=stored_Gruu
        [/store_unit]

        [store_unit]
            [filter]
                side=1,2,3
                race=troll
            [/filter]

            kill=yes
            variable=stored_trolls
        [/store_unit]

        [disallow_recruit]
            side=1,2,3
            type=Troll Whelp
        [/disallow_recruit]
    [/event]

    [event]
        name=turn 4

        [move_unit_fake]
            type=Orcish Warlord
            side=2
            x=27,25
            y=38,34
        [/move_unit_fake]

        {VARIABLE stored_AlBrock.x 25}
        {VARIABLE stored_AlBrock.y 34}

        [unstore_unit]
            variable=stored_AlBrock
        [/unstore_unit]

        [terrain]
            x=24,24,25,25,25,26,26
            y=33,34,33,34,35,33,34
            terrain=Ce
        [/terrain]

        [terrain]
            x=25
            y=34
            terrain=Ke
        [/terrain]

        [redraw]
        [/redraw]

        [message]
            speaker="Al'Brock"
            message= _ "I am in position, Chief."
        [/message]

        [message]
            speaker="Kapou'e"
            image=portraits/kapoue.png~FL()~RIGHT()
            message= _ "Excellent. Now, where are the others?"
        [/message]

        [allow_recruit]
            side=2
            type=Wolf Rider, Orcish Grunt, Orcish Archer, Orcish Crossbowman, Orcish Warrior
        [/allow_recruit]

        {CLEAR_VARIABLE stored_AlBrock}
    [/event]

    [event]
        name=turn 5

        [move_unit_fake]
            type=Orcish Warlord
            side=3
            x=30,27
            y=5,6
        [/move_unit_fake]

        {VARIABLE stored_FlarTar.x 27}
        {VARIABLE stored_FlarTar.y 6}

        [unstore_unit]
            variable=stored_FlarTar
        [/unstore_unit]

        [terrain]
            {CASTLE_OF_FLARTAR}
            terrain=Ce
        [/terrain]

        [terrain]
            x=27
            y=6
            terrain=Ke
        [/terrain]

        [redraw]
        [/redraw]

        [message]
            speaker="Flar'Tar"
            message= _ "We made it."
        [/message]

        [message]
            speaker="Kapou'e"
            image=portraits/kapoue.png~FL()~RIGHT()
            message= _ "Good, but where is Grüü?"
        [/message]

        [message]
            speaker="Flar'Tar"
            message= _ "Dumb trolls, you can never rely on them."
        [/message]

        [allow_recruit]
            side=3
            type=Wolf Rider, Orcish Grunt, Orcish Archer, Orcish Crossbowman, Orcish Warrior
        [/allow_recruit]

        {CLEAR_VARIABLE stored_FlarTar}
    [/event]

    [event]
        name=turn 7

        [move_unit_fake]
            type=$stored_Gruu.type
            side=4
            x=1,5
            y=1,4
        [/move_unit_fake]

        {VARIABLE stored_Gruu.side 4}
        {VARIABLE stored_Gruu.x 5}
        {VARIABLE stored_Gruu.y 4}
        {VARIABLE stored_Gruu.canrecruit yes}
        {VARIABLE stored_Gruu.ellipse ""}

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

        [foreach]
            array=stored_trolls
            [do]
                {VARIABLE this_item.side 4}

                [unstore_unit]
                    variable=this_item
                [/unstore_unit]
            [/do]
        [/foreach]

        {CLEAR_VARIABLE stored_Gruu,stored_trolls}

        [terrain]
            {CASTLE_OF_GRUU}
            terrain=Ce
        [/terrain]

        [terrain]
            x=5
            y=4
            terrain=Ke
        [/terrain]

        [redraw]
        [/redraw]

        [message]
            speaker=Grüü
            image=portraits/gruu.png~FL()~RIGHT()
            message= _ "I’m here, Chief!"
        [/message]

        [message]
            speaker="Kapou'e"
            image=portraits/kapoue-angry.png~FL()~RIGHT()
            message= _ "Blood and stone, Grüü! You were supposed to be in position by first watch. It’s dawn!"
        [/message]

        [message]
            speaker=Grüü
            image=portraits/gruu.png~FL()~RIGHT()
            message= _ "Err, sorry, there were some humans in way. We squash, no problem."
        [/message]

        [message]
            speaker="Kapou'e"
            image=portraits/kapoue.png~FL()~RIGHT()
            message= _ "Better late than never. Now it’s time to kill! Let nobody escape and everyone keep an eye out for the shamans."
        [/message]

        [message]
            speaker="Flar'Tar"
            message= _ "Sounds simple enough."
        [/message]

        [modify_side]
            side=4
            gold=100
        [/modify_side]

        [allow_recruit]
            side=4
            type=Troll Whelp
        [/allow_recruit]
    [/event]

    [event]
        name=last breath

        [filter]
            id=Thelarion
        [/filter]

        [message]
            speaker=second_unit
            message= _ "Miserable elf, we want some answers!"
        [/message]

        [message]
            speaker=Thelarion
            message= _ "Ugh!"
        [/message]

        [message]
            speaker=second_unit
            message= _ "SPEAK!"
        [/message]

        [message]
            speaker=Thelarion
            message= _ "... Well, what do you want to know?"
        [/message]

        [message]
            speaker=second_unit
            message= _ "You can start by telling us who told you to strike at Borstep."
        [/message]

        [message]
            speaker=Thelarion
            message= _ "Uh... we have intelligence."
        [/message]

        [message]
            speaker=second_unit
            message= _ "Don’t make me hurt you more."
        [/message]

        [message]
            speaker=Thelarion
            message= _ "I yield. Shan Taum the Smug told us that that’s where the shamans were, and that it was a rally point and weapons depot for you orcs."
        [/message]

        [message]
            speaker=second_unit
            message= _ "Bah, do not think you can break the unity of the horde with your stupid lies!"
        [/message]

        [message]
            speaker=Thelarion
            message= _ "No really, it’s true. He is jealous of some young upstart called Kapou’e. He says all the shamans ‘suck up’ to him just because his father had a black eye or something like that."
        [/message]

        [message]
            speaker=second_unit
            message= _ "Refer to Black-Eye Karun with respect, wose-born. Now, where are the shamans?"
        [/message]

        [message]
            speaker=Thelarion
            message= _ "They’re... the humans killed them."
        [/message]

        [message]
            speaker=second_unit
            message= _ "You lie!"
        [/message]

        [message]
            speaker=Thelarion
            message= _ "I do not. Their bodies are frozen in the lake just over there."
        [/message]

        [if]
            [variable]
                name=second_unit.id
                equals="Kapou'e"
            [/variable]
            [then]
                [message]
                    speaker="Kapou'e"
                    image=portraits/kapoue.png~FL()~RIGHT()
                    message= _ "We had better go look."
                [/message]
            [/then]
            [else]
                [message]
                    speaker="Kapou'e"
                    image=portraits/kapoue.png~FL()~RIGHT()
                    message= _ "You had better go look."
                [/message]

                [message]
                    speaker=second_unit
                    message= _ "Yes, Chief."
                [/message]
            [/else]
        [/if]

        [message]
            speaker=narrator
            message= _ "A few minutes later..."
            image=wesnoth-icon.png
        [/message]

        [if]
            [variable]
                name=second_unit.id
                equals="Kapou'e"
            [/variable]
            [then]
                [message]
                    speaker="Kapou'e"
                    image=portraits/kapoue-angry.png~FL()~RIGHT()
                    message= _ "The human-worms and tree-shaggers have gone too far! BLOOD AND STEEL! I want every human and elf in this area slaughtered! Show no mercy, give no quarter!"
                [/message]
            [/then]
            [else]
                [message]
                    speaker=second_unit
                    message= _ "Chief! It’s true, the shamans have been murdered!"
                [/message]

                [message]
                    speaker="Kapou'e"
                    image=portraits/kapoue-angry.png~FL()~RIGHT()
                    message= _ "<i>What</i>?! The human-worms and tree-shaggers have gone too far! BLOOD AND STEEL! I want every human and elf in this area slaughtered! Show no mercy, give no quarter!"
                [/message]

                [message]
                    speaker=second_unit
                    message= _ "What should I do with this one?"
                [/message]

                [message]
                    speaker="Kapou'e"
                    image=portraits/kapoue-angry.png~FL()~RIGHT()
                    message= _ "Throw him in the lake. If he freezes to death, all the better."
                [/message]
            [/else]
        [/if]
    [/event]

    [event]
        name=enemies defeated

        [store_side]
            side=4
            variable=stored_Gruu_side
        [/store_side]

        [if]
            [variable]
                name=stored_Gruu_side.gold
                greater_than=0
            [/variable]

            [then]
                {LOOT $stored_Gruu_side.gold 1}
                [+message]
                    message= _ "You retrieve $amount_gold of Grüü's leftover gold."
                [/message]

                [gold]
                    side=4
                    amount=-$stored_Gruu_side.gold
                [/gold]
            [/then]
        [/if]

        {CLEAR_VARIABLE stored_Gruu_side}

        [allow_recruit]
            side=1,2,3
            type=Troll Whelp
        [/allow_recruit]

        [modify_side]
            side=4
            controller=ai
        [/modify_side]

        [modify_unit]
            [filter]
                side=4
            [/filter]
            side=1
        [/modify_unit]

        [modify_unit]
            [filter]
                id=Grüü
            [/filter]
            canrecruit=no
            ellipse=misc/ellipse-hero
        [/modify_unit]

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

    {HERO_DEATHS}
    {GENERALS_MUST_SURVIVE}
[/scenario]
