#textdomain wesnoth-Invasion_from_the_Unknown

[scenario]
    id=12_The_Escape
    name= _ "The Escape"
    {MAP 12_The_Escape.map}
    {TURNS 40 38 36}
    next_scenario=12x_Outside
    victory_when_enemies_defeated=no

    {SCENARIO_MUSIC       "climactic_contemplation.ogg"}
    {EXTRA_SCENARIO_MUSIC "breaking_the_chains.ogg"}
    {EXTRA_SCENARIO_MUSIC "legends_of_the_north.ogg"}

    {UNDERGROUND}

    {STORYTXT_THE_ESCAPE}

    {DEATHS_ACT_2_2}
    {DEATHS_DWARVES}

    #
    # This scenario generates two public variables: anlinde_eoe1_state and
    # anlinde_eoe1_recall_list, containing Anlindë's unit WML, the synthetic
    # recall list used for her in E1S13, and Galas's recall list,
    # respectively. These variables are meant to persist between E1S12,
    # E1S12x, and E1S13.
    #

    # wmllint: validate-off
    [side]
        side=1
        controller=human
        team_name=heroes
        user_team_name= _ "team_name^Elves and Dwarves"

        shroud=yes

        # NOTE: gold must be 6 * max(recruit_cost, recall_cost) at the very
        #       minimum in order to let the player recall or recruit units on
        #       the first turn.
        gold=156
        # Emulate free upkeep for everyone without having to modify units.
        village_support=99

        # wmllint: recognize Galas
        {CHARACTER_STATS_GALAS}
    [/side]
    # wmllint: validate-on

#define TE_AVOID_STARTING_AREA
    [avoid]
        x=1-100
        y=45-100
    [/avoid]
#enddef

    # Loyalists for crossfire
    [side]
        side=2
        team_name=enemies
        user_team_name= _ "team_name^Chaos Empire"
        {CHAOS_FLAG}

        no_leader=yes
        recruit=Demon,Chaos Bowman,Chaos Invader,Chaos Invoker,Automaton,Imp,Mudcrawler,Chaos Headhunter

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_SIMPLE_ALWAYS_ASPECT aggression 1.00}
            {AI_SIMPLE_ALWAYS_ASPECT caution    0.00}

            {TE_AVOID_STARTING_AREA}
        [/ai]
    [/side]

    # Desperate Trolls
    [side]
        side=3
        team_name=trolls
        user_team_name= _ "team_name^Trolls"
        {RAGGED_FLAG}

        no_leader=yes
        recruit=Troll Whelp

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_SIMPLE_ALWAYS_ASPECT aggression 100.00} # Encourage them to get hurt.
            {AI_SIMPLE_ALWAYS_ASPECT caution      0.00}

            [goal]
                [criteria]
                    side=1
                [/criteria]
                value=0.0
            [/goal]
            [goal]
                [criteria]
                    side=2
                [/criteria]
                value=10.0
            [/goal]

            {TE_AVOID_STARTING_AREA}
        [/ai]
    [/side]

    # Cave creeps
    [side]
        side=4
        team_name=enemies
        user_team_name= _ "team_name^Cave Creatures"
        {RAGGED_FLAG}

        no_leader=yes
        hidden=yes

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_SIMPLE_ALWAYS_ASPECT aggression 100.00} # Encourage them to get hurt.
            {AI_SIMPLE_ALWAYS_ASPECT caution      0.00}

            {TE_AVOID_STARTING_AREA}
        [/ai]

        {SIDE_GENERIC_GUARD (Giant Ant) 35 45}
        {SIDE_GENERIC_GUARD (Giant Ant) 37 42}
        {SIDE_GENERIC_GUARD (Giant Ant) 36 42}
        {SIDE_GENERIC_GUARD (Giant Ant) 36 41}

#ifndef EASY
        {SIDE_GENERIC_GUARD (Lesser Giant Spider) 36 40}
#endif

        {SIDE_GENERIC_GUARD (Eyestalk) 30 37}
        {SIDE_GENERIC_GUARD (Eyestalk) 10 31}
        {SIDE_GENERIC_GUARD (Eyestalk) 39 22}
        {SIDE_GENERIC_GUARD (Eyestalk) 17 44}

        {SIDE_GENERIC_GUARD (Lesser Giant Spider) 12 29}
    [/side]

    # Final loyalists
    [side]
        side=5
        team_name=enemies
        user_team_name= _ "team_name^Chaos Empire"
        {CHAOS_FLAG}

        no_leader=yes
        recruit=Demon,Imp,Chaos Headhunter

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_SIMPLE_ALWAYS_ASPECT aggression 1.00}
            {AI_SIMPLE_ALWAYS_ASPECT caution    0.00}

            {TE_AVOID_STARTING_AREA}
        [/ai]
    [/side]

    # Goliath miniboss and friends
    [side]
        side=6
        team_name=enemies
        user_team_name= _ "team_name^Chaos Empire"
        {CHAOS_FLAG}

        no_leader=yes

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_SIMPLE_ALWAYS_ASPECT aggression        100.00} # Encourage them to get hurt.
            {AI_SIMPLE_ALWAYS_ASPECT caution             0.00}
            {AI_SIMPLE_ALWAYS_ASPECT leader_ignores_keep  yes}

            {TE_AVOID_STARTING_AREA}
        [/ai]
    [/side]

    {STARTING_VILLAGES 1 9}

    {CAVE_NOISE_SOUND_SOURCE}

    {CAVE_WATER_SOUND_SOURCE 36 12}
    {CAVE_WATER_SOUND_SOURCE 21 22}
    {CAVE_WATER_SOUND_SOURCE 39 48}

#define TE_DEFINE_OBJECTIVE _ID _TEXT
    [literal]
        id={_ID}
        text={_TEXT}
        active=no
        completed=no
    [/literal]
#enddef

#define TE_RESET_OBJECTIVES
    [fire_event]
        name=reset objectives
    [/fire_event]
#enddef

    [event]
        name=prestart

        #
        # TA used for surface ToD and the final goal SLF.
        #
        [time_area]
            id=surface

            x=1-100
            y=1-5
            [not]
                terrain=X*
            [/not]

            {LONGDARK4}
        [/time_area]

        # wmllint: recognize Anlindë

        # Take Anlindë aside for E1S13.
        [store_unit]
            [filter]
                id=Anlindë
            [/filter]
            variable=anlinde_eoe1_state
            kill=yes
        [/store_unit]

        #
        # Recall heroes
        #

        # wmllint: recognize Elynia
        {RECALL_ELYNIA_AT 42 55}
        # wmllint: recognize Mal Keshar
        {RECALL_MAL_KESHAR_AT 40 54}
        # wmllint: recognize Igor
        {RECALL_IGOR_AT 40 57}

        {FACE_DIRECTION (side=1) ne}

        # wmllint: recognize King Asthorgar
        {RECALL_ASTHORGAR_AT 43 53}
        # wmllint: recognize Althurin
        {RECALL_ALTHURIN_AT 44 51}

        {FACE_DIRECTION (id=Althurin,King Asthorgar) sw}

#ifdef EASY
        [unit]
            type=Dwarvish Guardsman
            side=1
            facing=ne
            x,y=43,51
            {IS_LOYAL}
            upkeep=free
            generate_name=yes
            random_traits=yes
            [modifications]
                {TRAIT_LOYAL}
            [/modifications]
        [/unit]

        [unit]
            type=Dwarvish Guardsman
            side=1
            facing=n
            x,y=45,52
            {IS_LOYAL}
            upkeep=free
            generate_name=yes
            random_traits=yes
            [modifications]
                {TRAIT_LOYAL}
            [/modifications]
        [/unit]
#endif

        [set_variables]
            name=escape_objectives
            mode=replace

            {TE_DEFINE_OBJECTIVE lagonus ( _ "Locate and eliminate the rearguard captain")}

            {TE_DEFINE_OBJECTIVE goliath ( _ "Defeat the Goliath")}

            {TE_DEFINE_OBJECTIVE yreul   ( _ "Defeat Yreul")}
        [/set_variables]

        {TE_RESET_OBJECTIVES}
    [/event]

    # Tag implementation raises 'reset objectives' event.
#define TE_NEW_OBJECTIVE _ID
    [update_escape_objectives]
        id={_ID}
    [/update_escape_objectives]
#enddef

    # Tag implementation raises 'reset objectives' event.
#define TE_COMPLETED_OBJECTIVE _ID
    [update_escape_objectives]
        id={_ID}
        completed=yes
    [/update_escape_objectives]
#enddef

#define TE_NOTE_ONLY_ON_FIRST_TURN
    {OBJECTIVE_NOTE_SHOW_IF ({VARIABLE_NUMERICAL_LESS_THAN turn_number 2})}
#enddef

#define TE_NOTE_ONLY_ON_GAMEPLAY_TURNS
    {OBJECTIVE_NOTE_SHOW_IF ({VARIABLE_NUMERICAL_GREATER_THAN turn_number 1})}
