#textdomain wesnoth-After_the_Storm

[scenario]
    id=05_The_Eastern_Front
    name= _ "The Eastern Front"
    {MAP 05_The_Eastern_Front.map}
    {TURNS 32 30 28}
    next_scenario=05_The_Eastern_Front_cutscene

    {D_DEATHS}

    {SCENARIO_MUSIC "nunc_dimittis.ogg"}

    {STORYTXT_THE_EASTERN_FRONT}

    {TWO_SUNS_DEFAULT_SCHEDULE}

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

        {GOLD 250 250 240}

        # wmllint: recognize Elynia
        {CHARACTER_STATS_ELYNIA}
    [/side]
    # wmllint: validate-on

    [side]
        side=2
        team_name=evil
        user_team_name= _ "team_name^Elves"
        {CHAOS_FLAG}

        recruit=Elvish Archer,Shaxthal Rayblade,Elvish Scout,Elvish Acolyte,Elvish Shaman
        {GOLD 180 200 220}

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

        canrecruit=yes
        type=Elvish Mystic
        id=Telan
        name= _ "Telan"
        facing=nw
        [modifications]
            {TRAIT_DEXTROUS}
            {TRAIT_RESILIENT}
        [/modifications]
    [/side]

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

        recruit=Elvish Archer,Elvish Fighter,Elvish Scout,Elvish Shaman
        {GOLD 170 180 190}

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            # Don't let the leader go scouting for villages.
            {AI_SIMPLE_ALWAYS_ASPECT passive_leader yes}
            {AI_SIMPLE_ALWAYS_ASPECT recruitment_pattern "healer,fighter,fighter,archer,scout"}
        [/ai]

        canrecruit=yes
        type=Elvish Outrider
        id=Ethanin-Adrael
        name= _ "Ethanin-Adrael"
        facing=sw
        [modifications]
            {TRAIT_STRONG}
            {TRAIT_DEXTROUS}
        [/modifications]
    [/side]

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

        recruit=Elvish Archer,Elvish Fighter,Elvish Shaman,Elvish Acolyte
        {GOLD 190 200 210}

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

        canrecruit=yes
        gender=female
        type=Elvish Avenger
        id=Unidë
        name= _ "Unidë"
        facing=se
        [modifications]
            {TRAIT_RESILIENT}
            {TRAIT_QUICK}
        [/modifications]
    [/side]

    [side]
        side=5
        team_name=good
        user_team_name= _ "team_name^Elves"
        {ELVISH_FLAG}
        color=teal

        no_leader=yes
        hidden=yes

        {NO_INCOME}
        gold,village_gold=0,0
    [/side]

    [side]
        side=6
        team_name=shaxthals
        user_team_name= _ "team_name^Undead"
        {RAGGED_FLAG}
        color=brightgreen
        hidden=yes
        no_leader=yes
        controller=null

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_SIMPLE_ALWAYS_ASPECT grouping   no }
            {AI_SIMPLE_ALWAYS_ASPECT aggression 1.0}
            {AI_SIMPLE_ALWAYS_ASPECT caution    0.0}
        [/ai]
    [/side]

    {UNDEAD_RECRUITMENT:ZYNARA:WILD_GHOSTS_SIDE 6}

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

    [event]
        name=prestart
        # wmllint: recognize Anya
        {RECALL_ANYA_AT_LOCATION   19 19}
        # wmllint: recognize Zynara
        {RECALL_ZYNARA_AT_LOCATION 16 20}

        {FACE_DIRECTION (side=1) ne}

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

            {OBJECTIVE_DEFEAT  ( _ "Death of Elynia")}
            {OBJECTIVE_DEFEAT  ( _ "Death of Anya")}
            {OBJECTIVE_DEFEAT  ( _ "Death of Durvan")}
            {OBJECTIVE_DEFEAT  ( _ "Death of Zynara")}

            {TURNS_RUN_OUT}

            {ZYNARA_UNDEAD_RECRUITMENT_NOTES}

            {OBJECTIVE_CARRYOVER}
        )}

        # wmllint: recognize Durvan
        {RECALL_DURVAN_AT_LOCATION 19 24}

        [store_unit]
            [filter]
                id=Durvan
            [/filter]
            variable=durvan_store
            kill=yes
        [/store_unit]

        {VARIABLE durvan_store.facing nw}

        {VARIABLE anya_has_regenerated no}
    [/event]

    [event]
        name=start

        [message]
            speaker=Anya
            message= _ "There are so many different flowers in this field! It’s beautiful!"
        [/message]

        [message]
            speaker=Elynia
            message= _ "Indeed it is."
        [/message]

        [move_unit_fake]
            side=1
            type=$durvan_store.type
            x=22,20,20,19
            y=26,25,24,24
        [/move_unit_fake]

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

        {CLEAR_VARIABLE durvan_store}

        [message]
            speaker=Durvan
            message= _ "My lady, there are encampments ahead, apparently occupied by elves! This doesn’t look right!"
        [/message]

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

        [redraw][/redraw]

        [delay]
            time=500
        [/delay]

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

        [redraw][/redraw]

        [delay]
            time=500
        [/delay]

        [scroll_to]
            x,y=8,4
        [/scroll_to]

        [redraw][/redraw]

        [delay]
            time=500
        [/delay]

        [message]
            speaker=Elynia
            message= _ "Certainly not — they shouldn’t be this close to Aragwaithi territory, so I presume they belong to the hostile faction. Everyone prepare for battle, and let’s hope for the best."
        [/message]
    [/event]

    {BOW_OF_KRYSVELEN 34 24}

    [event]
        name=side 2 turn 1 refresh

        [fade_out_music]
            duration=500
        [/fade_out_music]

        {REPLACE_SCENARIO_MUSIC "battle.ogg"}
        {APPEND_MUSIC           "casualties_of_war.ogg"}
        {APPEND_MUSIC           "northerners.ogg"}
    [/event]

    [event]
        name=turn 2

        [message]
            speaker=Durvan
            message= _ "May the Lords of Light protect us..."
        [/message]

        [scroll_to]
            x,y=8,4
        [/scroll_to]

        [message]
            scroll=no
            speaker=Anya
            message= _ "They have assembled an army!"
        [/message]

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

        [message]
            scroll=no
            speaker=Zynara
            message= _ "Not just that, but they also have support from the metallic creatures of Uria!"
        [/message]

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

        [message]
            scroll=no
            speaker=Anya
            message= _ "My lady, what do you suggest we do?"
        [/message]

        [message]
            speaker=Elynia
            message= _ "I wish we could just entirely avoid casualties, but that’s not going to happen."
        [/message]
    [/event]

    [event]
        name=side 1 turn 2 end

        [message]
            speaker=Elynia
            message= _ "I fear for the fate of the elves who sent that call for help to the Council..."
        [/message]
    [/event]

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

        [message]
            speaker=Telan
            message= _ "Who is it that dares defy the power of the Lady of Light?"
        [/message]

        [message]
            speaker=Elynia
            message= _ "You, I presume. I am the only Lady of Light that there is on Irdya, and you have been deceived into fighting against me and the Grand Council of the Northern Peoples in favor of a dark cause, one that betrays the memory of our civilization and our leaders."
        [/message]

        [message]
            speaker=Telan
            message= _ "You are nothing but a blatant impostor working for the human bastards — a dirty, treacherous impostor!"
        [/message]

        [message]
            speaker=Elynia
            message= _ "Take her back to the encampment! I need to ask a few questions..."
        [/message]

        [message]
            speaker=Telan
            message= _ "I refuse to answer to the likes of you!"
        [/message]

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

        [kill]
            x,y=$x1,$y1
            fire_event=yes
            animate=yes
        [/kill]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Unidë
        [/filter]

        [message]
            speaker=Unidë
            message= _ "The traitors... they have slain me..."
        [/message]
    [/event]

    [event]
        name=die
        [filter]
            id=Unidë
        [/filter]

        [message]
            speaker=Elynia
            message= _ "Those elves who willingly choose to support the forces that seek to destroy our world don’t deserve to live."
        [/message]

        [message]
            speaker=Zynara
            message= _ "(<i>mumbling</i>) That seems rather hypocritical coming from you."
        [/message]

        [message]
            speaker=Elynia
            message= _ "I can hear you, Zynara."
        [/message]

        [scroll_to]
            x,y=$x2,$y2
        [/scroll_to]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Ethanin-Adrael
        [/filter]

        [message]
            speaker=Ethanin-Adrael
            message= _ "I shall not fall today!"
        [/message]

        [message]
            x,y=$x2,$y2
            [and]
                race=human
                [or]
                    race=faerie
                [/or]
            [/and]
            [or]
                id=Anya
            [/or]
            message= _ "He’s escaping!"
        [/message]

        [sound]
            name=horse-elf-canter.wav
        [/sound]

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

        [move_unit_fake]
            type=$unit.type
            side=$unit.side
            x=$x1,45,46,47,48
            y=$y1,13,12,13,13
        [/move_unit_fake]

        [kill]
            x,y=$x1,$y1
            animate=no
            fire_event=yes
        [/kill]
    [/event]

    #
    # The following three events are involved in the logic for
    # triggering a dialog sequence in which Elynia discusses Anya's
    # regeneration ability.
    #

    [event]
        # Triggers before units heal
        name=side 1 turn
        first_time_only=no
        [filter_condition]
            {VARIABLE_BOOLEAN_EQUALS anya_has_regenerated no}
        [/filter_condition]

        [store_unit]
            [filter]
                id=Anya
            [/filter]
            variable=anya_state_old
            kill=no
        [/store_unit]
    [/event]

    [event]
        # Triggers after units heal
        name=side 1 turn refresh
        first_time_only=no
        [filter_condition]
            {VARIABLE_BOOLEAN_EQUALS anya_has_regenerated no}
        [/filter_condition]

        [store_unit]
            [filter]
                id=Anya
            [/filter]
            variable=anya_state_new
            kill=no
        [/store_unit]

        {VARIABLE anya_hp_diff "$($anya_state_new.hitpoints - $anya_state_old.hitpoints)"}

        #
        # We discuss her regeneration ability when she actually gets to use it in battle.
        # Determining exactly when that occurs is rather convoluted, to say the least,
        # since we must account for several gameplay factors.
        #
        # For this reason we use a simpler logic here. If she has healed more than 2 HP
        # or cured her own poision between turn start and turn refresh, and there are no
        # adjacent healers or she isn't stationed in a village, she can only have made
        # use of her regenerates ability.
        #

        [if]
            # Not in a healing terrain or adjacent to a healer (which can only be villages and
            # Elynia in this scenario, respectively)
            [not]
                [have_unit]
                    id=Anya
                    [and]
                        [filter_adjacent]
                            id=Elynia
                        [/filter_adjacent]
                        [or]
                            [filter_location]
                                terrain=*^V*
                            [/filter_location]
                        [/or]
                    [/and]
                [/have_unit]
            [/not]
            [and]
                # Poisoned status changed
                {VARIABLE_BOOLEAN_NOT_EQUALS anya_state_new.status.poisoned $anya_state_old.status.poisoned}
                [or]
                    # Effective HP increased by more than the rest healing amount
                    # with no leveling up or advancements involved
                    {VARIABLE_NUMERICAL_GREATER_THAN anya_hp_diff 2}
                    {VARIABLE_NUMERICAL_EQUALS anya_state_new.max_hitpoints $anya_state_old.max_hitpoints}
                [/or]
            [/and]
            [then]
                [fire_event]
                    name=anya regeneration speak
                [/fire_event]

                # Prevent this from running again
                {VARIABLE anya_has_regenerated yes}
            [/then]
        [/if]

        {CLEAR_VARIABLE anya_state_old,anya_state_new,anya_hp_diff}
    [/event]

    [event]
        # The actual dialog sequence, provided stand-alone for clarity.
        name=anya regeneration speak

        [message]
            speaker=Elynia
            message= _ "How do you do that, girl?"
        [/message]

        [message]
            speaker=Anya
            message= _ "Do what?"
        [/message]

        [message]
            speaker=Elynia
            message= _ "You seem able to heal your own wounds without any effort. I haven’t heard of other faeries of the deep forest having that power."
        [/message]

        [message]
            speaker=Anya
            message= _ "Ah. Well, I have had this ability for as long as I can remember."
        [/message]
    [/event]

    [event]
        name=enemies defeated
        {ENDLEVEL_VICTORY yes}
    [/event]

    [event]
        name=victory
        [store_locations]
            [filter]
                id=Elynia
            [/filter]
            variable=elynia_loc
        [/store_locations]

        [message]
            speaker=Elynia
            message= _ "This conflict didn’t begin just now. When Galas and I last visited the northern country, a civil war was already raging due to Inodien’s death. The rumors pointed at the Iron Council’s intrusion in our lands and affairs, but we didn’t have the opportunity to confirm anything."
        [/message]

        [message]
            speaker=Zynara
            message= _ "Ah, the struggle that resulted in the banishment of the elves from the country. I remember that."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Much elvish blood has been shed today. I swear that whoever is behind this shall pay with their own life — no matter what it takes."
        [/message]

        [set_variables]
            name=unarye_path
            mode=replace
            [literal]
                muf_x=26,26
                muf_y= 1, 2
                x=25
                y= 3
                facing=sw
            [/literal]
        [/set_variables]

        [if]
            {VARIABLE_NUMERICAL_IN_RANGE elynia_loc.x 1 25}
            {VARIABLE_NUMERICAL_IN_RANGE elynia_loc.y 1 14}
            [then]
                # Use the default path
            [/then]
            [else]
                [if]
                    {VARIABLE_NUMERICAL_IN_RANGE elynia_loc.x 26 48}
                    {VARIABLE_NUMERICAL_IN_RANGE elynia_loc.y  1 22}
                    [then]
                        [set_variables]
                            name=unarye_path
                            mode=replace
                            [literal]
                                muf_x=48,47
                                muf_y=19,19
                                x=46
                                y=19
                                facing=nw
                            [/literal]
                        [/set_variables]
                    [/then]
                    [else]
                        [set_variables]
                            name=unarye_path
                            mode=replace
                            [literal]
                                muf_x= 1, 2, 4, 5, 6
                                muf_y=32,32,31,32,31
                                x= 7
                                y=31
                                facing=ne
                            [/literal]
                        [/set_variables]
                    [/else]
                [/if]
            [/else]
        [/if]

        [move_unit_fake]
            side=5
            type=Elvish Avatar
            x=$unarye_path.muf_x,$unarye_path.x
            y=$unarye_path.muf_y,$unarye_path.y
        [/move_unit_fake]

        # wmllint: recognize Unarye
        [unit]
            {CHARACTER_STATS_UNARYE}
            canrecruit=yes
            side=5
            x,y=$unarye_path.x,$unarye_path.y
            facing=$unarye_path.facing
        [/unit]

        {LOYAL_UNIT 5 (Elvish Hero) $unarye_path.x $unarye_path.y}
        [+unit]
            facing=$unarye_path.facing
        [/unit]
        {LOYAL_UNIT 5 (Elvish Marksman) $unarye_path.x $unarye_path.y}
        [+unit]
            facing=$unarye_path.facing
        [/unit]
        {LOYAL_UNIT 5 (Elvish Druid) $unarye_path.x $unarye_path.y}
        [+unit]
            facing=$unarye_path.facing
        [/unit]

        [message]
            speaker=Unarye
            message= _ "Elynia! I’m so glad to see you again after so long..."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Unarye, what happened? We were heading towards the eastern forest to meet with you when we stumbled upon this incursion. How could our enemies advance this far?"
        [/message]

        [message]
            speaker=Unarye
            message= _ "Indeed we owe you a few explanations, and I apologize for being unable to arrive earlier, but our forces have been severely weakened. Come with me, and I’ll explain all."
        [/message]

        [message]
            speaker=Durvan
            message= _ "My lady, do you know this elf?"
        [/message]

        [message]
            speaker=Elynia
            message= _ "She is one of Galas’ friends, Unarye, and she’s been collaborating with the Grand Council ever since we left to infiltrate the Empire. I know she can be trusted. Now, let’s go."
        [/message]

        {CLEAR_VARIABLE unarye_path,elynia_loc,anya_state_old,anya_state_new,anya_hp_diff,anya_has_regenerated}
    [/event]

    [event]
        name=time over
        [message]
            speaker=Durvan
            message= _ "My lady, I’ve just heard rumors that the elves are already advancing towards Raelthyn."
        [/message]

        [message]
            speaker=Elynia
            message= _ "That explains why they haven’t crushed us yet despite our poor performance. This was a foolish move. It’s best that we fall back to aid in the defense of the central region, quickly."
        [/message]
    [/event]
