#textdomain wesnoth-Invasion_from_the_Unknown

[scenario]
    id=08x_Royal_Meeting
    name= _ "Royal Meeting"
    {MAP 08x_Royal_Meeting.map}
    turns=-1
    next_scenario=09_The_Library
    victory_when_enemies_defeated=no

    {FULLSCREEN_CUTSCENE_UI}

    {SCENARIO_MUSIC       "the_deep_path.ogg"} {CONTINUE_PLAYING_STORY_MUSIC_FIRST}
    {EXTRA_SCENARIO_MUSIC "nunc_dimittis.ogg"}

    {STORYTXT_ROYAL_MEETING}

    {UNDERGROUND}

    # 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}
        facing=ne
    [/side]

#define RM_DWARF _TYPE _X _Y
    [unit]
        random_traits=yes
        generate_name=yes
        type={_TYPE}
        x={_X}
        y={_Y}
        upkeep=loyal
    [/unit]
#enddef

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

        {NO_ECONOMY}

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

        {RM_DWARF (Dwarvish Dragonguard)  7 10} {FACING se}
        {RM_DWARF (Dwarvish Dragonguard)  7 15} {FACING ne}
        {RM_DWARF (Dwarvish Dragonguard)  7 20} {FACING ne}

        {RM_DWARF (Dwarvish Dragonguard) 21 10} {FACING sw}
        {RM_DWARF (Dwarvish Dragonguard) 21 15} {FACING nw}
        {RM_DWARF (Dwarvish Dragonguard) 21 20} {FACING nw}

        {RM_DWARF (Dwarvish Sentinel) 11  7} {FACING se}
        {RM_DWARF (Dwarvish Sentinel) 17  7} {FACING sw}

        {RM_DWARF (Dwarvish Guardsman) 11  9} {FACING se}
        {RM_DWARF (Dwarvish Guardsman) 17  9} {FACING sw}

        {RM_DWARF (Dwarvish Guardsman) 11 12} {FACING se}
        {RM_DWARF (Dwarvish Guardsman) 17 12} {FACING sw}

        {RM_DWARF (Dwarvish Guardsman) 11 14} {FACING se}
        {RM_DWARF (Dwarvish Guardsman) 17 14} {FACING sw}

        {RM_DWARF (Dwarvish Guardsman) 11 17} {FACING se}
        {RM_DWARF (Dwarvish Guardsman) 17 17} {FACING sw}

        {RM_DWARF (Dwarvish Guardsman) 11 19} {FACING se}
        {RM_DWARF (Dwarvish Guardsman) 17 19} {FACING sw}
    [/side]
    # wmllint: validate-on

    {CAVE_NOISE_SOUND_SOURCE}

    [event]
        name=prestart

        #
        # Recall heroes
        #

        # wmllint: recognize Anlindë
        {RECALL_ANLINDE_AT    13 12}
        # wmllint: recognize Mal Keshar
        {RECALL_MAL_KESHAR_AT 15 12}

        {FACE_DIRECTION (id=Galas,Anlindë) ne}
        {FACE_DIRECTION (id=Mal Keshar)    nw}

        [unit]
            # wmllint: recognize Unarye
            {CHARACTER_STATS_UNARYE}
            side=1
            x,y=14,13
            facing=ne
        [/unit]

        [unit]
            # wmllint: recognize Inodien
            {CHARACTER_STATS_INODIEN}
            side=1
            x,y=13,14
            facing=ne
        [/unit]

        [unit]
            type=Elvish Archer
            id=Unidë
            name= _ "Unidë"
            gender=female
            side=1
            x,y=15,14
            facing=nw
            {IS_HERO}
        [/unit]

        # wmllint: recognize Althurin

        [if]
            {VARIABLE_NUMERICAL_EQUALS althurin_store.length 0}
            [then]
                #
                # Someone used debug mode to skip scenarios,
                # so create Althurin here.
                #

                [unit]
                    canrecruit=yes
                    {CHARACTER_STATS_ALTHURIN_BASE}
                    side=2
                    to_variable=althurin_store
                [/unit]
            [/then]
        [/if]

        [set_variables]
            mode=merge
            name=althurin_store
            [literal]
                side=1
                canrecruit=no
                {IS_HERO}
                facing=sw
            [/literal]
        [/set_variables]

        [unstore_unit]
            variable=althurin_store
            x,y=15,8
            find_vacant=yes
        [/unstore_unit]

        {CLEAR_VARIABLE althurin_store}

        {LOCK_VIEW}
    [/event]

    [event]
        name=start

        {MOVE_UNIT (id=King Asthorgar) 14  8}

        [message]
            speaker=King Asthorgar
            message= _ "Welcome, friends. It’s been a long time since yer kinsmen last visited us... But tell me, what’re yer names? What brings ye here to the depths o’ the kingdom o’ Herthgar? And most importantly... why is that accursed lich in this chamber?!"
        [/message]

        [message]
            speaker=Galas
            message= _ "We can explain, Your Highness! I am Galas, leader of the elves from the Valley of Elynia. This is Anlindë and..."
        [/message]

        [message]
            speaker=Anlindë
            message= _ "The lich is Mal Keshar, our guide and... quite an important ally of ours. We would not be standing here in one piece without his help."
        [/message]

        [message]
            speaker=King Asthorgar
            message= _ "I ha’ heard enough o’ this old vile creature ye brought into my domain! Dinna’ ye realize how dangerous it is to deactivate our defenses just to let yer pet in? I would nae tolerate this folly if ye weren’t from the Quenoth kin!"
        [/message]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Galas
            message= _ "I beg your pardon, Your Highness, but what are you talking about?"
        [/message]

        [message]
            speaker=Anlindë
            message= _ "King, your fellow dwarves spoke of elves from the desert when they first met us. Am I to assume that they identified themselves as the ‘Quenoth’ people? Did they truly come from the desert to visit you?"
        [/message]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=King Asthorgar
            message= _ "Ye ask too many questions..."
        [/message]

        {MOVE_UNIT (id=King Asthorgar) 14 7}

        {FACE_DIRECTION (id=King Asthorgar) n}

        [redraw][/redraw]

        [delay]
            time=1000
        [/delay]

        [message]
            speaker=King Asthorgar
            message= _ "Aye, they were the Quenoth elves o’ the desert. It was a few centuries ago that they helped our brethren in the south and opened the route for the restoration of our kingdom. Ye nae heard o’ them before? That’s unexpected. So, from whence d’ye come? I hadn’t stopped to wonder why ye seem so different from what our historians describe..."
        [/message]

        [delay]
            time=750
        [/delay]

        {FACE_DIRECTION (id=King Asthorgar) s}

        [redraw][/redraw]

        [delay]
            time=500
        [/delay]

        [message]
            speaker=King Asthorgar
            message= _ "I reckon ye’re not from the desert then?"
        [/message]

        [message]
            speaker=Galas
            message= _ "That’s correct. We actually come from a secluded valley far from here, in which our ancestors found a favorable environment to settle. We were invaded by an army of the same force that I see has already arrived at your doors, the Chaos Empire. But I had never heard before of any large population of our kind living in the desert. What is this that you did not tell me before, Anlindë?"
        [/message]

        [message]
            speaker=Anlindë
            message= _ "There was a... civil war, some time after the Fall, Galas. You have to understand that such a world-changing event had similar consequences for every other civilization on the Great Continent and beyond. After the matter was settled and the flames of conflict subsided, our ancestors parted ways; two groups, different directions. We are the direct descendants of the group led by Lord Telchior of Thelien. No-one ever heard from the other group again, until now."
        [/message]

        [delay]
            time=500
        [/delay]

        [message]
            speaker=Galas
            message= _ "That would explain why many of the foes we have fought thus far are aware of our existence... Your Highness, what was the fate of the Quenoth elves?"
        [/message]

        [message]
            speaker=King Asthorgar
            message= _ "It’s said they were in search of a new home in the Far North, led by a young boy much like ye, by the name of Kalehssar. Our kin sent a soldier along them who eventually returned to tell quite the unusual tale. To put things into perspective, ye ha’ to realize that much o’ the green in the land was still desert back then. I ken it ha’ been a few centuries, but aye, things ha’ changed fast since then. Some believe an otherworldly force works to fix this fractured world bit by bit..."
        [/message]

        # wmllint: local spellings Zokan Zothan

        [message]
            speaker=King Asthorgar
            message= _ "Och, that nae the tale I was going to tell! Anyway, they didnae continue north. They were attacked by humans led by a wretched abomination posing as their goddess, Eloh! But the humans were nae match for young Kalehssar and his conviction, indeed. Then they were contacted by merfolk! Who guided them to Zokan... Zothan... some island in the ocean. There, they slew the impersonator Yechnagoth, the Eater of Souls! And this feat dispelled a curse that kept the minds o’ the peoples over the sands tied to the monster’s will!"
        [/message]

        [delay]
            time=750
        [/delay]

        {FACE_DIRECTION (id=King Asthorgar) n}

        [redraw][/redraw]

        [message]
            speaker=King Asthorgar
            message= _ "But ’tis just a story from a lunatic who barely made it back home. The poor thing provided them with a vivid account of the journey, though. Ye may ask Althurin later for all the details I omitted for the sake o’ brevity, if ye’re so inclined. (laughs)"
        [/message]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Mal Keshar
            message= _ "Sounds quite impressive for a mere band of elves."
        [/message]

        {MOVE_UNIT (id=King Asthorgar) 14 8}

        {FACE_DIRECTION (id=King Asthorgar) s}

        [redraw][/redraw]

        [message]
            speaker=King Asthorgar
            message= _ "Ah, but it wasn’t just a band o’ them! They brought all o’ their people for the journey! Anyway..."
        [/message]

        [message]
            speaker=Anlindë
            message= _ "What do you know about the Chaos Empire?"
        [/message]

        [message]
            speaker=Althurin
            message= _ "Murderers and thieves aided by the so-called “mother of all demons” from beyond this world. That’s what they are."
        [/message]

        [message]
            speaker=King Asthorgar
            message= _ "Aye... About two hundred years ago, they forced the southern clans in Gnalvarden to abandon their caves and move here. But far too many were slaughtered or captured before their king acceded to evacuate. The Chaos fiends even got their claws on some mighty war contraptions our brethren designed. And the poor engineers... we never heard o’ them again."
        [/message]

        [message]
            speaker=King Asthorgar
            message= _ "We ha’ been told a powerful warlord is bringing an army to strike against Herthgar, as if there were anything in these caves that could be useful to them. Heh. The point is, I heard yer people are looking for a new home, but we cannae provide ye with one here and now. However, the Far North has remained relatively peaceful for a couple o’ centuries, and I’m sure the humans would welcome ye in their country. I just cannae guarantee that it will last for long..."
        [/message]

        [delay]
            time=250
        [/delay]

        {FACE_DIRECTION (id=King Asthorgar) n}

        [redraw][/redraw]

        [delay]
            time=500
        [/delay]

        [message]
            speaker=King Asthorgar
            message= _ "Och, if ye can forgive me, there are so many things to do before we do battle with the demons... If there’s anything left to discuss, it must wait till dinner."
        [/message]

        [message]
            speaker=Galas
            message= _ "It is no problem, Your Highness. We are grateful for your counsel."
        [/message]

        {MOVE_UNIT (id=King Asthorgar) 14 4}

        [kill]
            id=King Asthorgar
        [/kill]

        [scroll_to_unit]
            id=Galas
        [/scroll_to_unit]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Galas
            message= _ "What do we do now?"
        [/message]

        [message]
            speaker=Anlindë
            message= _ "I don’t think the dwarf king is going to be of help to us. He seems largely ignorant of less mundane affairs... We’ll need to search for the Lady of Light and her consort on our own. But... his advice is sound, actually. If there are humans in the Far North, there might be a chance for our people to survive the forthcoming invasion if we send them to those lands."
        [/message]

        [message]
            speaker=Galas
            message= _ "I shall lead an expedition to the Far North, then."
        [/message]

        [message]
            speaker=Anlindë
            message= _ "Galas, as the regent lord appointed by Lord Lédinor, you should be beside us when we find her. It will be an important first meeting after all this time since the fall of our ancestors..."
        [/message]

        [message]
            speaker=Galas
            message= _ "Well, in that case... Inodien? Would you lead our main host and civilians to the humans?"
        [/message]

        [message]
            speaker=Inodien
            message= _ "M— my lord, are you suggesting that I..."
        [/message]

        [message]
            speaker=Galas
            message= _ "If it weren’t for Lady Unarye and you, we would have lost many more men and women to the sands. Your leadership in my absence was essential to our survival."
        [/message]

        [message]
            speaker=Inodien
            message= _ "Yes, my lord. I—"
        [/message]

        [message]
            speaker=Althurin
            message= _ "If I am allowed to interrupt, lord Galas... I may ha’ heard of this “Lady of Light” before."
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Oh! Now the dwarf decides to be useful! Why didn’t you say so before?"
        [/message]

        [message]
            speaker=Althurin
            message= _ "Ye... never said exactly what ye were lookin’ for in these caves."
        [/message]

        [message]
            speaker=Anlindë
            message= _ "What do you know about her?"
        [/message]

        [message]
            speaker=Althurin
            message= _ "We ha’ some lore about this elvish heroine... from a hundred years or so after the first cataclysm... ’Tis quite confusin’, really, but it’s not the point. My late master once told me a fascinatin’ story of what he found while explorin’ the deepest caves in these mountains. He was but a lad back then, though quite a well-versed one in the art of runecraftin’. He was searchin’ for rare metals that can only be found near the warmer caves where lava occasionally spurts from below and strange ferocious monsters lurk behind every corner."
        [/message]

        [message]
            speaker=Althurin
            message= _ "It was around those parts that with his runic artifacts he detected a strong power like he’d never seen before, hidin’ beneath. He said that he could see a light in the darkness of the abyss, and he felt there was somethin’ alive there... Alas, he didn’t have the resources or time to proceed further down. Even till his death he wondered what mighta’ been there."
        [/message]

        [message]
            speaker=Anlindë
            message= _ "... That could be the lead we needed. Did your master by any chance leave indications as to how to reach those caves?"
        [/message]

        [message]
            speaker=Althurin
            message= _ "Aye, he did. I could guide ye, as well. It’s not exactly advisable to explore the uncharted depths of the heart of Irdya if ye’re not a dwarf."
        [/message]

        [message]
            speaker=Galas
            message= _ "If that is a thing you can do... I mean, without the king taking offense to this plan..."
        [/message]

        # wmllint: local spelling pfft

        [message]
            speaker=Mal Keshar
            message= _ "Pfft, we wouldn’t need to rely on you if I were allowed to turn the elves into undead. Why would you want to risk your life on our mission, anyway?"
        [/message]

        [message]
            speaker=Althurin
            message= _ "As I said before, our loremasters have recorded the history of this sorceress. From what I figure she’s probably the most powerful one ever seen by any dwarf, orc, or even elf. ’Tis said she was cursed to live for the rest of eternity as punishment for the arts she delved into. My master took an interest in those stories after his discovery in the deep... And I want to find out the truth."
        [/message]

        [delay]
            time=500
        [/delay]

        [message]
            speaker=Althurin
            message= _ "And in any case, ye all saved our lives, and in particular mine — I am indebted for ye saving me from the followers of Uria. Sending ye on a suicidal mission now would not be good form, would it?"
        [/message]

        [message]
            speaker=Anlindë
            message= _ "Hm, fair enough, Althurin. We’ll gladly accept your help."
        [/message]

        [delay]
            time=750
        [/delay]

        [hide_unit][/hide_unit]

        {FADE_TO_BLACK}

        [fade_out_music][/fade_out_music]

        # Kill these three before they end up in side 1's recall list.
        [kill]
            id=Unarye,Inodien,Unidë
        [/kill]

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