#enddef

    #
    # Set objectives
    #

    [event]
        name=reset objectives
        first_time_only=no

        [set_variables]
            name=temp_objectives_data
            mode=replace
            [literal]
                side=1

                {OBJECTIVE_DEFEAT ( _ "Death of Galas")}
                {OBJECTIVE_DEFEAT ( _ "Death of Elynia")}
                {OBJECTIVE_DEFEAT ( _ "Death of Mal Keshar")}
                {OBJECTIVE_DEFEAT ( _ "Death of King Asthorgar")}
                {OBJECTIVE_DEFEAT ( _ "Death of Althurin")}

                {OBJECTIVE_NO_CARRYOVER}

                {OBJECTIVE_NOTE ( _ "In this scenario, you may only recall or recruit units during the first turn")}
                {TE_NOTE_ONLY_ON_FIRST_TURN}
                {OBJECTIVE_NOTE ( _ "Because Mal Keshar has granted control of most of his undead minions to Anlindë, any undead veterans you do not recall in this scenario will be permanently lost.")}
                {TE_NOTE_ONLY_ON_FIRST_TURN}
                {OBJECTIVE_NOTE ( _ "You may not recall or recruit units")}
                {TE_NOTE_ONLY_ON_GAMEPLAY_TURNS}
            [/literal]
        [/set_variables]

        {VARIABLE temp_have_int_objectives no}

        [foreach]
            array=escape_objectives
            variable=escape_objective
            [do]
                [if]
                    {VARIABLE_BOOLEAN_EQUALS escape_objective.active yes}
                    [then]
                        [set_variables]
                            name=temp_objectives_data.objective
                            mode=append
                            [value]
                                description=$escape_objective.text
                                condition=win
                            [/value]
                        [/set_variables]

                        #
                        # Completed goals are displayed in strike-through format.
                        #
                        [if]
                            {VARIABLE_BOOLEAN_EQUALS escape_objective.completed yes}
                            [then]
                                {VARIABLE temp_last "$($temp_objectives_data.objective.length - 1)"}
                                {VARIABLE
                                temp_objectives_data.objective[$temp_last].description
                                "<s>$temp_objectives_data.objective[$temp_last].description|</s>"}
                                {CLEAR_VARIABLE temp_last}
                            [/then]
                            [else]
                                {VARIABLE temp_have_int_objectives yes}
                            [/else]
                        [/if]
                    [/then]
                [/if]
            [/do]
        [/foreach]

        [if]
            {VARIABLE_BOOLEAN_EQUALS temp_have_int_objectives no}
            [then]
                #
                # Default objectives.
                #
                [set_variables]
                    name=temp_objectives_data.objective
                    mode=append
                    [value]
                        description= _ "Galas, Elynia, or Mal Keshar must reach the exit to the northlands"
                        condition=win
                    [/value]
                [/set_variables]

                {VARIABLE temp_objectives_data.summary ( _ "Current objectives:")}
            [/then]
            [else]
                {VARIABLE temp_objectives_data.summary ( _ "New objectives:")}
            [/else]
        [/if]

        [insert_tag]
            name=objectives
            variable="temp_objectives_data"
        [/insert_tag]

        {CLEAR_VARIABLE temp_objectives_data,temp_have_int_objectives}
    [/event]

    [event]
        name=start

        [message]
            speaker=King Asthorgar
            message= _ "The exit’s to the north. But before we proceed, I must warn ye: it ha’ been long since we last walked these caves, so we should be prepared to deal with anything that might be awaitin’ down the road."
        [/message]

        [message]
            speaker=Galas
            message= _ "Such as an unexpected encounter with Chaos troops? We are accustomed to that kind of thing after our quest underground."
        [/message]

        [message]
            speaker=Elynia
            message= _ "We must make haste, though. We don’t know for how long Anlindë’s strategy is going to work and provide us with safe passage."
        [/message]

        [message]
            speaker=Galas
            message= _ "Indeed... I would be unable to bear the thought of her sacrifice turning out to be in vain after so much."
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Hmph, I sure hope she has put my minions to good use. I had grown fond of some of them. Ah well, there will be plenty of opportunities to raise more later."
        [/message]
    [/event]

    [event]
        name=turn 2

        # No recruits or recalls after turn 2!
        [store_unit]
            [filter]
                side=1
                x,y=recall,recall
            [/filter]
            variable=galas_recalls
            kill=yes
        [/store_unit]

        # Get rid of this forever, we set up a new one from scratch in E2S1.
        {REMOVE_RECRUIT_LIST 1}
    [/event]

    # 1. The Mother Mudcrawler
    [event]
        name=moveto
        [filter]
            side=1
            x=30-39
            y=34-42
        [/filter]

        {CLEAR_CAVE_SHROUD x,y,radius=39,38,3}

        [redraw]
            side=1
        [/redraw]

        {GENERIC_UNIT 4 (Mother Mudcrawler) 39 38} {NO_UPKEEP_NO_OVERLAY} {FACING sw}
        {GENERIC_UNIT 4 (Giant Mudcrawler)  39 39} {NO_UPKEEP_NO_OVERLAY} {FACING sw}
        {GENERIC_UNIT 4 (Giant Mudcrawler)  38 37} {NO_UPKEEP_NO_OVERLAY} {FACING sw}
        {GENERIC_UNIT 4 (Mudcrawler)        38 38} {NO_UPKEEP_NO_OVERLAY} {FACING sw}

        [message]
            type=Mother Mudcrawler
            message= _ "Groaaaar!!" # wmllint: no spellcheck
        [/message]

        [message]
            speaker=unit
            {UNIT_SPEAKS_FOR_UNDEAD_MINION (id=Mal Keshar)}
            female_message= _ "female^I had heard of unusually large mudcrawlers before, but this thing is..."
            male_message= _ "I had heard of unusually large mudcrawlers before, but this thing is..."
        [/message]
    [/event]

#define TE_ACTIVATE_SIDE _SIDE _GOLD _LEADER_WML
    [modify_side]
        side={_SIDE}
        gold={_GOLD}
    [/modify_side]

    [unit]
        side={_SIDE}
        placement=leader
        {_LEADER_WML}
    [/unit]
#enddef

    # 2. Crossfire
    [event]
        name=moveto
        [filter]
            side=1
            x=1-29
            y=32-40
        [/filter]

        {TE_NEW_OBJECTIVE yreul}

        {CLEAR_CAVE_SHROUD x,y,radius=20,37,6}

        [redraw]
            side=1
        [/redraw]

        # wmllint: recognize Yreul

        {TE_ACTIVATE_SIDE 2 {DIFF 100 130 150} (
            canrecruit=yes
            id=Yreul
            name= _ "Yreul"
            type=Chaos Soulhunter
            facing=ne
            [modifications]
                {TRAIT_UNDEAD} # Why not?™
                {TRAIT_STRONG}
            [/modifications]
        )}

        [unit]
            side=2
            type=Blood Imp
            generate_name=yes
            placement=leader
            facing=ne
            upkeep=free
            [modifications]
                {TRAIT_RESILIENT}
                {TRAIT_SLOW}
            [/modifications]
        [/unit]

        # wmllint: recognize Karshas

        {TE_ACTIVATE_SIDE 3 {DIFF 90 100 110} (
            canrecruit=yes
            id=Karshas
            name= _ "Karshas"
            type=Troll Warrior
            facing=sw
            [modifications]
                {TRAIT_QUICK}
                {TRAIT_RESILIENT}
            [/modifications]
        )}

        [unit]
            side=3
            type=Troll Rocklobber
            id=Burg
            name= _ "Burg"
            placement=leader
            facing=sw
            upkeep=free
            [modifications]
                {TRAIT_STRONG}
                {TRAIT_FEARLESS}
            [/modifications]
        [/unit]

        [message]
            speaker=Karshas
            message= _ "Damned creatures! You kill our children! You pay with your blood!"
        [/message]

        [message]
            speaker=Yreul
            message= _ "Fat chance, dimwit. Get out of the way this instant, unless you would rather be ground into dust!"
        [/message]

        [message]
            side,type=2,Blood Imp
            message= _ "Hey, hey, what do we have here? The elfses and dwarfses are tryin’ to escape thru the backdoor!" # wmllint: no spellcheck
        [/message]

        [message]
            speaker=unit
            {UNIT_SPEAKS_FOR_UNDEAD_MINION (id=Mal Keshar)}
            message= _ "Uh..."
        [/message]

        [message]
            speaker=Yreul
            message= _ "Hah! So they are coming to us now! What’s your clever plan, rats? I am certain the captain will be very pleased to see your impaled heads topping our banners!"
        [/message]

        [message]
            speaker=Galas
            message= _ "We’ll have to deal with this scum first, lest they bring news of us to their superiors."
        [/message]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Yreul
        [/filter]

        [message]
            speaker=unit
            message= _ "Defeated... by rats!"
        [/message]
    [/event]

    [event]
        name=die
        [filter]
            id=Yreul
        [/filter]

        {TE_COMPLETED_OBJECTIVE yreul}
    [/event]

    # 3. The Goliath
    [event]
        name=moveto
        [filter]
            side=1
            x=11-20
            y=20-30
        [/filter]

        {TE_NEW_OBJECTIVE goliath}

        {CLEAR_CAVE_SHROUD x,y,radius=16,26,4}

        [redraw]
            side=1
        [/redraw]

        [unit]
            canrecruit=yes
            side=6
            type=Goliath
            {IS_BOSS}
            placement=leader
            facing=sw
        [/unit]

        [repeat]
            times={DIFF 2 3 3}
            [do]
                [unit]
                    side=6
                    type=Automaton
                    random_traits=yes
                    placement=leader
                    facing=sw
                    upkeep=free
                [/unit]
            [/do]
        [/repeat]

        [message]
            type=Goliath
            message= _ "The vermin must die! Affirmative!"
        [/message]

        # wmllint: local spelling aaah

        [message]
            speaker=unit
            {UNIT_SPEAKS_FOR_UNDEAD_MINION (id=Mal Keshar)}
            message= _ "Aaah! Another one of these metallic beasts!"
        [/message]

        [message]
            speaker=Galas
            message= _ "This is turning out to be harder than we expected."
        [/message]
    [/event]

    [event]
        name=die
        [filter]
            type=Goliath
            canrecruit=yes
        [/filter]

        {TE_COMPLETED_OBJECTIVE goliath}
    [/event]

    # 4. The Rearguard
    [event]
        name=moveto
        [filter]
            side=1
            x=20-35
            y=17-28
        [/filter]

        {TE_NEW_OBJECTIVE lagonus}

        {CLEAR_CAVE_SHROUD x,y,radius=26,24,5}

        [redraw]
            side=1
        [/redraw]

        {GENERIC_UNIT 5 (Hellhound) 26 24} {NO_UPKEEP_NO_OVERLAY} {FACING sw}

        {GENERIC_UNIT 6 (Automaton) 22 23} {NO_UPKEEP_NO_OVERLAY}
        {GENERIC_UNIT 6 (Automaton) 24 26} {NO_UPKEEP_NO_OVERLAY}
        {GENERIC_UNIT 6 (Automaton) 25 22} {NO_UPKEEP_NO_OVERLAY}
        {GENERIC_UNIT 6 (Automaton) 29 26} {NO_UPKEEP_NO_OVERLAY}
        {GENERIC_UNIT 6 (Automaton) 30 22} {NO_UPKEEP_NO_OVERLAY}

        {NAMED_UNIT 5 (Demon Zephyr) 27 24 Lilith ( _ "Lilith") (
            gender=female
            facing=sw
            [modifications]
                {TRAIT_STRONG}
                {TRAIT_DEXTROUS}
            [/modifications]
        )}

        {GENERIC_UNIT 6 (Demon) 26 23} {NO_UPKEEP_NO_OVERLAY} {FACING sw}
        {GENERIC_UNIT 6 (Demon) 27 25} {NO_UPKEEP_NO_OVERLAY} {FACING sw}

        {GENERIC_UNIT 5 (Chaos Marauder) 29 24} {NO_UPKEEP_NO_OVERLAY} {FACING sw}
        {GENERIC_UNIT 5 (Chaos Headhunter) 27 22} {NO_UPKEEP_NO_OVERLAY} {FACING sw}
        {GENERIC_UNIT 5 (Chaos Headhunter) 26 26} {NO_UPKEEP_NO_OVERLAY} {FACING sw}

        [message]
            speaker=Lilith
            message= _ "There they are! Don’t let them cross the bridge!"
        [/message]

        [message]
            type=Hellhound
            message= _ "Grrrrrr..." # wmllint: no spellcheck
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Hm, I see — they are the rearguard of our ‘friends’. Their blockade would be far more effective if they just demolished the bridge, so surely their captain is right across."
        [/message]
    [/event]

    # 5. The Rearguard Captain
    [event]
        name=moveto
        [filter]
            side=1
            x=28-29,30-31,1-27,32,32-53
            y= 1-18, 1-17,1-16,17,1-13
        [/filter]

        # wmllint: recognize Lagonus

        {TE_ACTIVATE_SIDE 5 {DIFF 90 120 130} (
            canrecruit=yes
            id=Lagonus
            name= _ "Lagonus"
            type=Gutwrencher Imp
            facing=se
            [modifications]
                {TRAIT_STRONG}
                {TRAIT_INTELLIGENT}
            [/modifications]
        )}