[/scenario]

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


#textdomain wesnoth-After_the_Storm

[scenario]
    id=05_The_Eastern_Front_cutscene
    name= _ "The Plan"
    {MAP 05_The_Eastern_Front_cutscene.map}
    turns=-1
    next_scenario=06_The_Voyage_Home
    victory_when_enemies_defeated=no

    {CUTSCENE_UI}

    {SCENARIO_MUSIC "heroes_rite.ogg"} {CONTINUE_PLAYING_STORY_MUSIC_FIRST}

    {STORYTXT_THE_PLAN}

    {AFTERNOON1}

    # wmllint: validate-off

    [side]
        side=1
        controller=human
        save_id=player
        team_name=good
        user_team_name= _ "team_name^Elynia"

        {NO_INCOME}
        gold,village_gold=0,0

        # wmllint: recognize Elynia
        {CHARACTER_STATS_ELYNIA}
    [/side]

    [side]
        side=2
        team_name=good
        user_team_name= _ "team_name^Elves"
        {ELVISH_FLAG}
        color=teal

        hidden=yes

        {NO_INCOME}
        gold,village_gold=0,0

        # wmllint: recognize Unarye
        {CHARACTER_STATS_UNARYE}
        canrecruit=yes
        facing=sw

        {GENERIC_UNIT () (Elvish Fighter) 14  3} {NO_UPKEEP_NO_OVERLAY} {FACING se}
        {GENERIC_UNIT () (Elvish Fighter) 17  5} {NO_UPKEEP_NO_OVERLAY} {FACING nw}

        {GENERIC_UNIT () (Elvish Captain) 18  6} {NO_UPKEEP_NO_OVERLAY} {FACING s}
        {GENERIC_UNIT () (Elvish Fighter) 18  9} {NO_UPKEEP_NO_OVERLAY} {FACING n}

        {GENERIC_UNIT () (Elvish Fighter)  8 11} {NO_UPKEEP_NO_OVERLAY} {FACING se}
        {GENERIC_UNIT () (Elvish Fighter) 11 13} {NO_UPKEEP_NO_OVERLAY} {FACING nw}

        {GENERIC_UNIT () (Elvish Ascetic) 12 11} {NO_UPKEEP_NO_OVERLAY} {FACING sw}
        {GENERIC_UNIT () (Elvish Archer)  12 10} {NO_UPKEEP_NO_OVERLAY} {FACING sw}
        {GENERIC_UNIT () (Elvish Archer)  11 11} {NO_UPKEEP_NO_OVERLAY} {FACING se}

        {GENERIC_UNIT () (Elvish Rider)    7 15} {NO_UPKEEP_NO_OVERLAY} {FACING ne}

        {GENERIC_UNIT () (Elvish Fighter)  6  5} {NO_UPKEEP_NO_OVERLAY} {FACING se}
        {GENERIC_UNIT () (Elvish Hunter)   6  6} {NO_UPKEEP_NO_OVERLAY} {FACING nw}

        {GENERIC_UNIT () (Elvish Shaman)  16  2} {NO_UPKEEP_NO_OVERLAY} {FACING sw}

        {GENERIC_UNIT () (Elvish Druid)    8 12} {NO_UPKEEP_NO_OVERLAY} {FACING s}

        [unit]
            type=Elvish Lord
            id=Lord Ardamién
            name= _ "Lord Ardamién"
            x,y=13,8
            upkeep=free
            facing=nw
            [modifications]
                {TRAIT_DEXTROUS}
                {TRAIT_QUICK}
            [/modifications]
        [/unit]

        [unit]
            type=Elvish Shyde
            id=Miryath
            name= _ "Miryath"
            profile="portraits/elves/shyde.png~FL(horiz)~RIGHT()"
            x,y=13,6
            upkeep=free
            facing=sw
            [modifications]
                {TRAIT_STRONG}
                {TRAIT_DEXTROUS}
            [/modifications]
        [/unit]
    [/side]

    # wmllint: validate-on

    {STARTING_VILLAGES_ALL 2}

    [event]
        name=prestart
        # wmllint: recognize Anya
        {RECALL_ANYA_AT_LOCATION   11 8}
        # wmllint: recognize Zynara
        {RECALL_ZYNARA_AT_LOCATION 11 6}
        # wmllint: recognize Durvan
        {RECALL_DURVAN_AT_LOCATION 10 7}

        {FACE_DIRECTION (id=Anya,Durvan) ne}
        {FACE_DIRECTION (id=Elynia,Zynara) se}

        [store_unit]
            [filter]
                id=Unarye
            [/filter]
            variable=unarye_store
            kill=yes
        [/store_unit]

        {LOCK_VIEW}
    [/event]

    [event]
        name=start
        [message]
            speaker=Durvan
            message= _ "Everyone here is restless, and the elvish leader is nowhere to be seen..."
        [/message]

        [message]
            speaker=Anya
            message= _ "Ah, here she comes!"
        [/message]

        [move_unit_fake]
            x=15,15,14,$unarye_store.x
            y= 9, 8, 7,$unarye_store.y
            type=$unarye_store.type
            side=$unarye_store.side
        [/move_unit_fake]

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

        [redraw][/redraw]

        [message]
            speaker=Unarye
            message= _ "I apologize once again for keeping you all waiting."
        [/message]

        [message]
            speaker=Elynia
            message= _ "It’s no problem, really."
        [/message]

        [message]
            speaker=Unarye
            message= _ "The reason we moved out of the way to the Aragwaith country is that we originally thought our fallen kin would chase us and leave the humans alone. As we all just saw, of course, we were mistaken. Our own people have managed to retrieve some valuable information from the enemy settlements, though. Listen carefully..."
        [/message]

        [message]
            speaker=Elynia
            message= _ "We are listening, my friend."
        [/message]

        [message]
            speaker=Unarye
            message= _ "The impostor who calls herself the Lady of Light has amassed a varied army of elves, humans, barbarians and Shaxthal creatures, apparently as part of a plan to reorganize the Chaos forces and strike the human country from the east while keeping their troops busy in the west. Not only have they gotten support from Inodien’s successors, but they have also made contact with elvish and human barbarians from lands farther to the east — peoples whose existence was unknown to us thus far."
        [/message]

        [message]
            speaker=Unarye
            message= _ "Their base of operations is said to be located in Telchior’s Hold in the Valley of Elynia — the very place whence we fled under Galas’ command following the Chaos invasion. Something deeply wrong must have occurred there after our departure. As I recall, the last time we met you mentioned that Lord Lédinor was possessed by Uria."
        [/message]

        [message]
            speaker=Elynia
            message= _ "That’s correct, indeed."
        [/message]

        [message]
            speaker=Lord Ardamién
            message= _ "The information we have could be a fabrication intended to mislead us into thinking the valley has some relevance in the greater scheme of things, but it’s not possible to disregard the danger this foul new alliance poses. If the northern lands fall now, the Chaos Empire will have won the war even without their Emperor or capital."
        [/message]

        [message]
            speaker=Unarye
            message= _ "We are in the middle of restructuring our forces to protect the eastern front for as long as we can, even if the Grand Council isn’t available to coordinate efforts with us."
        [/message]

        [message]
            speaker=Unarye
            message= _ "Elynia, you lead many capable warriors and you have the support of the undead. If you could infiltrate the valley in the meantime and vanquish the impostor, we could put an end to the war on this front."
        [/message]

        [message]
            speaker=Elynia
            message= _ "But... I know nothing of the valley other than that it lies in the middle of the desert — fighting in such an environment could be disastrous!"
        [/message]

        [message]
            speaker=Miryath
            message= _ "The impersonator is a coward and she isn’t going to lead her minions on the front line. If anything can be done about her, it’ll have to be at her base."
        [/message]

        [message]
            speaker=Unarye
            message= _ "You are a powerful warrior and you have more experience in these matters than any of us present. You helped Galas and Mal Keshar infiltrate the Chaos Empire before. I’m sure you will be successful in this task."
        [/message]

        [delay]
            time=1000
        [/delay]

        [message]
            speaker=Elynia
            message= _ "Very well. We’ll travel to your old home to purge this plague and strike down the false Lady of Light."
        [/message]

        [message]
            speaker=Unarye
            message= _ "Thank you, Elynia — thank you all. I’m sure that under your command the mission will be a success. Now, I must go to discuss our plans with our field commanders."
        [/message]

        [store_unit]
            [filter]
                id=Unarye
            [/filter]
            variable=unarye_store
            kill=yes
        [/store_unit]

        [move_unit_fake]
            x=$unarye_store.x,14,15,15
            y=$unarye_store.y, 7, 8, 9
            type=$unarye_store.type
            side=$unarye_store.side
        [/move_unit_fake]

        [redraw][/redraw]

        [message]
            speaker=Anya
            message={ASIDE ( _ "But, my lady, the Ruby! What if it’s a trap?")}
        [/message]

        [message]
            speaker=Elynia
            message={ASIDE ( _ "We’ll have to deal with the trap if that’s the case. This is more important!")}
        [/message]

        [message]
            speaker=Anya
            message={ASIDE ( _ "But Elorran is waiting for us!")}
        [/message]

        [message]
            speaker=Elynia
            message={ASIDE ( _ "Please inform him of our next mission and convince him to be patient.")}
        [/message]

        [message]
            speaker=Anya
            message={ASIDE ( _ "... Very well, then...")}
        [/message]

        {CLEAR_VARIABLE unarye_store}

        [fade_out_music][/fade_out_music]

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

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


