#textdomain wesnoth-After_the_Storm

[scenario]
    id=09_Dark_Depths
    name= _ "Dark Depths"
    {MAP 09_Dark_Depths_01.map}
    {TURNS 66 64 62}
    next_scenario=10_Blood
    victory_when_enemies_defeated=no
    disallow_recall=yes

    {I_DEATHS}

    {FINALE_AMLA_EVENTS}

    {SCENARIO_MUSIC       "knalgan_theme.ogg"}
    {EXTRA_SCENARIO_MUSIC "suspense.ogg"}
    {EXTRA_SCENARIO_MUSIC "heroes_rite.ogg"}

    {STORYTXT_DARK_DEPTHS}

    {SPAWN_CONTROLLER}

    {INDOORS_HIVE} {SCHEDULE_LIGHTING -40 -80 -20}

#define FINALE_B_SHARED_AI_PARAMS
    {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 grouping            no}
#enddef

    # wmllint: validate-off
    [side]
        side=1
        controller=human
        save_id=Elynia
        team_name=good
        user_team_name= _ "team_name^Elynia"
        {RAGGED_FLAG}

        fog=yes
        shroud=yes

        {NO_ECONOMY}

        share_vision=none

        # wmllint: recognize Elynia
        {CHARACTER_STATS_ELYNIA}
        type=Guardian of Earth Elynia
        canrecruit=yes
    [/side]
    # wmllint: validate-on

    [side]
        # Midboss 2
        side=2
        team_name=evil
        user_team_name= _ "team_name^Zhangor"
        {CHAOS_FLAG}
        color=gold

        hidden=yes
        no_leader=yes

        {NO_ECONOMY}

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {FINALE_B_SHARED_AI_PARAMS}

            {AI_BOSS_TARGETING_ENGINE <<{"Elyssa","Elynia"}>>}

            [goal]
                [criteria]
                    id=Elyssa
                [/criteria]
                value=200
            [/goal]

            [goal]
                [criteria]
                    id=Elynia
                [/criteria]
                value=200 # Targets Elynia the same.
            [/goal]

            [goal]
                [criteria]
                    type=Fire Wraith
                [/criteria]
                value=1
            [/goal]
        [/ai]
    [/side]

    [side]
        # Midboss 1
        side=3
        team_name=evil
        user_team_name= _ "team_name^Engineer"
        {CHAOS_FLAG}
        color=gold

        hidden=yes
        no_leader=yes

        {NO_ECONOMY}

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {FINALE_B_SHARED_AI_PARAMS}

            {AI_BOSS_TARGETING_ENGINE <<{"Elyssa","Elynia"}>>}

            [goal]
                [criteria]
                    id=Elyssa
                [/criteria]
                value=200
            [/goal]

            [goal]
                [criteria]
                    id=Elynia
                [/criteria]
                value=100 # Prefers Elyssa.
            [/goal]

            [goal]
                [criteria]
                    type=Fire Wraith
                [/criteria]
                value=1
            [/goal]
        [/ai]
    [/side]

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

        hidden=yes

        {NO_ECONOMY}

        canrecruit=yes
        type=Giant Spider

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {FINALE_B_SHARED_AI_PARAMS}
        [/ai]

        {GENERIC_UNIT () (Vampire Bat) 45 40} {NO_UPKEEP_NO_OVERLAY} {GUARDIAN}
        {GENERIC_UNIT () (Vampire Bat) 37 42} {NO_UPKEEP_NO_OVERLAY} {GUARDIAN} {FACING ne}
        {GENERIC_UNIT () (Vampire Bat) 55 38} {NO_UPKEEP_NO_OVERLAY} {GUARDIAN}
        {GENERIC_UNIT () (Vampire Bat) 51 44} {NO_UPKEEP_NO_OVERLAY} {GUARDIAN}

        {GENERIC_UNIT () (Dread Bat) 34 41} {NO_UPKEEP_NO_OVERLAY} {GUARDIAN} {FACING se}

        {GENERIC_UNIT () (Blood Bat) 42 37} {NO_UPKEEP_NO_OVERLAY} {GUARDIAN} {FACING sw}
    [/side]

    [side]
        side=5
        team_name=evil
        user_team_name= _ "team_name^Dark Hive"
        {CHAOS_FLAG}

        hidden=yes

        {NO_ECONOMY}

        canrecruit=yes
        type=Giant Spider

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {FINALE_B_SHARED_AI_PARAMS}
        [/ai]

        {GENERIC_UNIT () (Giant Ant) 27 26} {NO_UPKEEP_NO_OVERLAY} {GUARDIAN} {FACING se}
        {GENERIC_UNIT () (Giant Ant) 26 28} {NO_UPKEEP_NO_OVERLAY} {GUARDIAN} {FACING ne}

        {GENERIC_UNIT () (Fungoid) 58 37} {NO_UPKEEP_NO_OVERLAY} {GUARDIAN}
        {GENERIC_UNIT () (Fungoid) 49 41} {NO_UPKEEP_NO_OVERLAY} {GUARDIAN}
        {GENERIC_UNIT () (Fungoid) 57 44} {NO_UPKEEP_NO_OVERLAY} {GUARDIAN}

        {GENERIC_UNIT () (Abomination) 47 38} {NO_UPKEEP_NO_OVERLAY} {GUARDIAN} {FACING nw}
    [/side]

    [side]
        side=6
        team_name=evil
        user_team_name= _ "team_name^Dark Hive"
        {CHAOS_FLAG}

        hidden=yes

        {NO_ECONOMY}

        canrecruit=yes
        type=Psy Mindraider

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {FINALE_B_SHARED_AI_PARAMS}
        [/ai]

        {GENERIC_UNIT () (Psy Crawler) 50 30} {NO_UPKEEP_NO_OVERLAY} {GUARDIAN} {FACING nw}
        {GENERIC_UNIT () (Psy Crawler) 47 36} {NO_UPKEEP_NO_OVERLAY} {GUARDIAN} {FACING se}
        {GENERIC_UNIT () (Psy Crawler) 55 38} {NO_UPKEEP_NO_OVERLAY} {GUARDIAN} {FACING sw}

        {GENERIC_UNIT () (Verlissh Matrix Flow System) 58 22} {NO_UPKEEP_NO_OVERLAY}

        {GENERIC_UNIT () (Verlissh Matrix Flow System) 50 13} {NO_UPKEEP_NO_OVERLAY}
        {GENERIC_UNIT () (Verlissh Matrix Flow System) 51 14} {NO_UPKEEP_NO_OVERLAY}

        {GENERIC_UNIT () (Verlissh Matrix Flow System) 36  9} {NO_UPKEEP_NO_OVERLAY}

        {GENERIC_UNIT () (Verlissh Matrix Flow System) 34 14} {NO_UPKEEP_NO_OVERLAY}

        {GENERIC_UNIT () (Verlissh Matrix Flow System) 22 20} {NO_UPKEEP_NO_OVERLAY}
    [/side]

    [side]
        # Shaxthal
        side=7
        team_name=evil
        user_team_name= _ "team_name^Dark Hive"
        {CHAOS_FLAG}

        hidden=yes
        no_leader=yes

        {NO_ECONOMY}

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {FINALE_B_SHARED_AI_PARAMS}
        [/ai]

        {GENERIC_UNIT () (Shaxthal Stormblade) 41 30} {NO_UPKEEP_NO_OVERLAY} {GUARDIAN} {FACING n}
        {PALETTE shaxthal_drone_surface shaxthal_drone_purple}
        {GENERIC_UNIT () (Shaxthal Stormblade) 33 24} {NO_UPKEEP_NO_OVERLAY} {GUARDIAN} {FACING sw}
        {PALETTE shaxthal_drone_surface shaxthal_drone_purple}

        {GENERIC_UNIT () (Shaxthal Turret) 33 12} {NO_UPKEEP_NO_OVERLAY}
        {GENERIC_UNIT () (Shaxthal Turret) 52 21} {NO_UPKEEP_NO_OVERLAY}
        {GENERIC_UNIT () (Shaxthal Turret) 37 11} {NO_UPKEEP_NO_OVERLAY}
    [/side]

    [side]
        # Cutscene team used to emulate side 1 units
        side=8
        team_name=good
        user_team_name= _ "team_name^Elynia"
        {RAGGED_FLAG}
        color=red
        controller=null

        hidden=yes
        no_leader=yes

        share_vision=none

        {NO_ECONOMY}
    [/side]

#define FINALE_B_DRONE_TINT_1
    [modifications]
        {UNIT_PALETTE_SWITCH () shaxthal_drone_base shaxthal_drone_purple}
    [/modifications]
#enddef
#define FINALE_B_DRONE_TINT_2
    [modifications]
        {UNIT_PALETTE_SWITCH () shaxthal_drone_surface shaxthal_drone_purple}
    [/modifications]
#enddef

    {TIMED_DRONE_SPAWNER 8 ({FINALE_B_DRONE_TINT_1} type,facing="Shaxthal Sentry Drone",se)    7 31 9}
    {TIMED_DRONE_SPAWNER 8 ({FINALE_B_DRONE_TINT_1} type,facing="Shaxthal Sentry Drone",se)    7 33 6}
    {TIMED_DRONE_SPAWNER 8 ({FINALE_B_DRONE_TINT_1} type,facing="Shaxthal Enforcer Drone",sw)  7 39 4}

    {TIMED_DRONE_SPAWNER 4 ({FINALE_B_DRONE_TINT_1} type="Shaxthal Drone")  7 35  5}
    {TIMED_DRONE_SPAWNER 4 ({FINALE_B_DRONE_TINT_1} type="Shaxthal Drone")  7 34  5}
    {TIMED_DRONE_SPAWNER 4 ({FINALE_B_DRONE_TINT_1} type="Shaxthal Drone")  7 54 22}

    {TIMED_DRONE_SPAWNER 8 ({FINALE_B_DRONE_TINT_1} type,facing="Shaxthal Sentry Drone",sw)  7 58 23}
    {TIMED_DRONE_SPAWNER 8 ({FINALE_B_DRONE_TINT_1} type,facing="Shaxthal Sentry Drone",se)  7 54 23}

    {TIMED_DRONE_SPAWNER 9 ({FINALE_B_DRONE_TINT_2} type,facing="Shaxthal Custodian Drone",ne)  7 20 20}

    {TIMED_DRONE_SPAWNER 3 ({FINALE_B_DRONE_TINT_1} type="Shaxthal Drone")  7 19 20}
    {TIMED_DRONE_SPAWNER 3 ({FINALE_B_DRONE_TINT_1} type="Shaxthal Drone")  7 20 21}

    {TIMED_DRONE_SPAWNER 6 ({FINALE_B_DRONE_TINT_1} type="Shaxthal Drone")  7 29 14}
    {TIMED_DRONE_SPAWNER 6 ({FINALE_B_DRONE_TINT_1} type="Shaxthal Drone")  7 27 15}
    {TIMED_DRONE_SPAWNER 6 ({FINALE_B_DRONE_TINT_1} type="Shaxthal Drone")  7 25 16}

    {TIMED_DRONE_SPAWNER 8 ({FINALE_B_DRONE_TINT_1} type="Shaxthal Worm")   7 22 19}
    {TIMED_DRONE_SPAWNER 8 ({FINALE_B_DRONE_TINT_1} type="Shaxthal Worm")   7 34  9}
    {TIMED_DRONE_SPAWNER 8 ({FINALE_B_DRONE_TINT_1} type="Shaxthal Worm")   7 54 25}

    {BIND_UNIT_TO_UNIT_MOVEMENT_RANGE id=Elyssa id=Elynia}

    {FIRE_GUARDIAN_SUMMONING}

    #
    # Code common to all bosses.
    #
    # FIXME: this code should really be common to all bosses and be
    #        part of the absorb_damage ability implementation.
    #

    [event]
        name=attacker hits
        first_time_only=no
        [filter_second]
            ability=absorb_damage
        [/filter_second]

        {BOSS_ABSORB_FULL_DAMAGE (x,y=$x2,$y2)}
    [/event]

    [event]
        name=defender hits
        first_time_only=no
        [filter]
            ability=absorb_damage
        [/filter]

        {BOSS_ABSORB_FULL_DAMAGE (x,y=$x1,$y1)}
    [/event]

    {HIVE_NOISE_2_SOUND_SOURCE}
    [+sound_source]
        id=hive_noise # wmllint: ignore
    [/sound_source]

    {CAVE_WATER_SOUND_SOURCE 42  5}
    [+sound_source]
        id=water_drip_1 # wmllint: ignore
    [/sound_source]
    {CAVE_WATER_SOUND_SOURCE 15 22}
    [+sound_source]
        id=water_drip_2 # wmllint: ignore
    [/sound_source]
    {CAVE_WATER_SOUND_SOURCE 40 27}
    [+sound_source]
        id=water_drip_3 # wmllint: ignore
    [/sound_source]
    {CAVE_WATER_SOUND_SOURCE 55 38}
    [+sound_source]
        id=water_drip_4 # wmllint: ignore
    [/sound_source]

    [event]
        name=prestart

        # This is our flag to know where in the sequence of events for this
        # scenario we are, for situations where that cannot be inferred from
        # context.
        {VARIABLE finale_b_part 1}

        {VARIABLE used_touchplate_1 no}
        {VARIABLE used_touchplate_2 no}

        # NOTE: this one is used in a later scenario
        {VARIABLE collected_crystal_shards 0}

        {VARIABLE deathbringer_limit {DIFF 2 3 4}}
        {VARIABLE demolisher_limit   {DIFF 1 2 3}}

        {VARIABLE part_2_map "{LE /maps/09_Dark_Depths_02.map}"}
        {VARIABLE part_3_map "{LE /maps/09_Dark_Depths_03.map}"}

        # wmllint: recognize Elyssa
        {RECALL_ELYSSA_AT_LOCATION 44 23}

        {FACE_DIRECTION id=Elyssa ne}
        {FACE_DIRECTION id=Elynia sw}

        [hide_unit][/hide_unit]

        {OBJECTIVES (
            victory_string= _ "Current Objective:"
            {OBJECTIVE_VICTORY ( _ "Proceed further underground")}

            {OBJECTIVE_DEFEAT  ( _ "Death of Elyssa")}
            {OBJECTIVE_DEFEAT  ( _ "Death of Elynia")}

            {TURNS_RUN_OUT}

            {OBJECTIVE_NO_CARRYOVER}

            {LIMITED_CHARACTER_MOVES_NOTE}
            {FIRE_GUARDIAN_SUMMONING_NOTE}
        )}

        {BLACK_SCREEN}

        {LOCK_VIEW}
    [/event]

    [event]
        name=DEBUG1

        [teleport]
            [filter]
                id=Elyssa
            [/filter]
            x,y=37,43
        [/teleport]

        [teleport]
            [filter]
                id=Elynia
            [/filter]
            x,y=36,42
        [/teleport]
    [/event]

    [event]
        name=DEBUG2

        # Allow Elynia to move again.
        {DISABLE_BOUND_UNITS}

        [modify_turns]
            value=-1
        [/modify_turns]

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

        [fire_event]
            name=start part 2
        [/fire_event]
    [/event]

    [event]
        name=DEBUG3

        {DISABLE_BOUND_UNITS}

        {REMOVE_SOUND_SOURCE hive_noise,water_drip_1,water_drip_2,water_drip_3,water_drip_4}
        {REMOVE_SOUND_SOURCE cave_noise} # in case we're in part 2

        [modify_turns]
            value=-1
        [/modify_turns]

        [fire_event]
            name=start part 3
        [/fire_event]
    [/event]

    #
    # NOTE: part 1 has some stock macro-controlled events for which it isn't
    # currently feasible to add these conditionals. The maps for parts 2 and 3
    # are designed in such way those locations are inacessible during normal
    # gameplay. They are also marked with the Rough Overlay in the editor.
    #

