#textdomain wesnoth-low

# NOTE: Orcish plans: The orcs are somewhat wary of the forest, and do
# not want to commit their entire army from the start. So, they decide
# to send a part of their army (under the command of the Orcish
# Slayer Urudin), to test the defenses of Ka'lian. If the slayer dies (he's
# not supposed to die, as he is not taking part in the battle, but
# oversees it from a distance, and he'll flee if any orc dies), it
# means that the orcs will not attempt further attack on
# Ka'lian, but, instead, hold position and wait for their army to arrive

[scenario]
    id=03_Kalian_under_Attack
    name= _ "Ka’lian under Attack"
    next_scenario=04_The_Elvish_Treasury

    allow_new_game=no
    random_start_time=no
    force_lock_settings=yes

    experience_modifier=100

    #### Map setup ####
    {LOW_MAP  Kalian.map}

    [event]
        name=prestart

        {campaigns/Legend_of_Wesmere/maps/Kalian_map.cfg}

        [replace_map_section]
            x=9-53
            y=9-53
            {LOW_MAP_DATA  Kalian.map}
        [/replace_map_section]
        [shift_labels]
            x=-8
            y=-9
        [/shift_labels]
    [/event]

    {LOW_MASK 03_Kalian_under_Attack.mask (-7) (-7)}
    #### /Map setup ####

    {TURNS 5 7 9}

    {INTRO_AND_SCENARIO_MUSIC elf-land.ogg revelation.ogg}
    {EXTRA_SCENARIO_MUSIC into_the_shadows.ogg}
    {EXTRA_SCENARIO_MUSIC the_deep_path.ogg}
    {EXTRA_SCENARIO_MUSIC the_dangerous_symphony.ogg}
    {EXTRA_SCENARIO_MUSIC northerners.ogg}

    {DEFAULT_SCHEDULE}

    [story]
        [part]
            story= _ "Events at the Ka’lian took an ominous turn before Kalenz and his band could arrive there..."
        [/part]
    [/story]
    {LOW_TRACK {FLIGHT_STAGE3} }

#define PLAYER_GOLD
#ifndef MULTIPLAYER
    {GOLD   300 240 200}
    {INCOME  -2  -2 -2}
#else
    {GOLD    180 140 120}
    {INCOME  -2  -2 -2}
#endif
    village_gold=1
#enddef

    [side]
        side=1
        no_leader=yes
        {PLAYABLE}
        save_id=Kalenz
        disallow_shuffle=yes
        fog=yes
        {PLAYER_GOLD}
    [/side]

    # wmllint: skip-side
    {MP_SIDE 2 (
        no_leader=yes
        {PLAYABLE}
        save_id=Landar
        disallow_shuffle=yes
        fog=yes
        {PLAYER_GOLD}
    )}

    [side]
        side=3
        {PLAYABLE}
        fog=yes
        no_leader=yes
        previous_save_id=Kalenz
        save_id=Galtrid
        disallow_shuffle=yes
#ifndef MULTIPLAYER
        {GOLD   280 220 180}
        {INCOME  -2  -2 -2}
#else
        {GOLD    160  120 100}
        {INCOME  -2  -2 -2}
#endif
        income=-2
        village_gold=1

        [unit]
            {GALTRID}
            x=25
            y=24
            facing=nw
        [/unit]
#ifndef MULTIPLAYER
        [unit]
            {EL_ISOMITHIR}
            x=21
            y=24
            facing=nw
        [/unit]
        [unit]
            type=Elvish Scout
            facing=nw
            id=guard
            x=22
            y=21
        [/unit]
