#textdomain wesnoth-Invasion_from_the_Unknown

[scenario]
    id=21_Innuendo
    name= _ "Innuendo"
    {MAP 21_Innuendo.map}
    {TURNS 98 93 90}
    next_scenario=22A_Face_of_the_Enemy
    victory_when_enemies_defeated=no

    {SCENARIO_MUSIC       "siege_of_laurelmor.ogg"}
    {EXTRA_SCENARIO_MUSIC "the_deep_path.ogg"}
    {EXTRA_SCENARIO_MUSIC "western_theme2.ogg"}
    {EXTRA_SCENARIO_MUSIC "knalgan_theme.ogg"}

    {INDOORS} {SCHEDULE_LIGHTING -30 -40 -20}

    {STORYTXT_INNUENDO}

    {DEATHS_ACT_4}

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

        shroud=yes

        {NO_ECONOMY}
        # Minimum gold for 8 recalls
        gold=160

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

    [side]
        side=2
        team_name=enemies
        user_team_name= _ "team_name^Central Garrison"
        {CHAOS_FLAG}
        color=gold

        hidden=yes
        {NO_ECONOMY}

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

            {AI_BOSS_TARGETING_ENGINE <<{"Galas","Elynia","Mal Keshar"}>>}
        [/ai]

        canrecruit=yes
        type=Armageddon Imp
        id=Cragworg
        name= _ "Cragworg"
        facing=sw
        {IS_BOSS}
        [modifications]
            {TRAIT_SLOW}
            {TRAIT_RESILIENT}
            {BOSS_BOOST 100% 3 1 2 0}
        [/modifications]

        {SIDE_GENERIC_UNIT (Shaxthal Assault Drone) 34 14} {FACING sw}
        {SIDE_GENERIC_UNIT (Shaxthal Assault Drone) 37 16} {FACING sw}

        {SIDE_GENERIC_UNIT (Demon Grunt) 38 14} {FACING sw}
#ifdef EASY
        {SIDE_GENERIC_UNIT (Demon Grunt) 37 14} {FACING sw}
#else
        {SIDE_GENERIC_UNIT (Demon Warrior) 37 14} {FACING sw}
#endif
        {SIDE_GENERIC_UNIT (Demon Grunt) 36 13} {FACING sw}

        {SIDE_GENERIC_UNIT (Blood Imp) 39 16} {FACING sw}
        {SIDE_GENERIC_UNIT (Blood Imp) 33 13} {FACING sw}

        [unit]
            type=Demon Grunt
            id=Aelyriun-Balal
            name= _ "Aelyriun-Balal"
            gender=female
            x,y=39,13
            upkeep=free
            facing=sw
            [modifications]
                {TRAIT_STRONG}
                {TRAIT_DEXTROUS}
            [/modifications]
        [/unit]
    [/side]

    [side]
        side=3
        team_name=enemies
        user_team_name= _ "team_name^Central Garrison"
        {CHAOS_FLAG}

        recruit=Ghoul,Skeleton Archer,Ghost,Vampire Bat,Bone Shooter,Walking Corpse
        {INCOME 5 6 6}

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

        canrecruit=yes
        type=Ancient Lich
        id=Mal Vritra
        name= _ "Mal Vritra"
        gender=female
        [modifications]
            {TRAIT_UNDEAD}
            {TRAIT_QUICK}
        [/modifications]

        {SIDE_GENERIC_GUARD (Abomination) 13 11} {FACING se}
        {SIDE_GENERIC_GUARD (Abomination) 10 12} {FACING se}

        {SIDE_GENERIC_GUARD (Ghast) 13 13} {FACING se}

        {SIDE_GENERIC_GUARD ({DIFF Necrophage Ghast Ghast}) 17 17} {FACING sw}

        {SIDE_GENERIC_GUARD (Revenant) 16 14} {FACING sw}
        {SIDE_GENERIC_GUARD (Banebow)  14 15} {FACING se}

        {SIDE_GENERIC_GUARD (Necrophage) 63 28}

        {SIDE_GENERIC_GUARD (Soulless) 60 31} {VARIATION bat}
        {SIDE_GENERIC_GUARD (Soulless) 64 21} {VARIATION bat}
        {SIDE_GENERIC_GUARD (Blood Bat) 63 23}

#ifndef EASY
        {SIDE_GENERIC_GUARD (Wraith) 47 10} {FACING sw}
        {SIDE_GENERIC_GUARD (Wraith) 48 20} {FACING nw}
#endif

        {SIDE_GENERIC_GUARD (Spectre) 51  4} {FACING sw}
        {SIDE_GENERIC_GUARD (Shadow) 59  7} {FACING sw}

        {SIDE_GENERIC_GUARD (Draug) 32 10} {FACING se}
        {SIDE_GENERIC_GUARD (Draug) 34  9} {FACING sw}

        {SIDE_GENERIC_GUARD (Wraith)  8  8} {FACING sw}
        {SIDE_GENERIC_GUARD (Wraith) 11  7} {FACING sw}

        {SIDE_GENERIC_GUARD (Spectre) 14 18} {FACING sw}

        {SIDE_GENERIC_GUARD (Spectre) 61 29} {FACING ne}
    [/side]

    [side]
        side=4
        team_name=enemies
        user_team_name= _ "team_name^Central Garrison"
        {CHAOS_FLAG}

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

        type=Shaxthal Sentry Drone
        id=Nemaara
        name= _ "Nemaara"
        {IS_BOSS}
        [modifications]
            {TRAIT_BIOMECHANICAL}
            {TRAIT_ARMORED}
            {TRAIT_RESILIENT}
            {BOSS_BOOST 90% 2 0 1 1}
            [object]
                [effect]
                    apply_to=image_mod
                    add="PAL(shaxthal_drone_base>shaxthal_drone_brown)"
                [/effect]
            [/object]
        [/modifications]

        {SIDE_GENERIC_GUARD (Shaxthal Sentry Drone) 24 26} {FACING sw}
        {SIDE_GENERIC_GUARD (Shaxthal Sentry Drone) 24 28} {FACING sw}

        {SIDE_GENERIC_GUARD (Shaxthal Sentry Drone)  2 18} {FACING se}
        {SIDE_GENERIC_GUARD (Shaxthal Sentry Drone)  6 18} {FACING sw}

        {SIDE_GENERIC_GUARD (Shaxthal Assault Drone) 27  8} {FACING se}
        {SIDE_GENERIC_GUARD (Shaxthal Assault Drone) 38  3} {FACING sw}

        {SIDE_GENERIC_GUARD (Shaxthal Drone) 40  5} {FACING sw}

        {SIDE_GENERIC_GUARD (Shaxthal Drone) 65  4}
        {SIDE_GENERIC_GUARD (Shaxthal Drone) 65  8}
        {SIDE_GENERIC_GUARD (Shaxthal Drone) 68  8}
#ifndef EASY
        {SIDE_GENERIC_GUARD (Shaxthal Sentry Drone) 68  5} {FACING sw}
        {SIDE_GENERIC_GUARD (Shaxthal Sentry Drone) 63  8} {FACING nw}
#endif
        {SIDE_GENERIC_GUARD (Shaxthal Assault Drone) 64 15}

#ifndef EASY
        {SIDE_GENERIC_GUARD (Shaxthal Rayblade)  4 40} {FACING ne}
#endif

        {SIDE_GENERIC_GUARD (Shaxthal Rayblade)  6 25} {FACING sw}
        {SIDE_GENERIC_GUARD (Shaxthal Rayblade) 19 28} {FACING sw}
#ifndef EASY
        {SIDE_GENERIC_GUARD (Shaxthal Rayblade) 23 11} {FACING sw}
