#textdomain wesnoth-sotbe
[scenario]
    id="The_Siege_Of_Barag_Gor"
    name= _ "The Siege Of Barag Gór"
    map_data="{campaigns/Son_Of_The_Black_Eye/maps/The_Siege_Of_Barag_Gor.map}"
    {TURNS 30 28 26}
    victory_when_enemies_defeated=yes

    {DEFAULT_SCHEDULE}

    next_scenario="To_the_harbour_of_Tirigaz"

    {SCENARIO_MUSIC "vengeful.ogg"}
    {EXTRA_SCENARIO_MUSIC "the_city_falls.ogg"}
    {EXTRA_SCENARIO_MUSIC "battle.ogg"}

    [event]
        name=prestart
        [objectives]
            side=1
            [objective]
                condition=win
                description=_ "Defeat all enemy leaders"
            [/objective]
            [objective]
                condition=lose
                description=_ "Death of Kapou'e"
            [/objective]
            [objective]
                condition=lose
                description=_ "Death of Grüü"
            [/objective]
            [objective]
                condition=lose
                description=_ "Death of a Shaman"
            [/objective]
            [objective]
                condition=lose
                description=_ "Turns run out"
            [/objective]

            note={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=200
        {BLACK_FLAG}
    [/side]

    [side]
        type=Elvish Marshal
        id=Etheliel
        name= _ "Etheliel"
        side=2
        team_name=Elves
        user_team_name=_"Elves"
        canrecruit=yes
        recruit=Elvish Archer, Elvish Fighter
        {GOLD 60 80 100}
    [/side]

    {STARTING_VILLAGES 2 10}

    [side]
        type=Orcish Slayer
        id=Rugh
        name= _ "Rugh"
        side=3
        team_name=Kapoue
        user_team_name=_ "Kapou'e"
        canrecruit=yes
        recruit= Wolf Rider, Orcish Grunt, Troll Whelp, Orcish Archer
        gold=150

        [ai]
            [leader_goal]
                x=23
                y=14
            [/leader_goal]
        [/ai]
    [/side]

    {STARTING_VILLAGES 3 5}

    [side]
        type=Elvish Marshal
        id="Hida'tul"
        name= _ "Hida'tul"
        side=4
        team_name=Elves
        user_team_name=_"Elves"
        canrecruit=yes
        recruit=Elvish Archer, Elvish Fighter
        {GOLD 60 80 100}
    [/side]

    {STARTING_VILLAGES 4 10}

    [side]
        type=Elvish Marshal
        id=Ammon
        name= _ "Ammon"
        side=5
        team_name=Elves
        user_team_name=_"Elves"
        canrecruit=yes
        recruit=Elvish Archer, Elvish Fighter
        {GOLD 60 80 100}
    [/side]

    {STARTING_VILLAGES 5 6}

    [side]
        type=Elvish Marshal
        id=Sammual
        name= _ "Sammual"
        side=6
        team_name=Elves
        user_team_name=_"Elves"
        canrecruit=yes
        recruit=Elvish Archer, Elvish Fighter
        {GOLD 60 80 100}
    [/side]

    {STARTING_VILLAGES 6 8}

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

    [event]
        name=prestart

        [set_variable]
            name=elvish_casualties
            value=0
        [/set_variable]

        {GENERIC_UNIT 2 "Elvish Fighter" 18 14}
        {GENERIC_UNIT 2 "Elvish Fighter" 21 12}
        {GENERIC_UNIT 2 "Elvish Fighter" 22 11}
        {GENERIC_UNIT 2 "Elvish Fighter" 18 16}

        {GENERIC_UNIT 2 "Elvish Fighter" 26 15}
        {GENERIC_UNIT 2 "Elvish Fighter" 22 17}

        {GENERIC_UNIT 2 "Elvish Archer" 23 12}
        {GENERIC_UNIT 2 "Elvish Archer" 26 13}
        {GENERIC_UNIT 2 "Elvish Archer" 25 17}

        {GENERIC_UNIT 2 "Elvish Archer" 20 17}
        {GENERIC_UNIT 2 "Elvish Archer" 20 12}

        {GENERIC_UNIT 3 "Orcish Archer" 19 14} {GUARDIAN}
        {GENERIC_UNIT 3 "Orcish Archer" 22 13} {GUARDIAN}
        {GENERIC_UNIT 3 "Orcish Archer" 20 16} {GUARDIAN}

        {GENERIC_UNIT 3 "Orcish Archer" 23 17} {GUARDIAN}
        {GENERIC_UNIT 3 "Orcish Archer" 24 14} {GUARDIAN}

        {GENERIC_UNIT 3 "Orcish Grunt" 24 16} {GUARDIAN}
        {GENERIC_UNIT 3 "Orcish Grunt" 22 12} {GUARDIAN}
        {GENERIC_UNIT 3 "Orcish Grunt" 20 13} {GUARDIAN}
        {GENERIC_UNIT 3 "Orcish Grunt" 19 16} {GUARDIAN}

        {GENERIC_UNIT 3 "Orcish Grunt" 25 15} {GUARDIAN}
        {GENERIC_UNIT 3 "Orcish Grunt" 22 16} {GUARDIAN}
        {ORCISH_SHAMAN 22 14 Pirk _"Pirk"}
        {OLD_ORCISH_SHAMAN 22 15 Gork _"Gork"}
        {NOVICE_ORCISH_SHAMAN 21 15 Vraurk _"Vraurk"}
        # wmllint: recognize Pirk
        # wmllint: recognize Gork
        # wmllint: recognize Vraurk

        [item]
            x=7
            y=30
            image=units/orcs/assassin.png~RC(magenta>red)
        [/item]

        [item]
            x=7
            y=30
            image=items/cage.png
        [/item]

        {GENERIC_UNIT 2 "Elvish Fighter" 5 30} {GUARDIAN}
        {GENERIC_UNIT 2 "Elvish Captain" 7 29} {GUARDIAN}
        {GENERIC_UNIT 2 "Elvish Fighter" 9 30} {GUARDIAN}
    [/event]

    [event]
        name=start

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

        [role]
            type=Direwolf Rider,Goblin Knight,Goblin Pillager,Wolf Rider
            role=Scout
        [/role]

        [store_unit]
            [filter]
                role=Scout
            [/filter]
            variable=scout
        [/store_unit]

        [if]
            [variable]
                name=scout.length
                greater_than=0
            [/variable]

            [then]
                [recall]
                    role=Scout
                    x,y=36,20
                [/recall]
            [/then]

            [else]
                {GENERIC_UNIT 1 "Wolf Rider" 36 20}
                [+unit]
                    role=Scout
                    to_variable=scout
                [/unit]
            [/else]
        [/if]

        [message]
            speaker=narrator
            message= _ "When the party finally reached Barag Gór, they were met with a most startling sight."
            image=wesnoth-icon.png
        [/message]

        [message]
            speaker="Kapou'e"
            message= _ "What the...! Barag Gór is besieged by elves. The wose-born weaklings have always been jealous of our power, but what reason do they have to attack the city?"
        [/message]

        [message]
            speaker=Grüü
            message= _ "What can you expect, Chief? They're elves after all."
        [/message]

        [message]
            speaker="Kapou'e"
            message= _ "Hmmm, $scout.name go find out what they are up to."
        [/message]

        [message]
            role=Scout
            message= _ "Sure."
        [/message]

        [set_variable]
            name=scout.x
            value=13
        [/set_variable]

        [set_variable]
            name=scout.y
            value=27
        [/set_variable]

        [kill]
            role=Scout
        [/kill]

        [move_unit_fake]
            type=$scout.type
            side=1
            x=38,38,37,36,35.34,21,20,19,18,17,16,15,14,13
            y=19,18,18,18,19,19,29,28,28,28,28,28,28,27,27
        [/move_unit_fake]

        [unstore_unit]
            variable=scout
        [/unstore_unit]

        [message]
            speaker=Etheliel
            message= _ "One more step and you are dead, flea-bag. Better run if you value your life."
        [/message]

        [message]
            role=Scout
            message= _ "Quit your boasting, mule-ears. The chief wants to know why you're here, instead of cowering in your dung-spattered forests."
        [/message]

        [message]
            speaker=Etheliel
            message= _ "Watch your mouth around your betters, goblin! And you can tell your chief to hand the shamans over to us if he wants to be alive by sundown."
        [/message]

        [message]
            role=Scout
            message= _ "What business do you high-and-mighty elves have with our shamans?"
        [/message]

        [message]
            speaker=Etheliel
            message= _ "Our business with them is none of your concern."
        [/message]

        [message]
            role=Scout
            message= _ "Oh, yes, it is. The shamans keep our ancient knowledge and our sacred things; they are not for the likes of you. Why do you want them anyway?"
        [/message]

        [message]
            speaker=Etheliel
            message= _ "Well... the humans want to... meet with them."
        [/message]

        [message]
            role=Scout
            message= _ "Oh, so they paid you to come and get them, have they?"
        [/message]

        [message]
            speaker=Etheliel
            message= _ "Well..."
        [/message]

        [message]
            role=Scout
            message= _ "So the 'great and mighty' elves are now nothing but a bunch of mercenaries."
        [/message]

        [message]
            speaker=Etheliel
            message= _ "KILL HIM!!!"
        [/message]

        [unit]
            type=Elvish Fighter
            side=2
            x=3
            y=26
            generate_name=yes
            random_traits=yes
        [/unit]

        [unit]
            type=Elvish Fighter
            side=2
            x=2
            y=25
            generate_name=yes
            random_traits=yes
        [/unit]

        [message]
            role=Scout
            message= _ "Hahahahaha! If you can!"
        [/message]

        [set_variable]
            name=scout.x
            value=38
        [/set_variable]

        [set_variable]
            name=scout.y
            value=19
        [/set_variable]

        [kill]
            role=Scout
        [/kill]

        [move_unit_fake]
            type=$scout.type
            side=1
            x=13,14,15,16,17,18,19,20,21,34,35,36,37,38,38
            y=27,27,28,28,28,28,28,28,29,19,19,18,18,18,19
        [/move_unit_fake]

        [unstore_unit]
            variable=scout
        [/unstore_unit]

        [message]
            speaker=Etheliel
            message= _ "Blast it, he got away."
        [/message]

        [message]
            speaker="Kapou'e"
            message= _ "So, what news do you bring $scout.name?"
        [/message]

        [message]
            role=Scout
            message= _ "The elves have been bribed by the humans to capture and deliver the shamans to them."
        [/message]

        [message]
            speaker="Kapou'e"
            message= _ "Over my dead body! The shamans of the Great Council are the only people who can call up the Great Horde. If they are captured then all the orcs on this continent would surely be doomed."
        [/message]

        [message]
            speaker=Grüü
            message= _ "I have a subtle plan, chief."
        [/message]

        [message]
            speaker="Kapou'e"
            message= _ "Go on, Grüü."
        [/message]

        [message]
            speaker=Grüü
            message= _ "We go and we kill all of them. What do you think?"
        [/message]

        [message]
            speaker="Kapou'e"
            message= _ "..."
        [/message]

        [message]
            speaker=narrator
            message= _ "Then, Kapou'e launched his desperate attack to break the siege of Barag Gór."
            image=wesnoth-icon.png
        [/message]

        {CLEAR_VARIABLE scout}
    [/event]

    [event]
        name=moveto

        [removeitem]
            x,y=7,30
        [/removeitem]

        [filter]
            side=1
            x=7
            y=30
        [/filter]

        [unit]
            id=Jetto
            name= _ "Jetto"
            side=1
            type=Orcish Assassin
            profile=portraits/jetto.png
            x=7
            y=30
            random_traits=no
            [modifications]
                {TRAIT_LOYAL}
            [/modifications]
            {IS_LOYAL}
        [/unit]

        [allow_recruit]
            side=1
            type=Orcish Assassin
        [/allow_recruit]

        [message]
            speaker=Jetto
            message= _ "Freedom! Many thanks, Son of the Black-Eye. I'm Jetto, master of assassins, now you can count on the assassins' guild to help you in your quest!"
        [/message]

        [message]
            speaker="Kapou'e"
            message= _ "Jetto, how did you get captured by the likes of these?"
        [/message]

        [message]
            speaker=Jetto
            message= _ "The Barag Gór council sent me to assassinate the elvish leaders. Unfortunately, I was captured. But now I am free and the elves shall feel my wrath!"
        [/message]

        {VARIABLE freed_Jetto yes}
    [/event]

    [event]
        name=moveto

        [filter]
            side=1
            [not]
                id=Pirk
            [/not]
            [not]
                id=Gork
            [/not]
            [not]
                id=Vraurk
            [/not]
            x=18-25
            y=11-17
        [/filter]

        [message]
            speaker=Rugh
            message= _ "Good. Reinforcements at last!"
        [/message]

        [message]
            speaker=unit
            message= _ "That's right! Now let's drive those mincing tree-shaggers back into their forests!"
        [/message]

        [objectives]
            side=1
            [objective]
                condition=win
                description=_ "Defeat all enemy leaders"
            [/objective]
            [objective]
                condition=lose
                description=_ "Death of Kapou'e"
            [/objective]
            [objective]
                condition=lose
                description=_ "Death of Grüü"
            [/objective]
            [objective]
                condition=lose
                description=_ "Death of a Shaman"
            [/objective]
            [objective]
                condition=lose
                description=_ "Turns run out"
            [/objective]

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

    [event]
        name=enemies defeated

        [message]
            speaker=Pirk
            message= _ "At last! The siege has been broken."
        [/message]

        [message]
            speaker=Gork
            message= _ "Thank you, Son of the Black-Eye. If you hadn't arrived when you did, I don't know what would have happened to us."
        [/message]

        [message]
            speaker="Kapou'e"
            message= _ "No problem! It was fun, wasn't it, Grüü?"
        [/message]

        [message]
            speaker=Grüü
            message= _ "Hahaha! Yeah!"
        [/message]

        [message]
            speaker="Kapou'e"
            message= _ "But, actually, we have come all the way from our lands to get your help."
        [/message]

        [message]
            speaker=Vraurk
            message= _ "Why? What's wrong?"
        [/message]

        [message]
            speaker="Kapou'e"
            message= _ "Those insolent humans have massed a huge army and attacked us. We defeated their vanguard but in the end we were forced to retreat."
        [/message]

        [message]
            speaker=Pirk
            message= _ "Hmmmm, this situation is very serious. As you know by now, they have also hired these elves to attack us here."
        [/message]

        [message]
            speaker="Kapou'e"
            message= _ "Yes. It seems to me that the humans are declaring all-out war on us."
        [/message]

        [message]
            speaker=Gork
            message= _ "We must give this matter careful consideration. Come inside the city, and we'll discuss it."
        [/message]

        [if]
            [variable]
                name=freed_Jetto
                not_equals=yes
            [/variable]

            [then]
                [scroll_to]
                    x,y=7,30
                [/scroll_to]

                [message]
                    speaker=narrator
                    caption= _ "Jetto"
                    image=portraits/jetto.png
                    message= _ "Son of the Black-Eye! Could I ask for my release from this blighted cage?"
                [/message]

                [message]
                    speaker="Kapou'e"
                    message= _ "How did you get captured by the likes of these?"
                [/message]

                [scroll_to]
                    x,y=7,30
                [/scroll_to]

                [message]
                    speaker=narrator
                    caption= _ "Jetto"
                    image=portraits/jetto.png
                    message= _ "The Barag Gór council sent me to assassinate the elvish leaders. Unfortunately, I was captured."
                [/message]

                [message]
                    speaker="Kapou'e"
                    message= _ "Fine, someone go release him."
                [/message]

                [scroll_to]
                    x,y=7,30
                [/scroll_to]

                [removeitem]
                    x,y=7,30
                [/removeitem]

                [unit]
                    id=Jetto
                    name= _ "Jetto"
                    side=1
                    type=Orcish Assassin
                    profile=portraits/jetto.png
                    x=7
                    y=30
                    random_traits=no
                    [modifications]
                        {TRAIT_LOYAL}
                    [/modifications]
                    {IS_LOYAL}
                [/unit]

                [allow_recruit]
                    side=1
                    type=Orcish Assassin
                [/allow_recruit]

                [message]
                    speaker=Jetto
                    message= _ "Freedom! Many thanks, Son of the Black-Eye. I'm Jetto, master of assassins, now you can count on my assassins to help you in your quest!"
                [/message]
            [/then]
        [/if]

        {CLEAR_VARIABLE freed_Jetto}

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

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