#endif
        [unit]
            type=Elvish Scout
            [modifications]
                {TRAIT_LOYAL}
            [/modifications]
            facing=nw
            id=guard2
            x=24
            y=21
        [/unit]
        # wmllint: recognize Eradion
        # wmllint: recognize Galtrid
    [/side]

    # wmllint: skip-side
    {MP_SIDE 4 (
        no_leader=yes
        previous_save_id=Landar
        {PLAYABLE}
        save_id=El_Isomithir
        disallow_shuffle=yes
        fog=yes
        {GOLD    160  120 100}
        {INCOME  -2  -2 -2}
        income=-2
        village_gold=1
        [unit]
            {EL_ISOMITHIR}
            x=21
            y=24
        [/unit]
        [unit]
            type=Elvish Scout
            x=22
            y=21
            [modifications]
                {TRAIT_LOYAL}
            [/modifications]
        [/unit]
    )}

    [side]
        side=5
        controller=ai
        allow_player=no
        {ORC_SETUP}
        no_leader=yes
        team_name=orcs
        user_team_name= _ "Enemies"
        fog=yes
        shroud=yes
        share_vision=all
        gold=0
        village_gold=1
        recruit=""
        faction=Custom
        [ai]
            [engine]
                name=lua
                # Note that the move_full co-ordinates should match the moveto event for Urudin below
                code=<<
                local my_ai = { }

                function my_ai:retreat()
                    local urudin = wesnoth.units.find_on_map({id="Urudin"})[1]
                    if urudin and urudin.valid then
                        local mhp, hp = urudin.max_hitpoints, urudin.hitpoints
                        local turn = wesnoth.current.turn
                        if turn >= 3 or hp < mhp / 2 then
                            ai.move_full(urudin, 12, 4)
                        end
                    end
                end

                return my_ai
            >>
            [/engine]
            [stage]
                id=leader_retreat
                engine=lua
                name=leader_retreat
                #retreat on > half HP lost  or turn>=3
                code="(...):retreat()"
            [/stage]
            [stage]
                name=ai_default_rca::candidate_action_evaluation_loop
                id=simple_main_loop
                {AI_CA_COMBAT}
                {AI_CA_SIMPLE_MOVE_TO_TARGETS}
            [/stage]
        [/ai]
    [/side]

    {STARTING_VILLAGES_ALL 3}

#ifdef MULTIPLAYER
    [event]
        name=prestart
        [capture_village]
            side=4
            x=1-26
            y=1-infinity
        [/capture_village]
    [/event]
#endif

    # wmllint: recognize Urudin
    [event]
        name=last breath
        [filter]
            id=Urudin
        [/filter]
        [message]
            speaker=unit
            message= _ "Chief, the cursed tree-shaggers are defeating us!"
        [/message]
        [fire_event]
            name=orcs_select_strategy
        [/fire_event]
    [/event]

    #### /Side3 code ####

    #### Side6 code ####
    [side]
        side=6
        controller=ai
        allow_player=no
        {ORC_SETUP}
        no_leader=yes
        team_name=orcs
        user_team_name= _ "Enemies"
        fog=yes
        shroud=yes
        share_vision=all
#ifdef EASY
        recruit=Orcish Archer, Orcish Assassin, Orcish Grunt, Wolf Rider, Orcish Crossbowman, Goblin Knight, Goblin Pillager, Goblin Spearman
#endif
#ifdef NORMAL
        recruit=Orcish Archer, Orcish Assassin, Orcish Grunt, Wolf Rider, Orcish Crossbowman, Goblin Knight, Goblin Pillager, Goblin Spearman, Orcish Slayer, Orcish Warrior
#endif
#ifdef HARD
        recruit=Orcish Archer, Orcish Assassin, Orcish Grunt, Wolf Rider, Orcish Crossbowman, Goblin Knight, Goblin Pillager, Goblin Spearman, Orcish Slayer, Orcish Warrior
#endif
        {GOLD 0 40 80}
        {INCOME 4 8 12}
        village_gold=1

        [ai]
            {AI_SIMPLE_NIGHT_ASPECT aggression 1}
            {AI_SIMPLE_NIGHT_ASPECT caution 0}
            {AI_SIMPLE_NIGHT_ASPECT grouping offensive}
            {AI_SIMPLE_ALWAYS_ASPECT villages_per_scout 5}
            {AI_SIMPLE_ALWAYS_ASPECT recruitment_pattern "scout,scout,scout,fighter,archer,mixed fighter"}
        [/ai]
    [/side]
    #### /Side4 code ####

    #### Side5 code ####
    [side]
        side=7
        controller=ai
        allow_player=no
        {ORC_SETUP}
        no_leader=yes
        team_name=orcs
        user_team_name= _ "Enemies"
        shroud=yes
        fog=yes
        share_vision=all
#ifdef EASY
        recruit=Orcish Crossbowman, Goblin Pillager, Goblin Knight