#undef RM_DWARF

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


#textdomain wesnoth-Invasion_from_the_Unknown

[scenario]
    id=08_Errand_of_Hope
    name= _ "An Errand of Hope"
    {MAP 08_Errand_of_Hope.map}
    {TURNS 36 34 32}
    next_scenario=08x_Royal_Meeting
    victory_when_enemies_defeated=no

    {DEATHS_ACT_1}

    {SCENARIO_MUSIC "underground.ogg"} {CONTINUE_PLAYING_STORY_MUSIC_FIRST}

    {STORYTXT_ERRAND_OF_HOPE}

    {UNDERGROUND}

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

        shroud=yes

        {GOLD 140 130 120}
        {INCOME 13 11 8}

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

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

        hidden=yes
        no_leader=yes

        recruit=Dwarvish Pathfinder,Dwarvish Scout,Dwarvish Runesmith,Dwarvish Fighter,Dwarvish Thunderer

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_SIMPLE_ALWAYS_ASPECT caution       0.60}
            {AI_SIMPLE_ALWAYS_ASPECT village_value 0.10}
            {AI_SIMPLE_ALWAYS_ASPECT grouping      defensive}
        [/ai]
    [/side]

    # Other dwarves
    [side]
        side=3
        team_name=heroes
        user_team_name= _ "team_name^Dwarves"
        {DWARVISH_FLAG}

        hidden=yes
        no_leader=yes

        recruit=Dwarvish Pathfinder,Dwarvish Scout,Dwarvish Runesmith,Dwarvish Fighter,Dwarvish Thunderer

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

    # Hazor
    [side]
        side=4
        team_name=chaos
        user_team_name= _ "team_name^Chaos Empire"
        {CHAOS_FLAG}

        hidden=yes
        no_leader=yes

        recruit=Demon,Demon Zephyr,Chaos Hound,Chaos Invader,Chaos Invoker

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_SIMPLE_ALWAYS_ASPECT aggression    0.80}
            {AI_SIMPLE_ALWAYS_ASPECT caution       0.00}
            {AI_SIMPLE_ALWAYS_ASPECT recruitment_pattern "scout,scout,fighter,mixed fighter,archer,archer,mixed fighter,fighter,scout"}
        [/ai]
    [/side]

    # Zoltar
    [side]
        side=5
        team_name=chaos
        user_team_name= _ "team_name^Chaos Empire"
        {CHAOS_FLAG}

        hidden=yes
        no_leader=yes

        recruit=Demon,Chaos Hound,Chaos Invader,Chaos Invoker,Chaos Headhunter

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_SIMPLE_ALWAYS_ASPECT aggression    1.00}
            {AI_SIMPLE_ALWAYS_ASPECT caution       0.00}
            {AI_SIMPLE_ALWAYS_ASPECT grouping      no  }
            {AI_SIMPLE_ALWAYS_ASPECT recruitment_pattern "scout,scout,fighter,mixed fighter,archer,archer,mixed fighter,fighter,scout"}
        [/ai]
    [/side]

    # Kwurg
    [side]
        side=6
        team_name=trolls,cave
        user_team_name= _ "team_name^Trolls"
        {RAGGED_FLAG}

        {GOLD 90 130 190}
        {INCOME 2 3 4}