#define FINALE_B_IN_PART_1
    {VARIABLE_NUMERICAL_EQUALS finale_b_part 1}
#enddef

#define FINALE_B_IN_PART_2
    {VARIABLE_NUMERICAL_EQUALS finale_b_part 2}
#enddef

#define FINALE_B_IN_PART_3
    {VARIABLE_NUMERICAL_EQUALS finale_b_part 3}
#enddef

    [event]
        name=start

        {FADE_IN}

        {MOVE_UNIT id=Elyssa 44 17}

        [unhide_unit][/unhide_unit]

        [redraw]
            side=1
        [/redraw]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Elynia
            message= _ "... We are not really trying to locate Zhangor, are we?"
        [/message]

        [message]
            speaker=Elyssa
            message= _ "Of course we are. It is just taking us a while because he prefers to dwell in a very particular place... a place I also want you to see, before confronting him. I also want to give him a while to realize his mistake in interpreting the Seer’s prophecy."
        [/message]

        [message]
            speaker=Elynia
            message= _ "What mistake?"
        [/message]

        [message]
            speaker=Elyssa
            message= _ "The Seer said that on the Day of the Longest Night, the Angel of Blood would make a hasty attempt on the life of the New Guardian of Darkness, and fail. She also said that his actions would bring forth his own downfall."
        [/message]

        [message]
            speaker=Elyssa
            message= _ "Of course you don’t realize it because creatures like you lose track of time underground, but the Day of the Longest Night has been going on for more than a day already. And that is all because the New Guardian of Darkness the Seer mentioned cannot control her own powers, causing Irdya to be completely shrouded in darkness for longer than it should."
        [/message]

        [message]
            speaker=Elyssa
            message= _ "Zhangor decided to send his beasts after Ergea and your friend first, and then wait in his lair for me to go and challenge him — which would be a fairly predictable course of action for me. Or alternatively, he is waiting for Naia to rise up again so he can attack me then. All his actions suggest he wanted to subvert the prophecy. But he already confronted the New Guardian of Darkness and failed to kill her — granted, through his minions."
        [/message]

        [message]
            speaker=Elyssa
            message= _ "The New Guardian of Darkness the Seer referred to is not me. It is the girl. And the Longest Night will not end until she can put an end to the turmoil in her own heart, figuratively speaking."
        [/message]

        [message]
            speaker=Elynia
            message= _ "How do you know all this?"
        [/message]

        [message]
            speaker=Elyssa
            message= _ "Ha, ha, ha! Don’t forget I am a Guardian of Darkness — not the newest one, but I certainly am Merthiaal’s heiress, Yarae’s design be damned. Not only I can read into the minds of the weak, but I can also understand people’s desires and motivations in general. It is possible to predict their actions in advance this way. Ah well, that last part is not one of the powers of a Guardian of Darkness, strictly speaking."
        [/message]

        [message]
            speaker=Elyssa
            message= _ "And unfortunately, I also suspect Zhangor is already aware of our movements. Let’s not make him wait more time than strictly necessary, shall we?"
        [/message]

        {UNLOCK_VIEW}
    [/event]

    #
    # Events for the crystal shards during the first half of the scenario.
    #

    [event]
        name=collect crystal shard
        first_time_only=no

        {VARIABLE_INC collected_crystal_shards}

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

        [redraw]
            side=1
        [/redraw]

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

#define FINALE_B_CRYSTAL_SHARD _X _Y
    {PLACE_IMAGE items/crystal-shard.png {_X} {_Y} }

    #
    # There are no events for other units attempting to
    # collect these. This is intentional.
    #

    [event]
        name=moveto
        [filter]
            x={_X}
            y={_Y}
            [and]
                id=Elyssa
                [or]
                    id=Elynia
                [/or]
            [/and]
        [/filter]
        [filter_condition]
            {FINALE_B_IN_PART_1}
        [/filter_condition]

        [fire_event]
            name=collect crystal shard
            [primary_unit]
                x,y=$x1,$y1
            [/primary_unit]
        [/fire_event]
    [/event]
#enddef

    {FINALE_B_CRYSTAL_SHARD 37 21}

    {FINALE_B_CRYSTAL_SHARD 31 33}

    {FINALE_B_CRYSTAL_SHARD 46 48}

    {FINALE_B_CRYSTAL_SHARD 61 29}

    #
    # Some dialogue follows the activation of this
    # glyph.
    #

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

        {CLEAR_CAVE_SHROUD (
            x,y=25,25
            radius=2
        )}

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

    {GATE_GLYPH 38  3 25 25}

    [event]
        name=moveto
        [filter]
            side=1
            x,y=38,3
        [/filter]
        [filter_condition]
            {FINALE_B_IN_PART_1}
        [/filter_condition]

        {LOCK_VIEW}

        [terrain]
            terrain=^Br\
            x,y=25,25
            layer=overlay
        [/terrain]

        [redraw]
            side=1
        [/redraw]

        [message]
            speaker=Elynia
            message= _ "Where does that lead to?"
        [/message]

        [message]
            speaker=Elyssa
            message= _ "It’s an alternative path to an elevator shaft that will take us directly to the place I previously mentioned. While I don’t mind stabbing whoever stands in our way, a more discreet approach will get us there faster."
        [/message]

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

        {UNLOCK_VIEW}
    [/event]

    [event]
        name=may not use touchplate dialog
        first_time_only=no

        [message]
            speaker=narrator
            image=wesnoth-icon.png
            message= _ "Only a fully corporeal unit such as Elyssa or Elynia may activate this touchplate."
        [/message]
    [/event]

#define FINALE_B_IS_HERO
    id=Elynia
    [or]
        id=Elyssa
    [/or]
#enddef

#define FINALE_B_TOUCHPLATE _NUM _X _Y
    {ITEM_TOUCHPLATE {_X} {_Y} }

    [event]
        name=moveto
        first_time_only=no
        [filter]
            side=1
            type=Fire Wraith
            x={_X}
            y={_Y}
        [/filter]
        [filter_condition]
            {VARIABLE_BOOLEAN_EQUALS ("used_touchplate_"+{_NUM}) no}
            {FINALE_B_IN_PART_1}
        [/filter_condition]

        [fire_event]
            name=may not use touchplate dialog
        [/fire_event]
    [/event]

    [event]
        name=moveto
        [filter]
            x={_X}
            y={_Y}
            [and]
                {FINALE_B_IS_HERO}
            [/and]
        [/filter]
        [filter_condition]
            {FINALE_B_IN_PART_1}
        [/filter_condition]

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

        {VARIABLE ("used_touchplate_"+{_NUM}) yes}
    [/event]
#enddef

    #
    # Affects the walls around (44, 31) via explosion.
    #

    {FINALE_B_TOUCHPLATE 1 42 30}

    [event]
        name=moveto
        [filter]
            x,y=42,30
            [and]
                {FINALE_B_IS_HERO}
            [/and]
        [/filter]
        [filter_condition]
            {FINALE_B_IN_PART_1}
        [/filter_condition]

        {LOCK_VIEW}

        [delay]
            time=750
        [/delay]

        [message]
            speaker=narrator
            image=wesnoth-icon.png
            message= _ "Nothing happens."
        [/message]

        [if]
            [have_unit]
                x,y=$x1,$y1
                id=Elyssa
            [/have_unit]
            [then]
                [message]
                    speaker=Elyssa
                    message= _ "These passages have gone unused for centuries — it’s no wonder that most of their mechanisms have rusted beyond use. But I know a method that never fails..."
                [/message]
            [/then]
            [else]
                [message]
                    speaker=Elyssa
                    message= _ "These passages have gone unused for centuries — it’s no wonder that most of their mechanisms have rusted beyond use. Just blast the wall down already."
                [/message]
            [/else]
        [/if]

        [delay]
            time=750
        [/delay]

        #
        # Very simplified version of the "blast event wall" event from
        # the previous scenario.
        #

        [hide_unit][/hide_unit]

        {RED_SCREEN}

        [terrain]
            x=42-45,44,43
            y=31   ,30,32
            terrain=Ur^Es
        [/terrain]

        {CLEAR_CAVE_SHROUD (
            x=42-45,44,43
            y=31   ,30,32
        )}

        [scroll_to]
            x,y=44,31
            {WARP}
        [/scroll_to]

        [redraw]
            side=1
        [/redraw]

        {RESET_SCREEN}

        [unhide_unit][/unhide_unit]

        {QUAKE ("explosion-big.ogg")}

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Elyssa
            message= _ "Perfect."
        [/message]

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

        {UNLOCK_VIEW}
    [/event]

    #
    # This one is manually controlled further.
    # It affects both the walls around (44, 39), and the gate around 52 29.
    #
    {GATE_GLYPH 54 41 52 29}

    [event]
        name=moveto
        [filter]
            side=1
            x,y=54,41
        [/filter]
        [filter_condition]
            {FINALE_B_IN_PART_1}
        [/filter_condition]

        [message]
            speaker=Elyssa
            message= _ "That is not very useful—"
        [/message]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Elyssa
            message= _ "Hm, there is a hot current of air coming from another direction now."
        [/message]

        [terrain]
            x,y=43,39-40
            terrain=Urb
        [/terrain]

        {CLEAR_CAVE_SHROUD (x,y,radius=44,39,1)}

        [redraw]
            side=1
        [/redraw]

        [delay]
            time=750
        [/delay]

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

        {HIGHLIGHT_GOAL x,y=44,39}

        [message]
            speaker=Elyssa
            message= _ "Ah. I remember now."
        [/message]

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

    #
    # Lava shore.
    #

#define FINALE_B_LAVA_SHORE_X_Y
    x=43   ,44
    y=39-40,39
#enddef

#define FINALE_B_TRY_RELOCATE_HERO _ID _LOCS_X_Y
    [if]
        [not]
            [have_unit]
                id={_ID}
                {_LOCS_X_Y}
            [/have_unit]
        [/not]
        [then]
            [store_locations]
                {_LOCS_X_Y}
                [not]
                    [filter][/filter]
                [/not]
                variable=vacant_locs
            [/store_locations]

            [teleport]
                [filter]
                    id={_ID}
                [/filter]
                x,y=$vacant_locs[0].x,$vacant_locs[0].y
            [/teleport]

            {CLEAR_VARIABLE vacant_locs}
        [/then]
    [/if]
#enddef

    [event]
        name=moveto
        [filter]
            {FINALE_B_LAVA_SHORE_X_Y}
            [and]
                {FINALE_B_IS_HERO}
            [/and]
        [/filter]
        [filter_condition]
            {FINALE_B_IN_PART_1}
        [/filter_condition]

        {LOCK_VIEW}

        #
        # Make sure Elynia and Elyssa are together at this point.
        #

        {FORCE_MOBILIZE_BOUND_UNIT id=Elynia}

        [store_unit]
            [filter]
                {FINALE_B_LAVA_SHORE_X_Y}
                [not]
                    id=Elynia
                [/not]
                [not]
                    id=Elyssa
                [/not]
            [/filter]
            variable=other_store
            kill=yes
        [/store_unit]

        {FINALE_B_TRY_RELOCATE_HERO Elynia ({FINALE_B_LAVA_SHORE_X_Y})}
        {FINALE_B_TRY_RELOCATE_HERO Elyssa ({FINALE_B_LAVA_SHORE_X_Y})}

        [foreach]
            array=other_store
            [do]
                [unstore_unit]
                    variable=this_item
                    find_vacant=yes
                    check_passability=no
                [/unstore_unit]
            [/do]
        [/foreach]

        {CLEAR_VARIABLE other_store}

        {CLEAR_CAVE_SHROUD (
            x,y=41,40
            radius=4
        )}

        [redraw]
            side=1
        [/redraw]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Elyssa
            message= _ "We need to cross this inconvenient lava trench. Elynia, do your thing."
        [/message]

        [message]
            speaker=Elynia
            message= _ "My... thing?"
        [/message]

        [message]
            speaker=Elyssa
            message= _ "You are the Guardian of Earth, dear. You are supposed to do more complicated things than blasting walls and vermin."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Do you really expect me to know how this works all of a sudden?! I did not ask to be given this role, and all I know is that the pain has not ceased! I cannot think clearly like this!"
        [/message]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Elyssa
            message= _ "I really should just stab you in the chest and toss your useless bloody corpse into the lava."
        [/message]

        [hide_unit][/hide_unit]

        {RED_SCREEN}

        [terrain]
            x=42,41
            y=39,40
            terrain=Uh
        [/terrain]

        [redraw]
            side=1
        [/redraw]

        {RESET_SCREEN}

        [unhide_unit][/unhide_unit]

        {QUAKE ("explosion-big.ogg")}

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Elyssa
            message= _ "Keep moving."
        [/message]

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

        {UNLOCK_VIEW}
    [/event]

#define FINALE_B_CHAMBER_WALL_X_Y
    x=33,34,35,36
    y=43,43,44,44