#endif

        {SIDE_GENERIC_GUARD ({DIFF (Shaxthal Runner Drone) (Shaxthal Protector Drone) (Shaxthal Protector Drone)}) 21  8} {FACING se}

        {SIDE_GENERIC_GUARD (Shaxthal Rayblade) 32  7} {FACING se}
        {SIDE_GENERIC_GUARD (Shaxthal Rayblade) 34  7} {FACING se}

        {SIDE_GENERIC_GUARD (Shaxthal Protector Drone) 33  5} {FACING se}
        {SIDE_GENERIC_GUARD (Shaxthal Protector Drone) 31  6} {FACING se}
        {SIDE_GENERIC_GUARD (Shaxthal Protector Drone) 35  6} {FACING se}

        {SIDE_GENERIC_GUARD (Shaxthal Rayblade) 24 18} {FACING se}

        {SIDE_GENERIC_GUARD (Shaxthal Protector Drone) 28 17} {FACING sw}
        {SIDE_GENERIC_GUARD (Shaxthal Protector Drone) 30 18} {FACING sw}
    [/side]

    [side]
        side=5
        team_name=enemies
        user_team_name= _ "team_name^Central Garrison"
        {CHAOS_FLAG}

        recruit=Chaos Invader,Chaos Headhunter,Chaos Invoker,Demon
        {INCOME 4 5 6}

        canrecruit=yes
        type=Chaos Arbalestier
        id="Ra'aldir"
        name= _ "Ra’aldir"
        [modifications]
            {TRAIT_DEXTROUS}
            {TRAIT_STRONG}
            [object]
                [effect]
                    apply_to=attack
                    range=ranged
                    [set_specials]
                        mode=append
                        {WEAPON_SPECIAL_POISON}
                    [/set_specials]
                [/effect]
            [/object]
        [/modifications]

        {SIDE_GENERIC_GUARD (Chaos Razerman)  5 24}
        {SIDE_GENERIC_GUARD (Chaos Razerman) 17 23}

        {SIDE_GENERIC_UNIT (Doom Guard) 40 34} {FACING se}
        {SIDE_GENERIC_UNIT (Hell Guardian) 37 32} {FACING se}

        {SIDE_GENERIC_UNIT (Chaos Longbowman) 35 25} {FACING sw}
        {SIDE_GENERIC_UNIT (Chaos Longbowman) 32 25} {FACING se}

        {SIDE_GENERIC_GUARD (Chaos Magus) 27 34} {FACING se}
        {SIDE_GENERIC_GUARD (Chaos Magus) 26 39} {FACING nw}
        {SIDE_GENERIC_GUARD (Chaos Magus) 22 27} {FACING sw}

        [unit]
            type=Lich
            id=Mal Abbadur
            name= _ "Mal Abbadur"
            upkeep=free
            ai_special=guardian
            x,y=22,25
            facing=sw
            [modifications]
                {TRAIT_UNDEAD}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]

        {SIDE_GENERIC_UNIT (Demon Zephyr) 43 15}
        {SIDE_GENERIC_UNIT (Demon Zephyr) 40 18}
        {SIDE_GENERIC_UNIT (Demon Zephyr) 41 12}
        {SIDE_GENERIC_UNIT (Demon Zephyr) 31  4}

        {SIDE_GENERIC_GUARD (Demon Warrior) 20 36} {FACING ne}
        {SIDE_GENERIC_GUARD (Demon Grunt)   18 39} {FACING ne}
        {SIDE_GENERIC_GUARD (Demon Warrior) 15 35} {FACING ne}
        {SIDE_GENERIC_GUARD (Demon Warrior) 11 38} {FACING ne}

        {SIDE_GENERIC_GUARD (Imp) 20 33}
        {SIDE_GENERIC_GUARD (Imp) 12 32}
        {SIDE_GENERIC_GUARD (Imp) 13 41}
        {SIDE_GENERIC_GUARD (Imp) 20 39}
        {SIDE_GENERIC_GUARD (Imp)  8 39}

        {SIDE_GENERIC_GUARD (Blood Imp) 16 36} {FACING se}

        {SIDE_GENERIC_GUARD (Gutwrencher Imp) 14 38} {FACING ne}

        {SIDE_GENERIC_GUARD (Hell Guardian)  6 43} {FACING nw}
        {SIDE_GENERIC_GUARD (Chaos Magus)    4 35} {FACING se}
    [/side]

    [side]
        side=6
        team_name=enemies
        user_team_name= _ "team_name^Heart Hive"
        {CHAOS_FLAG}

        no_leader=yes
        hidden=yes

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

        {SIDE_GENERIC_UNIT (Verlissh Matrix Flow System) 20 14}
        {SIDE_GENERIC_UNIT (Verlissh Matrix Flow System) 21 15}
        {SIDE_GENERIC_UNIT (Verlissh Matrix Flow System) 21 11}
        {SIDE_GENERIC_UNIT (Verlissh Matrix Flow System) 22 11}
        {SIDE_GENERIC_UNIT (Verlissh Matrix Flow System) 25 18}

        {SIDE_GENERIC_UNIT (Verlissh Matrix Flow System) 68 11}

        {SIDE_GENERIC_GUARD (Psy Crawler) 23 10}
        {SIDE_GENERIC_GUARD (Psy Crawler) 26 14}
        {SIDE_GENERIC_GUARD (Psy Crawler) 67 12}
        {SIDE_GENERIC_GUARD (Psy Crawler) 63 17} {FACING ne}
        {SIDE_GENERIC_GUARD (Psy Crawler) 51 25}

        {SIDE_GENERIC_GUARD (Psy Crawler)  3 17} {FACING se}
        {SIDE_GENERIC_GUARD (Psy Crawler)  5 17} {FACING sw}
        {SIDE_GENERIC_GUARD (Psy Mindraider)  4 16} {FACING s}
    [/side]

    [side]
        side=7
        team_name=enemies
        user_team_name= _ "team_name^Central Garrison"
        {CHAOS_FLAG}

        no_leader=yes
        hidden=yes
        {NO_ECONOMY}

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

        {SIDE_GENERIC_GUARD (Shadow Spawn)  7 10}
        {SIDE_GENERIC_GUARD (Shadow Spawn) 15  9}
        {SIDE_GENERIC_GUARD (Shadow Spawn) 32  2}

        {SIDE_GENERIC_GUARD (Goliath) 34  2}

        {SIDE_GENERIC_GUARD (Goliath) 26 19} {FACING sw}

        {SIDE_GENERIC_GUARD (Goliath)  5 31} {FACING se}

        {SIDE_GENERIC_GUARD (Iron Golem) 17 29} {FACING sw}
        {SIDE_GENERIC_GUARD (Iron Golem) 24 35} {FACING ne}

        {SIDE_GENERIC_GUARD (Automaton) 12 34}
        {SIDE_GENERIC_GUARD (Automaton) 18 34}
        {SIDE_GENERIC_GUARD (Automaton) 18 37}
        {SIDE_GENERIC_GUARD (Automaton) 15 40}

        {SIDE_GENERIC_GUARD (Death Knight) 14 36} {FACING se}
    [/side]

    [side]
        side=8
        team_name=enemies
        user_team_name= _ "team_name^Central Garrison"
        {CHAOS_FLAG}

        no_leader=yes
        hidden=yes
        {NO_ECONOMY}
    [/side]

    {STARTING_VILLAGES_ALL 2}
    {STARTING_VILLAGES 3 6}

    {CAVE_NOISE_SOUND_SOURCE}

    {CAVE_WATER_SOUND_SOURCE 32 38}
    {CAVE_WATER_SOUND_SOURCE 64 30}
    {CAVE_WATER_SOUND_SOURCE  5 10}
    {CAVE_WATER_SOUND_SOURCE 12  4}
    {CAVE_WATER_SOUND_SOURCE 51  4}
    {CAVE_WATER_SOUND_SOURCE 59  6}

    {SET_LABEL 48  8 ( _ "Dungeon")}
    {SET_LABEL 53 18 ( _ "Dungeon")}

    {PLACE_IMAGE ("items/bones.png") 53 12}
    {PLACE_IMAGE ("items/bones.png") 64 24}
    {PLACE_IMAGE ("items/bones.png")  6 10}
    {PLACE_IMAGE ("items/bones.png~FL(horiz)") 16  7}
    {PLACE_IMAGE ("items/bones.png~FL(horiz)") 28 23}

    {PLACE_IMAGE ("scenery/rock3.png") 63 30}

    {FINAL_SCENARIO_PLAYER_RECRUITMENT}

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

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

#define IN_NOTE_NO_RECRUIT_RECALL
    {OBJECTIVE_NOTE ( _ "You may not recall or recruit units")} {IN_NOTE_ONLY_ON_GAMEPLAY_TURNS}
#enddef

    [event]
        name=prestart

        {PLACE_IMAGE ("items/gohere.png") 32-34 1}

        {SCATTER_RANDOM_IMAGE (
            terrain=!,*^Xp,!,Urb,Urb^*,Yh*,Yh*^*
            x=43-73
            y= 1-25
        ) 24 scenery/gibs1.png,scenery/gibs2.png,scenery/gibs3.png}

        [setup_doors]
            side=8
        [/setup_doors]

        [store_locations]
            terrain=C*
            [and]
                x,y=44,28
                radius=8
            [/and]
            [not]
                x=39,40,41
                y=30,30,31
            [/not]
            variable=entrance_spawn_locs
        [/store_locations]

        [foreach]
            array=entrance_spawn_locs
            variable=loc

            [do]
                {VARIABLE spawn "$(if($i % 2 = 0, 'yes', 'no'))"}

                [if]
                    {VARIABLE_BOOLEAN_EQUALS spawn yes}
                    [then]
                        {RANDOM "Chaos Invader,Chaos Invader,Chaos Invader,Chaos Invader,Chaos Invader,Chaos Invoker,Chaos Invoker,Chaos Bowman,Chaos Bowman,Chaos Bowman,Doom Guard,Demon,Demon,Demon,Blood Imp,Imp,Demon Zephyr,Demon Grunt"}

                        [unit]
                            side=5
                            type=$random
                            generate_name=yes
                            random_traits=yes
                            random_gender=yes
                            x,y=$loc.x,$loc.y
                        [/unit]
                    [/then]
                [/if]
            [/do]
        [/foreach]

        {CLEAR_VARIABLE entrance_spawn_locs,random}

        [store_locations]
            [filter]
                type=Shaxthal Sentry Drone,Shaxthal Drone
                [not]
                    canrecruit=yes
                [/not]
            [/filter]
            variable=shaxthal_repal_locs
        [/store_locations]

        [foreach]
            array=shaxthal_repal_locs
            variable=loc
            [do]
                [object]
                    silent=yes
                    [filter]
                        x,y=$loc.x,$loc.y
                    [/filter]
                    [effect]
                        apply_to=image_mod
                        add="PAL(shaxthal_drone_base>shaxthal_drone_cyan)"
                    [/effect]
                [/object]
            [/do]
        [/foreach]

        {CLEAR_VARIABLE shaxthal_repal_locs}

        #
        # Disable some sides that get activated by events later.
        #

        [modify_side]
            side=2,3
            controller=null
        [/modify_side]

        # These sides get used for sentries all over the map, so we can't lump
        # them together with the rest in the filter above.

        [store_unit]
            [filter]
                id=Nemaara
            [/filter]
            kill=yes
            variable=nemaara_store
        [/store_unit]

        [store_unit]
            [filter]
                id="Ra'aldir"
            [/filter]
            kill=yes
            variable=raaldir_store
        [/store_unit]

        #
        # Recall heroes
        #

        # wmllint: recognize Elynia
        {RECALL_ELYNIA_AT 46 36}
        # wmllint: recognize Mal Keshar
        {RECALL_MAL_KESHAR_AT 46 37}
        # wmllint: recognize Erathan
        {RECALL_ERATHAN_AT 45 37}
        # wmllint: recognize Igor
        {RECALL_IGOR_AT 48 37}

        {FACE_DIRECTION (side=1) nw}

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

        [store_locations]
            terrain=*^Cov
            [and]
                x,y=$galas_store.x,$galas_store.y
                radius=8
            [/and]
            variable=player_castle_locs
        [/store_locations]

        {OBJECTIVES (
            {OBJECTIVE_VICTORY ( _ "Explore and descend deeper underground with Galas, Elynia, or Mal Keshar")}

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

            {TURNS_RUN_OUT}

            {OBJECTIVE_FULL_CARRYOVER}

            {OBJECTIVE_NOTE ( _ "In this scenario, you may only recall or recruit units during the first turn, in your starting area")}
            {IN_NOTE_ONLY_ON_FIRST_TURN}
            {OBJECTIVE_NOTE ( _ "Only those units you recall or recruit during the first turn will be available for the remainder of the campaign")}
            {IN_NOTE_ONLY_ON_FIRST_TURN}
            {IN_NOTE_NO_RECRUIT_RECALL}
        )}

        {CLEAR_CAVE_SHROUD x,y,radius=52,39,5}

        [mute_sound_effects][/mute_sound_effects]

        [hide_unit][/hide_unit]

        {BLACK_SCREEN}

        {LOCK_VIEW}
    [/event]

    [event]
        name=start

        [fade_in_sound_effects]
            duration=500
        [/fade_in_sound_effects]

        {FADE_IN}

        [move_unit_fake]
            side=1
            type=$galas_store.type
            x=57,$galas_store.x
            y=42,$galas_store.y
            image_mods="RC(magenta>brown)"
            force_scroll=no
        [/move_unit_fake]

        [unhide_unit][/unhide_unit]

        {CLEAR_VARIABLE galas_store}

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Elynia
            message= _ "A presence... A strong, dark presence fills this whole place, as if the floor and walls had a life of their own. I don’t like this."
        [/message]

        {MYSTERIOUS_VOICE ( _ "Thus you dare enter my stronghold. You truly are a foolish hero, Galas.")}

        [message]
            speaker=Galas
            message= _ "... It’s that voice again."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Reveal yourself, coward who hides in the darkness! We have come here to put an end to your reign of chaos and suffering!"
        [/message]

        {QUAKE rumble.ogg}

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

        [message]
            speaker=Erathan
            message= _ "That metallic laughter sure sounded real to me."
        [/message]

        [message]
            speaker=Galas
            message= _ "He seems to want us to move forward, so let us be on the look out for traps. And... we need to find a way to open this gate."
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Oh, please, courtesy is wasted in a place like this. Just blast them down or something."
        [/message]

        {MOVE_UNIT id=Erathan 44 36}

        [animate_unit]
            [filter]
                id=Erathan
            [/filter]

            flag=attack
            hits=kill
            with_bars=yes
            [primary_attack]
                range=melee
            [/primary_attack]

            [facing]
                [filter]
                    type=Door
                    [filter_adjacent]
                        id=Erathan
                    [/filter_adjacent]
                [/filter]
            [/facing]

            [animate]
                [filter]
                    type=Door
                    [filter_adjacent]
                        id=Erathan
                    [/filter_adjacent]
                [/filter]
                flag=defend
                with_bars=yes
            [/animate]
        [/animate_unit]

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

        [kill]
            type=Door
            [filter_adjacent]
                id=Erathan
            [/filter_adjacent]
            fire_event=yes
            animate=no
        [/kill]

        [redraw]
            side=1
        [/redraw]

        [delay]
            time=750
        [/delay]

        [message]
            x,y=40,34
            message= _ "Drop your weapons this instant, elf, and the Master may yet show you and your friends mercy!"
        [/message]

        [message]
            speaker=Galas
            message= _ "Never! Onwards, everyone!"
        [/message]

        [transient_message]
            message= _ "Choose your recruits and recalls carefully. They will not require upkeep, but you should try to keep them alive for as long as possible; no other units will be available to you for the remainder of the campaign."
        [/transient_message]

        [item]
            image=items/gohere.png
            find_in=player_castle_locs
        [/item]

        {HIGHLIGHT_GOAL find_in=player_castle_locs}

        {UNLOCK_VIEW}
    [/event]

    [event]
        name=turn 2

        [remove_item]
            find_in=player_castle_locs
        [/remove_item]

        [remove_terrain_overlays]
            find_in=player_castle_locs
        [/remove_terrain_overlays]

        {CLEAR_VARIABLE player_castle_locs}

        #
        # Store side 1's recall list for use later.
        #

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

        {REMOVE_RECRUIT_LIST 1}

        [show_objectives][/show_objectives]
    [/event]