#endif
#ifdef NORMAL
        recruit=Orcish Crossbowman, Goblin Pillager, Goblin Knight, Orcish Slayer, Goblin Impaler, Goblin Rouser, Orcish Warrior
#endif
#ifdef HARD
        recruit=Orcish Crossbowman, Goblin Pillager, Goblin Knight, Orcish Slayer, Goblin Impaler, Goblin Rouser, Orcish Warrior
#endif
        {GOLD 0 40 80}
        {INCOME 4 8 12}
        village_gold=1

        [ai]
            {AI_SIMPLE_NIGHT_ASPECT aggression 1}
            {AI_SIMPLE_NIGHT_ASPECT caution 0}
            {AI_SIMPLE_NIGHT_ASPECT grouping offensive}
            {AI_SIMPLE_ALWAYS_ASPECT villages_per_scout 5}
            {AI_SIMPLE_ALWAYS_ASPECT recruitment_pattern "scout,fighter,fighter,archer,mixed fighter"}
        [/ai]
    [/side]

    # wmllint: recognize Mutaf-uru
    [event]
        name=last breath
        [filter]
            id=Mutaf-uru
        [/filter]
        [message]
            speaker=unit
            message= _ "We die, but more come after us, orcs will rule all!"
        [/message]
    [/event]
    #### /Side5 code ####

#undef PLAYER_GOLD

    #### Orc AI ####

#define ORC_BATTLEFIELD_EVALUATION
    {VARIABLE orc_battlefield_evaluation 0}
    # slayer dead: -1000
    [if]
        [not]
            [have_unit]
                id=Urudin
                side=5
            [/have_unit]
        [/not]
        [then]
            {VARIABLE_OP orc_battlefield_evaluation sub 1000}
        [/then]
    [/if]

    # orcs in Ka'lian: +3 +4 +5 per orc
    [store_unit]
        variable=eval_orcs_in_kalian
        [filter]
            side=5,6,7
            [filter_location]
                [and]
                    x,y=23,23
                    radius=5
                [/and]
                [not]
                    terrain=W*
                [/not]
            [/filter_location]
        [/filter]
    [/store_unit]

    {VARIABLE eval_orcs_in_kalian_score 0}
    {VARIABLE_OP eval_orcs_in_kalian_score add $eval_orcs_in_kalian.length}

#ifdef EASY
    {VARIABLE_OP eval_orcs_in_kalian_score multiply 3}
#endif
#ifdef NORMAL
    {VARIABLE_OP eval_orcs_in_kalian_score multiply 4}
#endif
#ifdef HARD
    {VARIABLE_OP eval_orcs_in_kalian_score multiply 5}
#endif

    {VARIABLE_OP orc_battlefield_evaluation add $eval_orcs_in_kalian_score}

    # elven units: -1 per unit
    [store_unit]
        variable=eval_elves
        [filter]
            side=1,2,3,4
        [/filter]
    [/store_unit]

    {VARIABLE_OP orc_battlefield_evaluation sub $eval_elves.length}
    {CLEAR_VARIABLE eval_elves}
    {CLEAR_VARIABLE eval_orcs_in_kalian}
    {CLEAR_VARIABLE eval_orcs_in_kalian_score}
#enddef

#define ORC_BATTLEFIELD_EVALUATION_SUCCESS
    [variable]
        name=orc_battlefield_evaluation
        greater_than_equal_to=11
    [/variable]
#enddef

#define ORC_BATTLEFIELD_EVALUATION_FAILURE
    [variable]
        name=orc_battlefield_evaluation
        less_than_equal_to=-25
    [/variable]
