#textdomain wesnoth-Invasion_from_the_Unknown

[scenario]
    id=10x_Elynia
    name= _ "Elynia"
    {MAP 10x_Elynia.map}
    turns=-1
    next_scenario=10y_The_Fall
    victory_when_enemies_defeated=no

    {NO_RECALLS}

    {SCENARIO_MUSIC "underground.ogg"}

    {DEEP_UNDERGROUND}

    {STORYTXT_ELYNIA}

    # Nobody can die in this scenario.

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

        shroud=yes

        gold=0
        {NO_INCOME}

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

    [side]
        side=2
        controller=null
        team_name=enemies
        color=red

        no_leader=yes
        hidden=yes

        {NO_ECONOMY}
    [/side]

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

    {CAVE_WATER_SOUND_SOURCE 31 32}
    [+sound_source]
        id=cave_water_drip # wmllint: ignore
    [/sound_source]

#define LOL_SET_OBJECTIVES _ADDITIONAL_OBJECTIVES
    {OBJECTIVES (
        victory_string= _ "Current Objectives:"
        {_ADDITIONAL_OBJECTIVES}
        {OBJECTIVE_VICTORY ( _ "Find the Lady of Light and the Master of Darkness")}

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

        {OBJECTIVE_CARRYOVER}
    )}
#enddef

    {PLACE_IMAGE items/barrel.png           23 29}
    {PLACE_IMAGE items/stone-tablet.png     26 28}
    {PLACE_IMAGE items/chest-plain-open.png 31 29}
    {PLACE_IMAGE "items/bones.png~FL()"     33 31}

    [event]
        name=prestart

        [store_starting_location]
            side=2
            variable=elynia_loc
        [/store_starting_location]

        [set_variables]
            # We'll need this in the next scenario.
            name=e1s10x_state.time_area
            mode=replace
            [value]
                id=tree_chamber # wmllint: ignore
                {ILLUMINATED_UNDERGROUND}
                x,y=$elynia_loc.x,$elynia_loc.y
                radius={INFINITY}
                [filter_radius]
                    # Extend across passable terrains (or terrains with impassable
                    # overlays, those don't really matter and look better with the
                    # same lighting as the surrounding terrains).
                    terrain=!,X*
                    [or]
                        # Also extend to impassable terrains adjacent to passable
                        # (the shroud radius 1 issue), otherwise cave walls appear
                        # with different lighting settings than the surrounding
                        # non-wall terrains.
                        [filter_adjacent_location]
                            terrain=!,X*
                        [/filter_adjacent_location]
                    [/or]
                    # Don't extend past y = 25.
                    [and]
                        x=0-999
                        y=0-25
                    [/and]
                [/filter_radius]
            [/value]
        [/set_variables]

        [insert_tag]
            name=time_area
            variable=e1s10x_state.time_area
        [/insert_tag]

        [store_side]
            side=1
            variable=side1_params
        [/store_side]

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

        {REMOVE_RECRUIT_LIST 1}

        #
        # Recall heroes
        #

        # wmllint: recognize Anlindë
        {RECALL_ANLINDE_AT    34 35}
        # wmllint: recognize Mal Keshar
        {RECALL_MAL_KESHAR_AT 33 36}
        # wmllint: recognize Althurin
        {RECALL_ALTHURIN_AT   35 35}
        # wmllint: recognize Unarye
        {RECALL_UNARYE_AT     35 37}

        {FACE_DIRECTION side=1 nw}

        {LOL_SET_OBJECTIVES ()}
    [/event]

    [event]
        name=start

        {LOCK_VIEW}

        [message]
            speaker=Galas
            message= _ "Well, here we are. I guess I was wrong to expect our heroes to be sleeping right by the entrance."
        [/message]

        [message]
            speaker=Althurin
            message= _ "Whoah, this place is much larger on the inside!"
        [/message]

        {IF_HAVE_IGOR (
            [fire_event]
                name=igor enters
            [/fire_event]
        )}

        [message]
            speaker=Unarye
            message= _ "This is... I can’t believe I— we are about to meet one of our ancestors and her human companion, in life! I wonder what they look like?"
        [/message]

        [message]
            speaker=Galas
            message= _ "I imagine they look like every other elf or human sorcerer, just... much more powerful, and maybe even terrifying?"
        [/message]

        {UNLOCK_VIEW}
    [/event]

    [event]
        name=igor enters

        [message]
            speaker=Unarye
            sound=human-female-hit-1.ogg
            message= _ "OW!"
        [/message]

        {FACE_DIRECTION id=Unarye se}

        [delay]
            time=250
        [/delay]

        {FACE_DIRECTION (id=Mal Keshar) se}

        [message]
            speaker=Mal Keshar
            message= _ "Huh?"
        [/message]

        {FACE_DIRECTION id=Galas se}

        [delay]
            time=500
        [/delay]

        [message]
            speaker=Unarye
            message= _ "Someone bumped into me!"
        [/message]

        [message]
            speaker=Galas
            message= _ "Who is there?!"
        [/message]

        {FACE_DIRECTION side=1 se}

        [delay]
            time=750
        [/delay]

        [recall]
            id=Igor
            x,y=35,38
            show=yes
        [/recall]

        [message]
            speaker=Igor
            message= _ "Sorry! I saw you coming into this temple and I thought... well, the other elves scare me, and you saved me from the undead back there, so..."
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Begone, goblin! This is no place for such a lowly creature like you!"
        [/message]

        [message]
            speaker=Anlindë
            message= _ "Oh, he can come with us. I am sure the Lady of Light will not mind the intrusion of a goblin and his pet wolf considering the... circumstances. (glares at Mal Keshar)"
        [/message]

        {FACE_DIRECTION id=Anlindë nw}

        [delay]
            time=250
        [/delay]

        [message]
            speaker=Igor
            message= _ "Oh, many thanks, my lady! I had never been treated so well by non-goblins! Many thanks!"
        [/message]

        {FACE_DIRECTION (id=Mal Keshar) nw}

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Mal Keshar
            message= _ "(grumble, grumble)"
        [/message]

        {FACE_DIRECTION side=1 nw}
    [/event]

    [event]
        name=DEBUG1

        [teleport]
            [filter]
                id=Galas
            [/filter]
            x,y=25,29
        [/teleport]

        [teleport]
            [filter]
                id=Anlindë
            [/filter]
            x,y=25,28
        [/teleport]

        [fire_event]
            name=chamber entry cutscene
        [/fire_event]
    [/event]

    [event]
        name=DEBUG2

        {CLEAR_CAVE_SHROUD area=tree_chamber}

        [fire_event]
            name=set up courtyard units
        [/fire_event]

        [fire_event]
            name=elynia cutscene 1
        [/fire_event]
    [/event]

    [event]
        name=moveto
        [filter]
            side=1
        [/filter]
        [filter_condition]
            [have_location]
                terrain=*^Pr\,*^Pr/
                [filter_vision]
                    side=1
                [/filter_vision]
            [/have_location]
        [/filter_condition]

        [allow_undo][/allow_undo]

        [remove_shroud]
            side=1
            x,y,radius=25,27,1
            [or]
                x,y,radius=27,28,1
            [/or]
        [/remove_shroud]

        [redraw]
            side=1
        [/redraw]

        [scroll_to]
            x,y=26,27
        [/scroll_to]

        {HIGHLIGHT_GOAL terrain=*^Pr\,*^Pr/}

        [message]
            speaker=Galas
            message= _ "We should be wary of any traps or enchantments set up to protect our heroes from hostile outsiders. Anlindë, could you inspect that gate?"
        [/message]

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

        {LOL_SET_OBJECTIVES ({OBJECTIVE_VICTORY ( _ "Move Anlindë next to the gate")})}

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

    [event]
        name=moveto
        [filter]
            side=1
            x,y=33,31
        [/filter]

        [allow_undo][/allow_undo]

        [message]
            speaker=unit
            message= _ "These bones appear to have belonged to a dwarf."
        [/message]
    [/event]

    [event]
        name=moveto
        [filter]
            side=1
            x,y=31,29
        [/filter]

        [allow_undo][/allow_undo]

        [message]
            speaker=unit
            message= _ "The chest is empty."
        [/message]
    [/event]

    [event]
        name=moveto
        [filter]
            side=1
            x,y=23,29
        [/filter]

        [allow_undo][/allow_undo]

        [message]
            speaker=unit
            message= _ "Nothing but bugs and dust in this barrel."
        [/message]
    [/event]

    [event]
        name=moveto
        [filter]
            id=Anlindë
            [filter_location]
                [filter_adjacent_location]
                    terrain=*^Pr\,*^Pr/
                [/filter_adjacent_location]
            [/filter_location]
        [/filter]

        [fire_event]
            name=chamber entry cutscene
        [/fire_event]
    [/event]

    #
    # Functional event used for forest spirits attacking Galas et al.
    #
    # spirit_locs must be set beforehand.
    #
    [event]
        name=chamber spirits closing in
        first_time_only=no

        [foreach]
            array=spirit_locs
            [do]
                [store_direction]
                    from_x,from_y=$this_item.x,$this_item.y
                    [to]
                        [filter]
                            id=Galas
                        [/filter]
                    [/to]
                [/store_direction]

                [store_locations]
                    [filter_adjacent_location]
                        x,y=$this_item.x,$this_item.y
                        adjacent=-$direction
                    [/filter_adjacent_location]
                    variable=location
                [/store_locations]

                [move_unit]
                    x,y=$this_item.x,$this_item.y
                    to_x,to_y=$location.x,$location.y
                [/move_unit]
            [/do]
        [/foreach]

        {CLEAR_VARIABLE location}
    [/event]