#define IN_SPEAKER_IS_UNIT_OR_MAL_KESHAR
    x,y=$x1,$y1
    {UNIT_SPEAKS_FOR_UNDEAD_MINION (id=Mal Keshar)}
#enddef

    ############################################################################
    #                                                                          #
    #                             ITEMS AND TRIGGERS                           #
    #                                                                          #
    ############################################################################

    #
    # Event-triggering items
    #

    {PLACE_IMAGE ("items/box.png")  4 39}

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

        [allow_undo][/allow_undo]

        [message]
            {IN_SPEAKER_IS_UNIT_OR_MAL_KESHAR}
            message= _ "The crate is full of metal parts. I guess they are meant for some kind of machine."
        [/message]
    [/event]

    {PLACE_IMAGE ("items/box.png")  3 41}

    [event]
        name=moveto
        [filter]
            side=1
            x,y=3,41
        [/filter]

        [allow_undo][/allow_undo]

        [message]
            {IN_SPEAKER_IS_UNIT_OR_MAL_KESHAR}
            message= _ "Books? What business do these fiends have reading <i>books</i>?"
        [/message]
    [/event]

    {PLACE_IMAGE ("items/box.png")  9 44}

    [event]
        name=moveto
        [filter]
            side=1
            x,y=9,44
        [/filter]

        [allow_undo][/allow_undo]

        [message]
            {IN_SPEAKER_IS_UNIT_OR_MAL_KESHAR}
            message= _ "It’s an empty crate."
        [/message]
    [/event]

    {PLACE_IMAGE ("items/box.png")  9 23}

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

        [allow_undo][/allow_undo]

        [message]
            {IN_SPEAKER_IS_UNIT_OR_MAL_KESHAR}
            message= _ "It’s full of bread. Very stale bread."
        [/message]
    [/event]

    {PLACE_IMAGE ("items/barrel.png")  7 43}

    [event]
        name=moveto
        [filter]
            side=1
            x,y=7,43
        [/filter]

        [allow_undo][/allow_undo]

        [message]
            {IN_SPEAKER_IS_UNIT_OR_MAL_KESHAR}
            message= _ "It’s an empty barrel."
        [/message]
    [/event]

    {PLACE_IMAGE ("items/barrel.png")  7 45}

    [event]
        name=moveto
        [filter]
            side=1
            x,y=7,45
        [/filter]

        [allow_undo][/allow_undo]

        [message]
            {IN_SPEAKER_IS_UNIT_OR_MAL_KESHAR}
            message= _ "Oh gods... It’s full of fish! Argh! But we are in the middle of a desert, so where did they get them from?"
        [/message]
    [/event]

    {PLACE_IMAGE ("items/barrel.png") 14  6}

    [event]
        name=moveto
        [filter]
            side=1
            x,y=14,6
        [/filter]

        [allow_undo][/allow_undo]

        [message]
            {IN_SPEAKER_IS_UNIT_OR_MAL_KESHAR}
            message= _ "There seems to be nothing but coal in here."
        [/message]
    [/event]

    {PLACE_IMAGE ("items/barrel.png")  7 12}

    [event]
        name=moveto
        [filter]
            side=1
            x,y=7,12
        [/filter]

        [allow_undo][/allow_undo]

        [message]
            {IN_SPEAKER_IS_UNIT_OR_MAL_KESHAR}
            message= _ "It gives off such a foul smell I don’t think I want to see the contents. Let’s leave it alone, shall we?"
        [/message]
    [/event]

    {PLACE_IMAGE ("items/barrel.png") 32 21}

    [event]
        name=moveto
        [filter]
            side=1
            x,y=32,21
        [/filter]

        [allow_undo][/allow_undo]

        [message]
            {IN_SPEAKER_IS_UNIT_OR_MAL_KESHAR}
            message= _ "... Eyes. It’s full of eyes."
        [/message]
    [/event]

    {PLACE_IMAGE ("items/armor-golden.png")  3 40}

    [event]
        name=moveto
        [filter]
            side=1
            x,y=3,40
        [/filter]

        [allow_undo][/allow_undo]

        [message]
            {IN_SPEAKER_IS_UNIT_OR_MAL_KESHAR}
            message= _ "Hmph, why would anyone craft armor out of pure gold? Everyone knows it’s one of the softest materials on Irdya. These ostentatious fiends..."
        [/message]
    [/event]

    {PLACE_IMAGE ("items/chest-plain-open.png")  4 34}

    [event]
        name=moveto
        [filter]
            side=1
            x,y=4,34
        [/filter]

        [allow_undo][/allow_undo]

        [message]
            {IN_SPEAKER_IS_UNIT_OR_MAL_KESHAR}
            message= _ "This chest is empty."
        [/message]
    [/event]

    {PLACE_IMAGE ("items/chest-plain-open.png")  9 45}

    [event]
        name=moveto
        [filter]
            side=1
            x,y=9,45
        [/filter]

        [allow_undo][/allow_undo]

        [message]
            {IN_SPEAKER_IS_UNIT_OR_MAL_KESHAR}
            message= _ "Yep, nothing to see here."
        [/message]
    [/event]

    {PLACE_IMAGE ("items/chest-plain-closed.png") 8 45}

    [event]
        name=moveto
        [filter]
            side=1
            x,y=8,45
        [/filter]

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

        {PLACE_IMAGE ("items/chest-plain-open.png") $x1 $y1}

        [sound]
            name=open-chest.wav
        [/sound]

        [delay]
            time=500
        [/delay]

        {RETRIEVE_GOLD {DIFF 180 160 140} }

        [message]
            {IN_SPEAKER_IS_UNIT_OR_MAL_KESHAR}
            message= _ "It’s not like we will need the gold any time soon, but there is nothing wrong with a little plundering, right?"
        [/message]
    [/event]

    {PLACE_IMAGE ("scenery/bookshelf-full.png")  6 42}

    [event]
        name=moveto
        [filter]
            side=1
            x,y=6,42
        [/filter]

        [allow_undo][/allow_undo]

        # wmllint: local spellings alvorian lancespade
        # wmllint: display on

        # Text by vultraz.
        [message]
            speaker=narrator
            image=icons/scroll_red.png
            caption= _ "Invisibility Tonic"
            message= _ " • 1× clipped faerie wing
 • 1× eye of blood bat
 • 2× sprig of alvorian shade flower
 • 1× lancespade powder
 • 3× blue moon wisps

Combine faerie wings with blood bat eye. Mix well and boil in iron cauldron for two hours. Add rest of ingredients, stirring. Makes 5 beakers of invisibility tonic."
        [/message]

        # wmllint: display off
    [/event]

    {PLACE_IMAGE ("scenery/bookshelf-full.png")  3 35}

    [event]
        name=moveto
        [filter]
            side=1
            x,y=3,35
        [/filter]

        [allow_undo][/allow_undo]

        # Text by vultraz.
        [message]
            speaker=narrator
            image=icons/scroll_red.png
            caption= _ "Chaos Warlord Field Report #452"
            message= _ "The elf sorceress is dead. I did not expect her to bring the entire cavern down on us; sadly for her, I simply dug my way out of the rubble with the help of a few drone servants. Even had I not seen her crushed and broken body, I knew there was no way she could have saved herself — not that the vacuous creature would have done so anyway. A curious trait, self-sacrifice. Unfortunately, she managed to buy the Lady of Light time to escape. But no matter. In the end, they will come to us..."
        [/message]
    [/event]

    #
    # Collectables.
    #

    {POTION_OF_DEFTNESS_S21 31 21}

    {POTION_OF_STRENGTH_S21  6 44}

    {ACCURACY_BOW            8 43}

    {ARCANE_SHOT_AMULET     69  8}

    {CHILLING_BLADE         61 31}

    #
    # Dungeon prisoners.
    #

    [event]
        name=prestart

        {VARIABLE prisoners_remaining 0}
    [/event]