#enddef

    [event]
        name=prestart
        {VARIABLE orc_reserve_used no}
        {VARIABLE orc_battlefield_strategy 'wait'}
        [unit]
            type="Orcish Slayer"
            id=Urudin
            name= _ "Urudin"
            side=5
            canrecruit=yes
            x=20
            y=10
            hitpoints=45
            max_hitpoints=45
        [/unit]
        [unit]
            type=Orcish Warlord
            id=Murudin
            name= _ "Murudin"
            side=6
            canrecruit=yes
            x=3
            y=12
        [/unit]
        [unit]
            type=Orcish Warlord
            id=Mutaf-uru
            name= _ "Mutaf-uru"
            profile=portraits/orcs/grunt-2.webp
            side=7
            canrecruit=yes
            x=9
            y=4
        [/unit]
    [/event]

    [event]
        name=moveto
        [filter]
            id=Urudin
            [filter_location]
                # Note that these co-ordinates should match the AI code for Urudin's side declared above
                x=12
                y=4
                radius=3
            [/filter_location]
        [/filter]
        [if]
            [variable]
                name=orc_reserve_used
                boolean_equals=no
            [/variable]
            [then]
                {CLEAR_FOG 1 7 3 4}
                {CLEAR_FOG 2 7 3 4}
                {CLEAR_FOG 3 7 3 4}
                {CLEAR_FOG 4 7 3 4}
                [message]
                    id=Mutaf-uru
                    message=_ "Good, you are returned. What news is there?"
                [/message]
                [message]
                    id=Urudin
                    message=_ "The elvish scum refused to surrender, Warlord. We have begun the attack, as planned."
                [/message]
                [message]
                    id=Mutaf-uru
                    message=_ "Were you able to breach their citadel?"
                [/message]
                {ORC_BATTLEFIELD_EVALUATION}
                [if]
                    {ORC_BATTLEFIELD_EVALUATION_SUCCESS}
                    [then]
                        [message]
                            id=Urudin
                            message=_ "Yes. We slaughtered them in great numbers."
                        [/message]
                    [/then]
                    [else]
                        [if]
                            {ORC_BATTLEFIELD_EVALUATION_FAILURE}
                            [then]
                                [message]
                                    id=Urudin
                                    message=_ "No, our attack was repulsed."
                                [/message]
                            [/then]
                            [else]
                                [message]
                                    id=Urudin
                                    message=_ "They resisted us fiercely; the battle is not yet done."
                                [/message]
                            [/else]
                        [/if]
                    [/else]
                [/if]
                {CLEAR_VARIABLE orc_battlefield_evaluation}
                [fire_event]
                    name=orcs_select_strategy
                [/fire_event]
                {UNCLEAR_FOG}
            [/then]
        [/if]
        [message]
            id=Mutaf-uru
            # Grubr is from LoW #7
            message=_ "Go, report this news to the warlord Grubr."
        [/message]
        [message]
            id=Urudin
            message=_ "I obey."
        [/message]
        [kill]
            id=Urudin
        [/kill]
    [/event]

    # triggered by slayer dying, or slayer reaching his boss, or Kalenz arriving
    [event]
        name=orcs_select_strategy
        first_time_only=no

        [if]
            [variable]
                name=orc_reserve_used
                boolean_equals=no
            [/variable]
            [then]
                # evaluate the battlefield. TODO Crab : consider using fai for evaluation
                {ORC_BATTLEFIELD_EVALUATION}

                [if]
                    {ORC_BATTLEFIELD_EVALUATION_SUCCESS}
                    [then]
                        {VARIABLE orc_battlefield_strategy 'attack'}
                    [/then]
                [/if]

                [if]
                    {ORC_BATTLEFIELD_EVALUATION_FAILURE}
                    [then]
                        {VARIABLE orc_battlefield_strategy 'defend'}
                    [/then]
                [/if]
                {CLEAR_VARIABLE orc_battlefield_evaluation}

                # if fog is gone (thus, Kalenz is here), then do not wait
                [if]
                    # wmllint: recognize Kalenz
                    [have_unit]
                        id=Kalenz
                        side=1
                    [/have_unit]
                    [variable]
                        name=orc_battlefield_strategy
                        equals='wait'
                    [/variable]
                    [then]
                        #{DEBUG_MSG ("$orc_battlefield_strategy changed to ‘attack’")}
                        {VARIABLE orc_battlefield_strategy 'attack'}
                    [/then]
                [/if]

                [switch]
                    variable=orc_battlefield_strategy
                    [case]
                        value='wait'
                        # do nothing
                    [/case]
                    [case]
                        value='attack'
                        {CLEAR_FOG 1 7 3 4}
                        [fire_event]
                            name=orc_commit_reserves
                        [/fire_event]
                        [fire_event]
                            name=orc_attack
                        [/fire_event]
                        {UNCLEAR_FOG}
                    [/case]
                    [case]
                        value='defend'
                        {CLEAR_FOG 1 7 3 4}
                        [fire_event]
                            name=orc_commit_reserves
                        [/fire_event]
                        [fire_event]
                            name=orc_defend
                        [/fire_event]
                        {UNCLEAR_FOG}
                    [/case]
                [/switch]
            [/then]
        [/if]
    [/event]

    [event]
        name=orc_commit_reserves
        first_time_only=yes
        {VARIABLE orc_reserve_used yes}
        [modify_side]
            side=6
            {GOLD 200 320 420}
        [/modify_side]
        [modify_side]
            side=7
            {GOLD 200 240 380}
        [/modify_side]
    [/event]
    [event]
        name=orc_attack
        first_time_only=no
        [message]
            id=Mutaf-uru
            message= _ "These elves are weak, mere meat for my wolves! Get them!"
        [/message]
        {MODIFY_AI_ADD_GOAL 6 (
            [goal]
                [criteria]
                    race=elf
                [/criteria]
                value=2
            [/goal]
        )}
        {MODIFY_AI_ADD_GOAL 7 (
            [goal]
                [criteria]
                    race=elf
                [/criteria]
                value=2
            [/goal]
        )}
    [/event]

    [event]
        name=orc_defend
        first_time_only=no
        [message]
            id=Mutaf-uru
            message= _ "Cursed tree-shaggers and their filthy bows! We shall await the main army."
        [/message]
        {MODIFY_AI_ADD_SIMPLE_ALWAYS_ASPECT 6 aggression 0.3}
        {MODIFY_AI_ADD_SIMPLE_ALWAYS_ASPECT 7 aggression 0.3}
        {MODIFY_AI_ADD_SIMPLE_ALWAYS_ASPECT 6 caution 0.4}
        {MODIFY_AI_ADD_SIMPLE_ALWAYS_ASPECT 7 caution 0.4}
        {MODIFY_AI_ADD_GOAL 4 (
            [goal]
                [criteria]
                    id=Mutaf-uru
                [/criteria]
                value=200
            [/goal]
        )}
        {MODIFY_AI_ADD_GOAL 7 (
            [goal]
                [criteria]
                    id=Mutaf-uru
                [/criteria]
                value=200
            [/goal]
        )}
    [/event]

    #### /Orc AI ####

    #### Kalenz arrives ####

    [event]
        name=time over
        [fire_event]
            name=kalenz_arrives
        [/fire_event]
    [/event]

    [event]
        name=kalenz_arrives

        {LOAD_SUBMAP 7-56 7-56 2 2 Kalian.map}
        {LOW_MASK_IN_EVENT 03_Kalian_under_Attack.mask (-5) (-5)}

        #redestroy the village destroyed by Urudrin
        [terrain]
            terrain = Rp^Dr
            x,y=23,17
        [/terrain]
        [redraw]
        [/redraw]

        {REPLACE_SCENARIO_MUSIC the_city_falls.ogg}
        {APPEND_MUSIC wanderer.ogg}
        {APPEND_MUSIC suspense.ogg}
        {APPEND_MUSIC siege_of_laurelmor.ogg}
        {APPEND_MUSIC silvan_sanctuary.ogg}

        [modify_turns]