#define LOL_SPIRITS_CLOSING_IN
    [fire_event]
        name=chamber spirits closing in
    [/fire_event]
#enddef

    #
    # Functional event used during the first cutscene segment and in some debug
    # mode skips.
    #
    [event]
        name=set up courtyard units

        [teleport]
            [filter]
                id=Galas
            [/filter]
            x,y=28,19
        [/teleport]

        [teleport]
            [filter]
                id=Anlindë
            [/filter]
            x,y=28,18
        [/teleport]

        [teleport]
            [filter]
                id=Mal Keshar
            [/filter]
            x,y=28,20
        [/teleport]

        [teleport]
            [filter]
                id=Unarye
            [/filter]
            x,y=29,19
        [/teleport]

        [teleport]
            [filter]
                id=Althurin
            [/filter]
            x,y=27,19
        [/teleport]

        {IF_HAVE_IGOR (
            [teleport]
                [filter]
                    id=Igor
                [/filter]
                x,y=28,21
            [/teleport]
        )}

        {FACE_LOCATION side=1 x,y=$elynia_loc.x,$elynia_loc.y}

        [scroll_to_unit]
            id=Galas
        [/scroll_to_unit]
    [/event]

    [event]
        name=chamber entry cutscene

        {LOCK_VIEW}

        [fade_out_music]
            duration=500
        [/fade_out_music]

        [message]
            speaker=Anlindë
            message= _ "There is a stone tablet nearby."
        [/message]

        [message]
            speaker=Anlindë
            message=""+_"“Here in this chamber lies the slayer of the Demon Lord, Protector of the Elves of Irdya, wielder of the Power of the Union: Elynia, the Lady of Light. Only those born of Faerie and the sacred earth of Irdya shall be allowed within her resting place. May her eternal sleep end once the wounds inflicted upon Irdya have healed.”"+""
        [/message]

        [message]
            speaker=Anlindë
            message= _ "There doesn’t seem to be anything else special about this gate. (aside) Why does it only mention her..."
        [/message]

        [message]
            speaker=Galas
            message= _ "I believe we fit the description, but I am unsure about the healing part. Still, we have faced all kinds of trials and braved numerous dangers to get here — there is no turning back now. Onwards!"
        [/message]

        [remove_terrain_overlays]
            terrain=*^Pr\,*^Pr/
        [/remove_terrain_overlays]

        [sound]
            name=gate-fall.ogg
        [/sound]

        [redraw]
            side=1
        [/redraw]

        {MOVE_UNIT id=Anlindë 28 24}
        {MOVE_UNIT id=Galas   28 25}

        {CLEAR_CAVE_SHROUD area=tree_chamber}

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

        [message]
            speaker=narrator
            image=wesnoth-icon.png
            message= _ "The group entered a massive chamber at the center of the underground temple. The place was abundantly illuminated through openings in the tall ceiling, rendering their torches and magic pointless. The whole chamber appeared to have been built not by an ancient civilization, but by the earth itself. Standing out amidst the chamber was a lush courtyard enclosed by five trees in a geometric arrangement, with a sixth tree in the middle of all.