#textdomain wesnoth-After_the_Storm

[scenario]
    id=06_The_Voyage_Home
    name= _ "The Voyage Home"
    {MAP 06_The_Voyage_Home.map}
    {TURNS 40 38 36}
    next_scenario=07_Proximus

    {D_DEATHS}

    {SCENARIO_MUSIC       "knolls.ogg"} {CONTINUE_PLAYING_STORY_MUSIC_FIRST}
    {EXTRA_SCENARIO_MUSIC "loyalists.ogg"}
    {EXTRA_SCENARIO_MUSIC "wanderer.ogg"}
    {EXTRA_SCENARIO_MUSIC "revelation.ogg"}
    {EXTRA_SCENARIO_MUSIC "breaking_the_chains.ogg"}

    {STORYTXT_THE_VOYAGE_HOME}

    {TWO_SUNS_DEFAULT_SCHEDULE}

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

        {GOLD 220 210 200}

        # wmllint: recognize Elynia
        {CHARACTER_STATS_ELYNIA}
    [/side]
    # wmllint: validate-on

    [side]
        side=2
        team_name=desert
        user_team_name= _ "team_name^Orcs"
        {CHAOS_FLAG}

        recruit=Orcish Archer,Wolf Rider,Orcish Grunt
        {GOLD 150 160 170}

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

        canrecruit=yes
        type=Orcish Warlord
        id=Pigork
        name= _ "Pigork"
        profile="portraits/orcs/grunt-6.png"
        facing=ne
        [modifications]
            {TRAIT_STRONG}
            {TRAIT_RESILIENT}
        [/modifications]
    [/side]

    [side]
        side=3
        team_name=desert
        user_team_name= _ "team_name^Orcs"
        {CHAOS_FLAG}

        recruit=Goblin Spearman,Wolf Rider,Orcish Archer,Orcish Assassin
        {GOLD 140 160 180}

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

        canrecruit=yes
        type=Orcish Slayer
        id=Bratar
        name= _ "Bratar"
        facing=nw
        [modifications]
            {TRAIT_RESILIENT}
            {TRAIT_INTELLIGENT}
        [/modifications]

        [unit]
            type=Goblin Rouser
            id=Vultraz
            name= _ "Vultraz"
            x,y=47,31
            facing=se
            profile="portraits/goblins/rouser-2.png"
            ai_special=guardian
            [modifications]
                {TRAIT_DIM}
                {TRAIT_SLOW}
            [/modifications]
        [/unit]

        [unit]
            type=Goblin Impaler
            id=Gargaz
            name= _ "Gargaz"
            x,y=57,31
            facing=ne
            ai_special=guardian
            [modifications]
                {TRAIT_WEAK}
                {TRAIT_DIM}
            [/modifications]
        [/unit]
    [/side]

    [side]
        side=4
        team_name=desert
        user_team_name= _ "team_name^Desert Creatures"
        hidden=yes
        no_leader=yes

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_SIMPLE_ALWAYS_ASPECT grouping no}
        [/ai]
    [/side]

    [side]
        side=5
        team_name=desert
        user_team_name= _ "team_name^Desert Spirits"
        hidden=yes
        no_leader=yes

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_SIMPLE_ALWAYS_ASPECT grouping   no }
            {AI_SIMPLE_ALWAYS_ASPECT aggression 1.0}
            {AI_SIMPLE_ALWAYS_ASPECT caution    0.0}
        [/ai]
    [/side]

    {UNDEAD_RECRUITMENT:ZYNARA:WILD_GHOSTS_SIDE 5}

    [label]
        x,y=4,41
        # wmllint: local spelling Boombadil
        text= _ "Mount Boombadil"
    [/label]

    [label]
        x,y=52,30
        text= _ "Fort Gralseth"
    [/label]

    {PLACE_IMAGE "items/bones.png~FL(horiz)"  49  6}
    {PLACE_IMAGE "items/bonestack.png"        51 39}
    {PLACE_IMAGE "items/bonestack.png"        49 45}
    {PLACE_IMAGE "items/bonestack.png"        41 43}
    {PLACE_IMAGE "items/bonestack.png"        55 29}
    {PLACE_IMAGE "items/bonestack.png"        47 29}
    {PLACE_IMAGE "items/burial.png"           50 21}
    {PLACE_IMAGE "items/burial.png"           38 12}
    {PLACE_IMAGE "items/burial.png~FL(horiz)" 40 16}

    {PLACE_IMAGE "scenery/banner-uria-standing.png"       50 27}
    {PLACE_IMAGE "scenery/banner-uria-standing.png"       52 42}
    {PLACE_IMAGE "scenery/banner-yechnagoth-standing.png" 49 39}

    {SPAWN_CONTROLLER}

#define TVH_SOUL _RESPAWN_TURNS _X _Y
    {TIMED_SPAWNER ({_RESPAWN_TURNS}) (
        type=Errant Soul
        ai_special=guardian
    ) 5 ({_X}) ({_Y})}
#enddef

    {TVH_SOUL  9 22 15}
    {TVH_SOUL  6 21 16}
    {TVH_SOUL 10 21 15}

    {TVH_SOUL  6 40  4}

    {TVH_SOUL 10 35  2}

    {TVH_SOUL  8 22 15}
    {TVH_SOUL  8 48 18}

    {TVH_SOUL 15 48 25}

    # west side of the river

    {TVH_SOUL  6  6 30}
    {TVH_SOUL  6  7 35}
    {TVH_SOUL  6 17 32}
    {TVH_SOUL  6 19 38}
    {TVH_SOUL  6 16 40}
    {TVH_SOUL  6 29 42}
    {TVH_SOUL  6 27 43}
    {TVH_SOUL  6  2 21}
    {TVH_SOUL  6  1 22}
    {TVH_SOUL  6 19 18}
    {TVH_SOUL  6 22 24}