#ifndef HARD
        recruit=Troll Whelp,Troll
#else
        recruit=Troll Rocklobber,Troll
#endif

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_SIMPLE_ALWAYS_ASPECT aggression    1.00}
            {AI_SIMPLE_ALWAYS_ASPECT caution       0.05}
#ifndef HARD
            {AI_SIMPLE_ALWAYS_ASPECT recruitment_pattern "fighter"}
#else
            {AI_SIMPLE_ALWAYS_ASPECT recruitment_pattern "fighter,mixed fighter,fighter,fighter,mixed fighter,fighter"}
#endif
        [/ai]

        canrecruit=yes
        type=Troll Shaman
        id=Kwurg
        name= _ "Kwurg"
        [modifications]
            {TRAIT_RESILIENT}
            {TRAIT_STRONG}
        [/modifications]
    [/side]

#define EOH_ANT _X _Y
    [unit]
        type=Giant Ant
        x={_X}
        y={_Y}
        upkeep=loyal
        ai_special=guardian
    [/unit]
#enddef

    # Cave creatures
    [side]
        side=7
        team_name=cave
        user_team_name= _ "team_name^Cave Creatures"

        hidden=yes
        no_leader=yes

        {NO_ECONOMY}

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

        {EOH_ANT 33 33} {FACING se}
        {EOH_ANT 32 33} {FACING se}
        {EOH_ANT 32 32} {FACING se}

        {EOH_ANT 42 23} {FACING sw}
        {EOH_ANT 41 24} {FACING sw}
        {EOH_ANT 41 23} {FACING sw}
        {EOH_ANT 41 26} {FACING sw}

        {EOH_ANT 43 16} {FACING nw}

        {EOH_ANT 36 17} {FACING sw}
        {EOH_ANT 35 19} {FACING ne}
    [/side]

    {STARTING_VILLAGES 1 4}

    {STARTING_VILLAGES 6 4}

    # Decorations
    {PLACE_IMAGE (items/coffin-closed.png) 11 29}
    {PLACE_IMAGE (scenery/rock-cairn.png) 33 17}
    {PLACE_IMAGE (scenery/rock-cairn.png) 27 18}
    {PLACE_IMAGE (scenery/rock-cairn.png) 15 15}
    {PLACE_IMAGE (scenery/rock-cairn.png) 10 18}
    {PLACE_IMAGE (scenery/rock-cairn.png) 13 25}
    {PLACE_IMAGE (scenery/rock-cairn.png) 1 17}
    {PLACE_IMAGE (items/bones.png) 19 20}
    {PLACE_IMAGE (items/bones.png) 18 25}
    {PLACE_IMAGE (items/bones.png) 16 18}
    {PLACE_IMAGE (items/bones.png) 42 23}
    {PLACE_IMAGE (items/bones.png) 39 20}
    {PLACE_IMAGE (items/bones.png) 47 27}
    {PLACE_IMAGE (items/bones.png) 54 16}
    {PLACE_IMAGE (items/bones.png) 41 12}
    {PLACE_IMAGE (items/bones.png) 32 35}
    {PLACE_IMAGE (items/bones.png) 32 38}
    {PLACE_IMAGE (items/bones.png) 46 31}
    {PLACE_IMAGE (items/bonestack.png) 40 10}
    {PLACE_IMAGE (items/bonestack.png) 41 14}
    {PLACE_IMAGE (items/bonestack.png) 47 6}
    {PLACE_IMAGE (items/bonestack.png) 53 3}
    {PLACE_IMAGE (items/bonestack.png) 53 7}
    {PLACE_IMAGE (items/burial.png) 35 12}
    {PLACE_IMAGE (items/burial.png) 37 15}
    {PLACE_IMAGE (items/burial.png) 42 20}
    {PLACE_IMAGE (items/burial.png) 38 30}
    {PLACE_IMAGE (items/burial.png) 44 35}
    {PLACE_IMAGE (items/burial.png) 35 33}

    {CAVE_NOISE_SOUND_SOURCE}

    {CAVE_WATER_SOUND_SOURCE 32 31}

    {CAVE_WATER_SOUND_SOURCE 39 20}

    {CAVE_WATER_SOUND_SOURCE 12  7}

    [event]
        name=prestart

        {PLAYER_RECRUITMENT_SETUP_FOR_SCENARIO 8}

        #
        # Recall heroes
        #

        # wmllint: recognize Anlindë
        {RECALL_ANLINDE_AT    54 37}
        # wmllint: recognize Mal Keshar
        {RECALL_MAL_KESHAR_AT 53 39}

        {ELVISH_SUPPORTER (supporter)}

        {FACE_DIRECTION side=1 nw}

        {OBJECTIVES (
            {OBJECTIVE_VICTORY ( _ "Explore the caves and defeat any opposition you might find")}

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

            {TURNS_RUN_OUT}

            {OBJECTIVE_CARRYOVER}
        )}
    [/event]

    [event]
        name=start

        [message]
            role=supporter
            message= _ "These caves are too dark for us to see, even with our torches. As if walking with the undead was not disquieting enough..."
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Your archers are renowned for being as accurate and deadly at night as they are under the light of the suns, and yet you fear the dark depths beneath the surface!"
        [/message]

        [message]
            role=supporter
            message= _ "It is not the dark itself we fear, lich, but rather the things that dwell in it."
        [/message]

        [message]
            speaker=Galas
            message= _ "I wonder if we’ll ever come across the people who built those structures. Our enemies roam these caves too in search of the two heroes... Whoever would be more apt for aiding us in our mission than the dwarves?"
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Eh, if they had to abandon their posts there is probably not much they can do for us. See, for all we know they have either all been slaughtered or converted to the Chaos Empire and their ridiculous cult. Not that they would be of much help anyway. They would rather tend to their own matters than deal with outsiders, especially elves. Not too different from your people in that regard."
        [/message]

        [message]
            speaker=Anlindë
            message= _ "It is true that historically they have refused to assist those whom they deem of very little utility for their ends, but given the ongoing Chaos infestation, we may be able to take advantage of that."
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "He, he, surely they would admit elves and undead into their domains, yes..."
        [/message]
    [/event]

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

        [message]
            x,y=$x1,$y1
            {UNIT_SPEAKS_FOR_UNDEAD_MINION id=Anlindë}
            message= _ "There seems to be some sort of spell cast on these gates — we cannot even touch them!"
        [/message]
    [/event]

    [event]
        name=attack
        #
        # Using filters like this works only because units from a given
        # side cannot attack other units from the same side, so a
        # situation where the primary and secondary units have the same
        # side number will never arise.
        #
        [filter]
            side=6
            [or]
                side=1
            [/or]
        [/filter]
        [filter_second]
            side=6
            [or]
                side=1
            [/or]
        [/filter_second]

        [message]
            speaker=unit
            message= _ "Elves! Undead! Begone dark treacherous ones, or we kill you!"
        [/message]
    [/event]

    # Poisonous bow
    {POISONOUS_BOW 44 29}

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

        [message]
            speaker=Kwurg
            message= _ "Ugh. It hurts a lot..."
        [/message]
    [/event]

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

        [message]
            speaker=Galas
            message= _ "If only trolls weren’t so quick to assume ill intentions on our part... I understand that they are protecting their territory and would never be willing to negotiate with those who consort with the undead, but..."
        [/message]

        [message]
            speaker=Anlindë
            message= _ "I have to agree with the sentiment. These creatures have lived for longer than our own species, as though they were created to guard the very earth from intruders who may threaten the balance of nature. Slaying them feels utterly wrong in that sense."
        [/message]

        [remove_terrain_overlays]
            # Open the passage leading to the battlefield
            x=29,30,31
            y=32,31,31
        [/remove_terrain_overlays]

        [redraw]
            clear_shroud=yes
        [/redraw]
    [/event]

    [event]
        name=moveto
        [filter]
            side=1
            x= 8-27
            y=16-25
        [/filter]

        [fire_event]
            name=enter battlefield
            [primary_unit]
                x,y=$x1,$y1
            [/primary_unit]
        [/fire_event]
    [/event]

    #
    # The battle proper begins.
    #

    [event]
        name=enter battlefield

        [remove_terrain_overlays]
            # Open small water channel gate
            x,y=30,22
            [or]
                # Open the other passage NW from the initial troll's keep
                x=38,39
                y=27,28
            [/or]
        [/remove_terrain_overlays]

        #
        # Initialize sides and their leaders.
        #

        #
        # Althurin
        #

        [store_starting_location]
            side=2
        [/store_starting_location]

        # wmllint: recognize Althurin
        [hidden_unit]
            canrecruit=yes
            {CHARACTER_STATS_ALTHURIN_BASE}
            side=2
            x,y=$location.x,$location.y
            facing=sw
        [/hidden_unit]

        [capture_village]
            side=2
            x,y,radius=$location.x,$location.y,9
        [/capture_village]

        [modify_side]
            side=2
            hidden=no
            {GOLD 130 110 90}
        [/modify_side]

        #
        # Aetilaes
        #

        [store_starting_location]
            side=3
        [/store_starting_location]

        # wmllint: recognize Aetilaes
        [hidden_unit]
            canrecruit=yes
            type=Dwarvish Pathfinder
            id=Aetilaes
            name= _ "Aetilaes"
            side=3
            x,y=$location.x,$location.y
            facing=se
            [modifications]
                {TRAIT_QUICK}
                {TRAIT_HEALTHY}
            [/modifications]
        [/hidden_unit]

        [capture_village]
            side=3
            x,y,radius=$location.x,$location.y,6
        [/capture_village]

        [modify_side]
            side=3
            hidden=no
            {GOLD 130 110 90}
        [/modify_side]

        #
        # Western enemy troops
        #

        [store_starting_location]
            side=4
        [/store_starting_location]

        # wmllint: recognize Hazor
        [hidden_unit]
            canrecruit=yes
            type=Chaos Razerman
            id=Hazor
            name= _ "Hazor"
            side=4
            x,y=$location.x,$location.y
            facing=ne
            [modifications]
                {TRAIT_STRONG}
                {TRAIT_FEARLESS}
            [/modifications]
        [/hidden_unit]

        [capture_village]
            side=4
            x= 1-11
            y=16-25
        [/capture_village]

        [modify_side]
            side=4
            hidden=no
            {GOLD 140 160 180}
        [/modify_side]

        #
        # Eastern enemy troops
        #

        [store_starting_location]
            side=5
        [/store_starting_location]

        # wmllint: recognize Zoltar
        [hidden_unit]
            canrecruit=yes
            type=Chaos Lorekeeper
            id=Zoltar
            name= _ "Zoltar"
            side=5
            x,y=$location.x,$location.y
            facing=sw
            [modifications]
                {TRAIT_RESILIENT}
                {TRAIT_SLOW}
            [/modifications]
        [/hidden_unit]

        [capture_village]
            side=5
            x=39-58
            y= 5-24
        [/capture_village]

        [modify_side]
            side=5
            hidden=no
            {GOLD 140 160 180}
        [/modify_side]

        {CLEAR_VARIABLE location}