An eerie gust of wind from the deep abyss below extinguished the fires as though intent on protecting the secret sanctuary from harm."
        [/message]

        [fire_event]
            name=set up courtyard units
        [/fire_event]

        #
        # Remove sound sources.
        #

        [fade_out_sound_effects]
            duration=750
        [/fade_out_sound_effects]

        {REMOVE_SOUND_SOURCE cave_ambience,cave_water_drip}

        [reset_sound_effects][/reset_sound_effects]

        [message]
            speaker=Mal Keshar
            message= _ "Hello there! Anybody at home?"
        [/message]

        {REPLACE_SCENARIO_MUSIC heroes_rite.ogg}

        [message]
            speaker=Galas
            message= _ "... There is no-one here. But... how? Did we arrive too late?"
        [/message]

        [store_locations]
            terrain=*^Fet
            [not]
                x,y=$elynia_loc.x,$elynia_loc.y
            [/not]
            variable=spirit_locs
        [/store_locations]

        [foreach]
            array=spirit_locs
            [do]
                [store_direction]
                    from_x,from_y=$this_item.x,$this_item.y
                    [to]
                        [filter]
                            id=Galas
                        [/filter]
                    [/to]
                [/store_direction]

                [terrain]
                    terrain=^Fetd
                    layer=overlay
                    x,y=$this_item.x,$this_item.y
                [/terrain]

                [sound]
                    name=wail.wav,wail-sml.wav
                [/sound]

                [redraw][/redraw]

                [delay]
                    time=100
                [/delay]

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

                [redraw][/redraw]

                [unit]
                    animate=yes
                    side=2
                    type=Faerie Spirit
                    facing=$direction
                    x,y=$this_item.x,$this_item.y
                    generate_name=no
                    random_traits=no
                    [modifications]
                        [object]
                            [effect]
                                apply_to="image_mod"
                                add="PAL(faerie_spirit_hair_leaves_green>faerie_spirit_hair_leaves_decay)~PAL(faerie_spirit_skin_green>faerie_spirit_skin_decay)"
                            [/effect]
                        [/object]
                    [/modifications]
                [/unit]
            [/do]
        [/foreach]

        [role]
            role=spirit1
            type=Faerie Spirit
        [/role]

        [role]
            role=spirit2
            type=Faerie Spirit
            [not]
                role=spirit1
            [/not]
        [/role]

        [role]
            role=spirit3
            type=Faerie Spirit
            [not]
                role=spirit1
            [/not]
            [not]
                role=spirit2
            [/not]
        [/role]

        [message]
            role=spirit3
            message=""+_"Kill the intruders."+""
        [/message]

        {LOL_SPIRITS_CLOSING_IN}

        [message]
            speaker=Anlindë
            message= _ "We are the Forest Elves of the Valley of Elynia! You must let us pass!"
        [/message]

        [message]
            role=spirit1
            message=""+_"Protect the Lady of Light."+""
        [/message]

        #
        # At this point two of the spirits will be adjacent to player units,
        # those cannot be moved any closer.
        #

        [store_locations]
            [filter]
                type=Faerie Spirit
                [not]
                    [filter_adjacent]
                        side=1
                    [/filter_adjacent]
                [/not]
            [/filter]
            variable=spirit_locs
        [/store_locations]

        {LOL_SPIRITS_CLOSING_IN}

        {IF_HAVE_IGOR (
            [message]
                speaker=Igor
                message= _ "Aieee! They’re gonna kill us!" # wmllint: no spellcheck
            [/message]
        )}

        [message]
            speaker=Mal Keshar
            message= _ "Enough of this nonsense!"
        [/message]

        {THUNDER (
            [teleport]
                [filter]
                    id=Mal Keshar
                [/filter]
                x,y=$elynia_loc.x,"$($elynia_loc.y + 1)"
            [/teleport]

            {FACE_DIRECTION (id=Mal Keshar) nw}

            {FACE_UNIT (type=Faerie Spirit) (id=Mal Keshar)}
        )}

        [delay]
            time=250
        [/delay]

        [message]
            speaker=Anlindë
            message= _ "Malin Keshar! What do you think you are doing?!"
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Something I should have done long ago! Unto me, whip of the Dark Gods!"
        [/message]

        {CLEAR_VARIABLE spirit_locs}

        [fire_event]
            name=elynia cutscene 1
        [/fire_event]
    [/event]

    [event]
        name=elynia cutscene 1

        [hide_unit][/hide_unit]

        {REPLACE_SCENARIO_MUSIC silence.ogg}

        [sound]
            name=magic-dark-big.ogg
        [/sound]

        {WHITE_SCREEN}

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

        [delay]
            time=250
        [/delay]

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

        [delay]
            time=250
        [/delay]

        [sound]
            name={SOUND_LIST:ELF_FEMALE_HIT}
        [/sound]

        [kill]
            type=Faerie Spirit
        [/kill]

        [terrain]
            x,y=$elynia_loc.x,$elynia_loc.y
            terrain=^Fetd
            layer=overlay
        [/terrain]

        [redraw][/redraw]

        [delay]
            time=250
        [/delay]

        {RESET_SCREEN}

        [unhide_unit][/unhide_unit]

        [delay]
            time=750
        [/delay]

        {FACE_DIRECTION (id=Mal Keshar) se}

        [delay]
            time=250
        [/delay]

        [terrain]
            x,y=$elynia_loc.x,$elynia_loc.y
            terrain=^Efm
            layer=overlay
        [/terrain]

        [redraw][/redraw]

        {MOVE_UNIT (id=Mal Keshar) 27 18}

        {FACE_DIRECTION (id=Mal Keshar) ne}

        [message]
            speaker=Mal Keshar
            message= _ "No need to thank me. Behold!"
        [/message]

        [delay]
            time=750
        [/delay]

        #
        # FIXME: images
        #

        {MOVE_UNIT (id=Galas) $elynia_loc.x "$($elynia_loc.y + 1)"}

        {REPLACE_SCENARIO_MUSIC traveling_minstrels.ogg}

        [message]
            speaker=narrator
            image=wesnoth-icon.png
            message= _ "On the ground where the white tree at the center of the chamber stood moments before, now lay a beautiful elven lady."
        [/message]

        [message]
            speaker=narrator
            image=wesnoth-icon.png
            message= _ "In a previous age when Irdya was green and wide, anyone who glanced at her radiant pale skin and glistening faerie wings would have been able to discern her identity without a second thought. Even as she slept, her strong bond with the essence of Light illuminated her surroundings and protected her from harm.