#undef TVH_SOUL

    {STARTING_VILLAGES 1 6}
    {STARTING_VILLAGES 2 8}
    {STARTING_VILLAGES 3 10}

    [event]
        name=prestart
        # wmllint: recognize Anya
        {RECALL_ANYA_AT_LOCATION   3 7}
        # wmllint: recognize Zynara
        {RECALL_ZYNARA_AT_LOCATION 4 5}
        # wmllint: recognize Durvan
        {RECALL_DURVAN_AT_LOCATION 4 7}

        {FACE_DIRECTION (side=1) se}

        {OBJECTIVES (
            {OBJECTIVE_VICTORY ( _ "Secure the orcish settlement to the southeast by defeating all enemy leaders")}

            {OBJECTIVE_DEFEAT  ( _ "Death of Elynia")}
            {OBJECTIVE_DEFEAT  ( _ "Death of Anya")}
            {OBJECTIVE_DEFEAT  ( _ "Death of Durvan")}
            {OBJECTIVE_DEFEAT  ( _ "Death of Zynara")}

            {TURNS_RUN_OUT}

            {ZYNARA_UNDEAD_RECRUITMENT_NOTES}

            {OBJECTIVE_CARRYOVER}
        )}

        [hide_unit]
            type=Errant Soul
        [/hide_unit]
    [/event]

    [event]
        name=start

        [message]
            speaker=Zynara
            message= _ "The desert... I never thought I’d have to see it again."
        [/message]

        [message]
            speaker=Anya
            message= _ "Ugh. I feel unwell in these dry and bright lands."
        [/message]

        [message]
            speaker=Elynia
            message= _ "It can’t be helped. Dark faeries are frail creatures that revel in the shadows of the greatest and densest forests. Really, the desert is no place for you. I am sorry for dragging you along."
        [/message]

        [message]
            speaker=Anya
            message= _ "Oh, my lady, don’t worry about me. I just need some time to adapt to this environment, that is all."
        [/message]

        [message]
            speaker=Durvan
            message= _ "My lady, if you’ll allow me to complain... we can’t just march across the desert without stopping to rest!"
        [/message]

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

        [redraw][/redraw]

        [message]
            scroll=no
            speaker=Elynia
            message= _ "The scouts reported the presence of orcs bearing the Chaos banner in a settlement ahead to the southeast, in the Gralseth region. Stopping to rest here would be very risky with those fools around, but perhaps we could secure their settlement and replenish our supplies."
        [/message]

        [message]
            speaker=Anya
            message= _ "Excellent!"
        [/message]

        [message]
            speaker=Elynia
            message= _ "A word of caution, though. Ever since the Fall, the many victims of the disasters which devastated Irdya have been endlessly wandering across lands like this, preying on the souls of the living."
        [/message]

        [unhide_unit]
            x,y=48,18
        [/unhide_unit]

        [redraw][/redraw]

        [scroll_to]
            x,y=48,18
        [/scroll_to]

        # Oops, I forgot to implement a way to select nothing!
        #[select_unit]
        #   x,y=48,18
        #[/select_unit]

        [redraw][/redraw]

        [message]
            scroll=no
            speaker=Elynia
            message= _ "They are particularly weak by themselves and our arcane fire should be enough to banish them from our world. However, our less experienced fighters should not take their chances fighting them alone."
        [/message]

        # FIXME: not implemented yet, see above.
        #[unselect_unit]
        #[/unselect_unit]

        [redraw][/redraw]

        [message]
            speaker=Durvan
            message= _ "Understood, my lady."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Time to get moving."
        [/message]

        [unhide_unit]
            type=Errant Soul
        [/unhide_unit]

        [redraw][/redraw]
    [/event]

    [event]
        name=last breath
        [filter]
            type=Errant Soul
        [/filter]
        [filter_second]
            side=1
        [/filter_second]
        [filter_second_attack]
            type=arcane
        [/filter_second_attack]

        [if]
            [have_unit]
                x,y=$x2,$y2
                [not]
                    race=undead
                [/not]
                [not]
                    id=Zynara
                [/not]
            [/have_unit]
            [then]
                [message]
                    speaker=second_unit
                    message= _ "I banish you from this world! Go now to your deserved rest!"
                [/message]
            [/then]
            [else]
                [message]
                    speaker=Zynara
                    message= _ "Begone, wandering spirit!"
                [/message]
            [/else]
        [/if]
    [/event]

    [event]
        name=last breath
        first_time_only=no
        [filter]
            type=Errant Soul
        [/filter]
        [filter_second]
            side=1
        [/filter_second]
        [filter_second_attack]
            type=arcane
        [/filter_second_attack]

        #
        # Bypass the die event defined by the SPAWN_CONTROLLER macro.
        #

        [floating_text]
            [filter]
                x,y=$x1,$y1
            [/filter]
            text=""+_"banished"+"" # wmllint: ignore
        [/floating_text]

        [kill]
            x,y=$x1,$y1
            animate=yes
            fire_event=no
        [/kill]
    [/event]

    [event]
        name=moveto
        [filter]
            id=Anya
            [filter_location]
                terrain=W*
            [/filter_location]
        [/filter]

        [message]
            speaker=Anya
            message= _ "Ahhhh... There’s no feeling like putting my feet under refreshing, flowing water... I miss the northern forests..."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Where do you come from, anyway? You couldn’t have spent your whole life traveling with Elorran and Tara."
        [/message]

        [redraw][/redraw]

        [delay]
            time=500
        [/delay]

        [message]
            speaker=Anya
            message= _ "Oh... Of course not. It’s just... it’s complicated."
        [/message]

        [redraw][/redraw]

        [delay]
            time=1000
        [/delay]

        [message]
            speaker=Elynia
            message= _ "If you don’t feel like telling me more about yourself right now, I can understand — I’m just curious, that’s all."
        [/message]
    [/event]

    [event]
        name=side 2 turn 1
        [message]
            speaker=Bratar
            message= _ "Chief! The faerie! The faerie and her pets are approaching from the northwest!"
        [/message]

        [message]
            speaker=Pigork
            # po: "Necromancer" should be translated in a gender neutral fashion
            # po: if possible to keep their identity ambiguous (there are two
            # po: necromancers in the Iron Council, one is female (Mal Kendria)
            # po: and the other is male (Mal Hekuba).
            message= _ "Ah, just as the necromancer told us. Excellent news. More meat for our wolves!"
        [/message]

        [message]
            speaker=Vultraz
            # wmllint: local spelling Er
            message= _ "Yes, more meat for our pigs! Er— I mean wolves!"
        [/message]

        [message]
            speaker=Pigork
            message= _ "SHUT UP, you disgusting INSECT!"
        [/message]
    [/event]

#define TVH_SAND_STORM _START_TURN _END_TURN
    [event]
        name=turn {_START_TURN}
        [modify_side]
            side=1
            fog=yes
        [/modify_side]

        [color_adjust]
            red,green,blue=-10,-10,-40
        [/color_adjust]

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

    [event]
        name=turn {_END_TURN}
        [modify_side]
            side=1
            fog=no
        [/modify_side]

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

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

    {TVH_SAND_STORM 4 8} # afternoon1 till morning2

    {TVH_SAND_STORM 20 22} # dusk1 till dawn2

    {TVH_SAND_STORM 31 35} # dawn1 till dusk1

#undef TVH_SAND_STORM

    [event]
        name=turn 4
        [message]
            speaker=Zynara
            message= _ "A sandstorm! We won’t be able to continue marching like this!"
        [/message]

        [message]
            speaker=Elynia
            message= _ "This small inconvenience shall not stop us! Onwards!"
        [/message]
    [/event]

    [event]
        name=turn 5
        [message]
            speaker=Anya
            message= _ "My lady, are you sure this is a good plan?"
        [/message]

        [message]
            speaker=Elynia
            message= _ "It’s better than tarrying here for too long, so it’s good enough for me!"
        [/message]
    [/event]

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

        [message]
            speaker=Vultraz
            # wmllint: local spelling Eaaaagh
            message= _ "Eaaaagh..."
        [/message]
    [/event]

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

        [message]
            speaker=Gargaz
            message= _ "Argh! No!"
        [/message]
    [/event]

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

        [message]
            speaker=Bratar
            # po: "Send our messenger back to the valley, immediately!"
            message= _ "They are more than we expected! Send our messenger back to—"
        [/message]
    [/event]

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

        [move_unit_fake]
            side=3
            type=Direwolf Rider
            x=54,60
            y=34,37
        [/move_unit_fake]

        [redraw][/redraw]

        [message]
            speaker=Elynia
            message= _ "Blast it! Their messenger escaped!"
        [/message]
    [/event]

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

        [message]
            speaker=Pigork
            message= _ "... useless... insects..."
        [/message]
    [/event]

    [event]
        name=enemies defeated
        {ENDLEVEL_VICTORY yes}
    [/event]

    [event]
        name=victory
        [message]
            speaker=Durvan
            message= _ "Maybe this wasn’t such a good idea after all."
        [/message]

        [message]
            speaker=Elynia
            message= _ "I wasn’t counting on that messenger and his swift mount. Regardless, our presence here was both predicted and awaited — this decidedly spells bad news."
        [/message]

        [message]
            speaker=Anya
            message= _ "But I told you so!"
        [/message]

        [message]
            speaker=Elynia
            message= _ "I did expect a trap from the very beginning too, girl. We— I have been in situations like this before..."
        [/message]

        [message]
            speaker=Elynia
            message={ASIDE ( _ "But this time I won’t let them succeed.")}
        [/message]
    [/event]

    [event]
        name=time over
        [message]
            speaker=Elynia
            message= _ "Valen just informed me that the impostor’s forces are advancing towards Raelthyn. That can only mean Unarye and her troops fell in battle. This is hopeless."
        [/message]
    [/event]
[/scenario]

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


#textdomain wesnoth-After_the_Storm

[scenario]
    id=07_Proximus
    name= _ "Proximus"
    {MAP 07_Proximus.map}
    {TURNS 28 26 24}
    next_scenario=08_And_then_there_was_Chaos

    {E_DEATHS}

    {SCENARIO_MUSIC "weight_of_revenge.ogg"} {CONTINUE_PLAYING_STORY_MUSIC_FIRST}

    {STORYTXT_PROXIMUS}

    {LONGDARK1}  {GLOBAL_LIGHTING_BAD_NIGHT}
    {LONGDARK2}  {GLOBAL_LIGHTING_BAD_NIGHT}
    {LONGDARK3}  {GLOBAL_LIGHTING_BAD_NIGHT}
    {LONGDARK4}  {GLOBAL_LIGHTING_BAD_NIGHT}
    {DAWN1}      {GLOBAL_LIGHTING_BAD_DAWN}
    {MORNING1}   {GLOBAL_LIGHTING_BAD_MORNING}
    {MIDDAY1}    {GLOBAL_LIGHTING_BAD_DAY}
    {AFTERNOON1} {GLOBAL_LIGHTING_BAD_DAY}
    {DUSK1}      {GLOBAL_LIGHTING_BAD_DUSK}
    {SHORTDARK}  {GLOBAL_LIGHTING_BAD_NIGHT_SHORT}
    {DAWN2}      {GLOBAL_LIGHTING_BAD_DAWN}
    {MORNING2}   {GLOBAL_LIGHTING_BAD_MORNING}
    {MIDDAY2}    {GLOBAL_LIGHTING_BAD_DAY}
    {AFTERNOON2} {GLOBAL_LIGHTING_BAD_DAY}
    {DUSK2}      {GLOBAL_LIGHTING_BAD_DUSK}

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

        fog=yes
        {GOLD 200 190 180}

        # wmllint: recognize Elynia
        {CHARACTER_STATS_ELYNIA}
    [/side]
    # wmllint: validate-on

