#textdomain wesnoth-Invasion_from_the_Unknown

[scenario]
    id=10_The_Source_of_Light
    name= _ "The Source of Light"
    {MAP 10_The_Source_of_Light.map}
    {TURNS 60 59 58}
    next_scenario=10x_Elynia
    victory_when_enemies_defeated=no

    #
    # TODO: the berserker potion is too hard to reach with elves
    #

    {SCENARIO_MUSIC "nunc_dimittis.ogg"}

    {DEEP_UNDERGROUND}

    [time_area]
        x=41-69,43-69,37-40,44-52,46-50,48,58-61,60,41-42
        y=38-44,45-61,56-59,   37,   36,35,   37,36,56-61
        {UNDERGROUND_VOLCANO_DEFAULT}
    [/time_area]

    {STORYTXT_THE_SOURCE_OF_LIGHT}

    {DEATHS_ACT_2_1}
    {DEATHS_DWARVES}

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

        shroud=yes

        {GOLD 200 180 170}
        {INCOME 5 4 3}

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

    # Chaos incursion remnants
    [side]
        side=2
        team_name=gaia
        user_team_name= _ "team_name^Chaos Empire"
        {CHAOS_FLAG}

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            #{AI_SIMPLE_ALWAYS_ASPECT leader_ignores_keep yes}
            {AI_SIMPLE_ALWAYS_ASPECT leader_aggression   1.0}
            {AI_SIMPLE_ALWAYS_ASPECT aggression          1.0}
            {AI_SIMPLE_ALWAYS_ASPECT village_value       0.0}
        [/ai]

        canrecruit=yes
        type=Demon Warrior
        id=Mena
        name= _ "Mena"
        gender=female
        ai_special=guardian
        experience=112
        [modifications]
            {TRAIT_DEXTROUS}
            {TRAIT_STRONG}
        [/modifications]

        {SIDE_GENERIC_GUARD ({DIFF (Iron Golem) Goliath Goliath}) 33 22}
        [+unit]
            experience=96
        [/unit]

        {SIDE_GENERIC_GUARD Automaton 35 23}
        {SIDE_GENERIC_GUARD Automaton 35 20}

        {SIDE_GENERIC_GUARD (Demon Grunt) 32 21}
        {SIDE_GENERIC_GUARD (Demon Grunt) 38 20}

        {SIDE_GENERIC_GUARD (Demon Zephyr) 33 24}
        {SIDE_GENERIC_GUARD (Demon Zephyr) 38 23}

        {SIDE_GENERIC_GUARD (Chaos Marauder) 34 23}
        {SIDE_GENERIC_GUARD (Chaos Magus)    36 23}
    [/side]

#ifdef HARD

#define TSOL_DZOMBIE
    Soulless
#enddef

#else

#define TSOL_DZOMBIE
    Walking Corpse
#enddef

#endif

    # Undead in NE tunnels and central chamber
    [side]
        side=3
        team_name=gaia
        user_team_name= _ "team_name^Cave Creatures"
        {RAGGED_FLAG}

        no_leader=yes
        hidden=yes

        recruit=Walking Corpse,Soulless,Vampire Bat,Ghost,Mudcrawler

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_SIMPLE_ALWAYS_ASPECT village_value                 0.40}
            {AI_SIMPLE_ALWAYS_ASPECT grouping                      defensive}
            {AI_SIMPLE_ALWAYS_ASPECT aggression                    0.80}
            {AI_SIMPLE_ALWAYS_ASPECT caution                       0.00}
        [/ai]

        # Roaming fossils in the central chamber
        {SIDE_GENERIC_GUARD Soulless 28 31} {VARIATION wose}
        {SIDE_GENERIC_GUARD Soulless 30 25} {VARIATION wose}
        {SIDE_GENERIC_GUARD Soulless 35 25} {VARIATION wose}
        {SIDE_GENERIC_GUARD Soulless 41 26} {VARIATION wose}
        {SIDE_GENERIC_GUARD Soulless 41 32} {VARIATION wose}
        {SIDE_GENERIC_GUARD Soulless 36 34} {VARIATION wose}

        {SIDE_GENERIC_GUARD {TSOL_DZOMBIE} 55 27} {VARIATION bat} {FACING se}
        {SIDE_GENERIC_GUARD {TSOL_DZOMBIE} 59 31} {VARIATION bat} {FACING se}
        {SIDE_GENERIC_GUARD {TSOL_DZOMBIE} 54 33} {VARIATION bat} {FACING nw}

        {SIDE_GENERIC_GUARD Soulless 56 28} {VARIATION troll}

        {SIDE_GENERIC_GUARD Soulless 66 33} {VARIATION bat}

        {SIDE_GENERIC_GUARD (Vampire Bat) 50 16}
        {SIDE_GENERIC_GUARD (Vampire Bat) 51 17}
        {SIDE_GENERIC_GUARD (Vampire Bat) 52 16}

        {SIDE_GENERIC_GUARD (Blood Bat) 67 18}

        {SIDE_GENERIC_GUARD (Revenant) 61 18} {FACING se}
        {SIDE_GENERIC_GUARD (Revenant) 64 20} {FACING nw}

        {SIDE_GENERIC_GUARD {DIFF Ghoul Ghoul Necrophage} 55 21} {FACING nw}

        {SIDE_GENERIC_GUARD (Vampire Bat) 22 59}
        {SIDE_GENERIC_GUARD (Vampire Bat) 30 57}
        {SIDE_GENERIC_GUARD (Vampire Bat)  6 59}
    [/side]

    {RECRUIT_UNIT_VARIATIONS 3 "Walking Corpse,Soulless" saurian}

    # Fire spirits in SE tunnels
    [side]
        side=4
        team_name=gaia
        user_team_name= _ "team_name^Cave Creatures"
        {RAGGED_FLAG}

        no_leader=yes
        hidden=yes

        recruit=Fire Wisp,Fire Guardian

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

        {SIDE_GENERIC_GUARD (Fire Guardian) 45 39}
        {SIDE_GENERIC_GUARD (Fire Guardian) 48 36}
        {SIDE_GENERIC_GUARD (Fire Guardian) 60 43}
        {SIDE_GENERIC_GUARD (Fire Guardian) 62 48}
        {SIDE_GENERIC_GUARD (Fire Guardian) 53 55}
        {SIDE_GENERIC_GUARD (Fire Guardian) 47 51}

        {SIDE_GENERIC_GUARD (Fire Wisp) 52 47}
        {SIDE_GENERIC_GUARD (Fire Wisp) 46 43}
        {SIDE_GENERIC_GUARD (Fire Wisp) 57 41}
        {SIDE_GENERIC_GUARD (Fire Wisp) 58 39}
        {SIDE_GENERIC_GUARD (Fire Wisp) 65 57}
        {SIDE_GENERIC_GUARD (Fire Wisp) 68 52}
    [/side]

    # Ghosts in SW tunnels
    [side]
        side=5
        team_name=gaia
        user_team_name= _ "team_name^Cave Creatures"
        {RAGGED_FLAG}

        no_leader=yes
        hidden=yes

        recruit=Ghost,Animated Rock,Mudcrawler,Walking Corpse,Giant Leech

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

        {SIDE_GENERIC_GUARD Wraith 11 49}
        {SIDE_GENERIC_GUARD Wraith 17 49}
#ifndef EASY
        {SIDE_GENERIC_GUARD Wraith 16 52}
#endif

        {SIDE_GENERIC_GUARD (Rock Golem)  9 45}
        {SIDE_GENERIC_GUARD (Rock Golem) 17 43}
        {SIDE_GENERIC_GUARD (Rock Golem) 13 39}
        {SIDE_GENERIC_GUARD (Rock Golem) 25 38}
        {SIDE_GENERIC_GUARD (Rock Golem) 32 45}
        {SIDE_GENERIC_GUARD (Rock Golem) 41 47}
    [/side]

    {RECRUIT_UNIT_VARIATIONS 5 "Walking Corpse" troll,saurian,drake}

    # Water spirits in NW tunnels
    [side]
        side=6
        team_name=gaia
        user_team_name= _ "team_name^Cave Creatures"
        {RAGGED_FLAG}

        no_leader=yes
        hidden=yes

        recruit=Water Tidal,Water Spirit,Walking Corpse,Mudcrawler,Water Serpent

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

        {SIDE_GENERIC_GUARD (Water Spirit) 17 31}
        {SIDE_GENERIC_GUARD (Water Spirit) 16 26}
        {SIDE_GENERIC_GUARD (Water Spirit) 13 30}
        {SIDE_GENERIC_GUARD (Water Spirit) 18 28}
        {SIDE_GENERIC_GUARD (Water Spirit) 21 22}

        {SIDE_GENERIC_GUARD (Water Serpent) 10 27}
        {SIDE_GENERIC_GUARD (Water Serpent)  8 31}
        {SIDE_GENERIC_GUARD (Water Serpent)  3 30}

        {SIDE_GENERIC_GUARD {TSOL_DZOMBIE} 19 25} {VARIATION swimmer}
        {SIDE_GENERIC_GUARD {TSOL_DZOMBIE} 19 21} {VARIATION swimmer}
        {SIDE_GENERIC_GUARD {TSOL_DZOMBIE} 20 31} {VARIATION swimmer}
        {SIDE_GENERIC_GUARD {TSOL_DZOMBIE} 22 20} {VARIATION swimmer}

        {SIDE_GENERIC_GUARD (Giant Mudcrawler) 15 21}
        {SIDE_GENERIC_GUARD (Giant Mudcrawler)  9 24}
        {SIDE_GENERIC_GUARD (Giant Mudcrawler) 13 25}
    [/side]

    {RECRUIT_UNIT_VARIATIONS 6 "Walking Corpse" swimmer,swimmer,bat}

    # Miscellaneous creatures
    [side]
        side=7
        team_name=gaia
        user_team_name= _ "team_name^Cave Creatures"
        {RAGGED_FLAG}

        no_leader=yes
        hidden=yes

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

        {SIDE_GENERIC_GUARD (Giant Spider) 24  6} {FACING se}
#ifndef EASY
        {SIDE_GENERIC_GUARD (Giant Spider) 16 12} {FACING sw}