#define IN_CAGE _IMG _COLOR _X _Y _EVENT_NAME
    {PLACE_IMAGE {_IMG}+"~RC(magenta>"+{_COLOR}+")" {_X} {_Y} }
    {PLACE_IMAGE items/cage.png                     {_X} {_Y} }

    [event]
        name=prestart

        {VARIABLE_INC prisoners_remaining}

        [terrain]
            x={_X}
            y={_Y}
            terrain=^Xo
            layer=overlay
        [/terrain]
    [/event]

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

        {VARIABLE cage.x {_X} }
        {VARIABLE cage.y {_Y} }

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

        [remove_item]
            x,y=$cage.x,$cage.y
        [/remove_item]

        [redraw]
            side=1
        [/redraw]

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

        [store_direction]
            from_x,from_y=$cage.x,$cage.y
            to_x,to_y=$x1,$y1
        [/store_direction]

        [fire_event]
            name={_EVENT_NAME}
            [primary_unit]
                x,y=$x1,$y1
            [/primary_unit]
        [/fire_event]

        {CLEAR_VARIABLE cage,direction}

        {VARIABLE_DEC prisoners_remaining}

        [fire_event]
            name=dungeon prisoners check
        [/fire_event]
    [/event]
#enddef

    {IN_CAGE units/undead/soulless-troll.png       red   55  2 "release zombie troll"}
    {IN_CAGE units/undead/soulless-swimmer.png     red   46  3 "release merzombie"   }
    {IN_CAGE units/undead/zombie-drake.png         green 61 11 "release zombie drake"}
    {IN_CAGE "units/elves-wood/lord.png~FL(horiz)" teal  65 16 "release ledinor"     }

    [event]
        name=release zombie troll

        {LOYAL_UNIT 1 Soulless $cage.x $cage.y} {VARIATION troll} {FACING $direction}
        [+unit]
            animate=yes
        [/unit]
    [/event]

    [event]
        name=release merzombie

        {LOYAL_UNIT 1 Soulless $cage.x $cage.y} {VARIATION swimmer} {FACING $direction}
        [+unit]
            animate=yes
        [/unit]
    [/event]

    [event]
        name=release zombie drake

        {LOYAL_UNIT 3 Soulless $cage.x $cage.y} {VARIATION drake} {FACING $direction}
        [+unit]
            name= _ "Rurhló"
            animate=yes
        [/unit]

        [message]
            x,y=$cage.x,$cage.y
            message= _ "Graurgh... Argh gaaaaa... (<i>roars</i>)" # wmllint: no spellcheck
        [/message]

        [message]
            {IN_SPEAKER_IS_UNIT_OR_MAL_KESHAR}
            scroll=no
            message= _ "It’s hostile! Kill it!"
        [/message]
    [/event]

    [event]
        name=release ledinor

        [unit]
            # wmllint: recognize Lédinor
            {CHARACTER_STATS_LEDINOR}
            animate=yes
            facing=$direction
            hitpoints=4
            x,y=$cage.x,$cage.y
        [/unit]

        [message]
            speaker=Galas
            message= _ "Lord Lédinor! Is that really you? What have these beasts done to you?!"
        [/message]

        [kill]
            animate=yes
            fire_event=no
            id=Lédinor
        [/kill]

        [message]
            speaker=Elynia
            message= _ "He seems extremely unwell — no doubt he has been constantly tortured by his captors during all this time. I will have to treat him before he’ll be able to stand on his own again."
        [/message]

        [message]
            speaker=Galas
            message= _ "If only we could take him back outside... Damn it!"
        [/message]
    [/event]

    #
    # Secret passage touchplate
    #

    {ITEM_TOUCHPLATE 58 29}

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

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

        [terrain]
            x=57-58,52,51,49
            y=   28,25,23,26
            terrain=Urb
        [/terrain]

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

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

    [event]
        name=DEBUG3

        {VARIABLE prisoners_remaining 0}

        [fire_event]
            name=dungeon prisoners check
        [/fire_event]
    [/event]

    ############################################################################
    #                                                                          #
    #                           SCENARIO PROGRESSION                           #
    #                                                                          #
    ############################################################################

    #
    # Central chamber
    #

    [event]
        name=die
        [filter]
            type=Door
            x=25-26,27
            y=   34,35
        [/filter]

        [fire_event]
            name=enter central chamber
            [primary_unit]
                x,y=$x2,$y2
            [/primary_unit]
        [/fire_event]
    [/event]

    [event]
        name=enter central chamber

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

        {CLEAR_VARIABLE raaldir_store}

        [modify_side]
            side=5
            {GOLD 130 140 150}
        [/modify_side]

        {MOBILIZE_GUARDIANS (
            x= 1-28
            y=32-42
            [not]
                side=1
            [/not]
        )}

        {CLEAR_CAVE_SHROUD x,y,radius=15,36,7}

        [redraw]
            side=1
        [/redraw]

        [scroll_to]
            x,y=14,36
        [/scroll_to]

        [delay]
            time=750
        [/delay]

        [message]
            {IN_SPEAKER_IS_UNIT_OR_MAL_KESHAR}
            message= _ "Oh, just... great."
        [/message]

        [message]
            speaker="Ra'aldir"
            message= _ "Seize the Lady of Light and kill the intruders!"
        [/message]

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

    [event]
        name=last breath
        [filter]
            id="Ra'aldir"
        [/filter]

        [message]
            speaker="Ra'aldir"
            message= _ "You... you will not succeed... You can’t kill... the Emperor..."
        [/message]
    [/event]

    [event]
        name=die
        [filter]
            id="Ra'aldir"
        [/filter]

        [message]
            speaker=Galas
            message= _ "I don’t suspect anyone has actually tried before."
        [/message]
    [/event]

    #
    # Touchgem 1 (west side passage)
    #

#define IN_ACTIVATE_TOUCHGEM _X _Y
    [remove_item]
        x={_X}
        y={_Y}
    [/remove_item]

    {PLACE_IMAGE ("items/ball-magenta.png") {_X} {_Y} }

    [message]
        speaker=narrator
        image=wesnoth-icon.png
        message= _ "Touchgem triggered. A gate opens."
    [/message]