#define P_TARGETS
    [goal]
        [criteria]
            id=Elynia
        [/criteria]
        value=50.0
    [/goal]
    [goal]
        [criteria]
            id=Anya
        [/criteria]
        value=25.0
    [/goal]
    [goal]
        [criteria]
            id=Durvan
        [/criteria]
        value=25.0
    [/goal]
#enddef

    [side]
        side=2
        team_name=chaos
        user_team_name= _ "team_name^Northern Defense Line"
        {CHAOS_FLAG}

        recruit=Walking Corpse,Skeleton,Skeleton Archer,Ghoul,Ghost
        {GOLD 175 190 220}

        no_leader=yes

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

            {P_TARGETS}
        [/ai]
    [/side]

    [side]
        side=3
        team_name=chaos
        user_team_name= _ "team_name^Northern Defense Line"
        {CHAOS_FLAG}

        recruit=Walking Corpse,Skeleton,Skeleton Archer,Vampire Bat
        {GOLD 125 150 175}

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

            {P_TARGETS}
        [/ai]

        canrecruit=yes
        type=Chocobone
        id=General Lorelath
        name= _ "General Lorelath"
        max_hitpoints=52
        level=3
        max_experience=150
        [modifications]
            {TRAIT_UNDEAD}
        [/modifications]

        [village]
            x,y=29,30
        [/village]
        [village]
            x,y=30,34
        [/village]
        [village]
            x,y=34,34
        [/village]
    [/side]

    [side]
        side=4
        team_name=chaos
        user_team_name= _ "team_name^Northern Defense Line"
        {CHAOS_FLAG}

        recruit=Elvish Fighter,Elvish Hunter,Elvish Archer,Elvish Shaman
        {GOLD 150 160 170}

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_SIMPLE_ALWAYS_ASPECT aggression 0.90}
            {AI_SIMPLE_ALWAYS_ASPECT caution    0.01}

            {P_TARGETS}
        [/ai]

        canrecruit=yes
        type=Elvish Hero
        id=Cithraldin
        name= _ "Cithraldin"
        [modifications]
            {TRAIT_QUICK}
            {TRAIT_DEXTROUS}
        [/modifications]

        [village]
            x,y=32,25
        [/village]
        [village]
            x,y=34,25
        [/village]
    [/side]

    [side]
        side=5
        team_name=chaos
        user_team_name= _ "team_name^Northern Defense Line"
        {CHAOS_FLAG}

        recruit=Chaos Invoker,Chaos Invader,Chaos Hound
        {GOLD 150 160 170}

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

            {P_TARGETS}
        [/ai]

        canrecruit=yes
        type=Chaos Soulhunter
        id=Gerumanen
        name= _ "Gerumanen"
        [modifications]
            {TRAIT_QUICK}
            {TRAIT_DEXTROUS}
        [/modifications]

        [village]
            x,y=26,26
        [/village]
        [village]
            x,y=29,26
        [/village]
    [/side]

    [side]
        side=6
        team_name=chaos
        user_team_name= _ "team_name^Shaxthals"
        hidden=yes
        no_leader=yes

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

#undef P_TARGETS

    {RECRUIT_UNIT_VARIATIONS 2,3 "Walking Corpse" "bat,mounted,mounted,goblin,goblin,goblin,none"}

    {PLACE_IMAGE "scenery/banner-yechnagoth-standing.png" 28 26}
    {PLACE_IMAGE "scenery/banner-yechnagoth-standing.png" 33 26}
    {PLACE_IMAGE "scenery/banner-uria-standing.png"       27 23}
    {PLACE_IMAGE "scenery/banner-uria-standing.png"       33 22}
    {PLACE_IMAGE "scenery/banner-uria-standing.png"       29 18}
    {PLACE_IMAGE "scenery/banner-uria-standing.png"       37 35}

    [event]
        name=prestart
        # wmllint: recognize Zynara
        {RECALL_ZYNARA_AT_LOCATION 15 4}

        {FACE_DIRECTION (side=1) sw}

        [capture_village]
            side=1
            x=18-26
            y= 3-11
        [/capture_village]

        {LOCK_VIEW}
    [/event]

    [event]
        name=start
        [message]
            speaker=Elynia
            message= _ "According to the map Unarye gave us, the valley entrance is just ahead."
        [/message]

        [message]
            speaker=Zynara
            message= _ "Good."
        [/message]

        [delay]
            time=1000
        [/delay]

        {MOVE_UNIT (id=Zynara) 14  3}

        [message]
            speaker=Zynara
            message= _ "Don’t you think it is unsafe to be here all alone, though?"
        [/message]

        [message]
            speaker=Elynia
            message= _ "There’s nothing suspicious around here, so... No, I don’t think so. We are both capable of defending ourselves against desert animals."
        [/message]

        [delay]
            time=500
        [/delay]

        [message]
            speaker=Zynara
            message= _ "I see..."
        [/message]

        [disallow_recruit]
            side=1
            type=Ghost
        [/disallow_recruit]

        [allow_recruit]
            side=1
            type=Vampire Bat
        [/allow_recruit]

        {PLAY_LEVELOUT_ANIM (id=Zynara)}

        [kill]
            animate=no
            fire_event=no
            id=Zynara
        [/kill]

        [unit]
            canrecruit=yes
            side=2
            type=Lich
            id=Mal Zynavu
            name= _ "Mal Zynavu"
            gender=female
            profile="portraits/undead/brown-lich.png"
            #profile="portraits/zynavu.png"
            x,y=14,3
            facing=sw
            [modifications]
                {TRAIT_STRONG}
                {TRAIT_QUICK}
            [/modifications]
        [/unit]

        {PLAY_LEVELIN_ANIM (id=Mal Zynavu)}

        [redraw][/redraw]

        {REPLACE_SCENARIO_MUSIC "the_city_falls.ogg"}
        {APPEND_MUSIC "casualties_of_war.ogg"}

        [message]
            speaker=Mal Zynavu
            message= _ "Well, let’s see how you fare on your own against me!"
        [/message]

        {FACE_DIRECTION (id=Elynia) ne}

        [message]
            speaker=Elynia
            # wmllint: local spelling Wh
            message= _ "Wh—"
        [/message]

        [animate_attack]
            [filter]
                id=Elynia
            [/filter]
            [filter_second]
                id=Mal Zynavu
            [/filter_second]
            [filter_attack]
                range=ranged
            [/filter_attack]
            kill=no
            animate=yes
            fire_event=no
            amount=9
            damage_type=arcane
            alignment=chaotic
            #experience=no
        [/animate_attack]

        #
        # Give the floating damage label some time to fade out -- the exact
        # amount of time required varies according to the Accelerated Speed
        # setting, though.
        #
        [delay]
            time=500
        [/delay]

        [message]
            speaker=Elynia
            message= _ "—Who are you in truth? ANSWER!"
        [/message]

        [message]
            speaker=Mal Zynavu
            message= _ "It saddens me to admit that my master was a very misguided person — his destruction was only a matter of time. Uria’s power is the greatest force that’s ever graced us. We could avoid wasting so many lives all over the continent if everyone accepted her offer and joined her cause."
        [/message]

        [message]
            speaker=Elynia
            message= _ "So you were in the country working for the Triad all this time? YOU BETRAYED US!"
        [/message]

        [message]
            speaker=Mal Zynavu
            message= _ "I am not the only one! Even those pitiful northerners have grown weary of this pointless war and seek easier alternatives. Now, give me that staff. Oh, and don’t forget you are not in possession of godlike powers anymore — I can and will kill you if you don’t concede."
        [/message]

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

        [unit]
            animate=yes
            type=Shaxthal Sentry Drone
            variation=surface
            side=6
            x,y=11,4
            upkeep=free
            facing=ne
            [modifications]
                {TRAIT_BIOMECHANICAL}
                {TRAIT_ARMORED}
            [/modifications]
        [/unit]

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

        [unit]
            animate=yes
            type=Shaxthal Sentry Drone
            variation=surface
            side=6
            x,y=12,5
            upkeep=free
            facing=ne
            [modifications]
                {TRAIT_BIOMECHANICAL}
                {TRAIT_ARMORED}
            [/modifications]
        [/unit]

        [redraw][/redraw]

        [message]
            speaker=Mal Zynavu
            message= _ "They are also willing to help..."
        [/message]

        # wmllint: recognize Anya
        {RECALL_ANYA_AT_LOCATION 15 4}

        [store_unit]
            [filter]
                id=Anya
            [/filter]
            variable=anya_store
        [/store_unit]

        {VARIABLE anya_store.facing nw}

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

        [animate_unit]
            [filter]
                id=Anya
            [/filter]
            flag=recruited
            with_bars=yes
        [/animate_unit]

        [if]
            {VARIABLE_NUMERICAL_EQUALS anya_store.level 3}
            [then]
                {VARIABLE anya_attack_name "noctum"}
            [/then]
            [else]
                {VARIABLE anya_attack_name "shadow wave"}
            [/else]
        [/if]

        [harm_unit]
            [filter]
                id=Mal Zynavu
            [/filter]
            [filter_second]
                id=Anya
            [/filter_second]
            [primary_attack]
                name=$anya_attack_name
                range=ranged
            [/primary_attack]
            kill=no
            animate=yes
            fire_event=no
            amount=11
            damage_type=arcane
            alignment=chaotic
        [/harm_unit]

        {CLEAR_VARIABLE anya_attack_name,anya_store}

        [redraw][/redraw]

        [message]
            speaker=Mal Zynavu
            # wmllint: local spelling GAH
            message= _ "—GAH!"
        [/message]

        # wmllint: recognize Durvan
        {RECALL_DURVAN_AT_LOCATION 15 5}
        {FACE_DIRECTION (id=Durvan) nw}

        [animate_unit]
            [filter]
                id=Durvan
            [/filter]
            flag=recruited
            with_bars=yes
        [/animate_unit]

        [store_starting_location]
            side=2
        [/store_starting_location]

        [animate_unit]
            [filter]
                id=Mal Zynavu
            [/filter]
            flag=pre_teleport
            with_bars=yes
        [/animate_unit]

        [teleport]
            [filter]
                id=Mal Zynavu
            [/filter]
            x,y=$location.x,$location.y
        [/teleport]

        {CLEAR_VARIABLE location}

        [redraw][/redraw]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Elynia
            message= _ "Anya! Durvan! How did you know? I—"
        [/message]

        [message]
            speaker=Anya
            message= _ "My lady, we’d never leave you alone in the darkness. After all, it is our element!"
        [/message]

        [message]
            speaker=Durvan
            message= _ "There’s a lot of movement in the hills to the south, my lady. The northern defense line is preparing for battle, and so should we!"
        [/message]

        {MOVE_UNIT (id=Elynia) 22 6}

        [redraw]
            side=1
        [/redraw]

        {MOVE_UNIT (id=Durvan) 18 6}

        [redraw]
            side=1
        [/redraw]

        {MOVE_UNIT (id=Anya)   19 9}

        [redraw]
            side=1
        [/redraw]

        {UNLOCK_VIEW}

        {OBJECTIVES (
            {OBJECTIVE_VICTORY ( _ "Elynia must destroy Mal Zynavu by herself")}
            {OBJECTIVE_VICTORY ( _ "Defeat all enemy leaders")}

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

            {TURNS_RUN_OUT}

            {OBJECTIVE_CARRYOVER}

            {OBJECTIVE_NOTE ( _ "You may attack Mal Zynavu only with Elynia")}
        )}
    [/event]

    # wmlindent: start ignoring
    {FORCE_CHANCE_TO_HIT (
        [not]
            id="Elynia"
        [/not]
    ) (id="Mal Zynavu")   0 ()}
    {FORCE_CHANCE_TO_HIT (
        id="Elynia"
    ) (id="Mal Zynavu") 100 ()}
    # wmlindent: stop ignoring

    #
    # The following event handlers are wired into the victory event
    # as an alternative when using :cl or :n.
    #

    [event]
        name=prerecruit,prerecall,turn 2,victory
        [filter]
            race=undead
            side=1
        [/filter]

        [fire_event]
            name=elynia_faerie_fire_upgrade_pre_speech
        [/fire_event]
    [/event]

    [event]
        name=elynia_faerie_fire_upgrade_pre_speech
        [message]
            speaker=Elynia
            message= _ "I didn’t come from so far to the former home of my people to be defeated by a traitor and coward."
        [/message]
    [/event]

    [event]
        name=recruit,recall,turn 2,victory
        [filter]
            race=undead
            side=1
        [/filter]

        [fire_event]
            name=elynia_faerie_fire_upgrade
        [/fire_event]
    [/event]

    [event]
        name=elynia_faerie_fire_upgrade
        [message]
            speaker=Anya
            # po: The truncated word is "Elynia".
            message= _ "El— my lady?!"
        [/message]

        [message]
            speaker=Elynia
            message= _ "I have done this before, thanks to Argan and Malin. Although I am not as good as them with spirits, unfortunately..."
        [/message]

        [message]
            speaker=Durvan
            message= _ "Your staff... the Ruby’s glowing!"
        [/message]

        [if]
            [not]
                [have_unit]
                    id=Elynia
                    [has_attack]
                        name=faerie fire
                    [/has_attack]
                [/have_unit]
            [/not]
            [then]
                # Elynia somehow hasn't acquired Faerie Fire I (what are you
                # doing with your life, player??), so force-unlock it.
                [apply_amlas]
                    id=Elynia
                    {AMLA_ELYNIA_FAERIE_FIRE_L1}
                [/apply_amlas]
            [/then]
        [/if]

        [transient_message]
            image="units/undead/bloodbat-se-3.png~RC(magenta>red)"
            message= _ "Elynia can no longer recruit Ghosts.