#ifndef EASY
        {GENERIC_UNIT 5 (Blood Imp) 26 11} {NO_UPKEEP_NO_OVERLAY} {FACING se}
#endif
        {GENERIC_UNIT 5 (Imp) 25 10} {NO_UPKEEP_NO_OVERLAY} {FACING se}
        {GENERIC_UNIT 5 (Imp) 27 10} {NO_UPKEEP_NO_OVERLAY} {FACING se}

        {CLEAR_CAVE_SHROUD (
            x,y,radius=26,10,4
        )}

        [redraw]
            side=1
        [/redraw]

        [message]
            speaker=Lagonus
            message= _ "I swear to Uria, this is the end of the road for you, insolent maggots! Prepare to die!"
        [/message]

        [message]
            speaker=Galas
            message= _ "Wishful thinking, filth!"
        [/message]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Lagonus
        [/filter]

        [message]
            speaker=unit
            message= _ "How could I fail like this? Forgive me, Master... <i>(gurgle)</i>"
        [/message]
    [/event]

    [event]
        name=die
        [filter]
            id=Lagonus
        [/filter]

        {TE_COMPLETED_OBJECTIVE lagonus}

        [message]
            speaker=Galas
            message= _ "The imp’s body is dissolving into slime!"
        [/message]

        {VARIABLE i 0}

        [while]
            {VARIABLE_NUMERICAL_LESS_THAN i 4}
            [do]
                [unit]
                    side=$unit.side
#ifdef EASY
                    type=Mudcrawler
#else
                    type="$( if( ($i = 1) or ($i = 2), 'Giant Mudcrawler', 'Mudcrawler' ) )"
#endif
                    # BUG: using placement=leader_passable here as of 1.11.12
                    #      has no effect (no location is stored in u!).
                    x,y=$x1,$y1
                    to_variable=u
                [/unit]

                [lua]
                    code=<<
                        local ctx = wesnoth.current.event_context
                        local x, y = wesnoth.paths.find_vacant_hex(ctx.x1, ctx.y1)
                        wml.variables["u.x"] = x
                        wml.variables["u.y"] = y
                    >>
                [/lua]

                [store_direction]
                    from_x,from_y=$u.x,$u.y
                    to_x,to_y=$x2,$y2
                    variable=u.facing
                [/store_direction]

                [move_unit_fake]
                    side=$u.side
                    type=$u.type
                    x=$x1,$u.x
                    y=$y1,$u.y
                [/move_unit_fake]

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

                {CLEAR_VARIABLE u}

                {VARIABLE_INC i}
            [/do]
        [/while]

        {CLEAR_VARIABLE i}

        [message]
            speaker=Elynia
            message= _ "This is truly disgusting."
        [/message]
    [/event]

    # 6. Anlindë dies
    [event]
        name=turn 30

        {QUAKE (rumble.ogg)}

        {QUAKE (cave-in.ogg)}
    [/event]

    # 7. Escape
    [event]
        name=moveto
        first_time_only=no
        [filter]
            id=Galas,Elynia,Mal Keshar
            [filter_location]
                area=surface
            [/filter_location]
        [/filter]

        {VARIABLE all_objectives_complete yes}

        [foreach]
            array=escape_objectives
            variable=escape_objective
            [do]
                [if]
                    {VARIABLE_BOOLEAN_EQUALS escape_objective.active yes}
                    {VARIABLE_BOOLEAN_EQUALS escape_objective.completed no}
                    [then]
                        {VARIABLE all_objectives_complete no}

                        [break][/break]
                    [/then]
                [/if]
            [/do]
        [/foreach]

        [if]
            {VARIABLE_BOOLEAN_EQUALS all_objectives_complete yes}
            [then]
                [message]
                    speaker=unit
                    female_message= _ "female^The exit, at last! Follow me!"
                    male_message= _ "The exit, at last! Follow me!"
                [/message]

                # Go to an interlude scenario, intended to ease testing of
                # scenario 13's side init code and to make a more interesting
                # landscape for the player.
                {ENDLEVEL_QUIET}
            [/then]
            [else]
                [role]
                    role=complainer
                    side=1
                    [not]
                        # wmllint: recognize $unit.id
                        # FIXME: I mean seriously, what the hell, wmllint?
                        id=Igor,$unit.id
                    [/not]
                    [not]
                        race=bats,undead
                        [not]
                            type=Lich,Ancient Lich,Ghost,Wraith,Spectre,Shadow,Nightgaunt
                        [/not]
                    [/not]
                [/role]

                [message]
                    role=complainer
                    message= _ "Wait a moment, we cannot leave yet! If we don’t dispose of our pursuers, they may report our position to their leaders!"
                [/message]
            [/else]
        [/if]

        {CLEAR_VARIABLE all_objectives_complete}
    [/event]

    [event]
        name=time over

        [message]
            speaker=Galas
            message= _ "I can hear their main assault force approaching from behind. Oh, forgive me, Anlindë..."
        [/message]
    [/event]

    [event]
        name=victory

        [if]
            {VARIABLE_NUMERICAL_GREATER_THAN galas_recalls.length 0}
            [then]
                #
                # Came here from turn 2 or later -- we need to temporarily
                # unstore Galas's# recall list so we can let the engine do
                # the unit data juggling for us.
                #

                [foreach]
                    array=galas_recalls
                    [do]
                        [unstore_unit]
                            variable=this_item
                            x,y=recall,recall
                        [/unstore_unit]
                    [/do]
                [/foreach]

                {CLEAR_VARIABLE galas_recalls}
            [/then]
        [/if]

        #
        # Move undead minions who aren't on the map to Anlindë's recall list.
        # This list is meant to include generic Liches (but not living
        # Necromancers) as a convenience for players.
        #

        [store_unit]
            [filter]
                side=1
                x,y=recall,recall
                race=undead
            [/filter]
            variable=anlinde_eoe1_recall_list
            kill=yes
        [/store_unit]

        #
        # Switching leader, recall lists, and gold supplies is left as a task
        # for E1S13's prestart.
        #

        {CLEAR_VARIABLE escape_objectives}
    [/event]
[/scenario]

#undef TE_AVOID_STARTING_AREA
#undef TE_DEFINE_OBJECTIVE
#undef TE_RESET_OBJECTIVES
#undef TE_NEW_OBJECTIVE
#undef TE_COMPLETED_OBJECTIVE
#undef TE_NOTE_ONLY_ON_FIRST_TURN
#undef TE_NOTE_ONLY_ON_GAMEPLAY_TURNS
#undef TE_ACTIVATE_SIDE

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-Invasion_from_the_Unknown

[scenario]
    id=13x_Intermission
    name= _ "Intermission"
    {NO_MAP_DATA}
    next_scenario=14_Bye_and_Behold
    victory_when_enemies_defeated=no

    {FULLSCREEN_CUTSCENE_UI}

    {SCENARIO_MUSIC "data/core/sounds/ambient/wardrums.ogg"}

    # wmllint: validate-off
    [side]
        side=1
        controller=human
        team_name=heroes
        user_team_name= _ "team_name^Elves"

        shroud=yes

        {NO_ECONOMY}

        # wmllint: recognize Galas
        {CHARACTER_STATS_GALAS}
    [/side]
    # wmllint: validate-on

    [event]
        name=prestart

        # Galas to recall list
        {RESET_AND_SEND_TO_RECALL_LIST id=Galas}

        [modify_unit]
            [filter]
                id=Galas
            [/filter]
            moves=$this_unit.max_moves
        [/modify_unit]

        [place_shroud]
            side=1
        [/place_shroud]
    [/event]

    [event]
        name=start

        [intermission_prompt][/intermission_prompt]
    [/event]
[/scenario]

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-Invasion_from_the_Unknown

