#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"

#ifdef MULTIPLAYER
[multiplayer]
    random_start_time=no
    #No next_scenario: End of Chapter one
    next_scenario=Chapter_One_End
#ifndef DEBUG_MODE
    allow_new_game=no
#endif

#else
    [scenario]
#endif
        next_scenario=04_The_Elvish_Treasury
        id=03_Kalian_under_Attack

        experience_modifier=100
        name= _ "Ka’lian under Attack"

        #### Map setup ####
        {LOW_MAP  Kalian.map}
        {campaigns/Legend_of_Wesmere/maps/Kalian_map.cfg}

        [event]
            name=prestart

            [replace_map]
                x=11-42
                y=5-38
                {LOW_MAP  Kalian.map}
            [/replace_map]
            [shift_labels]
                x=-10
                y=-4
            [/shift_labels]
        [/event]

        [event]
            name=preload
            first_time_only=no
            [lua]
                code = <<
				H = wesnoth.require "lua/helper.lua"
				W = H.set_wml_action_metatable {}
				_ = wesnoth.textdomain "my-campaign"

				-- Define your global constants here.
				-- ...
				ai = {}
				ca_counter = 0
				H.set_wml_var_metatable(_G)
			>>
            [/lua]
        [/event]

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

#ifdef DEBUG_MODE
        turns=2
#else
        {TURNS 5 7 9}