#define EOH_UNIT _SIDE _TYPE _X _Y
    [hidden_unit]
        side={_SIDE}
        type={_TYPE}
        generate_name=yes
        random_gender=yes
        random_traits=yes
        x={_X}
        y={_Y}
        upkeep=loyal
    [/hidden_unit]
#enddef

#define EOH_FACING _FACING
    [+hidden_unit]
        facing={_FACING}
    [/hidden_unit]
#enddef

        #
        # Create regular units
        #

        {EOH_UNIT 4 (Iron Golem) 11 19} {EOH_FACING ne}
        {EOH_UNIT 4 (Chaos Marauder) 9 21} {EOH_FACING ne}
        {EOH_UNIT 4 (Chaos Invoker) 13 17} {EOH_FACING ne}
        {EOH_UNIT 4 (Blood Imp) 11 25} {EOH_FACING ne}
        {EOH_UNIT 4 (Demonic Hound) 12 22} {EOH_FACING ne}
        {EOH_UNIT 4 (Chaos Invader) 14 22} {EOH_FACING ne}
        {EOH_UNIT 4 (Iron Golem) 17 19} {EOH_FACING ne}
        {EOH_UNIT 4 (Dark Knight) 4 22} {EOH_FACING ne}
        {EOH_UNIT 4 (Demon Grunt) 18 26} {EOH_FACING ne}
        {EOH_UNIT 4 (Chaos Magus) 16 15} {EOH_FACING ne}
        {EOH_UNIT 4 (Dark Knight) 16 20} {EOH_FACING ne}

        {EOH_UNIT 5 (Chaos Crossbowman) 37 10} {EOH_FACING sw}
        {EOH_UNIT 5 (Demon Zephyr) 42 12} {EOH_FACING sw}
        {EOH_UNIT 5 (Chaos Magus) 40 14} {EOH_FACING sw}
        {EOH_UNIT 5 (Dark Knight) 38  8} {EOH_FACING sw}
        {EOH_UNIT 5 (Troll Warrior) 31 12} {EOH_FACING sw}
        {EOH_UNIT 5 (Chaos Marauder) 39 11} {EOH_FACING sw}

        {EOH_UNIT 5 (Troll Rocklobber) 43 10} {EOH_FACING sw}
        {EOH_UNIT 5 (Troll Rocklobber) 46 13} {EOH_FACING sw}
        {EOH_UNIT 5 (Chaos Longbowman) 35 11} {EOH_FACING sw}
        {EOH_UNIT 5 (Chaos Longbowman) 35 18} {EOH_FACING sw}
        {EOH_UNIT 5 (Demon Warrior) 37 14} {EOH_FACING sw}
        [+hidden_unit]
            gender=female
        [/hidden_unit]

        {EOH_UNIT 5 (Demon Zephyr) 45 8} {EOH_FACING sw}
        [+hidden_unit]
            gender=female
        [/hidden_unit]
        {EOH_UNIT 5 (Demon Zephyr) 38 11} {EOH_FACING sw}
        {EOH_UNIT 5 (Demon Grunt) 35 13} {EOH_FACING sw}

        # Create fighters and other units for allies
        {EOH_UNIT 3 (Dwarvish Runesmith) 25 20} {EOH_FACING sw}
        {EOH_UNIT 2 (Dwarvish Stalwart) 28 18} {EOH_FACING sw}
        {EOH_UNIT 2 (Dwarvish Fighter) 23 18} {EOH_FACING sw}
        {EOH_UNIT 3 (Dwarvish Pathfinder) 27 17} {EOH_FACING sw}
        {EOH_UNIT 3 (Dwarvish Steelclad) 27 22} {EOH_FACING sw}

        {EOH_UNIT 3 (Dwarvish Thunderguard) 28 15}
        {EOH_UNIT 2 (Dwarvish Thunderguard) 32 18}
        {EOH_UNIT 2 (Dwarvish Thunderer) 22 14}  {EOH_FACING sw}
        {EOH_UNIT 3 (Dwarvish Ulfserker) 27 15}
        {EOH_UNIT 3 (Dwarvish Pathfinder) 30 18}
        {EOH_UNIT 2 (Dwarvish Scout) 29 16}
        {EOH_UNIT 2 (Dwarvish Ulfserker) 19 16} {EOH_FACING sw}
        {EOH_UNIT 3 (Dwarvish Guardsman) 32 14}

        [message]
            x,y=$x1,$y1
            race=elf
            [or]
                id=Anlindë
            [/or]
            message= _ "What is that ahead?"
        [/message]

        [unhide_unit][/unhide_unit]

        #
        # Remove shroud on the battlefield
        #

        {CLEAR_CAVE_SHROUD (
            x,y=17,19
            radius=9
            [or]
                x,y=5,19
                radius=7
            [/or]
        )}

        [redraw]
            clear_shroud=yes
        [/redraw]

        [delay]
            time=750
        [/delay]

        {REPLACE_SCENARIO_MUSIC "casualties_of_war.ogg"}
        {APPEND_MUSIC           "battle.ogg"}
        {APPEND_MUSIC           "legends_of_the_north.ogg"}
        {APPEND_MUSIC           "northerners.ogg"}

        [message]
            x,y=$x1,$y1
            race=elf
            [or]
                id=Anlindë
            [/or]
            message= _ "Bright gods!"
        [/message]

        [scroll_to]
            x,y=12,23
        [/scroll_to]

        [delay]
            time=500
        [/delay]

        [scroll_to]
            x,y=23,16
        [/scroll_to]

        [delay]
            time=500
        [/delay]

        [message]
            speaker=Hazor
            message= _ "Look, over there! The heathens from the valley still live!"
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "These accursed humans brought a whole battalion into the caves. How bothersome."
        [/message]

        [message]
            speaker=Althurin
            message= _ "(<i>confused</i>) ... Elves? And with undead marching amongst their ranks? ’Tis a strange sight... We thought that yer race was still an enemy of necromancy and their practitioners! Though, ye helped our kin three centuries ago... Would ye help us now?"
        [/message]

        [message]
            speaker=Galas
            message= _ "Centuries? Well... sure, we have helped each other in times of need throughout history. Why would we not help you?"
        [/message]

        [message]
            speaker=Anlindë
            message={ASIDE ( _ "Three centuries... interesting...")}
        [/message]

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

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

        [message]
            speaker=Althurin
            message= _ "Excellent! As ye can see, there are these foul men from the lands of Chaos, tryin’ to take over our tunnels. They’re everywhere! It’d be a boon if ye can help us repel ’em from here. Yes... Our brethren ha’ been eager to hear of the mighty desert heroes again!"
        [/message]

        [message]
            speaker=Anlindë
            message= _ "Rest assured we shall do our best."
        [/message]

        [message]
            speaker=Galas
            message={ASIDE ( _ "What is going on? Elves from the desert? Anlindë, might they be...")}
        [/message]

        [message]
            speaker=Anlindë
            message={ASIDE ( _ "I believe that is a discussion for another time, when we have finished our new job here.")}
        [/message]
        [message]
            speaker=Galas
            message={ASIDE ( _ "Fair enough.")}
        [/message]

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

        {OBJECTIVES (
            {HEADER_NEW_OBJECTIVES}

            {OBJECTIVE_VICTORY ( _ "Defeat all enemy leaders")}

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

            {TURNS_RUN_OUT}

            {OBJECTIVE_CARRYOVER}
        )}

        #
        # Allow enemies-defeated victory after this point.
        #

        [event]
            name=enemies defeated

            {ENDLEVEL_VICTORY yes}
        [/event]
    [/event]

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

        [message]
            side=3
            message= _ "Althurin, sir! You are seriously injured!"
        [/message]

        [message]
            speaker=Althurin
            message= _ "Argh... I need... I need’a report this news to the king. I hafta make it there. Please stand fast, friend elves. I shall be back with ye soon."
        [/message]

        [store_unit]
            [filter]
                id=Althurin
            [/filter]
            variable=althurin_store
            kill=yes
        [/store_unit]

        [move_unit_fake]
            type=$althurin_store.type
            side=$althurin_store.side
            x=$althurin_store.x|,15
            y=$althurin_store.y|,14
        [/move_unit_fake]
    [/event]

    [event]
        name=victory

        #
        # NOTE:
        # We'll need althurin_store in the cutscene scenario following this one.
        #

        [if]
            [have_unit]
                id=Althurin
            [/have_unit]
            [then]
                [store_unit]
                    [filter]
                        id=Althurin
                    [/filter]
                    variable=althurin_store
                    kill=no
                [/store_unit]

                {VARIABLE althurin_store.hitpoints $althurin_store.max_hitpoints}
                {CLEAR_VARIABLE althurin_store.status}
            [/then]
            [else]
                [if]
                    {VARIABLE_NUMERICAL_EQUALS althurin_store.length 0}
                    [then]
                        #
                        # Someone used debug mode to skip the battle event,
                        # so create Althurin here.
                        #

                        [unit]
                            canrecruit=yes
                            {CHARACTER_STATS_ALTHURIN_BASE}
                            side=2
                            x,y=11,1
                            to_variable=althurin_store
                        [/unit]
                    [/then]
                [/if]

                {CLEAR_CAVE_SHROUD (
                    x,y,radius=11,6,6
                )}

                [redraw]
                    clear_shroud=yes
                [/redraw]

                [move_unit_fake]
                    type=$althurin_store.type
                    side=$althurin_store.side
                    x=11,10,11
                    y= 1, 3, 6
                [/move_unit_fake]

                {VARIABLE althurin_store.hitpoints $althurin_store.max_hitpoints}
                {CLEAR_VARIABLE althurin_store.status}

                [unstore_unit]
                    variable=althurin_store
                    x,y=11,6
                    find_vacant=yes
                [/unstore_unit]
            [/else]
        [/if]

        [message]
            speaker=Althurin
            message= _ "Dwarf-friends, ye made it. Now, follow me to the Throne Room, King Asthorgar awaits. He’ll be pleased to hear and see news of ye and yer kind again."
        [/message]
    [/event]

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

        [redraw][/redraw]

        [allow_undo][/allow_undo]

        [message]
            speaker=unit
            {UNIT_SPEAKS_FOR_UNDEAD_MINION (id=Mal Keshar)}
            message= _ "This coffin is empty."
        [/message]
    [/event]