[scenario]
    id=13_Face_your_Fate
    name= _ "Face your Fate"
    {MAP 13_Face_your_Fate.map}
    {TURNS 10 12 14}
    next_scenario=13x_Intermission
    victory_when_enemies_defeated=no

    {SCENARIO_MUSIC       "into_the_shadows.ogg"} {CONTINUE_PLAYING_STORY_MUSIC_FIRST}
    {EXTRA_SCENARIO_MUSIC "suspense.ogg"}

    {UNDERGROUND}

    {STORYTXT_FACE_YOUR_FATE}

    {SHAXTHAL_SET_SURFACE_VARIATIONS_FLAG}

    #
    # We could have used a new side 1 player with a different save_id for this
    # scenario, but then we have no way to get rid of its stats and other
    # unwanted detritus later on and it would continue to take up space in
    # saved games. Plus, unlike the bifurcation done in AtS E3, this is a
    # one-time-only thing, so that approach seems wasteful to me.
    #
    #   -- shadowm, 2014-04-11
    #

    # wmllint: validate-off
    [side]
        side=1
        controller=human
        team_name=heroes
        user_team_name= _ "team_name^Elves"

        shroud=yes

        gold=0

        # wmllint: recognize Galas
        {CHARACTER_STATS_GALAS}
    [/side]
    # wmllint: validate-on

    # Boss
    [side]
        side=2
        team_name=foes
        user_team_name= _ "team_name^Chaos Warlord"
        {CHAOS_FLAG}
        color=gold
        controller=null

        hidden=yes
        no_leader=yes
        {NO_ECONOMY}

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_SIMPLE_ALWAYS_ASPECT aggression             9.00}
            {AI_SIMPLE_ALWAYS_ASPECT leader_aggression      9.00}
            {AI_SIMPLE_ALWAYS_ASPECT caution                0.00}
            {AI_SIMPLE_ALWAYS_ASPECT village_value          0.00}
            {AI_SIMPLE_ALWAYS_ASPECT leader_ignores_keep     yes}
            {AI_SIMPLE_ALWAYS_ASPECT grouping                 no}

            {AI_BOSS_TARGETING_ENGINE <<{"Anlindë"}>>}
        [/ai]
    [/side]

    # Vanguard
    [side]
        side=3
        team_name=foes
        user_team_name= _ "team_name^Chaos Empire"
        {CHAOS_FLAG}
        color=blue

        {GOLD 200 250 300}
        {INCOME 4 6 8}
        recruit=Imp,Demon,Chaos Headhunter,Chaos Invoker,Chaos Hound,Chaos Invader,Dark Knight,Doom Guard

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_SIMPLE_ALWAYS_ASPECT aggression             1.00}
            {AI_SIMPLE_ALWAYS_ASPECT caution                0.00}
            {AI_SIMPLE_ALWAYS_ASPECT village_value          0.00}
        [/ai]

        canrecruit=yes
        type=Gutwrencher Imp
        id=Laveri
        name= _ "Laveri"
        facing=ne
        experience=102
        [modifications]
            {TRAIT_RESILIENT}
            {TRAIT_INTELLIGENT}
        [/modifications]
    [/side]

#define FYF_DRONE _X _Y
    [unit]
        random_traits=yes
        generate_name=yes
        ai_special=guardian
        type=Shaxthal Drone
        x,y={_X},{_Y}
        upkeep=loyal
        variation=surface
    [/unit]
#enddef

    # Assimilating drones
    [side]
        side=4
        team_name=foes
        user_team_name= _ "team_name^Chaos Empire"
        {CHAOS_FLAG}
        color=brown

        {GOLD 130 180 230}
        {INCOME 4 5 7}
        recruit=Shaxthal Drone,Shaxthal Sentry Drone,Shaxthal Assault Drone

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_SIMPLE_ALWAYS_ASPECT aggression             1.00}
            {AI_SIMPLE_ALWAYS_ASPECT caution                0.00}
            {AI_SIMPLE_ALWAYS_ASPECT village_value          0.00}
            {AI_SIMPLE_ALWAYS_ASPECT grouping                 no}
        [/ai]

        canrecruit=yes
        type=Shaxthal Sentry Drone
        variation=surface
        [modifications]
            {TRAIT_BIOMECHANICAL}
            {TRAIT_ARMORED}
        [/modifications]

        {FYF_DRONE 13  9}
        {FYF_DRONE  8  7}
        {FYF_DRONE  9  5}
    [/side]

    # Enemy waves
    [side]
        side=5
        team_name=foes
        user_team_name= _ "team_name^Chaos Empire"
        {CHAOS_FLAG}
        color=black

        hidden=yes
        no_leader=yes
        {NO_ECONOMY}

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_SIMPLE_ALWAYS_ASPECT aggression             1.00}
            {AI_SIMPLE_ALWAYS_ASPECT caution                0.00}
            {AI_SIMPLE_ALWAYS_ASPECT village_value          0.00}
        [/ai]
    [/side]

    {STARTING_VILLAGES_ALL 1}
    {STARTING_VILLAGES 3 6}
    {STARTING_VILLAGES 4 6}

    {PLACE_IMAGE terrain/castle/dwarven-keep.png 36 12}

    {CAVE_NOISE_SOUND_SOURCE}
    [+sound_source]
        id=cave_ambience # wmllint: ignore
    [/sound_source]

    [event]
        name=prestart

        #
        # Manual player set-up.
        #

        #
        # Swap Galas and Anlindë's units.
        #

        [store_unit]
            [filter]
                id=Galas
            [/filter]
            variable=galas_eoe1_state
            kill=yes
        [/store_unit]

        [store_unit]
            [filter]
                side=1
                x,y=recall,recall
            [/filter]
            variable=galas_eoe1_recall_list
            kill=yes
        [/store_unit]

        # wmllint: recognize Anlindë

        [if]
            {VARIABLE_NUMERICAL_NOT_EQUALS anlinde_eoe1_state.length 1}
            [then]
                {BUG ()}

                #
                # We might be coming here via debug mode, so try to recall
                # Anlindë first to grab her data.
                #

                {RECALL_ANLINDE}

                [store_unit]
                    [filter]
                        id=Anlindë
                    [/filter]
                    variable=anlinde_eoe1_state
                    kill=yes
                [/store_unit]
            [/then]
        [/if]

        # Remove hero overlay+ellipse.
        {CLEAR_VARIABLE anlinde_eoe1_state.ellipse,anlinde_eoe1_state.overlays}
        # Wear the crown. Be the leader.
        {VARIABLE anlinde_eoe1_state.canrecruit yes}

        {VARIABLE anlinde_eoe1_state.facing sw}

        [unstore_unit]
            variable=anlinde_eoe1_state
            x,y=$galas_eoe1_state.x,$galas_eoe1_state.y
        [/unstore_unit]

        #
        # We don't care whether we can place any of her recall list units. In
        # fact, her list may be empty if the player somehow didn't have any
        # undead left in E1S12.
        #

        [foreach]
            array=anlinde_eoe1_recall_list
            [do]
                [unstore_unit]
                    variable=this_item
                    x,y=recall,recall
                [/unstore_unit]
            [/do]
        [/foreach]

        {CLEAR_VARIABLE anlinde_eoe1_state,anlinde_eoe1_recall_list}

        #[store_gold]
        #    side=1
        #    variable=galas_eoe1_gold
        #[/store_gold]

        # Set Anlindë's own gold amount and recruitment list, given by the dwarf King and Malin
        [modify_side]
            side=1
            {GOLD 380 340 320}
            {INCOME 12 11 10}
            recruit="Walking Corpse,Skeleton,Skeleton Archer,Dwarvish Ulfserker"
        [/modify_side]

        [remove_shroud]
            side=1
            [not]
                # The Warlord's spawn region.
                x= 0-14,  0-8
                y=17-27,28-32
                [not]
                    x= 3,5-7, 9
                    y=17, 17,17
                [/not]
            [/not]
        [/remove_shroud]

        [capture_village]
            # Uncapture villages in the Warlord's spawn region.
            x,y="8,4","20,29"
        [/capture_village]

        #
        # Set-up finished.
        #

        # Some dwarven fanatics to aid you.
#ifndef HARD
        {NAMED_GENERIC_UNIT 1 (Dwarvish Berserker) 34 13 Pelaes ( _ "Pelaes")}
        {NAMED_GENERIC_UNIT 1 (Dwarvish Flamethrower) 38 13 Pelcatil ( _ "Pelcatil")}