#enddef

    {PLACE_IMAGE ("items/ball-green.png")  4 18}

    [event]
        name=moveto
        [filter]
            side=1
            x,y=4,18
        [/filter]

        {IN_ACTIVATE_TOUCHGEM $x1 $y1}

        {CLEAR_CAVE_SHROUD (x,y,radius=15,20,4)}

        {REMOVE_EVENT_BARRIER *^Zz\,*^Zz/,*^Zz| 15 20}

        [message]
            {IN_SPEAKER_IS_UNIT_OR_MAL_KESHAR}
            scroll=no
            message= _ "Ah, that ought to do the trick."
        [/message]

        [message]
            speaker=Galas
            scroll=no
            message= _ "Onwards!"
        [/message]

        [modify_side]
            side=3
            controller=ai
            {GOLD 190 220 230}
        [/modify_side]
    [/event]

    #
    # Touchgem 2 (northwest area, location is random)
    #

    [event]
        name=prestart

        [set_variables]
            name=touchgem_locs
            mode=replace
            [value]
                x,y=22,6
            [/value]
            [value]
                x,y=25,16
            [/value]
            [value]
                x,y=29,13
            [/value]
            [value]
                x,y=9,18
            [/value]
        [/set_variables]

        {VARIABLE_RANDOM i "0..$($touchgem_locs.length - 1)"}

        {PLACE_IMAGE ("items/ball-green.png") $touchgem_locs[$i].x $touchgem_locs[$i].y}

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

            [fire_event]
                name=lift vritra gate barrier
                [primary_unit]
                    x,y=$touchgem_locs[$i].x,$touchgem_locs[$i].y
                [/primary_unit]
            [/fire_event]
        [/event]

        {CLEAR_VARIABLE touchgem_locs,i}
    [/event]

    [event]
        name=lift vritra gate barrier

        {IN_ACTIVATE_TOUCHGEM $x1 $y1}

        {CLEAR_CAVE_SHROUD (x,y,radius=14,13,5)}

        {REMOVE_EVENT_BARRIER *^Zz\,*^Zz/,*^Zz| 14 13}
    [/event]

    [event]
        name=last breath
        [filter]
            id=Mal Vritra
        [/filter]

        [message]
            speaker=Mal Vritra
            message= _ "Ah, every story has to come to an end someday... even yours, Lady of Light..."
        [/message]
    [/event]

    #
    # Touchgem 3 (side 3 leader)
    #

    {PLACE_IMAGE ("items/ball-green.png") 10 8}

    [event]
        name=moveto
        [filter]
            side=1
            x,y=10,8
        [/filter]

        {IN_ACTIVATE_TOUCHGEM $x1 $y1}

        {CLEAR_CAVE_SHROUD (x,y,radius=21,22,5)}

        {REMOVE_EVENT_BARRIER *^Zz\,*^Zz/,*^Zz| 21 22}
    [/event]

    #
    # Boss encounter start
    #

    {FIRE_EVENT_ON_STUMBLE_UPON "boss encounter" side=2}

    [event]
        name=boss encounter

        [message]
            {IN_SPEAKER_IS_UNIT_OR_MAL_KESHAR}
            message= _ "Oh no... Uria be damned!"
        [/message]

        {CLEAR_CAVE_SHROUD (x,y,radius=36,14,5)}

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

        {BOSS_POPUP}

        [redraw]
            side=1
        [/redraw]

        [scroll_to_unit]
            id=Cragworg
        [/scroll_to_unit]

        [delay]
            time=1000
        [/delay]

        [message]
            speaker=Galas
            message= _ "Not this again..."
        [/message]

        [message]
            speaker=Cragworg
            message= _ "Your foolishness ends here with your death, enemies of Uria! Her Voice requests that we prevent your advance towards the Gate of Inferno at all costs!"
        [/message]

        [message]
            speaker=Galas
            message= _ "You mean the Chaos Emperor, right? I can’t believe your kind lets a lesser monster like him order you around like dogs."
        [/message]

        [message]
            speaker=Aelyriun-Balal
            message= _ "Don’t you dare speak ill of the Voice of Uria, elf scum! Cragworg, crush these disgusting vermin!"
        [/message]
    [/event]

    [event]
        name=attack
        [filter]
            id=Cragworg
        [/filter]
        [filter_second]
            id=Elynia
        [/filter_second]

        [message]
            speaker=Aelyriun-Balal
            message= _ "Not the Lady of Light, you worthless idiot!"
        [/message]
    [/event]

    [event]
        name=attack end
        [filter]
            side=1
        [/filter]
        [filter_second]
            side=2
        [/filter_second]

        [message]
            speaker=Mal Keshar
            message= _ "Is this our curse? To fight countless big shot enemies with death wishes?"
        [/message]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Aelyriun-Balal
        [/filter]

        [message]
            speaker=Aelyriun-Balal
            message= _ "Oh, Uria, I... have... failed..."
        [/message]
    [/event]

    #
    # Boss encounter end
    #

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

        [message]
            speaker=Cragworg
            message= _ "(<i>spits blood</i>) You have not seen the last of me! I am not... dying... today... (<i>collapses</i>)"
        [/message]
    [/event]

    [event]
        name=die
        [filter]
            id=Cragworg
        [/filter]
        [filter_condition]
            {VARIABLE_NUMERICAL_NOT_EQUALS prisoners_remaining 0}
        [/filter_condition]

        [message]
            speaker=Galas
            message= _ "Ugh. Hopefully that’s the last time we will need to fight one of these drooling imps. Now, where do we go from here?"
        [/message]

        [message]
            speaker=Elynia
            message= _ "They seemed determined not just to prevent our progress towards the ‘Gate’, but also to impede our access to the dungeon on this level. May I suggest we investigate and possibly release any prisoners kept captive?"
        [/message]

        [message]
            speaker=Galas
            message= _ "Yes, sounds good to me."
        [/message]
    [/event]

    [event]
        name=moveto
        [filter]
            side=1
            [and]
                [filter_location]
                    x,y=50,8
                    [or]
                        x,y=52,21
                    [/or]
                    radius=5
                [/filter_location]
            [/and]
        [/filter]

        [message]
            speaker=Galas
            message= _ "I think I just heard a voice calling for help."
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Galas, do you really want us to explore the whole place? We do not have all the time in the world, you know. Besides, I doubt the prisoners can be of much help. <small>Not alive, at least...</small>"
        [/message]

        [message]
            speaker=Galas
            message= _ "It would be highly inhumane for us to leave them abandoned to their own luck!"
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Very well, boy, do as you wish. I don’t really care! Should we lose precious time due to your insistence on helping all living things, that shall be <i>your</i> problem to deal with, not mine."
        [/message]
    [/event]

    #
    # Called from the dungeon cage handlers
    #

    [event]
        name=dungeon prisoners check
        [filter_condition]
            {VARIABLE_NUMERICAL_EQUALS prisoners_remaining 0}
        [/filter_condition]

        [message]
            speaker=Elynia
            message= _ "I wonder if that’s all of them... It seems odd that the dungeon is almost completely empty. Perhaps they saw us coming and moved all of their prisoners elsewhere?"
        [/message]

        [message]
            speaker=Galas
            message= _ "Why would they bother? They have never seemed to be the kind who would take prisoners in the first place; Lord Lédinor’s presence here is highly unusual."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Yes, and that is... Hold on, I hear movement."
        [/message]

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

        {MOBILIZE_GUARDIANS (
            [filter_location]
                x,y=$nemaara_store.x,$nemaara_store.y
                radius=4
            [/filter_location]
            [not]
                side=1
            [/not]
        )}

        {CLEAR_CAVE_SHROUD (
            x,y,radius=$nemaara_store.x,$nemaara_store.y,7
            [filter_radius]
                terrain=!,Q*,Q*^*
            [/filter_radius]
            [not]
                y=1-3
            [/not]
        )}

        {CLEAR_VARIABLE nemaara_store}

        {REMOVE_EVENT_BARRIER *^Zz\,*^Zz/,*^Zz| 34 10}

        [message]
            speaker=Mal Keshar
            message= _ "So I guess we don’t need to find a way to open that gate after all!"
        [/message]

        #
        # TODO: fix this
        #
#ifdef 0
        [scroll_to_unit]
            id=Nemaara
        [/scroll_to_unit]

        {HIGHLIGHT_GOAL (
            [filter]
                id=Nemaara
            [/filter]
        )}

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

    #
    # Victory
    #

    [event]
        name=moveto
        [filter]
            id=Galas,Elynia,Mal Keshar
            x=32-34
            y=1
        [/filter]

        {ENDLEVEL_CONTINUE}
    [/event]

    [event]
        name=victory

        [message]
            speaker=Galas
            message= _ "And deeper underground we go. (<i>sighs</i>) Perhaps we should focus on finding that ‘Gate’ and close it off somehow before confronting the Emperor. Elynia, would you be able to do that?"
        [/message]

        [delay]
            time=750
        [/delay]

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

        [message]
            speaker=Elynia
            # po: She is supposed to sound as though she's distracted with/by something else.
            message=_  "Huh? Oh, sorry. You are asking about the portal to Inferno, right. I fear it might be a much more severe fissure in our reality than I originally suspected. I can’t even begin to fathom the amount of power that was required to create it, let alone how to heal it."
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "So, you mean..."
        [/message]

        [message]
            speaker=Elynia
            message= _ "This whole city is the Gate."
        [/message]

        {CLEAR_VARIABLE prisoners_remaining,raaldir_store,nemaara_store,player_castle_locs}
    [/event]
[/scenario]

#undef IN_NOTE_ONLY_ON_FIRST_TURN
#undef IN_NOTE_ONLY_ON_GAMEPLAY_TURNS
#undef IN_NOTE_NO_RECRUIT_RECALL
#undef IN_SPEAKER_IS_UNIT_OR_MAL_KESHAR
#undef IN_CAGE
#undef IN_ACTIVATE_TOUCHGEM

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


#textdomain wesnoth-Invasion_from_the_Unknown

[scenario]
    id=22A_Face_of_the_Enemy
    name= _ "Face of the Enemy"
    {MAP 22A_Face_of_the_Enemy.map}
    {TURNS 46 45 44}
    next_scenario=22B_Dark_Hive
    victory_when_enemies_defeated=no
    {NO_RECALLS}

    {SCENARIO_MUSIC       "climactic_contemplation.ogg"}
    {EXTRA_SCENARIO_MUSIC "heroes_rite.ogg"}
    {EXTRA_SCENARIO_MUSIC "the_deep_path.ogg"}
    {EXTRA_SCENARIO_MUSIC "nunc_dimittis.ogg"}
    {EXTRA_SCENARIO_MUSIC "suspense.ogg"}

    {INDOORS_HIVE}

    {STORYTXT_GAUNTLET}

    {DEATHS_ACT_4}

    {SPAWN_CONTROLLER}

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

        fog=yes
        shroud=yes

        {NO_ECONOMY}

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

    # Boss and boss supporters
    [side]
        side=2
        team_name=enemies
        user_team_name= _ "team_name^Chaos Warlord"
        {CHAOS_FLAG}
        color=gold
        controller=null # Activated later.

        hidden=yes
        no_leader=yes
        # Gold set by events.
        recruit=Chaos Invoker,Fire Wraith,Demon Grunt,Demon Zephyr

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

            {AI_BOSS_TARGETING_ENGINE <<{"Elynia","Galas","Mal Keshar"}>>}
        [/ai]
    [/side]

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

        hidden=yes
        no_leader=yes
        {NO_ECONOMY}

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

        {SIDE_GENERIC_GUARD (Chaos Razerman) 18 27} {FACING ne}
        {SIDE_GENERIC_GUARD (Chaos Razerman) 28 30} {FACING nw}

        [unit]
            id=Urunur
            name= _ "Urunur"
            type=Iron Mauler
            x,y=22,30
            facing=ne
            upkeep=free
            alignment=chaotic
            [modifications]
                {TRAIT_FEARLESS}
                {TRAIT_STRONG}
            [/modifications]
        [/unit]

        {SIDE_GENERIC_GUARD (Chaos Marauder) 16 32}
        {SIDE_GENERIC_GUARD (Chaos Marauder) 31 34}

        {SIDE_GENERIC_GUARD (Hell Guardian) 33 35}

        {SIDE_GENERIC_GUARD (Chaos Magus)   21 35}
        {SIDE_GENERIC_GUARD (Chaos Magus)   18 31}
        {SIDE_GENERIC_GUARD (Chaos Magus)   26 31}

        {SIDE_GENERIC_GUARD (Chaos Invader) 30 21}
        {SIDE_GENERIC_GUARD (Chaos Invader) 31 21}
        {SIDE_GENERIC_GUARD (Chaos Invader) 35 23}
        {SIDE_GENERIC_GUARD (Chaos Invader) 34 23}

        {SIDE_GENERIC_GUARD (Demon Warrior) 31 23} {FACING ne}

        {SIDE_GENERIC_GUARD (Blood Imp) 28 23}
        {SIDE_GENERIC_GUARD (Blood Imp) 28 24}
        {SIDE_GENERIC_GUARD (Blood Imp) 29 24}

        {SIDE_GENERIC_GUARD (Hellhound) 26 25} {FACING ne}

        {SIDE_GENERIC_GUARD (Chaos Invoker) 35 20} {FACING nw}
        {SIDE_GENERIC_GUARD (Imp)           36 19} {FACING nw}
    [/side]

    [side]
        side=4
        team_name=enemies
        user_team_name= _ "team_name^Dark Hive"
        {CHAOS_FLAG}

        hidden=yes
        no_leader=yes
        {NO_ECONOMY}

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

        {SIDE_GENERIC_UNIT (Verlissh Matrix Flow System) 25 35}
        {SIDE_GENERIC_UNIT (Verlissh Matrix Flow System) 14 32}
        {SIDE_GENERIC_UNIT (Verlissh Matrix Flow System) 42 44}
        {SIDE_GENERIC_UNIT (Verlissh Matrix Flow System) 54 40}
        {SIDE_GENERIC_UNIT (Verlissh Matrix Flow System) 57 44}

        {SIDE_GENERIC_GUARD (Prong Bug) 22  4}
    [/side]

    [side]
        side=5
        team_name=enemies
        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             1.00}
            {AI_SIMPLE_ALWAYS_ASPECT caution                0.00}
            {AI_SIMPLE_ALWAYS_ASPECT village_value          0.00}
            {AI_SIMPLE_ALWAYS_ASPECT simple_targeting        yes}
            {AI_SIMPLE_ALWAYS_ASPECT grouping                 no}
        [/ai]

        {SIDE_GENERIC_GUARD (Blood Bat) 30 10}
        {SIDE_GENERIC_GUARD (Blood Bat) 28 13}
        {SIDE_GENERIC_GUARD (Blood Bat) 32  5}
        {SIDE_GENERIC_GUARD (Blood Bat) 48 16}
        {SIDE_GENERIC_GUARD (Blood Bat) 51 14}

        {SIDE_GENERIC_GUARD (Brain Drainer) 47 12}
        {SIDE_GENERIC_GUARD (Brain Drainer) 31  6}

        {SIDE_GENERIC_GUARD (Giant Ant) 48 34}
        {SIDE_GENERIC_GUARD (Giant Ant) 50 37}
        {SIDE_GENERIC_GUARD (Giant Ant) 54 29}

        {SIDE_GENERIC_GUARD (Giant Spider) 49 48}

        {SIDE_GENERIC_GUARD (Water Serpent) 50 32}

        {SIDE_GENERIC_GUARD (Cuttle Fish) 44 11}
    [/side]

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

        no_leader=yes
        hidden=yes
        {NO_ECONOMY}
    [/side]

    {CAVE_NOISE_SOUND_SOURCE}

    {CAVE_WATER_SOUND_SOURCE 33  6}

    {PLACE_IMAGE ("items/bones.png~FL(horiz)") 30  5}
    {PLACE_IMAGE ("items/bones.png~FL(horiz)") 48 35}
    {PLACE_IMAGE ("items/bones.png")           56 42}