[/scenario]

#undef EOH_ANT
#undef EOH_UNIT
#undef EOH_FACING

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


#textdomain wesnoth-Invasion_from_the_Unknown

[scenario]
    id=09_The_Library
    name= _ "The Library"
    {MAP 09_The_Library.map}
    {TURNS 50 49 48}
    next_scenario=10_The_Source_of_Light
    victory_when_enemies_defeated=no

    # Was Pitch Black Hole until shortly after 0.1.34's release

    {SCENARIO_MUSIC "underground.ogg"}

    {UNDERGROUND}

    {STORYTXT_THE_LIBRARY}

    {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 180 170 160}
        {INCOME 4 3 3}

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

#define TL_CAVE_DWELLER _TYPE _X _Y
    [unit]
        type={_TYPE}
        x={_X}
        y={_Y}
        upkeep=loyal
        ai_special=guardian
    [/unit]
#enddef

    # NW
    [side]
        side=2
        team_name=evil
        user_team_name= _ "team_name^Undead"
        {RAGGED_FLAG}

        {GOLD 130 140 150}
        recruit=Skeleton,Skeleton Archer,Vampire Bat,Blood Bat

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_SIMPLE_ALWAYS_ASPECT recruitment_pattern "fighter,archer,archer,scout,archer,scout,fighter"}
        [/ai]

        canrecruit=yes
        type=Banebow
        id=Kargorath
        name= _ "Kargorath"
        [modifications]
            {TRAIT_UNDEAD}
        [/modifications]

        {TL_CAVE_DWELLER (Deathblade) 11 20}
        {TL_CAVE_DWELLER (Deathblade) 16 22}
    [/side]

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

        {GOLD 160 170 180}
        recruit=Chaos Invader,Chaos Headhunter

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_SIMPLE_ALWAYS_ASPECT aggression    1.00}
            {AI_SIMPLE_ALWAYS_ASPECT caution       0.00}
            {AI_SIMPLE_ALWAYS_ASPECT recruitment_pattern "fighter,fighter,fighter,scout,fighter,scout"}
        [/ai]

        canrecruit=yes
        type=Lich
        id=Mal Em-Nonaluz
        name= _ "Mal Em-Nonaluz"
        gender=female
        profile=portraits/undead/brown-lich.png
        [modifications]
            {TRAIT_UNDEAD}
            {TRAIT_RESILIENT}
            {TEAM_COLOR_OVERRIDE () brown}
        [/modifications]

        {TL_CAVE_DWELLER Revenant 35 16}
        {TL_CAVE_DWELLER Revenant 31 16}

        {TL_CAVE_DWELLER Deathblade     32  9}
        {TL_CAVE_DWELLER Deathblade     31 11}
        {TL_CAVE_DWELLER (Bone Shooter) 33 13}

        {TL_CAVE_DWELLER {DIFF Skeleton Skeleton Revenant} 23  5}
        {TL_CAVE_DWELLER (Skeleton Archer)                 25  6}
    [/side]

    {RECRUIT_UNIT_VARIATIONS 3 "Walking Corpse,Soulless" troll,troll,bat,troll,bat,troll,dwarf,troll,goblin,troll}

    # West
    [side]
        side=4
        team_name=evil
        user_team_name= _ "team_name^Undead"
        {RAGGED_FLAG}

        {GOLD 150 160 170}
        recruit=Skeleton,Skeleton Rider,Skeleton Archer

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_SIMPLE_ALWAYS_ASPECT aggression    1.00}
            {AI_SIMPLE_ALWAYS_ASPECT caution       0.00}
            {AI_SIMPLE_ALWAYS_ASPECT recruitment_pattern "fighter,scout,scout,fighter,archer"}
        [/ai]

        canrecruit=yes
        type=Draug
        id=Oroktharn
        name= _ "Oroktharn"
        [modifications]
            {TRAIT_UNDEAD}
        [/modifications]

        {TL_CAVE_DWELLER (Bone Shooter) 14 34}
        {TL_CAVE_DWELLER (Bone Shooter) 17 31}
    [/side]

    [side]
        side=5
        team_name=evil
        user_team_name= _ "team_name^Cave Creatures"
        {RAGGED_FLAG}

        no_leader=yes
        hidden=yes

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

        {TL_CAVE_DWELLER (Fire Guardian) 13 41} {FACING se}
        {TL_CAVE_DWELLER (Fire Guardian) 13 44} {FACING ne}
        {TL_CAVE_DWELLER (Fire Guardian) 50 28} {FACING sw}
        {TL_CAVE_DWELLER (Fire Guardian) 52 30} {FACING nw}

        {TL_CAVE_DWELLER (Giant Ant) 43 46}
        {TL_CAVE_DWELLER (Giant Ant) 43 48}
        {TL_CAVE_DWELLER (Giant Ant) 41 47}

        {TL_CAVE_DWELLER (Brain Drainer) 20 47}
        {TL_CAVE_DWELLER (Brain Drainer) 20 45}
        {TL_CAVE_DWELLER (Giant Leech) 22 46}

        {TL_CAVE_DWELLER (Leech) 26 33}
        {TL_CAVE_DWELLER (Leech) 19 28}
        {TL_CAVE_DWELLER (Leech) 39 18}
        {TL_CAVE_DWELLER (Leech) 52 37}
        {TL_CAVE_DWELLER (Leech) 42 42}
        {TL_CAVE_DWELLER (Leech) 13 36}
        {TL_CAVE_DWELLER (Leech)  6 26}
        {TL_CAVE_DWELLER (Leech) 21 18}
        {TL_CAVE_DWELLER (Leech) 51 24}
        {TL_CAVE_DWELLER (Leech) 46 22}
        {TL_CAVE_DWELLER (Leech) 29 43}
        {TL_CAVE_DWELLER (Leech) 18 37}

        {TL_CAVE_DWELLER (Giant Leech) 22 31}
        {TL_CAVE_DWELLER (Giant Leech) 38 28}
        {TL_CAVE_DWELLER (Giant Leech) 53 23}
        {TL_CAVE_DWELLER (Giant Leech)  8 24}

