#textdomain wesnoth-Invasion_from_the_Unknown

[scenario]
    id=16_Dawn_of_War
    name= _ "Dawn of War"
    {MAP 16_Dawn_of_War.map}
    {TURNS 32 29 27}
    next_scenario=17_Voice_of_the_Armageddon
    victory_when_enemies_defeated=no

    {SCENARIO_MUSIC "underground.ogg"} {CONTINUE_PLAYING_STORY_MUSIC_FIRST}

    {LONGDARK1}
    {LONGDARK2}
    {LONGDARK3}
    {LONGDARK4}
    {DAWN1}
    {MORNING1}
    {MIDDAY1}
    {AFTERNOON1}
    {DUSK1}
    {SHORTDARK}
    {DAWN2}
    {MORNING2}
    {MIDDAY2}
    {AFTERNOON2}
    {DUSK2}

    {SHAXTHAL_SET_SURFACE_VARIATIONS_FLAG}

    {STORYTXT_DAWN_OF_THE_GREAT_WAR}

    {DEATHS_ACT_3}

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

        shroud=yes
        fog=yes

        # NOTE: gold must be 6 * recall_cost at the very minimum in order to
        #       let the player recall units on the first turn.
        {GOLD 180 170 160}

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

    [side]
        side=2
        team_name=good
        user_team_name= _ "team_name^Alliance"
        {ALLIANCE_FLAG}

        {GOLD 200 190 180}
        recruit=Aragwaith Archer,Aragwaith Witch,Aragwaith Swordsman,Aragwaith Spearman,Aragwaith Scout,Aragwaith Eagle Rider,Aragwaith Wizard,Aragwaith Lancer,Aragwaith Pikeman,Aragwaith Guard,Aragwaith Longswordsman

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

        canrecruit=yes
        type=Aragwaith Captain
        id=Ivancyn
        name= _ "Ivancyn"
        [modifications]
            {TRAIT_STRONG}
            {TRAIT_DEXTROUS}
        [/modifications]
    [/side]

    [side]
        side=3
        team_name=good
        user_team_name= _ "team_name^Alliance"
        {ALLIANCE_FLAG}

        {GOLD 200 180 175}
        recruit=Orcish Archer,Orcish Assassin,Saurian Augur,Orcish Grunt,Wolf Rider,Goblin Spearman

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_SIMPLE_UTBS_DAY_ASPECT      aggression 0.8}
            {AI_SIMPLE_UTBS_TWILIGHT_ASPECT aggression 0.9}
            {AI_SIMPLE_UTBS_NIGHT_ASPECT    aggression 1.0}

            {AI_SIMPLE_UTBS_DAY_ASPECT      caution    0.2}
            {AI_SIMPLE_UTBS_TWILIGHT_ASPECT caution    0.3}
            {AI_SIMPLE_UTBS_NIGHT_ASPECT    caution    0.5}
        [/ai]

        canrecruit=yes
        type=Orcish Slurbow
        id=Zirshe
        name= _ "Zirshe"
        gender=female
        [modifications]
            {TRAIT_QUICK}
            {TRAIT_RESILIENT}
        [/modifications]
    [/side]

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

        {GOLD 240 260 275}
        {INCOME 0 4 6}
        recruit=Shaxthal Rayblade,Dark Knight,Chaos Invader,Chaos Raider,Chaos Invoker,Automaton

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_SIMPLE_ALWAYS_ASPECT aggression    1.0}
            {AI_SIMPLE_ALWAYS_ASPECT caution       0.0}
            {AI_SIMPLE_ALWAYS_ASPECT village_value 0.0}

            {AI_SAVE_GOLD_DEFAULT}

            {AI_RECRUITMENT_ALWAYS_ASPECT (
                {AI_RECRUIT_LIMIT "Shaxthal Rayblade" 4}
                {AI_RECRUIT_LIMIT "Dark Knight"       2}
                {AI_RECRUIT_LIMIT "Automaton"         2}
            )}
        [/ai]

        canrecruit=yes
        type=Chaos Razerman
        id=Obandur
        name= _ "Obandur"
        [modifications]
            {TRAIT_STRONG}
            {TRAIT_INTELLIGENT}
        [/modifications]
    [/side]

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

        {GOLD 190 200 210}
        recruit=Automaton,Chaos Hound,Chaos Headhunter,Chaos Invader,Demon

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_SIMPLE_ALWAYS_ASPECT aggression    0.80}
            {AI_SIMPLE_ALWAYS_ASPECT caution       0.15}
            {AI_SIMPLE_ALWAYS_ASPECT village_value 0.25}
        [/ai]

        canrecruit=yes
        type=Gutwrencher Imp
        id=Zulthor
        name= _ "Zulthor"
        [modifications]
            {TRAIT_SLOW}
            {TRAIT_RESILIENT}
        [/modifications]
    [/side]

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

        {GOLD 230 240 250}
        {INCOME 2 3 4}
        recruit=Shaxthal Runner Drone,Shaxthal Protector Drone,Chaos Hound,Chaos Headhunter,Imp,Chaos Invoker

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_SIMPLE_UTBS_TOD_ASPECT aggression    0.80 0.90 1.00}
            {AI_SIMPLE_UTBS_TOD_ASPECT caution       0.50 0.25 0.00}
            {AI_SIMPLE_UTBS_TOD_ASPECT village_value 0.10 0.50 0.20}

            {AI_RECRUITMENT_ALWAYS_ASPECT (
                {AI_RECRUIT_LIMIT "Shaxthal Protector Drone" 2}
                {AI_RECRUIT_LIMIT "Shaxthal Runner Drone"    6}
            )}

            [goal]
                [criteria]
                    id=Mal Keshar
                [/criteria]
                value=9.0
            [/goal]
            [goal]
                [criteria]
                    id=Elynia
                [/criteria]
                value=10.0
            [/goal]
        [/ai]

        canrecruit=yes
        type=Chaos Lorekeeper
        id=Karin-Ilyanai
        name= _ "Karin-Ilyanai"
        [modifications]
            {TRAIT_RESILIENT}
            {TRAIT_INTELLIGENT}
        [/modifications]
    [/side]

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

        {GOLD 280 300 320}
        {INCOME 3 4 5}
        recruit=Shaxthal Runner Drone,Chaos Invoker,Chaos Raider,Chaos Invader,Demon,Demon Grunt,Demon Zephyr

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_SIMPLE_UTBS_TOD_ASPECT aggression    0.60 0.75 0.95}
            {AI_SIMPLE_UTBS_TOD_ASPECT caution       0.30 0.20 0.05}
            {AI_SIMPLE_UTBS_TOD_ASPECT village_value 0.10 0.30 0.25}

            {AI_RECRUITMENT_ALWAYS_ASPECT (
                {AI_RECRUIT_LIMIT "Shaxthal Runner Drone" 8}
                {AI_RECRUIT_LIMIT "Demon Zephyr"          6}
                {AI_RECRUIT_LIMIT "Demon Grunt"           6}
            )}

            [goal]
                [criteria]
                    id=Galas
                [/criteria]
                value=10.0
            [/goal]
        [/ai]

        canrecruit=yes
        type=Hell Overlord
        id=Ben
        name= _ "Ben"
        [modifications]
            {TRAIT_STRONG}
            {TRAIT_RESILIENT}
        [/modifications]
    [/side]

    [side]
        side=8
        team_name=enemies
        user_team_name= _ "team_name^Wild Animals"

        no_leader=yes
        hidden=yes

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

        {SIDE_GENERIC_UNIT (Shaxthal Razorbird) 18 34}
        {SIDE_GENERIC_UNIT (Shaxthal Razorbird) 28 34}
        {SIDE_GENERIC_UNIT (Shaxthal Razorbird) 12 46}
        {SIDE_GENERIC_UNIT (Shaxthal Razorbird) 21 48}
        {SIDE_GENERIC_UNIT (Shaxthal Razorbird) 35 39}
        {SIDE_GENERIC_UNIT (Shaxthal Razorbird) 25 40}
    [/side]

    [side]
        side=9
        team_name=enemies
        user_team_name= _ "team_name^Wild Animals"
        color=pink

        no_leader=yes
        hidden=yes

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

        {SIDE_GENERIC_UNIT (Falcon) 27 53}
        {SIDE_GENERIC_UNIT (Falcon)  4 47}
        {SIDE_GENERIC_UNIT (Falcon) 13 38}
        {SIDE_GENERIC_UNIT (Falcon) 28 40}
        {SIDE_GENERIC_UNIT (Falcon) 27 42}
        {SIDE_GENERIC_UNIT (Falcon) 46 36}
    [/side]

    [side]
        side=10
        controller=null
        team_name=good
        user_team_name= _ "team_name^Galas"
        color=red

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

    {STARTING_VILLAGES 2 4}
    {STARTING_VILLAGES 3 4}

    {STARTING_VILLAGES 4 6}
    {STARTING_VILLAGES 5 6}
    {STARTING_VILLAGES 6 4}
    {STARTING_VILLAGES 7 4}

    {NPC_BIRD_BEHAVIOR_WHOLE_MAP 8}

    {NPC_BIRD_BEHAVIOR_WHOLE_MAP 9}

    [event]
        name=prestart

        #
        # Replace the turn limit for the initial section.
        #

        [store_turns]
            variable=dow_real_turn_limit
        [/store_turns]

        [modify_turns]
            side=1
            value=5
        [/modify_turns]

        #
        # Disable AI sides.
        #

        [modify_side]
            [filter_side]
                [not]
                    side=1,10
                [/not]
            [/filter_side]
            controller=null
        [/modify_side]

        #
        # Disallow Galas from straying off path at the start.
        #

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

        [object]
            silent=yes
            [filter]
                id=Galas
            [/filter]
            [effect]
                apply_to=movement_costs
                replace=true
                [movement_costs]
                    deep_water={UNREACHABLE}
                    shallow_water={UNREACHABLE}
                    reef={UNREACHABLE}
                    swamp_water={UNREACHABLE}
                    forest={UNREACHABLE}
                    hills={UNREACHABLE}
                    mountains={UNREACHABLE}
                    village={UNREACHABLE}
                    castle={UNREACHABLE}
                    fungus={UNREACHABLE}
                [/movement_costs]
            [/effect]
            [effect]
                apply_to=movement
                set=4
            [/effect]
        [/object]

        [store_starting_location]
            side=9
            variable=goal_loc
        [/store_starting_location]

        {PLACE_IMAGE items/goplate.png $goal_loc.x $goal_loc.y}

        [remove_shroud]
            side=1
            [filter]
                id=Galas
            [/filter]
            radius=6
        [/remove_shroud]

        {PLAYER_RECRUITMENT_SETUP_FOR_SCENARIO 16}

        #
        # Recall heroes
        #

        # wmllint: recognize Elynia
        {RECALL_ELYNIA_AT     20 15}
        # wmllint: recognize Mal Keshar
        {RECALL_MAL_KESHAR_AT 20 17}
        # wmllint: recognize Erathan
        {RECALL_ERATHAN_AT    21 17}
        # wmllint: recognize Igor
        {RECALL_IGOR_AT       26 17}

        [modify_unit]
            [filter]
                id=Elynia,Mal Keshar,Erathan,Igor
            [/filter]
            side=10
        [/modify_unit]

        {FACE_UNIT side=10 id=Galas}

        {OBJECTIVES (
            {OBJECTIVE_VICTORY ( _ "Rendezvous with your allies")}

            {OBJECTIVE_DEFEAT ( _ "Death of Galas")}

            {TURNS_RUN_OUT}
        )}

        {VARIABLE shadowm_talk 1}
    [/event]

    [event]
        id=shadowm_talk_controller
        name=moveto
        first_time_only=no
        [filter]
            #id=Galas
            side=1
        [/filter]

        [fire_event]
            name=shadowm_talk_$shadowm_talk
        [/fire_event]

        {VARIABLE_INC shadowm_talk}
    [/event]

    # wmllint: unbalanced-on
    # wmlindent: start ignoring