#endif
        {NAMED_GENERIC_UNIT 1 (Dwarvish Ulfserker) 34 11 Marlin ( _ "Marlin")}
        {NAMED_GENERIC_UNIT 1 (Dwarvish Ulfserker) 38 11 Durcanos ( _ "Durcanos")}

        # Enemy sidekicks
        # wmllint: recognize Izkotep
        {NAMED_GENERIC_UNIT 3 (Hell Guardian) () () Izkotep ( _ "Izkotep")}
        [+unit]
            placement=leader
            facing=ne
        [/unit]

        {OBJECTIVES (
            {HEADER_CURRENT_OBJECTIVES}

            {OBJECTIVE_VICTORY_END_OF_TURNS}

            {OBJECTIVE_DEFEAT ( _ "Death of Anlindë")}

            {OBJECTIVE_NO_CARRYOVER}
        )}
    [/event]

    [event]
        name=start

        [message]
            side=4
            canrecruit=yes
            message= _ "Shrieek!" # wmllint: no spellcheck
        [/message]

        [message]
            speaker=Anlindë
            message= _ "What in the world are those creatures doing?"
        [/message]

        [message]
            speaker=Durcanos
            message= _ "I’m na’ sure, they seem to be laying larvae on the flooded western keep."
        [/message]

        [message]
            speaker=Marlin
            message= _ "My lady, we swear we winna’ rest until either we ha’ spilled all the the blood o’ those wretched freaks, or our dead bodies are all layin’ on the floor. We’ll fight for ye. May the glorious ruins of Herthgar be our tomb!"
        [/message]

        [message]
            speaker=Laveri
            message= _ "Ah, the stench of death and decay that fills this place only intensifies my hunger. Let us make haste and finish this once and for all so we can have our well-deserved feast!"
        [/message]

        [message]
            speaker=Izkotep
            message= _ "Look, the elvish witch is on the dwarvish capital’s keep!"
        [/message]

        # wmllint: local spelling graaargh

        [message]
            speaker=Laveri
            message= _ "Graaargh, kill her, now! And the elf leader too! And find the filthy faerie of the forests — but remember the Warlord’s orders: trap the creature, but she must not come to harm! We need her alive and intact."
        [/message]

        [message]
            speaker=Izkotep
            message= _ "Attack now! You know what to do!"
        [/message]

        [message]
            speaker=Anlindë
            message= _ "Their final assault begins. Hopefully we’ll manage to give Galas and the rest enough time to escape unnoticed."
        [/message]
    [/event]

    #
    # Death of the Subcommander.
    #
    [event]
        name=last breath
        [filter]
            id=Laveri
        [/filter]

        [message]
            speaker=unit
            message= _ "Aaargh!! It’s pointless! (spits) Killing me won’t do anything to weaken our forces! We are unstoppable!"
        [/message]
    [/event]

    #
    # Spawn more foes every turn unless the Warlord, Laveri, or other spawned
    # foes are around.
    #
    [event]
        name=new turn
        first_time_only=no
        [filter_condition]
            [not]
                [have_unit]
                    id=Laveri
                    [or]
                        side=2,5
                    [/or]
                [/have_unit]
            [/not]
        [/filter_condition]

        [set_variables]
            name=survival_spawn_regions
            mode=replace
            [literal]
                # West
                x=1
                y=9-14
            [/literal]
            [literal]
                # North
                x=29-43
                y=1
            [/literal]
            [literal]
                # South
                x=13-20,22
                y=40   ,40
            [/literal]
        [/set_variables]

        [foreach]
            array=survival_spawn_regions
            variable=survival_spawn_region
            [do]
                {VARIABLE_RANDOM rcount {DIFF 1..4 3..7 5..9} }

                [repeat]
                    times=$rcount
                    [do]
                        {VARIABLE_RANDOM rtype ("Imp,Blood Imp,Chaos Hound,Shaxthal Assault Drone,Demon,Demon Zephyr,Shaxthal Runner Drone,Chaos Headhunter,Demon Grunt,Shaxthal Protector Drone")}

                        [store_locations]
                            variable=spawn_locs
                            x=$survival_spawn_region.x
                            y=$survival_spawn_region.y
                            [not]
                                terrain=X*,*^X*,Q*
                            [/not]
                        [/store_locations]

                        {VARIABLE_RANDOM rloc "0..$($spawn_locs.length - 1)"}

                        [store_direction]
                            from_x,from_y=$spawn_locs[$rloc].x,$spawn_locs[$rloc].y
                            [to]
                                [filter]
                                    id=Anlindë
                                [/filter]
                            [/to]
                        [/store_direction]

                        [unit]
                            side=5
                            type=$rtype
                            x,y=$spawn_locs[$rloc].x,$spawn_locs[$rloc].y
                            facing=$direction
                            passable=yes
                            generate_name=yes
                            random_traits=yes
                            random_gender=yes
                        [/unit]

                        {CLEAR_VARIABLE spawn_locs,rtype,rloc,direction}
                    [/do]
                [/repeat]

                {CLEAR_VARIABLE rcount}
            [/do]
        [/foreach]

        {CLEAR_VARIABLE survival_spawn_regions}
    [/event]

    [event]
        name=time over

        [fire_event]
            name=warlord incoming
        [/fire_event]
    [/event]

    [event]
        name=warlord incoming

        {LOCK_VIEW}

        [sound]
            name=fuse.ogg
        [/sound]

        [delay]
            time=2750
        [/delay]

        [unit]
            side=4
            type=Shaxthal Sentry Drone
            variation=surface
            x,y=14,22
            random_traits=yes
            facing=ne
        [/unit]

        [unit]
            side=4
            type=Shaxthal Sentry Drone
            variation=surface
            x,y=14,20
            random_traits=yes
            facing=se
        [/unit]

        [hide_unit][/hide_unit]

        {WHITE_SCREEN}

        [redraw][/redraw]

        [scroll_to]
            x,y=15,21
            {WARP}
        [/scroll_to]

        [sound]
            name=explosion.ogg
        [/sound]

        [delay]
            time=250
        [/delay]

        [terrain_mask]
            {MASK 13_Face_your_Fate.mask}
            x,y=13,19
        [/terrain_mask]

        [remove_shroud]
            side=1
        [/remove_shroud]

        [sound]
            name=explosion.ogg
        [/sound]

        {RESET_SCREEN}

        [unhide_unit][/unhide_unit]

        [redraw][/redraw]

        {QUAKE rumble.ogg}

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Anlindë
            message= _ "Great. Nobody informed me that there was another alternate entrance to this chamber in the west. We ought to seal that somehow."
        [/message]

        [modify_turns]
            value=-1
        [/modify_turns]

        {UNLOCK_VIEW}

        [event]
            delayed_variable_substitution=no
            name="turn $($turn_number + 1)"

            [fire_event]
                name=warlord arrival
            [/fire_event]
        [/event]
    [/event]

    [event]
        name=warlord arrival

        {LOCK_VIEW}

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

        [unit]
            side=2
            type=Chaos Warlord
            id=Chaos Warlord
            name= _ "Chaos Warlord"
            placement=leader
            {IS_BOSS}
            unrenamable=yes
            facing=se
            [modifications]
                {TRAIT_BIOMECHANICAL}
                {TRAIT_INTELLIGENT}
            [/modifications]
        [/unit]

        {GENERIC_UNIT 2 (Goliath)                  () ()} {PLACEMENT leader} {PASSABLE} {FACING se}
        {GENERIC_UNIT 2 (Goliath)                  () ()} {PLACEMENT leader} {PASSABLE} {FACING se}
        {GENERIC_UNIT 2 (Shaxthal Protector Drone) () ()} {PLACEMENT leader} {PASSABLE} {FACING se} {VARIATION surface}

        [hide_unit][/hide_unit]

        {WHITE_SCREEN}

        [scroll_to]
            [filter]
                id=Chaos Warlord
            [/filter]
            {WARP}
        [/scroll_to]

        [delay]
            time=250
        [/delay]

        [sound]
            name=thunderstick.ogg
        [/sound]

        [modify_side]
            side=1
            shroud=no
        [/modify_side]

        {DISALLOW_RECRUIT 1 "Dwarvish Ulfserker"}

        {RESET_SCREEN}

        [unhide_unit][/unhide_unit]

        {BOSS_AMBIENTANCE}

        [redraw][/redraw]

        {QUAKE rumble.ogg}

        [sound]
            name=dwarf-laugh.wav
        [/sound]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Anlindë
            message= _ "Their commander, at last! Come and fight me, fiend! This place shall be your grave!"
        [/message]

        [message]
            speaker=Chaos Warlord
            message= _ "(muffled metallic voice) You should do like your friends and run away, little worm, unless you would prefer me to tear your frail body to pieces and delight in your suffering."
        [/message]

        [message]
            speaker=Chaos Warlord
            message= _ "Trying to divert my attention is futile. I already know where your friends are; it is all in your weak and permeable mind. Your pointless sacrifice does not fool our Master either, and neither will it save the cowards from his wrath. We’ll find them all in due time."
        [/message]

        [message]
            speaker=Anlindë
            message= _ "Not if I can stop you first!"
        [/message]

        {UNLOCK_VIEW}

        {OBJECTIVES (
            {HEADER_FINAL_OBJECTIVES}

            {OBJECTIVE_VICTORY ( _ "Vanquish the Chaos Warlord")}

            {OBJECTIVE_NO_CARRYOVER}
        )}
    [/event]

    #
    # The Chaos Warlord cannot be killed.
    #
    [event]
        name=last breath
        first_time_only=no
        [filter]
            id=Chaos Warlord
        [/filter]

        [fire_event]
            name=boss regeneration
            [primary_unit]
                x,y=$x1,$y1
            [/primary_unit]
            [secondary_unit]
                x,y=$x2,$y2
            [/secondary_unit]
        [/fire_event]
    [/event]

    [event]
        name=boss regeneration
        first_time_only=no

        {VARIABLE unit.hitpoints $unit.max_hitpoints}

        # Deduct the killing XP from the attacker, otherwise it is possible
        # for them to advance very quickly from L1 to their maximum advancement.
        # Things get even messier once the full health AMLA effect kicks in.
        # Just give them regular attack XP instead.

        {LOG_IFTU_DBG "warlord is dying, deducting attacker's XP"}
        {LOG_IFTU_DBG "  before: $second_unit.experience/$second_unit.max_experience"}

        {VARIABLE_MIN second_unit.experience "$(max([4, 8 * $unit.level]) - $unit.level)"}

        {LOG_IFTU_DBG "  after: $second_unit.experience/$second_unit.max_experience"}

        [unstore_unit]
            variable=unit
            find_vacant=no
        [/unstore_unit]

        [unstore_unit]
            variable=second_unit
            find_vacant=no
        [/unstore_unit]
    [/event]

    #
    # Dialogue only first time the Warlord regenerates.
    #
    [event]
        name=boss regeneration

        [message]
            speaker=Chaos Warlord
            message= _ "You will never succeed in slaying me with such pitiful weapons and spells."
        [/message]

        [message]
            speaker=Chaos Warlord
            message= _ "By the power you have bestowed upon me, Uria, may the spells conferring life to the dead be canceled now!"
        [/message]

        {THUNDER (
            [kill]
                side=1
                race=undead
                animate=yes
            [/kill]
        )}

        {DISALLOW_RECRUIT 1 "Walking Corpse,Skeleton,Skeleton Archer"}
    [/event]

#define FYF_EVENT_BEFORE_BOSS_ARRIVAL
    [filter_condition]
        [not]
            [have_unit]
                id=Chaos Warlord
            [/have_unit]
        [/not]
    [/filter_condition]
#enddef

#define FYF_EVENT_PAST_BOSS_ARRIVAL
    [filter_condition]
        [have_unit]
            id=Chaos Warlord
        [/have_unit]
    [/filter_condition]
