#textdomain wesnoth-sotbe
[scenario]
    id=18_Northern_Alliance
    name= _ "Northern Alliance"
    map_data="{campaigns/Son_Of_The_Black_Eye/maps/18_Northern_Alliance.map}"

    turns=unlimited

    victory_when_enemies_defeated="yes"

    {DEFAULT_SCHEDULE}

    {SCENARIO_MUSIC "the_city_falls.ogg"}
    {EXTRA_SCENARIO_MUSIC "legends_of_the_north.ogg"}
    {EXTRA_SCENARIO_MUSIC "battle.ogg"}
    {EXTRA_SCENARIO_MUSIC "suspense.ogg"}

    next_scenario=19_Epilogue

    [event]
        name=prestart
        [objectives]
            side=1
            [objective]
                condition=win
                description=_ "Kill Shan Taum and Earl Lanbec’h"
            [/objective]
            [objective]
                condition=lose
                description=_ "Death of Kapou’e"
            [/objective]
            [objective]
                description= _ "Death of Grüü"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Howgarth III"
                condition=lose
            [/objective]

            {IS_LAST_SCENARIO}

            {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_AREA 1 22 5 10}

    {AI_CONTROLLER () 1 2,3,6 ()}

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

    {STARTING_VILLAGES 2 6}

    [side]
        {FLARTAR_SIDE}
        # wmllint: unwho ALL
        {GOLD 200 150 125}
    [/side]

    {STARTING_VILLAGES 3 6}

    [side]
        type=Grand Marshal
        id="Earl Lanbec'h"
        name= _ "Earl Lanbec’h"
        profile=portraits/lanbech.png
        side=4
        canrecruit=yes
        recruit=Dragoon, Swordsman, Pikeman, Longbowman,Shock Trooper,Mage,Duelist,White Mage,Red Mage,Lancer,Knight,Spearman,Bowman,Cavalryman,Horseman
        team_name=villians
        user_team_name=_"Villains"
        {GOLD 600 800 1000}
        {INCOME 20 30 40}
        [ai]
            leader_value=50.0
            villages_per_scout=10
            passive_leader=yes
            [goal]
                name=protect_unit
                [criteria]
                    id="Earl Lanbec'h"
                [/criteria]
                protect_radius=8
                value=20
            [/goal]
        [/ai]
        [ai]
            time_of_day=dawn,morning,afternoon
            aggression=0.9
            caution=0.2
            village_value=0.2
            grouping=offensive
        [/ai]
        [ai]
            time_of_day=dusk,first_watch,second_watch
            aggression=0.2
            caution=0.5
            village_value=0.8
            grouping=defensive
        [/ai]
        {FLAG_VARIANT loyalist}
    [/side]

    {STARTING_VILLAGES 4 12}

    [side]
        type=Orcish Warlord
        id=Shan Taum
        name= _ "Shan Taum"
        profile=portraits/shan_taum.png
        side=5
        canrecruit=yes
        facing=sw
        recruit= Wolf Rider, Goblin Knight, Orcish Grunt, Ogre, Orcish Archer, Orcish Crossbowman, Orcish Warrior, Orcish Assassin, Orcish Slayer
        team_name=villians
        user_team_name=_"Villains"
        {GOLD 600 700 800}
        {INCOME 15 20 25}

        [ai]
            aggression=1.0
            [goal]
                name=target
                [criteria]
                    id="Kapou'e"
                [/criteria]
                value=10
            [/goal]
        [/ai]
    [/side]

    {STARTING_VILLAGES_AREA 5 60 6 10}

    [side]
        type=General
        id=Howgarth III
        name= _ "Howgarth III"
        profile=portraits/howgarth.png
        side=6
        canrecruit=yes
        facing=sw
        recruit=Gryphon Rider, Gryphon Master, Spearman, Swordsman, Javelineer, Pikeman, Dwarvish Steelclad, Dwarvish Fighter, Dwarvish Thunderer, Dwarvish Thunderguard, Dwarvish Scout, Dwarvish Pathfinder, Bowman, Longbowman, Mage, White Mage, Red Mage, Fencer, Duelist
        team_name=Kapoue
        user_team_name=_ "Kapou’e"
        {GOLD 400 350 300}
        {INCOME 15 20 25}
        {FLAG_VARIANT loyalist}

        [ai]
            [goal]
                name=protect_unit
                [criteria]
                    id="Howgarth III"
                [/criteria]
                protect_radius=12
                value=20
            [/goal]
        [/ai]
    [/side]

    {STARTING_VILLAGES_AREA 6 59 29 12}

    [story]
        [part]
            story= _ "Kapou’e agreed to meet Howgarth III. Not trusting the human however, Kapou’e brought along Grüü, as well as one of his most trusted soldiers. Earl Lanbec’h flatly refused to attend the parley."
            {SOTBE_BIGMAP}
            {JOURNEY_17_OLD}
        [/part]

        [part]
            story= _ "The human attack having stopped for the time being, both parties met in the middle of the battlefield. Howgarth III demanded that Kapou’e give Dorest back to the humans and return to their lands as defined in the treaty. Kapou’e refused to do so as long as the humans were attacking orcish lands. He demanded that the humans disperse their forces and return any land they had stolen from the orcs. Only then would he return Dorest and disperse the Horde."
            {SOTBE_BIGMAP}
            {JOURNEY_17_OLD}
        [/part]

        [part]
            story= _ "Howgarth III agreed and further added that, if Earl Lanbec’h continued in aggression, then under the dictates of the Northern Alliance, he himself would be forced to move against the Earl."
            {SOTBE_BIGMAP}
            {JOURNEY_17_OLD}
        [/part]

        [part]
            story= _ "That having been settled, Kapou’e began to inquire about the death of his father. Howgarth III repeated his story, that the last thing they heard from Black-Eye Karun was the message declining their invitation to join the Northern Alliance, brought by none other than Shan Taum himself."
            {SOTBE_BIGMAP}
            {JOURNEY_17_OLD}
        [/part]

        [part]
            story= _ "As they were discussing the matter, a group of orcs charged from the surrounding trees and hills and surrounded the parley."
            {SOTBE_BIGMAP}
            {JOURNEY_17_OLD}
        [/part]
    [/story]

    {SOTBE_TRACK {JOURNEY_18_NEW} }

    {GOT_THE_GREAT_HORDE 1,2,3}

    [event]
        name=prestart

        [recall]
            id=Grüü
            x,y=45,20
        [/recall]
        [recall]
            id=Jetto
            x,y=21,6
        [/recall]
        [recall]
            id=Inarix
            x,y=23,6
        [/recall]

        [recall]
            type=Orcish Warlord,Orcish Slurbow,Troll Warrior,Direwolf Rider,Goblin Pillager,Orcish Crossbowman,Orcish Warrior,Goblin Knight
            x,y=43,21
        [/recall]

        [hide_unit]
            x,y=48,19
        [/hide_unit]

        {LOYAL_UNIT 4 Halberdier 21 26}
        {LOYAL_UNIT 4 Halberdier 23 26}

        {LOYAL_UNIT 4 Pikeman 19 27}
        {LOYAL_UNIT 4 Pikeman 25 27}

        {LOYAL_UNIT 4 Javelineer 16 27}
        {LOYAL_UNIT 4 Javelineer 28 27}

        {LOYAL_UNIT 4 (Iron Mauler) 16 29}
        {LOYAL_UNIT 4 (Iron Mauler) 28 29}

        {LOYAL_UNIT 4 (Shock Trooper) 16 31}
        {LOYAL_UNIT 4 (Shock Trooper) 28 31}

        {LOYAL_UNIT 4 (Shock Trooper) 17 33}
        {LOYAL_UNIT 4 (Shock Trooper) 27 33}

        {LOYAL_UNIT 4 (Shock Trooper) 19 33}
        {LOYAL_UNIT 4 (Shock Trooper) 25 33}

        {LOYAL_UNIT 4 Swordsman 21 34}
        {LOYAL_UNIT 4 Swordsman 23 34}

        {MODIFY_UNIT side,canrecruit=4,no ai_special guardian}
        {MODIFY_UNIT x,y=23-28,25-35 facing sw}

        {LOYAL_UNIT 6 (Royal Guard) 45 22}
        {LOYAL_UNIT 6 (Royal Guard) 47 21}
    [/event]