#define DOW_SHADOWM_TALK_EVENT _NUM
    # wmlxgettext: [event]
    [/event]
    [event]
        name="shadowm_talk_{_NUM}"
    # wmlxgettext: [/event]
#enddef
    # wmlindent: stop ignoring
    # wmllint: unbalanced-off

    [event]
        name=start

        [message]
            speaker=narrator
            image=wesnoth-icon.png
            message= _ "A cold gust of wind blows..."
        [/message]

        {MYSTERIOUS_VOICE ( _ "Galas...")}

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

        #
        # End of start event.
        #

        {DOW_SHADOWM_TALK_EVENT 1}

        {MYSTERIOUS_VOICE ( _ "Galas.")}

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Galas
            message= _ "Is anybody there?"
        [/message]

        {MYSTERIOUS_VOICE ( _ "Only the darkness within your heart, Galas.")}

        {DOW_SHADOWM_TALK_EVENT 2}

        {MYSTERIOUS_VOICE ( _ "The darkness, and the fear... They feed me, Galas. I grow stronger with them.")}

        {DOW_SHADOWM_TALK_EVENT 3}

        {MYSTERIOUS_VOICE ( _ "You cannot escape the darkness within your heart, and thus you cannot escape us. And your friend, the sorceress... neither could she.")}

        {MYSTERIOUS_VOICE ( _ "And you will suffer the same fate as she if you refuse our generous offer.")}

        [remove_event]
            id=shadowm_talk_controller
        [/remove_event]

        {CLEAR_VARIABLE shadowm_talk}
    [/event]

#define DOW_ENEMIES_NOT_DEFEATED
    [have_unit]
        canrecruit=yes
        [filter_side]
            [enemy_of]
                side=1
            [/enemy_of]
        [/filter_side]
    [/have_unit]
#enddef

#define DOW_ENEMIES_DEFEATED
    [not]
        {DOW_ENEMIES_NOT_DEFEATED}
    [/not]
#enddef

#define DOW_NOTE_ONLY_ON_FIRST_TURN
    {OBJECTIVE_NOTE_SHOW_IF ({VARIABLE_NUMERICAL_EQUALS turn_number $initial_turn})}
#enddef

#define DOW_NOTE_ONLY_ON_GAMEPLAY_TURNS
    {OBJECTIVE_NOTE_SHOW_IF ({VARIABLE_NUMERICAL_GREATER_THAN turn_number $initial_turn})}
#enddef

    {FIRE_EVENT_ON_STUMBLE_UPON "begin regular gameplay" side=10}

    [event]
        name=begin regular gameplay

        [remove_terrain_overlays]
            terrain=*^Xo
        [/remove_terrain_overlays]

        [redraw][/redraw]

        [capture_village]
            side=1
            x=1-100
            y=1-11
            [or]
                x,y=$goal_loc.x,$goal_loc.y
                radius=6
            [/or]
        [/capture_village]

        {MOVE_UNIT id=Galas $goal_loc.x $goal_loc.y}
        [+move_unit]
            check_passability=no
        [/move_unit]

        {VARIABLE initial_turn $turn_number}

        [modify_turns]
            value=$dow_real_turn_limit
        [/modify_turns]

        {REMOVE_IMAGE $goal_loc.x $goal_loc.y}

        #
        # Restore heroes.
        #

        [modify_unit]
            [filter]
                side=10
            [/filter]
            side=1
        [/modify_unit]

        [unstore_unit]
            variable=galas_backup_store
            find_vacant=no
            x,y=$goal_loc.x,$goal_loc.y
        [/unstore_unit]

        {CLEAR_VARIABLE galas_backup_store,goal_loc,dow_real_turn_limit}

        #
        # Re-enable AI sides.
        #

        [modify_side]
            [filter_side]
                [not]
                    side=1,10
                [/not]
            [/filter_side]
            controller=ai
        [/modify_side]

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

        [redraw]
            side=1
        [/redraw]

        {OBJECTIVES (
            {OBJECTIVE_VICTORY ( _ "Sneak past enemy lines and make it to the south edge of the map with Galas, Elynia or Mal Keshar")}
            {OBJECTIVE_BONUS           ( _ "Optional: Defeat all enemy leaders")}
            {OBJECTIVE_SHOW_IF         ({DOW_ENEMIES_NOT_DEFEATED})}
            {OBJECTIVE_BONUS_COMPLETED ( _ "Optional: Defeat all enemy leaders")}
            {OBJECTIVE_SHOW_IF         ({DOW_ENEMIES_DEFEATED})}

            {OBJECTIVE_DEFEAT  ( _ "Death of Galas")}
            {OBJECTIVE_DEFEAT  ( _ "Death of Elynia")}
            {OBJECTIVE_DEFEAT  ( _ "Death of Mal Keshar")}
            {OBJECTIVE_DEFEAT  ( _ "Death of Erathan")}
            {OBJECTIVE_DEFEAT  ( _ "Losing both ally leaders")}

            {TURNS_RUN_OUT}

            {OBJECTIVE_CARRYOVER}
            {OBJECTIVE_CARRYOVER_SHOW_IF ({DOW_ENEMIES_DEFEATED})}
            {OBJECTIVE_CARRYOVER_NO_BONUS}
            {OBJECTIVE_CARRYOVER_SHOW_IF ({DOW_ENEMIES_NOT_DEFEATED})}

            {OBJECTIVE_NOTE ( _ "After this scenario, you will only be able to recruit undead units (except Dark Adepts) and faeries")}
            {OBJECTIVE_NOTE ( _ "Any veteran units that you do not recall during this scenario will be permanently lost")}
            {OBJECTIVE_NOTE ( _ "You may recall or recruit elves only during the first gameplay turn (turn $initial_turn)")}
            {DOW_NOTE_ONLY_ON_FIRST_TURN}
            {OBJECTIVE_NOTE ( _ "You may not recall or recruit elvish units")}
            {DOW_NOTE_ONLY_ON_GAMEPLAY_TURNS}
        )}

        {REPLACE_SCENARIO_MUSIC "battle.ogg"}
        {APPEND_MUSIC           "the_city_falls.ogg"}
        {APPEND_MUSIC           "casualties_of_war.ogg"}
        {APPEND_MUSIC           "loyalists.ogg"}
        {APPEND_MUSIC           "western_theme2.ogg"}

        [message]
            speaker=Zirshe
            message= _ "A large Chaos battalion has set up camp near the mountains. It is paramount that we block their advance here. Charge!"
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "So, what are we going to do? Run across the battlefield with wild abandon?"
        [/message]

        [message]
            speaker=Galas
            message= _ "Well, our priority is to sneak past the enemy lines and make it to the mountain pass. We are not meant to actively participate in this battle, but helping our allies on our way to enemy territory would be highly beneficial to everyone."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Let us see if we can... The followers of Uria seem to have sent more battle-hardened troops this time."
        [/message]

        [message]
            speaker=Galas
            message= _ "No matter. I trust that you two can handle it."
        [/message]

        [event]
            name=side 3 turn end

            [fire_event]
                name=mysterious invitation
            [/fire_event]
        [/event]

        [event]
            name=new turn

            #
            # Remove the ability to recruit or recall elves.
            #

            [modify_side]
                side=1
                recruit="Dark Adept,Faerie Sprite,Skeleton,Skeleton Archer,Skeleton Rider,Ghost,Vampire Bat,Walking Corpse"
            [/modify_side]

            [kill]
                side=1
                race=elf
                x,y=recall,recall
            [/kill]
        [/event]
    [/event]

    [event]
        name=mysterious invitation

        [message]
            speaker=Galas
            message= _ "And so it begins..."
        [/message]

        {MYSTERIOUS_VOICE ( _ "The beginning of your revenge, Galas? It would have been better for you to join us than setting off on this pointless journey that resulted in the sorceress’ death. Your people would have been safe under Uria’s protection.")}

        {MYSTERIOUS_VOICE ( _ "You cannot conceal your bloodlust from me, Galas. But there are better ways to satiate this desire. If you come to me, if you bring the Lady of Light to me... Uria might yet give your people a chance.")}

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

        {MYSTERIOUS_VOICE ( _ "You know where to find me. I eagerly await your answer, Galas.")}

        [message]
            speaker=Elynia
            message= _ "Galas? Is something the matter? You seem pale."
        [/message]

        [message]
            speaker=Galas
            message= _ "No... (<i>shakes head</i>) no, not really."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Galas, if you feel weak or ill, or need to rest, just remember that I am here to help you."
        [/message]
    [/event]

    [event]
        name=enemies defeated

        [show_objectives][/show_objectives]
    [/event]

    [event]
        name=side 2 turn 7 # turn 5 + 2

        [message]
            speaker=Mal Keshar
            message= _ "This is such a disgrace. Why am I even allowing this elf to command me like a minion when <b>I</b> should be the one ordering his corpse around. Elynia! Help me! You have the power to put an end to my suffering!"
        [/message]

        [message]
            speaker=Elynia
            message= _ "Normally, I would be happy to oblige. But as it turns out, Galas is quite fond of you for reasons I can’t even begin to understand. He would not be pleased if he found out I turned his necromancer friend into a steaming pile of ash."
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Pah, you sound so sure of yourself. Hear me, then: some day, this kid will bite the dust, and I will be free to do as I wish. Then we shall duel to the death and show the world that not even the Lady of Light can banish Mal Keshar the Eternal from Irdya. Just you wait."
        [/message]
    [/event]

    [event]
        name=side 2 turn 7 end

        [message]
            speaker=Elynia
            message= _ "Oh, please. It’s not as if Anlindë cast some sort of curse on you that compels you to obey and follow Galas as long as he lives... right?"
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "... right."
        [/message]
    [/event]