#ifdef EASY
            add=35
#endif
#ifdef NORMAL
            add=30
#endif
#ifdef HARD
            add=25
#endif
        [/modify_turns]

        [unit]
            {KALENZ_YOUNG}
            side=1
            x=49
            y=32
        [/unit]
        [unit]
            {LANDAR_YOUNG}
#ifndef MULTIPLAYER
            side=1
#else
            side=2
#endif
            x=49
            y=36
        [/unit]
        [recall]
            id=Anduilas
            side=1
            x=49
            y=33
        [/recall]
        [recall]
            id=Arkildur
#ifndef MULTIPLAYER
            side=1
#else
            side=2
#endif
            x=49
            y=37
        [/recall]

        [modify_side]
            side=1
            fog=no
        [/modify_side]
        [modify_side]
            side=3
            fog=no
        [/modify_side]
        [modify_side]
            side=5
            fog=no
        [/modify_side]
        [modify_side]
            side=6
            fog=no
        [/modify_side]
        [modify_side]
            side=7
            fog=no
        [/modify_side]
#ifdef MULTIPLAYER
        [modify_side]
            side=2
            fog=no
        [/modify_side]
        [modify_side]
            side=4
            fog=no
        [/modify_side]
#endif
    [/event]

    [event]
        name=time over

        [objectives]
            side=0
            [objective]
                description= _ "Defeat all enemy leaders."
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Kalenz"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Landar"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Galtrid"
                condition=lose
            [/objective]