The legends told of the lavender-haired heroine of the elves and lauded her everlasting grace and splendor, but Galas never imagined the truth could possibly surpass the historical accounts; neither did he imagine how it would render him completely dumbstruck, unable to greet her as it was required of him as lord of the Elves."
        [/message]

        [message]
            speaker=Galas
            # po: "beautiful"
            message= _ "She is..."
        [/message]

        [message]
            speaker=Anlindë
            message= _ "Come forth, Light of the First Gods! Awaken your blessed emissary from her millennial sleep!"
        [/message]

        {FLASH_WHITE (
            [sound]
                name=magic-holy-2.ogg
            [/sound]
        )}

        [delay]
            time=250
        [/delay]

        [unit]
            # wmllint: recognize Elynia
            {CHARACTER_STATS_ELYNIA}
            animate=yes
            x,y=$elynia_loc.x,$elynia_loc.y
            facing=se
            side=2
        [/unit]

        [delay]
            time=2000
        [/delay]

        [message]
            speaker=Elynia
            message= _ "... Who has... awakened me?"
        [/message]

        [message]
            speaker=Anlindë
            message= _ "(points at Galas)"
        [/message]

        [message]
            speaker=Unarye
            message= _ "(points at Galas)"
        [/message]

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

        [message]
            speaker=Elynia
            message= _ "... Elves? Huh... I must be dreaming..."
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Actually, no, not at all."
        [/message]

        {FACE_UNIT id=Elynia (id=Mal Keshar)}

        [message]
            speaker=Elynia
            message= _ "Necromancer! Your kind is not welcome here! Say your last words!"
        [/message]

        [message]
            speaker=Galas
            message= _ "No, he doesn’t mean any harm, Lady Elynia! He is our ally!"
        [/message]

        {FACE_UNIT id=Elynia id=Galas}

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Elynia
            message= _ "Ally, you say? Who are you, strangers, and why have you come to interrupt my sleep?"
        [/message]

        [message]
            speaker=Galas
            message= _ "Right, right, I forgot to introduce ourselves. I am Lord Galas of the Elves of the Valley of Elynia, my lady, and these are Anlindë, my loyal advisor and leader of the Elven Council at Telchior’s Hold; Lady Unarye, High Sorceress of our people; Althurin, High Runemaster of the Dwarvish Kingdom of Herthgar; and this is—"
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Mal Keshar, the Harbinger of Dread — a title I just made up so I don’t seem out of place among those big names."
        [/message]

        [fade_out_music]
            duration=500
        [/fade_out_music]

        [message]
            speaker=Elynia
            message= _ "(appalled) I—"
        [/message]

        {IF_HAVE_IGOR (
            {MOVE_UNIT id=Igor 28 19}

            [message]
                speaker=Igor
                message= _ "And I’m Igor! But I fear I don’t have any titles or feats to brag about..."
            [/message]
        )}

        [message]
            speaker=Elynia
            message= _ "I mean, I appreciate that you would name a valley after me, but... Lord Galas, do you even realize that you are standing beside two criminals condemned by elvenkind? How could this depravity come to be?! Is this truly Telchior’s legacy?! How am I supposed to trust the elves of this time now?"
        [/message]

        [delay]
            time=750
        [/delay]

        {REPLACE_SCENARIO_MUSIC into_the_shadows.ogg}

        [message]
            speaker=Elynia
            message= _ "Because... I presume it has been long since the Fall, hasn’t it? And you are a descendant of Lord Telchior of Thelien, aren’t you, Lord Galas?"
        [/message]

        # wmllint: local spelling uhh

        [message]
            speaker=Galas
            message= _ "Uhh... perhaps? I beg your pardon, my lady, but the only person here whom I am aware has committed past crimes against elvenkind is Mal Keshar, and I have specifically allowed him amongst us so he could guide us to the Heart Mountains, and to you."
        [/message]

        [delay]
            time=750
        [/delay]

        [fire_event]
            name=elynia cutscene 2
        [/fire_event]
    [/event]

    [event]
        name=elynia cutscene 2

        [message]
            speaker=Elynia
            message= _ "So you were raised unaware of the most crucial chapter of your people’s history... That... actually makes sense. Why are you all here today?"
        [/message]

        [message]
            speaker=Anlindë
            message= _ "Because the demons have returned, my lady; this time in greater numbers, and backed by an empire established by the humans of the southern deserts during the last few centuries. They decimated our defenses, razed our lands, and slaughtered countless innocent civilians before we finally left our home to request help from you and the Master of Darkness... who... seems to be absent for some reason?"
        [/message]

        [delay]
            time=750
        [/delay]

        {MOVE_UNIT id=Elynia $elynia_loc.x "$($elynia_loc.y - 1)"}

        {FACE_DIRECTION id=Elynia nw}

        [message]
            speaker=narrator
            image=wesnoth-icon.png
            message= _ "The Lady of Light seemed suddenly distraught at Anlindë’s words. She breathed deeply and turned around, trying to avert the inquisitive glances, and remained silent for a moment..."
        [/message]

        [delay]
            time=750
        [/delay]

        {FACE_DIRECTION id=Elynia se}

        [delay]
            time=100
        [/delay]

        [message]
            speaker=narrator
            image=wesnoth-icon.png
            message= _ "And then, she turned around once again.