#define DOW_IS_ENEMY
    [filter_side]
        [enemy_of]
            side=1
        [/enemy_of]
        [not]
            side=8,9
        [/not]
    [/filter_side]
#enddef

#define DOW_FIRE_EVENT_CHANCE _CHANCE _EVENT
    {VARIABLE_RANDOM temp_event_chance 0..100}

    [if]
        {VARIABLE_NUMERICAL_LESS_THAN_OR_EQUAL temp_event_chance {_CHANCE}}
        [then]
            [fire_event]
                name={_EVENT}
                [primary_unit]
                    x,y=$x1,$y1
                [/primary_unit]
                # We don't need the second unit for the use cases below -- which, in fact,
                # don't have a second unit at all.
                #[secondary_unit]
                #    x,y=$x2,$y2
                #[/secondary_unit]
            [/fire_event]
        [/then]
    [/if]

    {CLEAR_VARIABLE temp_event_chance}
#enddef

#define DOW_FIRE_EVENT_CHANCE_SLF _CHANCE _EVENT _SLF
    [if]
        [have_unit]
            x,y=$x1,$y1
            [filter_location]
                {_SLF}
            [/filter_location]
        [/have_unit]
        [then]
            {DOW_FIRE_EVENT_CHANCE {_CHANCE} {_EVENT}}
        [/then]
    [/if]
#enddef

    #
    # Village pillaging logic.
    #

    [event]
        name=capture
        first_time_only=no
        [filter]
            {DOW_IS_ENEMY}
        [/filter]

        {DOW_FIRE_EVENT_CHANCE 20 ("pillage village")}
    [/event]

    [event]
        name=pillage village
        #first_time_only=yes

        [message]
            side=$unit.side
            canrecruit=yes
            scroll=no
            message= _ "Leave nothing standing! Burn the heathens alive!"
        [/message]

        [message]
            race=aragwaith
            scroll=no
            message= _ "They are burning the villages of our people! This atrocity will not go unpunished. Don’t bother taking prisoners, just crush them all!"
        [/message]
    [/event]

#define DOW_BURN_SOUNDS _DELAY
    [sound]
        name="torch.ogg"
    [/sound]

    [delay]
        time={_DELAY}
    [/delay]

    [sound]
        name="wose-die.ogg"
    [/sound]
#enddef

    [event]
        name=pillage village
        first_time_only=no

        {DOW_BURN_SOUNDS 200}

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

        {ADD_GOLD $unit.side 16 32 48}

        [redraw][/redraw]
    [/event]

    #
    # Terrain destruction logic.
    #

#define DOW_GRASSLAND_DAMAGE_CASE _CASE _REPLACEMENT
    [if]
        {VARIABLE_LEXICAL_CONTAINS loc.terrain {_CASE}^}
        [then]
            [terrain]
                x,y=$loc.x,$loc.y
                terrain={_REPLACEMENT}
                layer=base
            [/terrain]
        [/then]
    [/if]