#enddef

    #
    # Handle Anlindë's death before the Warlord's arrival.
    #
    [event]
        name=last breath
        [filter]
            id=Anlindë
        [/filter]
        {FYF_EVENT_BEFORE_BOSS_ARRIVAL}

        [message]
            speaker=unit
            message= _ "I am... sorry, Galas... I... failed..."
        [/message]
    [/event]

    [event]
        name=die
        [filter]
            id=Anlindë
        [/filter]
        {FYF_EVENT_BEFORE_BOSS_ARRIVAL}

        {ENDLEVEL_DEFEAT}
    [/event]

    [event]
        name=die
        [filter]
            id=Anlindë
        [/filter]
        {FYF_EVENT_PAST_BOSS_ARRIVAL}

        {LOCK_VIEW}

        {CLEAR_LABELS}

        {VARIABLE x $x1}
        {VARIABLE y $y1}

        [kill]
            id=Anlindë
        [/kill]

        # wmllint can't tell it's not the same Anlindë.
        # wmllint: deathcheck off

        [unit]
            id=Anlindë
            name= _ "Anlindë"
            type=Anlinde Dead
            side=1
            x,y=$x,$y
            hitpoints=1
        [/unit]

        [message]
            speaker=Chaos Warlord
            message= _ "You still draw breath? This is an infuriating waste of my time."
        [/message]

        [message]
            speaker=Anlindë
            message= _ "... Heh."
        [/message]

        {QUAKE cave-in.ogg}

        [message]
            speaker=Chaos Warlord
            message= _ "What is this?!"
        [/message]

        {QUAKE rumble.ogg}

        {QUAKE cave-in.ogg}

        [message]
            speaker=Anlindë
            message= _ "I’m not... leaving this world... without taking you with me..."
        [/message]

        [message]
            race=demon,imps
            message= _ "Aiyeee!! Retreat, retreat!!" # wmllint: no spellcheck
        [/message]

        {QUAKE rumble.ogg}

        {QUAKE cave-in.ogg}

        [message]
            speaker=Chaos Warlord
            message= _ "Do you truly believe it will be all over just like this? How naïve of someone like you, a past servant of Zhangor."
        [/message]

        [message]
            speaker=Anlindë
            message= _ "Death will take us all now... None of that matters anymore."
        [/message]

        {QUAKE rumble.ogg}

        [kill]
            [filter_location]
                x,y=$x,$y
                radius=8
            [/filter_location]
            [not]
                id=Chaos Warlord
            [/not]
            animate=yes
            fire_event=no
        [/kill]

        {CLEAR_VARIABLE x,y}

        {QUAKE rumble.ogg}

        {REMOVE_SOUND_SOURCE cave_ambience}

        [kill][/kill]

        [remove_item][/remove_item]

        [terrain]
            terrain=Xv
        [/terrain]

        [place_shroud]
            side=1
        [/place_shroud]

        [redraw][/redraw]

        {QUAKE dragonstick.ogg}

        [fade_out_music]
            duration=2000
        [/fade_out_music]

        {UNLOCK_VIEW}

        {ENDLEVEL_QUIET}

        # wmllint: deathcheck on
    [/event]

    [event]
        name=victory

        #
        # Get rid of side 1 units if they are still around (e.g., :debug :n).
        #

        [kill]
            side=1
        [/kill]

        #
        # Grant side 1 control back to Galas.
        #

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

        [unstore_unit]
            variable=galas_eoe1_state
            x,y=recall,recall
        [/unstore_unit]

        [modify_side]
            side=1
            gold=0
        [/modify_side]

        {CLEAR_VARIABLE galas_eoe1_state,galas_eoe1_recall_list}
    [/event]
[/scenario]

#undef FYF_DRONE
#undef FYF_EVENT_BEFORE_BOSS_ARRIVAL
#undef FYF_EVENT_PAST_BOSS_ARRIVAL

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-Invasion_from_the_Unknown

[scenario]
    id=14x_The_Aragwaithi
    name= _ "The Grand Council"
    {MAP 14x_Raelthyn.map}
    turns=-1
    next_scenario=14y_The_Grand_Council
    victory_when_enemies_defeated=no

    {FULLSCREEN_CUTSCENE_UI}

    {SCENARIO_MUSIC "knolls.ogg"}

    {MIDDAY1}

    {STORYTXT_THE_ARAGWAITHI}

    # wmllint: validate-off
    [side]
        side=1
        controller=human
        team_name=heroes
        user_team_name= _ "team_name^Elves"

        {NO_ECONOMY}

        # wmllint: recognize Galas
        {CHARACTER_STATS_GALAS}
    [/side]

    [side]
        side=2
        team_name=heroes
        user_team_name= _ "team_name^Central Garrison"
        {ARAGWAITH_FLAG}

        {NO_ECONOMY}

        canrecruit=yes
        # wmllint: recognize De'Arthian
        {CHARACTER_STATS_DE_ARTHIAN}
        facing=sw

        [unit]
            type=Aragwaith Swordsman
            x,y=11,19
            generate_name=yes
        [/unit]
        [unit]
            type=Aragwaith Swordsman
            x,y=9,14
            generate_name=yes
        [/unit]
        [unit]
            type=Aragwaith Guardian
            x,y=19,15
            generate_name=yes
        [/unit]
        [unit]
            type=Aragwaith Flagbearer
            x,y=16,19
            generate_name=yes
        [/unit]
        [unit]
            type=Aragwaith Guard
            x,y=13,27
            generate_name=yes
        [/unit]
        [unit]
            type=Aragwaith Guard
            x,y=17,12
            generate_name=yes
        [/unit]
        [unit]
            type=Aragwaith Guardian
            x,y=14,9
            generate_name=yes
        [/unit]
        [unit]
            type=Aragwaith Guardian
            x,y=22,20
            generate_name=yes
        [/unit]
    [/side]
    # wmllint: validate-on

    [side]
        side=3
        team_name=heroes
        user_team_name= _ "team_name^Elves"
        {ALLIANCE_FLAG}
        color=teal

        no_leader=yes
        {NO_ECONOMY}
    [/side]

    [side]
        side=4
        team_name=heroes
        user_team_name= _ "team_name^City Guard"
        {ARAGWAITH_FLAG}

        {NO_ECONOMY}

        canrecruit=yes
        type=Aragwaith Pikeman
        id=Quor
        name= _ "Quor"

        [unit]
            type=Aragwaith Longswordsman
            x,y=4,19
            id=Cain
            name= _ "Cain"
        [/unit]
        [unit]
            type=Aragwaith Pikeman
            x,y=4,21
            generate_name=yes
        [/unit]
        [unit]
            type=Aragwaith Longswordsman
            x,y=2,23
            generate_name=yes
        [/unit]
        [unit]
            type=Aragwaith Strongbow
            x,y=7,17
            generate_name=yes
        [/unit]
        [unit]
            type=Aragwaith Slayer
            x,y=6,14
            generate_name=yes
        [/unit]
        [unit]
            type=Aragwaith Shield Guard
            x,y=1,10
            generate_name=yes
        [/unit]
        [unit]
            type=Aragwaith Shield Guard
            x,y=2,13
            generate_name=yes
        [/unit]
        [unit]
            type=Aragwaith Captain
            x,y=4,26
            generate_name=yes
        [/unit]
        [unit]
            type=Aragwaith Strongbow
            x,y=4,29
            generate_name=yes
        [/unit]
        [unit]
            type=Aragwaith Strongbow
            x,y=7,29
            generate_name=yes
        [/unit]
        [unit]
            type=Aragwaith Greatbow
            x,y=9,29
            generate_name=yes
        [/unit]
        [unit]
            type=Aragwaith Pikeman
            x,y=12,29
            generate_name=yes
        [/unit]
        [unit]
            type=Aragwaith Swordsman
            x,y=16,29
            generate_name=yes
        [/unit]
        [unit]
            type=Aragwaith Flagbearer
            x,y=19,28
            generate_name=yes
        [/unit]
        [unit]
            type=Aragwaith Captain
            x,y=22,24
            generate_name=yes
        [/unit]
        [unit]
            type=Aragwaith Archer
            x,y=26,22
            generate_name=yes
        [/unit]
        [unit]
            type=Aragwaith Spearman
            x,y=2,2
            generate_name=yes
        [/unit]
        [unit]
            type=Aragwaith Pikeman
            x,y=5,3
            generate_name=yes
        [/unit]
        [unit]
            type=Aragwaith Guard
            x,y=9,3
            generate_name=yes
        [/unit]
        [unit]
            type=Aragwaith Swordsman
            x,y=17,3
            generate_name=yes
        [/unit]
        [unit]
            type=Aragwaith Flagbearer
            x,y=22,3
            generate_name=yes
        [/unit]
    [/side]

    {STARTING_VILLAGES_ALL 2}

    [label]
        x,y=33,4
        text= _ "Arphalad"
    [/label]

    [label]
        x,y=29,9
        text= _ "River Lorin"
    [/label]

    [label]
        x,y=17,26
        text= _ "Lake Wylven"
    [/label]

    [label]
        x,y=13,16
        text= _ "Adavyan’s Keep"
    [/label]

    [label]
        x,y=5,11
        text= _ "Danaerad"
    [/label]

    [label]
        x,y=23,6
        text= _ "Tower of Silence"
    [/label]

    {PLACE_IMAGE scenery/leanto.png              5  5}
    {PLACE_IMAGE scenery/temple1.png            10  7}
    {PLACE_IMAGE scenery/oak-leaning.png        18 17}
    {PLACE_IMAGE scenery/oak-leaning.png        18  8}
    {PLACE_IMAGE scenery/oak-leaning.png        10  8}
    {PLACE_IMAGE items/archery-target-right.png  3 10}
    {PLACE_IMAGE items/archery-target-right.png 13 14}

    {PLACE_IMAGE scenery/temple1.png            30  1}
    {PLACE_IMAGE items/straw-bale1.png          37  4}
    {PLACE_IMAGE items/straw-bale2.png          35 22}
    {PLACE_IMAGE items/grain-sheaf.png          38 30}
    {PLACE_IMAGE items/straw-bale1.png          31 34}
    {PLACE_IMAGE items/straw-bale1.png          39 22}

    [event]
        name=prestart

        [store_unit]
            [filter]
                id=Galas
            [/filter]
            kill=yes
            variable=galas_store
        [/store_unit]

        # wmllint: recognize Erathan
        {RECALL_ERATHAN_AT $galas_store.x $galas_store.y}

        {LOCK_VIEW}
    [/event]

    [event]
        name=start

        {MOVE_UNIT id=Erathan 3 19}

        [unstore_unit]
            variable=galas_store
        [/unstore_unit]

        {CLEAR_VARIABLE galas_store}

        {MOVE_UNIT id=Galas   2 19}

        # wmllint: recognize Elynia
        {RECALL_ELYNIA_AT      1 20}
        # wmllint: recognize Mal Keshar
        {RECALL_MAL_KESHAR_AT  2 20}

        [message]
            speaker=Erathan
            message= _ "Behold! Our capital city, Raelthyn."
        [/message]

        [message]
            speaker=Galas
            message= _ "It certainly is an impressive and beautiful city. So, where are we going?"
        [/message]

        [message]
            speaker=Erathan
            message= _ "The members of the Council gather in Adavyan’s Keep, the fortress at the heart of the city. They will be waiting for lord Galas, but I don’t think they’ll let the faerie and the necromancer in. So, they should wait here while we—"
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "That is not up for you to decide, whelp. We are coming with him."
        [/message]

        [message]
            speaker=Erathan
            message= _ "Hey!"
        [/message]

        [message]
            speaker=Quor
            message= _ "Hold on! Who goes there?"
        [/message]

        [message]
            speaker=Erathan
            message= _ "It is I, Erathan. I bring the elves’ leader with me for a meeting with the Council."
        [/message]

        [message]
            speaker=Cain
            message= _ "It’s a faerie! And... a lich!? Seize them!"
        [/message]

        [message]
            speaker=Erathan
            message= _ "No! The lich is their servant! He’s perfectly safe, don’t worry about it. Just—"
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "<b>I AM NOT THEIR SERVANT!</b>"
        [/message]

        [message]
            speaker=Cain
            message= _ "Alert the central garrison! We need reinforcements!"
        [/message]

        [message]
            speaker=Elynia
            message= _ "What are you doing?!"
        [/message]

        [delay]
            time=750
        [/delay]

        [unit]
            # wmllint: recognize Inodien
            {CHARACTER_STATS_INODIEN}
            ellipse,overlays="",""
            side=3
            x,y=7,19
            facing=ne
            canrecruit=yes
            animate=yes
        [/unit]

        {MOVE_UNIT id=Inodien  5 18}

        [message]
            speaker=Inodien
            message= _ "Lord Galas! We were worried about you. Is that... Oh, Bright Gods, is that... the Lady of Light? So you actually did it! We— What are these people doing? Release the lich and the Lady, you fools! They are our allies!"
        [/message]

        [message]
            speaker=Cain
            message= _ "Oh... Oh! Apologies sirs, please don’t tell the captain about this incident! Or anyone else, really."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Hmph."
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "You lowly fools ought to be thankful that we both have a compassionate disposition towards lesser beings like you, or you’d be begging us to spare your useless lives—"
        [/message]

        [message]
            speaker=Galas
            message= _ "That’s quite enough, Mal Keshar. Inodien, do you think the Grand Council could allow Mal Keshar and Lady Elynia’s presence? I would rather have them by my side if we are to discuss the present state of affairs with the northerners."
        [/message]

        [message]
            speaker=Inodien
            message= _ "Yes, I am absolutely certain they will, lord Galas. They have expressed an interest in seeing her — she’s quite a legend around here amongst the more educated Aragwaith leaders, it seems. Follow me."
        [/message]

        {ENDLEVEL_QUIET} {NO_START_OF_SCENARIO_SAVE} {NO_REPLAY_SAVE}
    [/event]