“Argan, the Master of Darkness, is dead.”"
        [/message]

        [delay]
            time=1000
        [/delay]

        [message]
            speaker=Anlindë
            message= _ "I... I never imagined—"
        [/message]

        [message]
            speaker=Elynia
            message= _ "It pains me to have to admit this truth to you... After our victory against the Demon Lord Zhangor in Wesmere, many elves — your ancestors, lord Galas — were convinced that we were like gods, immortal and invincible, the exclusive wielders of the only power that could rival the demon’s own. But it was only by sheer fortune that we survived that battle; and our lives, even though they truly exceed the norm of our kind in span, are as fragile as those of everyone else. We learned this the only possible way: by one of us dying."
        [/message]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Elynia
            message= _ "As to how it happened... (sighs) I suppose I might as well tell you of the world-changing events that led up to it. Our stories are more closely intertwined than you might suspect, lord Galas, and because our people have apparently forgotten the tragedies that befell us all at the end of times, I shall try my best to provide you with my own abridged account. You have to know the truth that Anlindë has kept from you for so long."
        [/message]

        [message]
            speaker=Elynia
            message= _ "But I must warn you: if the lorekeepers of elvenkind chose to not pass this knowledge on to you and your forefathers, it would be highly unwise of us to do otherwise now that our civilization is once again on the brink of extinction, and susceptible to the influence of demons hailing from Inferno."
        [/message]

        [modify_unit]
            [filter]
                id=Elynia
            [/filter]
            side=1
        [/modify_unit]

        [hide_unit][/hide_unit]

        {FADE_TO_BLACK}

        [store_shroud]
            side=1
            variable=e1s10x_state.shroud_mask
        [/store_shroud]

        [place_shroud]
            side=1
        [/place_shroud]

        [fade_out_music][/fade_out_music]

        [message]
            speaker=Elynia
            message= _ "Which is why all of you standing before me now are forever bound to keep this a secret. Sit down, and listen well..."
        [/message]

        [delay]
            time=750
        [/delay]

        {UNLOCK_VIEW}

        {ENDLEVEL_QUIET} {NO_REPLAY_SAVE}
    [/event]

    [event]
        name=victory

        #
        # All state needs to be transferred to the next scenario, which only
        # exists for the sake of working around the lack of scenario-mandated
        # save points.
        #
        # But before, we must pass some additional state to it (code
        # duplication across scenarios sucks!).
        #

        [store_time_of_day]
            variable=e1s10x_state.schedule
        [/store_time_of_day]

        [store_unit]
            [filter]
                side=1
                x,y=1-999,1-99
            [/filter]
            variable=e1s10x_state.units
            kill=yes
        [/store_unit]

        [save_map]
            variable=e1s10x_state.map
        [/save_map]

        # shroud map handled by the last cutscene segment.

        [store_items]
            variable=e1s10x_state.items
        [/store_items]
    [/event]
[/scenario]

#undef LOL_SET_OBJECTIVES
#undef LOL_SPIRITS_CLOSING_IN

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


#textdomain wesnoth-Invasion_from_the_Unknown