#enddef

    [event]
        name=damage grassland
        first_time_only=no

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

        [store_locations]
            terrain=G*^*
            [and]
                x,y=$x1,$y1
                radius=1
            [/and]
            variable=locs
        [/store_locations]

        [foreach]
            array=locs
            variable=loc
            [do]
                {DOW_GRASSLAND_DAMAGE_CASE Gg  Gs} # Green -> semi-dry
                {DOW_GRASSLAND_DAMAGE_CASE Gs  Gd} # Semi-dry -> dry
                {DOW_GRASSLAND_DAMAGE_CASE Gll Gd} # Leafy -> dry
                {DOW_GRASSLAND_DAMAGE_CASE Gd  Re} # Dry -> regular dirt
            [/do]
        [/foreach]

        {CLEAR_VARIABLE locs}
    [/event]

    [event]
        name=destroy windmill
        first_time_only=no

        {DOW_BURN_SOUNDS 200}

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

    [event]
        name=destroy roads
        first_time_only=no

        [terrain]
            [and]
                terrain=Rd,Rp,Rd^*,Rp^*
                [and]
                    x,y=$x1,$y1
                    radius=1
                [/and]
            [/and]
            terrain=Rd
            layer=base
        [/terrain]
    [/event]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            {DOW_IS_ENEMY}
        [/filter]

        {DOW_FIRE_EVENT_CHANCE_SLF 60 ("damage grassland") terrain=G*,G*^*,*^Gvs,*^Efm,!,*^F*}

        {DOW_FIRE_EVENT_CHANCE_SLF 75 ("destroy windmill") terrain=*^Wm}

        {DOW_FIRE_EVENT_CHANCE_SLF 33 ("destroy roads")    terrain=Rd,Rp,Rd^*,Rp^*}

        [redraw][/redraw]
    [/event]

    #
    # Enemies burn forests (100% chance).
    #

    [event]
        name=moveto
        first_time_only=no
        [filter]
            {DOW_IS_ENEMY}

            [filter_location]
                terrain=*^F*
            [/filter_location]
        [/filter]

        [terrain]
            [and]
                terrain=*^F*
                [and]
                    x,y=$x1,$y1
                    radius=1
                [/and]
            [/and]
            terrain=Rb
        [/terrain]

        [redraw][/redraw]

        [fire_event]
            name=discuss burning forests
            [primary_unit]
                x,y=$x1,$y1
            [/primary_unit]
        [/fire_event]
    [/event]

    [event]
        name=discuss burning forests

        [message]
            #
            # Try to have this line be read by a faerie other than Elynia.
            #
            race=faerie
            [not]
                id=Elynia
            [/not]
            [or]
                id=Elynia
            [/or]
            scroll=no
            message= _ "Those monsters are burning down the forest! Why would people do this in a world where all verdant land is more precious than gold?"
        [/message]

        [message]
            speaker=Galas
            scroll=no
            message= _ "We shall make them pay dearly for this."
        [/message]
    [/event]

    #
    # Moving south of the river.
    #

    [event]
        name=moveto
        [filter]
            id=Galas,Elynia,Mal Keshar
            x=1-100
            y=40-53
        [/filter]

        [allow_undo][/allow_undo]

        [message]
            speaker=unit
            message= _ "We are almost there..."
        [/message]
    [/event]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            id=Galas,Elynia,Mal Keshar
            x=1-100
            y=54
        [/filter]
        [filter_condition]
            {DOW_ENEMIES_NOT_DEFEATED}
        [/filter_condition]

        [message]
            speaker=Elynia
            message= _ "Galas, are you sure we should proceed south before finishing the battle here?"
        [/message]

        [message]
            speaker=Galas
            message= _ "Hm..."
            [option]
                label= _ "You are right, it would not be good form for us to leave our allies to fight on their own."
                [command]
                    [message]
                        speaker=Galas
                        message= _ "We shall stay for a little longer."
                    [/message]
                [/command]
            [/option]
            [option]
                label= _ "Time is of the essence. We shall proceed south as swiftly as we may."
                [command]
                    [message]
                        speaker=Elynia
                        message= _ "Very well, then."
                    [/message]

                    {ENDLEVEL_VICTORY no}
                [/command]
            [/option]
        [/message]
    [/event]

    [event]
        name=moveto
        [filter]
            id=Galas,Elynia,Mal Keshar
            x=1-100
            y=54
        [/filter]
        [filter_condition]
            {DOW_ENEMIES_DEFEATED}
        [/filter_condition]

        {ENDLEVEL_VICTORY yes}
    [/event]

    #
    # Ally leaders death.
    #
    [event]
        name=die
        [filter]
            canrecruit=yes
            [filter_side]
                [allied_with]
                    side=1
                [/allied_with]
            [/filter_side]
        [/filter]
        [filter_condition]
            [not]
                [have_unit]
                    canrecruit=yes
                    [filter_side]
                        [allied_with]
                            side=1
                        [/allied_with]
                    [/filter_side]
                    [not]
                        x,y=$x1,$y1
                    [/not]
                [/have_unit]
            [/not]
        [/filter_condition]

        [message]
            speaker=Galas
            message= _ "The alliance forces are being decimated! We must fall back and call for reinforcements now, otherwise the legions of Uria will surely lay waste to the Aragwaith country!"
        [/message]

        {ENDLEVEL_DEFEAT}
    [/event]

    #
    # Shaxthal-related events.
    #

    [event]
        name=recruit
        [filter]
            race=shaxthal
        [/filter]

        #
        # Defer talk event until the AI side's turn ends so that there are
        # hopefully a few more Shaxthal units in sight.
        #
        [event]
            name=side turn end
            delayed_variable_substitution=no

            [fire_event]
                name=shaxthal sighted
                [primary_unit]
                    x,y=$x1,$y1
                [/primary_unit]
            [/fire_event]
        [/event]
    [/event]

    [event]
        name=shaxthal sighted

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

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Zirshe
            message= _ "Look out! They brought numbers of some sort of metallic war-beast with them!"
        [/message]

        [message]
            speaker=Elynia
            message= _ "What in the world are those things? Wait, could it be those creatures Lord Torancyn mentioned?"
        [/message]

        [message]
            speaker=Erathan
            message= _ "Indeed. ‘Shaxthals’, as the enemy calls them. The name supposedly means ‘Invincibles’ in some dead language. Rumor has it that all settlements upon which they are unleashed fall in a matter of hours, leaving no survivors; thus their existence remains one of the best guarded secrets of the Chaos Empire."
        [/message]

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

    [event]
        name=attacker hits
        [filter]
            race=shaxthal
        [/filter]
        [filter_attack]
            name=energy shock
        [/filter_attack]

        [fire_event]
            name=shaxthal ranged attack
            [primary_unit]
                x,y=$x1,$y1
            [/primary_unit]
            [secondary_unit]
                x,y=$x2,$y2
            [/secondary_unit]
        [/fire_event]
    [/event]

    [event]
        name=defender hits
        [filter_second]
            race=shaxthal
        [/filter_second]
        [filter_second_attack]
            name=energy shock
        [/filter_second_attack]

        [fire_event]
            name=shaxthal ranged attack
            [primary_unit]
                x,y=$x2,$y2
            [/primary_unit]
            [secondary_unit]
                x,y=$x1,$y1
            [/secondary_unit]
        [/fire_event]
    [/event]

    [event]
        name=shaxthal ranged attack

        [message]
            # May match low level undead, this is intentional.
            speaker=second_unit
            message= _ "Aiyeee!!!" # wmllint: no spellcheck
        [/message]

        [message]
            speaker=Galas
            scroll=no
            message= _ "What was that? I have never seen anything like it before!"
        [/message]
    [/event]

    [event]
        name=die
        [filter]
            type=Skeleton Archer,Bone Shooter,Banebow,Skeleton,Deathblade,Revenant,Draug,Death Baron,Death Knight,Skeleton Rider,Bone Knight
        [/filter]
        [filter_second]
            race=shaxthal
        [/filter_second]

        [message]
            speaker=Mal Keshar
            scroll=no
            message= _ "Ugh. Galas, what the hell? You ought to know better than this! Do you have any idea how much it costs me to summon these skeleton warriors?!"
        [/message]

        [message]
            speaker=Galas
            scroll=no
            message= _ "You are right, that wasn’t my brightest move. Sorry."
        [/message]
    [/event]

    [event]
        name=die
        [filter]
            race=shaxthal
        [/filter]

        [if]
            [have_unit]
                x,y=$x2,$y2
                race=bats,undead
                [not]
                    type=Lich
                [/not]
            [/have_unit]
            [then]
                [fire_event]
                    name=shaxthal fell
                    [primary_unit]
                        id=Mal Keshar
                    [/primary_unit]
                [/fire_event]
            [/then]
            [else]
                [fire_event]
                    name=shaxthal fell
                    [primary_unit]
                        x,y=$x2,$y2
                    [/primary_unit]
                [/fire_event]
            [/else]
        [/if]
    [/event]

    [event]
        name=shaxthal fell

        [message]
            speaker=unit
            female_message= _ "female^Well, so much for the ‘invincible’ part. But what is this? I have managed to remove one of its armor plates and there is living flesh inside, although it smells much like a rotting corpse... So it is a living creature after all! But it seems completely unlike anything I have ever seen. What kind of foul sorcery is this?"
            male_message= _ "Well, so much for the ‘invincible’ part. But what is this? I have managed to remove one of its armor plates and there is living flesh inside, although it smells much like a rotting corpse... So it is a living creature after all! But it seems completely unlike anything I have ever seen. What kind of foul sorcery is this?"
        [/message]

        [message]
            id=Erathan
            [not]
                x,y=$x1,$y1
            [/not]
            [or]
                id=Ivancyn
            [/or]
            message= _ "I haven’t the slightest idea. Nobody from our country has ever seen one of these abominations in the flesh. It’s very likely that they specifically created them to serve as the Empire’s living weapons. I shudder to think there might be thousands of them en route to our lands..."
        [/message]

        [message]
            speaker=Elynia
            message= _ "I simply cannot begin to fathom the sort of twisted mind that would create a new form of life for the express purpose of slaughtering whole civilizations. These are slaves!"
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Hm. Their flesh begins to disintegrate once you breach their metallic exteriors. And it seems they don’t even have a skeleton inside, much like insects. Pah! What a waste of time. I can’t work with this!"
        [/message]

        [message]
            speaker=Elynia
            message= _ "I would not let you anyway."
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Oh, Elynia, you truly are the life of the party."
        [/message]
    [/event]

    #
    # Enemy leader deaths.
    #

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

        [message]
            speaker=Ben
            message= _ "Your boldness has sealed your doom, elf. Even if you manage to survive the trials that await you at the Pass of Ilgrid, the Master and the Warlord will ensure you pay dearly for your insolence, yes..."
        [/message]

        [message]
            speaker=Galas
            # po: Again, the warlord's gender has not revealed to Galas & co.
            # po: yet, at this point in the story.
            message= _ "The Warlord is... alive? Where is he?!"
        [/message]

        [message]
            speaker=Ben
            message= _ "Heh, heh, I am not telling you heathens anything... May Uria bless the souls of the fallen!"
        [/message]
    [/event]

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

        [message]
            speaker=Galas
            message= _ "So he committed suicide. The coward."
        [/message]

        [message]
            speaker=Elynia
            message= _ "I suppose it comes with the territory of worshiping demon goddesses that instigate death and destruction on a world scale. The things I have heard from the northerners’ spies are truly horrifying."
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Such as?"
        [/message]

        [message]
            speaker=Elynia
            message= _ "Binding the souls of fallen powerful demons to the bodies of other creatures like humans, orcs, even beasts; pulling the spirits of deceased warriors of past ages back into this world; torturing and experimenting on large numbers of all manner of living creatures and feeding upon their energy... Galas?"
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Perhaps he would prefer to not be reminded of his comrades’ fate back at your eponymous valley, don’t you think?"
        [/message]

        [message]
            speaker=Elynia
            message= _ "Yes... that was highly improper of me. I am sorry, Galas."
        [/message]
    [/event]

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

        [message]
            speaker=Zulthor
            message= _ "Argh, such a shameful death! I beg your mercy, Uria..."
        [/message]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Karin-Ilyanai
        [/filter]

        [message]
            speaker=Karin-Ilyanai
            # po: The Voice of Uria is the Chaos Emperor, and the Fire is the Warlord
            message= _ "Oooooh, striking me down hardly makes a difference in the grand scheme of things. May the Voice and the Fire of Uria have mercy on your pitiful souls..."
        [/message]
    [/event]

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

        [message]
            speaker=Obandur
            message= _ "Yechnagoth shall feast on your souls some day, you unworthy fools... some day... some... day..."
        [/message]
    [/event]

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

        [message]
            speaker=Mal Keshar
            message= _ "How about we make sure to cut their windpipes open from now on so they cannot give these irritating cookie-cutter dying speeches?"
        [/message]
    [/event]

    [event]
        name=victory

        #
        # Set the new recruit list for the next scenarios.
        #
        [modify_side]
            side=1
            recruit="Faerie Sprite,Skeleton,Skeleton Archer,Skeleton Rider,Ghost,Vampire Bat,Walking Corpse"
        [/modify_side]

        #
        # Clear the whole recall list.
        #
        [kill]
            side=1
            x,y=recall,recall
        [/kill]

        [role]
            role=talking_elf
            race=elf
            [not]
                id=Galas
            [/not]
            side=1
        [/role]

        [if]
            [have_unit]
                role=talking_elf
            [/have_unit]
            [then]
                [message]
                    role=talking_elf
                    message= _ "Galas, sir, we can’t just say farewell and let you go on alone. Even though you have stepped down, we have followed and served you for so long that it doesn’t feel right to part ways here."
                [/message]

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

                [message]
                    speaker=Elynia
                    message={ASIDE ( _ "Galas, this is supposed to be an <b>infiltration</b> mission. It would be unwise to let your men come with us. We can’t even guarantee our own survival!")}
                [/message]

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

                [message]
                    role=talking_elf
                    message= _ "My lord, we understand well the risks involved in this mission. This is not a choice we made lightly. But you will need all the help you can get to reach the Empire’s capital alive. Please! Let us accompany you one last time."
                [/message]

                [delay]
                    time=750
                [/delay]

                [message]
                    speaker=Galas
                    message= _ "(<i>chuckles</i>) I doubt I will ever convince you otherwise. Very well, you may come with us if you wish. But understand that the odds are not in our favor; it’s likely you will never see your loved ones again."
                [/message]

                [message]
                    role=talking_elf
                    message= _ "We know, sir, and they do as well. But hasn’t it always been this way since Uria’s followers first set foot in our valley?"
                [/message]

                [message]
                    speaker=Galas
                    message= _ "Perhaps—"
                [/message]
            [/then]
        [/if]

        {MYSTERIOUS_VOICE ( _ "You are bold for coming to my domain, Galas. But, how long will it be before you succumb to the temptation of the power of Uria?")}

        [message]
            speaker=Galas
            message= _ "Only time can tell... what fate has in store for us..."
        [/message]

        {CLEAR_VARIABLE initial_turn,shadowm_talk}
    [/event]
[/scenario]

