#textdomain wesnoth-sotbe
[scenario]
    id=back_home
    name= _ "Back Home"
    map_data="{campaigns/Son_Of_The_Black_Eye/maps/Back_Home.map}"
    {TURNS 40 35 30}

    {DEFAULT_SCHEDULE}

    next_scenario="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
            [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]
            [objective]
                description= _ "Turns run out"
                condition=lose
            [/objective]

            note= _ "The Great Horde: upkeep cost of every unit decreased by one." + "
"+{EARLY_FINISH_BONUS_NOTE}+{NEW_GOLD_CARRYOVER_NOTE_40}
        [/objectives]
    [/event]

    [side]
        type=Orcish Leader
        id="Kapou'e"
        name= _ "Kapou'e"
        side=1
        canrecruit=yes
        controller=human
        recruit= Wolf Rider, Orcish Grunt, Troll Whelp, Orcish Archer
        team_name=Kapoue
        user_team_name=_ "Kapou'e"
        gold=400
        {BLACK_FLAG}
    [/side]

    {STARTING_VILLAGES 1 2}

    [side]
        {ALBROCK_SIDE}
    [/side]

    [side]
        {FLARTAR_SIDE}
    [/side]

    [side]
        side=4
        id=gruu_recall_enabling_hack_leader
        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}
        {AVOID_ALLIES}
    [/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}
        {AVOID_ALLIES}
    [/side]

    {STARTING_VILLAGES 6 10}

    [side]
        type=General
        id=Fredrick
        name= _ "Fredrick"
        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}
        {AVOID_ALLIES}
    [/side]

    {STARTING_VILLAGES_AREA 7 27 20 8}

    [side]
        type=General
        id=Georgy
        name= _ "Georgy"
        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}
        {AVOID_ALLIES}
    [/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."
            background=farnorth.png
        [/part]

        [part]
            show_title=yes
            {TO_BACK_HOME}
        [/part]
    [/story]

    [event]
        name=prestart

        {RENAME_IF_DEAD thelarion_dead Thelarion (_"Valan")}

        [kill]
            id=gruu_recall_enabling_hack_leader
        [/kill]
    [/event]

    {GOT_THE_GREAT_HORDE 1,2,3,4}

    [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"
            message= _ "Well, boys, we're home. I told you we would return one day."
        [/message]

        [message]
            role=army
            message= _ "Boy, have they ever built this place up."
        [/message]

        [message]
            speaker="Kapou'e"
            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"
            message= _ "What are you thinking, Chief?"
        [/message]

        [message]
            speaker="Kapou'e"
            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üü
            message= _ "I like this plan, Chief!"
        [/message]

        [message]
            role=army
            message= _ "You always like his plans, Grüü."
        [/message]

        [message]
            speaker=Grüü
            message= _ "Of course. Squash elves, squash undead, squash dwarves, squash humans. Squash them all, very good plan!"
        [/message]

        [message]
            role=army
            message= _ "Well, he has the right idea, anyway."
        [/message]

        [message]
            speaker="Kapou'e"
            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"
            message= _ "Yeah, sure."
        [/message]

        [message]
            speaker="Al'Brock"
            message= _ "Whatever."
        [/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üü
            message= _ "Uh, Chief..."
        [/message]

        [message]
            speaker="Kapou'e"
            message= _ "...yes, Grüü?"
        [/message]

        [message]
            speaker=Grüü
            message= _ "Can I get some gold with me?"
        [/message]

        [message]
            speaker="Kapou'e"
            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
                race=troll
            [/filter]

            kill=yes
            variable=stored_trolls
        [/store_unit]
    [/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"
            message= _ "Excellent. Now, where are the others?"
        [/message]

        [modify_side]
            side=2
            {GOLD 350 300 250}
        [/modify_side]

        [allow_recruit]
            side=2
            type=Wolf Rider, Orcish Grunt, Troll Whelp, 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"
            message= _ "Good, but where is Grüü?"
        [/message]

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

        [modify_side]
            side=3
            {GOLD 350 300 250}
        [/modify_side]

        [allow_recruit]
            side=3
            type=Wolf Rider, Orcish Grunt, Troll Whelp, 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}

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

        {FOREACH stored_trolls i}
            {VARIABLE stored_trolls[$i].side 4}

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

        {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üü
            message= _ "I'm here, chief!"
        [/message]

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

        [message]
            speaker=Grüü
            message= _ "Err, sorry, there were some humans in way. We squash, no problem."
        [/message]

        [message]
            speaker="Kapou'e"
            message= _ "Better late then 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]

        [objectives]
            side=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]
            [objective]
                description= _ "Turns run out"
                condition=lose
            [/objective]

            note= _ "The Great Horde: upkeep cost of every unit decreased by one." + "
"+{EARLY_FINISH_BONUS_NOTE}+{NEW_GOLD_CARRYOVER_NOTE_40}
        [/objectives]
    [/event]

    [event]
        name=die

        [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= _ "OK OK, 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
                value="Kapou'e"
            [/variable]
            [then]
                [message]
                    speaker="Kapou'e"
                    message= _ "We had better go look."
                [/message]
            [/then]
            [else]
                [message]
                    speaker="Kapou'e"
                    message= _ "You had better go look."
                [/message]

                [message]
                    speaker=second_unit
                    # wmllint: local spelling OK
                    message= _ "OK, Chief."
                [/message]
            [/else]
        [/if]

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

        [if]
            [variable]
                name=second_unit.id
                value="Kapou'e"
            [/variable]
            [then]
                [message]
                    speaker="Kapou'e"
                    message= _ "WHAT! 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!"
                    image=portraits/kapoue-angry.png
                [/message]
            [/then]
            [else]
                [message]
                    speaker=second_unit
                    message= _ "Chief! It's true, the shamans have been murdered!"
                [/message]

                [message]
                    speaker="Kapou'e"
                    message= _ "WHAT! 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!"
                    image=portraits/kapoue-angry.png
                [/message]

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

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

    [event]
        name=enemies defeated

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

        [gold]
            side=1
            amount=$stored_Gruu_side.gold
        [/gold]

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

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

            kill=yes
            variable=stored_Gruu
        [/store_unit]

        {VARIABLE stored_Gruu.side 1}
        {VARIABLE stored_Gruu.canrecruit no}

        [unstore_unit]
            variable=stored_Gruu
        [/unstore_unit]

        {MODIFY_UNIT (
            side=4
            [not]
                id=Grüü
            [/not]
        ) side 1}

        {CLEAR_VARIABLE stored_Gruu_side,stored_Gruu,stored_trolls}

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

    {campaigns/Son_Of_The_Black_Eye/utils/deaths.cfg}
    {GENERALS_MUST_SURVIVE}
[/scenario]