#endif

        {SIDE_GENERIC_GUARD (Giant Ant) 10 21}
        {SIDE_GENERIC_GUARD (Giant Ant) 11 22}
        {SIDE_GENERIC_GUARD (Giant Ant) 10 22}

        {SIDE_GENERIC_GUARD (Giant Ant) 15 20}

        {SIDE_GENERIC_GUARD (Giant Ant) 27 20}
        {SIDE_GENERIC_GUARD (Giant Ant) 28 23}
        {SIDE_GENERIC_GUARD (Giant Ant) 21 33}
        {SIDE_GENERIC_GUARD (Giant Ant) 20 34}

        {SIDE_GENERIC_GUARD (Fungoid) 24 13}
        {SIDE_GENERIC_GUARD (Fungoid) 37  6}
        {SIDE_GENERIC_GUARD (Fungoid) 35  8}
        {SIDE_GENERIC_GUARD (Fungoid) 42  9}
        {SIDE_GENERIC_GUARD (Fungoid) 52 34}
        {SIDE_GENERIC_GUARD (Fungoid) 57 34}
        {SIDE_GENERIC_GUARD (Fungoid) 33 41}
        {SIDE_GENERIC_GUARD (Fungoid) 28 46}
        {SIDE_GENERIC_GUARD (Fungoid) 24 44}
        {SIDE_GENERIC_GUARD (Fungoid) 11 48}
        {SIDE_GENERIC_GUARD (Fungoid) 16 47}
        {SIDE_GENERIC_GUARD (Fungoid) 14 38}
        {SIDE_GENERIC_GUARD (Fungoid) 43 25}
        {SIDE_GENERIC_GUARD (Fungoid) 43 31}
        {SIDE_GENERIC_GUARD (Fungoid) 38 35}
        {SIDE_GENERIC_GUARD (Fungoid) 26 33}
        {SIDE_GENERIC_GUARD (Fungoid) 26 31}
        {SIDE_GENERIC_GUARD (Fungoid) 22 25}

        {SIDE_GENERIC_GUARD (Eyestalk) 21 41}
        {SIDE_GENERIC_GUARD (Eyestalk) 13 36}
        {SIDE_GENERIC_GUARD (Eyestalk) 18 13}

        {SIDE_GENERIC_GUARD (Leech) 13  6}
        {SIDE_GENERIC_GUARD (Leech) 37 12}
        {SIDE_GENERIC_GUARD (Leech) 52 31}
        {SIDE_GENERIC_GUARD (Leech) 32 43}
        {SIDE_GENERIC_GUARD (Leech) 12 58}
        {SIDE_GENERIC_GUARD (Leech)  2 26}
        {SIDE_GENERIC_GUARD (Leech)  1 25}

        {SIDE_GENERIC_GUARD (Giant Leech) 12  3}
        {SIDE_GENERIC_GUARD (Giant Leech)  7 14}
    [/side]

    {CAVE_NOISE_SOUND_SOURCE}

    {CAVE_WATER_SOUND_SOURCE 29 29}

    {CAVE_WATER_SOUND_SOURCE 11 30}

    {CAVE_WATER_SOUND_SOURCE 24 19}

    {CAVE_WATER_SOUND_SOURCE 11 16}

    {CAVE_WATER_SOUND_SOURCE 32 12}

    #
    # FIXME: Yes, the names are hardcoded because sound sources haven't
    #        received enough love from the developers and there isn't a lot
    #        that can be done with them in Lua/WML.
    #
#define TSOL_DISABLE_WATER_SOUND_SOURCES
    {REMOVE_SOUND_SOURCE __ss_cave_water_29_29}

    {REMOVE_SOUND_SOURCE __ss_cave_water_11_30}

    {REMOVE_SOUND_SOURCE __ss_cave_water_24_19}

    {REMOVE_SOUND_SOURCE __ss_cave_water_11_16}

    {REMOVE_SOUND_SOURCE __ss_cave_water_32_12}
#enddef

    {STARTING_VILLAGES 1 6}
    {STARTING_VILLAGES 2 8}

#define TSOL_INITIAL_OBJECTIVES
    [fire_event]
        name=initial objectives
    [/fire_event]
#enddef

#define TSOL_DECLARE_SEAL_GLYPH _GX _GY _PX _PY
    [literal]
        x={_GX}
        y={_GY}
        pillar_x={_PX}
        pillar_y={_PY}
    [/literal]
#enddef

    [event]
        name=prestart

        {VARIABLE active_seal_glyphs     6}
        {VARIABLE found_central_chamber  no}
        {VARIABLE glyph_scrying_progress -1}

        [set_variables]
            name=seal_glyphs
            mode=replace

            {TSOL_DECLARE_SEAL_GLYPH   51 16   40 26}
            {TSOL_DECLARE_SEAL_GLYPH   56 51   40 31}
            {TSOL_DECLARE_SEAL_GLYPH   28 43   35 34}
            {TSOL_DECLARE_SEAL_GLYPH   14 49   30 31}
            {TSOL_DECLARE_SEAL_GLYPH    6 29   30 26}
            {TSOL_DECLARE_SEAL_GLYPH   23  5   35 24}
        [/set_variables]

        [foreach]
            array=seal_glyphs
            [do]
                {PLACE_IMAGE "scenery/rune$($i + 1).png" $this_item.x $this_item.y}

                [event]
                    name=moveto
                    delayed_variable_substitution=no
                    [filter]
                        side=1
                        x,y=$this_item.x,$this_item.y
                    [/filter]

                    [fire_event]
                        name=trigger glyph activated
                        [primary_unit]
                            x,y=$|x1,$|y1 # Delay substitution.
                        [/primary_unit]
                    [/fire_event]
                [/event]
            [/do]
        [/foreach]

        {PLAYER_RECRUITMENT_SETUP_FOR_SCENARIO 10}

        #
        # Recall heroes
        #

        # wmllint: recognize Anlindë
        {RECALL_ANLINDE_AT    52  5}
        # wmllint: recognize Mal Keshar
        {RECALL_MAL_KESHAR_AT 54  6}
        # wmllint: recognize Althurin
        {RECALL_ALTHURIN_AT   52  6}
        # wmllint: recognize Igor
        {RECALL_IGOR}

        [role]
            side=1
            role=scout
            type=Elvish Marksman,Elvish Ranger,Elvish Outrider,Elvish Rider,Elvish Captain,Elvish Hero,Elvish Fighter,Elvish Scout,Elvish Archer,Civilian
            [not]
                id=Galas
            [/not]
        [/role]

        [role]
            side=1
            role=magic user
            type=Elvish Shyde,Elvish Sylph,Elvish Enchantress,Elvish Druid,Elvish Sorceress,Elvish Shaman
        [/role]

        [recall]
            x,y=53,7
            role=magic user
        [/recall]

        [recall]
            role=scout
        [/recall]

        {MAKE_TIMED_LOYAL (role=magic user)}
        {MAKE_TIMED_LOYAL (role=scout)}

        {TSOL_INITIAL_OBJECTIVES}
    [/event]

    #
    # Objectives used before and after killing Mena before the glyph
    # search begins.
    #
    [event]
        name=initial objectives
        first_time_only=no

        {OBJECTIVES (
            victory_string= _ "Current Objectives:"
            {OBJECTIVE_VICTORY ( _ "Explore the caves")}

            {OBJECTIVE_DEFEAT ( _ "Death of Galas")}
            {OBJECTIVE_DEFEAT ( _ "Death of Anlindë")}
            {OBJECTIVE_DEFEAT ( _ "Death of Mal Keshar")}
            {OBJECTIVE_DEFEAT ( _ "Death of Althurin")}

            {TURNS_RUN_OUT}

            {OBJECTIVE_CARRYOVER_NO_BONUS}
        )}
    [/event]

    [event]
        name=update objectives
        first_time_only=no

        [filter_condition]
            [have_unit]
                id=Mena
            [/have_unit]
        [/filter_condition]

        {OBJECTIVES (
            victory_string= _ "Current Objectives:"
            {OBJECTIVE_VICTORY ( _ "Defeat the enemy leader")}

            {OBJECTIVE_DEFEAT ( _ "Death of Galas")}
            {OBJECTIVE_DEFEAT ( _ "Death of Anlindë")}
            {OBJECTIVE_DEFEAT ( _ "Death of Mal Keshar")}
            {OBJECTIVE_DEFEAT ( _ "Death of Althurin")}

            {TURNS_RUN_OUT}

            {OBJECTIVE_CARRYOVER_NO_BONUS}
        )}
    [/event]

    [event]
        name=update objectives
        first_time_only=no

        [filter_condition]
            [not]
                [have_unit]
                    id=Mena
                [/have_unit]
            [/not]
        [/filter_condition]

        [if]
            {VARIABLE_NUMERICAL_GREATER_THAN active_seal_glyphs 1}
            [then]
                {VARIABLE glyph_count_text ( _ "($active_seal_glyphs runes remaining)")}
            [/then]
            [else]
                {VARIABLE glyph_count_text ( _ "($active_seal_glyphs rune remaining)")}
            [/else]
        [/if]

        # We need to be able to update this every time so the current value of
        # $active_seal_glyphs is processed.
        {OBJECTIVES (
            victory_string= _ "Current Objectives:"
            {OBJECTIVE_VICTORY
            (_"Find and activate all six trigger runes"+" "+"$glyph_count_text"+"")}

            {OBJECTIVE_DEFEAT ( _ "Death of Galas")}
            {OBJECTIVE_DEFEAT ( _ "Death of Anlindë")}
            {OBJECTIVE_DEFEAT ( _ "Death of Mal Keshar")}
            {OBJECTIVE_DEFEAT ( _ "Death of Althurin")}

            {TURNS_RUN_OUT}

            {OBJECTIVE_CARRYOVER_NO_BONUS}

            {OBJECTIVE_NOTE ( _ "Allow Mal Keshar to rest for three consecutive turns and he will reveal the location of the trigger runes")}
            # Don't display the note before the event where Mal Keshar suggests
            # doing this, or after he has already located the glyphs.
            {OBJECTIVE_NOTE_SHOW_IF ({VARIABLE_NUMERICAL_NOT_EQUALS glyph_scrying_progress -1})}
        )}

        [show_objectives][/show_objectives]

        {CLEAR_VARIABLE glyph_count_text}
    [/event]