[scenario]
    id=10y_The_Fall
    name= _ "The Fall"
    {NO_MAP_DATA}
    turns=-1
    next_scenario=11_Strike_on_Herthgar
    victory_when_enemies_defeated=no

    #
    # This is somewhat of a tiny stub scenario using configuration carried
    # over from E1S10x using WML variables. The intention is to allow players
    # to replay the cutscene skipping to the historical part if they want. All
    # unit and map configuration is done dynamically. I suppose it might also
    # be of interest to aspiring advanced WML coders.
    #
    # The variables required from E1S10x are:
    #
    #   e1s10x_state
    #       Actual game, units, and gamemap state data.
    #   elynia_loc
    #       Used to avoid hardcoding Elynia's intended initial location
    #       everywhere.
    #   side1_params
    #       Partial side 1 gameplay state from E1S10x prestart including its
    #       recruit list and gold reserve, both of which are cleared for the
    #       duration of both E1S10x and E1S10y.
    #

    {NO_RECALLS}

    {FULLSCREEN_CUTSCENE_UI}

    {SCENARIO_MUSIC       "snowfall.ogg"}
    {EXTRA_SCENARIO_MUSIC "revelation.ogg"}
    {EXTRA_SCENARIO_MUSIC "nunc_dimittis.ogg"}

    {STORYTXT_THE_FALL}

    # Nobody can die in this scenario.

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

        shroud=yes

        gold=0
        {NO_INCOME}

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

    [event]
        name=prestart

        {DIE_ON (
            [not]
                {VARIABLE_ARRAY_NOT_EMPTY e1s10x_state}
                {VARIABLE_ARRAY_NOT_EMPTY elynia_loc}
                {VARIABLE_ARRAY_NOT_EMPTY side1_params}
            [/not]
        )
        ("E1S10x state store missing, did you use debug mode to skip scenarios?")}

        # Kill automatic leader placed by the engine at 1,1 because we killed
        # the real one in the last scenario.
        [kill]
            id=Galas
        [/kill]

        [load_map]
            variable=e1s10x_state.map
        [/load_map]

        [replace_schedule]
            [insert_tag]
                variable=e1s10x_state.schedule
                name=time
            [/insert_tag]
        [/replace_schedule]

        [insert_tag]
            name=time_area
            variable=e1s10x_state.time_area
        [/insert_tag]

        [foreach]
            array=e1s10x_state.items
            variable=item
            [do]
                [insert_tag]
                    variable=item
                    name=item
                [/insert_tag]
            [/do]
        [/foreach]

        [foreach]
            array=e1s10x_state.units
            variable=unit
            [do]
                [insert_tag]
                    variable=unit
                    name=unit
                [/insert_tag]
            [/do]
        [/foreach]

        # wmllint: recognize Elynia
        # wmllint: recognize Mal Keshar
        # wmllint: recognize Anlindë
        # wmllint: recognize Althurin
        # wmllint: recognize Unarye
        # wmllint: recognize Igor

        {BLACK_SCREEN}

        [hide_unit][/hide_unit]
    [/event]

    [event]
        name=start

        # FIXME: doesn't work on prestart
        [place_shroud]
            side=1
        [/place_shroud]

        {LOCK_VIEW}

        [scroll_to_unit]
            id=Galas
            {WARP}
        [/scroll_to_unit]

        [fire_event]
            name=elynia cutscene 3
        [/fire_event]
    [/event]

    [event]
        name=elynia cutscene 3

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Elynia
            message= _ "Once upon a time, the Great Continent was dominated by many human kingdoms united under a single banner, the banner of the Empire of Wesnoth; but elves and dwarves were here first, and inhabited the vast green forests and tall mountains ranges. Although they had come to see the humans of Wesnoth as valuable friends, many remembered that the humans first arrived to the continent with legions of orcs in pursuit. But by the Golden Age, we had all managed to set our differences aside and prosper together."
        [/message]

        [message]
            speaker=Elynia
            message= _ "South of the Heart Mountains lay one of the greatest and oldest domains of our kind, Wesmere. For long it served as the capital of our civilization, with its elven council — the Ka’lian — holding greater authority than our own kings and lords. The members of the Ka’lian valued knowledge over all other things, and they sought to plunder all the secrets of Irdya for the greater good. In time, this would bring about our downfall."
        [/message]

        [message]
            speaker=Elynia
            message= _ "But the first step towards ending our peaceful lives was taken not by elvenkind, but by the Empire of Wesnoth. At the time, the human Emperor saw his popularity among his subjects dwindle. He saw fit to take advantage of an otherwise unremarkable incursion of undead in orcish territory, led by a powerful necromancer said to have been destroyed countless times before. You must still remember this, Mal Keshar."
        [/message]

        # wmllint: local spelling pfft

        [message]
            speaker=Mal Keshar
            message= _ "I have lived for, uh, I don’t know, thousands of years, and you suddenly expect me to remember one specific instance of me terrorizing those despicable creatures!? Pfft."
        [/message]

        [message]
            speaker=Elynia
            message= _ "It served as the perfect excuse for the Emperor of Wesnoth to take the fate of Irdya into his own hands. He ordered his magi to gather masters and students from all academies throughout the land; together, they lifted a mountain into the skies to shine forth and force all soldiers of darkness to retreat underground until the end of times. That is Naia, the second sun."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Centuries later, things... happened in Wesmere. There is no-one still alive who remembers exactly how it all began, and in the end, Argan and I had to rely on hearsay to put together the pieces of the puzzle."
        [/message]

        [message]
            speaker=Elynia
            message= _ "As part of their experiments seeking to unveil the nature of our reality, the most skilled sorcerers in Wesmere discovered a way to open portals to another world; and from one of those portals emerged a young elf seer who warned them of disasters to come; disasters that he claimed would destroy all elvish civilization, and with it, the knowledge hoarded by the good people of Wesmere. He promised them protection and more knowledge in exchange for being worshiped as a god. That was Zhangor, and that was the pact he proposed to elvish civilization."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Knowledge begets power, and power begets ambition; the offer was only too enticing for the lords of Wesmere. Those who disagreed with the Ka’lian’s decision to accept the Demon Lord as their god would be the first to meet him... as offerings. As part of his requirements, these blood sacrifices were to remain a secret concealed from the rest of the world; and because of this, for a long time, we remained unaware of the corruption that took root in Wesmere."
        [/message]

        # wmllint: local spellings Dantair Gaia

        [message]
            speaker=Elynia
            message= _ "Zhangor’s claims would prove true after but a few years following this. A nobleman by the name of Dantair became Emperor of Wesnoth six years later, since the previous holder of the title had left no heirs to take the throne. The mysterious circumstances of his decease led people to suspect Dantair of regicide. With Wesnoth’s civil unity at stake, two years later Dantair saw no option but to quell his detractors with a decree for the immediate creation of Gaia, the third sun."
        [/message]

        [message]
            speaker=Elynia
            message= _ "But his confidence in this plan was too great. As Wesnoth had only seen threats of mundane origins for two centuries and the old masters had long since passed away, the human magi were no longer the impressive force that once created Naia. Dantair went ahead with his plan and took measures to ensure nobody could possibly interfere. Thus, to my heart’s pain, I came to witness the mayhem..."
        [/message]

        [message]
            speaker=Elynia
            message= _ "The magi realized only too late that they were unable to tether Gaia up in the skies. Their failure resulted in the Fall of the third sun, and the end of an era that later came to be known as the Golden Age."
        [/message]

        [message]
            speaker=Elynia
            message= _ "The earth-shattering force of the impact caused cataclysms and eruptions all over Irdya, destroying forests, cities, rivers, even mountains. The Great Continent was entirely reshaped, and the fruits of civilization were destroyed all at once. Perhaps for the best, Dantair did not live to see the full extent of the damage he caused — he and his magi were murdered by the panicked people of Wesnoth, and thus their sad story came to a swift end amidst the destruction."
        [/message]

        [message]
            speaker=Galas
            message= _ "So it’s true, after all."
        [/message]

        [message]
            speaker=Elynia
            message= _ "The humans were far from the only ones to suffer the calamities that resulted from their prideful actions. Elves, dwarves, humans, and orcs... they all fought among themselves for the scarce resources left after everything green perished. Naia and Sela also contributed by drying up every source of water on the surface. And while we at Lintanir Forest had to cope with this for some time until the situation proved unsustainable, Wesmere stood intact through everything, protected by Zhangor’s arcane magic. The unholy sacrifices continued, and soon he saw that he would be left with nothing to rule if the Wesmere population waned further; his thirst for blood became increasingly difficult to quench."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Luckily for him, many outsiders sought shelter in Wesmere after the Fall. He came up with a simple but effective solution to his dilemma: all foreigners, be it elves or members of any other race, were declared heretics unworthy of his gift of life. The pain and agony of the unfortunate souls captured by the elves continued to feed him and cause his power to grow stronger and stronger; and when his prey stopped coming to Wesmere, he sent hunters beyond their borders to obtain more sacrifices for him."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Finally, Lintanir became inhospitable and we were forced to ask refuge of the Ka’lian. Argan and I led my people out of the ruins of the northern forests, and after a long journey across the ravaged land, we arrived at the eastern frontier of Wesmere. Then, we were ambushed."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Many of our people were already weak due to the long march from Lintanir, unable to fend off the forces sent after us by Zhangor’s cultists. Those who didn’t die during the confrontation were captured and sacrificed to the demon, as my husband later found out. ... He risked his life to infiltrate the capital and obtain intelligence on our enemy."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Thus we found ourselves faced with a difficult choice: either we could stop our brethren, the elves of the forest where I grew up, and release them from this unprecedented evil at all costs; or instead, we could avoid the onslaught and abandon their lands, thus perpetuating the Demon Lord’s cruel rule through inaction."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Had we chosen the latter, elvenkind would likely have flourished once again... as the slaves of the Demon Lord, bound by that fateful pact for the rest of eternity. You certainly wouldn’t be here now."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Destiny works in mysterious ways, and it was only by chance that we made contact with the elves led by Lord Quetor’el of Aethenwood before they could be lured into a trap by Wesmere. Even though their military proficiency paled in comparison to that of Lintanir or Wesmere, their larger numbers proved essential to make our plan work. Our combined forces laid siege to Wesmere for nearly a year before Zhangor realized that the devotion and fear of his followers would never suffice to turn the tide in his favor."
        [/message]

        [message]
            speaker=Elynia
            message= _ "He then revealed his true form to the world, and proceeded to slaughter all from the skies — even his own subjects. The great power he unleashed upon Irdya did not only kill almost every living creature within range, but it also tore the forest ground asunder, while his fire and lightning took care of the rest. His power had allowed Wesmere to survive the events of the Fall, and then turned it all into a dead wasteland."
        [/message]

        [message]
            speaker=Elynia
            message= _ "With little chance of prevailing, Argan and I called upon the Union of Light and Darkness, risking our own destruction by overexertion, and challenging a foe without precedent in Irdya’s recorded history. Of course, we did defeat Zhangor in the end, but our power was not enough to counteract his impressive regeneration ability and allow us to kill him; which is why we could only tear his hideous body apart, seal every piece, and send them all back to Inferno."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Victory was ours, but the cost was much greater than we anticipated, and less than five hundred elves of Wesmere survived Zhangor’s display of power, many of them priests and warriors. They surrendered and begged for forgiveness, and we did spare the civilians’ lives."
        [/message]

        [message]
            speaker=Elynia
            message= _ "But the surviving priests, warriors, and Ka’lian members met a different fate, for we could not risk the possibility of them sparking another civil war or bringing Zhangor or other demons back to Irdya. No... we had no choice but to execute them, and then burn their bodies to ashes in case Zhangor’s magic could still be at work."
        [/message]

        [set_shroud]
            side=1
            shroud_data=$e1s10x_state.shroud_mask
        [/set_shroud]

        {FADE_IN}

        [unhide_unit][/unhide_unit]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Elynia
            message= _ "In hindsight, it’s ironic that we despised the humans so much after their hubris caused the end of all civilizations. Our kin in Wesmere represented the entirety of our race to the rest of the world, and their transgressions were far worse in that they were fully aware of the implications of what they were doing. And in both cases, it was ultimately the flaws of just a few select individuals that doomed the rest. Perhaps, if Zhangor and the Ka’lian had not conspired to destroy the integrity of elvenkind from within, we would have been able to rebuild what we lost, given sufficient time."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Although we elves rarely suffer from lapses of judgment like this, whenever it happens, the results are catastrophic for everyone involved. The recurrence of events like this throughout our history is unsettling, and it’s why I fear something like this may happen again if the creatures of Inferno get involved. We had to forbid telling the more shameful details of this story to anyone, elf or otherwise, at least for a few generations. But I expected our lorekeepers to at least have the sense to educate our future leaders about our past mistakes!"
        [/message]

        [message]
            speaker=Galas
            message= _ "To be fair, my lady, I have only recently been given this title by our previous lord Lédinor, who... stayed behind in the Valley, in an attempt to give us an opportunity to flee. We all owe our lives to his noble sacrifice."
        [/message]

        [message]
            speaker=Unarye
            message= _ "My lady, how does this relate to Anlindë or the death of the Master of Darkness?"
        [/message]

        [message]
            speaker=Elynia
            message= _ "I... I will get to the last part soon. As for her... Telchior was responsible for sparing her life. She was amongst the cultists serving Zhangor in Wesmere, one of the few who survived the final battle."
        [/message]

        [message]
            speaker=Anlindë
            message= _ "I am fully aware of the crimes I committed while under Zhangor’s command, my lady. But had I not obeyed the orders given to me, my family and I would have paid the price in blood. Not that any of that helped in the end... I can only hope their deaths turned out to be less painful than how they would have been on the altar."
        [/message]

        [message]
            speaker=Althurin
            message= _ "Why did the elves part ways?"
        [/message]

        [message]
            speaker=Elynia
            message= _ "Would that you were a little more patient... After we had finished dealing with the survivors, Anlindë tried to convince us to head back northeast instead of retreating to the south. Telchior and his people accepted her counsel, albeit reluctantly, while Quetor’el returned south. Argan and I would have followed Quetor’el’s group, but the lengthy war and the final battle had weakened us, both physically and mentally. We chose a third option, which was to descend into the depths of the Heart Mountains. Along the way we were joined by a few elves, and later dwarves."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Bear in mind that the dwarvish settlements underground weren’t exempt of the disasters of the Fall, and strong and frequent earthquakes persisted through all those years. But still, we wanted to learn more about the catalyst of elvenkind’s destruction. We remembered that some time before the catastrophe, the dwarves had unearthed the ruins of a civilization suspected to predate ours by eons. Seeing as how the elves no longer needed us, we decided to try and find those ruins."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Instead of finding them, we became lost in the depths, and eventually... one of those earthquakes caused the floor beneath our feet to collapse, leaving nothing below but a deep chasm. I held on to a ledge in time and survived, but Argan... he fell into the darkness. I could not... find him afterwards..."
        [/message]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Elynia
            message= _ "He always managed to escape the worst situations, but never something like that... I still hoped... I hoped he might have survived somehow, but... after some time — I don’t know how much — I realized that I was waiting for the impossible."
        [/message]

        [message]
            speaker=Elynia
            message= _ "The few of our followers who were still with me at the time convinced me that the situation was hopeless, and with Irdya ruined and perishing, I thought that my only option was to sleep. Perhaps, at some point later, if the world ever recovered..."
        [/message]

        [message]
            speaker=Unarye
            message= _ "The world is coming back to life, my lady, slowly but surely. Although for a good part of our journey we saw only dunes and dry plains, we also found green hills and valleys before proceeding underground. We have seen but a tiny fraction of our world in its present state, but the country of the northern humans is rumored to be thriving with life, and to support the Chaos Empire’s armies there must also be lands like that to the south."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Who is leading this empire against us, though?"
        [/message]

        [message]
            speaker=Anlindë
            message= _ "All their demons and humans appear to serve an emperor of some sort, but they also worship two names that were once subjects of myth: Uria and Yechnagoth. It is important to keep in mind that the dwarves learned that a creature also called Yechnagoth attempted to eradicate a people of the desert, elves who I presume are descended from Quetor’el’s band."
        [/message]

        [message]
            speaker=Althurin
            message= _ "She had the power to corrupt the souls of all surface-dwellers but those elves, and if the story is true, she also knew the name of this Demon Lord Zhangor. Though her dark influence ebbed away once she was slain by Kalehssar, the humans in the south remained under the control of a powerful group of cultists. We believe ’tis these people who later gave rise to the empire."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Yechnagoth, the Eater of Souls... and Uria, the Mother of Demons. This is deeply troubling. Simple humans clearly cannot control the forces of Inferno alone, so it might be... that Uria is more real than we thought. I need to ponder this later. For now, let us go."
        [/message]

        [message]
            speaker=Galas
            message= _ "So you will help us?"
        [/message]

        [message]
            speaker=Elynia
            message= _ "It’s my mission as the Protector of the Elves of Irdya. It would be dishonorable of me to shirk my sworn duty — for longer than I already did, anyway. I shall help you, even... even without Argan by my side."
        [/message]

        [message]
            speaker=Galas
            message= _ "Thank you, my lady."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Although everyone refers to me as the ‘Lady of Light’, it’s not really a title or rank, Lord Galas. You may call me Elynia if you wish. Now, guide me to the other elves. And... I want to see the surface again."
        [/message]

        [message]
            speaker=Igor
            message= _ "Yes! The surface! It’s been so long since I last saw it."
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Pah, finally. After such a long talk I’d be surprised if there were still any life left out there."
        [/message]

        [hide_unit][/hide_unit]

        {FADE_TO_BLACK}

        {UNLOCK_VIEW}

        {ENDLEVEL_QUIET} {NO_REPLAY_SAVE}
    [/event]

    [event]
        name=victory

        [modify_side]
            side=1
            gold=$side1_params.gold
            recruit=$side1_params.recruit
        [/modify_side]

        [kill]
            id=Unarye
        [/kill]

        {CLEAR_VARIABLE side1_params,elynia_loc,e1s10x_state}
    [/event]
[/scenario]

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