#define GA_DRONES_EASY
    "Shaxthal Drone,Shaxthal Drone,Shaxthal Drone,Shaxthal Drone,Shaxthal Runner Drone,Shaxthal Sentry Drone" #enddef
#define GA_DRONES_MEDIUM
    "Shaxthal Drone,Shaxthal Sentry Drone,Shaxthal Sentry Drone,Shaxthal Protector Drone,Shaxthal Protector Drone" #enddef
#define GA_DRONES_HARD
    "Shaxthal Sentry Drone,Shaxthal Assault Drone" #enddef
#define GA_DRONES_ULTRA
    "Shaxthal Sentry Drone,Shaxthal Sentry Drone,Shaxthal Assault Drone,Shaxthal Assault Drone,Shaxthal Assault Drone,Shaxthal Rayblade" #enddef

#define GA_DRONE _TURNS _DIFFICULTY_LEVEL _X _Y
    {TIMED_DRONE_SPAWNER {_TURNS} (type={GA_DRONES_{_DIFFICULTY_LEVEL}}) 4 {_X} {_Y} }
#enddef

    {GA_DRONE {DIFF 4 7 9} ULTRA 34 30}
    {GA_DRONE {DIFF 4 7 9} ULTRA 28 22}
    {GA_DRONE {DIFF 4 7 9} ULTRA 32 24}

    {GA_DRONE 8 MEDIUM 29 26}
    {GA_DRONE 8 MEDIUM 26 23}
    {GA_DRONE 8 MEDIUM 35 26}

    {GA_DRONE 6 EASY 14 31}
    {GA_DRONE 6 EASY 20 33}
    {GA_DRONE 6 EASY 26 30}
    {GA_DRONE 6 EASY 27 29}
    {GA_DRONE 6 EASY 16 29}

    {GA_DRONE 9 HARD 43 44}
    {GA_DRONE 9 HARD 53 41}

    {GA_DRONE 4 ULTRA 55 44}

    {GA_DRONE 6 HARD 35 10}

    {GA_DRONE 6 MEDIUM 18  8}
    {GA_DRONE 6 MEDIUM 20  9}
    {GA_DRONE 6 MEDIUM 15  6}

    {GA_DRONE 6 EASY 13  3}
    {GA_DRONE 6 EASY 16  4}
    {GA_DRONE 6 EASY 13  7}

#define GA_TENTACLE _TURNS _X _Y
    {TIMED_SPAWNER {_TURNS} (type=Tentacle of the Deep) 5 {_X} {_Y} }