#enddef

    # Manually controlled.
    # Affects the walls around (34, 43) via old-fashioned wall-lifting.
    {FINALE_B_TOUCHPLATE 2 35 43}

    [event]
        name=moveto
        [filter]
            x,y=35,43
            [and]
                {FINALE_B_IS_HERO}
            [/and]
        [/filter]
        [filter_condition]
            {FINALE_B_IN_PART_1}
        [/filter_condition]

        {LOCK_VIEW}

        {VARIABLE spawner_controller_enabled no}

        {FORCE_MOBILIZE_BOUND_UNIT id=Elynia}

        [if]
            [have_unit]
                id=Elyssa
                x,y=$x1,$y1
            [/have_unit]
            [then]
                [message]
                    speaker=Elyssa
                    message= _ "Well, this wall is not going to move by itself—"
                [/message]
            [/then]
            [else]
                [message]
                    speaker=Elyssa
                    message= _ "Well, that wall is not going to move by itself—"
                [/message]
            [/else]
        [/if]

        {QUAKE ("rumble.ogg")}

        [terrain]
            {FINALE_B_CHAMBER_WALL_X_Y}
            terrain=Urb
        [/terrain]

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

        {CLEAR_CAVE_SHROUD (
            x,y=31,48
            radius=5
        )}

        [redraw]
            side=1
        [/redraw]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Elyssa
            message= _ "I stand corrected. That was very convenient."
        [/message]

        {MOVE_UNIT id=Elyssa 32 46}
        {MOVE_UNIT id=Elynia 34 47}

        {RESET_UNIT_STATUSES (
            id=Elyssa
            [or]
                id=Elynia
            [/or]
        )}

        [kill]
            type=Fire Wraith
            side=1
        [/kill]

        [place_shroud]
            side=1
            [not]
                x,y=31,48
                radius=6
            [/not]
        [/place_shroud]

        [terrain]
            {FINALE_B_CHAMBER_WALL_X_Y}
            terrain=Xos
        [/terrain]

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

        [redraw]
            side=1
        [/redraw]

        {REPLACE_SCENARIO_MUSIC "overlive.ogg"}

        {QUAKE ("dragonstick.ogg")}

        [delay]
            time=500
        [/delay]

        {FACE_DIRECTION id=Elyssa ne}
        {FACE_DIRECTION id=Elynia nw}

        [redraw][/redraw]

        [delay]
            time=1000
        [/delay]

        [message]
            speaker=Elyssa
            message= _ "Of course. A cunning trap by Zhangor, I presume?"
        [/message]

        {FACE_DIRECTION id=Elyssa sw}
        {FACE_DIRECTION id=Elynia sw}

        [redraw][/redraw]

        [delay]
            time=500
        [/delay]

        {FACE_DIRECTION id=Elyssa se}

        {CLEAR_CAVE_SHROUD (
            x,y=31,52
            radius=4
        )}

        [redraw]
            side=1
        [/redraw]

        [scroll_to]
            x,y=32,52
        [/scroll_to]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Elyssa
            scroll=no
            message= _ "The elevator..."
        [/message]

        [scroll_to_unit]
            id=Elyssa
        [/scroll_to_unit]

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

#define FINALE_B_ENGIE_BOSS_BOOST
    {BOSS_BOOST 60% 0 1 4 0}
    [object]
        [effect]
            apply_to=attack
            range=melee
            [set_specials]
                mode=append
                {WEAPON_SPECIAL_SLOW}
            [/set_specials]
        [/effect]
    [/object]
#enddef

    [event]
        name=boss 1 stage 1

        {LOCK_VIEW}

        [store_starting_location]
            side=3
        [/store_starting_location]

        [unit]
            canrecruit=yes
            side=3
            id=Engineer Fendyrn
            name= _ "Engineer Fendyrn"
            type=Dwarvish Engineer
            x,y=$location.x,$location.y
            [modifications]
                {TRAIT_HEALTHY}
                {TRAIT_INTELLIGENT}
            [/modifications]
        [/unit]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=narrator
            image=misc/blank-hex.png
            message= _ "... heh, heh, heh, heh, heh, heh..."
        [/message]

        [delay]
            time=250
        [/delay]

        [message]
            speaker=Elynia
            message= _ "Who is that?"
        [/message]

        {FACE_DIRECTION id=Elyssa sw}

        [redraw][/redraw]

        [message]
            speaker=Elyssa
            message= _ "Engineer?"
        [/message]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=narrator
            image=misc/blank-hex.png
            message= _ "... hah, hah, hah, hah..."
        [/message]

        [message]
            speaker=Elyssa
            message= _ "You are not supposed to be around these levels, Engineer. Return to your workshop immediately."
        [/message]

        [message]
            speaker=Engineer Fendyrn
            message= _ "I dinna’ listen tae orders from ye anymore, witch. Yer time as the ‘Warlord’ ended with Lord Zhangor’s arrival."
        [/message]

        [message]
            speaker=Elyssa
            message= _ "I believe I speak for Zhangor as well when I say that you are not supposed to be here. Return to your workshop immediately, or face the consequences."
        [/message]

        [message]
            speaker=Engineer Fendyrn
            message= _ "Ye’ll chop me remainin’ leg too, winna ye? Ha, ha, ha, ha. Yer torture methods are as obsolete as the tech’ Argan used tae rebuild yer body." # wmllint: no spellcheck
        [/message]

        [message]
            speaker=Engineer Fendyrn
            # po: "Squirming insects" refers to the Shaxthal.
            # po: "The two of you" refers to Elyssa and Zhangor, not Elyssa and Elynia.
            message= _ "Zhangor released me a while ago, didna’ ye hear? “Yer free”, he said. “Ye can do anythin’ ye please”, said. And so here I am, ready tae take on the two of ye, and all yer squirmin’ insects." # wmllint: no spellcheck
        [/message]

        [message]
            speaker=Elyssa
            message= _ "Is this insubordination I hear? This is your last chance."
        [/message]

        [message]
            speaker=Engineer Fendyrn
            message= _ "I believe ’tis yer last chance tae run, girl." # wmllint: no spellcheck
        [/message]

        {REPLACE_SCENARIO_MUSIC "silence.ogg"}

        [hide_unit][/hide_unit]

        {WHITE_SCREEN}

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

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

        [terrain]
            x=24
            y=47-53
            terrain=Ur^Es
        [/terrain]

        {CLEAR_CAVE_SHROUD (
            x,y=26,49
            radius=7
        )}

        [redraw][/redraw]

        [kill]
            id=Engineer Fendyrn
        [/kill]

        [hidden_unit]
            canrecruit=yes
            side=3
            id=Engineer Fendyrn
            name= _ "Engineer Fendyrn"
            type=Magnum Suit
            {IS_BOSS}
            x,y=$location.x,$location.y
            facing=ne
            [modifications]
                {TRAIT_MECHANICAL}
                {TRAIT_INTELLIGENT}
            [/modifications]
            [variables]
                previous_facing=none
            [/variables]
        [/hidden_unit]

        {CLEAR_VARIABLE location}

        [hidden_unit]
            side=3
            type=Goliath
            x,y=22,48
            facing=ne
            [modifications]
                {TRAIT_MECHANICAL}
                {FINALE_B_ENGIE_BOSS_BOOST}
            [/modifications]
        [/hidden_unit]

        [hidden_unit]
            side=3
            type=Goliath
            x,y=21,49
            facing=ne
            [modifications]
                {TRAIT_MECHANICAL}
                {FINALE_B_ENGIE_BOSS_BOOST}
            [/modifications]
        [/hidden_unit]

        [hidden_unit]
            side=3
            type=Goliath
            x,y=21,50
            facing=ne
            [modifications]
                {TRAIT_MECHANICAL}
                {FINALE_B_ENGIE_BOSS_BOOST}
            [/modifications]
        [/hidden_unit]

        {RESET_SCREEN}

        [unhide_unit][/unhide_unit]

        [redraw]
            side=1
        [/redraw]

        [scroll_to_unit]
            id=Engineer Fendyrn
            {WARP}
        [/scroll_to_unit]

        {BOSS_POPUP}

        [delay]
            time=1000
        [/delay]

        {REPLACE_SCENARIO_MUSIC "ambuscade-loop.ogg"}

        {INCIDENTAL_MUSIC       "moleman.ogg"}

        [message]
            speaker=Elynia
            message= _ "Oh gods... Is that..."
        [/message]

        [message]
            speaker=Engineer Fendyrn
            # po: The lich is Mal Hekuba.
            message= _ "Aye. The Soul Hammer is made’a the crystals commissioned by tha’ wretched lich. Lord Zhangor has put many a’them intae good use, elf. But he dinna’ ken ’tis hammer exists, or that it shall be the instrument of me revenge! Perhaps I should’a named her... the Destroyer o’ Gods!" # wmllint: no spellcheck
        [/message]

        [message]
            speaker=Elyssa
            message= _ "Elynia, this is extremely dangerous. Stay away from this lunatic and his hammer! You, fool... you have absolutely no idea with what kind of powers you are trifling."
        [/message]

        [message]
            speaker=Engineer Fendyrn
            message= _ "HA, HA, HA, HA, HA, HA, HA, HA!!!"
        [/message]

        [scroll_to_unit]
            id=Elyssa
        [/scroll_to_unit]

        [modify_turns]
            value=-1
        [/modify_turns]

        # Allow Elynia to move again.
        {DISABLE_BOUND_UNITS}

        {UNLOCK_VIEW}

        {OBJECTIVES (
            victory_string= _ "Current Objective:"
            {OBJECTIVE_VICTORY ( _ "Stop the Engineer")}

            {OBJECTIVE_DEFEAT  ( _ "Death of Elyssa")}
            {OBJECTIVE_DEFEAT  ( _ "Death of Elynia")}

            {OBJECTIVE_NO_CARRYOVER}

            {OBJECTIVE_NOTE ( _ "The power of the Engineer’s hammer allows him to debilitate and destroy the Energy Heart of a Guardian")}
            {OBJECTIVE_NOTE ( _ "Elyssa and Elynia cannot damage the Engineer’s armor suit as it is powered by more replicas of Merthiaal’s heart; they must find another way to stop him")}
            {FIRE_GUARDIAN_SUMMONING_NOTE}
        )}

        [event]
            delayed_variable_substitution=no
            id=engineer_backstabbing_hint_handler # wmllint: ignore
            name="turn $($turn_number + 3)"

            [message]
                speaker=Elynia
                message= _ "I have an idea... Malin once mentioned something specific about Galas’ first encounter with your mechanical automatons."
            [/message]

            [message]
                speaker=Elyssa
                message= _ "And what would that be?"
            [/message]

            [message]
                speaker=Elynia
                message= _ "They are particularly vulnerable in the neck region. Maybe if we could distract him, you could stab him with your weapon—"
            [/message]

            [message]
                speaker=Elyssa
                message= _ "That was already my plan, stupid! Just try to do your part right for once!"
            [/message]

            {OBJECTIVES (
                victory_string= _ "Current Objective:"
                {OBJECTIVE_VICTORY ( _ "Backstab the Engineer using the Claw of Urvatha while he is facing Elynia")}

                {OBJECTIVE_DEFEAT  ( _ "Death of Elyssa")}
                {OBJECTIVE_DEFEAT  ( _ "Death of Elynia")}

                {OBJECTIVE_NO_CARRYOVER}

                {OBJECTIVE_NOTE ( _ "You can only backstab the Engineer during your own turns, on offense")}
                {OBJECTIVE_NOTE ( _ "The power of the Engineer’s hammer allows him to debilitate and destroy the Energy Heart of a Guardian")}
                {FIRE_GUARDIAN_SUMMONING_NOTE}
            )}
        [/event]
    [/event]

    [event]
        name=side 3 turn refresh
        first_time_only=no
        [filter_condition]
            [have_unit]
                id=Engineer Fendyrn
            [/have_unit]
        [/filter_condition]

        [store_locations]
            x=14-40
            y=42-56
            terrain=C*,C*^*
            variable=engineer_castle_locs
        [/store_locations]

        [count_units]
            side=3
            [not]
                canrecruit=yes
            [/not]
            variable=engineer_units
        [/count_units]

        [while]
            {VARIABLE_NUMERICAL_LESS_THAN engineer_units {DIFF 5 7 10}}
            [do]
                {VARIABLE_INC engineer_units}

                {VARIABLE_RANDOM engineer_recruit "Automaton,Automaton,Automaton,Automaton,Iron Golem,Iron Golem,Goliath,Goliath,Goliath"}
                {VARIABLE_RANDOM recruit_pos      "0..$($engineer_castle_locs.length - 1)"}

                {GENERIC_UNIT 3 $engineer_recruit $engineer_castle_locs[$recruit_pos].x $engineer_castle_locs[$recruit_pos].y}
                {NO_UPKEEP_NO_OVERLAY}
                [+unit]
                    animate=yes
                    passable=yes
                    moves=0
                    attacks_left=0
                    [+modifications]
                        {FINALE_B_ENGIE_BOSS_BOOST}
                    [/modifications]
                [/unit]
            [/do]
        [/while]

        {CLEAR_VARIABLE engineer_units,engineer_castle_locs,engineer_recruit,recruit_pos}
    [/event]

    #
    # Crack the floor every time the Engineer hits something with the hammer.
    #

    [event]
        name=attacker hits
        first_time_only=no
        [filter]
            id=Engineer Fendyrn
        [/filter]
        [filter_attack]
            name=soul hammer
        [/filter_attack]

        [fire_event]
            name=crack floor
            [primary_unit]
                x,y=$x2,$y2
            [/primary_unit]
        [/fire_event]
    [/event]

    [event]
        name=defender hits
        first_time_only=no
        [filter_second]
            id=Engineer Fendyrn
        [/filter_second]
        [filter_second_attack]
            name=soul hammer
        [/filter_second_attack]

        [fire_event]
            name=crack floor
            [primary_unit]
                x,y=$x1,$y1
            [/primary_unit]
        [/fire_event]
    [/event]

    [event]
        name=crack floor
        first_time_only=no
        [filter]
            [filter_location]
                terrain=Urb,Uu,Ur,Urb^E*,Uu^E*,Ur^E*
            [/filter_location]
        [/filter]

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

    #
    # Remember the Engineer's original facing before attacking him.
    #

#define FINALE_B_ENGIE_FACING_ATTACK_HANDLER _NUM _PRIMARY _SECONDARY
    [event]
        id="engineer_bsh_atk_"+{_NUM} # wmllint: ignore
        name=attack
        first_time_only=no
        [filter]
            id={_PRIMARY}
        [/filter]
        [filter_second]
            id={_SECONDARY}
        [/filter_second]

        [fire_event]
            name=engineer facing track
            [primary_unit]
                id=Engineer Fendyrn
            [/primary_unit]
        [/fire_event]
    [/event]
#enddef

#define FINALE_B_ENGIE_FACING_MOVETO_HANDLER _NUM _PRIMARY _SECONDARY
    [event]
        id="engineer_bsh_mov_"+{_NUM} # wmllint: ignore
        name=moveto
        first_time_only=no
        [filter]
            id={_PRIMARY}
            [filter_adjacent]
                id={_SECONDARY}
            [/filter_adjacent]
        [/filter]

        [fire_event]
            name=engineer facing track
            [primary_unit]
                id=Engineer Fendyrn
            [/primary_unit]
        [/fire_event]
    [/event]