#ifdef MULTIPLAYER
            [objective]
                description= _ "Death of Eradion"
                condition=lose
            [/objective]
#endif

            [gold_carryover]
                bonus=yes
                carryover_percentage=40
            [/gold_carryover]
            {TURNS_RUN_OUT}
        [/objectives]

        [redraw]
        [/redraw]

        [scroll_to_unit]
            id=Kalenz
        [/scroll_to_unit]

        [message]
            speaker=narrator
            image=wesnoth-icon.png
            message= _ "For days, Kalenz and his small host of followers traveled, moving nearer and yet nearer to the Ka’lian. Thanks to the dense fog and elvish woodscraft, the band was able to evade the orcish hunters. Then, as they were almost arrived at their destination, the north wind blew, and the fog lifted to reveal a grim sight..."
        [/message]
        [message]
            id=Kalenz
            message= _ "Great hosts of orcs converge on the Ka’lian! But if we fall upon them from behind as they are fully engaged with the defenders, we and they together might yet defeat them."
        [/message]
        [message]
            id=Galtrid
            message= _ "Are you our army’s vanguard? Hurry, for we are sorely pressed here."
        [/message]
        [message]
            id=Kalenz
            message= _ "No, we are fleeing an attack on our home in the Lintanir. Time enough for talk later; we must defeat these orcs together, or at least hold them off long enough for the humans to come to our aid."
        [/message]
        [message]
            id=Galtrid
            message= _ "Then you have not heard the ill tidings. King Haldric has broken the treaty. The humans will not come to our aid!"
        [/message]
        [message]
            id=Landar
            message= _ "How dare they break the treaty!"
        [/message]

        [fire_event]
            name=orcs_select_strategy
        [/fire_event]

        [event]
            name="time over"
            [message]
                id=Kalenz
                message= _ "We have failed to relieve the defenders, and more orcish war-bands are arriving. All is lost!"
            [/message]
        [/event]
    [/event]

    [event]
        name=prestart
        [objectives]
            [objective]
                description= _ "Hold on until turns run out."
                condition=win
                show_turn_counter=yes
            [/objective]
            [objective]
                description= _ "Death of Galtrid"
                condition=lose
            [/objective]
#ifdef MULTIPLAYER
            [objective]
                description= _ "Death of Eradion"
                condition=lose
            [/objective]