[/scenario]

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-Invasion_from_the_Unknown

[scenario]
    id=14y_The_Grand_Council
    name= _ "The Grand Council"
    {MAP 14y_The_Grand_Council.map}
    turns=-1
    next_scenario=15_Shadows_of_Time

    {FULLSCREEN_CUTSCENE_UI}

    {SCENARIO_MUSIC "underground.ogg"}

    {INDOORS}

    # wmllint: validate-off
    [side]
        side=1
        controller=human
        team_name=heroes
        user_team_name= _ "team_name^Elves"

        {NO_ECONOMY}

        # wmllint: recognize Galas
        {CHARACTER_STATS_GALAS}
    [/side]

    [side]
        side=2
        team_name=heroes
        {ARAGWAITH_FLAG}
        color=blue

        {NO_ECONOMY}

        canrecruit=yes
        # wmllint: recognize De'Arthian
        {CHARACTER_STATS_DE_ARTHIAN}
    [/side]

    [side]
        side=3
        team_name=heroes
        {ALLIANCE_FLAG}
        color=teal

        {NO_ECONOMY}

        canrecruit=yes
        # wmllint: recognize Inodien
        {CHARACTER_STATS_INODIEN}
        ellipse,overlays="",""
    [/side]

    [side]
        side=4
        team_name=heroes
        {ARAGWAITH_FLAG}
        color=purple

        {NO_ECONOMY}

        canrecruit=yes
        # wmllint: recognize Illana
        {CHARACTER_STATS_ILLANA}
    [/side]

    [side]
        side=5
        team_name=heroes
        {ARAGWAITH_FLAG}
        color=black

        {NO_ECONOMY}

        canrecruit=yes
        # wmllint: recognize Arnesius
        {CHARACTER_STATS_ARNESIUS}
    [/side]

    [side]
        side=6
        team_name=heroes
        {ARAGWAITH_FLAG}
        color=brown

        {NO_ECONOMY}

        canrecruit=yes
        # wmllint: recognize Delarel
        {CHARACTER_STATS_DELAREL}
    [/side]

    [side]
        side=7
        team_name=heroes
        {ARAGWAITH_FLAG}
        color=orange

        {NO_ECONOMY}

        canrecruit=yes
        # wmllint: recognize Torancyn
        {CHARACTER_STATS_TORANCYN}
    [/side]

    [side]
        side=8
        team_name=heroes
        {ARAGWAITH_FLAG}
        color=white

        {NO_ECONOMY}

        canrecruit=yes
        # wmllint: recognize Aleazar
        {CHARACTER_STATS_ALEAZAR}
    [/side]
    # wmllint: validate-on

    [event]
        name=prestart

        # wmllint: recognize Elynia
        {RECALL_ELYNIA_AT      9  8}
        # wmllint: recognize Mal Keshar
        {RECALL_MAL_KESHAR_AT  9  6}
        # wmllint: recognize Erathan
        {RECALL_ERATHAN_AT     8  7}
        # wmllint: recognize Unarye
        {RECALL_UNARYE_AT      8  6}

        {FACE_LOCATION () x,y=12,7}

        {LOCK_VIEW}
    [/event]

#define TGC_SET_VUNIT_LOCATION_FACING _VAR _X _Y _FACING
    [set_variables]
        name={_VAR}
        mode=merge
        [value]
            x={_X}
            y={_Y}
            facing={_FACING}
        [/value]
    [/set_variables]