However, she still has access to Ghost line units left in her recall list, and she is now able to recruit Vampire Bats."
        [/transient_message]
    [/event]

    [event]
        name=turn 3
        [modify_side]
            side=1
            fog=no
        [/modify_side]

        [redraw][/redraw]

        [message]
            speaker=Gerumanen
            message= _ "I can see her friends there... he, he..."
        [/message]

        [message]
            speaker=Mal Zynavu
            message= _ "Ignore them — strike down the faerie first!"
        [/message]
    [/event]

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

        [message]
            speaker=Elynia
            message= _ "Who is your leader? Who is awaiting us in the valley and who is my impersonator?"
        [/message]

        [message]
            speaker=Mal Zynavu
            message= _ "I work for the Iron Council! I have no idea who—"
        [/message]

        [message]
            speaker=Elynia
            message= _ "You... are... LYING!"
        [/message]

        [object]
            silent=yes
            [filter]
                id=Mal Zynavu
            [/filter]
            [effect]
                apply_to=new_animation
                [extra_anim]
                    flag=cutscene_burning
                    start_time=-400

                    {FLAME_BLAST_ANIMATION}

                    # Override stock animation offsets
                    offset=0.0~-0.1
                    {FLAME_BLAST_AFFECTS_SELF}

                    [frame]
                        #sound=fire.wav
                        duration=100
                    [/frame]
                    [frame]
                        sound={SOUND_LIST:LICH_HIT}
                        duration=100
                    [/frame]
                    [frame]
                        duration=200
                    [/frame]
                    [frame]
                        sound={SOUND_LIST:LICH_HIT}
                        duration=100
                    [/frame]
                    [frame]
                        sound=fire.wav
                        duration=100
                    [/frame]
                [/extra_anim]
            [/effect]
        [/object]

        {FLASH_RED (
            [animate_unit]
                [filter]
                    id=Mal Zynavu
                [/filter]
                flag=cutscene_burning
                with_bars=yes
            [/animate_unit]
        )}

        [delay]
            time=250
        [/delay]

        [kill]
            animate=yes
            fire_event=yes
            id=Mal Zynavu
        [/kill]

        [fade_out_music]
            time=1000
        [/fade_out_music]

        {REPLACE_SCENARIO_MUSIC "nunc_dimittis.ogg"}

        [message]
            speaker=Elynia
            message= _ "How could you..."
        [/message]
    [/event]

    [event]
        name=enemies defeated
        {ENDLEVEL_VICTORY yes}
    [/event]

    [event]
        name=victory
        [message]
            speaker=Durvan
            message= _ "It’s over now."
        [/message]

        [delay]
            time=500
        [/delay]

        [message]
            speaker=Anya
            message= _ "My lady..."
        [/message]

        [delay]
            time=1000
        [/delay]

        [message]
            speaker=Elynia
            message= _ "Just ‘Elynia’ will do, friends."
        [/message]

        [delay]
            time=1000
        [/delay]

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

        [message]
            speaker=Elynia
            message= _ "There is no turning back, and the impostor must be preparing to confront us or flee from the valley. Whichever is the case, I am going to find her and burn her to ashes. You must contact Elorran immediately to notify him of Zynara’s betrayal. It’s very probable that he is in danger."
        [/message]

        [message]
            speaker=Anya
            message= _ "Very well!"
        [/message]

        [message]
            speaker=Elynia
            message= _ "Everyone else, prepare for what I hope will be our last battle."
        [/message]

        [message]
            speaker=Durvan
            message= _ "Yes, my lady!"
        [/message]
    [/event]

    [event]
        name=time over
        [message]
            speaker=Durvan
            message= _ "The main troops are coming..."
        [/message]
    [/event]
[/scenario]

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


#textdomain wesnoth-After_the_Storm