#endif
            #TODO
            #  [objective]
            #      {BONUS_OBJECTIVE_CAPTION}
            #      description= _ "Defeat Urudin"
            #      #condition=win
            #  [/objective]
        [/objectives]
    [/event]

    [event]
        name=start
        [scroll_to]
            x,y=23,24
        [/scroll_to]
        [delay]
            time=5000 #this delay is to give the player the sightseening opportunity
        [/delay]
        [scroll_to_unit]
            id=Urudin
        [/scroll_to_unit]
        {MOVE_UNIT (id=Urudin) 21 13}
        [message]
            id=guard
            message= _ "Hist! Someone is sneaking about in the mist."
        [/message]
        [message]
            id=Urudin
            message= _ "Ho, elves! Hand over the stone and we <i>might</i> not destroy your cute little playhouse, and we <i>might</i> spare you. Or, at the very least, we promise you a quick and painless death."
        [/message]
        [message]
            id=Galtrid
            message= _ "What ‘stone’, foul and clumsy orc? Your lips are not fit even to name the citadel of the Ka’lian, for it has stood since before your kind crawled into sunlight and will endure long after you are forgotten!"
        [/message]

        {MOVE_UNIT (id=Urudin) 21 15}
        [terrain]
            terrain = Rp^Dr
            x,y=21,15
        [/terrain]
        #TODO add village destroying sound effect
        [redraw]
        [/redraw]
        {MOVE_UNIT (id=Urudin) 20 14}
        [message]
            id=Urudin
            message= _ "We will cram those arrogant words back down your throat before we kill you, wose-spawned worm of an elf!"
        [/message]

        {REPLACE_SCENARIO_MUSIC the_deep_path.ogg}
        {APPEND_MUSIC siege_of_laurelmor.ogg}
        #TODO add one more title

        {GENERIC_UNIT 7 "Orcish Assassin" 17 17}
        {MOVE_UNIT (x,y=17,17) 19 19}

        {GENERIC_UNIT 7 "Orcish Assassin" 17 16}
        {MOVE_UNIT (x,y=17,16) 21 17}

        {GENERIC_UNIT 6 "Orcish Assassin" 13 19}
        {MOVE_UNIT (x,y=13,19) 16 20}

        {GENERIC_UNIT 6 "Orcish Assassin" 11 21}
        {MOVE_UNIT (x,y=11,21) 16 21}

        {GENERIC_UNIT 6 "Orcish Assassin" 12 22}
        {MOVE_UNIT (x,y=12,22) 15 23}

        {GENERIC_UNIT 6 "Orcish Assassin" 12 24}
        {MOVE_UNIT (x,y=12,24) 16 24}

        {GENERIC_UNIT 6 "Orcish Assassin" 13 30}
        {MOVE_UNIT (x,y=13,30) 17 29}

        {GENERIC_UNIT 6 "Orcish Assassin" 20 32}
        {MOVE_UNIT (x,y=20,32) 22 29}

        {GENERIC_UNIT 6 "Orcish Assassin" 27 32}
        {MOVE_UNIT (x,y=27,32) 24 29}

        {GENERIC_UNIT 6 "Orcish Assassin" 26 32}
        {MOVE_UNIT (x,y=26,32) 24 30}

        {GENERIC_UNIT 7 "Orcish Assassin" 30 17}
        {MOVE_UNIT (x,y=30,17) 28 19}

        {GENERIC_UNIT 7 "Orcish Assassin" 33 20}
        {MOVE_UNIT (x,y=33,20) 30 21}

        {GENERIC_UNIT 7 "Orcish Assassin" 33 21}
        {MOVE_UNIT (x,y=33,21) 31 23}

        {GENERIC_UNIT 7 "Orcish Assassin" 34 24}
        {MOVE_UNIT (x,y=34,24) 30 24}

        [message]
            id=Galtrid
            message= _ "To arms, elven-kin! They are many, but our army is returning and surely close at hand. We have but to hold until it arrives!"
        [/message]
        [scroll_to]
            x,y=21,22
        [/scroll_to]

        #Soldiers
        {UNIT 3 "Elvish Archer"  24 19 (facing=ne
        animate=yes)}
        {UNIT 3 "Elvish Archer"  26 21 (facing=ne
        animate=yes)}
        {UNIT 3 "Elvish Fighter" 27 23 (facing=ne
        animate=yes)}
        {UNIT 3 "Elvish Archer"  27 25 (facing=se
        animate=yes)}

        {UNIT 3 "Elvish Fighter" 24 26 (facing=sw
        animate=yes)}
        {UNIT 3 "Elvish Archer"  25 27 (facing=se
        animate=yes)}

#ifndef MULTIPLAYER
        {UNIT 3 "Elvish Archer"  22 19 (facing=nw
        animate=yes)}
        {UNIT 3 "Elvish Archer"  20 21 (facing=nw
        animate=yes)}
        {UNIT 3 "Elvish Fighter" 19 23 (facing=nw
        animate=yes)}
        {UNIT 3 "Elvish Archer"  19 25 (facing=sw
        animate=yes)}

        {UNIT 3 "Elvish Fighter" 22 26 (facing=se
        animate=yes)}
        {UNIT 3 "Elvish Archer"  21 27 (facing=sw
        animate=yes)}
#else
        {UNIT 4 "Elvish Archer"  22 19 (facing=nw
        animate=yes)}
        {UNIT 4 "Elvish Archer"  20 21 (facing=nw
        animate=yes)}
        {UNIT 4 "Elvish Fighter" 19 23 (facing=nw
        animate=yes)}
        {UNIT 4 "Elvish Archer"  19 25 (facing=sw
        animate=yes)}

        {UNIT 4 "Elvish Fighter" 22 26 (facing=se
        animate=yes)}
        {UNIT 4 "Elvish Archer"  21 27 (facing=sw
        animate=yes)}