#enddef

    [event]
        name=start

        [fire_event]
            name=scene 1
        [/fire_event]

        [fire_event]
            name=scene 2
        [/fire_event]

        {ENDLEVEL_QUIET} {NO_REPLAY_SAVE}
    [/event]

    [event]
        name=scene 1

        [message]
            speaker="De'Arthian"
            message= _ "Welcome, Lord Galas, to the Grand Council. We must say, we feel greatly honored by your presence here, in the Grand Council Chamber. To think that the forest elves managed to survive and thrive in the middle of the southeastern desert! It is truly a disgrace that we did not find out about your community before. All these blood and tears could have been avoided had we gone searching for civilizations hiding amidst the cruel sands."
        [/message]

        [message]
            speaker=Galas
            message= _ "Thank you for your hospitality, my lord. It’s our pleasure to meet such a fine people as well."
        [/message]

        [message]
            speaker=Torancyn
            message= _ "So, Lord Inodien came to us with the bulk of your... not very impressive army, and he also brought your civilians. He has asked us for shelter since your people lost their home in your war against the Chaos Empire."
        [/message]

        [message]
            speaker=Galas
            message= _ "Pardon me, sir, but it is not a war! Our home and most of our forces fell victim to a large-scale invasion by the Chaos Empire started with no provocation whatsoever. We were completely unaware of their existence until their troops set foot in our lands."
        [/message]

        [message]
            speaker=Torancyn
            message= _ "And then your people hid underground, and found this pet lich of yours who is — for some unfathomable reason — allowed to walk around freely rather than punished for his crimes against nature. Who allowed him into the council chamber anyway?"
        [/message]

        [message]
            speaker=Arnesius
            message= _ "I did, and we have already discussed this before — countless times, I must add. Mal Keshar and the Lady of Light shall be considered our friends for as long as the elves treat them as such."
        [/message]

        [message]
            speaker=Torancyn
            message= _ "... Very well, then."
        [/message]

        [message]
            speaker=Mal Keshar
            message={ASIDE ( _ "They seem awfully prone to lumping you together with me on the undesirables list. How do you feel about this turn of events, Elynia?")}
        [/message]

        [message]
            speaker=Elynia
            message={ASIDE ( _ "I am not particularly impressed, but at least you seem delighted by the irony.")}
        [/message]

        [message]
            speaker=Illana
            message= _ "Say, Lord Galas, Lady of Light, and I ask this on a purely hypothetical basis: What possible benefit would allowing your people to settle lands within our borders give us? Why should we cede resources that could be put to better use serving our people?"
        [/message]

        [message]
            speaker=Galas
            message= _ "That is an excellent question, my lady. So, allow me to ask: for how long have you been struggling against the Chaos Empire’s advances into the northern lands? Your messenger Erathan made it sound like you’ve been aware of them for quite a while."
        [/message]

        [message]
            speaker=Aleazar
            message= _ "We had dealt non-violently with them for years before they decided to cease all trading and communication with us. Still, they have not proven to be an actual threat thus far, beyond a few occasional skirmishes in Glamdrol. The dwarf kingdoms of Valgran and Herthgar shield us from potential attacks coming from the Heart Mountains, and the southeastern desert is an effective natural barrier against invaders."
        [/message]

        [message]
            speaker=Galas
            message= _ "Herthgar fell just a week ago, and the enemy is now recruiting orcish mercenaries to their cause. How long do you think it will take them to penetrate the Aragwaith country? Adopting a defensive stance and hoping for the best is exactly what resulted in Herthgar’s doom."
        [/message]

        [message]
            speaker="De'Arthian"
            message= _ "And your proposal is...?"
        [/message]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Elynia
            message={ASIDE ( _ "Galas, what are you planning to do?")}
        [/message]

        [message]
            speaker=Galas
            message= _ "My proposal is as follows: we shall pledge allegiance to the Grand Council as long as our people are granted lands to live in the Aragwaith country; furthermore, we shall officially declare war against the Chaos Empire, and we expect you to do likewise. We intend to cooperate fully with the war efforts, placing our army at your disposal."
        [/message]

        [message]
            speaker=Inodien
            message={ASIDE ( _ "Wait... what?!")}
        [/message]

        [message]
            speaker=Unarye
            message={ASIDE ( _ "My lord, you can’t decide this on your own without asking the other lords!")}
        [/message]

        [message]
            speaker=Mal Keshar
            message={ASIDE ( _ "He, he, he. Good plan, boy.")}
        [/message]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Torancyn
            message= _ "That is quite a bold proposal, elf lord. However, if the enemy is as strong as it’s been rumored, can we really expect to win a war against them with our combined forces alone?"
        [/message]

        [message]
            speaker=Illana
            message= _ "Even if the Chaos Empire is already trying to undermine the Far North’s political stability by enlisting orcs, we might still be able to turn the majority of them to our side if we play our cards cautiously. The western clans might agree to join us in alliance if we give them something in exchange... such as some of the Empire-controlled lands."
        [/message]

        [message]
            speaker=Mal Keshar
            message={ASIDE ( _ "Then by extension, we would be allying ourselves with the orcs too! This must be some sort of joke! Galas, you would not agree to such a thing... Right?")}
        [/message]

        [message]
            speaker=Elynia
            message={ASIDE ( _ "Quiet, you. This is no time to let personal grudges guide our decisions.")}
        [/message]

        [message]
            speaker=Torancyn
            message= _ "That might actually work... We can keep the fertile areas and hand them barren wastelands to keep them content."
        [/message]

        [message]
            speaker=Mal Keshar
            message={ASIDE ( _ "You say that, but it is perfectly evident to anyone with a drop of sense that he wants to avenge his mentor... friend... whatever the accursed priestess was.")}
        [/message]

        [message]
            speaker=Illana
            message= _ "We can and should work out the details later."
        [/message]

        [message]
            speaker=Elynia
            message={ASIDE ( _ "Malin Keshar, please, I am trying to pay attention. Could you keep quiet for a minute? We can discuss this later.")}
        [/message]

        [message]
            speaker=Arnesius
            message= _ "Lord Galas, perhaps you would prefer to take some time to consider the proposal. Once we officially sign the pact, there will be no going back for us or your people. Nonetheless, I would like to put forth a clause of our own."
        [/message]

        [message]
            speaker=Mal Keshar
            message={ASIDE ( _ "Hmph. As you wish.")}
        [/message]

        [message]
            speaker=Galas
            message= _ "Sure."
        [/message]

        [message]
            speaker=Arnesius
            message= _ "We want the Lady of Light, and the lich Mal Keshar and all necromancers under his control to pledge unconditional allegiance to the Grand Council of the Northern Peoples. This also means that their actions will be governed by the Council rather than the elves’ leadership."
        [/message]

        [message]
            speaker=Elynia
            message={ASIDE ( _ "Wait, what! Galas you can’t do this! Galas!")}
        [/message]

        [message]
            speaker=Galas
            message= _ "I am sure they will accede. My condition is that their safety be guaranteed at all times, as this was also Mal Keshar’s condition for assisting us on the way to Herthgar. And if I must participate in field missions, I shall be allowed to have them by my side as I deem necessary or convenient."
        [/message]

        [message]
            speaker=Elynia
            message={ASIDE ( _ "Galas! I object to this! Galas!")}
        [/message]

        [message]
            speaker=Mal Keshar
            message={ASIDE ( _ "I should have killed this kid when I had the opportunity, back in those caves.")}
        [/message]

        [message]
            speaker=Aleazar
            message= _ "Very well, then. This has been a pleasantly productive discussion, everyone. We shall give Lord Galas one week to make his decision. But... it would be highly beneficial for us to strike a deal with the orcs first, as time is of the essence and we need to secure their support before the Chaos Empire does."
        [/message]

        [message]
            speaker=Torancyn
            message= _ "I say we assign Lord Galas the task of negotiating with the orcs. May this serve to the Council as proof of his commitment and loyalty."
        [/message]

        [message]
            speaker=Illana
            message= _ "Agreed."
        [/message]

        [message]
            speaker="De'Arthian"
            message= _ "Agreed."
        [/message]

        [message]
            speaker=Arnesius
            message= _ "(sighs) Agreed."
        [/message]

        [message]
            speaker=Aleazar
            message= _ "Agreed!"
        [/message]

        [message]
            speaker=Mal Keshar
            message={ASIDE ( _ "Galas, I hate you sooo much right now.")}
        [/message]
    [/event]

    [event]
        name=scene 2

        #
        # Begin scene transition.
        #

        [kill]
            [not]
                side=1
            [/not]
            [or]
                id=Unarye,Erathan
            [/or]
        [/kill]

        [store_unit]
            [filter]
                id=Galas
            [/filter]
            kill=yes
            variable=galas_store
        [/store_unit]

        [store_unit]
            [filter]
                id=Elynia
            [/filter]
            kill=yes
            variable=elynia_store
        [/store_unit]

        [store_unit]
            [filter]
                id=Mal Keshar
            [/filter]
            kill=yes
            variable=malin_store
        [/store_unit]

        {FADE_TO_BLACK}

        [modify_side]
            side=1
            shroud=yes
        [/modify_side]

        [place_shroud]
            side=1
        [/place_shroud]

        [redraw][/redraw]

        [replace_map]
            map="{LD /maps/14z_Garden.map}"
            expand,shrink=yes,yes
        [/replace_map]

        [delay]
            time=2000
        [/delay]

        [modify_side]
            side=1
            shroud=no
        [/modify_side]

        [redraw][/redraw]

        {TGC_SET_VUNIT_LOCATION_FACING galas_store  23  8 ne}
        {TGC_SET_VUNIT_LOCATION_FACING elynia_store 22  9 ne}
        {TGC_SET_VUNIT_LOCATION_FACING malin_store  21  8 ne}

        [scroll_to]
            x,y=$galas_store.x,$galas_store.y
            {WARP}
        [/scroll_to]

        {FADE_IN}

        [unstore_unit]
            variable=galas_store
        [/unstore_unit]

        [unstore_unit]
            variable=elynia_store
        [/unstore_unit]

        [unstore_unit]
            variable=malin_store
        [/unstore_unit]

        {CLEAR_VARIABLE galas_store,elynia_store,malin_store}

        [redraw][/redraw]

        #
        # End scene transition.
        #

        [delay]
            time=1000
        [/delay]

        [message]
            speaker=Elynia
            message= _ "Galas, why are you doing this? First you decide to lead the elves to war without consulting with Lord Inodien and the others, then you treat me... us as mere possessions to barter for political favors! Have you lost your senses?!"
        [/message]

        [message]
            speaker=Galas
            message= _ "I am truly sorry, my la— Elynia, but..."
        [/message]

        [message]
            speaker=Elynia
            message= _ "I understand that you are intent on avenging Anlindë, but isn’t the safety of your people a more pressing matter right now? How can you... How can you do this to them after going through so much to escape from the followers of Uria!"
        [/message]

        [message]
            speaker=Galas
            message= _ "Elynia, do you really believe the Aragwaith country can withstand a full-scale invasion from the Empire if the dwarves couldn’t? Gnalvarden, Aidal, Herthgar, all their larger kingdoms have fallen over time. The Aragwaith don’t take the Empire’s threat seriously and only see this war as a convenient opportunity to keep their complacent troops entertained, as well as to deal with the orcs. They also expect us elves to do most of the work for them so they will have even fewer of us to accommodate in these lands."
        [/message]

        [message]
            speaker=Galas
            message= _ "My comrades, childhood friends, the lord who I served faithfully all these years... the woman who cared for me as if I were her own son... They are all dead. Why would I want to perpetuate this living hell, Elynia? Do you really believe the humans will be as charitable as to allow us to dwell in their territory without a steep price to pay? And, what will we do when the Chaos Emperor comes knocking on our door?"
        [/message]

        [message]
            speaker=Elynia
            message= _ "A war against the Empire could last for years, possibly decades... Our people..."
        [/message]

        [message]
            speaker=Galas
            message= _ "That is why we must figure out a way to put an end to this madness. Together."
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Wait, you are not thinking of..."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Taking the fight to their Emperor?"
        [/message]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Elynia
            message= _ "I cannot go with you, Galas. It has been far too long since I last participated in a mission like that... And I am far too weak from the amount of time I spent slumbering underground... And if it comes to that, I can’t summon the power of the Union again. Not without... Argan..."
        [/message]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Elynia
            message= _ "I cannot be the elves’ living weapon again. I am sorry, Galas."
        [/message]

        [delay]
            time=1500
        [/delay]

        {MOVE_UNIT id=Galas 22  8}

        {FACE_UNIT (id="Elynia,Mal Keshar") id=Galas}

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Galas
            message= _ "Fair enough. I will be taking Mal Keshar with me, anyway."
        [/message]

        {MOVE_UNIT id=Galas 20  9}

        {FACE_UNIT (id="Elynia,Mal Keshar") id=Galas}

        [message]
            speaker=Elynia
            message= _ "Who will lead the elves in your absence?"
        [/message]

        [message]
            speaker=Galas
            message= _ "Lord Inodien will replace me as the regent lord once we finish dealing with the orcs and humans. Don’t worry — I am sure you will make a fine advisor to him and Lady Unarye."
        [/message]

        {MOVE_UNIT id=Galas 17 11}

        {FACE_UNIT (id="Elynia,Mal Keshar") id=Galas}

        [message]
            speaker=Mal Keshar
            message= _ "It was not so long ago that he was but a meek kid who let the priestess make all decisions for him. Heh. He has truly become something, don’t you think?"
        [/message]

        [message]
            speaker=Elynia
            message= _ "Yes. And that’s exactly what troubles me."
        [/message]

        [hide_unit][/hide_unit]

        {FADE_TO_BLACK}

        [delay]
            time=750
        [/delay]
    [/event]
[/scenario]

#undef TGC_SET_VUNIT_LOCATION
#undef TGC_SET_VUNIT_LOCATION_FACING

# kate: indent-mode normal; encoding utf-8; space-indent on;