#ifndef EASY
        {TL_CAVE_DWELLER {DIFF () (Blood Bat) (Dread Bat)} 26 41}
        {TL_CAVE_DWELLER {DIFF () (Blood Bat) (Dread Bat)} 42 25}

        {TL_CAVE_DWELLER (Dread Bat) 25 26}
#endif

        {TL_CAVE_DWELLER (Tentacle of the Deep) 32 22}
        {TL_CAVE_DWELLER (Tentacle of the Deep) 34 21}
        {TL_CAVE_DWELLER (Tentacle of the Deep) 34 23}

        {TL_CAVE_DWELLER (Tentacle of the Deep) 45 19}
    [/side]

#define TL_PALETTE_OVERRIDE
    [+unit]
        [modifications]
            [object]
                [effect]
                    apply_to="image_mod"
                    add="PAL(shaxthal_drone_base>shaxthal_drone_surface)"
                [/effect]
            [/object]
        [/modifications]
    [/unit]
#enddef

    [side]
        side=6
        team_name=evil
        user_team_name= _ "team_name^Unknown"
        {RAGGED_FLAG}

        no_leader=yes
        hidden=yes

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

        {TL_CAVE_DWELLER (Shaxthal Worm) 54 43} {VARIATION a} {TL_PALETTE_OVERRIDE}
        {TL_CAVE_DWELLER (Shaxthal Worm) 57 40} {VARIATION a} {TL_PALETTE_OVERRIDE}
        {TL_CAVE_DWELLER (Shaxthal Worm) 56 44} {VARIATION a} {TL_PALETTE_OVERRIDE}
    [/side]

    [event]
        name=block sw exit

        [terrain]
            terrain=Xu
            x= 9-10
            y=41-43
        [/terrain]

        [terrain]
            terrain=Uh
            x=11,12
            y=42,41
        [/terrain]

        [terrain]
            terrain=Uu
            x,y=12,42
        [/terrain]
    [/event]

    [event]
        name=block s exit

        [terrain]
            terrain=Xu
            x=23-26
            y=49-50
        [/terrain]
    [/event]

    [event]
        name=block se exit

        [terrain]
            terrain=Xu
            x=45-46
            y=46-49
        [/terrain]
    [/event]

#define TL_BLOCK_EXIT _DIRECTION
    [fire_event]
        name="block {_DIRECTION} exit"
    [/fire_event]
#enddef

#define TL_ENEMIES_NOT_DEFEATED
    [have_unit]
        canrecruit=yes
        [not]
            side=1
        [/not]
    [/have_unit]
#enddef

#define TL_ENEMIES_DEFEATED
    [not]
        {TL_ENEMIES_NOT_DEFEATED}
    [/not]
#enddef

    {PLACE_IMAGE items/burial.png     36 30}
    {PLACE_IMAGE items/bonestack.png  39 30}

    {PLACE_IMAGE items/bonestack.png  40 38}
    {PLACE_IMAGE items/bonestack.png  31 37}
    {PLACE_IMAGE items/bonestack.png  39 42}

    {PLACE_IMAGE items/burial.png     48 31}
    {PLACE_IMAGE items/bonestack.png  48 34}

    {PLACE_IMAGE items/burial.png     23 33}
    {PLACE_IMAGE items/bonestack.png  25 29}

    {PLACE_IMAGE items/bonestack.png  15 20}

    {PLACE_IMAGE items/bonestack.png  18 32}

    # Igor's home
    {PLACE_IMAGE scenery/signpost.png 19  5}
    {PLACE_IMAGE items/burial.png     24  4}
    {PLACE_IMAGE items/burial.png     26  7}

    {PLACE_IMAGE scenery/underground_temple.png 18  5}

    {CAVE_NOISE_SOUND_SOURCE}

    {CAVE_WATER_SOUND_SOURCE 34 17}

    {CAVE_WATER_SOUND_SOURCE 23 27}

    {CAVE_WATER_SOUND_SOURCE 24 32}

    {CAVE_WATER_SOUND_SOURCE 15 22}

    {CAVE_WATER_SOUND_SOURCE 24 48}

    {STARTING_VILLAGES_ALL 3  }
    {STARTING_VILLAGES     2 4}
    {STARTING_VILLAGES     4 4}

    [event]
        name=prestart

        {ITEM_CRYSTAL_GLYPH_GATE ( 5,25,47) (42,51,48)}

        # Exit markers.
        [item]
            image=items/gohere.png
            # NOTE: This is the same SLF used for the victory trigger.
            x,y=48-52,54
            [or]
                # s
                x,y=25-29,54
            [/or]
            [or]
                # sw
                x,y=1,45-47
            [/or]
        [/item]

        {VARIABLE_RANDOM library_key_holder    2,3,4}
        {VARIABLE_RANDOM library_exit          sw,s,se}
        {VARIABLE        have_library_exit_key no}

        [switch]
            variable=library_exit
            [case]
                value=sw
                {TL_BLOCK_EXIT s }
                {TL_BLOCK_EXIT se}
            [/case]
            [case]
                value=s
                {TL_BLOCK_EXIT sw}
                {TL_BLOCK_EXIT se}
            [/case]
            [case]
                value=se
                {TL_BLOCK_EXIT sw}
                {TL_BLOCK_EXIT s }
            [/case]
        [/switch]

        [event]
            name=die
            delayed_variable_substitution=no
            [filter]
                canrecruit=yes
                side=$library_key_holder
            [/filter]

            [if]
                [have_unit]
                    x,y=$|x1,$|y1 # Delay variable substitution.
                    [not]
                        race=bats
                    [/not]
                    [not]
                        race=undead
                        [not]
                            type=Lich,Ancient Lich,Ghost,Wraith,Spectre,Shadow,Nightgaunt
                        [/not]
                    [/not]
                [/have_unit]
                [then]
                    [message]
                        speaker=second_unit
                        message= _ "Wait, I think I found something here..."
                    [/message]
                [/then]
                [else]
                    # wmllint: recognize Mal Keshar
                    [message]
                        speaker=Mal Keshar
                        scroll=no
                        message= _ "Hm, my minions found something..."
                    [/message]
                [/else]
            [/if]

            [transient_message]
                image="icons/crystal-shard.png"
                message= _ "You pick up a peculiar-looking crystal shard."
            [/transient_message]

            {VARIABLE have_library_exit_key yes}
        [/event]

#ifndef HARD
        [object]
            silent=yes
            duration=forever
            [filter]
                id=Galas
            [/filter]
            [effect]
                apply_to=movement_costs
                [movement_costs]
                    cave=-1
                [/movement_costs]
            [/effect]
        [/object]