[scenario]
    id=08_And_then_there_was_Chaos
    name= _ "And then there was Chaos"
    {MAP 08_And_then_there_was_Chaos.map}
    {TURNS 42 40 38}
    next_scenario=09_New_Hive

    {E_DEATHS}

    {SCENARIO_MUSIC       "siege_of_laurelmor.ogg"}
    {EXTRA_SCENARIO_MUSIC "casualties_of_war.ogg"}
    {EXTRA_SCENARIO_MUSIC "northerners.ogg"}
    {EXTRA_SCENARIO_MUSIC "battle.ogg"}

    {STORYTXT_AND_THEN_THERE_WAS_CHAOS}

    {DAWN1}      {GLOBAL_LIGHTING_BAD_DAWN}
    {MORNING1}   {GLOBAL_LIGHTING_BAD_MORNING}
    {MIDDAY1}    {GLOBAL_LIGHTING_BAD_DAY}
    {AFTERNOON1} {GLOBAL_LIGHTING_BAD_DAY}
    {DUSK1}      {GLOBAL_LIGHTING_BAD_DUSK}
    {SHORTDARK}  {GLOBAL_LIGHTING_BAD_NIGHT_SHORT}
    {DAWN2}      {GLOBAL_LIGHTING_BAD_DAWN}
    {MORNING2}   {GLOBAL_LIGHTING_BAD_MORNING}
    {MIDDAY2}    {GLOBAL_LIGHTING_BAD_DAY}
    {AFTERNOON2} {GLOBAL_LIGHTING_BAD_DAY}
    {DUSK2}      {GLOBAL_LIGHTING_BAD_DUSK}
    {LONGDARK1}  {GLOBAL_LIGHTING_BAD_NIGHT}
    {LONGDARK2}  {GLOBAL_LIGHTING_BAD_NIGHT}
    {LONGDARK3}  {GLOBAL_LIGHTING_BAD_NIGHT}
    {LONGDARK4}  {GLOBAL_LIGHTING_BAD_NIGHT}

    {SHAXTHAL_SET_SURFACE_VARIATIONS_FLAG}

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

        {GOLD 200 190 180}

        # wmllint: recognize Elynia
        {CHARACTER_STATS_ELYNIA}
    [/side]

    [side]
        side=2
        team_name=chaos
        user_team_name= _ "team_name^Telchior’s Hold"
        {CHAOS_FLAG}

        recruit=Elvish Acolyte,Elvish Fighter,Elvish Archer,Elvish Scout
        {GOLD 140 150 160}

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

        # wmllint: recognize Lady of Light
        {CHARACTER_STATS_IVYEL}
        canrecruit=yes
        facing=nw

        {NAMED_LOYAL_UNIT 2 (Elvish Outrider) 18 27 Adel ( _ "Adel")} {FACING sw} {GUARDIAN}

        {NAMED_LOYAL_UNIT 2 (Elvish Marshal) 26 33 Kethael ( _ "Kethael")} {FACING ne} {GUARDIAN}
        {NAMED_LOYAL_UNIT 2 (Elvish Prowler) 30 28 Midnolan ( _ "Midnolan")} {FACING nw} {GUARDIAN}
    [/side]
    # wmllint: validate-on

    [side]
        side=3
        team_name=chaos
        user_team_name= _ "team_name^Telchior’s Hold"
        {CHAOS_FLAG}

        recruit=Demon,Imp,Chaos Headhunter,Chaos Invoker
        {GOLD 150 175 190}

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

        canrecruit=yes
        type=Chaos Lorekeeper
        id=Kaerus-Aganan
        name= _ "Kaerus-Aganan"
        facing=nw
        [modifications]
            {TRAIT_STRONG}
            {TRAIT_RESILIENT}
            {BOSS_BOOST 30% 1 0 0 1}
        [/modifications]
    [/side]

    [side]
        side=4
        team_name=chaos
        user_team_name= _ "team_name^Base Defenses"
        {CHAOS_FLAG}

        recruit=Shaxthal Runner Drone,Chaos Hound,Chaos Headhunter,Chaos Invoker
        {GOLD 150 160 170}

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

        canrecruit=yes
        type=Gutwrencher Imp
        id=Galael
        name= _ "Galael"
        facing=nw
        [modifications]
            {TRAIT_SLOW}
            {TRAIT_RESILIENT}
            {BOSS_BOOST 25% 0 0 1 1}
        [/modifications]

        [unit]
            type=Shaxthal Enforcer Drone
            ai_special=guardian
            upkeep=free
            x,y=29,24
            facing=nw
            variation=surface
            [modifications]
                {TRAIT_BIOMECHANICAL}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]

        [unit]
            type=Shaxthal Sentry Drone
            ai_special=guardian
            upkeep=free
            x,y=33,30
            facing=se
            variation=surface
            [modifications]
                {TRAIT_BIOMECHANICAL}
                {TRAIT_STRONG}
            [/modifications]
        [/unit]

        [unit]
            type=Shaxthal Enforcer Drone
            ai_special=guardian
            upkeep=free
            x,y=29,37
            facing=nw
            variation=surface
            [modifications]
                {TRAIT_BIOMECHANICAL}
                {TRAIT_ARMORED}
            [/modifications]
        [/unit]

        [unit]
            type=Shaxthal War Drone
            ai_special=guardian
            upkeep=free
            x,y=10,23
            facing=ne
            [modifications]
                {TRAIT_BIOMECHANICAL}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]

        [unit]
            type=Shaxthal Assault Drone
            ai_special=guardian
            upkeep=free
            x,y=19,23
            facing=sw
            [modifications]
                {TRAIT_BIOMECHANICAL}
                {TRAIT_STRONG}
            [/modifications]
        [/unit]

        [unit]
            type=Shaxthal Sentry Drone
            ai_special=guardian
            upkeep=free
            x,y=10,30
            facing=ne
            variation=surface
            [modifications]
                {TRAIT_BIOMECHANICAL}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]
    [/side]

    [side]
        side=5
        team_name=chaos
        user_team_name= _ "team_name^Base Defenses"
        {CHAOS_FLAG}

        recruit=Demon,Chaos Invader,Chaos Bowman,Chaos Raider
        {GOLD 160 170 180}

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

        canrecruit=yes
        type=Ancient Lich
        id=Mal Ryagath
        name= _ "Mal Ryagath"
        facing=ne
        [modifications]
            {TRAIT_UNDEAD}
            {TRAIT_INTELLIGENT}
            {TRAIT_RESILIENT}
        [/modifications]
    [/side]

    [side]
        side=6
        team_name=chaos
        user_team_name= _ "team_name^Enemies"

        no_leader=yes
        hidden=yes
        gold,village_gold=0,0
        {NO_INCOME}

        {IS_HOSTILE_NPC}

        {GENERIC_UNIT () (Shaxthal Razorbird)  4 32} {GUARDIAN}
        {GENERIC_UNIT () (Shaxthal Razorbird) 37 10} {GUARDIAN}
        {GENERIC_UNIT () (Shaxthal Razorbird)  4 17} {GUARDIAN}
    [/side]

    {NPC_BIRD_BEHAVIOR 6 1 40 1 40}

    {STARTING_VILLAGES_ALL 2}

    {STARTING_VILLAGES 1 7}
    {STARTING_VILLAGES 3 4}
    {STARTING_VILLAGES 4 4}
    {STARTING_VILLAGES 5 7}

    # wmlindent: start ignoring

    {FORCE_CHANCE_TO_HIT (
        [not]
            id=Elynia
        [/not]
    ) (id=Lady of Light) 20 ()}

    {FORCE_CHANCE_TO_HIT (id=Elynia) (id=Lady of Light) 100 ()}

#ifdef EASY
    {FORCE_CHANCE_TO_HIT (id=Lady of Light) (id=Elynia)   0 ()}
#endif

    # wmlindent: stop ignoring

    [label]
        x,y=27,33
        text= _ "Telchior’s Hold"
    [/label]

    [label]
        x,y=36,16
        text= _ "Belandras’ Bridge" # wmllint: no spellcheck
    [/label]

    [label]
        x,y=19,2
        text= _ "Alenaril’s Pass" # wmllint: no spellcheck
    [/label]

    [label]
        x,y=24,26
        text= _ "River Toldrin" # wmllint: no spellcheck
    [/label]

    {PLACE_IMAGE ("scenery/mine-abandoned.png")        18 13}
    {PLACE_IMAGE ("scenery/mine-abandoned.png")         9  9}
    {PLACE_IMAGE ("scenery/mine-abandoned.png")        32  4}

    {PLACE_IMAGE ("scenery/monolith1.png")             22 17}

    {PLACE_IMAGE ("scenery/rock2.png")                 22 21}
    {PLACE_IMAGE ("scenery/rock3.png")                  9 20}

    {PLACE_IMAGE ("scenery/trash.png")                 28 34}
    {PLACE_IMAGE ("scenery/trash.png~FL(horiz)")       29 24}

    {PLACE_IMAGE ("scenery/trash.png")                  9 21}

    {PLACE_IMAGE ("scenery/temple1.png~FL(horiz)")     11 19}

    {PLACE_IMAGE ("scenery/village-human-burned3.png") 37 22}

    {PLACE_IMAGE "scenery/banner-yechnagoth-standing.png" 30 25}
    {PLACE_IMAGE "scenery/banner-uria-standing.png"       28 24}
    {PLACE_IMAGE "scenery/banner-yechnagoth-standing.png" 33 16}
    {PLACE_IMAGE "scenery/banner-yechnagoth-standing.png" 24 18}
    {PLACE_IMAGE "scenery/banner-uria-standing.png"       22  3}
    {PLACE_IMAGE "scenery/banner-uria-standing.png"       18  6}
    {PLACE_IMAGE "scenery/banner-uria-standing.png"       15 19}
    {PLACE_IMAGE "scenery/banner-uria-standing.png"       17 22}
    {PLACE_IMAGE "scenery/banner-yechnagoth-standing.png"  9 22}
    {PLACE_IMAGE "scenery/banner-uria-standing.png"       29 31}
    {PLACE_IMAGE "scenery/banner-uria-standing.png"       31 35}
    {PLACE_IMAGE "scenery/banner-uria-standing.png"       13 33}
    {PLACE_IMAGE "scenery/banner-yechnagoth-standing.png" 18 37}

    [event]
        name=prestart
        # wmllint: recognize Anya
        {RECALL_ANYA_AT_LOCATION   21 7}
        # wmllint: recognize Durvan
        {RECALL_DURVAN_AT_LOCATION 24 7}

        {FACE_DIRECTION (side=1) se}

        {OBJECTIVES (
            {OBJECTIVE_VICTORY ( _ "Elynia must defeat the false Lady of Light by herself")}
            {OBJECTIVE_VICTORY ( _ "Defeat all other enemy leaders")}

            {OBJECTIVE_DEFEAT  ( _ "The false Lady of Light gets killed by a different unit")}
            {OBJECTIVE_DEFEAT  ( _ "Death of Elynia")}
            {OBJECTIVE_DEFEAT  ( _ "Death of Anya")}
            {OBJECTIVE_DEFEAT  ( _ "Death of Durvan")}

            {TURNS_RUN_OUT}

            {OBJECTIVE_CARRYOVER}
        )}

        {LOCK_VIEW}
    [/event]

    [event]
        name=start
        # wmlindent: start ignoring
        {MOVE_UNIT (id=Adel)
            (17,16,15,14,14,15)
            (29,29,30,30,31,32)
        }
        # wmlindent: stop ignoring

        {FACE_DIRECTION (id=Adel) se}

        [message]
            speaker=Adel
            message= _ "Sirs, the impostor has arrived with her army! The northern defense line is—"
        [/message]

        [message]
            speaker=Kaerus-Aganan
            message= _ "Ha! Ha! That is no army. I thought the northern elves would be more kind to their so-called savior! Ha!"
        [/message]

        [message]
            speaker=Lady of Light
            message= _ "Behold, the usurper arrived to challenge us in our own headquarters. What a pitiful effort! To arms! Take her down and bring me her head and the staff she stole from me!"
        [/message]

        [message]
            speaker=Kethael
            message= _ "Yes, my lady."
        [/message]

        [message]
            speaker=Midnolan
            message= _ "As you command, my lady!"
        [/message]

        [scroll_to_unit]
            id=Elynia
        [/scroll_to_unit]

        [redraw][/redraw]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Durvan
            message = _ "They seem quite loyal to her despite the state of their home."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Indeed, something is seriously amiss about these elves. If only we could prove she is the impostor, perhaps they would then listen to reason."
        [/message]

        [message]
            speaker=Anya
            message= _ "What do you suggest, my lady... Elynia?"
        [/message]

        [message]
            speaker=Elynia
            message= _ "Stay clear of her and allow me to confront her by myself."
        [/message]

        [message]
            speaker=Anya
            message= _ "Very well..."
        [/message]

        {UNLOCK_VIEW}
    [/event]

    [event]
        name=moveto
        [filter]
            side=1
            x,y=22,17
        [/filter]

        [redraw][/redraw]

        [allow_undo][/allow_undo]

        [message]
            speaker=narrator
            image="scenery/monolith1.png"
            message= _ "Dedicated to Elynia-Thanadria of Wesmere, Lady of Light and Protector of the Elves of Irdya."
        [/message]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Kaerus-Aganan
        [/filter]

        [message]
            speaker=Kaerus-Aganan
            message= _ "Protect the Lady of Light! Argh—"
        [/message]
    [/event]

    [event]
        name=last breath
        [filter]
            race=elf
        [/filter]
        [filter_second]
            id=Elynia
        [/filter_second]

        [message]
            speaker=unit
            message= _ "I— the Lady of Light... why..."
        [/message]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Lady of Light
        [/filter]
        [filter_second]
            [not]
                id=Elynia
            [/not]
        [/filter_second]

        [animate_unit]
            [filter]
                id=Lady of Light
            [/filter]
            flag=pre_teleport
            with_bars=yes
        [/animate_unit]

        [kill]
            id=Lady of Light
            animate=no
            fire_event=no
        [/kill]

        [message]
            speaker=Anya
            message= _ "The impostor escaped!"
        [/message]

        [message]
            speaker=Elynia
            message= _ "This isn’t good. Since we couldn’t unmask her in front of her subjects, they will summon reinforcements and fight us to the death. We must retreat immediately!"
        [/message]

        {ENDLEVEL_DEFEAT}
    [/event]

    [event]
        name=attack end
        first_time_only=no
        [filter]
            id=Lady of Light
        [/filter]
        [filter_second]
            id=Elynia
        [/filter_second]

        [if]
            {VARIABLE_NUMERICAL_LESS_THAN_OR_EQUAL unit.hitpoints "$($unit.max_hitpoints * 0.5)"}
            [then]
                [fire_event]
                    name=unmask impostor
                [/fire_event]
            [/then]
        [/if]
    [/event]

    [event]
        name=attack end
        first_time_only=no
        [filter_second]
            id=Lady of Light
        [/filter_second]
        [filter]
            id=Elynia
        [/filter]

        [if]
            {VARIABLE_NUMERICAL_LESS_THAN_OR_EQUAL second_unit.hitpoints "$($second_unit.max_hitpoints * 0.5)"}
            [then]
                [fire_event]
                    name=unmask impostor
                [/fire_event]
            [/then]
        [/if]
    [/event]

    [event]
        name=unmask impostor
        [message]
            speaker=Lady of Light
            message= _ "I shall never be defeated by vile impostors like you!"
        [/message]

        [message]
            speaker=Elynia
            message= _ "Do you truly believe your own lies? Why don’t you show these elves what you are capable of? Your great powers as the Lady of Light? <i>Who</i> are you, and why are you posing as me?"
        [/message]

        [message]
            speaker=Lady of Light
            message= _ "Your end is at hand. I shall not answer. Guards! Kill her!"
        [/message]