#define TSOL_UPDATE_OBJECTIVES
    [fire_event]
        name=update objectives
    [/fire_event]
#enddef

    [event]
        name=start

        [message]
            speaker=Galas
            message= _ "I’m fairly certain we have been to this intersection countless times before. How much deeper could the last home of our heroes be?"
        [/message]

        [message]
            role=scout
            message= _ "I wouldn’t know for sure, sir, but at this rate I think we may soon reach the very bottom of the earth and find that there’s nothing below but a blazing hell—"
        [/message]

        [message]
            speaker=Mal Keshar
            sound=rumble.ogg
            message= _ "SILENCE!"
        [/message]

        [delay]
            time=750
        [/delay]

        [message]
            role=magic user
            message= _ "It is... an enormous power. It fills the entire place!"
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Yes, indeed, I recognize this presence. We must be finally there."
        [/message]

        [message]
            speaker=Galas
            message= _ "You magic-skilled people can perceive things which are beyond me."
        [/message]

        [message]
            speaker=Althurin
            message= _ "Indeed, lad. Magic skill lets ye ken things whose existence is normally ignored by common folk. Every rock in these caves, even the air... everything is imbued with an ancient magic not known to any living dwarf in this age. ’Tis a dangerous place to senselessly wander without nature’s permission."
        [/message]

        {QUAKE cave-in.ogg}

        [message]
            speaker=Galas
            message= _ "Fair enough. I hope we find them soon, before we run out of food and torches..."
        [/message]

        [message]
            speaker=Anlindë
            message= _ "And before the Chaos army reaches Herthgar, I would add. While the might of the dwarves and their many inventions may normally provide an insurmountable obstacle to invaders from the surface, I have this disquieting feeling that the enemy that approaches is much unlike the other commanders we have faced thus far."
        [/message]

        {QUAKE rumble.ogg}

        [message]
            role=scout
            message= _ "My lady, sirs, less chatter and more exploring, before the walls cave in on us!"
        [/message]
    [/event]

    #
    # Random earthquake effect when units move.
    #

    [event]
        name=moveto
        first_time_only=no

        [lua]
            code= <<
                local rumble_seed = unsynced_random(1, 100)

                if rumble_seed % 11 == 0 then -- 9.09% chance
                    wesnoth.wml_actions.sound({ name = "cave-in.ogg,cave-in.ogg,rumble.ogg" })
                end

                if rumble_seed % 13 == 0 then -- 7.69% chance
                    wesnoth.wml_actions.quake({ sound = "cave-in.ogg" })
                end

                if rumble_seed % 29 == 0 then -- 3.44% chance
                    wesnoth.wml_actions.quake({ sound = "rumble.ogg" })
                end
            >>
        [/lua]

        [allow_undo][/allow_undo]
    [/event]

    [event]
        name=moveto
        [filter]
            side=1
            x=1-44
            y=1-999
        [/filter]

        {FACE_UNIT id=Mena  id=Galas}
        {FACE_UNIT id=Galas id=Mena}

        {CLEAR_CAVE_SHROUD (
            [filter]
                id=Mena
            [/filter]
            radius=6
        )}

        [redraw]
            side=1
        [/redraw]

        [message]
            speaker=Mena
            # po: "She is dead"
            message= _ "The elves! How could they get past the commander? This can only mean she is... Damn it all!"
        [/message]

        [message]
            speaker=Galas
            message= _ "You too will perish at our hands if you insist on hindering us, demon."
        [/message]

        [message]
            speaker=Mena
            message= _ "So be it! I would rather die than surrender to you, Irdyan scum!"
        [/message]

        [modify_side]
            side=2
            recruit=Demon,Chaos Invoker,Automaton,Demon Zephyr
            {GOLD 120 135 150}
        [/modify_side]

        {MOBILIZE_GUARDIANS side=2}

        [scroll_to_unit]
            x,y=$x1,$y1
        [/scroll_to_unit]

        {TSOL_UPDATE_OBJECTIVES}
    [/event]

    [event]
        name=attack
        [filter]
            type=Goliath,Iron Golem
        [/filter]
        [filter_second]
            side=1
            [and]
                race=elf
                [or]
                    race=undead
                    [not]
                        type=Walking Corpse,Soulless
                    [/not]
                [/or]
            [/and]
        [/filter_second]

        [message]
            # May match low level undead, this is intentional.
            speaker=second_unit
            message= _ "Surely I could use some help here!"
        [/message]

        [message]
            speaker=unit
            message= _ "Die, vermin!"
        [/message]
    [/event]

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

        [message]
            speaker=unit
            message= _ "Oh, Uria... I have... failed... All our efforts... fruitless..."
        [/message]
    [/event]

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

        [if]
            {VARIABLE_BOOLEAN_EQUALS found_central_chamber yes}
            [then]
                [fire_event]
                    name=enter central chamber
                [/fire_event]

                [scroll_to]
                    x,y=$x1,$y1
                [/scroll_to]
            [/then]
            [else]
                {TSOL_INITIAL_OBJECTIVES}
            [/else]
        [/if]
    [/event]

    [event]
        name=moveto
        [filter]
            side=1
            [filter_location]
                x,y=35,29
                radius=8
            [/filter_location]
        [/filter]

        {VARIABLE found_central_chamber yes}

        [if]
            [not]
                [have_unit]
                    id=Mena
                [/have_unit]
            [/not]
            [then]
                [fire_event]
                    name=enter central chamber
                [/fire_event]

                [scroll_to]
                    x,y=$x1,$y1
                [/scroll_to]
            [/then]
            [else]
                [allow_undo][/allow_undo]
            [/else]
        [/if]
    [/event]

#define TSOL_SET_UP_GUARD_SIDE _SIDE _UNIT_WML _SIDE_WML
    [store_starting_location]
        side={_SIDE}
    [/store_starting_location]

    [unit]
        side={_SIDE}
        x,y=$location.x,$location.y
        {_UNIT_WML}
    [/unit]

    [capture_village]
        side={_SIDE}
        x,y=$location.x,$location.y
        radius=5
    [/capture_village]

    [modify_side]
        side={_SIDE}
        {_SIDE_WML}
    [/modify_side]

    {CLEAR_VARIABLE location}