#endif
        #village grabbers
        {GENERIC_UNIT 7 "Wolf Rider" 17 11}
        {GENERIC_UNIT 6 "Wolf Rider" 5 14}

        #spotter
        {GENERIC_UNIT 7 "Wolf Rider" 12 7}
        {GENERIC_UNIT 6 "Wolf Rider" 8 14}

        #second wave - north
        {GENERIC_UNIT 5 "Orcish Archer" 18 11}
        {GENERIC_UNIT 5 "Orcish Grunt" 19 11}
        {GENERIC_UNIT 5 "Orcish Grunt" 21 11}
        {GENERIC_UNIT 5 "Orcish Archer" 22 11}

        #second wave - east
        {GENERIC_UNIT 5 "Orcish Archer" 33 19}
        {GENERIC_UNIT 5 "Orcish Grunt" 34 20}
        {GENERIC_UNIT 5 "Orcish Grunt" 35 23}
        {GENERIC_UNIT 5 "Orcish Archer" 35 24}

        #second wave - west
        {GENERIC_UNIT 5 "Orcish Archer" 11 21}
        {GENERIC_UNIT 5 "Orcish Grunt" 11 23}
        {GENERIC_UNIT 5 "Orcish Grunt" 11 24}
        {GENERIC_UNIT 5 "Orcish Archer" 11 25}

        #second wave - south
        {GENERIC_UNIT 5 "Orcish Archer" 21 36}
        {GENERIC_UNIT 5 "Orcish Grunt" 22 35}
        {GENERIC_UNIT 5 "Orcish Grunt" 24 35}
        {GENERIC_UNIT 5 "Orcish Archer" 25 36}

        [message]
            speaker=narrator
            message= _ "You will have a different recall list and amount of starting gold than you may be expecting at the beginning of this scenario, as you will not start with Kalenz’s army."
            image=wesnoth-icon.png
        [/message]
    [/event]
    [event]
        name=scenario_end
        [filter_condition]
            [proceed_to_next_scenario]
            [/proceed_to_next_scenario]
        [/filter_condition]

        [fire_event]
            name=kalenz_arrives
        [/fire_event]

        [message]
            id=Kalenz
            message= _ "We won! The Ka’lian is safe!"
        [/message]

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

        [move_unit_fake]
            type=Elvish Scout
            x=50,43,34,24
            y=15,15,12,18
        [/move_unit_fake]

        [unit]
            #wmllint: who {HURALDUR} is Huraldur
            {HURALDUR}
            side=1
            x=24
            y=18
            facing=se
        [/unit]

        [move_unit_fake]
            type=Elvish Scout
            x=50,43,34,26
            y=15,15,12,18
        [/move_unit_fake]

        [unit]
            {SCOUT}
#ifdef MULTIPLAYER
            side=2
#else
            side=1
#endif
            x=26
            y=18
            facing=sw
        [/unit]

        [message]
            id=Huraldur
            message= _ "The elvish treasury is under attack! They need help desperately!"
        [/message]
        [message]
            id=Kalenz
            message= _ "Galtrid, your men are weary from long combat. Mine are fresher; I’ll go."
        [/message]
        [message]
            id=Huraldur
            message= _ "Hurry! We were near overwhelmed as I left."
        [/message]
        [message]
            id=Galtrid
            message= _ "Yes, go, Kalenz, I’ll guard the Ka’lian till our army returns from the front."
        [/message]
    [/event]

    [event]
        name=scenario_end
        [filter_condition]
            [proceed_to_next_scenario]
            [/proceed_to_next_scenario]
        [/filter_condition]
        {CLEAR_VARIABLE orc_reserve_used}
        {CLEAR_VARIABLE orc_battlefield_strategy}

#ifdef MULTIPLAYER
        [persistent_carryover_store]
            scenario_id = LoW_Chapter_One
        [/persistent_carryover_store]
#endif
    [/event]
    {DEFAULT_VICTORY 0.5}

    {campaigns/Legend_of_Wesmere/utils/deaths.cfg}
[/scenario]

#undef ORC_BATTLEFIELD_EVALUATION
#undef ORC_BATTLEFIELD_EVALUATION_SUCCESS
#undef ORC_BATTLEFIELD_EVALUATION_FAILURE
# wmllint: unwho KALENZ_YOUNG
# wmllint: unwho LANDAR_YOUNG