#endif

        {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..."
                delay=4000
            [/part]
            [part]
                delay=4000
                show_title=yes
                {TO_KALIAN}
            [/part]
        [/story]

        [side]
            side=1
            no_leader=yes
            controller=human
            team_name=player
            user_team_name= _ "Player"
            save_id=Kalenz
            fog=yes
            share_view=yes
            {GOLD 160 100 50}
        [/side]
        {STARTING_VILLAGES_ALL 2}

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

        [side]
            fog=yes
            side=2
            share_view=yes
            hidden=no
            allow_player=yes
            no_leader=yes
            controller=human
            persistent=yes
            save_id=Galtrid
            team_name=player
            user_team_name= _ "Player"
            recruit=Elvish Fighter, Elvish Archer
            {GOLD 300 200 100}

            [unit]
                {GALTRID}
                extra_recruit=Elvish Fighter, Elvish Archer
                x=23
                y=22
                facing=nw
            [/unit]
            [unit]
                {EL_ISOMITHIR}
                extra_recruit=Elvish Fighter, Elvish Archer
                x=19
                y=22
                facing=nw
            [/unit]
            [unit]
                type=Elvish Scout
                facing=nw
                id=guard
                x=21
                y=20
            [/unit]
            # wmllint: recognize Eradion
            # wmllint: recognize Galtrid
        [/side]

        #### Side3 code ####
        [side]
            side=3
            controller=ai
            allow_player=no
            {ORC_SETUP}
            no_leader=yes
            team_name=orcs
            fog=yes
            shroud=yes
            share_view=yes
            gold=0
            recruit=""
            [ai]
                version=10703
                [engine]
                    name=lua
                    code=<<
				ai = ...
				local my_ai = { }

				function my_ai:retreat()
					local urudin = wesnoth.get_units({side = 3, 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, 20, 6)
						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=testing_ai_default::candidate_action_evaluation_loop
                    id=simple_main_loop
                    {AI_CA_COMBAT}
                    {AI_CA_SIMPLE_MOVE_TO_TARGETS}
                [/stage]
            [/ai]
        [/side]

        # 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 ####

        #### Side4 code ####
        [side]
            side=4
            controller=ai
            allow_player=no
            {ORC_SETUP}
            no_leader=yes
            team_name=orcs
            fog=yes
            shroud=yes
            share_view=yes
#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}
            {ai/aliases/stable_singleplayer.cfg}  #note that this MUST be given OUTSIDE the 'ai' tag
            [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"}
                {MODIFY_AI_ADD_CANDIDATE_ACTION 4 main_loop {AI_CA_POISONING}}
            [/ai]
        [/side]
        #### /Side4 code ####

        #### Side5 code ####
        [side]
            side=5
            controller=ai
            allow_player=no
            {ORC_SETUP}
            no_leader=yes
            team_name=orcs
            shroud=yes
            fog=yes
            share_view=yes
#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}

            {ai/aliases/stable_singleplayer.cfg}  #note that this MUST be given OUTSIDE the 'ai' tag
            [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"}
                {MODIFY_AI_ADD_CANDIDATE_ACTION 5 main_loop {AI_CA_POISONING}}
            [/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 ####

#ifdef MULTIPLAYER
        [side]
            side=6
            no_leader=yes
            controller=human
            team_name=player
            user_team_name= _ "Player"
            recruit=Elvish Fighter, Elvish Archer
            save_id=Landar
            fog=yes
            share_view=yes
            {GOLD 300 200 100}
            [unit]
                {EL_ISOMITHIR}
                x=19
                y=22
            [/unit]
            # wmllint: recognize Eradion
            x=19
            y=22
        [/side]
#endif

        #### Orc AI ####

#define ORC_BATTLEFIELD_EVALUATION
    {VARIABLE orc_battlefield_evaluation 0}
    # slayer dead: -1000
    [if]
        [not]
            [have_unit]
                id=Urudin
                side=3
            [/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=3,4,5
            [filter_location]
                [and]
                    x,y=21,21
                    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,6,7
        [/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=3
                canrecruit=yes
                x=19
                y=11
                hitpoints=45
                max_hitpoints=45
            [/unit]
            [unit]
                type=Orcish Warlord
                id=Murudin
                name= _ "Murudin"
                side=4
                canrecruit=yes
                x=1
                y=10
            [/unit]
            [unit]
                type=Orcish Warlord
                id=Mutaf-uru
                name= _ "Mutaf-uru"
                profile=portraits/orcs/transparent/grunt-2.png
                side=5
                canrecruit=yes
                x=7
                y=2
            [/unit]
        [/event]

        [event]
            name=moveto
            [filter]
                x=10
                y=2
                id=Urudin
            [/filter]
            [if]
                [variable]
                    name=orc_reserve_used
                    boolean_equals=no
                [/variable]
                [then]
                    {CLEAR_FOG 1 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]
            [store_unit]
                [filter]
                    id=Urudin
                [/filter]
                variable=Urudin_from_low3
                kill=yes
            [/store_unit]
        [/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=4
                {GOLD 200 320 420}
            [/modify_side]
            [modify_side]
                side=5
                {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 4 (
                [goal]
                    [criteria]
                        race=elf
                    [/criteria]
                    value=2
                [/goal]
            )}
            {MODIFY_AI_ADD_GOAL 5 (
                [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 4 aggression 0.3}
            {MODIFY_AI_ADD_SIMPLE_ALWAYS_ASPECT 5 aggression 0.3}
            {MODIFY_AI_ADD_SIMPLE_ALWAYS_ASPECT 4 caution 0.4}
            {MODIFY_AI_ADD_SIMPLE_ALWAYS_ASPECT 5 caution 0.4}
            {MODIFY_AI_ADD_GOAL 4 (
                [goal]
                    [criteria]
                        id=Mutaf-uru
                    [/criteria]
                    value=200
                [/goal]
            )}
            {MODIFY_AI_ADD_GOAL 5 (
                [goal]
                    [criteria]
                        id=Mutaf-uru
                    [/criteria]
                    value=200
                [/goal]
            )}
        [/event]

        #### /Orc AI ####


        #### Kalenz arrives ####

        [event]
            name=time over

            [replace_map]
                x=11-45
                y=5-38
                {LOW_MAP  Kalian.map}
            [/replace_map]

            {LOW_MASK_IN_EVENT 03_Kalian_under_Attack.mask (-9) (-3)}

            #redestroy the village destroyed by Urudrin
            [terrain]
                terrain = Rp^Dr
                x,y=19,13
            [/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}
                side=1
                x=33
                y=11
            [/unit]

            # wmllint: recognize Landar
            [unit]
                {LANDAR}
#ifndef MULTIPLAYER
                side=1
#else
                side=6
#endif
                x=33
                y=7
            [/unit]

            {RECALL_LOYALS}

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

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

#ifdef MULTIPLAYER
            [modify_side]
                side=6
                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=80
                [/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]

            {MODIFY_AI_ADD_GOAL 2 (
                [goal]
                    [criteria]
                        id=Mutaf-uru
                        [or]
                            id=Murudin
                        [/or]
                    [/criteria]
                    value=2
                [/goal]
            )}

            [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=21,22
            [/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) 19 11}
            [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) 19 13}
            [terrain]
                terrain = Rp^Dr
                x,y=19,13
            [/terrain]
            #TODO add village destroying sound effect
            [redraw]
            [/redraw]
            {MOVE_UNIT (id=Urudin) 19 13}
            [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 5 "Orcish Assassin" 15 15}
            {MOVE_UNIT (x,y=15,15) 17 17}

            {GENERIC_UNIT 5 "Orcish Assassin" 15 14}
            {MOVE_UNIT (x,y=15,14) 19 15}

            {GENERIC_UNIT 4 "Orcish Assassin" 11 17}
            {MOVE_UNIT (x,y=11,17) 14 18}

            {GENERIC_UNIT 4 "Orcish Assassin" 9 19}
            {MOVE_UNIT (x,y=9,19) 14 19}

            {GENERIC_UNIT 4 "Orcish Assassin" 10 20}
            {MOVE_UNIT (x,y=10,20) 13 21}

            {GENERIC_UNIT 4 "Orcish Assassin" 10 22}
            {MOVE_UNIT (x,y=10,22) 14 22}

            {GENERIC_UNIT 4 "Orcish Assassin" 11 28}
            {MOVE_UNIT (x,y=11,28) 15 26}

            {GENERIC_UNIT 4 "Orcish Assassin" 18 30}
            {MOVE_UNIT (x,y=18,30) 20 27}

            {GENERIC_UNIT 4 "Orcish Assassin" 25 30}
            {MOVE_UNIT (x,y=25,30) 22 27}

            {GENERIC_UNIT 4 "Orcish Assassin" 24 30}
            {MOVE_UNIT (x,y=24,30) 22 28}

            {GENERIC_UNIT 5 "Orcish Assassin" 28 15}
            {MOVE_UNIT (x,y=28,15) 26 17}

            {GENERIC_UNIT 5 "Orcish Assassin" 31 18}
            {MOVE_UNIT (x,y=31,18) 28 19}

            {GENERIC_UNIT 5 "Orcish Assassin" 31 19}
            {MOVE_UNIT (x,y=31,19) 29 21}

            {GENERIC_UNIT 5 "Orcish Assassin" 32 22}
            {MOVE_UNIT (x,y=32,22) 28 22}

            [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 2 "Elvish Archer"  22 17 (facing=ne
            animate=yes)}
            {UNIT 2 "Elvish Archer"  24 19 (facing=ne
            animate=yes)}
            {UNIT 2 "Elvish Fighter" 25 21 (facing=ne
            animate=yes)}
            {UNIT 2 "Elvish Archer"  25 23 (facing=se
            animate=yes)}

            {UNIT 2 "Elvish Fighter" 22 24 (facing=sw
            animate=yes)}
            {UNIT 2 "Elvish Archer"  23 25 (facing=se
            animate=yes)}

#ifndef MULTIPLAYER
            {UNIT 2 "Elvish Archer"  20 17 (facing=nw
            animate=yes)}
            {UNIT 2 "Elvish Archer"  18 19 (facing=nw
            animate=yes)}
            {UNIT 2 "Elvish Fighter" 17 21 (facing=nw
            animate=yes)}
            {UNIT 2 "Elvish Archer"  17 23 (facing=sw
            animate=yes)}

            {UNIT 2 "Elvish Fighter" 20 24 (facing=se
            animate=yes)}
            {UNIT 2 "Elvish Archer"  19 25 (facing=sw
            animate=yes)}
#else
            {UNIT 6 "Elvish Archer"  20 17 (facing=nw
            animate=yes)}
            {UNIT 6 "Elvish Archer"  18 19 (facing=nw
            animate=yes)}
            {UNIT 6 "Elvish Fighter" 17 21 (facing=nw
            animate=yes)}
            {UNIT 6 "Elvish Archer"  17 23 (facing=sw
            animate=yes)}

            {UNIT 6 "Elvish Fighter" 20 24 (facing=se
            animate=yes)}
            {UNIT 6 "Elvish Archer"  19 25 (facing=sw
            animate=yes)}

#endif
            #village grabbers
            {GENERIC_UNIT 5 "Wolf Rider" 15 9}
            {GENERIC_UNIT 4 "Wolf Rider" 3 12}

            #spotter
            {GENERIC_UNIT 5 "Wolf Rider" 10 5}
            {GENERIC_UNIT 4 "Wolf Rider" 6 12}

            #second wave - north
            {GENERIC_UNIT 3 "Orcish Archer" 16 9}
            {GENERIC_UNIT 3 "Orcish Grunt" 17 9}
            {GENERIC_UNIT 3 "Orcish Grunt" 19 9}
            {GENERIC_UNIT 3 "Orcish Archer" 20 9}

            #second wave - east
            {GENERIC_UNIT 3 "Orcish Archer" 31 17}
            {GENERIC_UNIT 3 "Orcish Grunt" 32 18}
            {GENERIC_UNIT 3 "Orcish Grunt" 33 21}
            {GENERIC_UNIT 3 "Orcish Archer" 33 22}

            #second wave - west
            {GENERIC_UNIT 3 "Orcish Archer" 9 19}
            {GENERIC_UNIT 3 "Orcish Grunt" 9 21}
            {GENERIC_UNIT 3 "Orcish Grunt" 9 22}
            {GENERIC_UNIT 3 "Orcish Archer" 9 23}

            #second wave - south
            {GENERIC_UNIT 3 "Orcish Archer" 19 34}
            {GENERIC_UNIT 3 "Orcish Grunt" 20 33}
            {GENERIC_UNIT 3 "Orcish Grunt" 22 33}
            {GENERIC_UNIT 3 "Orcish Archer" 23 34}

            [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=victory
            [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=34,32,30,24,22,21
                y= 9, 8, 8,11,14,18
            [/move_unit_fake]

            #TODO Move Huraldur to characters?
            [unit]
                id=Huraldur
                name= _ "Huraldur"
                type=Elvish Scout
                side=1
                x=21
                y=18
                [modifications]
                    {TRAIT_QUICK}
                    {TRAIT_RESILIENT}
                    {TRAIT_LOYAL}
                [/modifications]
                {IS_LOYAL}
                facing=se
            [/unit]

            #TODO Multiplayer: give a second Huraldur to Landar

            [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=victory
            {CLEAR_VARIABLE orc_reserve_used}
            {CLEAR_VARIABLE orc_battlefield_strategy}
        [/event]

        {campaigns/Legend_of_Wesmere/utils/deaths.cfg}

#ifndef MULTIPLAYER
    [/scenario]
#else
[/multiplayer]
#endif

#undef ORC_BATTLEFIELD_EVALUATION
#undef ORC_BATTLEFIELD_EVALUATION_SUCCESS
#undef ORC_BATTLEFIELD_EVALUATION_FAILURE