#enddef

    [event]
        name=reveal central chamber
        first_time_only=no

        [remove_shroud]
            side=1
            x,y=35,29
            radius=8
        [/remove_shroud]

        [redraw]
            side=1
        [/redraw]
    [/event]

    [event]
        name=enter central chamber

        {LOCK_VIEW}

        {REPLACE_SCENARIO_MUSIC silence.ogg}

        {QUAKE rumble.ogg}

        [fire_event]
            name=activate glyph chamber guards
        [/fire_event]

        [fire_event]
            name=reveal central chamber
        [/fire_event]

        [scroll_to]
            x,y=35,29
        [/scroll_to]

        [delay]
            time=1000
        [/delay]

        [message]
            speaker=Galas
            message= _ "That structure at the center of the chamber..."
        [/message]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Galas
            message= _ "Anlindë?"
        [/message]

        [message]
            speaker=Anlindë
            message= _ "We found it, Galas! This is the final resting place of the Lady of Light and the Master of Darkness! That strong magic comes from within the structure. We need to find a way to enter."
        [/message]

        [scroll_to]
            x,y=35,33
        [/scroll_to]

        {HIGHLIGHT_GOAL x,y=35,33}

        {REPLACE_SCENARIO_MUSIC snowfall.ogg}
        {APPEND_MUSIC           wanderer.ogg}
        {APPEND_MUSIC           nunc_dimittis.ogg}
        {APPEND_MUSIC           into_the_shadows.ogg}

        [message]
            speaker=Mal Keshar
            message= _ "Hm, it’s evident they did not want anybody waking them from their slumber. The entrance seems to be completely blocked, and the six pillars around the structure appear to be part of some kind of magic seal."
        [/message]

        [message]
            speaker=Althurin
            message= _ "They carved glyphs in them! Ancient dwarvish runes! This musta’ been the work of our kin from ages past. I ha’ heard of this kind of seal before... There may be trigger runes around the area, mayhap designed to be activated by specific people."
        [/message]

        [message]
            speaker=Anlindë
            message= _ "Yes. Hm, I imagine that the Lady of Light would mandate the glyphs to react only to the presence of elvenkind and their allies, so... that may explain why the demons were unable to do anything here. That said, if our arrival had been delayed long enough, they might have eventually figured out a way to violate the seal’s magic."
        [/message]

        [message]
            speaker=Galas
            message= _ "All we have to do, then, is to search for the triggers in these caves?"
        [/message]

        [message]
            speaker=Althurin
            message= _ "Aye, aye... Well, there’s no guarantee that they may ha’ carved them in accessible locations close to this chamber, but ’tis a good starting point as any."
        [/message]

        [message]
            speaker=Galas
            message= _ "Sure, let’s do it!"
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Careful, elf — the earth itself does not seem pleased with our intrusion into its eternal domain. As far as it is concerned, we are unwelcome parasites not unlike the demons we just vanquished."
        [/message]

        {UNLOCK_VIEW}

        {TSOL_UPDATE_OBJECTIVES}

        #
        # Allow Mal Keshar to help with locating the runes.
        #

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

            [fire_event]
                name=begin glyph scrying
            [/fire_event]
        [/event]
    [/event]

    [event]
        name=activate glyph chamber guards

        {TSOL_SET_UP_GUARD_SIDE 3 (
            canrecruit=yes
            type=Chocobone
        ) {GOLD 50 75 100} }

        {TSOL_SET_UP_GUARD_SIDE 4 (
            canrecruit=yes
            type=Fire Guardian
        ) {GOLD 50 75 100} }

        {TSOL_SET_UP_GUARD_SIDE 5 (
            canrecruit=yes
            type=Rock Golem
            # This special golem cannot move around, but has great defense ratios
            [modifications]
                [object]
                    silent=yes
                    [effect]
                        apply_to=movement
                        set=1
                    [/effect]
                    [effect]
                        apply_to=movement_costs
                        replace=true
                        [movement_costs]
                            deep_water={UNREACHABLE}
                            shallow_water={UNREACHABLE}
                            reef={UNREACHABLE}
                            swamp_water={UNREACHABLE}
                            flat={UNREACHABLE}
                            sand={UNREACHABLE}
                            forest={UNREACHABLE}
                            hills={UNREACHABLE}
                            mountains={UNREACHABLE}
                            village={UNREACHABLE}
                            castle={UNREACHABLE}
                            cave={UNREACHABLE}
                            frozen={UNREACHABLE}
                            unwalkable={UNREACHABLE}
                            impassable={UNREACHABLE}
                            fungus={UNREACHABLE}
                        [/movement_costs]
                    [/effect]
                    [effect]
                        apply_to=defense
                        replace=true
                        [defense]
                            cave=30
                            impassable=20
                            hills=30
                            mountains=20
                            fungus=30
                        [/defense]
                    [/effect]
                [/object]
            [/modifications]
        ) {GOLD 50 75 100} }

        {TSOL_SET_UP_GUARD_SIDE 6 (
            canrecruit=yes
            type=Cuttle Fish
        ) {GOLD 50 75 90} }
    [/event]

    [event]
        name=begin glyph scrying

        [message]
            speaker=Mal Keshar
            message= _ "Perhaps if I was allowed to concentrate for a while, I would be able to pinpoint the precise location of the glyphs using magic."
        [/message]

        [message]
            speaker=Galas
            message= _ "Really? That would be a great help!"
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "I am not completely sure it’s possible, but I can try."
        [/message]

        {VARIABLE glyph_scrying_progress 0}

        {TSOL_UPDATE_OBJECTIVES}

        [event]
            delayed_variable_substitution=no
            id=glyph_scrying_progress_incrementor_eh
            name=new turn
            first_time_only=no
            [filter_condition]
                #
                # This event is generated on a new turn event, and we don't
                # want it to run on the same turn it is generated.
                #
                {VARIABLE_NUMERICAL_GREATER_THAN turn_number "$turn_number"}
            [/filter_condition]

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

            [if]
                {VARIABLE_BOOLEAN_EQUALS malin_store.resting yes}
                [then]
                    {VARIABLE_INC glyph_scrying_progress}

                    [floating_text]
                        [filter]
                            id=Mal Keshar
                        [/filter]
                        text= _ "Concentrating"
                    [/floating_text]
                [/then]
                [else]
                    {VARIABLE glyph_scrying_progress 0}
                [/else]
            [/if]

            {CLEAR_VARIABLE malin_store}
        [/event]

        [event]
            id=glyph_scrying_finish_eh
            name=new turn
            first_time_only=no
            [filter_condition]
                {VARIABLE_NUMERICAL_GREATER_THAN glyph_scrying_progress 3}
            [/filter_condition]

            [fire_event]
                name=glyph scrying complete
            [/fire_event]
        [/event]
    [/event]

    [event]
        name=glyph scrying complete

        [remove_event]
            id=glyph_scrying_progress_incrementor_eh
        [/remove_event]

        [remove_event]
            id=glyph_scrying_finish_eh
        [/remove_event]

        # Flag for the objectives screen.
        {VARIABLE glyph_scrying_progress -1}

        [message]
            speaker=Mal Keshar
            message= _ "Yes, I found them!"
        [/message]

        [foreach]
            array=seal_glyphs
            [do]
                [remove_shroud]
                    side=1
                    x,y=$this_item.x,$this_item.y
                    radius=3
                [/remove_shroud]

                [redraw]
                    side=1
                [/redraw]

                [scroll_to]
                    x,y=$this_item.x,$this_item.y
                [/scroll_to]

                {HIGHLIGHT_GOAL x,y=$this_item.x,$this_item.y}
            [/do]
        [/foreach]

        [message]
            speaker=Anlindë
            message= _ "Thanks, Mal Keshar. This will certainly make our mission much easier. Now we only need to clear the path leading to each glyph."
        [/message]

        {TSOL_UPDATE_OBJECTIVES}
    [/event]

    #
    # Unique glyph handler, expects a primary unit.
    #
    # The glyph locations and the proxy moveto EH that fires this event are
    # defined by the prestart EH.
    #
    [event]
        name=trigger glyph activated
        first_time_only=no

        [store_items]
            x,y=$x1,$y1
        [/store_items]

        {BUG_ON {VARIABLE_NUMERICAL_GREATER_THAN items.length 1} ()}

        [remove_item]
            x,y=$x1,$y1
        [/remove_item]

        [lua]
            code=<<
                local var = "items[0].image"
                local v = tostring(wml.variables[var])

                v = v:gsub("scenery/rune(%d)%.png", "scenery/rune%1-glow.png")

                wml.variables[var] = v
            >>
        [/lua]

        [terrain]
            x,y=$x1,$y1
            layer=overlay
            terrain=^Ii
        [/terrain]

        [insert_tag]
            name=item
            variable=items[0]
        [/insert_tag]

        {CLEAR_VARIABLE items}

        {VARIABLE_DEC active_seal_glyphs}

        [message]
            speaker=narrator
            image=wesnoth-icon.png
            message= _ "Rune activated."
        [/message]

        [if]
            {VARIABLE_NUMERICAL_GREATER_THAN active_seal_glyphs 0}
            [then]
                #
                # Display the updated remaining glyphs counter.
                #
                {TSOL_UPDATE_OBJECTIVES}
            [/then]
            [else]
                #
                # End the scenario.
                #

                [message]
                    speaker=narrator
                    image=wesnoth-icon.png
                    message= _ "All glyphs have been activated. The earth shakes!"
                [/message]

                {ENDLEVEL_VICTORY no}
            [/else]
        [/if]
    [/event]

    #
    # The glyph at 51,16 has a secondary event
    #
    [event]
        name=moveto
        [filter]
            side=1
            x,y=51,16
        [/filter]

        [terrain]
            x=   50,   51
            y=11-12,13-15
            terrain=Rb
        [/terrain]

        [message]
            speaker=narrator
            image=wesnoth-icon.png
            message= _ "A wall moves."
        [/message]

        [redraw]
            side=1
        [/redraw]
    [/event]

    [event]
        name=moveto
        [filter]
            side=1
            [filter_location]
                [filter_adjacent_location]
                    terrain=*^Pr/,*^Pr\
                [/filter_adjacent_location]
            [/filter_location]
        [/filter]

        [if]
            [have_unit]
                x,y=$x1,$y1
                [not]
                    race=bats,undead
                    [not]
                        type=Lich,Ancient Lich,Ghost,Wraith,Spectre,Shadow,Nightgaunt
                    [/not]
                [/not]
            [/have_unit]
            [then]
                [message]
                    speaker=unit
                    message= _ "Hmm... This gate seems magical in nature. It glows blue in a pulsating and mesmerizing fashion, and my hands are unable to reach the metal bars, as though they were enveloped by an invisible shield."
                [/message]
            [/then]
            [else]
                [message]
                    speaker=Mal Keshar
                    scroll=no
                    message= _ "Hmm... My minions inform me that the gate seems magical in nature. Their hands are unable to reach the metal bars, as if they were protected by some kind of shield."
                [/message]
            [/else]
        [/if]

        [message]
            speaker=Galas
            scroll=no
            message= _ "There must be a way to open the gate, somewhere."
        [/message]
    [/event]

#define TSOL_AREA_DESCRIPTION_UNIT
    x,y=$x1,$y1
    {UNIT_SPEAKS_FOR_UNDEAD_MINION_STRICT (id=Galas)}