#undef DOW_SHADOWM_TALK_EVENT
#undef DOW_ENEMIES_NOT_DEFEATED
#undef DOW_ENEMIES_DEFEATED
#undef DOW_NOTE_ONLY_ON_FIRST_TURN
#undef DOW_NOTE_ONLY_ON_GAMEPLAY_TURNS
#undef DOW_IS_ENEMY
#undef DOW_FIRE_EVENT_CHANCE
#undef DOW_FIRE_EVENT_CHANCE_SLF
#undef DOW_BURN_SOUNDS
#undef DOW_GRASSLAND_DAMAGE_CASE

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


#textdomain wesnoth-Invasion_from_the_Unknown

[scenario]
    id=17_Voice_of_the_Armageddon
    name= _ "Voice of the Armageddon"
    {MAP 17_Voice_of_the_Armageddon.map}
    {TURNS 25 24 23}
    next_scenario=18_Ashes_of_Wesmere

    {SCENARIO_MUSIC       "climactic_contemplation.ogg"}
    {EXTRA_SCENARIO_MUSIC "breaking_the_chains.ogg"}

    {LONGDARK1}

    {SHAXTHAL_SET_SURFACE_VARIATIONS_FLAG}

    {STORYTXT_VOICE_OF_THE_ARMAGEDDON}

    {DEATHS_ACT_3}

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

        shroud=yes

        {GOLD 180 170 160}
        {INCOME 5 5 4}

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

    # Boss
    [side]
        side=2
        team_name=foes
        user_team_name= _ "team_name^Chaos Empire"
        {CHAOS_FLAG}
        color=gold

        hidden=yes
        {NO_ECONOMY}

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

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

        canrecruit=yes
        type=Armageddon Imp
        id=Kalazar
        name= _ "Kalazar"
        facing=ne
        {IS_BOSS}
        [modifications]
            {TRAIT_STRONG}
            {TRAIT_RESILIENT}
            {BOSS_BOOST 60% 2 0 2 0}
        [/modifications]

#ifndef EASY
        [unit]
            x,y=20,32
            type=Gutwrencher Imp
            name= _ "Pythias"
            facing=ne
            [modifications]
                {TRAIT_DIM}
                {TRAIT_STRONG}
            [/modifications]
        [/unit]
#endif

        [unit]
            x,y=21,34
            type=Blood Imp
            name= _ "Beras"
            facing=ne
            [modifications]
                {TRAIT_INTELLIGENT}
                {TRAIT_SLOW}
            [/modifications]
        [/unit]
    [/side]

    [side]
        side=3
        team_name=foes
        user_team_name= _ "team_name^Chaos Empire"
        {CHAOS_FLAG}

        {GOLD 180 190 200}
        recruit=Skeleton,Ghost,Skeleton Archer,Ghoul,Demon

        canrecruit=yes
        type=Necromancer
        id=Mal Laraghor
        name= _ "Mal Laraghor"
        facing=nw
        [modifications]
            {TRAIT_STRONG}
            {TRAIT_QUICK}
        [/modifications]

        {SIDE_GENERIC_GUARD (Chaos Longbowman)         24 29} {FACING ne}
        {SIDE_GENERIC_GUARD (Chaos Longbowman)         27 31} {FACING nw}

        {SIDE_GENERIC_GUARD (Shaxthal Protector Drone) 14 35}
        {SIDE_GENERIC_GUARD (Shaxthal Protector Drone) 20 38}
#ifndef EASY
        {SIDE_GENERIC_GUARD (Shaxthal Rayblade)        16 38}

        {SIDE_GENERIC_GUARD (Shaxthal Protector Drone) 34 21}
        {SIDE_GENERIC_GUARD (Shaxthal Rayblade)        26 16}
#endif
    [/side]

    # wmllint: validate-off
    [side]
        side=4
        team_name=foes
        user_team_name= _ "team_name^Chaos Empire"
        {CHAOS_FLAG}

        {GOLD 150 170 200}
        recruit=Elvish Warrior Spirit,Necrophage,Soulless

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

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

        canrecruit=yes
        facing=ne
        # wmllint: recognize Mal Hekuba
        {CHARACTER_STATS_MAL_HEKUBA}

        {SIDE_GENERIC_GUARD (Ghast) 18 32} {FACING ne}
        {SIDE_GENERIC_GUARD (Ghast) 23 35} {FACING ne}

        {SIDE_GENERIC_GUARD (Elvish Forefather)             12 37} {FACING se}
        {SIDE_GENERIC_GUARD ({DIFF Wraith Spectre Spectre}) 15 32} {FACING se}
        {SIDE_GENERIC_GUARD (Elvish Forefather)             25 36} {FACING nw}
        {SIDE_GENERIC_GUARD ({DIFF Wraith Spectre Spectre}) 23 39} {FACING nw}
    [/side]
    # wmllint: validate-on

    [side]
        side=5
        team_name=foes
        user_team_name= _ "team_name^Wild Animals"
        color=black

        no_leader=yes
        hidden=yes
        {NO_ECONOMY}

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

        {SIDE_GENERIC_UNIT (Shaxthal Thunderbird)  9 25}
        {SIDE_GENERIC_UNIT (Shaxthal Thunderbird)  3 30}
        {SIDE_GENERIC_UNIT (Shaxthal Thunderbird) 36 38}
        {SIDE_GENERIC_UNIT (Shaxthal Thunderbird) 37 43}
        {SIDE_GENERIC_UNIT (Shaxthal Thunderbird) 36 11}
        {SIDE_GENERIC_UNIT (Shaxthal Thunderbird)  3  3}

        {SIDE_GENERIC_UNIT (Shaxthal Razorbird)  3 12}
        {SIDE_GENERIC_UNIT (Shaxthal Razorbird) 26 11}
        {SIDE_GENERIC_UNIT (Shaxthal Razorbird) 14 21}
        {SIDE_GENERIC_UNIT (Shaxthal Razorbird) 39  3}
    [/side]

    {NPC_BIRD_BEHAVIOR_WHOLE_MAP 5}

    {STARTING_VILLAGES_ALL 4}
    {STARTING_VILLAGES 1 5}
    {STARTING_VILLAGES 3 6}

    [event]
        name=prestart

        # We need to disable these sides here, otherwise their leaders are not
        # spawned by the game if controller=null is set in the side defs.
        [modify_side]
            side=2,4
            controller=null
        [/modify_side]

        #
        # Recall heroes
        #

        # wmllint: recognize Elynia
        {RECALL_ELYNIA}
        # wmllint: recognize Mal Keshar
        {RECALL_MAL_KESHAR}
        # wmllint: recognize Erathan
        {RECALL_ERATHAN}
        # wmllint: recognize Igor
        {RECALL_IGOR}

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

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

            {TURNS_RUN_OUT}

            {OBJECTIVE_CARRYOVER}
        )}
    [/event]

    [event]
        name=start

        [message]
            speaker=narrator
            image=wesnoth-icon.png
            message= _ "The air trembles as a loud roar echoes throughout the mountain pass."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Have any of you heard anything like that before?"
        [/message]

        [message]
            speaker=Galas
            message= _ "No, not really. Whatever it is, it must be enormous. Be on your keenest guard, everyone."
        [/message]
    [/event]

    {FIRE_EVENT_ON_STUMBLE_UPON "gauntlet start" (id=Mal Laraghor)}

    [event]
        name=gauntlet start

        [message]
            speaker=Mal Laraghor
            message= _ "There they are, those foul miscreants. You know what to do. Crush them! Crush them all!"
        [/message]
    [/event]

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

        [message]
            speaker=Mal Laraghor
            message= _ "Damn you, pathetic sub-creatures— Noooo!!!"
        [/message]
    [/event]

    {FIRE_EVENT_ON_STUMBLE_UPON "boss start" (side=2,4)}

    [event]
        name=boss start

        {LOCK_VIEW}

        # Re-enable both Hekuba's and the boss's sides.
        [modify_side]
            side=2,4
            controller=ai
        [/modify_side]

        #
        # TODO: Need actual giant footsteps instead of this.
        #
        {QUAKE rumble.ogg}

        [message]
            speaker=Galas
            message= _ "Only a creature heavy as a mountain would make such loud steps. Wait. Is that... Look, over there!"
        [/message]

        [remove_shroud]
            side=1
            [filter]
                id=Kalazar
            [/filter]
            radius=8
            [or]
                [filter]
                    id=Mal Hekuba
                [/filter]
                radius=6
            [/or]
        [/remove_shroud]

        {BOSS_AMBIENTANCE}

        [redraw]
            side=1
        [/redraw]

        [scroll_to_unit]
            id=Kalazar
        [/scroll_to_unit]

        [delay]
            time=1000
        [/delay]

        [message]
            speaker=Igor
            scroll=no
            message= _ "Eek! It’s a giant! A demon giant!"
        [/message]

        [message]
            speaker=Mal Hekuba
            scroll=no
            message= _ "Oh my, what do we have here?"
        [/message]

        [scroll_to_unit]
            id=Mal Hekuba
        [/scroll_to_unit]

        [message]
            speaker=Mal Hekuba
            message= _ "It’s none other than the elves’ popular comedy trio: the young lord, his pet lich, and the Lady of Light. I see you have finally decided to accept our invitation. How considerate of you. Trust me, our Master is dying to see your faces."
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Enough with the grating quips, you pathetic zealot. Did you not learn to not trifle with us after last time?"
        [/message]

        [message]
            speaker=Mal Hekuba
            message= _ "Me? Pathetic, you say? Ho! You are but a stain on the long line of grand necromancers who have ever walked the land. Look at yourself — allying with these pitiful vermin. For what purpose? What has possessed you to defer to the will of Xia’el’s children?"
        [/message]

        [delay]
            time=750
        [/delay]

        [scroll_to_unit]
            id=Mal Keshar
        [/scroll_to_unit]

        [message]
            speaker=Mal Hekuba
            scroll=no
            message= _ "How can a magnificent being such as you have fallen so low as to turn himself into a mockery of the legend he was in the times before Naia? How can the universe allow such a disgrace to even exist?"
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Shut up! I am not a mindless servant following the orders of a cult of degenerates worshiping a deceased goddess. I am my own person, I have chosen my own fate, and, before you know it, the entirety of Irdya shall kneel before me... starting with you!"
        [/message]

        [message]
            speaker=Galas
            message= _ "Let us put an end to this folly. Take that foul behemoth down and capture the dark priest!"
        [/message]

        {UNLOCK_VIEW}

        [event]
            name=new turn

            [fire_event]
                name=mysterious voice
            [/fire_event]
        [/event]
    [/event]

    [event]
        name=mysterious voice

        [message]
            speaker=Mal Hekuba
            message= _ "Oh Galas, sweet, little misguided Galas. Don’t you feel his power around you? How can you expect to strike him down when he is already peering into your head?"
        [/message]

        [message]
            speaker=Galas
            message= _ "I don’t know what you are talking about."
        [/message]

        [message]
            speaker=Mal Hekuba
            message= _ "You only waste your time fighting his power. Do you not know why he is called the Voice of Uria? Do you not know what fate awaits those fools who choose to ignore his sacred words?"
        [/message]

        [message]
            speaker=Elynia
            message= _ "Galas, what is this lich talking about?"
        [/message]

        [message]
            speaker=Galas
            message= _ "I have no idea. It’s just more of his religious bravado."
        [/message]
    [/event]

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

        [message]
            speaker=Kalazar
            message= _ "Master, nooooooooooo... (gurgle)"
        [/message]
    [/event]

    [event]
        name=die
        [filter]
            id=Kalazar
        [/filter]
        [filter_condition]
            [have_unit]
                id=Mal Hekuba
            [/have_unit]
        [/filter_condition]

        [message]
            speaker=Elynia
            message= _ "We still have the lich left to deal with!"
        [/message]
    [/event]

    #
    # Mal Hekuba escape logic.
    #