#enddef

    [event]
        id=engineer_bsh_call # wmllint: ignore
        name=engineer facing track
        first_time_only=no

        {VARIABLE unit.variables.previous_facing $unit.facing}

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

    # moveto and attack may seem redundant but it's important to remember that
    # a unit may attack a target without moving to it as well as move next to
    # it without attacking it. The objective is broad enough so that it's not
    # required for the Engineer and Elynia to actually engage in combat so
    # long as Elynia is in front of him before Elyssa stabs him.

    {FINALE_B_ENGIE_FACING_ATTACK_HANDLER A Elynia (Engineer Fendyrn)}
    {FINALE_B_ENGIE_FACING_ATTACK_HANDLER B (Engineer Fendyrn) Elynia}

    {FINALE_B_ENGIE_FACING_MOVETO_HANDLER A Elynia (Engineer Fendyrn)}
    {FINALE_B_ENGIE_FACING_MOVETO_HANDLER B (Engineer Fendyrn) Elynia}

    #
    # Handle the Engineer being backstabbed using the Claw of Urvatha.
    #

    [event]
        id=engineer_backstabbing_handler # wmllint: ignore
        name=attacker hits
        first_time_only=no
        [filter]
            id=Elyssa
        [/filter]
        [filter_attack]
            name=claw of urvatha
        [/filter_attack]
        [filter_second]
            id=Engineer Fendyrn
        [/filter_second]
        [filter_condition]
            {VARIABLE_NUMERICAL_EQUALS side_number 1}
        [/filter_condition]

        [if]
            # As of 1.14 using an invalid direction below is harmless and
            # lets the filter silently fail but I get the feeling this isn't
            # gonna be the case forever.
            {VARIABLE_LEXICAL_NOT_EQUALS second_unit.variables.previous_facing none}

            [have_unit]
                id=Elynia
                [filter_location]
                    [filter_adjacent_location]
                        x,y=$x2,$y2
                        adjacent="-$second_unit.variables.previous_facing"
                    [/filter_adjacent_location]
                [/filter_location]
            [/have_unit]
            [then]
                [fire_event]
                    name=boss 1 stage 2
                [/fire_event]
            [/then]
        [/if]
    [/event]

    [event]
        name=boss 1 stage 2

        #
        # Remove previous related event handlers.
        #

        [remove_event]
            id=engineer_bsh_mov_A,engineer_bsh_mov_B,engineer_bsh_atk_A,engineer_bsh_atk_B
        [/remove_event]

        [remove_event]
            id=engineer_bsh_call,engineer_backstabbing_hint_handler,engineer_backstabbing_handler # wmllint: ignore
        [/remove_event]

        #
        # Allow the Engineer to be damaged from now on, but boost
        # his HP and attack strength in exchange.
        #

        [object]
            silent=yes
            [filter]
                id=Engineer Fendyrn
            [/filter]
            [effect]
                apply_to=remove_ability
                [abilities]
                    {ABILITY_ABSORB_DAMAGE}
                [/abilities]
            [/effect]
            [effect]
                apply_to=hitpoints
                increase_total=25%
                heal_full=yes
            [/effect]
            [effect]
                apply_to=attack
                name=soul hammer
                increase_damage=5 # 26-2
            [/effect]
            [effect]
                apply_to=attack
                name=flamethrower
                increase_damage=1 # 16-3
            [/effect]
        [/object]

        {REPLACE_SCENARIO_MUSIC "frantic.ogg"}

        #
        # Go red.
        #

        {DARKEN_RED_SCREEN -10}

        [message]
            speaker=Engineer Fendyrn
            message= _ "ACK! What ha’ ye done!!!"
        [/message]

        [message]
            speaker=Elyssa
            message= _ "Oops! It seems your armor suit and fancy hammer are not perfect substitutes for the power of a true Guardian of Darkness!"
        [/message]

        {OBJECTIVES (
            victory_string= _ "Current Objective:"
            {OBJECTIVE_VICTORY ( _ "Defeat the Engineer now that he is vulnerable to attacks")}

            {OBJECTIVE_DEFEAT  ( _ "Death of Elyssa")}
            {OBJECTIVE_DEFEAT  ( _ "Death of Elynia")}

            {OBJECTIVE_NO_CARRYOVER}

            {OBJECTIVE_NOTE ( _ "The power of the Engineer’s hammer allows him to debilitate and destroy the Energy Heart of a Guardian")}
            {FIRE_GUARDIAN_SUMMONING_NOTE}
        )}

        [event]
            id=engineer_red_screening_handler # wmllint: ignore
            name=attacker hits
            first_time_only=no
            [filter_condition]
                [have_unit]
                    id=Engineer Fendyrn
                [/have_unit]
            [/filter_condition]

            [final_boss_hp_tint]
                id=Engineer Fendyrn
            [/final_boss_hp_tint]
        [/event]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Engineer Fendyrn
        [/filter]

        [fire_event]
            name=start part 2
        [/fire_event]
    [/event]

#define FINALE_B_ELYNIA_THOUGHTS _MESSAGE
    [message]
        speaker=narrator
        caption= _ "Elynia"
        image= # wmllint: ignore
        message=""+{_MESSAGE}+"" # wmllint: ignore
    [/message]