#define ATTACK_ANIM ID_ATTACKER ID_DEFENDER HITS DAMAGE TEXT
    [animate_unit]
        flag=attack
        with_bars=yes
        hits={HITS}

        [filter]
            id={ID_ATTACKER}
        [/filter]

        [primary_attack]
            range=melee
        [/primary_attack]

        [facing]
            [filter]
                id={ID_DEFENDER}
            [/filter]
        [/facing]

        [animate]
            flag=defend
            with_bars=yes
            hits={HITS}
            text={TEXT}
            red,blue,green=255,0,0

            [filter]
                id={ID_DEFENDER}
            [/filter]

            [facing]
                [filter]
                    id={ID_ATTACKER}
                [/filter]
            [/facing]
        [/animate]
    [/animate_unit]

    [store_unit]
        [filter]
            id={ID_DEFENDER}
        [/filter]

        variable=defender
    [/store_unit]

    [modify_unit]
        [filter]
            id={ID_DEFENDER}
        [/filter]

        hitpoints=$($defender.hitpoints-{DAMAGE})
    [/modify_unit]

    {CLEAR_VARIABLE defender}
#enddef

    [event]
        name=start

        [move_unit_fake]
            type=Orcish Warrior
            side=5
            x=46,42
            y=16,19
        [/move_unit_fake]

        [unit]
            type=Orcish Warrior
            side=5
            x=42
            y=19
            generate_name=yes
            random_traits=yes
        [/unit]

        [move_unit_fake]
            type=Orcish Warrior
            side=5
            x=46,44
            y=18,18
        [/move_unit_fake]

        [unit]
            type=Orcish Warrior
            id=warrior1
            side=5
            x=44
            y=18
            generate_name=yes
            [modifications]
                {TRAIT_QUICK}
                {TRAIT_INTELLIGENT}
            [/modifications]
        [/unit]

        [move_unit_fake]
            type=Orcish Warrior
            side=5
            x=40,41
            y=24,21
        [/move_unit_fake]

        [unit]
            type=Orcish Warrior
            side=5
            x=41
            y=21
            generate_name=yes
            random_traits=yes
        [/unit]

        [move_unit_fake]
            type=Orcish Warrior
            side=5
            x=40,42
            y=24,22
        [/move_unit_fake]

        [unit]
            type=Orcish Warrior
            side=5
            x=42
            y=22
            generate_name=yes
            random_traits=yes
        [/unit]

        [move_unit_fake]
            type=Orcish Warrior
            side=5
            x=44,45
            y=24,24
        [/move_unit_fake]

        [unit]
            type=Orcish Warrior
            side=5
            x=45
            y=24
            generate_name=yes
            random_traits=yes
        [/unit]

        [move_unit_fake]
            type=Orcish Warrior
            side=5
            x=48,47
            y=24,24
        [/move_unit_fake]

        [unit]
            type=Orcish Warrior
            side=5
            x=47
            y=24
            generate_name=yes
            random_traits=yes
        [/unit]

        [move_unit_fake]
            type=Orcish Warrior
            side=5
            x=47,46
            y=18,18
        [/move_unit_fake]

        [unit]
            type=Orcish Warrior
            side=5
            x=46
            y=18
            generate_name=yes
            random_traits=yes
        [/unit]

        [move_unit_fake]
            type=Orcish Warrior
            side=5
            x=49,49
            y=24,23
        [/move_unit_fake]

        [unit]
            type=Orcish Warrior
            side=5
            x=49
            y=23
            generate_name=yes
            random_traits=yes
        [/unit]

        [move_unit_fake]
            type=Orcish Warlord
            side=5
            x=49,48
            y=19,19
        [/move_unit_fake]

        [unhide_unit]
        [/unhide_unit]

        [message]
            speaker=Shan Taum
            message= _ "Now now now, what do we have here. Collaborating with the enemy again just like your disgusting father, are you?"
        [/message]

        [message]
            speaker="Kapou'e"
            # wmllint: local spelling pfff
            message= _ "Collaborating with the humans, pfff. You’re one to talk. What are you doing here, Shan Taum?"
        [/message]

        [message]
            speaker=Shan Taum
            message= _ "I am here to do to you what I did to your father."
        [/message]

        [message]
            speaker="Kapou'e"
            message= _ "So you did kill my father then."
        [/message]

        [message]
            speaker=Howgarth III
            message= _ "What did I tell you, Kapou’e?"
        [/message]

        [message]
            speaker="Earl Lanbec'h"
            image=portraits/lanbech.png~FL()~RIGHT()
            message= _ "Ha ha! Good work Shan Taum. That will teach them. Attack, boys, I want Dorest recaptured by sunset."
        [/message]

        [message]
            speaker=Howgarth III
            message= _ "Hold, Earl Lanbec’h. I have reached an agreement with these orcs. Since your army has been the aggressor, you must immediately disperse your army and withdraw from orcish territory. Once that is done then Kapou’e will give you back Dorest and call off the horde. I have had dealings with Kapou’e’s father before and I believe his blood will be trustworthy. And if that isn’t enough, then we are here to protect you in case he violates the pact."
        [/message]

        [message]
            speaker="Earl Lanbec'h"
            image=portraits/lanbech.png~FL()~RIGHT()
            message= _ "You and your damned compromises can go to hell. Your beloved Kapou’e will be joining you shortly."
        [/message]

        [message]
            speaker=Howgarth III
            message= _ "You leave us no choice but to take military action against you."
        [/message]

        [message]
            speaker="Earl Lanbec'h"
            image=portraits/lanbech.png~FL()~RIGHT()
            message= _ "Ha ha! Very funny, Howgarth. Look around you. You are going to be dead as soon as my orc friend here gives the order. And then your men will automatically assume that Kapou’e tricked and killed you."
        [/message]

        [message]
            speaker=Howgarth III
            message= _ "Not today, my friend. (<i>Whistles</i>)"
        [/message]

        [move_unit_fake]
            type=Gryphon Master
            side=6
            x=52,47
            y=21,22
        [/move_unit_fake]

        [unit]
            type=Gryphon Master
            x=47
            y=22
            side=6
            generate_name=yes
            random_traits=yes
        [/unit]

        [move_unit_fake]
            type=Gryphon Master
            side=6
            x=47,44
            y=27,23
        [/move_unit_fake]

        [unit]
            type=Gryphon Master
            x=44
            y=23
            side=6
            generate_name=yes
            random_traits=yes
            facing=sw
        [/unit]

        [move_unit_fake]
            type=Gryphon Master
            side=6
            x=38,41
            y=22,22
        [/move_unit_fake]

        [unit]
            type=Gryphon Master
            x=41
            y=22
            side=6
            generate_name=yes
            random_traits=yes
        [/unit]

        [move_unit_fake]
            type=Gryphon Master
            side=6
            x=51,44
            y=22,19
        [/move_unit_fake]

        [unit]
            type=Gryphon Master
            id=gryphon1
            x=44
            y=19
            side=6
            generate_name=yes
            [modifications]
                {TRAIT_STRONG}
            [/modifications]
        [/unit]

        {ATTACK_ANIM gryphon1 warrior1 yes 16 16}
        {ATTACK_ANIM warrior1 gryphon1 no 0 ()}
        {ATTACK_ANIM gryphon1 warrior1 yes 16 16}
        {ATTACK_ANIM warrior1 gryphon1 yes 10 10}
        {ATTACK_ANIM warrior1 gryphon1 no 0 ()}

        [move_unit_fake]
            type=Gryphon Master
            side=6
            x=52,45
            y=18,18
        [/move_unit_fake]

        [unit]
            type=Gryphon Master
            id=gryphon2
            x=45
            y=18
            side=6
            generate_name=yes
            [modifications]
                {TRAIT_STRONG}
            [/modifications]
            facing=sw
        [/unit]

        {ATTACK_ANIM gryphon2 warrior1 yes 16 16}
        {ATTACK_ANIM warrior1 gryphon2 no 0 ()}
        {ATTACK_ANIM gryphon2 warrior1 yes 7 7}

        [kill]
            id=warrior1
            animate=yes
        [/kill]

        [message]
            speaker=Howgarth III
            message= _ "Kapou’e, it is essential that I make it back to my camp to bring news of our agreement and this treachery. One of my gryphon riders will take me. My bodyguards and the rest of my gryphons will help you fight free of this ambush. Once you get back to your camp, we will make a joint assault on these traitors. Once they are dead and dispersed, then I trust you will carry out our agreement."
        [/message]

        [message]
            speaker="Kapou'e"
            message= _ "Agreed. Let’s get to it. BLOOD AND STEEL!"
            image=portraits/kapoue-angry.png
        [/message]

        [store_unit]
            [filter]
                id=Howgarth III
            [/filter]

            kill=yes
            variable=stored_Hogwarth
        [/store_unit]

        {VARIABLE stored_Hogwarth.x 57}
        {VARIABLE stored_Hogwarth.y 27}

        {MOVE_UNIT x,y=47,22 56 26}

        [unstore_unit]
            variable=stored_Hogwarth
        [/unstore_unit]

        [message]
            speaker=Shan Taum
            message= _ "Blast! The human has escaped. Orcs, bring me Kapou’e’s head. I must get to my camp and assault the city."
        [/message]

        [store_unit]
            [filter]
                id=Shan Taum
            [/filter]

            kill=yes
            variable=stored_ShanTaum
        [/store_unit]

        {VARIABLE stored_ShanTaum.x 60}
        {VARIABLE stored_ShanTaum.y 6}

        [move_unit_fake]
            type=Orcish Warlord
            side=5
            x=48,60
            y=19,6
        [/move_unit_fake]

        [unstore_unit]
            variable=stored_ShanTaum
        [/unstore_unit]

        [message]
            speaker=Grüü
            image=portraits/gruu.png~FL()~RIGHT()
            message= _ "Shan Taum big coward. Never want to fight."
        [/message]

        {CLEAR_VARIABLE stored_Hogwarth,stored_ShanTaum}
    [/event]

    [event]
        name=new turn
        first_time_only=no

        [store_time_of_day]
        [/store_time_of_day]

        [if]
            [variable]
                name=time_of_day.id
                equals=afternoon
            [/variable]

            [then]
                {GENERIC_UNIT 4 General 22 38}
                {GENERIC_UNIT 4 Swordsman 22 38}
                {GENERIC_UNIT 4 Swordsman 22 38}
                {GENERIC_UNIT 4 Longbowman 22 38}
                {GENERIC_UNIT 4 Longbowman 22 38}
                {GENERIC_UNIT 4 Horseman 22 38}
                {GENERIC_UNIT 4 Horseman 22 38}
            [/then]
        [/if]

        {CLEAR_VARIABLE time_of_day}
    [/event]

    [event]
        name=die

        [filter]
            id=Shan Taum
        [/filter]

        [if]
            [have_unit]
                side=1,2,3
                x,y=$x2,$y2
            [/have_unit]

            [then]
                [if]
                    [variable]
                        name=second_unit.id
                        equals="Kapou'e"
                    [/variable]
                    [then]
                        [message]
                            speaker=second_unit
                            message= _ "Yeah, we finally got the coward."
                        [/message]
                    [/then]
                    [else]
                        [message]
                            speaker=second_unit
                            message= _ "Yeah, we finally got the coward. What do you want us to do with him, Chief?"
                        [/message]
                    [/else]
                [/if]
            [/then]

            [else]
                [message]
                    speaker="Kapou'e"
                    message= _ "Blood and steel! The traitor was mine!"
                    image=portraits/kapoue-angry.png
                [/message]

                [message]
                    speaker=Howgarth III
                    message= _ "I’m sorry, Kapou’e. I’ll have my men leave what remains of him to you."
                [/message]

                [message]
                    side=1,2,3
                    canrecruit=no
                    message= _ "What do you want us to do with him, Chief?"
                [/message]
            [/else]
        [/if]

        [message]
            speaker="Kapou'e"
            message= _ "Stick his head at the end of a pike and let the buzzards pick it clean. I wasn’t joking about making a mug from his skull."
        [/message]
    [/event]

    [event]
        name=die

        [filter]
            id=Howgarth III
        [/filter]

        [message]
            speaker="Kapou'e"
            message= _ "No! Without him the Northern Alliance will continue to fall apart."
        [/message]

        [endlevel]
            result=defeat
        [/endlevel]
    [/event]

    [event]
        name=victory

        [message]
            speaker=Grüü
            message= _ "YEAH!"
        [/message]

        [endlevel]
            result=victory
            carryover_report=no
            save=no
            linger_mode=no
        [/endlevel]
    [/event]

    {HERO_DEATHS}
[/scenario]