#enddef

    {GA_TENTACLE 6 42 13}
    {GA_TENTACLE 4 39 16}
    {GA_TENTACLE 6 45 10}
    {GA_TENTACLE 4 48 10}

    {GA_TENTACLE 4 50 30}
    {GA_TENTACLE 6 52 34}
    {GA_TENTACLE 4 57 34}

    [event]
        name=prestart

        {VARIABLE boss_revived 0}

        # Used for SLFs only.
        [time_area]
            id=escape_area
            x=36-63,34-35,35
            y=29-48,   36,37
            {INDOORS_HIVE}
        [/time_area]

        [setup_doors]
            side=6
        [/setup_doors]

        # Recall heroes

        # wmllint: recognize Elynia
        {RECALL_ELYNIA}
        # wmllint: recognize Mal Keshar
        {RECALL_MAL_KESHAR}
        # wmllint: recognize Lédinor
        {RECALL_LEDINOR}
        # wmllint: recognize Erathan
        {RECALL_ERATHAN2}
        # wmllint: recognize Igor
        {RECALL_IGOR}

        {FACE_DIRECTION side=1 ne}

        [modify_unit]
            [filter]
                id=Lédinor
            [/filter]
            hitpoints="$($this_unit.max_hitpoints * 0.6)"
        [/modify_unit]

        [hide_unit]
            id=Lédinor
        [/hide_unit]

        {OBJECTIVES (
            {OBJECTIVE_VICTORY ( _ "Explore and descend deeper underground with Galas, Elynia, or Mal Keshar")}

            {OBJECTIVE_DEFEAT ( _ "Death of Galas")}
            {OBJECTIVE_DEFEAT ( _ "Death of Elynia")}
            {OBJECTIVE_DEFEAT ( _ "Death of Mal Keshar")}
            {OBJECTIVE_DEFEAT ( _ "Death of Lédinor")}

            {TURNS_RUN_OUT}

            {OBJECTIVE_FULL_CARRYOVER}
        )}
    [/event]

    {FINAL_SCENARIO_PLAYER_RECRUITMENT_WITH_AUTORECALL}

    [event]
        name=start

        [message]
            speaker=Galas
            message= _ "It has been a while since we last encountered an enemy other than those mindless hive creatures, and the stench of decay is only getting worse. Are we sure we are going in the right direction?"
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Oh, we certainly are heading towards a powerful dark presence. Whether it is the Chaos Emperor himself or not—"
        [/message]

        [message]
            speaker=Elynia
            message= _ "Galas, Lord Lédinor seems to be regaining consciousness."
        [/message]

        [unhide_unit]
            id=Lédinor
        [/unhide_unit]

        [message]
            speaker=Galas
            message= _ "My lord! Are you all right?"
        [/message]

        [message]
            speaker=Lédinor
            message= _ "Oh, young Galas, that is a... silly question to ask... (coughs) To say that I have felt better in my life would be quite an understatement. But... I am alive at least. I never expected to see you here, and... I hear this radiant lady is the Lady of Light, the savior of elf-kind? How can this be? I... I always thought..."
        [/message]

        [message]
            speaker=Galas
            message= _ "Oh, my lord, it is a long and sorrowful story. I suppose it rests on me to bring you up to speed. Do you think you will be able to walk on your own, sir?"
        [/message]

        [message]
            speaker=Lédinor
            message= _ "I am old and tortured, but not useless yet. Yes, I can walk, and perhaps I may still be of help."
        [/message]

        [message]
            speaker=Galas
            message= _ "Let us get moving then."
        [/message]
    [/event]

    [event]
        name=turn 4

        [message]
            speaker=Lédinor
            message= _ "So that is why Anlindë is not here... Oh, Galas, would that I had foreseen this. It’s not fair. I should have died in her place, making a last stand against our enemies! Instead, I was captured and brought to this living hell."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Why would they do this? Were any other elves captured? Did the demons want anything specific from you, perhaps to make an example for the rest of our people?"
        [/message]

        [message]
            speaker=Lédinor
            message= _ "Oh, I fear I was never allowed to see or be seen by any other prisoners back in the Valley, my fair lady. Then I was brought here tied and blindfolded. Although there certainly used to be other people in the dungeon, not a single one of them sounded like one of our own. As for why they kept me alive... Ugh... (holds head)"
        [/message]

        [message]
            speaker=Lédinor
            message= _ "These fiends, they have no compassion for any living creature, not even those from their own ranks. You don’t want to hear of the atrocities they do to their prisoners... I am sure you recall the stories we tell about orcs mutilating their enemies and boiling them alive? Compared to the things they do to you in here — the things they make you do — I assure you, becoming an orc’s dinner... would be a far preferable fate to even witnessing all this..."
        [/message]

        [message]
            speaker=Elynia
            message= _ "I... Lord Lédinor, pardon me. I should not have asked."
        [/message]
    [/event]

    {ITEM_CRYSTAL_GLYPH_MESSAGE 49 15}

    [event]
        name=moveto
        [filter]
            x,y=49,15
            side=1
        [/filter]

        {MSG_GLYPH ( _ "We are the Argazar people, creators of these crystal glyphs. And this is the story of our downfall.")}

        {MSG_GLYPH ( _ "Our extensive research allowed us to select the best characteristics of all natural lifeforms in our domain and combine them into a new creature. Thus the ‘invincibles’, or ‘Shaxthals’, were born. Our original intention was to use this knowledge to advance our civilization beyond the limits of mortality, and achieve the dream of eternal life. However, a hostile invasion from Rythé brought our plan to an abrupt halt.")}

        {MSG_GLYPH ( _ "After years of war, desperate for a resolution we saw fit to employ our invincibles as weapons against our ancient enemy, and much to our amazement, the plan worked. But even though we managed to fend off Rythé’s forces for a while, in doing so we garnered new attention from a mysterious entity whose existence we had ignored thus far.")}

        {MSG_GLYPH ( _ "A powerful beam of pure darkness struck our world, destroying our civilization, and our creations. Our population swiftly dwindled, and the Rythenians took advantage of the situation. Cornered and without escape from the increasingly poisonous air, we devised a mechanism that allowed us to escape into a world beyond the veil; a primitive world devoid of intelligent life, a world stranded in a limbo between times.")}

        {MSG_GLYPH ( _ "Although our new home was far too hostile for us to survive on the surface, we found shelter under the ground, where we decided we would try to rebuild our civilization. However...")}

        {MSG_GLYPH ( _ "Originally non-sentient, the Shaxthals we brought with us somehow developed minds of their own, with new instincts and desires, and they could no longer be contained by their creators. They began to attack and assimilate the remnants of our people and spawn new generations with new, more sophisticated bodies able to protect them against our weapons. Their numbers increased at an exceedingly fast rate, and we could do nothing to save ourselves in time.")}

        {MSG_GLYPH ( _ "With barely a few dozen of us left, we discovered a way to thwart the Shaxthals’ reproductive capabilities. And thus the circle was completed: our hope for eternal life became the instrument of our demise, and us their own. In the twilight days of our race, we were left to ponder this irony.")}

        {MSG_GLYPH ( _ "In spite of our protests, the elders ordered us to take a few of the last Shaxthal creatures and put them into preservation pods for further experimentation, believing that they might still hold the key to our survival. By then it was too late, and we no longer had specialists able to conduct any new research. We could only make sure to record our history and thoughts in these crystal glyphs, with the hope that perhaps some day someone will resurrect our fallen race.")}
    [/event]

    ############################################################################
    #                                                                          #
    #                           SCENARIO PROGRESSION                           #
    #                                                                          #
    ############################################################################

    {FIRE_EVENT_ON_STUMBLE_UPON "guard encounter" side=3}

    [event]
        name=guard encounter

        [redraw]
            side=1
        [/redraw]

        [message]
            speaker=Mal Keshar
            message= _ "Do they seriously expect these two to prevent our advance somehow?"
        [/message]
    [/event]

    [event]
        name=die
        [filter]
            type=Door
            x=34,35
            y=20,21
        [/filter]

        {CLEAR_CAVE_SHROUD x,y,radius=31,23,3}
        {CLEAR_CAVE_SHROUD x,y,radius=28,24,3}

        [redraw]
            side=1
        [/redraw]

        [message]
            speaker=Mal Keshar
            message= _ "Ah, that’s much better!"
        [/message]
    [/event]

    [event]
        name=die
        [filter]
            type=Door
            x=24,25,26
            y=25,26,26
        [/filter]

        {MOBILIZE_GUARDIANS (
            side=3
            [filter_location]
                x,y,radius=20,31,8
            [/filter_location]
        )}

        [store_unit]
            [filter]
                side=1
                x=1-100
                y=1-100
            [/filter]
            variable=onmap_player_units
            kill=yes
        [/store_unit]

        [hide_unit][/hide_unit]

        {FADE_TO_BLACK}

        [delay]
            time=1000
        [/delay]

        [foreach]
            array=onmap_player_units
            [do]
                {VARIABLE this_item.attacks_left $this_item.max_attacks}
                {VARIABLE this_item.moves        $this_item.max_moves}

                [unstore_unit]
                    variable=this_item
                    check_passability=yes
                    find_vacant=yes
                    x,y=21,28
                [/unstore_unit]

                [hide_unit]
                    id=$this_item.id
                [/hide_unit]
            [/do]
        [/foreach]

        {CLEAR_VARIABLE onmap_player_units}

        [redraw]
            side=1
        [/redraw]

        [scroll_to]
            x,y=22,27
            {WARP}
        [/scroll_to]

        {FADE_IN}

        [unhide_unit]
            side=1
        [/unhide_unit]

        [delay]
            time=500
        [/delay]

        [scroll_to]
            x,y=15,30
        [/scroll_to]

        [delay]
            time=500
        [/delay]

        [unhide_unit]
            [not]
                side=1
            [/not]
        [/unhide_unit]

        [message]
            speaker=Urunur
            message= _ "It’s the heathens! Keep them entertained!"
        [/message]

        [message]
            speaker=Galas
            message= _ "What is this now? Keep us entertained for what?"
        [/message]

        [terrain]
            x=23-24,25-26,27
            y=   25,   26,27
            terrain=Xos
        [/terrain]

        [redraw][/redraw]

        [kill]
            type=Door
            [filter_location]
                terrain=Xos
            [/filter_location]
        [/kill]

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

        [scroll_to]
            x,y=25,26
            {WARP}
        [/scroll_to]

        [delay]
            time=1000
        [/delay]

        [message]
            speaker=Erathan
            message= _ "I suppose it’s too late to turn back now."
        [/message]

        [scroll_to_unit]
            id=Galas
        [/scroll_to_unit]

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

            [fire_event]
                name=boss stage 1
            [/fire_event]
        [/event]
    [/event]

    ############################################################################
    #                                                                          #
    #                               BOSS STAGE 1                               #
    #                                                                          #
    ############################################################################

    [event]
        name=boss stage 1

        {LOCK_VIEW}

        [store_starting_location]
            side=2
        [/store_starting_location]

        {CLEAR_CAVE_SHROUD x,y,radius=$location.x,$location.y,6}

        [redraw]
            side=1
        [/redraw]

        {CLEAR_FOG 1 $location.x $location.y 6}

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

        [delay]
            time=250
        [/delay]

        [terrain]
            x,y=$location.x,$location.y
            terrain=Kud
        [/terrain]

        [redraw][/redraw]

        {REPLACE_SCENARIO_MUSIC silence.ogg}

        {QUAKE thunderstick.ogg}

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

        [delay]
            time=500
        [/delay]

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

        [message]
            speaker=Erathan
            scroll=no
            message= _ "He is here!"
        [/message]

        [delay]
            time=500
        [/delay]

        [message]
            speaker=Igor
            scroll=no
            message= _ "That’s..."
        [/message]

        [store_direction]
            [to]
                [filter]
                    id=Galas
                [/filter]
            [/to]
            from_x,from_y=$location.x,$location.y
        [/store_direction]

        {REPLACE_SCENARIO_MUSIC "the_city_falls.ogg"}

        [modify_side]
            side=2
            controller=ai
            hidden=no
            {INCOME 6 8 9}
            {GOLD 150 170 200}
        [/modify_side]

        [unit]
            # wmllint: recognize Elyssa
            {CHARACTER_STATS_ELYSSA}
            animate=yes
            canrecruit=yes
            side=2
            placement=leader
            facing=$direction
            {IS_BOSS}
        [/unit]

        {BOSS_POPUP}

        [delay]
            time=1000
        [/delay]

        {CONDITIONAL_ERATHAN (
            [message]
                speaker=Erathan
                message= _ "A woman? The warlord is actually a woman?"
            [/message]
        ) (
            [message]
                speaker=Mal Keshar
                message= _ "Huh? The warlord is actually a woman? Pah, not that it makes any difference."
            [/message]
        )}

        [message]
            speaker=Elyssa
            message= _ "Galas, the elf leader. You have no idea how long I’ve been waiting to meet you. It’s too bad that the elven witch could not make it — she seemed too infatuated with self-sacrifice for that, much like you."
        [/message]

        [message]
            speaker=Galas
            message= _ "So you are the monster who killed Anlindë. I shall make sure you meet your due punishment, and I am not planning on dying tonight!"
        [/message]

        [message]
            speaker=Elyssa
            message= _ "Alas, lord of the elves, there is no weapon nor magical power left on this ruined world able to destroy me. You will only waste the last minutes of your life!"
        [/message]

        [message]
            speaker=Elynia
            message= _ "No, we will prevail. No matter how many times your kind tries, you cannot escape justice at our hands. You will be banished from Irdya all the same!"
        [/message]

        [message]
            speaker=Elyssa
            message= _ "Ah, the formidable Lady of Light... I am truthfully disappointed to see you are but a brash, ignorant creature, just like the rest. You should be taught to not defy the power of Uria."
        [/message]

        [message]
            speaker=Elyssa
            message= _ "You all appear to be under the misconception that your pitiful war will make a difference; but to her, you are completely beneath notice. We have been kept distracted by more important matters, but since you decided to come to our domain in person, I suppose it rests upon me to put an end to this folly."
        [/message]

        [message]
            speaker=narrator
            image=wesnoth-icon.png
            message= _ "The demoness unsheathed her sword and held it to the fore, glancing at the Lady of Light with murderous glee in her eyes. And just for one instant, Galas could read a hint of outrage and anguish on Elynia’s face."
        [/message]

        [message]
            speaker=Elyssa
            # po: Yes, she doesn't spell out the Chaos Emperor's name or title
            # po: on this line, that's intentional.
            message= _ "Although he and Uria had an interest in dealing with you personally, I fear that will not be possible, my dear."
        [/message]

        [scroll_to_unit]
            id=Elynia
        [/scroll_to_unit]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Elynia
            message= _ "No. It is time for you to meet your fate!"
        [/message]

        {OBJECTIVES (
            {OBJECTIVE_VICTORY ( _ "Defeat the Chaos Warlord")}

            {OBJECTIVE_DEFEAT ( _ "Death of Galas")}
            {OBJECTIVE_DEFEAT ( _ "Death of Elynia")}
            {OBJECTIVE_DEFEAT ( _ "Death of Mal Keshar")}
            {OBJECTIVE_DEFEAT ( _ "Death of Lédinor")}

            {TURNS_RUN_OUT}

            {OBJECTIVE_FULL_CARRYOVER}
        )}

        {UNCLEAR_FOG}

        {CLEAR_VARIABLE location,direction}

        {UNLOCK_VIEW}
    [/event]

    #
    # Elyssa can't die in this scenario.
    #

    {BOSS_IMMORTALITY Elyssa () 100}

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

        {BUG ()}
    [/event]

    #
    # Make her fully invulnerable after the first two times.
    #

    [event]
        id=boss_revives_counter
        name=boss revived
        first_time_only=no

        {VARIABLE_INC boss_revived}

        [if]
            {VARIABLE_NUMERICAL_EQUALS boss_revived 2}
            [then]
                [remove_event]
                    id=boss_revives_counter # wmllint: ignore
                [/remove_event]
            [/then]
        [/if]
    [/event]

    {BOSS_ABSORB_FULL_DAMAGE Elyssa ({VARIABLE_NUMERICAL_GREATER_THAN_OR_EQUAL boss_revived 2})}

    [event]
        name=boss revived

        [message]
            speaker=Elyssa
            message= _ "I did warn you... You cannot destroy me."
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Galas, you know that normally I would approve of sticking around to enact some form of revenge, but the harsh reality of the situation is..."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Everyone, cover your eyes!"
        [/message]

        [sound]
            name=magic-holy-miss-1.ogg
        [/sound]

        [hide_unit][/hide_unit]

        {WHITE_SCREEN}

        [delay]
            time=2000
        [/delay]

        [lua]
            code=<<
                local shift, step, delay = 256, 32, 20

                repeat
                    shift = math.max(0, shift - step)
                    wesnoth.wml_actions.color_adjust { red = shift, green = shift, blue = shift }
                    wesnoth.interface.delay(delay)
                    if shift <= 128 then
                        wesnoth.wml_actions.unhide_unit {}
                    end
                    wesnoth.wml_actions.redraw {}
                until shift <= 0
            >>
        [/lua]

        [modify_unit]
            [filter]
                id=Elyssa
            [/filter]
            moves=1
            max_moves=1
            [variables]
                normal_moves=$this_unit.max_moves
            [/variables]
            [status]
                # Yes, only for one turn.
                slowed=yes
            [/status]
        [/modify_unit]

        [message]
            speaker=Elyssa
            message= _  "What is this...? Do you really think such a cheap trick is going to stop me!? (holds her head)"
        [/message]

        [message]
            speaker=Galas
            message= _ "She seems disoriented. Is this what we are doing now, Elynia? Fleeing from the enemy like cowards?"
        [/message]

        [message]
            speaker=Elynia
            message= _ "We’re not fleeing from her — we are just advancing to a more tactically advantageous position! Mal Keshar, take care of the enchantment shielding the gate!"
        [/message]

        [setup_doors]
            side=6
            terrain=*^Zz*
        [/setup_doors]

        {CLEAR_CAVE_SHROUD terrain,radius=*^Zz*,3}

        [redraw]
            side=1
        [/redraw]

        [scroll_to]
            terrain=*^Zz*
        [/scroll_to]

        {HIGHLIGHT_GOAL terrain=*^Zz*}

        [scroll_to_unit]
            id=Galas
        [/scroll_to_unit]

        #
        # Set up a counter for Elyssa's unconditional victory
        #

        # Yes this is a lot of turns, to account for the possibility that Mal
        # Keshar needs to move to the gates from Elyssa's keep.
        {VARIABLE boss_reactivate_turns {DIFF 8 7 7} }

        [event]
            id=boss_victory_progress_update
            name=update boss countdown
            first_time_only=no

            {OBJECTIVES (
                {OBJECTIVE_VICTORY ( _ "Destroy the exit gate using Mal Keshar before the Chaos Warlord regains her sight ($boss_reactivate_turns turns remaining)")}
                {OBJECTIVE_SHOW_IF ({VARIABLE_NUMERICAL_NOT_EQUALS boss_reactivate_turns 1})}
                {OBJECTIVE_VICTORY ( _ "Destroy the exit gate using Mal Keshar before the Chaos Warlord regains her sight (1 turn remaining)")}
                {OBJECTIVE_SHOW_IF ({VARIABLE_NUMERICAL_EQUALS boss_reactivate_turns 1})}

                {OBJECTIVE_DEFEAT ( _ "Death of Galas")}
                {OBJECTIVE_DEFEAT ( _ "Death of Elynia")}
                {OBJECTIVE_DEFEAT ( _ "Death of Mal Keshar")}
                {OBJECTIVE_DEFEAT ( _ "Death of Lédinor")}

                {TURNS_RUN_OUT}

                {OBJECTIVE_FULL_CARRYOVER}

                {OBJECTIVE_NOTE ( _ "Elyssa will be incapacitated only for a limited time ($boss_reactivate_turns turns remaining)")}
            )}
        [/event]

        [fire_event]
            name=update boss countdown
        [/fire_event]

        [event]
            id=boss_victory_countdown
            name=new turn
            first_time_only=no
            delayed_variable_substitution=yes

            {VARIABLE_DEC boss_reactivate_turns}

            [if]
                {VARIABLE_NUMERICAL_EQUALS boss_reactivate_turns 0}
                [then]
                    [fire_event]
                        name=boss victory
                    [/fire_event]
                [/then]
                [else]
                    [fire_event]
                        name=update boss countdown
                    [/fire_event]
                [/else]
            [/if]
        [/event]
    [/event]

    #
    # If Elyssa comes back to her senses it'll be too late for the player to
    # attempt to escape.
    #
    [event]
        name=boss victory

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

        [message]
            speaker=Mal Keshar
            message= _ "Oh no..."
        [/message]

        {THUNDER (
            [message]
                speaker=Mal Keshar
                message= _ "Her power is too great! I... cannot..."
            [/message]

            #
            # This will kill Mal Keshar and trigger defeat.
            #
            [kill]
                side=1
                race=undead
                animate=yes
                fire_event=yes
            [/kill]
        )}
    [/event]