#endif

        {PLAYER_RECRUITMENT_SETUP_FOR_SCENARIO 9}

        #
        # Recall heroes
        #

        # wmllint: recognize Anlindë
        {RECALL_ANLINDE_AT    45  5}
        # wmllint: recognize Mal Keshar
        {RECALL_MAL_KESHAR_AT 47  9}
        # wmllint: recognize Althurin
        {RECALL_ALTHURIN_AT   45  4}

        {FACE_DIRECTION (id=Galas)      se}
        {FACE_DIRECTION (id=Mal Keshar) sw}
        {FACE_DIRECTION (id=Anlindë)    nw}
        {FACE_DIRECTION (id=Althurin)   sw}

        [remove_shroud]
            side=1
            x,y=46,11
            radius=3
        [/remove_shroud]

        [remove_shroud]
            side=1
            x,y=50,3
            radius=7
            [filter_radius]
                terrain=!,X*,*^X*
            [/filter_radius]
        [/remove_shroud]

        [capture_village]
            side=1
            x=41-53
            y= 3-6
        [/capture_village]

        # Uncapture these two villages in the Shaxthal cave.

        [capture_village]
            x=58,61
            y=47,45
        [/capture_village]

        {OBJECTIVES (
            {OBJECTIVE_VICTORY ( _ "Explore and find the exit with Galas, Anlindë, or Mal Keshar")}
            {OBJECTIVE_BONUS           ( _ "Optional: Defeat all enemy leaders")}
            {OBJECTIVE_SHOW_IF         ({TL_ENEMIES_NOT_DEFEATED})}
            {OBJECTIVE_BONUS_COMPLETED ( _ "Optional: Defeat all enemy leaders")}
            {OBJECTIVE_SHOW_IF         ({TL_ENEMIES_DEFEATED})}

            {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}
        )}
    [/event]

    [event]
        name=start

        {INCIDENTAL_MUSIC "into_the_shadows.ogg"}

        [message]
            speaker=Galas
            message= _ "It’s hard to believe we’ve made it this far, in spite of all the obstacles in our way."
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Hah. You would never have survived the trials of the desert and the confrontations with those demons without me around, ready to save your useless posteriors."
        [/message]

        [message]
            speaker=Galas
            # po: He intends to ask Mal Keshar about his true intentions.
            message= _ "Sure, that is why we are grateful for your help. But before we proceed further, I must ask..."
        [/message]

        {MOVE_UNIT      id=Anlindë 46  6}
        {FACE_DIRECTION id=Anlindë se}

        [redraw]
            side=1
        [/redraw]

        [delay]
            time=500
        [/delay]

        [message]
            speaker=Anlindë
            message= _ "These passages appear to have been used relatively recently. We should be on the watch for enemies."
        [/message]

        [message]
            speaker=Galas
            message= _ "Right. Let us proceed cautiously, then."
        [/message]

        {MOVE_UNIT id=Galas 46  8}

        [message]
            speaker=Mal Keshar
            message= _ "What did you want to ask me, Galas?"
        [/message]

        [message]
            speaker=Galas
            message= _ "... Nothing important. Let’s go."
        [/message]

        {MOVE_UNIT      id=Galas 50  3}
        {FACE_DIRECTION id=Galas sw}

        {MOVE_UNIT      id=Anlindë 46  4}
        {FACE_DIRECTION id=Anlindë sw}

        {MOVE_UNIT      (id=Mal Keshar) 45  6}
        {FACE_DIRECTION (id=Mal Keshar) nw}

        [scroll_to_unit]
            id=Galas
        [/scroll_to_unit]

#ifndef HARD
        [message]
            speaker=narrator
            image=wesnoth-icon.png
            message= _ "As Galas has become accustomed to moving on rough cave terrains, his movement cost on them has decreased by one!"
        [/message]
#endif
    [/event]

    {ALTHURIN_1ST_TIME_HELP}

    [event]
        name=moveto
        [filter]
            side=1
            x=0-64
            y=16-54
        [/filter]

        {CLEAR_CAVE_SHROUD x,y,radius=33,18,4}

        [message]
            speaker=Galas
            message= _ "What is this? The ruins of an ancient city, here?"
        [/message]

        [message]
            speaker=Althurin
            message= _ "Hm, the runes on the floor and walls aren’t dwarvish. This is quite interestin’."
        [/message]
    [/event]

    [event]
        name=moveto
        [filter]
            side=1
            x,y=19,5
        [/filter]

        [allow_undo][/allow_undo]

        [message]
            speaker=narrator
            image="scenery/signpost.png"
            message= _ "GO AWAY"
        [/message]
    [/event]

    [event]
        id=igors_hideout_found_by_undead
        name=moveto
        first_time_only=no
        [filter]
            side=1
            x,y=18,5
            race=undead,bats
        [/filter]

        [message]
            speaker=narrator
            image=wesnoth-icon.png
            message= _ "You have found an interesting building, crude in design. There appears to be someone hiding inside.

You may want to get a living unit that is not a bat to take a look inside."
        [/message]
    [/event]

    [event]
        id=igors_hideout_found_by_living
        name=moveto
        first_time_only=no
        [filter]
            side=1
            x,y=18,5
            [not]
                race=undead,bats
            [/not]
        [/filter]

        [message]
            speaker=unit
            message= _ "It is a very unusual location for a home, but it appears that someone indeed lives here. The decorations in this cave seem recent and rushed, and I think I heard noise coming from inside the rustic building.

Should I leave, or take a look inside?"
            [option]
                label= _ "Leave, it may be dangerous."
                [command]
                    [allow_undo][/allow_undo]
                [/command]
            [/option]
            [option]
                label= _ "Surely whatever is hiding inside can’t be more trouble than the undead roaming about..."
                [command]
                    [fire_event]
                        name=meet igor
                        [primary_unit]
                            x,y=$x1,$y1
                        [/primary_unit]
                    [/fire_event]
                [/command]
            [/option]
        [/message]
    [/event]

    [event]
        name=meet igor

        [unit]
            # wmllint: recognize Igor
            {CHARACTER_STATS_IGOR}
            x,y=17,5
            side=1
            moves=5
            resting=no
            facing=se
        [/unit]

        [delay]
            time=500
        [/delay]

        [message]
            speaker=Igor
            message= _ "No! Please don’t kill meeee!" # wmllint: no spellcheck
        [/message]

        [message]
            speaker=unit
            message= _ "Huh? A goblin? How did you get here?"
        [/message]

        [message]
            speaker=Galas
            message= _ "You have nothing to fear, goblin. We are not here to kill you."
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "What, are you serious? He is a <i>goblin</i>, a miniature orc!"
        [/message]

        [message]
            speaker=Igor
            message= _ "I used to live in the northlands, in a small town populated by goblins, goblins like me! But then, those foul humans came and ransacked it all! They killed everyone, those ‘Chaos’ people... I escaped, and tried to find a safe place to live, deep in these caves..."
        [/message]

        [message]
            speaker=Igor
            message= _ "And then those horrors came here too! They woke up all those dangerous beasts from underground, and then they tried to turn me into their slave! Oh... so horrible..."
        [/message]

        [message]
            speaker=Galas
            message= _ "Seeing as how peril lurks behind every corner around here, would you perhaps prefer to join us? We could provide you with protection from those demons and the undead, if you agree to help us as well."
        [/message]

        [delay]
            time=500
        [/delay]

        [message]
            speaker=Igor
            message= _ "Really?! Oh... Yes! Yes, I would be very thankful if you let me join you, yes! Hang on, let me pack my things..."
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "This is a very bad idea, Galas! Galas! Are you even listening to me?"
        [/message]

        [message]
            speaker=Anlindë
            message= _ "It’s just a little goblin and his ferocious mount. What harm could possibly come of letting them fight alongside us? I would be far more concerned if we didn’t already allow a necromancer in our ranks..."
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Hmph. <small>Such careless words coming from an elf, <small>elves these days...</small></small>"
        [/message]

        [scroll_to_unit]
            id=Igor
        [/scroll_to_unit]

        [remove_event]
            id=igors_hideout_found_by_undead
        [/remove_event]

        [remove_event]
            id=igors_hideout_found_by_living
        [/remove_event]
    [/event]

    [event]
        name=turn 5

        [message]
            speaker=Mal Em-Nonaluz
            message= _ "The elves are here? Well, well, where the hell are our dear warlord’s troops? I suppose I will have to make do with what little I have, as usual."
        [/message]

        #
        # Only allow her to recruit undead from now on.
        #
        [set_recruit]
            side=3
            recruit=Ghost,Walking Corpse,Soulless
        [/set_recruit]

        [unit]
            id=Aralaija
            name= _ "Aralaija"
            side=3
            type=Demon Warrior
            gender=female
            x,y=34,37
            upkeep=free
            [modifications]
                {TRAIT_RESILIENT}
                {TRAIT_DEXTROUS}
            [/modifications]
        [/unit]

        [unit]
            id=Ferunghiel
            name= _ "Ferunghiel"
            side=3
            type=Demon Warrior
            x,y=38,37
            upkeep=free
            [modifications]
                {TRAIT_STRONG}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]

        [message]
            speaker=Galas
            message= _ "This is bad news. It appears the Chaos Empire’s forces somehow managed to get a head start. We need to stop them and secure these caves before they can advance any further!"
        [/message]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Mal Em-Nonaluz
        [/filter]

        [message]
            speaker=Mal Em-Nonaluz
            message= _ "You may take me down and win this battle, elf... but know this... The Warlord... the Warlord is coming... Flee while you can, and you may yet be able to enjoy your lives a few days more!"
        [/message]
    [/event]

    [event]
        name=die
        [filter]
            id=Mal Em-Nonaluz
        [/filter]

        [message]
            speaker=Galas
            message= _ "These fiends seem so confident in the might of this warlord of theirs. It’s rather troubling."
        [/message]

        [message]
            speaker=Althurin
            message= _ "Necromancers... there surely is no end to their arrogance, not even as they’re dyin’ — again. Ye shouldn’t give their words too much credit, lord Galas."
        [/message]
    [/event]

    [event]
        name=enemies defeated

        [show_objectives][/show_objectives]
    [/event]

    #
    # Secret touchplate.
    #

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

        [terrain]
            x,y=54,37
            terrain=Ur
        [/terrain]

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

        [item]
            x,y=54,37
            image=scenery/rubble.png
            redraw=no
        [/item]

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

    #
    # Prophecy of the Union.
    #