#enddef

    #
    # Water zone narration.
    #
    [event]
        name=moveto
        [filter]
            x= 1-25
            y=18-34
            side=1
        [/filter]

        {CLEAR_CAVE_SHROUD (
            x=16-30
            y=33-19
            radius=1
            terrain=W*
        )}

        [redraw][/redraw]

        [message]
            {TSOL_AREA_DESCRIPTION_UNIT}
            scroll=no
            message= _ "Wow. It’s a very large underground pool. There are some shallow parts where the ground below sticks out interspersed with deeper bits we cannot cross. The whole area seems well-guarded by aquatic creatures and spirits. Getting to the island behind the ruined building will not be as easy as I would prefer."
        [/message]
    [/event]

    #
    # Lava zone narration.
    #
    [event]
        name=moveto
        [filter]
            side=1
            x=44-68
            y=36-60
        [/filter]

        {CLEAR_CAVE_SHROUD (
            x,y=48,39
            radius=4
        )}

        [redraw][/redraw]

        [message]
            {TSOL_AREA_DESCRIPTION_UNIT}
            scroll=no
            message= _ "The air here is unbearably dense and hot due to the pools and outflows of lava everywhere. Of course, the fire spirits below don’t mind the temperature at all — they frolic in the lava and seem completely unharmed by it. I would advise against allowing our undead warriors to explore the area unassisted."
        [/message]
    [/event]

    #
    # Potion of drain.
    #
    {PICK_UP (items/potion-poison.png) 63 19 (
        [not]
            race=bats,undead
        [/not]
    )
    ( _ "This is a strange ornate emerald bottle containing a foul-smelling potion. The scroll next to it, though highly deteriorated due to its age, still has enough legible words on it so I can tell that it explains the nature of the potion. Apparently, it makes the drinker much weaker than usual, but it also allows them to drain the life force of every creature they come into contact with to replenish their own.

The effects are said to be permanent, which only makes me more unsure as to whether it is really worth the trade-off.")
    ( _ "This potion may only be used by living units, not including bats.")
    (
        [sound]
            name=poison.ogg
        [/sound]

        [object]
            id=e1s10_drainer_potion
            name= _ "Potion of Drain"
            image=icons/potion-green-4.png
            duration=forever
            description= _ "This potion grants the drains special to the unit’s melee attacks, reduces its maximum hitpoints by 5%, and increases its resistance to arcane damage by 10%."
            [filter]
                x,y=$x1,$y1
            [/filter]
            [effect]
                apply_to=attack
                range=melee
                [set_specials]
                    mode=append
                    {WEAPON_SPECIAL_DRAIN}
                [/set_specials]
            [/effect]
            [effect]
                apply_to=hitpoints
                increase_total=-5%
            [/effect]
            [effect]
                apply_to=resistance
                replace=no
                [resistance]
                    arcane=-10
                [/resistance]
            [/effect]
        [/object]
    )}

    #
    # Berserker potion.
    #
    {PICK_UP (items/potion-red.png) 36 39 (
        [not]
            type=Walking Corpse,Soulless
        [/not]
        [not]
            type=Ghost,Wraith,Shadow,Spectre,Nightgaunt
        [/not]
        [not]
            type=Elvish Shaman,Elvish Druid,Elvish Shyde,Elvish Sorceress,Elvish Enchantress,Elvish Sylph
        [/not]
        [not]
            id=Anlindë,Mal Keshar,Galas
        [/not]
        [not]
            race=bats
        [/not]
    )
    ( _ "Such a pretty potion flask! As I open and smell the red liquid inside, I immediately feel energized and ready to take down any incoming threat. It appears to be a berserker potion, said to make the user stronger and fiercer in battle. Using these is often reserved for last-resort scenarios due to the potential side effects, which include utter recklessness and even psychosis!

Nevertheless, it might prove useful in our war against the Chaos Empire, and the flask contains enough potion for a dozen fights, if not more.")
    ( _ "This potion may only be used by a true warrior with an axe or sword in hand.")
    (
        [sound]
            name=potion.ogg
        [/sound]

        # wmllint: local spelling •

        [object]
            id=e1s10_berserker_potion
            name= _ "Berserker Potion"
            image=icons/potion-red-1.png
            duration=forever
            description= _ "This potion grants the berserk special to the unit’s melee attacks, which also sees their damage increased by one. As an advantageous side effect, the unit’s maximum hitpoints increase by 10%, and it also becomes more resistant to certain forms of damage:

 • Blade: +10% resistance
 • Fire: +20% resistance
 • Impact: +30% resistance"
            [filter]
                x,y=$x1,$y1
            [/filter]
            [effect]
                apply_to=attack
                range=melee
                increase_damage=1
                [set_specials]
                    mode=append
                    {WEAPON_SPECIAL_BERSERK}
                [/set_specials]
            [/effect]
            [effect]
                apply_to=hitpoints
                increase_total=10%
                increase=10%
            [/effect]
            [effect]
                apply_to=resistance
                replace=no
                [resistance]
                    impact=-30
                    blade=-10
                    fire=-20
                [/resistance]
            [/effect]
        [/object]
    )}

    #
    # Touchplate at 39,53 opening a glyph room.
    #
    {ITEM_TOUCHPLATE 39 53}

    [event]
        name=moveto
        [filter]
            side=1
            x,y=39,53
        [/filter]

        [remove_item]
            x,y=$x1,$y1
        [/remove_item]

        [terrain]
            x,y=28,44
            terrain=Ur
        [/terrain]

        [message]
            speaker=narrator
            image=wesnoth-icon.png
            message=_"Touchplate triggered. A magical gate opens."
        [/message]

        {CLEAR_CAVE_SHROUD x,y,radius=28,44,1}

        [redraw]
            side=1
        [/redraw]

        [scroll_to]
            x,y=28,44
        [/scroll_to]

        {HIGHLIGHT_GOAL x,y=28,44}

        [scroll_to]
            x,y=$x1,$y1
        [/scroll_to]
    [/event]

    [event]
        name=enter hex
        [filter]
            side=1
            x,y="33-34","47"
            [not]
                type=Ghost,Wraith,Spectre,Shadow,Nightgaunt
            [/not]
            [not]
                race=bats
            [/not]
        [/filter]

        [allow_undo][/allow_undo]

        [if]
            [have_unit]
                x,y=$x1,$y1
                [not]
                    race=undead
                    [not]
                        type=Lich,Ancient Lich
                    [/not]
                [/not]
            [/have_unit]
            [then]
                [message]
                    speaker=unit
                    message= _ "This bridge seems extremely unsafe..."
                [/message]
            [/then]
            [else]
                [message]
                    speaker=Mal Keshar
                    scroll=no
                    message= _ "That bridge seems extremely unsafe."
                [/message]
            [/else]
        [/if]
    [/event]

    [event]
        name=victory

        {LOCK_VIEW}

        #
        # Remove sound sources we no longer need to free up mixer channels.
        #
        {TSOL_DISABLE_WATER_SOUND_SOURCES}

        {REPLACE_SCENARIO_MUSIC silence.ogg}

        #
        # Reveal the central chamber in case we are in debug mode.
        #
        [fire_event]
            name=reveal central chamber
        [/fire_event]

        [foreach]
            array=seal_glyphs
            [do]
                [scroll_to]
                    x,y=$this_item.pillar_x,$this_item.pillar_y
                    {WARP}
                [/scroll_to]

                [terrain]
                    terrain=Qxu
                    #terrain=Qxu^Ii
                    x,y=$this_item.pillar_x,$this_item.pillar_y
                [/terrain]

                [redraw]
                    side=1
                [/redraw]

                {QUAKE thunderstick.ogg}

                [delay]
                    time=150
                [/delay]
            [/do]
        [/foreach]

        [scroll_to]
            x,y=35,32
            {WARP}
        [/scroll_to]

        [delay]
            # Long delay, gives sounds a chance to finish playing.
            time=750
        [/delay]

        [hide_unit][/hide_unit]

        {WHITE_SCREEN}

        [delay]
            time=250
        [/delay]

        [terrain]
            terrain=Rb
            layer=base
            x,y=35,31-32
        [/terrain]

        # Lit up the entrance.
        [terrain]
            terrain=^Efs
            layer=overlay
            x=33-34,36-37
            y=   31,   31
        [/terrain]

        [terrain]
            terrain=^Ebn
            layer=overlay
            x=34,36
            y=32,32
        [/terrain]

        [redraw]
            side=1
        [/redraw]

        {RESET_SCREEN}

        [unhide_unit][/unhide_unit]

        {QUAKE dragonstick.ogg}

        [delay]
            time=750
        [/delay]

        #
        # Just to keep the cutscene zone clear.
        #

        {RESET_AND_SEND_TO_RECALL_LIST (
            side=1
            [not]
                id=Galas,Mal Keshar,Anlindë,Althurin
            [/not]
            [not]
                x,y=recall,recall
            [/not]
        )}

        [teleport]
            [filter]
                id=Galas
            [/filter]
            x,y=35,33
        [/teleport]

        [teleport]
            [filter]
                id=Mal Keshar
            [/filter]
            x,y=34,33
        [/teleport]

        [teleport]
            [filter]
                id=Anlindë
            [/filter]
            x,y=36,33
        [/teleport]

        [teleport]
            [filter]
                id=Althurin
            [/filter]
            x,y=34,34
        [/teleport]

        [unit]
            # wmllint: recognize Unarye
            {CHARACTER_STATS_UNARYE}
            side=1
            x,y=36,34
            passable=yes
        [/unit]

        {FACE_LOCATION (id=Galas,Anlindë,Mal Keshar,Althurin,Unarye) x,y=35,32}

        {REPLACE_SCENARIO_MUSIC underground.ogg}

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Galas
            message= _ "At long last! Let us go, now."
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "I have been waiting for this for too long."
        [/message]

        [message]
            speaker=Anlindë
            message= _ "Wait, Galas, before continuing... only the two of us should enter."
        [/message]

        [message]
            speaker=Galas
            message= _ "... Why?"
        [/message]

        [message]
            speaker=Anlindë
            message= _ "The regent lord of the elves is surely the only appropriate person to greet the Lady of Light and the Master of Darkness after such a long time, but since you don’t have any magical ability, my presence may be required to wake our heroes from their eternal sleep. It is not proper that anybody else should be present around the greatest sages in the history of elvenkind on this singular occasion."
        [/message]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Galas
            message= _ "I must say, I never expected such words from you, Anlindë. After so long, we are finally here, but not only thanks to you — we owe a great debt to Lady Unarye and Mal Keshar as well, and this is why I must ask them to accompany us as well."
        [/message]

        [message]
            speaker=Unarye
            scroll=no
            message= _ "Me— meeting the Lady of Light in person? I would be greatly honored, my lord!"
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Ah, so would I. Galas, you really are an example to follow for the other elves!"
        [/message]

        [message]
            speaker=Anlindë
            message= _ "But I—"
        [/message]

        [message]
            speaker=Galas
            message= _ "You will allow them to come with us. This is an order, Anlindë."
        [/message]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Anlindë
            message= _ "... As you command, my lord."
        [/message]

        {UNLOCK_VIEW}

        {CLEAR_VARIABLE active_seal_glyphs,seal_glyphs,found_central_chamber,glyph_scrying_progress}
    [/event]
[/scenario]

#undef TSOL_DZOMBIE
#undef TSOL_DISABLE_WATER_SOUND_SOURCES
#undef TSOL_DECLARE_SEAL_GLYPH
#undef TSOL_SET_UP_GUARD_SIDE
#undef TSOL_AREA_DESCRIPTION_UNIT
#undef TSOL_OBJECTIVE_GLYPHS
#undef TSOL_INITIAL_OBJECTIVES
#undef TSOL_UPDATE_OBJECTIVES

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


#textdomain wesnoth-Invasion_from_the_Unknown

[scenario]
    id=11_Strike_on_Herthgar
    name= _ "Strike on Herthgar"
    {MAP 11_Strike_on_Herthgar.map}
    {TURNS 16 19 24}
    next_scenario=12_The_Escape

    {SCENARIO_MUSIC       "battle.ogg"}  {CONTINUE_PLAYING_STORY_MUSIC_FIRST}
    {EXTRA_SCENARIO_MUSIC "the_city_falls.ogg"}
    {EXTRA_SCENARIO_MUSIC "casualties_of_war.ogg"}

    {UNDERGROUND}

    {STORYTXT_STRIKE_ON_HERTHGAR}

    {DEATHS_ACT_2_2}
    {DEATHS_DWARVES}

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

        {GOLD 390 370 320}

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

    [side]
        side=2
        team_name=heroes
        user_team_name= _ "team_name^Dwarves"
        {DWARVISH_FLAG}

        {GOLD 350 300 250}
        {INCOME 8 7 5}
        {QUANTITY recruit
        (Dwarvish Stalwart,Dwarvish Guardsman,Dwarvish Ulfserker,Dwarvish Pathfinder,Dwarvish Scout,Dwarvish Steelclad,Dwarvish Runesmith,Dwarvish Fighter,Dwarvish Thunderwheel,Dwarvish Steamwheel,Dwarvish Thunderer,Dwarvish Flamethrower,Dwarvish Thunderguard)
        (Dwarvish Stalwart,Dwarvish Guardsman,Dwarvish Pathfinder,Dwarvish Scout,Dwarvish Runesmith,Dwarvish Fighter,Dwarvish Thunderwheel,Dwarvish Thunderer,Dwarvish Flamethrower)
        (Dwarvish Guardsman,Dwarvish Scout,Dwarvish Runesmith,Dwarvish Fighter,Dwarvish Thunderwheel,Dwarvish Thunderer)
        }

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

            [goal]
                name=protect_unit
                [criteria]
                    id=King Asthorgar
                [/criteria]
                value=10.0
                protect_radius=6
            [/goal]
        [/ai]

        canrecruit=yes
        # wmllint: recognize King Asthorgar
        {CHARACTER_STATS_ASTHORGAR_BASE}

        {SIDE_GENERIC_GUARD (Dwarvish Stalwart) 16 23}
        {SIDE_GENERIC_GUARD (Dwarvish Guardsman) 19 22}
        {SIDE_GENERIC_GUARD (Dwarvish Guardsman) 21 22}
        {SIDE_GENERIC_GUARD (Dwarvish Stalwart) 24 23}
        {SIDE_GENERIC_GUARD (Dwarvish Stalwart) 15 25}
        {SIDE_GENERIC_GUARD (Dwarvish Guardsman) 15 28}
        {SIDE_GENERIC_GUARD (Dwarvish Stalwart) 25 25}
        {SIDE_GENERIC_GUARD (Dwarvish Guardsman) 25 28}
        {SIDE_GENERIC_GUARD (Dwarvish Guardsman) 16 29}
        {SIDE_GENERIC_GUARD (Dwarvish Stalwart) 19 31}
    [/side]
    # wmllint: validate-on

#define SOK_LRECRUITMENT
    {ai/aliases/stable_singleplayer.cfg}
    [ai]
        {AI_SIMPLE_ALWAYS_ASPECT passive_leader    yes}
        {AI_SIMPLE_ALWAYS_ASPECT simple_targeting  yes}
        {AI_SIMPLE_ALWAYS_ASPECT village_value     0.0}
        {AI_SIMPLE_ALWAYS_ASPECT aggression        1.0}
        {AI_SIMPLE_ALWAYS_ASPECT caution          -1.0}

        [goal]
            [criteria]
                id=Elynia
            [/criteria]
            value=7.0
        [/goal]
        [goal]
            [criteria]
                id=Anlindë
            [/criteria]
            value=6.0
        [/goal]
        [goal]
            [criteria]
                id=Galas
            [/criteria]
            value=6.5
        [/goal]
        [goal]
            [criteria]
                id=Mal Keshar
            [/criteria]
            value=2.0
        [/goal]
        [goal]
            [criteria]
                id=King Asthorgar
            [/criteria]
            value=8.0
        [/goal]
    [/ai]
#enddef

    [side]
        side=3
        team_name=evil
        user_team_name= _ "team_name^Chaos Empire"
        {CHAOS_FLAG}

        {GOLD 310 360 410}
        {INCOME 4 7 8}
        recruit=Demon,Chaos Invader,Chaos Invoker,Automaton,Imp,Mudcrawler,Chaos Headhunter

        {SOK_LRECRUITMENT}

        canrecruit=yes
        type=Chaos Lorekeeper
        id="Armiza'ar"
        name= _ "Armiza’ar"
        facing=sw
        [modifications]
            {TRAIT_STRONG}
            {TRAIT_INTELLIGENT}
        [/modifications]
    [/side]

    [side]
        side=4
        team_name=heroes
        user_team_name= _ "team_name^Dwarves"
        {DWARVISH_FLAG}

        {GOLD 200 150 100}
        recruit=Dwarvish Guardsman,Dwarvish Ulfserker,Dwarvish Scout,Dwarvish Fighter,Dwarvish Thunderwheel,Dwarvish Thunderer,Dwarvish Steamwheel,Dwarvish Runesmith

        canrecruit=yes
        type=Dwarvish Explorer
        id=Denathor
        name= _ "Denathor"
        {IS_EXPENDABLE_LEADER}
        [modifications]
            {TRAIT_HEALTHY}
            {TRAIT_RESILIENT}
        [/modifications]

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

            [goal]
                name=protect_unit
                [criteria]
                    id=King Asthorgar
                [/criteria]
                protect_radius=7
                value=7.5
            [/goal]
        [/ai]
    [/side]

    [side]
        side=5
        team_name=evil
        user_team_name= _ "team_name^Chaos Empire"
        {CHAOS_FLAG}

        {GOLD 310 360 410}
        {INCOME 2 6 9}
        recruit=Automaton,Chaos Invader,Demon,Blood Imp,Chaos Headhunter,Imp,Chaos Invoker

        {SOK_LRECRUITMENT}

        canrecruit=yes
        type=Chaos Soulhunter
        id=Oddis
        name= _ "Oddis"
        facing=ne
        [modifications]
            {TRAIT_QUICK}
            {TRAIT_RESILIENT}
        [/modifications]
    [/side]

    [side]
        side=6
        team_name=evil
        user_team_name= _ "team_name^Chaos Empire"
        {CHAOS_FLAG}

        {GOLD 310 360 410}
        {INCOME 3 4 6}
        recruit=Chaos Invader,Chaos Hound,Chaos Headhunter,Imp,Demon,Chaos Bowman,Chaos Invoker,Blood Imp

        {SOK_LRECRUITMENT}

        canrecruit=yes
        type=Hell Guardian
        id=Gythrn
        name= _ "Gythrn"
        facing=se
        [modifications]
            {TRAIT_STRONG}
            {TRAIT_QUICK}
        [/modifications]
    [/side]

    [side]
        side=7
        team_name=evil
        user_team_name= _ "team_name^Chaos Empire"
        {CHAOS_FLAG}

        {GOLD 310 360 410}
        {INCOME 6 8 8}
        recruit=Chaos Invoker,Demon,Chaos Invader,Demon Zephyr,Chaos Hound,Imp,Chaos Magus

        {SOK_LRECRUITMENT}

        canrecruit=yes
        type=Chaos Cataphract
        id=Alazar
        name= _ "Alazar"
        facing=nw
        [modifications]
            {TRAIT_RESILIENT}
            {TRAIT_QUICK}
        [/modifications]
    [/side]

    [side]
        side=8
        team_name=heroes
        user_team_name= _ "team_name^Dwarves"
        {DWARVISH_FLAG}

        {GOLD 200 150 100}
        {INCOME 4 2 0}
        recruit=Dwarvish Guardsman,Dwarvish Berserker,Dwarvish Fighter,Dwarvish Thunderwheel,Dwarvish Thunderer,Dwarvish Steamwheel,Dwarvish Runesmith,Dwarvish Steelclad,Dwarvish Flamethrower

        canrecruit=yes
        type=Dwarvish Dragonguard
        id=Furin
        name= _ "Furin"
        {IS_EXPENDABLE_LEADER}
        [modifications]
            {TRAIT_RESILIENT}
            {TRAIT_STRONG}
        [/modifications]

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_SIMPLE_ALWAYS_ASPECT aggression     1.00}
            {AI_SIMPLE_ALWAYS_ASPECT caution        0.10}
            {AI_SIMPLE_ALWAYS_ASPECT village_value  0.10}
            {AI_SIMPLE_ALWAYS_ASPECT passive_leader yes}

            [goal]
                name=protect_unit
                [criteria]
                    id=King Asthorgar
                [/criteria]
                protect_radius=7
                value=7.5
            [/goal]
        [/ai]
    [/side]

    [side]
        side=9
        team_name=evil
        user_team_name= _ "team_name^Chaos Empire"
        {CHAOS_FLAG}

        {GOLD 290 340 390}
        {INCOME 4 6 8}
        recruit=Automaton,Chaos Invoker,Demon,Chaos Headhunter,Blood Imp,Demon Zephyr,Imp

        {SOK_LRECRUITMENT}

        canrecruit=yes
        type=Chaos Heavy Longbowman
        id=Wygerm
        name= _ "Wygerm"
        facing=se
        [modifications]
            {TRAIT_DEXTROUS}
            {TRAIT_STRONG}
        [/modifications]
    [/side]

#undef SOK_LRECRUITMENT

    {STARTING_VILLAGES 1 3}
    {STARTING_VILLAGES 2 5}
    {STARTING_VILLAGES 3 3}
    {STARTING_VILLAGES 4 3}
    {STARTING_VILLAGES 5 3}
    {STARTING_VILLAGES 6 3}
    {STARTING_VILLAGES 7 8}
    {STARTING_VILLAGES 8 3}
    {STARTING_VILLAGES 9 3}

    {PLACE_IMAGE terrain/castle/dwarven-keep.png 20 26}

    {CAVE_NOISE_SOUND_SOURCE}

    [event]
        name=prestart

        {VARIABLE malin_attacks  0}
        {VARIABLE elynia_attacks 0}

        [hide_unit]
            id=King Asthorgar
        [/hide_unit]

        {PLAYER_RECRUITMENT_SETUP_FOR_SCENARIO 11}

        #
        # Recall heroes
        #

        # wmllint: recognize Elynia
        {RECALL_ELYNIA}
        # wmllint: recognize Mal Keshar
        {RECALL_MAL_KESHAR}
        # wmllint: recognize Anlindë
        {RECALL_ANLINDE}
        # wmllint: recognize Althurin
        {RECALL_ALTHURIN}
        # wmllint: recognize Igor
        {RECALL_IGOR}

        {OBJECTIVES (
            {OBJECTIVE_VICTORY_END_OF_TURNS}
            {OBJECTIVE_OR}
            {OBJECTIVE_VICTORY ( _ "Defeat all enemy leaders")}

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

            {OBJECTIVE_NO_CARRYOVER}
        )}
    [/event]

    [event]
        name=start

        [message]
            speaker=Anlindë
            message= _ "Just as I feared, they managed to take down Herthgar’s defenses and surround the capital."
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "It matters little. We shall drive them out of the caves regardless of their numbers! Maybe we could even manage to turn them to our side in death, he he."
        [/message]

        [message]
            speaker=Elynia
            message= _ "So those are the demons you have fought? They are not as impressive as I expected."
        [/message]

        [message]
            speaker=Althurin
            message= _ "They shall pay with their accursed blood if our good king was captured or murdered!"
        [/message]

        [unhide_unit]
            id=King Asthorgar
        [/unhide_unit]

        [message]
            speaker=King Asthorgar
            message= _ "Ye ha’ nae reason to fear, Althurin! Well, at least I am still alive!"
        [/message]

        [message]
            speaker=Galas
            message= _ "Your Highness, what is the situation?"
        [/message]

        [message]
            speaker=King Asthorgar
            message= _ "Our main defenses ha’ fallen and if we are to ha’ any hope o’ fending off these demented barbarians and their ever-increasing numbers, we’ll need all the help we can muster!"
        [/message]

        [message]
            speaker=Galas
            message= _ "We will help you, and we shall die fighting if it is necessary."
        [/message]

        [message]
            speaker=Anlindë
            message= _ "Galas, this is suicidal! Just look at their numbers — if the dwarves did not manage to hold out on their own, the odds our small group will be of any help are unreasonably low. Look — they are already closing in on us from behind!"
        [/message]

        [message]
            speaker=Galas
            message= _ "We cannot leave the dwarves to perish alone! We are indebted to Althurin for helping us find Elynia, and his people <i>need us now</i>! Besides, if Herthgar is to fall, what obstacles shall be left to impede their advance towards the northlands?"
        [/message]

        [message]
            speaker=Elynia
            message= _ "Lord Galas is right — we must fight."
        [/message]

        [message]
            speaker=Anlindë
            message= _ "My lady? But our numbers are small, and we are still weak!"
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Hah! You elves might be weak, but my minions are as strong as ever. Let the slaughter commence!"
        [/message]
    [/event]

    {ELYNIA_1ST_TIME_HELP}

    [event]
        name=turn 2

        [message]
            speaker=Alazar
            message= _ "Your doom is at hand, dwarf king! If you surrender now, the Warlord might show some mercy and spare the lives of your underlings."
        [/message]

        [message]
            speaker=Wygerm
            message= _ "We’ll rip you to pieces if you don’t accept the offer!"
        [/message]

        [message]
            speaker=King Asthorgar
            message= _ "We’ll never surrender to ye and yer loathsome vermin! We shallna’ give our domain to those who kill everything in sight, dabble in the darkest of arts, and nae ken any diplomacy other than that done wi’ fire and swords! May Herthgar be destroyed and forgotten, but it shallna’ be remembered as a kingdom of cowards!"
        [/message]

        [message]
            speaker=Alazar
            message= _ "So be it! Your pride and arrogance has sealed your fate! Attack! Wipe these bearded children out of this place! For Uria! For the Empire!"
        [/message]

        [message]
            speaker=Oddis
            # po: The 'Blessed One' is Elynia.
            message= _ "Hey, it’s the pointy-eared rats of the forest! And they made it back with the Blessed One!"
        [/message]

        [message]
            speaker=Gythrn
            message= _ "It matters not. We shall flood the caverns with the elves’ blood, and bring that creature to the Warlord."
        [/message]

        [message]
            speaker=Oddis
            message= _ "Aye."
        [/message]

        [message]
            speaker=Alazar
            message= _ "Aye."
        [/message]

        [message]
            speaker="Armiza'ar"
            message= _ "Aye!"
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "So annoying."
        [/message]
    [/event]

    [event]
        name=turn 3

        [message]
            speaker=Mal Keshar
            message= _ "If I might make a suggestion — using the corpses of the fallen as a barrier could delay our enemies enough to let our best warriors do their duty from safe positions."
        [/message]

        [message]
            speaker=Galas
            message= _ "The idea sickens me; many of the corpses will be those of our kinsmen. But... I have to admit it’s an option."
        [/message]
    [/event]

    #
    # Short dialog between Elynia and Mal Keshar, takes place mid-fight.
    #

    [event]
        id=elynia_malin_dialog_controller
        name=attack
        first_time_only=no
        [filter]
            id=Elynia,Mal Keshar
        [/filter]

        [if]
            [have_unit]
                x,y=$x1,$y1
                id=Elynia
            [/have_unit]
            [then]
                {VARIABLE_INC elynia_attacks}
            [/then]
            [else]
                {VARIABLE_INC malin_attacks}
            [/else]
        [/if]

        [if]
            {VARIABLE_NUMERICAL_GREATER_THAN malin_attacks  2}
            {VARIABLE_NUMERICAL_GREATER_THAN elynia_attacks 3}
            [then]
                [message]
                    speaker=Elynia
                    message= _ "Why are you even fighting alongside us, lich? Are the struggles of my people entertaining to you?"
                [/message]

                [event]
                    name=attack end

                    [message]
                        speaker=Elynia
                        message= _ "Or perhaps you seek redemption? But I find that unlikely."
                    [/message]

                    [message]
                        speaker=Mal Keshar
                        message= _ "Why do you want to know?"
                    [/message]

                    [message]
                        speaker=Elynia
                        message= _ "Lord Galas and Anlindë seem to consider you an equal, but in truth you are a menace to our lifestyle. Your mere existence would not have been tolerated in the past — and surely you remember that I was once charged with the task of destroying you..."
                    [/message]

                    [message]
                        speaker=Mal Keshar
                        message= _ "The angry assailants over there seem really interested in chopping off your head, you know. Shouldn’t you focus on the mission at hand instead of blabbering about your precious past like an elderly lady?"
                    [/message]

                    [scroll_to]
                        x,y=$x1,$y1
                    [/scroll_to]
                [/event]

                # Self-destruct
                [remove_event]
                    id=elynia_malin_dialog_controller
                [/remove_event]
            [/then]
        [/if]
    [/event]

    [event]
        name=turn 6,turn 14
        first_time_only=no

        {ADD_GOLD 3 25 40 60}

        {ADD_GOLD 5 25 40 60}

        {ADD_GOLD 6 25 40 60}

        {ADD_GOLD 7 25 40 60}

        {ADD_GOLD 9 25 40 60}
    [/event]

    [event]
        name=turn 8

        [message]
            speaker=Mal Keshar
            message= _ "What is it with these demons and their endless numbers?"
        [/message]
    [/event]

    [event]
        name=turn 14
        [filter_condition]
            [have_unit]
                count=4-99999 # count > 3
                canrecruit=yes
                [filter_side]
                    [enemy_of]
                        side=1
                    [/enemy_of]
                [/filter_side]
            [/have_unit]
        [/filter_condition]

        [message]
            speaker=Galas
            message= _ "We must persevere. We cannot lose this battle!"
        [/message]
    [/event]

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

        [message]
            speaker=Denathor
            message= _ "Forgive me, my King..."
        [/message]
    [/event]

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

        [message]
            speaker=Furin
            message= _ "Y’may take me down, but me’ brethren’s hearts still stand!" # wmllint: no spellcheck
        [/message]
    [/event]

    [event]
        name=last breath
        [filter]
            id="Armiza'ar"
        [/filter]

        [message]
            speaker="Armiza'ar"
            message= _ "A curse upon you, heretics!"
        [/message]
    [/event]

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

        [message]
            speaker=Oddis
            message= _ "May Yechnagoth swallow your souls!"
        [/message]

        [message]
            x,y=$x2,$y2
            [not]
                race=undead,bats
                [not]
                    type=Lich,Ancient Lich,Ghost,Wraith,Spectre,Shadow,Nightgaunt
                [/not]
            [/not]
            [or]
                id=Mal Keshar
            [/or]
            message= _ "Yechnagoth is long gone, you fool!"
        [/message]
    [/event]

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

        [message]
            speaker=unit
            message= _ "I shall be avenged!"
        [/message]
    [/event]

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

        [message]
            speaker=unit
            message= _ "Today, you might win the battle, but you will never win the war!"
        [/message]
    [/event]

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

        [message]
            speaker=unit
            message= _ "<i>Ack!</i> Your efforts are in vain — you’re just delaying the inevitable!"
        [/message]
    [/event]

    [event]
        name=enemies defeated

        [message]
            speaker=Galas
            message= _ "At last, we have defeated them! They are retreating!"
        [/message]

        [message]
            speaker=Althurin
            message= _ "No, lad — I reckon they are preparin’ to retaliate. The way they fight, I doubt we’ve even seen a hair o’ their assault force."
        [/message]

        {ENDLEVEL_VICTORY_NO_GOLD_CARRYOVER}
    [/event]

    [event]
        name=time over

        [message]
            canrecruit=yes
            [filter_side]
                [enemy_of]
                    side=1
                [/enemy_of]
            [/filter_side]
            message= _ "These persistent earthworms won’t forfeit as easily as the other clans did, it seems. Time to execute the backup plan, everyone! Retreat!"
        [/message]

        [message]
            speaker=Galas
            message= _ "The enemy troops are retreating!"
        [/message]

        [message]
            speaker=Althurin
            message= _ "’Tis doesn’t sound good, lad. They must be preparin’ to retaliate. The way they fight, I doubt we’ve even seen a hair o’ their assault force."
        [/message]

        {ENDLEVEL_VICTORY_NO_GOLD_CARRYOVER}
    [/event]

    [event]
        name=victory

        [message]
            speaker=King Asthorgar
            message= _ "I ha’ to admit that we gravely underestimated the threat posed by the Chaos Empire. Our losses ha’ been too great... <i>(sighs)</i> At this point, I say we must leave. Mayhap our kin to the northwest would allow us to regroup there."
        [/message]

        [message]
            speaker=Anlindë
            message= _ "So, Herthgar has fallen."
        [/message]

        [message]
            speaker=King Asthorgar
            message= _ "Dinnae say that! Sure, our home ha’ fallen, but Herthgar is more than just stone and marble. We’ll figure out something later. And as much as it troubles me to think about it, the northern humans will ha’ to deal with these bloodthirsty barbarians somehow. I ken that will be their next move, aye."
        [/message]

        [message]
            speaker=Galas
            message= _ "Most of our people went north. It is worrying that we haven’t heard anything of them ever since we parted ways, but assuming that nothing bad has occurred to them, we need to warn them of this development, quickly."
        [/message]

        [message]
            speaker=Elynia
            message= _ "How prepared are the northerners to deal with an invasion from the Chaos Empire, King Asthorgar? Do you think they would be able to defend the Far North with the elves’ and dwarves’ aid?"
        [/message]

        [message]
            speaker=King Asthorgar
            message= _ "Dwarves, elves, and humans united under a single banner? I find that highly improbable, lass! I ken it ha’ been thousands o’ years since the last alliance, and it didna’ turn out very well in the end. And in any case, we ha’ our own battles to fight here. I ken the humans will do well on their own as long as they arena’ caught unprepared, but... <i>(shrugs)</i>"
        [/message]

        [message]
            speaker=Galas
            message= _ "We will warn them and seek their help regardless. We can’t keep running away from the enemy like rats; there <i>has</i> to be some way to stop them before there is no more land left on the continent for us."
        [/message]

        [message]
            speaker=Althurin
            message= _ "My king, d’ye really think we can vacate Herthgar before the demons return?"
        [/message]

        [message]
            speaker=King Asthorgar
            message= _ "We must at least try — I fear we dinna’ have a choice at this point."
        [/message]

        [message]
            speaker=Anlindë
            message= _ "King, if you attempt to evacuate, it is quite likely that the enemy forces will manage to sneak up on your people from behind and perpetrate yet another slaughter. But there is a simple solution to this quandary — I believe Mal Keshar could lend me his minions to aid in setting up an ambush to keep the enemy from advancing."
        [/message]

        [fade_out_music][/fade_out_music]

        [message]
            speaker=Galas
            message= _ "What? But... Anlindë, you can’t possibly fend off those fiends alone! Odds are... you won’t be able to get back to us. Don’t do the same as Lord Lédinor... please..."
        [/message]

        [message]
            speaker=Anlindë
            message= _ "Our Lady of Light once said that there things more important in this world than the lives of the few. For me, the safety of our people is far more important than my own, and as you already know, I have a debt to repay. Our past will never cease to haunt me, and I certainly will never be able to repair the great damage we caused back then; but if I am going to die, I would prefer it to be for your sake."
        [/message]

        [message]
            speaker=Anlindë
            message= _ "If the circumstances hadn’t conspired against it, I would have done it back in the Valley instead of Lédinor, but you were too young, and I first had to make sure you were ready. Since then, you have proven yourself to be a fierce warrior and a capable leader, Galas; I’m proud of you."
        [/message]

        [message]
            speaker=Galas
            message= _ "This is insane! What purpose does it serve to throw your life away like this?! Let Mal Keshar dispatch his minions; there is absolutely no need for you to get involved—"
        [/message]

        [message]
            speaker=Anlindë
            message= _ "And leave them to be quickly disposed of by the enemy? We cannot afford such a risk right now, Galas! Your survival... you are far more important! There is a much greater foe hiding in these caves, and sooner or later he will catch up with us, and Elynia is in no condition to fight anyone."
        [/message]

        [message]
            speaker=Elynia
            message= _ "What? But I—"
        [/message]

        [message]
            speaker=Anlindë
            message= _ "I have seen your performance in this battle, my lady, and I regret saying this but... I saw you do far better in Wesmere. It’s plainly evident that you have been dormant for too long."
        [/message]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Elynia
            message= _ "About my words... it is not necessary to take them to heart. Anlindë, we will need all available spellcasters on the front line if our plans come to fruition. The ill-gotten power you wield is far superior than the norm for our kin, and combined with the might of the undead, it could offer us an unprecedented tactical advantage. How may I persuade you to reconsider?"
        [/message]

        [message]
            speaker=Anlindë
            message= _ "You cannot. I feel that my mission and my fate lies here, in the very heart of Irdya. Allow me to protect elvenkind a last time, my lady; I shall obliterate every demon, every cultist, and every dark soldier who dares to approach this keep; and even if it is to be with my dying breath, I shall vanquish their Warlord, and turn fate in our favor."
        [/message]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Galas
            message= _ "You have lived for so long, and you have seen so much, so many things that were never even recorded in books... I don’t understand why... why do you want it to end like this?"
        [/message]

        [message]
            speaker=Anlindë
            message= _ "Picture living for thousands of years knowing it was only made possible by the suffering and death of millions of innocent souls. Eternal life becomes a disillusioning burden as time passes by and you see... you see everything turn to dust. And then your memories begin to fade away as well... You eventually forget all positive experiences and can only recall the horrors that haunt you in your sleep."
        [/message]

        [message]
            speaker=Anlindë
            message= _ "At least none of you will have to live with the knowledge that you were accomplices of the evil that brought elvenkind to its knees."
        [/message]

        [delay]
            time=1500
        [/delay]

        [message]
            speaker=Elynia
            message= _ "So be it. Your sacrifice won’t be forgotten, and I swear that I will not rest until the last of our enemies is reduced to cinders on the ground. May the Lords of Light guide you in your last mission."
        [/message]

        #
        # Switch Asthorgar to side 1, preserving any XP he might have gained
        # during this scenario.
        #

        [store_unit]
            [filter]
                id=King Asthorgar
            [/filter]
            variable=asthorgar_store
        [/store_unit]

        [set_variables]
            name=asthorgar_store
            mode=merge
            [literal]
                side=1
                canrecruit=no
                {IS_HERO}
                upkeep=free
            [/literal]
        [/set_variables]

        [set_variables]
            name=temp_loyal_trait_data
            mode=replace
            [literal]
                {TRAIT_LOYAL}
            [/literal]
        [/set_variables]

        [set_variables]
            name=asthorgar_store.modifications.trait
            mode=insert
            to_variable=temp_loyal_trait_data.trait
        [/set_variables]

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

        {CLEAR_VARIABLE elynia_attacks,malin_attacks,asthorgar_store,temp_loyal_trait_data}
    [/event]
[/scenario]

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


#textdomain wesnoth-Invasion_from_the_Unknown

[scenario]
    id=12x_Outside
    name= _ "Outside"
    {MAP 12x_Outside.map}
    turns=-1
    next_scenario=13_Face_your_Fate
    victory_when_enemies_defeated=no

    {FULLSCREEN_CUTSCENE_UI}

    {SCENARIO_MUSIC "revelation.ogg"}

    {DAWN1}

    # 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]
    # wmllint: validate-on

#define O_STORE_AND_SET_POS _ID _STORE _X _Y
    [store_unit]
        [filter]
            id={_ID}
        [/filter]
        variable={_STORE}
        kill=yes
    [/store_unit]

    {VARIABLE {_STORE}+".x" {_X} }
    {VARIABLE {_STORE}+".y" {_Y} }
#enddef

    [event]
        name=prestart

        # wmllint: recognize Elynia
        {RECALL_ELYNIA_AT 19 15}
        # wmllint: recognize Mal Keshar
        {RECALL_MAL_KESHAR_AT 21 15}

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

        {VARIABLE muf_galas_store.x 20}
        {VARIABLE muf_galas_store.y 14}

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

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

        [store_starting_location]
            side=1
        [/store_starting_location]

        {LOCK_VIEW}
    [/event]

    [event]
        name=start

        [delay]
            time=1000
        [/delay]

        [move_unit_fake]
            x=$location.x,$muf_galas_store.x
            y=$location.y,$muf_galas_store.y
            side=1
            type=$muf_galas_store.type
        [/move_unit_fake]

        [unstore_unit]
            variable=muf_galas_store
        [/unstore_unit]

        [redraw][/redraw]

        [move_unit_fake]
            x="$location.x,$muf_galas_store.x,$muf_elynia_store.x"
            y="$location.y,$($muf_galas_store.y + 2),$muf_elynia_store.y"
            side=1
            type=$muf_elynia_store.type
        [/move_unit_fake]

        [unstore_unit]
            variable=muf_elynia_store
        [/unstore_unit]

        [redraw][/redraw]

        [move_unit_fake]
            x="$location.x,$muf_galas_store.x,$muf_malin_store.x"
            y="$location.y,$($muf_galas_store.y + 2),$muf_malin_store.y"
            side=1
            type=$muf_malin_store.type
        [/move_unit_fake]

        [unstore_unit]
            variable=muf_malin_store
        [/unstore_unit]

        {CLEAR_VARIABLE muf_galas_store,muf_elynia_store,muf_malin_store,location}

        #
        # Dialogue starts
        #

        [redraw][/redraw]

        [delay]
            time=2000
        [/delay]

        [message]
            speaker=Galas
            message= _ "We made it! And there are no signs of demons."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Ah, I can feel the wind in my hair again... It is cold, but it’s a refreshing change from the stale air of the deep caverns."
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "You know, returning to the surface doesn’t seem all that great to me, but at least it’s not the desert."
        [/message]

        [message]
            speaker=Galas
            message= _ "I wish Anlindë was here with us to breathe the fresh air and contemplate the beautiful landscape."
        [/message]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Elynia
            message= _ "So do I."
        [/message]

        [delay]
            time=1000
        [/delay]

        [hide_unit][/hide_unit]

        {FADE_TO_BLACK}

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

        [place_shroud]
            side=1
        [/place_shroud]

        [redraw][/redraw]

        [delay]
            time=250
        [/delay]

        [message]
            speaker=narrator
            image=wesnoth-icon.png
            message= _ "And so, Galas and his band left the dark caves beneath the Heart Mountains for the northern lands. After making sure that there were no foes in sight, they signaled the rest of their group to emerge from the caverns.

The fate of Anlindë was to remain uncertain to all of them. But this did not deter other elves and dwarves from telling legends of her last battle against Chaos. Her courage and resolve would be remembered by many for generations to come; and in time, the dwarves of Herthgar would build a gleaming silver temple to pay tribute to her great sacrifice."
        [/message]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Elynia
            message= _ "May your soul find peace, Anlindë."
        [/message]

        [fade_out_music]
            duration=2000
        [/fade_out_music]

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

#undef O_STORE_AND_SET_POS

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