#define VOTA_GO_BYEBYE
    [fire_event]
        name=hekuba escapes
    [/fire_event]
#enddef

#define VOTA_BYEBYE_COND _UNIT_STORE
    [filter_condition]
        {VARIABLE_NUMERICAL_LESS_THAN_OR_EQUAL {_UNIT_STORE}.hitpoints "$(0.2 * ${_UNIT_STORE}.max_hitpoints)"}
    [/filter_condition]
#enddef

    [event]
        name=attacker_hits
        first_time_only=no
        [filter_second]
            id=Mal Hekuba
        [/filter_second]

        {VOTA_BYEBYE_COND second_unit}

        {VOTA_GO_BYEBYE}
    [/event]

    [event]
        name=defender hits
        first_time_only=no
        [filter]
            id=Mal Hekuba
        [/filter]

        {VOTA_BYEBYE_COND unit}

        {VOTA_GO_BYEBYE}
    [/event]

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

        {VOTA_GO_BYEBYE}
    [/event]

#define VOTA_SET_HEKUBA_OPACITY _VALUE
    [object]
        silent=yes
        [filter]
            id=Mal Hekuba
        [/filter]
        [effect]
            apply_to=image_mod
            replace="RC(magenta>purple)~O("+{_VALUE}+")"
        [/effect]
    [/object]
#enddef

    [event]
        name=hekuba escapes

        {LOCK_VIEW}

        [message]
            speaker=Mal Hekuba
            message= _ "Today is not the day you will see me fall, heretics. Send my regards to our Master... if you can get to the Heart alive, that is..."
        [/message]

        # Go dark.

        {FADE_STEP -32 25}

        {VOTA_SET_HEKUBA_OPACITY 0.9}
        {FADE_STEP -64 25}

        {VOTA_SET_HEKUBA_OPACITY 0.8}
        {FADE_STEP -96 25}

        {VOTA_SET_HEKUBA_OPACITY 0.7}
        {FADE_STEP -128 25}

        {VOTA_SET_HEKUBA_OPACITY 0.6}
        {FADE_STEP -160 25}

        {VOTA_SET_HEKUBA_OPACITY 0.5}
        {FADE_STEP -192 25}

        {VOTA_SET_HEKUBA_OPACITY 0.4}
        {FADE_STEP -224 25}

        {VOTA_SET_HEKUBA_OPACITY 0.3}
        {FADE_STEP -256 25}

        # Keep going in case we are on a daytime ToD with a positive lighting
        # color shift.

        [hide_unit][/hide_unit]

        {FADE_STEP -280 25}

        {FADE_STEP -340 25}

        {FADE_STEP -500 25}

        [kill]
            id=Mal Hekuba
        [/kill]

        [delay]
            time=750
        [/delay]

        {FADE_STEP -340 25}

        {FADE_STEP -280 25}

        [unhide_unit][/unhide_unit]

        {FADE_STEP -256 25}

        {FADE_STEP -224 25}

        {FADE_STEP -192 25}

        {FADE_STEP -160 25}

        {FADE_STEP -128 25}

        {FADE_STEP -96 25}

        {FADE_STEP -64 25}

        {FADE_STEP -32 25}

        {FADE_STEP 0 500}

        [message]
            speaker=Mal Keshar
            message= _ "Damn it all! He did it again! Why do you keep allowing this to happen, Galas!"
        [/message]

        [message]
            speaker=Galas
            message= _ "Hey, I am not the spell-caster here!"
        [/message]

        {UNLOCK_VIEW}
    [/event]

    [event]
        name=enemies defeated

        {ENDLEVEL_VICTORY yes}
    [/event]

    [event]
        name=victory

        # TODO
    [/event]
[/scenario]

#undef VOTA_GO_BYEBYE
#undef VOTA_BYEBYE_COND
#undef VOTA_SET_HEKUBA_OPACITY

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


#textdomain wesnoth-Invasion_from_the_Unknown

[scenario]
    id=18_Ashes_of_Wesmere
    name= _ "Ashes of Wesmere"
    {MAP 18_Ashes_of_Wesmere.map}
    {TURNS 34 32 30}
    next_scenario=19_Under_the_Sands
    victory_when_enemies_defeated=no

    {SCENARIO_MUSIC "suspense.ogg"}

    {LONGDARK1}
    {LONGDARK2}
    {LONGDARK3}
    {LONGDARK4}
    {SHORTDARK}
    {SHORTDARK}
    {SHORTDARK}
    {SHORTDARK}
    {SHORTDARK}
    {SHORTDARK}
    {SHORTDARK}
    {SHORTDARK}
    {SHORTDARK}
    {SHORTDARK}
    {SHORTDARK}

    {SHAXTHAL_SET_SURFACE_VARIATIONS_FLAG}

    {STORYTXT_WESMERE}

    {DEATHS_ACT_3}

    {SPAWN_CONTROLLER}

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

        shroud=no
        fog=yes

        {GOLD 150 140 130}
        {INCOME 12 9 8}

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

#define AOW_MOBILE_DRONE _TYPE _X _Y
    [unit]
        type={_TYPE}
        x={_X}
        y={_Y}
        random_traits=yes
        generate_name=yes
        random_gender=yes
        variation=surface
        upkeep=free
    [/unit]
#enddef

    # Drones - notably dumb
    [side]
        side=2
        team_name=enemies
        user_team_name= _ "team_name^Chaos Empire"
        {CHAOS_FLAG}

        hidden=yes
        no_leader=yes

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

#ifndef EASY
        {AOW_MOBILE_DRONE (Shaxthal Assault Drone) 29 19}
#endif
        {AOW_MOBILE_DRONE (Shaxthal Assault Drone) 11 42}
#ifndef EASY
        {AOW_MOBILE_DRONE (Shaxthal Sentry Drone)  15 35}
        {AOW_MOBILE_DRONE (Shaxthal Sentry Drone)  34 33}
#endif
        {AOW_MOBILE_DRONE (Shaxthal Sentry Drone)  31 29}
        {AOW_MOBILE_DRONE (Shaxthal Sentry Drone)  16 26}
    [/side]

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

        hidden=yes
        no_leader=yes
        recruit=Imp,Demon,Chaos Hound,Shaxthal Drone

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

        {SIDE_GENERIC_GUARD (Psy Crawler)   28 30}
        {SIDE_GENERIC_GUARD (Psy Crawler)   28 28}
        {SIDE_GENERIC_GUARD (Psy Crawler)   30 28}

        {SIDE_GENERIC_GUARD (Psy Crawler)   14 39}
        {SIDE_GENERIC_GUARD (Psy Crawler)   15 37}
        {SIDE_GENERIC_GUARD (Psy Crawler)   16 40}

        {SIDE_GENERIC_GUARD (Psy Crawler)    3 32}

        {SIDE_GENERIC_GUARD (Psy Crawler)   38 24}
        {SIDE_GENERIC_GUARD (Psy Crawler)   37 26}

        {SIDE_GENERIC_GUARD (Verlissh Matrix Flow System) 17 38}
        {SIDE_GENERIC_GUARD (Verlissh Matrix Flow System) 23 40}
        {SIDE_GENERIC_GUARD (Verlissh Matrix Flow System) 39 32}
        {SIDE_GENERIC_GUARD (Verlissh Matrix Flow System) 35 25}
        {SIDE_GENERIC_GUARD (Verlissh Matrix Flow System)  3 31}
        {SIDE_GENERIC_GUARD (Verlissh Matrix Flow System) 17 40}
        {SIDE_GENERIC_GUARD (Verlissh Matrix Flow System) 13 36}
        {SIDE_GENERIC_GUARD (Verlissh Matrix Flow System) 33 35}
        {SIDE_GENERIC_GUARD (Verlissh Matrix Flow System) 29 22}
        {SIDE_GENERIC_GUARD (Verlissh Matrix Flow System)  8 22}

        {SIDE_GENERIC_GUARD (Shadow Minion) 29 43}
        {SIDE_GENERIC_GUARD (Shadow Minion) 35 40}
        {SIDE_GENERIC_GUARD (Shadow Minion) 29 39}
        {SIDE_GENERIC_GUARD (Shadow Minion) 23 35}
    [/side]