#define TL_PROPHECY_FRAGMENT _X _Y _MSG
    [literal]
        x={_X}
        y={_Y}
        message={_MSG}
    [/literal]
#enddef

    [event]
        name=prestart

        [set_variables]
            name=union_prophecy_fragments
            mode=replace

            {TL_PROPHECY_FRAGMENT 10 17
            ( _ "Long ago, during a forgotten age, the beings of Light and Darkness waged an endless war, ceasing only when Yarae the Arcane Lord appeared and took his place as arbiter.

With his great power, he created Ten Guardians to bring balance to the factions. Upon each guardian was then bestowed control over the different creatures and aspects of their power, and other great demons were created as needed to aid each in their task.")}

            {TL_PROPHECY_FRAGMENT 13 33
            ( _ "Yarae had unrivaled control over the forces of Light and Darkness. Wisdom and moderation were instrumental in this role, and he brought peace and prosperity for all... until an unknown force turned him against his peers, the gods of Light and Darkness.")}

            {TL_PROPHECY_FRAGMENT 36 39
            ( _ "As he fell victim to that corruption, so did the original Ten Guardians. Yarae led them and their subjects against the gods of Light and Darkness, and wreaked chaos and destruction upon all that existed. In the end, the gods joined their forces in a single entity capable of fighting this new evil: the Avatar of the Union of Light and Darkness was born.")}

            {TL_PROPHECY_FRAGMENT 49 33
            ( _ "Wielding the power of the Union and aided by the only three guardians who chose to stand against their creator, they managed to destroy their fallen brethren one by one. Finally, they put an end to his revolt and trapped him in the Void between worlds.")}

            {TL_PROPHECY_FRAGMENT 46 28
            ( _ "Of the remaining Ten, Uria and <i>(garbled)</i> were tasked with guarding the creatures that had been influenced and corrupted by Yarae’s touch, while <i>(garbled)</i> attended to undoing the great damage wreaked by him and his guardians across the lands. The power of the Union was lastly used to isolate the fallen creatures in a reality set apart from our own: Inferno.")}

            {TL_PROPHECY_FRAGMENT 54 20
            ( _ "The Union faded, leaving behind the Body of the Union and the twin orbs that held its essence. Fearing that the successors of the Ten could fall prey to the same corruption or that Yarae might escape his imprisonment, these relics were hidden away on Ethea, Irdya, and Norsula. Should the need ever arise again, two beings shall assume the mantle to protect our reality from the threat: one blessed with the power of the Orb of Light, the other with the power of the Orb of Darkness; and once both join their spirits, they shall become the new Avatars of the Union. And thus, the cycle will repeat until the Tree withers and eternity comes to an end.")}
        [/set_variables]

        #
        # Generate glyph event handlers, and place the map items.
        #

        [foreach]
            array=union_prophecy_fragments
            [do]
                {ITEM_CRYSTAL_GLYPH_MESSAGE $this_item.x $this_item.y}

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

                    [allow_undo][/allow_undo]

                    # Delay .message substitution until the event handler runs.
                    {MSG_GLYPH $|union_prophecy_fragments[$i].message}
                [/event]
            [/do]
        [/foreach]
    [/event]

    # Secret message glyph at 58,44 that contains the non-fragmented prophecy of the Union
    {ITEM_CRYSTAL_GLYPH_MESSAGE 58 44}
    [event]
        name=moveto
        [filter]
            x,y=58,44
            side=1
        [/filter]

        [allow_undo][/allow_undo]

        [foreach]
            array=union_prophecy_fragments
            [do]
                {MSG_GLYPH $this_item.message}
            [/do]
        [/foreach]
    [/event]

    [event]
        name=victory

        {CLEAR_VARIABLE union_prophecy_fragments}
    [/event]

    #
    # Other message glyphs.
    #

#define TL_GLYPH _X _Y _MSG
    {ITEM_CRYSTAL_GLYPH_MESSAGE {_X} {_Y} }

    [event]
        name=moveto
        [filter]
            x={_X}
            y={_Y}
            side=1
        [/filter]

        [allow_undo][/allow_undo]

        {MSG_GLYPH ({_MSG})}
    [/event]
#enddef

    {TL_GLYPH 34 36 ( _ "These message-encoding crystal glyphs were created by us, the Argazar civilization, so that our knowledge and technology could be preserved even past the end of our existence. It is our final hope that all of this information will not be used for malign purposes.")}

    {TL_GLYPH 34 38 ( _ "Mal Si’ah was here.")}

    {TL_GLYPH 38 38 ( _ "There are permanent gateways to Inferno hidden in many different worlds, protected by the chosen Gatekeepers of Iluvia.")}

    {FIRE_EVENT_ON_STUMBLE_UPON found_biped_leech (type=Giant Leech,Brain Drainer)}
    [event]
        name=found_biped_leech

        [message]
            speaker=second_unit
            message= _ "Skreeech!!" # wmllint: no spellcheck
        [/message]
    [/event]

    {FIRE_EVENT_ON_STUMBLE_UPON found_demon race=demon}
    [event]
        name=found_demon

        [message]
            speaker=second_unit
            message= _ "There they are! Get them!"
        [/message]
    [/event]

    [event]
        name=moveto
        [filter]
            side=1
            [filter_location]
                terrain=*^Xp
            [/filter_location]
        [/filter]

        [redraw][/redraw]

        [allow_undo][/allow_undo]

        [message]
            x,y=$x1,$y1
            {UNIT_SPEAKS_FOR_UNDEAD_MINION (id=Mal Keshar)}
            message= _ "I wonder where these holes in the ground lead to."
        [/message]
    [/event]

    #
    # Exit barrier glyphs.
    #

    [event]
        name=moveto
        first_time_only=no
        [filter]
            side=1
            x= 5,25,47
            y=42,51,48
        [/filter]
        [filter_condition]
            {VARIABLE_BOOLEAN_EQUALS have_library_exit_key no}
        [/filter_condition]

        [message]
            speaker=narrator
            image="items/crystal-glyph-gate.png"
            message= _ "Access denied — key glyph required."
        [/message]
    [/event]

    [event]
        name=moveto
        [filter]
            side=1
            x= 5,25,47
            y=42,51,48
        [/filter]
        [filter_condition]
            {VARIABLE_BOOLEAN_EQUALS have_library_exit_key yes}
        [/filter_condition]

        [message]
            speaker=narrator
            image="items/crystal-glyph-gate.png"
            message= _ "Access granted."
        [/message]

        [remove_terrain_overlays]
            x,y=$x1,$y1
            radius=1
            [and]
                terrain=*^Ii,*^Xo
            [/and]
        [/remove_terrain_overlays]

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

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

    #
    # Victory trigger event.
    #

    [event]
        name=moveto
        [filter]
            id=Galas,Mal Keshar,Anlindë
            [and]
                # se
                x,y=48-52,54
                [or]
                    # s
                    x,y=25-29,54
                [/or]
                [or]
                    # sw
                    x,y=1,45-47
                [/or]
            [/and]
        [/filter]

        [if]
            [have_unit]
                x,y=$x1,$y1
                id=Galas
            [/have_unit]
            [then]
                [message]
                    speaker=unit
                    message= _ "This path goes even deeper underground. I hesitate to continue."
                [/message]

                [message]
                    speaker=Anlindë
                    message= _ "There is no reason to hesitate, Galas. Wherever the Lady of Light is, we will be safe."
                [/message]

                [message]
                    speaker=Galas
                    message= _ "I hope so..."
                [/message]
            [/then]
            [else]
                [message]
                    speaker=unit
                    message= _ "This path goes even deeper underground."
                [/message]

                [message]
                    speaker=Mal Keshar
                    message= _ "We must continue. I feel we are <i>very</i> close to our destination now."
                [/message]
            [/else]
        [/if]

        [if]
            [have_unit]
                canrecruit=yes
                [not]
                    side=1
                [/not]
            [/have_unit]
            [then]
                {ENDLEVEL_VICTORY no}
            [/then]
            [else]
                {ENDLEVEL_VICTORY yes}
            [/else]
        [/if]
    [/event]

    [event]
        name=victory

        {CLEAR_VARIABLE have_library_exit_key,library_key_holder,library_exit}
    [/event]
[/scenario]

#undef TL_PALETTE_OVERRIDE
#undef TL_ENEMIES_DEFEATED
#undef TL_ENEMIES_NOT_DEFEATED
#undef TL_BLOCK_EXIT
#undef TL_CAVE_DWELLER
#undef TL_GLYPH
#undef TL_PROPHECY_FRAGMENT

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