#define ATTWC_GUARD _TYPE _X _Y _ID _NAME _GENDER _EXTRA_TRAIT
    [unit]
        side=2
        type={_TYPE}
        x={_X}
        y={_Y}
        id={_ID}
        name={_NAME}
        gender={_GENDER}
        random_traits=no
        generate_name=no
        random_gender=no
        unrenamable=yes
        animate=yes
        [modifications]
            {_EXTRA_TRAIT}
        [/modifications]
    [/unit]
#enddef

        # wmllint: whofield ATTWC_GUARD 4
        {ATTWC_GUARD (Elvish Druid)   27 36 Anariel ( _ "Anariel") () ({TRAIT_RESILIENT})} {FACING n}
        {ATTWC_GUARD (Elvish Archer)  31 34 Eldulas ( _ "Eldulas") () ({TRAIT_INTELLIGENT})} {FACING nw}
        {ATTWC_GUARD (Elvish Fighter) 28 29 Vinon ( _ "Vinon") () ({TRAIT_DEXTROUS})} {FACING sw}
        # wmllint: whofield clear ATTWC_GUARD

#undef ATTWC_GUARD

        [if]
            [have_unit]
                id=Elynia
                [filter_location]
                    x,y=27,33
                    radius=1
                [/filter_location]
            [/have_unit]
            [then]
                [if]
                    [not]
                        [have_unit]
                            x,y=27,35
                        [/have_unit]
                    [/not]
                    [then]
                        {MOVE_UNIT (id=Anariel) 27 35}
                    [/then]
                [/if]
                [if]
                    [not]
                        [have_unit]
                            x,y=30,33
                        [/have_unit]
                    [/not]
                    [then]
                        {MOVE_UNIT (id=Eldulas) 30 33}
                    [/then]
                [/if]
                [if]
                    [not]
                        [have_unit]
                            x,y=27,30
                        [/have_unit]
                    [/not]
                    [then]
                        {MOVE_UNIT (id=Vinon) 27 30}
                    [/then]
                [/if]
            [/then]
        [/if]

        [message]
            speaker=Elynia
            message= _ "Back, you fools!"
        [/message]

        # Back up Elynia while we transform her into a different variation

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

        #
        # HACK:
        #
        # Because this event is thrown from attack end, it's possible that
        # Elynia is a dead woman walking after receiving damage from Ivyel.
        # We may signal victory afterwards, so her death events don't fire and
        # her unit is silently deleted from the map before the victory handler
        # is run, which results in unusual behavior. This is an issue on 1.12.4
        # at least.
        #
        # The sane thing to do here would be to check at the very start of this
        # event whether Elynia must die or not and kill her accordingly, but
        # since completing this scenario objective is hard enough as it is, I
        # thought I might as well be a bit charitable for once and give her a
        # chance to survive (which may not work anyway depending on how well
        # the player prepared for fighting Ivyel and whether there are any
        # enemy leaders left).
        #
        {VARIABLE elynia_store.hitpoints "$(max($elynia_store.hitpoints, 1))"}

        # Force Elynia to be alive again before transforming her, otherwise
        # she's considered a dead woman walking and stops having a primary
        # frame for her standing animation as if we were handling her 'die'
        # event here (on 1.14.x at least).

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

        [object]
            silent=yes
            [filter]
                id=Elynia
            [/filter]
            [effect]
                apply_to=variation
                name=faerie_fire_cutscene
            [/effect]
        [/object]

        # Reset her cutscene version's hitpoints back to what her gameplay self
        # has right now, otherwise she gets healed above to around 90% (on 1.14.x
        # at least) for some mysterious reason. Presumably she's healed to full
        # sans mod effects (traits, etc.).

        [modify_unit]
            [filter]
                id=Elynia
            [/filter]
            hitpoints=$elynia_store.hitpoints
        [/modify_unit]

        [animate_unit]
            [filter]
                id=Elynia
            [/filter]
            flag=cutscene_begin
            with_bars=yes
        [/animate_unit]

        [delay]
            time=1500
        [/delay]

        [message]
            speaker=Eldulas
            message= _ "What is this? She emanates such a radiant light!"
        [/message]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Vinon
            # wmllint: local spelling Wha
            message= _ "... Wha— What are we doing?"
        [/message]

        [message]
            speaker=Lady of Light
            message= _ "Do not hesitate! Kill her! <b>Now!</b>"
        [/message]

        [delay]
            time=500
        [/delay]

        [message]
            speaker=Vinon
            message= _ "Who... Who should we trust?"
        [/message]

        [message]
            speaker=Anariel
            message= _ "My lady... Elynia! The Lady of Light! I remember you!"
        [/message]

        [delay]
            time=500
        [/delay]

        [message]
            speaker=Lady of Light
            message= _ "No..."
        [/message]

        [message]
            speaker=Eldulas
            message= _ "... We have been deceived..."
        [/message]

        [message]
            speaker=Lady of Light
            message= _ "NO!"
        [/message]

        [store_unit]
            [filter]
                race=elf
                [not]
                    side=1
                [/not]
            [/filter]
            variable=enemy_elves_store
        [/store_unit]

        #
        # We need the TRAIT_LOYAL macro contents in a temporary.
        # They include the [trait] opening and closing tags, and
        # we don't want those below, hence this approach.
        #

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

        [foreach]
            array=enemy_elves_store
            [do]
                [set_variables]
                    name=this_item
                    mode=merge
                    [literal]
                        side=1
                        upkeep=free
                        {IS_LOYAL}
                    [/literal]
                [/set_variables]

                [if]
                    # Do not add the Loyal trait if the unit already has it
                    # Note that we expect it to be in the first slot; that
                    # is usually the case and allows for simpler code.
                    {VARIABLE_LEXICAL_NOT_EQUALS this_item.modifications.trait[0].id "loyal"}
                    [then]
                        [set_variables]
                            name="this_item.modifications.trait[0]"
                            mode=insert
                            to_variable="temp_trait_loyal_wml.trait"
                        [/set_variables]
                    [/then]
                [/if]

                [unstore_unit]
                    variable=this_item
                    find_vacant=no
                [/unstore_unit]
            [/do]
        [/foreach]

        [message]
            speaker=Vinon
            message= _ "What have we done?"
        [/message]

        [animate_unit]
            [filter]
                id=Elynia
            [/filter]
            flag=cutscene_end
            with_bars=yes
        [/animate_unit]

        # Restore Elynia's gameplay self

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

        [redraw][/redraw]

        {CLEAR_VARIABLE elynia_store,enemy_elves_store,temp_trait_loyal_wml}

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Lady of Light
            message= _ "This is <i>not</i> over yet!"
        [/message]

        {MOVE_UNIT (id=Lady of Light) 34 31}

        [animate_unit]
            [filter]
                id=Lady of Light
            [/filter]
            flag=pre_teleport
            with_bars=yes
        [/animate_unit]

        [kill]
            id=Lady of Light
            animate=no
            fire_event=no
        [/kill]

        [redraw][/redraw]

        [delay]
            time=750
        [/delay]

        [message]
            side=1
            race=elf
            message= _ "The false Lady of Light has escaped!"
        [/message]

        [if]
            [not]
                [have_unit]
                    side=3
                    canrecruit=yes
                [/have_unit]
            [/not]
            [not]
                [have_unit]
                    side=4
                    canrecruit=yes
                [/have_unit]
            [/not]
            [not]
                [have_unit]
                    side=5
                    canrecruit=yes
                [/have_unit]
            [/not]
            [then]
                {ENDLEVEL_VICTORY yes}
            [/then]
            [else]
                [message]
                    speaker=Anya
                    message= _ "We still need to defeat the other commanders!"
                [/message]

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

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

                    {TURNS_RUN_OUT}

                    {OBJECTIVE_CARRYOVER}
                )}
            [/else]
        [/if]
    [/event]

    [event]
        name=time over
        [message]
            speaker=Durvan
            message= _ "Their reinforcements have arrived and they have surrounded the valley! This is hopeless!"
        [/message]
    [/event]

    [event]
        name=enemies defeated
        {ENDLEVEL_VICTORY yes}
    [/event]

    [event]
        name=victory
        [message]
            speaker=Durvan
            message= _ "That fiend retreated into the Shaxthal hive."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Her crimes against the unity of the elvish civilization must not go unpunished. I shall pursue her underground if need be."
        [/message]

        [message]
            speaker=Anariel
            message= _ "My lady, we cannot let you go underground alone! It’s become an exceedingly dangerous place since the new hive was completed."
        [/message]

        [message]
            speaker=Eldulas
            message= _ "We haven’t seen him or her ourselves yet, but the humans have been spreading rumors of the arrival of a powerful ally of the impostor! They might be awaiting you!"
        [/message]

        [message]
            speaker=Anya
            message= _ "My lady, I— I mean Elynia, let us go with you, please!"
        [/message]

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Vinon
            message= _ "If there’s anything else we can do to try to amend our grave mistake..."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Let’s go together."
        [/message]
    [/event]
[/scenario]

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