#enddef

    ############################################################################
    #                                                                          #
    #                               SECOND PART                                #
    #                                                                          #
    ############################################################################

    [event]
        name=start part 2

        {LOCK_VIEW}

        {DARKEN_RED_SCREEN -60}

        {REPLACE_SCENARIO_MUSIC "silence.ogg"}

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

        {VARIABLE finale_b_part 2}

        #
        # Prepare transition to part 2.
        #

        {QUAKE ("rumble.ogg")}

        [delay]
            time=500
        [/delay]

        {QUAKE ("explosion-big.ogg")}

        [delay]
            time=250
        [/delay]

        {QUAKE ("dragonstick.ogg")}

        [message]
            speaker=Elyssa
            message= _ "Elynia, grab my hand!"
        [/message]

        {QUAKE ("explosion-big.ogg")}

        [delay]
            time=500
        [/delay]

        {DISABLE_FIRE_GUARDIAN_SUMMONING}

        {RESET_UNIT_STATUSES (
            id=Elynia
            [or]
                id=Elyssa
            [/or]
        )}

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

        [store_unit]
            [filter]
                id=Elyssa
            [/filter]
            variable=elyssa_store
            kill=yes
        [/store_unit]

        [kill]
            #
            # Kill everything else on the map.
            #
            [not]
                x,y=recall,recall
            [/not]
        [/kill]

        #
        # Deactivate all sides we will not use anymore.
        #

        [modify_side]
            [filter_side]
                [not]
                    side=1
                [/not]
                [not]
                    side=2
                [/not]
                [not]
                    side=8
                [/not]
            [/filter_side]
            hidden=yes
            controller=null
        [/modify_side]

        [remove_item][/remove_item]

        {CLEAR_LABELS}

        {BLACK_SCREEN}

        [terrain]
            terrain=Xv
        [/terrain]

        [place_shroud]
            side=1
        [/place_shroud]

        [redraw]
            side=1
        [/redraw]

        {REMOVE_SOUND_SOURCE hive_noise,water_drip_1,water_drip_2,water_drip_3,water_drip_4}

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

        #
        # Break.
        #

        [delay]
            # rumble.ogg is 6 seconds long. We want to mute SFX after we are
            # done playing it.
            time=6000
        [/delay]

        #
        # Setup the new map.
        #

        [replace_schedule]
            {UNDERGROUND}
        [/replace_schedule]

        [replace_map]
            map=$part_2_map
            expand,shrink=yes,yes
        [/replace_map]

        [redraw][/redraw]

        # The demolition immunity flag is used during the next boss fight.

        {VARIABLE elynia_store.x      50}
        {VARIABLE elynia_store.y      33}
        {VARIABLE elynia_store.facing se}
        {VARIABLE elynia_store.status.immune_to_demolition yes}

        {VARIABLE elyssa_store.x      50}
        {VARIABLE elyssa_store.y      31}
        {VARIABLE elyssa_store.facing se}
        {VARIABLE elyssa_store.status.immune_to_demolition yes}

        # Reinstate fog.

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

        {CLEAR_CAVE_SHROUD (
            x,y=50,31
            radius=4
        )}

        [hidden_unit]
            {CHARACTER_STATS_ELYNIA}
            type=Guardian of Earth Elynia
            canrecruit=no
            facing=$elynia_store.facing
            side=1
            x,y=$elynia_store.x,$elynia_store.y
            max_hitpoints=1
            variation=injured
        [/hidden_unit]

        {PLACE_IMAGE "scenery/blood-2.png" $elynia_store.x $elynia_store.y}

        [hidden_unit]
            {CHARACTER_STATS_ELYSSA}
            type=Guardian of Darkness Elyssa
            canrecruit=no
            facing=$elyssa_store.facing
            side=8
            x,y=$elyssa_store.x,$elyssa_store.y
            max_hitpoints=1
            variation=injured
        [/hidden_unit]

        {PLACE_IMAGE "scenery/blood-1.png" $elyssa_store.x $elyssa_store.y}

        {PLACE_IMAGE ("items/claw-of-urvatha.png~FL(horiz)") ("$($elyssa_store.x - 1)") $elyssa_store.y}

        {CLEAR_FOG 1 $elyssa_store.x "$($elyssa_store.y - 1)" $elyssa_store.max_moves}

        [redraw]
            side=1
        [/redraw]

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

        [mute_sound_effects][/mute_sound_effects]

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

        [fade_in_sound_effects]
            duration=500
        [/fade_in_sound_effects]

        {FADE_IN}

        [unhide_unit][/unhide_unit]

        [redraw]
            side=1
        [/redraw]

        [delay]
            time=3000
        [/delay]

        [message]
            speaker=Elynia
            image=misc/blank-hex.png
            message= _ "Unngh..." # wmllint: no spellcheck
        [/message]

        [delay]
            time=1000
        [/delay]

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

        [redraw][/redraw]

        [delay]
            time=1500
        [/delay]

        {FINALE_B_ELYNIA_THOUGHTS ( _ "I did not know where I was. The last thing I could recall was the chamber floor collapsing due to the energy released from the dwarf’s fractured hammer.")}

        {FINALE_B_ELYNIA_THOUGHTS ( _ "My neck felt cold and sticky... it was blood. I must have smashed my head during the fall, and yet I was standing there as though my body had healed itself from the otherwise fatal injury.

I glanced at my surroundings...")}

        # FIXME: ah, if only!
        #{FACE_DIRECTION id=Elynia n}
        {FACE_DIRECTION id=Elynia nw}

        [redraw][/redraw]

        [delay]
            time=750
        [/delay]

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

        {MOVE_UNIT id=Elynia ("$elyssa_store.x") ("$($elyssa_store.y + 1)")}

        [delay]
            time=1000
        [/delay]

        # po: Yes, Elynia is describing a literal BSOD (Blue Screen of Death).
        # po: See: http://en.wikipedia.org/wiki/Blue_Screen_of_Death
        # po: Looks like Norsulan technology isn't perfect either!
        {FINALE_B_ELYNIA_THOUGHTS ( _ "The demoness was lying on the humid cavern floor, inert as a rock. She did not seem injured, but neither did she draw breath. I did not know at first what to make of the situation.

I laid a hand on her forehead and attempted to peer into her mind to see whether she was still alive. However, all I could see through her frozen eyes was a series of incomprehensible white glyphs on a blue background, interspersed with an alien and yet somehow familiar language. Knowing she was a hybrid lifeform, the evidence I gathered was useless.")}

        {FINALE_B_ELYNIA_THOUGHTS ( _ "She could be alive... or she could be dead.

And not too far from her was the weapon she called the Claw of Urvatha. My master’s staff, first corrupted by the heart of a Gatekeeper, the artifact we used to call the Ruby of Fire, and now, by the malignant touch of Merthiaal’s successor.")}

        [delay]
            time=750
        [/delay]

        {FINALE_B_ELYNIA_THOUGHTS ( _ "I felt compelled to grab the weapon and leave the demoness behind... but I had to ponder my possibilities first. She could come back to life the moment I laid my hands on it, and destroy me. Or she could stay as a dormant machine, and I would just abandon her and return to the surface, with Anya and Ergea.

A third alternative then occurred to me. I could grab the Claw, and destroy the creature in her sleep...")}

        [delay]
            time=1500
        [/delay]

        {FINALE_B_ELYNIA_THOUGHTS ( _ "... I spent some amount of time contemplating that tempting alternative.

Suddenly, the thought of becoming a cold-blooded murderer horrified me.

No.

No, I would not give in to such terrifying ideas. No. That was not me. That was not the elf who was raised by Niryone to protect the peoples of Irdya.

No.")}

        {MOVE_UNIT id=Elynia 48 30}

        {UNCLEAR_FOG}

        [redraw]
            side=1
        [/redraw]

        [delay]
            time=1000
        [/delay]

        {FINALE_B_ELYNIA_THOUGHTS ( _ "Between tears, I could catch a glimpse of light coming from around a corner.")}

        [delay]
            time=750
        [/delay]

        {MOVE_UNIT id=Elynia 46 29}
        {FACE_DIRECTION id=Elynia sw}

        [redraw]
            side=1
        [/redraw]

        [delay]
            time=750
        [/delay]

        {FINALE_B_ELYNIA_THOUGHTS ( _ "A conspicuous corridor, leading somewhere brightly illuminated. The walls were decorated with peculiar engravings.

I was compelled to follow. With my captor completely incapacitated to exert any kind of magic control over me, I could once again move with absolute freedom.")}

        {MOVE_UNIT id=Elynia 40 32}

        [terrain]
            x,y=43,31
            terrain=^Xo
            layer=overlay
        [/terrain]

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

        [place_shroud]
            side=1
            [not]
                x,y=40,32
                radius=3
            [/not]
        [/place_shroud]

        [redraw]
            side=1
        [/redraw]

        [kill]
            id=Elyssa
        [/kill]

        [remove_item]
            x,y="$($elyssa_store.x - 1)",$elyssa_store.y
        [/remove_item]

        [scroll_to_unit]
            id=Elynia
        [/scroll_to_unit]

        {OBJECTIVES (
            victory_string= _ "Current Objective:"
            {OBJECTIVE_VICTORY ( _ "Explore the place")}

            {OBJECTIVE_DEFEAT  ( _ "Death of Elynia")}

            {OBJECTIVE_NO_CARRYOVER}

            {UNLIMITED_PLAYER_MOVES_NOTE}
        )}

        {CLEAR_VARIABLE elynia_store} # NOT elyssa_store, used later.

        [disallow_end_turn][/disallow_end_turn]

        {UNLIMITED_PLAYER_MOVES}

        {UNLOCK_VIEW}

        [event]
            name=moveto
            first_time_only=no
            [filter]
                id=Elynia
                x=41,42
                y=32,31
            [/filter]

            # Eeenope, not going back.

            {FINALE_B_ELYNIA_THOUGHTS ( _ "It was not my intention to go back where Elyssa’s inert body laid. I needed to keep exploring the corridor. My curiosity was just too great to resist.")}
        [/event]
    [/event]

    [event]
        name=moveto
        [filter]
            id=Elynia
            # The sigil room event.
            x=18,17-19,14-22,12-24,12-26,14-25,23-24,25 # last two entries correspond to
            y=38,   39,   40,   41,42-47,48-51,   40,41 # the arch at the entrance
        [/filter]
        [filter_condition]
            {FINALE_B_IN_PART_2}
        [/filter_condition]

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

#define FINALE_B_ARGAN_THOUGHTS _MESSAGE
    [message]
        speaker=narrator
        caption= _ "Argan"
        image= # wmllint: ignore
        message=""+{_MESSAGE}+"" # wmllint: ignore
    [/message]
#enddef

    [event]
        name=cutscene 1

        {BUG_ON ({FINALE_B_IN_PART_1}) ()}

        {LOCK_VIEW}

        {CLEAR_LABELS}

        {CLEAR_CAVE_SHROUD (
            x,y=19,43
            radius=8
        )}

        {MOVE_UNIT id=Elynia 19 43}

        [place_shroud]
            side=1
            [not]
                x,y=19,43
                radius=8
            [/not]
        [/place_shroud]

        [redraw]
            side=1
        [/redraw]

        [scroll_to]
            x,y=19,45
        [/scroll_to]

        [scroll_to_unit]
            id=Elynia
        [/scroll_to_unit]

        [delay]
            time=1000
        [/delay]

        {FINALE_B_ELYNIA_THOUGHTS ( _ "The ceiling lights formed a familiar shape on the floor: the sigil of the First Guardian of Earth, Xia’el. Or at least, as it was depicted in Argan’s journal.

An odd sense of comfort suddenly came to me. I felt for once as though I was, finally, at home.")}

        [delay]
            time=750
        [/delay]

        {MOVE_UNIT id=Elynia 19 45}

        {FACE_DIRECTION id=Elynia ne}

        [fade_out_sound_effects]
            duration=750
        [/fade_out_sound_effects]

        {REPLACE_SCENARIO_MUSIC "snowfall.ogg"}

        {FINALE_B_ELYNIA_THOUGHTS ( _ "If Elyssa spoke the truth, this was my destiny all along. I was meant to be the Guardian of Earth on Irdya, and I was meant to keep my world and my people from harm; from Elyssa, from Argan, from Zhangor, from Uria...

... From myself.

... And I had failed. I had failed them all. I grew up ignorant of my true purpose, focusing only on mundane problems, selfishly centered on my own needs and desires for the most part. I allowed Irdya’s terrible fate to come to pass: the destruction of many civilizations, the deaths of millions.

Weren’t Guardians created to protect their worlds?")}

        [delay]
            time=750
        [/delay]

        [hide_unit][/hide_unit]

        {FADE_TO_BLACK}

        [delay]
            time=1000
        [/delay]

        #
        # Dear gods, why am I doing this to myself? Next campaign I write
        # will be all about happiness and sunshine.
        #

        {FINALE_B_ELYNIA_THOUGHTS ( _ "I let myself collapse on the floor... and cried.

I needed to cry after Galas’ death. I needed to cry after losing Malin. But I resisted the emotion for so long because I did not want anyone to know I was weak inside.

But then, I was at home at last... alone. Nobody would know. So I cried.

I wished Anya could be with me. But she did not know where I was, and I did not even know whether she was still alive. And even if she was... it would only be a matter of time until Zhangor solved the Seer’s riddle and killed the girl.")}

        [delay]
            time=750
        [/delay]

        {FINALE_B_ELYNIA_THOUGHTS ( _ "Home...")}

        [delay]
            time=5000
        [/delay]

        {FINALE_B_ARGAN_THOUGHTS ( _ "There, there.")}

        [delay]
            time=750
        [/delay]

        {FINALE_B_ARGAN_THOUGHTS ( _ "You have not failed yet, my love. There are still things left to do.")}

        [delay]
            time=2000
        [/delay]

        {FINALE_B_ELYNIA_THOUGHTS ( _ "... A— Argan?")}

        [delay]
            time=250
        [/delay]

        {FINALE_B_ELYNIA_THOUGHTS ( _ "... Oh, I must have really lost it now.")}

        [delay]
            time=250
        [/delay]

        {FINALE_B_ARGAN_THOUGHTS ( _ "I am here. Don’t you feel me?")}

        [delay]
            time=250
        [/delay]

        {FINALE_B_ELYNIA_THOUGHTS ( _ "... Is this a dream?")}

        [delay]
            time=250
        [/delay]

        {FINALE_B_ARGAN_THOUGHTS ( _ "... Is it?")}

        [delay]
            time=250
        [/delay]

        {FINALE_B_ELYNIA_THOUGHTS ( _ "... I feel you. I feel your warm touch again. But... how?")}

        {FINALE_B_ARGAN_THOUGHTS ( _ "Because you wished for my return. All these years...")}

        {FINALE_B_ELYNIA_THOUGHTS ( _ "... I did.")}

        {FINALE_B_ARGAN_THOUGHTS ( _ "I missed you, Elynia.")}

        {FINALE_B_ELYNIA_THOUGHTS ( _ "... I— I—

... I did too.

Oh, Argan...")}

        [delay]
            time=5000
        [/delay]

        {FINALE_B_ARGAN_THOUGHTS ( _ "We don’t have much time left, my love. Irdya is in ruins now, and Zhangor could find us any moment now. You need to get up.")}

        {FINALE_B_ELYNIA_THOUGHTS ( _ "Yes...")}

        [fade_in_sound_effects]
            duration=1000
        [/fade_in_sound_effects]

        {FADE_IN}

        [unhide_unit][/unhide_unit]

        [unit]
            side=1
            type=Master of Darkness
            canrecruit=yes
            id=Argan
            name= _ "Argan"
            x,y=19,44
            facing=sw
            [modifications]
                {TRAIT_STRONG}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]

        {RESET_UNIT_STATUSES id=Elynia}

        [delay]
            time=1000
        [/delay]

        #
        # Hello, censors.
        #
        # Please don't mess with the plot or you will pay dearly.
        #
        # -- Iris
        #

        {FINALE_B_ELYNIA_THOUGHTS ( _ "I let my lips approach his own as we embraced like we had not for an eternity. He felt so delightfully real, I was willing to give in to our carnal urges.

But...")}

        [delay]
            time=1000
        [/delay]

        [message]
            speaker=Argan
            message= _ "Is there something wrong, my love?"
        [/message]

        [message]
            speaker=Elynia
            message= _ "I... feel... strange."
        [/message]

        [delay]
            time=1000
        [/delay]

        [message]
            speaker=Elynia
            message= _ "My heart... it hurts..."
        [/message]

        [message]
            speaker=Argan
            message= _ "That must be because you have spent too much time scurrying around. Just let yourself relax for a moment. We can reminisce about better times together..."
        [/message]

        [fade_out_music][/fade_out_music]

        [delay]
            time=1000
        [/delay]

        [message]
            speaker=Elynia
            # po: Yes, the question mark may seem misplaced, but it's actually intentional
            # po: as it denotes a different sentence inflection. She is supposed to sound
            # po: confused.
            message= _ "You don’t sound like yourself? My head... I—"
        [/message]

        [message]
            speaker=Elynia
            message= _ "My memories have become so hazy... but... I... remember that sword... Elyssa has your sword..."
        [/message]

        [message]
            speaker=Argan
            message= _ "Elynia, please, just..."
        [/message]

        [delay]
            time=1000
        [/delay]

        {VARIABLE elyssa_store.x      19}
        {VARIABLE elyssa_store.y      43}
        {VARIABLE elyssa_store.facing se}

        [message]
            speaker=narrator
            caption= _ "Elyssa"
            image=$elyssa_store.profile
            message= _ "Hello..."
        [/message]

        [unit]
            # We only want the recruit animation, screw stats.
            animate=yes
            side=1
            canrecruit=yes
            id=Elyssa
            type=$elyssa_store.type
            x,y=$elyssa_store.x,$elyssa_store.y
            facing=$elyssa_store.facing
        [/unit]

        [unstore_unit]
            # clobbered!
            variable=elyssa_store
            find_vacant=no
        [/unstore_unit]

        [redraw][/redraw]

        [delay]
            time=500
        [/delay]

        [animate_attack]
            [filter]
                id=Argan
            [/filter]
            [filter_second]
                id=Elyssa
            [/filter_second]
            [filter_attack]
                name=$elyssa_store.attack[0].name
            [/filter_attack]
            kill=no
            animate=yes
            fire_event=no
            amount=$elyssa_store.attack[0].damage
            damage_type=$elyssa_store.attack[0].type
            alignment=neutral
            #experience=no
        [/animate_attack]

        {CLEAR_VARIABLE elyssa_store}

        [delay]
            time=250
        [/delay]

        [message]
            speaker=Elyssa
            message= _ "... Zhangor."
        [/message]

        {REPLACE_SCENARIO_MUSIC "gathering_storm.ogg"}

        [delay]
            time=1000
        [/delay]

        [message]
            speaker=Argan
            message= _ "How..."
        [/message]

        [message]
            speaker=Elyssa
            # po: I guess I'm already pushing the censors' limits a lot here?
            # po: It'd be advisable to keep it subtle in translations too.
            message= _ "Your act seems pretty cheap in retrospect. I cannot say I am completely disappointed, though; it was absolutely amusing to watch you attempt to—ahem—handle the poor, broken elf. But did you truly think it would work out? Ha ha ha!"
        [/message]

        [message]
            speaker=Argan
            message= _ "(metallic voice) I am not precisely myself, though."
        [/message]

        [hide_unit][/hide_unit]

        {RED_SCREEN}

        [teleport]
            [filter]
                id=Elyssa
            [/filter]
            x,y=19,42
        [/teleport]

        [teleport]
            [filter]
                id=Elynia
            [/filter]
            x,y=19,46
        [/teleport]

        [kill]
            id=Argan
        [/kill]

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

        [delay]
            time=50
        [/delay]

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

        {RESET_SCREEN}

        [unhide_unit][/unhide_unit]

        [unit]
            canrecruit=yes
            side=2
            id=Deathbringer
            name= _ "Deathbringer"
            type=Shaxthal Deathbringer Alpha
            {IS_BOSS}
            x,y=19,44
            facing=sw
            [status]
                immune_to_demolition=yes
            [/status]
            [modifications]
                {TRAIT_BIOMECHANICAL}
                {TRAIT_DEXTROUS}
            [/modifications]
        [/unit]

        {PALETTE shaxthal_drone_surface shaxthal_drone_purple}

        [redraw]
            side=1
        [/redraw]

        [scroll_to_unit]
            id=Deathbringer
        [/scroll_to_unit]

        [delay]
            time=1000
        [/delay]

        [message]
            speaker=Deathbringer
            message= _ "But your guess was close enough. Congratulations, Guardian of Darkness."
        [/message]

        [message]
            speaker=Elyssa
            message= _ "So the rumors are true, after all — you go around possessing other creatures using your disgusting body ooze."
        [/message]

        [message]
            speaker=Elynia
            message= _ "(enraged) You were going to possess me..."
        [/message]

        [message]
            speaker=Deathbringer
            # po: "Aspect" here refers to the Aspect of Earth, not Elynia's physical appearance.
            message= _ "Or steal your aspect through your currently vulnerable energy heart. Either outcome would have been advantageous for me, but no — it would seem you will both have to die instead."
        [/message]

        [terrain]
            terrain=Xu
            x=23-24,25
            y=40   ,41
        [/terrain]

        [place_shroud]
            side=1
            x=23-27,25-27
            y=38-39,   40
        [/place_shroud]

        [redraw]
            side=1
        [/redraw]

        {QUAKE ("dragonstick.ogg")}

        [message]
            speaker=Elynia
            message= _ "(enraged) Not if I can kill you first."
        [/message]

#define FINALE_B_BOSS_DRONE _TYPE _X _Y
    [unit]
        side=2
        type={_TYPE}
        x={_X}
        y={_Y}
        random_gender=yes
        random_traits=yes
        generate_name=yes
        animate=yes
        passable=yes
    [/unit]

    {PALETTE shaxthal_drone_surface shaxthal_drone_purple}
#enddef

        {FINALE_B_BOSS_DRONE ("Shaxthal Assault Drone")   18 43}
        {FINALE_B_BOSS_DRONE ("Shaxthal Protector Drone") 19 43}
        {FINALE_B_BOSS_DRONE ("Shaxthal Assault Drone")   20 43}
        {FINALE_B_BOSS_DRONE ("Shaxthal Assault Drone")   20 44}
        {FINALE_B_BOSS_DRONE ("Shaxthal Protector Drone") 19 45}
        {FINALE_B_BOSS_DRONE ("Shaxthal Assault Drone")   18 44}

        {OBJECTIVES (
            victory_string= _ "Current Objective:"
            {OBJECTIVE_VICTORY ( _ "Defeat Zhangor’s Deathbringer")}

            {OBJECTIVE_DEFEAT  ( _ "Death of Elyssa")}
            {OBJECTIVE_DEFEAT  ( _ "Death of Elynia")}

            {OBJECTIVE_NO_CARRYOVER}

            {OBJECTIVE_NOTE ( _ "The Deathbringer’s spear allows it to destroy the Energy Heart of a Guardian")}

            {FIRE_GUARDIAN_SUMMONING_NOTE}
        )}

        [allow_end_turn][/allow_end_turn]

        {DISABLE_UNLIMITED_PLAYER_MOVES}

        {ENABLE_FIRE_GUARDIAN_SUMMONING}

        {UNLOCK_VIEW}
    [/event]

#define FINALE_B_CHECK_UNIT_LIMIT _VAR_ID
    [if]
        {VARIABLE_NUMERICAL_GREATER_THAN {_VAR_ID} 0}
        [then]
            {VARIABLE_DEC {_VAR_ID}}
        [/then]
        [else]
            {VARIABLE_RANDOM recruit_type "Shaxthal Assault Drone,Shaxthal Assault Drone,Shaxthal War Drone"}
        [/else]
    [/if]
#enddef

    [event]
        name=side 2 turn refresh
        first_time_only=no
        [filter_condition]
            [have_unit]
                id=Deathbringer
            [/have_unit]
        [/filter_condition]

        [store_locations]
            terrain=C*,C*^*
            variable=recruit_locs
        [/store_locations]

        [count_units]
            side=2
            [not]
                canrecruit=yes
            [/not]
            variable=zhangor_units
        [/count_units]

        [while]
            {VARIABLE_NUMERICAL_LESS_THAN zhangor_units {DIFF 6 7 8}}
            [do]
                {VARIABLE_INC zhangor_units}

                {VARIABLE        recruit_variation $null}
                {VARIABLE_RANDOM recruit_type      "Shaxthal Worm,Shaxthal Deathbringer,Shaxthal Assault Drone,Shaxthal Assault Drone,Shaxthal War Drone,Shaxthal Demolisher Drone"}
                {VARIABLE_RANDOM loc_n             "0..$($recruit_locs.length - 1)"}

                # Deathbringers and Demolishers are spawned in limited numbers
                # per scenario run (not turn). They are supposed to be in short
                # supply.

                [switch]
                    variable=recruit_type
                    [case]
                        value="Shaxthal Deathbringer"
                        {FINALE_B_CHECK_UNIT_LIMIT deathbringer_limit}
                    [/case]
                    [case]
                        value="Shaxthal Demolisher Drone"
                        {FINALE_B_CHECK_UNIT_LIMIT demolisher_limit}
                    [/case]
                [/switch]

                # The unit type may have been re-randomized above if we hit
                # one of the unit limits.

                [if]
                    {VARIABLE_LEXICAL_EQUALS recruit_type "Shaxthal Deathbringer"}
                    [then]
                        {VARIABLE_RANDOM recruit_variation base,cyclops,beast}
                    [/then]
                [/if]

                [if]
                    {VARIABLE_LEXICAL_EQUALS recruit_type "Shaxthal Worm"}
                    [then]
                        {VARIABLE_RANDOM recruit_variation a,b,c}
                    [/then]
                [/if]

                {FINALE_B_BOSS_DRONE $recruit_type $recruit_locs[$loc_n].x $recruit_locs[$loc_n].y}
                [+unit]
                    variation=$recruit_variation
                    # DON'T allow Zhangor to use potentially devastating units
                    # as soon as they are spawned.
                    moves=0
                    attacks_left=0
                [/unit]
            [/do]
        [/while]

        {CLEAR_VARIABLE zhangor_units,recruit_type,recruit_variation,recruit_locs,loc_n}
    [/event]

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

        [fire_event]
            name=start part 3
        [/fire_event]
    [/event]

    ############################################################################
    #                                                                          #
    #                                THIRD PART                                #
    #                                                                          #
    ############################################################################

#define FINALE_B_DREAMSCAPE_UNIQUE_SOUND_SOURCE _SOUND_LIST _X _Y
    {FINALE_B_DREAMSCAPE_REMOVE_UNIQUE_SOUND_SOURCE}

    [sound_source]
        id=__dreamscape_unique
        x={_X}
        y={_Y}
        sounds={_SOUND_LIST}
        # Play continuously, don't loop on a single sound.
        delay,loop,chance=0,0,100
        full_range,fade_range=10,6
        # Ignore everything
        check_fogged,check_shrouded=no,no
    [/sound_source]
#enddef

#define FINALE_B_DREAMSCAPE_REMOVE_UNIQUE_SOUND_SOURCE
    [remove_sound_source]
        id=__dreamscape_unique
    [/remove_sound_source]
#enddef

#define FINALE_B_DREAMSCAPE_MOVECOSTS _SUF
    [object]
        silent=yes
        [filter]
            {_SUF}
        [/filter]
        [effect]
            apply_to=movement_costs
            replace=yes
            [movement_costs]
                forest={UNREACHABLE}
                village={UNREACHABLE}
            [/movement_costs]
        [/effect]
    [/object]
#enddef

#define FINALE_B_DREAMSCAPE_TRIGGER_LOCATION _EVENT_FLAG _RADIUS
    terrain="*^&"+{_EVENT_FLAG}
    radius={_RADIUS}
#enddef

    #
    # Fire "dreamscape <FLAG>" event with Elynia as the primary unit and the
    # trigger area's center and radius stored in t.x, t.y, and t.radius. The
    # terrain flag is removed at the end. The viewport is also locked for the
    # duration of these events.
    #
#define FINALE_B_DREAMSCAPE_TRIGGER _EVENT_FLAG _RADIUS
    [event]
        name=moveto
        [filter]
            id=Elynia
            [filter_location]
                {FINALE_B_DREAMSCAPE_TRIGGER_LOCATION {_EVENT_FLAG} {_RADIUS} }
            [/filter_location]
        [/filter]
        [filter_condition]
            {FINALE_B_IN_PART_3}
        [/filter_condition]

        {LOG_ATS ("dreamscape EH "+{_EVENT_FLAG}+": enter")}

        {LOCK_VIEW}

        [store_locations]
            {FINALE_B_DREAMSCAPE_TRIGGER_LOCATION {_EVENT_FLAG} 0 }
            variable=t
        [/store_locations]

        {BUG_ON ({VARIABLE_NUMERICAL_NOT_EQUALS t.length 1}) ()}

        {VARIABLE t.radius {_RADIUS} }

        #[remove_shroud]
        #    side=1
        #    {FINALE_B_DREAMSCAPE_TRIGGER_LOCATION {_EVENT_FLAG} {_RADIUS} }
        #[/remove_shroud]

        #[redraw]
        #    clear_shroud=yes
        #[/redraw]

        {LOG_ATS ("dreamscape EH "+{_EVENT_FLAG}+": enter nested EH")}

        [fire_event]
            name="dreamscape trigger "+{_EVENT_FLAG}
            [primary_unit]
                id=Elynia
            [/primary_unit]
        [/fire_event]

        {LOG_ATS ("dreamscape EH "+{_EVENT_FLAG}+": leave nested EH")}

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

        [redraw][/redraw]

        {CLEAR_VARIABLE t}

        {UNLOCK_VIEW}

        {LOG_ATS ("dreamscape EH "+{_EVENT_FLAG}+": leave")}
    [/event]
#enddef

#define FINALE_B_DREAMWALK _SUF _X _Y
    [dreamwalk]
        {_SUF}
        to_x={_X}
        to_y={_Y}
    [/dreamwalk]

    [redraw]
        side=1
    [/redraw]
#enddef

    # wmllint: recognize Niryone
    # wmllint: recognize Galas
    # wmllint: recognize Anya
    # wmllint: recognize Elynia2

    # wmllint: local spelling Filinor Cerin Niry

    [event]
        name=start part 3

        {LOCK_VIEW}

        {CLEAR_LABELS}

        {DISABLE_FIRE_GUARDIAN_SUMMONING}

        {VARIABLE finale_b_part 3}

        [store_shroud]
            side=1
            variable=precutscene_shroud
        [/store_shroud]

        #
        # Keep copies of these two around, we'll need them for the
        # final cutscene.
        #

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

        [store_unit]
            [filter]
                id=Elyssa
            [/filter]
            kill=yes
            variable=elyssa_store
        [/store_unit]

        [set_variables]
            name=elynia_precutscene_store
            mode=replace
            to_variable=elynia_store
        [/set_variables]

        [set_variables]
            name=elyssa_precutscene_store
            mode=replace
            to_variable=elyssa_store
        [/set_variables]

        [kill]
            [not]
                x,y=recall,recall
            [/not]
        [/kill]

        [remove_item][/remove_item]

        {BLACK_SCREEN}

        {REMOVE_SOUND_SOURCE cave_noise}

        [terrain]
            terrain=Xv
        [/terrain]

        [place_shroud]
            side=1
        [/place_shroud]

        [redraw]
            side=1
        [/redraw]

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

        # We're disabling music for most of the sequence.
        [fade_out_music][/fade_out_music]

        [delay]
            time=3000
        [/delay]

        #
        # Swith to the last map.
        #

        # We'll replace this as the player proceeds further into lalaland,
        # and use time_areas to set local lighting.
        [replace_schedule]
            {UNDERGROUND}
        [/replace_schedule]

        [replace_map]
            map=$part_3_map
            expand,shrink=yes,yes
        [/replace_map]

        {PLACE_IMAGE units/shaxthal/master-of-darkness-dead.png 64 19}

        [redraw][/redraw]

        [set_variables]
            name=elynia_store
            mode=merge
            [value]
                x,y=37,34
                facing=se
                hitpoints=$elynia_store.max_hitpoints
                moves=$elynia_store.max_moves
                attacks_left=$elynia_store.max_attacks
            [/value]
        [/set_variables]

        [set_variables]
            name=elyssa_store
            mode=merge
            [value]
                hitpoints=$elyssa_store.max_hitpoints
                moves=$elyssa_store.max_moves
                attacks_left=$elyssa_store.max_attacks
            [/value]
        [/set_variables]

        {CLEAR_VARIABLE elynia_store.status,elyssa_store.status}

        #
        # Set up sound sources.
        #

        [mute_sound_effects][/mute_sound_effects]

        {FINALE_B_DREAMSCAPE_UNIQUE_SOUND_SOURCE {SOUND_LIST:BIRDS} 20 35}

        # Reinstate fog again.
        [modify_side]
            side=1
            fog=yes
        [/modify_side]

        # No more flags.
        [modify_side]
            flag_icon="misc/blank-hex.png"
        [/modify_side]

        # Will cause dream turn controller below to clobber previous autosaves
        # if the player somehow spent enough turns previously. We don't care.
        # Also, it'll become turn 1 forever if the player actually spends too
        # long playing this sequence.
        {VARIABLE dream_turn "$(max(1, max($turn_number, 1024)))"}

        [modify_turns]
            current="$dream_turn"
        [/modify_turns]

        # Make turn counter go backwards.
        [event]
            id=dream_turn_count_controller
            name=new turn
            first_time_only=no

            {VARIABLE_DEC dream_turn}

            [modify_turns]
                current="$dream_turn"
            [/modify_turns]
        [/event]

        [redraw]
            side=1
        [/redraw]

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

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

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

        [redraw]
            side=1
        [/redraw]

        {FADE_IN}

        # Don't clear this, we'll need her later.
        [unstore_unit]
            variable=elynia_store
        [/unstore_unit]

        {FINALE_B_DREAMSCAPE_MOVECOSTS id=Elynia}

        [fade_in_sound_effects][/fade_in_sound_effects]

        [message]
            speaker=Elynia
            message= _ "Is that..."
        [/message]

        {UNCLEAR_FOG}

        [redraw]
            side=1
        [/redraw]

        {OBJECTIVES (
            victory_string= _ "Current Objective:"
            {OBJECTIVE_VICTORY ({TSTR_NO_OBJECTIVES_AVAILABLE})}

            {OBJECTIVE_DEFEAT  ( _ "Death of Elynia")}
            {OBJECTIVE_DEFEAT  ( _ "Death of Elynia")}
            {OBJECTIVE_DEFEAT  ( _ "Death of Elynia")}
            {OBJECTIVE_DEFEAT  ( _ "Death of Elynia")}

            # This is intentional.
            {OBJECTIVE_CARRYOVER}
        )}

        {UNLOCK_VIEW}

        [event]
            name=moveto
            first_time_only=no

            # Use a dummy synced action to forcefully disallow undo for the
            # remainder of the scenario.

            {RANDOM dummy}

            {CLEAR_VARIABLE random}
        [/event]
    [/event]

#define FINALE_B_DREAMSCAPE_TRANSFORM _ID _VARIATION
    [store_unit]
        [filter]
            id={_ID}
        [/filter]
        variable=ds_transform_store
        kill=yes
    [/store_unit]

    [unit]
        side=$ds_transform_store.side
        id=$ds_transform_store.id
        type=Dream Controller
        variation={_VARIATION}
        name=$ds_transform_store.name
        canrecruit=$ds_transform_store.canrecruit
        upkeep=$ds_transform_store.upkeep

        moves=$ds_transform_store.moves
        max_moves=$ds_transform_store.max_moves
        attacks_left=$ds_transform_store.attacks_left
        max_attacks=$ds_transform_store.max_attacks

        x=$ds_transform_store.x
        y=$ds_transform_store.y
        facing=$ds_transform_store.facing

        [modifications]
            {FINALE_B_DREAMSCAPE_MOVECOSTS ()}
            [insert_tag]
                name=trait
                variable=$ds_transform_store.modifications.trait
            [/insert_tag]
        [/modifications]
    [/unit]

    {CLEAR_VARIABLE ds_transform_store}
#enddef

#define FINALE_B_DREAMSCAPE_CREATE_WARPED _SIDE _X _Y _FACING _ID _NAME _VARIATION
    [unit]
        type=Dream Controller
        variation={_VARIATION}
        id={_ID}
        name={_NAME}
        side={_SIDE}
        x={_X}
        y={_Y}
        facing={_FACING}
    [/unit]
#enddef

#define FINALE_B_ANIMATE_SPAWN
    [+unit]
        animate=yes
    [/unit]
#enddef

#define FINALE_B_FLOAT _ID _TEXT
    [floating_text]
        [filter]
            id={_ID}
        [/filter]
        text={_TEXT}
    [/floating_text]
#enddef

#define FINALE_B_NO_TOD_TRANSITION
    [+time]
        sound=""
    [/time]
#enddef

    {FINALE_B_DREAMSCAPE_TRIGGER A 6}

    [event]
        name=dreamscape trigger A

        [replace_schedule]
            {MORNING} {FINALE_B_NO_TOD_TRANSITION}
        [/replace_schedule]

        {FINALE_B_DREAMWALK id=Elynia "$($t.x + 2)" "$t.y"}

        [delay]
            time=1000
        [/delay]

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

        {FINALE_B_DREAMWALK id=Elynia $t.x $t.y}

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Elynia
            message= _ "Hello?"
        [/message]

        # FIXME: hardcoded location set!
        [remove_terrain_overlays]
            x=25,26
            y=51,50
        [/remove_terrain_overlays]

        {FINALE_B_DREAMSCAPE_CREATE_WARPED 8 22 43 sw Niryone ( _"Niryone") niryone} {FINALE_B_ANIMATE_SPAWN}

        [message]
            speaker=Niryone
            message= _ "Back from Filinor’s class early?"
        [/message]

        {FINALE_B_FLOAT id=Elynia "!"}

        [delay]
            time=750
        [/delay]

        {FINALE_B_DREAMSCAPE_TRANSFORM Elynia elynia1}

        {FACE_UNIT id=Elynia id=Niryone}

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Elynia
            message= _ "He twisted his ankle yesterday morning while hunting with Cerin, so he let us go after a short round of questions."
        [/message]

        [message]
            speaker=Niryone
            message= _ "Bah. Figures. At least that means we can enjoy a nice midday meal together for a change."
        [/message]

        [color_adjust]
            red,green,blue=64,64,64
        [/color_adjust]

        {RESET_SCREEN}

        [message]
            speaker=Elynia
            message= _ "Sure, that would be great! I’m starving."
        [/message]

        [teleport]
            [filter]
                id=Niryone
            [/filter]
            x,y=18,43
            check_passability=no
        [/teleport]

        [message]
            speaker=Niryone
            message= _ "Don’t come with me. It’s too dangerous."
        [/message]

        [replace_schedule]
            {SECOND_WATCH} {FINALE_B_NO_TOD_TRANSITION}
        [/replace_schedule]

        [message]
            speaker=Elynia
            message= _ "Huh?"
        [/message]

        {FACE_UNIT id=Elynia id=Niryone}

        [kill]
            id=Niryone
        [/kill]

        {GENERIC_UNIT 2 (Elvish Fighter) 35 58} {GUARDIAN} {NO_UPKEEP_NO_OVERLAY}
        [+unit]
            [variables]
                zhangor_follower=yes
            [/variables]
        [/unit]
        {GENERIC_UNIT 2 (Elvish Fighter) 38 53} {GUARDIAN} {NO_UPKEEP_NO_OVERLAY}
        [+unit]
            [variables]
                zhangor_follower=yes
            [/variables]
        [/unit]
        {GENERIC_UNIT 2 (Elvish Fighter) 40 56} {GUARDIAN} {NO_UPKEEP_NO_OVERLAY}
        [+unit]
            [variables]
                zhangor_follower=yes
            [/variables]
        [/unit]

        [event]
            name=turn refresh

            # wmllint: display on
            [transient_message]
                image=attacks/blank-attack.png
                message= _ "As a low-level unit under your control, Elynia has no special After Maximum Level Advancements (AMLAs). You can learn more about those by 4 Ł vª§Ð t¬ þ ä
ŋ ½5 °5 é’   ⅞ Ý  T*  4    $$º ©      ŕ     `¬     _ē → fv     ’     ±        ¡"
            [/transient_message]
            # wmllint: display off
        [/event]

        [event]
            name=moveto
            [filter]
                id=Elynia
                x=1-100
                y=49-100
            [/filter]

            [terrain]
                [and]
                    terrain=W*,W*^*
                [/and]
                terrain=Wwb
            [/terrain]

            [terrain]
                [and]
                    terrain=*^Efm
                [/and]
                terrain=Gd^Edb
            [/terrain]

            [terrain]
                [and]
                    terrain=*^Ve
                [/and]
                terrain=Gd^Dr
            [/terrain]

            [terrain]
                [and]
                    terrain=*^Fet
                [/and]
                terrain=Gd^Fetd
            [/terrain]

            [redraw][/redraw]

            [message]
                speaker=Elynia
                message= _ "Niry? Where did you go?"
            [/message]

            [message]
                speaker=narrator
                caption= _ "Argan"
                image= # wmllint: ignore
                # po: IftU S23B callback.
                message= _ "You are... hurting me..."
            [/message]

            {OBJECTIVES (
                victory_string= _ "Final Objective:"
                {OBJECTIVE_VICTORY ( _ "Death of Elynia")}

                {OBJECTIVE_DEFEAT  ( _ "Death of Elynia")}

                {OBJECTIVE_NO_CARRYOVER}

                {OBJECTIVE_NOTE ( _ "Elynia")}
            )}

            [event]
                name=side 1 turn end

                [replace_schedule]
                    {DUSK} {FINALE_B_NO_TOD_TRANSITION}
                [/replace_schedule]

                {FINALE_B_DREAMSCAPE_TRANSFORM Elynia elynia2}

                [message]
                    speaker=narrator
                    caption= _ "Anlindë"
                    image= # wmllint: ignore
                    message= _ "Don’t you realize that he will murder them all if you continue this pointless crusade of yours? Just leave them be, please!"
                [/message]

                [message]
                    speaker=narrator
                    caption= _ "Elynia"
                    image= # wmllint: ignore
                    message= _ "Don’t you dare speak in that tone to me, foul priestess! You should be grateful we do not cut your tongue off for your insolence. Guards! Escort her out, now!"
                [/message]
            [/event]
        [/event]

        [event]
            name=attack
            [filter]
                id=Elynia
            [/filter]
            [filter_second]
                [filter_wml]
                    [variables]
                        zhangor_follower=yes
                    [/variables]
                [/filter_wml]
            [/filter_second]

            [fire_event]
                name=zhangor follower fight
                [primary_unit]
                    x,y=$x2,$y2
                [/primary_unit]
            [/fire_event]
        [/event]

        [event]
            name=attack
            [filter_second]
                id=Elynia
            [/filter_second]
            [filter]
                [filter_wml]
                    [variables]
                        zhangor_follower=yes
                    [/variables]
                [/filter_wml]
            [/filter]

            [fire_event]
                name=zhangor follower fight
                [primary_unit]
                    x,y=$x1,$y1
                [/primary_unit]
            [/fire_event]
        [/event]

        [event]
            name=zhangor follower fight

            [message]
                speaker=unit
                sound=laugh.ogg
                message= _ "The Lady of Light and the Master of Darkness must die!"
            [/message]

            [message]
                speaker=Elynia
                message= _ "Stop! Why are you doing this?!"
            [/message]

            [kill]
                [filter_wml]
                    [variables]
                        zhangor_follower=yes
                    [/variables]
                [/filter_wml]
            [/kill]

            [message]
                speaker=narrator
                caption= _ "Argan"
                image= # wmllint: ignore
                # po: "Them" = the elvish peoples
                message= _ "I do not suppose I can convince you to abandon them now, after so long. Am I right?"
            [/message]

            [message]
                speaker=narrator
                caption= _ "Elynia"
                image= # wmllint: ignore
                message= _ "Of course not."
            [/message]

            [event]
                name=side turn end

                [message]
                    speaker=narrator
                    caption= _ "Argan"
                    image= # wmllint: ignore
                    message= _ "Then... we shall do this. Together."
                [/message]

                [delay]
                    time=750
                [/delay]

                [message]
                    speaker=narrator
                    caption= _ "Elynia"
                    image= # wmllint: ignore
                    message= _ "... Together."
                [/message]
            [/event]
        [/event]
    [/event]

    {FINALE_B_DREAMSCAPE_TRIGGER B 6}

    [event]
        name=dreamscape trigger B

        {FINALE_B_DREAMSCAPE_REMOVE_UNIQUE_SOUND_SOURCE}

        [replace_schedule]
            {LONGDARK1} {FINALE_B_NO_TOD_TRANSITION}
        [/replace_schedule]

        {FINALE_B_DREAMWALK id=Elynia "$($t.x + 2)" "$t.y"}

        {FACE_DIRECTION id=Elynia se}

        {FAKE_RECRUIT 2 (Skeleton) 36 63} {FACING se}

        {FAKE_RECRUIT 2 (Skeleton) 38 62} {FACING se}

        {FACE_DIRECTION id=Elynia nw}

        {FAKE_RECRUIT 2 (Chaos Invoker) 40 62} {FACING sw}

        {FAKE_RECRUIT 2 (Demon Grunt)   42 62} {FACING sw} {GENDER male}

        [unit]
            side=8
            {CHARACTER_STATS_GALAS}
            canrecruit=yes
            animate=yes
            facing=sw
            x,y=42,62
        [/unit]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Galas
            message= _ "Do you think our people will ever find peace again, Elynia?"
        [/message]

        [delay]
            time=750
        [/delay]

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

        {FINALE_B_DREAMSCAPE_TRANSFORM Elynia elynia3}

        {FINALE_B_DREAMSCAPE_TRANSFORM Galas galas}

        {FACE_DIRECTION id=Galas se}

        [delay]
            time=500
        [/delay]

        [message]
            speaker=Galas
            message= _ "It doesn’t matter now, I guess."
        [/message]

        [delay]
            time=250
        [/delay]

        [kill]
            id=Galas
        [/kill]

        [unit]
            side=2
            type=Dream Controller
            variation=argan1
            id=Argan
            name= _ "Argan"
            canrecruit=yes
            facing=se
            x,y=42,62
            #placement=map_overwrite   Doesn't work
            [modifications]
                {TRAIT_BIOMECHANICAL}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]

        [message]
            speaker=Argan
            message= _ "Because I am dead."
        [/message]

        [kill]
            id=Argan
            [or]
                side=2
            [/or]
        [/kill]

        [delay]
            time=250
        [/delay]

        [scroll_to_unit]
            id=Elynia
        [/scroll_to_unit]

        {OBJECTIVES (
            victory_string= _ "Previous Objective:"
            {OBJECTIVE_VICTORY ( _ "Kill Argan, the Master of Darkness, and put an end to his sinister rule over Irdya")}

            {OBJECTIVE_DEFEAT  ( _ "Kill Argan, the Master of Darkness, and put an end to his sinister rule over Irdya")}

            {OBJECTIVE_NO_CARRYOVER}

            {OBJECTIVE_NOTE ("     da       ä  ¬Ŋ     Þ"+"
"+_"Elynia")}
        )}

        [show_objectives][/show_objectives]

        [delay]
            time=500
        [/delay]

        [message]
            speaker=Elynia
            message= _ "What is this place... Something feels amiss."
        [/message]

        {FACE_DIRECTION id=Elynia nw}

        [delay]
            time=250
        [/delay]

        {FACE_DIRECTION id=Elynia ne}

        [delay]
            time=250
        [/delay]

        {FINALE_B_DREAMWALK id=Elynia 46 62}

        [remove_terrain_overlays]
            x=50   ,49
            y=64-65,66
        [/remove_terrain_overlays]

        {FINALE_B_DREAMWALK id=Elynia 47 65}

        [redraw]
            side=1
        [/redraw]

        [move_unit_fake]
            side=8
            type=Nightshade Fire
            x=55,51
            y=66,66
        [/move_unit_fake]

        [unit]
            side=8
            {CHARACTER_STATS_ANYA}
            type=Nightshade Fire
            x,y=51,66
            facing=nw
        [/unit]

        [message]
            speaker=Anya
            message= _ "Elynia! Oh, I’m so glad I could finally find you... Come with me, this way! Quickly!"
        [/message]

        [kill]
            id=Anya
        [/kill]

        [move_unit_fake]
            side=8
            type=Nightshade Fire
            x=51,55
            y=66,66
        [/move_unit_fake]

        [event]
            name=new turn

            {OBJECTIVES (
                silent=yes
                victory_string= _ "Current Objective:"
                {OBJECTIVE_DEFEAT ( _ "Elynia")}
            )}
        [/event]
    [/event]

    {FINALE_B_DREAMSCAPE_TRIGGER C 6}

    [event]
        name=dreamscape trigger C

        {FINALE_B_DREAMWALK id=Elynia "$($t.x + 2)" "$t.y"}

        [scroll_to_unit]
            id=Elynia
        [/scroll_to_unit]

        {FINALE_B_DREAMSCAPE_CREATE_WARPED 8 59 64 ne Anya ( _ "Anya") anya} {FINALE_B_ANIMATE_SPAWN}

        [message]
            speaker=Anya
            message= _ "My hair gets so messy with all the wind in this desert. It’s almost tempting to shave it... Do you think I would look too weird if I did that?"
        [/message]

        {FACE_UNIT id=Elynia id=Anya}

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Elynia
            message= _ "Did we... Didn’t we have this conversation already?"
        [/message]

        [message]
            speaker=Anya
            message= _ "I’m just concerned that you might not like it if I do that... Your hair is always so fluffy and nice and beautiful..."
        [/message]

        [message]
            speaker=Elynia
            message= _ "... All right, that is not something I recall you saying..."
        [/message]

        [teleport]
            [filter]
                id=Anya
            [/filter]
            x,y=62,61
            check_passability=no
        [/teleport]

        {FACE_UNIT id=Anya id=Elynia}

        [message]
            speaker=Anya
            message= _ "You promised..."
        [/message]

        [kill]
            id=Anya
        [/kill]

        {FINALE_B_DREAMSCAPE_CREATE_WARPED 8 59 64 ne Argan ( _ "Argan") argan2} # {FINALE_B_ANIMATE_SPAWN}

        [message]
            speaker=Argan
            message= _ "You promised..."
        [/message]

        [kill]
            id=Argan
        [/kill]

        #
        # Set up hive sound source at Elyssa's future location.
        #

        [mute_sound_effects][/mute_sound_effects]

        [store_locations]
            terrain=*^&F
            variable=ss_location
        [/store_locations]

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

        [lua]
            code=<<
                local ely = wesnoth.units.find_on_map({ id = "Elynia" })[1]
                local ss_x, ss_y = wml.variables["ss_location.x"], wml.variables["ss_location.y"]
                wml.variables["r"] = wesnoth.map.distance_between({ss_x, ss_y}, {ely.x, ely.y})
            >>
        [/lua]

        {HIVE_NOISE_2_SOUND_SOURCE}
        [+sound_source]
            id=lair_sound_source # wmllint: ignore
            x,y=$ss_location.x,$ss_location.y
            fade_range=$($r * 0.75)
            full_range=$($r * 0.25)
        [/sound_source]

        {CLEAR_VARIABLE ss_location,r}

        # Cutscene delay
        [fade_in_sound_effects][/fade_in_sound_effects]

        {VARIABLE elynia_store.facing ne}
        [unstore_unit]
            variable=elynia_store
            x,y="$($t.x + 2)","$t.y"
            find_vacant=no
        [/unstore_unit]

        {FINALE_B_DREAMSCAPE_MOVECOSTS id=Elynia}

        [message]
            speaker=Elynia
            message= _ "I must find Elyssa. She must be here, somewhere..."
        [/message]

        [show_objectives][/show_objectives]
    [/event]

    {FINALE_B_DREAMSCAPE_TRIGGER D 6}

    {SNOW_ON_TOD inferno_night}

    [event]
        name=dreamscape trigger D

        # We do this ahead of time because parts of the time area for Inferno
        # overlap a region that's going to be unshrouded and onscreen while
        # trigger E fires.

        [time_area]
            id=inferno
            {INFERNO_NIGHT}
            x=55-83
            y=31-44
        [/time_area]

        # This is made redundant later by a global ToD schedule replacement.

        [time_area]
            id=lair
            {DEEP_UNDERGROUND} {SCHEDULE_LIGHTING -40 -50 -15}
            x=0-9999
            y=0-30
        [/time_area]

        [remove_terrain_overlays]
            x=64-66,67,68,69
            y=   49,50,49,50
        [/remove_terrain_overlays]

        [redraw]
            side=1
        [/redraw]

        [message]
            speaker=narrator
            image= # wmllint: ignore
            # po: Elyssa speaking here.
            message= _ "Did you know that this entire land used to be a huge empire?"
        [/message]
    [/event]

    {FINALE_B_DREAMSCAPE_TRIGGER E 6}

    [event]
        name=dreamscape trigger E

        [message]
            speaker=narrator
            image= # wmllint: ignore
            # po: Elyssa speaking to Argan here.
            message= _ "You’re asking too much from me. To confront a goddess who has accrued enough power to wipe out an entire world..."
        [/message]

        [delay]
            time=1000
        [/delay]

        [message]
            speaker=narrator
            image= # wmllint: ignore
            # po: Elyssa speaking to Argan here.
            message= _ "... I understand. "
        [/message]
    [/event]

    {FINALE_B_DREAMSCAPE_TRIGGER F 8}

#define FINALE_B_FLASH_RED
    {RED_SCREEN}

    [delay]
        time=100
    [/delay]

    {RESET_SCREEN}
#enddef

    [event]
        name=dreamscape trigger F

        #
        # Final cutscene. Lots of hardcoded locations.
        #

        [replace_schedule]
            {DEEP_UNDERGROUND} {SCHEDULE_LIGHTING -40 -50 -15}
        [/replace_schedule]

        [remove_time_area]
            id=lair
        [/remove_time_area]

        [fade_out_sound_effects][/fade_out_sound_effects]

        {REMOVE_SOUND_SOURCE lair_sound_source}

        [reset_sound_effects][/reset_sound_effects]

        [message]
            speaker=narrator
            image= # wmllint: ignore
            caption= _ "Argan"
            # po: Callback to IftU S23Bx.
            message= _ "... you betrayed... me..."
        [/message]

        [remove_shroud]
            side=1
            x,y,radius=$t.x,$t.y,$t.radius
        [/remove_shroud]

        {FINALE_B_DREAMWALK id=Elynia 65 28}

        [delay]
            time=250
        [/delay]

        [set_variables]
            name=elyssa_store
            mode=merge
            [value]
                facing=ne
                x,y=$t.x,$t.y
            [/value]
        [/set_variables]

        {FINALE_B_DREAMWALK id=Elynia $elyssa_store.x $elyssa_store.y}

        {FACE_DIRECTION id=Elynia $elyssa_store.facing}

        [delay]
            time=500
        [/delay]

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

        [modify_unit]
            [filter]
                id=Elynia
            [/filter]
            id=Elynia2
        [/modify_unit]

        {FINALE_B_DREAMSCAPE_CREATE_WARPED 1 66 18 sw Elynia _"Elynia" elynia3}

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Elynia
            # po: Callback to IftU S23Bx.
            message= _ "Argan! No, no, this can’t be happening, you can’t be doing this, I am trying to heal you, don’t you see? I..."
        [/message]

        [delay]
            time=1000
        [/delay]

        {FINALE_B_FLASH_RED}

        [remove_time_area]
            id=inferno
        [/remove_time_area]

        [delay]
            time=2000
        [/delay]

        [message]
            speaker=Elynia
            message= _ "Why don’t you say anything? Argan!"
        [/message]

        [message]
            speaker=Elynia2
            message= _ "Argan— No..."
        [/message]

        [redraw][/redraw]

        {FINALE_B_FLASH_RED}

        [mute_sound_effects][/mute_sound_effects]

        {HIVE_NOISE_3_SOUND_SOURCE}
        [+sound_source]
            id=horror_noise # wmllint: ignore
        [/sound_source]

        [fade_in_sound_effects][/fade_in_sound_effects]

        [message]
            speaker=Elynia
            message= _ "Elyssa?"
        [/message]

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

        [message]
            speaker=Elyssa
            message= _ "YOU KILLED HIM!"
        [/message]

        {MOVE_UNIT id=Elyssa 64 20}
        {FACE_DIRECTION id=Elyssa nw}
        [redraw][/redraw]

        [message]
            speaker=Elynia
            message= _ "Elyssa, I..."
        [/message]

        {FINALE_B_DREAMSCAPE_TRANSFORM Elyssa elyssa1}

        [message]
            speaker=Elyssa
            message= _ "Why— Why do you have to show me this again? WHY?"
        [/message]

        [set_variables]
            name=elyssa_store
            mode=merge
            [value]
                facing=ne
            [/value]
        [/set_variables]

        [unstore_unit]
            variable=elyssa_store
            find_vacant=no
            x,y=64,20
        [/unstore_unit]

        {MOVE_UNIT id=Elyssa 65 20}

        [set_variables]
            name=elynia_store
            mode=merge
            [value]
                facing=sw
            [/value]
        [/set_variables]

        [unstore_unit]
            variable=elynia_store
            find_vacant=no
            x,y=66,18
        [/unstore_unit]

        {MOVE_UNIT id=Elyssa 65 19}

#define FINALE_B_ELYSSA_STRIKES_ELYNIA
    [animate_attack]
        [filter]
            id=Elynia
        [/filter]
        [filter_second]
            id=Elyssa
        [/filter_second]
        [filter_attack]
            name=$elyssa_store.attack[0].name
        [/filter_attack]
        kill=no
        animate=yes
        fire_event=no
        amount=$elyssa_store.attack[0].damage
        damage_type=$elyssa_store.attack[0].type
        alignment=neutral
        #experience=no
    [/animate_attack]

    [delay]
        time=250
    [/delay]
#enddef

        [message]
            speaker=Elyssa
            message= _ "Why couldn’t you save him instead?!"
        [/message]

        {FINALE_B_ELYSSA_STRIKES_ELYNIA}

        {FINALE_B_DREAMSCAPE_TRANSFORM Elyssa elyssa2}

        #
        # Dreamscape breakdown, it all becomes a black void.
        #

        [replace_schedule]
            {UNDERGROUND}
        [/replace_schedule]

        # Bye Argan.
        [remove_item][/remove_item]

        {BLACK_SCREEN}

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

        [terrain]
            # EVERYWHERE
            terrain=Xv^Gov
        [/terrain]

        [redraw]
            side=1
        [/redraw]

        [message]
            speaker=Elyssa
            sound=laugh.ogg
            message= _ "WHY?!"
        [/message]

        {FINALE_B_ELYSSA_STRIKES_ELYNIA}

        {FINALE_B_ELYSSA_STRIKES_ELYNIA}

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

        [kill]
            id=Elynia
            animate=yes
            fire_event=no
        [/kill]

        [unstore_unit]
            variable=elynia_store
        [/unstore_unit]

        {APPLY_INJURED_VARIATION id=Elynia ne}

        {MODIFY_UNIT id=Elynia profile misc/blank-hex.png}

        [message]
            speaker=Elyssa
            message= _ "(metallic voice) You are a disgrace to your sad excuse of a civilization!"
        [/message]

        [message]
            speaker=Elynia
            message= _ "Stop it... please... Zhangor is attempting to control you..."
        [/message]

        {FINALE_B_ELYSSA_STRIKES_ELYNIA}

        {FINALE_B_DREAMSCAPE_TRANSFORM Elyssa elyssa3}

        [message]
            speaker=Elyssa
            message= _ "(metallic voice) Nobody can control me!"
        [/message]

        {FINALE_B_ELYSSA_STRIKES_ELYNIA}

        {FINALE_B_DREAMSCAPE_TRANSFORM Elynia elynia4}

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

        {FINALE_B_ELYSSA_STRIKES_ELYNIA}

        [message]
            speaker=Elynia
            message= _ "... I know you—"
        [/message]

        {FINALE_B_ELYSSA_STRIKES_ELYNIA}

        {FINALE_B_DREAMSCAPE_TRANSFORM Elynia elynia5}

        [message]
            speaker=Elynia
            message= _ "... I know you loved Argan too."
        [/message]

        [delay]
            time=2000
        [/delay]

        #
        # NOTE: At this point Elynia and Elyssa's lines get mixed up. This is
        #       on purpose.
        #

        [message]
            speaker=Elynia
            message= _ "(metallic voice) ... He wanted you to find me... and guide me... didn’t he..."
        [/message]

        [delay]
            time=1000
        [/delay]

        [message]
            speaker=Elyssa
            message= _ "... You... you are not me. Why am I crying?"
        [/message]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Elyssa
            message= _ "... Are these... my own tears?"
        [/message]

        [message]
            speaker=Elynia
            message= _ "(metallic voice) ... Try to remember... that you..."
        [/message]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Elyssa
            message= _ "... that I was once..."
        [/message]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Elyssa
            message= _ "(metallic voice) ... human—"
        [/message]

        {FINALE_B_FLASH_RED}

        [message]
            speaker=Elyssa
            message= _ "No... no..."
        [/message]

        [message]
            speaker=Elynia
            message= _ "(metallic voice) Uria demanded I kill them! It was... it was never my intention... please!"
        [/message]

        {FINALE_B_FLASH_RED}

        [delay]
            time=250
        [/delay]

        {FINALE_B_FLASH_RED}

        [message]
            speaker=Elyssa
            message= _ "Zhangor is trying to make us lose control..."
        [/message]

        [message]
            speaker=Elynia
            # po: This is part of one of Elyssa's lines from IftU scenario 22B.
            message= _ "(metallic voice) Now that I have failed, there’s no purpose left for me..."
        [/message]

        {FINALE_B_FLASH_RED}

        [message]
            speaker=Elyssa
            message= _ "... He is trying to take us both at once... using the powers of the Gatekeeper..."
        [/message]

        [message]
            speaker=Elynia
            message= _ "(metallic voice) Why... why did you bring me back to life... WHY?!"
        [/message]

        [message]
            speaker=narrator
            caption= _ "Ethealim"
            image=misc/blank-hex.png
            # po: Callback to AtS E3S8A "Interim".
            message= _ "... you have allowed others to distort your identity..."
        [/message]

        [message]
            speaker=narrator
            caption= _ "Mal Keshar"
            image=misc/blank-hex.png
            # po: Callback to AtS E1S12 "The Queen".
            message= _ "... a greater cause, one that transcends the fate of Irdya..."
        [/message]

        [message]
            speaker=narrator
            caption= _ "Niryone"
            image=misc/blank-hex.png
            message= _ "... take the Sceptre of Fire... and wield it... against our enemies..."
        [/message]

        {FINALE_B_FLASH_RED}

        [message]
            speaker=Elyssa
            message= _ "... He is using the powers of the Gatekeeper of Urvatha to tear into our minds... I should have known that he would try to do this..."
        [/message]

        {FINALE_B_FLASH_RED}

        [delay]
            time=250
        [/delay]

        {FINALE_B_FLASH_RED}

        [message]
            speaker=Elyssa
            message= _ "(metallic voice) Elynia, grab my hand!"
        [/message]

        {FINALE_B_FLASH_RED}

        [kill]
            id=Elynia
            [or]
                id=Elyssa
            [/or]
        [/kill]

        {FADE_TO_BLACK}

        [fade_out_sound_effects]
            duration=4000
        [/fade_out_sound_effects]

        [delay]
            time=1000
        [/delay]

        {REMOVE_SOUND_SOURCE horror_noise}

        [reset_sound_effects][/reset_sound_effects]

        {INCIDENTAL_MUSIC "heroes_rite.ogg"}

        {FINALE_B_ELYNIA_THOUGHTS ( _ "For a moment, I could not tell our memories and emotions apart. For a moment, I saw the fear in the demoness’ subconscious; I saw her fear of Uria; her fear of the many creatures she had tortured and slain, both under Uria’s command and of her own volition.

I felt her suffering at the hands of Argan’s men before he rescued her from their cruelty. I saw her wandering the sands before her capture. I saw through the invisible mask she had worn all this time to protect her fragile self from the corruption rooted deep within the energy hearts of our kind.

I saw that, despite her claims to the contrary, she was human. And despite living for longer than any elf on Irdya, she was still just a girl, forced by Argan and Uria to live a life she did not want. A life she could not end on her own, for fear of ceasing to exist forever.")}

        {FINALE_B_ELYNIA_THOUGHTS ( _ "I saw one of her nightmares, one in which she is alone wandering an endless void with nothing in sight but a tree above; a broken tree, in flames.

But it was a tree unlike any other I have never seen...")}

        [delay]
            time=2000
        [/delay]

        [message]
            speaker=narrator
            image=misc/blank-hex.png
            # po: Callback to AtS E1S9.3 "The Triad, part 3".
            message= _ "Don’t you see? We aren’t that different after all."
        [/message]

        # A single warp should suffice as long as part 3's map is larger than
        # part 2's.
        [scroll_to]
            x,y=$elynia_precutscene_store.x,$elynia_precutscene_store.y
            {WARP}
        [/scroll_to]

        [replace_map]
            map=$part_2_map
            expand,shrink=yes,yes
        [/replace_map]

        [modify_side]
            side=1
            shroud=yes
            shroud_data=$precutscene_shroud
        [/modify_side]

        [redraw][/redraw]

        [delay]
            time=2000
        [/delay]

        {FADE_IN}

        # Remove demolition immunity status flag from both

        {CLEAR_VARIABLE elynia_precutscene_store.status.immune_to_demolition}
        {CLEAR_VARIABLE elyssa_precutscene_store.status.immune_to_demolition}

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

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

        [delay]
            time=1000
        [/delay]

        [message]
            speaker=Elynia
            # po: Callback to AtS E3S8C "Breakdown".
            message= _ "Why... did you not kill me?"
        [/message]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Elyssa
            message= _ "Because..."
        [/message]

        [delay]
            time=1000
        [/delay]

        [message]
            speaker=Elyssa
            message= _ "Argan asked me to help you."
        [/message]

        [delay]
            time=2000
        [/delay]

        {FINALE_B_ELYNIA_THOUGHTS ( _ "I could restrain myself no longer. With tears in my eyes I laughed maniacally like I never had before.")}

        {FINALE_B_ELYNIA_THOUGHTS ( _ "Was that my own emotion, or Elyssa’s? Did it actually matter?")}

        {FINALE_B_ELYNIA_THOUGHTS ( _ "There was only one thing I knew for sure.

Galas, Anlindë, and Mal Keshar woke me to save Irdya from Uria’s corrupting influence. Their lives were cut short not by Elyssa, but by the broken creature into which Uria turned her.")}

        {FINALE_B_ELYNIA_THOUGHTS ( _ "I gave Ergea a chance because that is what my friends would have done, and she led me to Elyssa.

If fate dictates we join forces in spite of our mutual hatred, then so be it.")}

        {FINALE_B_ELYNIA_THOUGHTS ( _ "No-one on Irdya will ever see peace again for as long as Zhangor and Uria exist.

No matter the consequences... no matter who is at my side, I will confront those two.

Uria has to be stopped.")}

        [delay]
            time=250
        [/delay]

        {UNLOCK_VIEW}

        {ENDLEVEL_QUIET}
    [/event]

    [event]
        name=victory

        {CLEAR_VARIABLE finale_b_part,used_touchplate_1,used_touchplate_2,part_2_map,part_3_map,elynia_store,elyssa_store,elynia_precutscene_store,elyssa_precutscene_store,precutscene_shroud,dream_turn,deathbringer_limit,demolisher_limit}
    [/event]

    [event]
        name=time over
        [message]
            speaker=Elyssa
            message= _ "... I give up. You are beyond useless."
        [/message]
    [/event]
[/scenario]

#undef FINALE_B_SHARED_AI_PARAMS
#undef FINALE_B_DRONE_TINT_1
#undef FINALE_B_DRONE_TINT_2
#undef FINALE_B_CRYSTAL_SHARD
#undef FINALE_B_TOUCHPLATE
#undef FINALE_B_LAVA_SHORE_X_Y
#undef FINALE_B_TRY_RELOCATE_HERO
#undef FINALE_B_ENGIE_BOSS_BOOST
#undef FINALE_B_ENGIE_FACING_ATTACK_HANDLER
#undef FINALE_B_ENGIE_FACING_MOVETO_HANDLER
#undef FINALE_B_ELYNIA_THOUGHTS
#undef FINALE_B_IN_PART_1
#undef FINALE_B_IN_PART_2
#undef FINALE_B_IN_PART_3
#undef FINALE_B_BOSS_DRONE
#undef FINALE_B_CHECK_UNIT_LIMIT
#undef FINALE_B_FLASH_RED
#undef FINALE_B_ELYSSA_STRIKES_ELYNIA
#undef FINALE_B_IS_HERO
#undef FINALE_B_CHAMBER_WALL_X_Y
#undef FINALE_B_ARGAN_THOUGHTS
#undef FINALE_B_FLOAT
#undef FINALE_B_DREAMWALK
#undef FINALE_B_NO_TOD_TRANSITION
#undef FINALE_B_DREAMSCAPE_REMOVE_UNIQUE_SOUND_SOURCE
#undef FINALE_B_DREAMSCAPE_TRIGGER_LOCATION
#undef FINALE_B_DREAMSCAPE_TRANSFORM
#undef FINALE_B_ANIMATE_SPAWN
#undef FINALE_B_DREAMSCAPE_TRIGGER
#undef FINALE_B_DREAMSCAPE_MOVECOSTS
#undef FINALE_B_DREAMSCAPE_CREATE_WARPED
#undef FINALE_B_DREAMSCAPE_UNIQUE_SOUND_SOURCE

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