#define AOW_WC _TYPE _VARIATION _X _Y
    [unit]
        type={_TYPE}
        variation={_VARIATION}
        x={_X}
        y={_Y}
        random_traits=yes
        generate_name=yes
        random_gender=yes
        ai_special=guardian
    [/unit]
#enddef

    # Walking corpses
    [side]
        side=4
        team_name=enemies
        user_team_name= _ "team_name^Chaos Empire"
        {CHAOS_FLAG}
        color=black

        hidden=yes
        no_leader=yes

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

        {AOW_WC (Soulless) wose 24 25}
        {AOW_WC (Soulless) wose 32 20}
        {AOW_WC (Soulless) wose 13 21}
        {AOW_WC (Soulless) wose  3 21}
        {AOW_WC (Soulless) wose 25 41}

        {AOW_WC (Soulless) drake 19 30}

        {AOW_WC (Soulless) () 11 23}
        {AOW_WC (Soulless) () 19 20}
        {AOW_WC (Soulless) () 29 12}
        {AOW_WC (Soulless) () 30 19}

        {AOW_WC (Soulless) troll 16 30}

        {AOW_WC (Soulless) mounted 31 42}
        {AOW_WC (Soulless) mounted 37 34}
        {AOW_WC (Soulless) mounted  4 27}

        {AOW_WC (Soulless) goblin 17 27}
    [/side]

    {TIMED_DRONE_SPAWNER 4 (type,variation="Shaxthal Drone",surface) 2 17 34}
    {TIMED_DRONE_SPAWNER 4 (type,variation="Shaxthal Drone",surface) 2 17 41}
    {TIMED_DRONE_SPAWNER 4 (type,variation="Shaxthal Drone",surface) 2 26 40}
    {TIMED_DRONE_SPAWNER 4 (type,variation="Shaxthal Drone",surface) 2 25 18}
    {TIMED_DRONE_SPAWNER 4 (type,variation="Shaxthal Drone",surface) 2 15 19}
    {TIMED_DRONE_SPAWNER 4 (type,variation="Shaxthal Drone",surface) 2 12 19}
    {TIMED_DRONE_SPAWNER 4 (type,variation="Shaxthal Drone",surface) 2 17 23}
    {TIMED_DRONE_SPAWNER 4 (type,variation="Shaxthal Drone",surface) 2  4 17}
    {TIMED_DRONE_SPAWNER 4 (type,variation="Shaxthal Drone",surface) 2  3 16}
    {TIMED_DRONE_SPAWNER 4 (type,variation="Shaxthal Drone",surface) 2  4 22}
    {TIMED_DRONE_SPAWNER 4 (type,variation="Shaxthal Drone",surface) 2 35 15}
    {TIMED_DRONE_SPAWNER 4 (type,variation="Shaxthal Drone",surface) 2 36 16}
    {TIMED_DRONE_SPAWNER 4 (type,variation="Shaxthal Drone",surface) 2 32 14}
    {TIMED_DRONE_SPAWNER 4 (type,variation="Shaxthal Drone",surface) 2 34 12}

    {PLACE_IMAGE items/gohere.png 36 44}

    [event]
        name=prestart

        # wmllint: recognize Elynia
        {RECALL_ELYNIA}
        # wmllint: recognize Mal Keshar
        {RECALL_MAL_KESHAR}
        # wmllint: recognize Erathan
        {RECALL_ERATHAN}
        # wmllint: recognize Igor
        {RECALL_IGOR}

        [fire_event]
            name=reset objectives
        [/fire_event]
    [/event]

    [event]
        name=reset objectives
        first_time_only=no

        {OBJECTIVES (
            {OBJECTIVE_VICTORY ( _ "Move Galas, Mal Keshar, or Elynia to the cavern at the southeastern corner of the map")}

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

            {TURNS_RUN_OUT}

            {OBJECTIVE_CARRYOVER_NO_BONUS}
        )}
    [/event]

    [event]
        name=start

        [message]
            speaker=Mal Keshar
            message= _ "Behold, the great forest of Wesmere! Home to the Ka’lian, the Great Council of the Elves — as well as the sacred capital of the Blood Apostle, the Fair Leader of the Wise People, the Ninth Bane of Inferno and Herald of Irdya’s New Awakening, Demon Lord Zhangor!"
        [/message]

        [message]
            speaker=Elynia
            message= _ "... Never utter his titles again, Malin Keshar, unless you would rather see me test your silly theory about transcending life and death."
        [/message]

        [message]
            speaker=Galas
            message= _ "So this is the place. It is quite... desolated now."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Nothing was left of the former glory of Wesmere after that night. Trees, beasts, elves and all other civilized life... all that stood in Zhangor’s path of destruction was burned to ashes, leaving nothing behind for us to bury as elvish custom demands. That would have been the end of all elvish civilization if Argan and I... if we hadn’t..."
        [/message]

        [message]
            speaker=Erathan
            message= _ "Well, we didn’t come here to weep for the fallen of wars past. The enemy knows we are here and will be searching for us shortly, I imagine. Where should we head to?"
        [/message]

        [message]
            speaker=Elynia
            message= _ "I... well, I am not sure if it’s still intact, but back then there used to be a cave system leading to the lands of Wesnoth. If we can find it, we might be able to use it to skirt the Chaos patrols... that is, assuming they are unaware of its existence in the first place."
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "That does seem highly unlikely, don’t you think? How long has it been again? Thousands, millions of years? Does anyone know?"
        [/message]

        [message]
            speaker=Elynia
            message= _ "Anyway, if we make it past the end of the caverns, we will be halfway to the empire’s capital, and... the Chaos Emperor. It seems odd they would choose the ruins of the old empire’s capital to establish their own. Anything of value that was left in it after the Fall must have been taken by scavengers and thieves since then."
        [/message]

        [message]
            speaker=Galas
            message= _ "Let us find that cave, then— Wait, why is the ground glimmering under the moonlight?"
        [/message]
    [/event]

    [event]
        name=side 1 turn 1 end

        [message]
            speaker=Elynia
            message= _ "It would seem our ‘friends’ have been busy at work in the ruins. All these structures are artificial in nature and weren’t here at the time. What purpose could they serve?"
        [/message]
    [/event]

    [event]
        name=turn 5

        [message]
            speaker=Galas
            message= _ "It should be dawn by now — the moon has set and Naia should have already appeared in the sky."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Zhangor’s curse, a side-effect of the powerful magic he used to tear the earth asunder. Even Argan with his thorough understanding of dark magic could not properly explain what Zhangor did that night. It seemed as though the very fabric of reality was coming apart with each successive blow. I fear that no matter what we do, the suns will never touch these lands ever again — perhaps for the best."
        [/message]
    [/event]

#define AOW_SCROLL_TO
    [scroll_to]
        x,y=$x2,$y2
    [/scroll_to]

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

#define AOW_SCROLL_BACK
    [scroll_to]
        x,y=$x1,$y1
    [/scroll_to]