#define GA_EXIT_SUF
    type=Door
    [filter_location]
        terrain=*^Zz*
    [/filter_location]
#enddef

    #
    # Only Mal Keshar can destroy the exit gate!
    #

    {FORCE_CHANCE_TO_HIT (
        [not]
            id=Mal Keshar
        [/not]
    ) ({GA_EXIT_SUF}) 0 ()}

    [event]
        name=die
        [filter]
            type=Door
            [filter_location]
                terrain=*^Zz*
            [/filter_location]
        [/filter]

        [remove_terrain_overlays]
            [filter]
                type=Door
            [/filter]
            terrain=*^Zz*
        [/remove_terrain_overlays]

        [kill]
            type=Door
            [filter_location]
                x,y=$x1,$y1
                radius=1
            [/filter_location]
        [/kill]

        [fire_event]
            name=boss stage 2
        [/fire_event]
    [/event]

    ############################################################################
    #                                                                          #
    #                               BOSS STAGE 2                               #
    #                                                                          #
    ############################################################################

    [event]
        name=boss stage 2

        [message]
            speaker=Elynia
            message= _ "Time for us to leave!"
        [/message]

        [message]
            speaker=Galas
            message= _ "What exactly do you intend to accomplish with this, Elynia? Could you at least tell me what your plan is for once?"
        [/message]

        [message]
            speaker=Elynia
            message= _ "Oh, you mean that as if you never did anything of the sort before? We have no time to waste here, I will explain later!"
        [/message]

        {OBJECTIVES (
            {OBJECTIVE_VICTORY ( _ "Escape from the Chaos Warlord with Galas, Elynia, or Mal Keshar")}

            {OBJECTIVE_DEFEAT ( _ "Death of Galas")}
            {OBJECTIVE_DEFEAT ( _ "Death of Elynia")}
            {OBJECTIVE_DEFEAT ( _ "Death of Mal Keshar")}
            {OBJECTIVE_DEFEAT ( _ "Death of Lédinor")}

            {TURNS_RUN_OUT}

            {OBJECTIVE_FULL_CARRYOVER}
        )}

        [remove_event]
            id=boss_victory_countdown # wmllint: ignore
        [/remove_event]

        [remove_event]
            id=boss_victory_progress_update # wmllint: ignore
        [/remove_event]

        {CLEAR_VARIABLE boss_reactivate_turns}

        [modify_unit]
            [filter]
                id=Elyssa
            [/filter]
            max_moves=$this_unit.variables.normal_moves
            moves=$this_unit.variables.normal_moves
        [/modify_unit]

        #
        # End the boss fight once all heroes are out of the boss chamber.
        #
        [event]
            name=moveto
            [filter]
                id=Galas,Elynia,Mal Keshar
            [/filter]
            [filter_condition]
                [not]
                    [have_unit]
                        id=Galas,Elynia,Mal Keshar
                        [not]
                            x=37-100
                            y=31-100
                        [/not]
                    [/have_unit]
                [/not]
            [/filter_condition]

            [fire_event]
                name=boss end
            [/fire_event]
        [/event]

        #
        # Don't allow returning to the boss chamber after everyone's left.
        #
        [event]
            name=moveto
            [filter]
                side=1
            [/filter]
            [filter_condition]
                [not]
                    [have_unit]
                        side=1
                        [filter_location]
                            [not]
                                area=escape_area
                            [/not]
                        [/filter_location]
                    [/have_unit]
                [/not]
            [/filter_condition]

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

            [place_shroud]
                side=1
                [not]
                    area=escape_area
                [/not]
            [/place_shroud]

            [terrain]
                x=32-35,31,33
                y=34-35,35,36
                terrain=Xos
            [/terrain]

            [redraw]
                side=1
            [/redraw]

            {QUAKE dragonstick.ogg}

            [delay]
                time=1000
            [/delay]

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

    [event]
        name=boss end

        [message]
            speaker=Elyssa
            message= _ "So that is your plan, Lady of Light. I see..."
        [/message]

        {MOVE_UNIT id=Elyssa 24 26}

        [kill]
            id=Elyssa
        [/kill]

        {REPLACE_SCENARIO_MUSIC "the_deep_path.ogg"}
    [/event]

    [event]
        name=moveto
        [filter]
            id=Galas,Elynia,Mal Keshar
            x=45-63
            y=38-48
        [/filter]

        [message]
            speaker=Galas
            message= _ "So will you explain your plan now?"
        [/message]

        [message]
            speaker=Elynia
            message= _ "I... am not completely sure yet if it is possible, but... even without Argan’s assistance, I may be able to summon the Union again somehow, if we can concentrate for a few minutes."
        [/message]

        [message]
            speaker=Galas
            message= _ "We? I don’t think I can..."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Not you! Malin and me."
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Wait, what?"
        [/message]
    [/event]

    #
    # "Victory"
    #
    [event]
        name=moveto
        [filter]
            id=Galas,Elynia,Mal Keshar
            x=1-100
            y=48
        [/filter]

        {ENDLEVEL_CONTINUE}
    [/event]

    [event]
        name=victory

        {CLEAR_VARIABLE boss_reactivate_turns,boss_revived}
    [/event]
[/scenario]

#undef GA_DRONE
#undef GA_DRONES_EASY
#undef GA_DRONES_MEDIUM
#undef GA_DRONES_HARD
#undef GA_DRONES_ULTRA
#undef GA_DRONE
#undef GA_TENTACLE
#undef GA_EXIT_SUF

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