#enddef

    {FIRE_EVENT_ON_STUMBLE_UPON "spotted hive dwellers"
    (type="Shaxthal Drone,Shaxthal Assault Drone,Shaxthal Sentry Drone")}

    [event]
        name=spotted hive dwellers

        {AOW_SCROLL_TO}

        [message]
            speaker=Erathan
            message= _ "Those infernal flying creatures! What are they?! How can they float if they are as heavy as their land cousins?!"
        [/message]

        [message]
            speaker=Elynia
            message= _ "They come from the holes in the ground, like ants!"
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Pah, just what we needed... let us hope they don’t come in similar numbers."
        [/message]

        {AOW_SCROLL_BACK}
    [/event]

    [event]
        name=moveto
        [filter]
            x=1-100
            y=20-100
            side=1
        [/filter]

        {RANDOM_PLACEMENT_AREA x,y,radius=35,25,4}
        {PLACE_UNITS_RANDOMLY (Shaxthal Drone) 2 {DIFF 3 4 5} {SHAXTHAL_SURFACE_VARIATION} }

        {RANDOM_PLACEMENT_AREA x,y,radius=17,25,4}
        {PLACE_UNITS_RANDOMLY (Shaxthal Drone) 2 {DIFF 3 4 5} {SHAXTHAL_SURFACE_VARIATION} }

        {RANDOM_PLACEMENT_AREA x,y,radius=8,28,4}
        {PLACE_UNITS_RANDOMLY (Shaxthal Drone) 2 {DIFF 3 4 5} {SHAXTHAL_SURFACE_VARIATION} }

        {CLEAR_PLACEMENT_AREA}

        [message]
            speaker=unit
            {UNIT_SPEAKS_FOR_UNDEAD_MINION (id=Mal Keshar)}
            message= _ "Argh! We attracted the attention of more of these monsters."
        [/message]

        #
        # Spawn Oz.
        #

        [modify_side]
            side=3
            {GOLD 90 110 140}
        [/modify_side]

        [unit]
            canrecruit=yes
            side=3
            placement=leader
            type=Gutwrencher Imp
            id=Oz-Deamal
            name= _ "Oz-Deamal"
            [modifications]
                {TRAIT_QUICK}
                {TRAIT_INTELLIGENT}
            [/modifications]
        [/unit]

        # wmllint: local spelling grargh

        [message]
            speaker=Oz-Deamal
            message= _ "The rebels are here, huh? Grargh, why do I get to do all the hard work around here while those lazy bastards in Kalari sleep off? Don’t let any single one of them escape!"
        [/message]

        [message]
            speaker=Galas
            message= _ "Ugh, does this ever stop? We probably should take care of that imp and his minions before proceeding underground."
        [/message]

        {OBJECTIVES (
            {OBJECTIVE_VICTORY ( _ "Kill Oz-Deamal before proceeding to the caves")}

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

            {TURNS_RUN_OUT}

            {OBJECTIVE_CARRYOVER_NO_BONUS}
        )}
    [/event]

    [event]
        name=die
        [filter]
            id=Oz-Deamal
        [/filter]

        [fire_event]
            name=reset objectives
        [/fire_event]

        [message]
            speaker=Galas
            message= _ "Phew! That was a close call. But I doubt your plan will help us much now, Elynia."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Well, look at it this way. Once we leave these plains, sooner or later we will have to endure the desert. I would rather fight demons and these metallic fiends for a while underground than let the suns burn my wings and skin off. Surely you will agree with me on this."
        [/message]

        [message]
            speaker=Galas
            message= _ "... Yes... Yes, you are right."
        [/message]
    [/event]

    {FIRE_EVENT_ON_STUMBLE_UPON "spotted hive stem" (type="Verlissh Matrix Flow System")}

    [event]
        name=spotted hive stem

        {AOW_SCROLL_TO}

        [message]
            speaker=Galas
            message= _ "There may not be any living trees left on these plains, but those alien structures sure play the part."
        [/message]

        {AOW_SCROLL_BACK}
    [/event]

    {FIRE_EVENT_ON_STUMBLE_UPON "spotted zombie tree" (
        side=4
        type=Walking Corpse,Soulless
        variation=wose
    )}

    [event]
        name=spotted zombie tree

        {AOW_SCROLL_TO}

        [message]
            speaker=Erathan
            message= _ "There’s something very wrong going on here... Why are there dead tree-folk wandering around?"
        [/message]

        {AOW_SCROLL_BACK}
    [/event]

    {FIRE_EVENT_ON_STUMBLE_UPON "spotted zombie drake" (
        side=4
        type=Walking Corpse,Soulless
        variation=drake
    )}

    [event]
        name=spotted zombie drake

        {AOW_SCROLL_TO}

        [message]
            speaker=Galas
            message= _ "Is that... Could it be? A dragon’s corpse?"
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Not quite. There once was a race of dragon-like creatures, the Drakes. Most of them were quite large and could fly and breath fire, so they would easily pass for dragons to a casual observer. Ah, it’s a pity that none of them survived the events of the Fall... as far as I know, at least."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Hm. I would not be surprised if they still existed somewhere on Irdya. It is a quite large world, after all, and they proved to be quite adaptable in the past."
        [/message]

        {AOW_SCROLL_BACK}
    [/event]

    [event]
        name=moveto
        [filter]
            side=1
            [filter_location]
                [filter_adjacent_location]
                    terrain=Qxv # wmllint: ignore
                [/filter_adjacent_location]
            [/filter_location]
        [/filter]

        [if]
            [have_unit]
                x,y=$x1,$y1
                race=bats,undead
                [not]
                    type=Lich
                [/not]
            [/have_unit]
            [then]
                [fire_event]
                    name=discuss cracks
                    [primary_unit]
                        id=Mal Keshar
                    [/primary_unit]
                [/fire_event]
            [/then]
            [else]
                [fire_event]
                    name=discuss cracks
                    [primary_unit]
                        x,y=$x1,$y1
                    [/primary_unit]
                [/fire_event]
            [/else]
        [/if]
    [/event]

    [event]
        name=discuss cracks

        [message]
            speaker=unit
            female_message= _ "female^A current of hot air ascends from the bottom of this chasm. It is as though the very earth is boiling inside. I reckon this is why the plains are relatively warm in spite of the unending darkness that envelops the land?"
            male_message= _ "A current of hot air ascends from the bottom of this chasm. It is as though the very earth is boiling inside. I reckon this is why the plains are relatively warm in spite of the unending darkness that envelops the land?"
        [/message]
    [/event]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x=36-40
            y=44-46
            id=Galas,Mal Keshar,Elynia
        [/filter]
        [filter_condition]
            [have_unit]
                id=Oz-Deamal
            [/have_unit]
        [/filter_condition]

        [message]
            speaker=Galas
            message= _ "I said we should take down the imp and his lackeys before continuing!"
        [/message]
    [/event]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x=36-40
            y=44-46
            id=Galas,Mal Keshar,Elynia
        [/filter]
        [filter_condition]
            [not]
                [have_unit]
                    id=Oz-Deamal
                [/have_unit]
            [/not]
        [/filter_condition]

        {ENDLEVEL_VICTORY no}
    [/event]

    [event]
        name=victory

        [message]
            speaker=Galas
            message= _ "That stomping... It sounds like two or three more of those giant imps are coming! We ought to hurry and seal up the entrance!"
        [/message]
    [/event]

    [event]
        name=time over

        [message]
            speaker=Erathan
            message= _ "Look! A huge swarm of drones approaches!"
        [/message]

        [message]
            speaker=Galas
            message= _ "We’re not equipped to handle a threat of this scale! We should have found the cave entrance faster..."
        [/message]
    [/event]
[/scenario]

#undef AOW_MOBILE_DRONE
#undef AOW_WC
#undef AOW_SCROLL_TO
#undef AOW_SCROLL_BACK

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


#textdomain wesnoth-Invasion_from_the_Unknown

[scenario]
    id=19x_Crossroads
    name= _ "Crossroads"
    {MAP 19x_Crossroads.map}
    turns=-1
    next_scenario=20_The_Heart

    {CUTSCENE_UI}

    {SCENARIO_MUSIC "revelation.ogg"}

    {DAWN1}

    {STORYTXT_CROSSROADS}

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

        {NO_ECONOMY}

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

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

        {NO_ECONOMY}

        # wmllint: recognize Althurin
        canrecruit=yes
        {CHARACTER_STATS_ALTHURIN}
    [/side]
    # wmllint: validate-on

    [event]
        name=prestart

        # wmllint: recognize Elynia
        {RECALL_ELYNIA}
        # wmllint: recognize Mal Keshar
        {RECALL_MAL_KESHAR}
        # wmllint: recognize Erathan
        {RECALL_ERATHAN}
        # wmllint: recognize Igor
        {RECALL_IGOR}

        [if]
            {VARIABLE_NUMERICAL_EQUALS s14_althurin_store.length 1}
            [then]
                [kill]
                    id=Althurin
                [/kill]

                [store_starting_location]
                    side=2
                [/store_starting_location]

                {VARIABLE s14_althurin_store.canrecruit yes}
                {VARIABLE s14_althurin_store.side         2}

                {CLEAR_VARIABLE s14_althurin_store.overlays,s14_althurin_store.ellipse}

                [unstore_unit]
                    variable=s14_althurin_store
                    x,y=$location.x,$location.y
                [/unstore_unit]

                {CLEAR_VARIABLE location}
            [/then]
        [/if]

        {LOCK_VIEW}
    [/event]

    [event]
        name=start

        [message]
            speaker=Galas
            message= _ "Hail, Althurin! What business brings you to enemy territory, so far from the Heart Mountains?"
        [/message]

        [message]
            speaker=Althurin
            message= _ "I would like to ask ye the same question if I may, lord Galas. We received word that the Alliance of the Peoples of the Far North sent a team of assassins to the Chaos capital, but they did not tell us ye were part of it. This is a pleasant surprise!"
        [/message]

        [message]
            speaker=Elynia
            message= _ "Althurin, did the King really send you to these lands knowing that you might never be able to return?"
        [/message]

        [message]
            speaker=Althurin
            message= _ "Uh, no, it’s not like that, fair lady. In truth, I volunteered for this mission out of my own volition, along with the others. The idea did not come from our King either — it’s the Valgran council’s response to the Alliance’s call for help. So... What do ye say, lord Galas, have ye concocted an action plan yet?"
        [/message]

        [message]
            speaker=Galas
            message= _ "I have to admit we haven’t. We were hoping to get to the Heart region and assess the situation first."
        [/message]

        [message]
            speaker=Althurin
            message= _ "Oh ho! Well, ye might be interested in knowing that the legions of Uria appear to be fully preoccupied with the Alliance’s troops in the Glamdrol region. The Empire’s lands are very poorly guarded right now, and even though the enemy’s prepared to defend the capital against potential attacks, their numbers are not too impressive. If we act fast, they will not have the time to call for reinforcements from the border outposts. On the other hand, we’ve heard dark rumors..."
        [/message]

        [message]
            speaker=Althurin
            message= _ "The Chaos Emperor is in the capital, guarding what is said to be a large portal to Inferno. If this is true..."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Failing to take the Emperor down and close the portal would have disastrous consequences for everyone, indeed. Say, Althurin, do you have the resources to mount a distraction?"
        [/message]

        [message]
            speaker=Althurin
            message= _ "Hm... The thing is, we don’t have much ourselves, as we were only intended to serve as support. I figure a distraction is not out of the question, but it probably won’t help for long. What do ye suggest?"
        [/message]

        [message]
            speaker=Elynia
            message= _ "I believe I might have a plan that will allow us to get into the capital without having to face the entirety of their defenses, but I will need your help and Mal Keshar’s."
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "Hah! My help, you say? If you have to stoop to ask me for assistance then you must have truly run out of ideas!"
        [/message]

        [message]
            speaker=Elynia
            message= _ "It involves raising many undead soldiers, disguising a few, and unleashing them on nearby enemy settlements while we flank the capital from two different directions. Hopefully this will keep most of their available troops entertained while we deal with the Emperor and his men ourselves. We will need you to assault the capital together with us, though."
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "The longer my minions are allowed to roam free without my supervision, the more destructive and disorganized they become. Don’t take me wrong, though; there’s nothing I enjoy more than a chaotic bloodbath, but I would be concerned about this interfering with your ‘plan’ somehow."
        [/message]

        [message]
            speaker=Elynia
            message= _ "Not at all. In fact, the more noise they make and the more dark soldiers of Uria they strike off the face of Irdya the better. Surely a necromancer of your caliber can figure something out."
        [/message]

        [message]
            speaker=Mal Keshar
            message= _ "He he he he, yes, yes! I will make sure to not disappoint."
        [/message]

        [message]
            speaker=Galas
            message= _ "I suppose it’s time to get moving then. We have a long day ahead of us."
        [/message]

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

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