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

#TODO make the ugly map border nicer

#ifdef MULTIPLAYER
[multiplayer]
    random_start_time=no
#ifndef DEBUG_MODE
    allow_new_game=no
#endif
#else
[scenario]
#endif

    id=03_Kalian
    name= _ "Ka'lian under attack"
    next_scenario=04_Elvish_Treasury

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

    {LOW_PRESTART}

    [event]
        name=prestart

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

    {LOW_MASK 03_Kalian.mask (-9) (-3)}

    {TURNS 5 7 9}
    #turns=2
    

    {INTRO_AND_SCENARIO_MUSIC elf-land.ogg revelation.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
        controller=human
        user_team_name= _ "Player"
        team_name=player
        recruit={ELVES}
        save_id=Kalenz
        fog=yes
        share_view=yes
        {GOLD 300 200 100}
        {GALTRID}
        # wmllint: recognize Galtrid
        x=23
        y=22
    [/side]
    {STARTING_VILLAGES_ALL 1}

#ifdef MULTIPLAYER
    [event]
        name=prestart
        {CAPTURE_FILTERED_VILLAGES 6 (x=26-999 
                                      y=1-999)}
    [/event]
#endif

    #wml_disabled_lint: validate-off
    [side]
        side=2
        hidden=yes
        allow_player=no
        no_leader=yes
        controller=ai
        persistent=yes
        save_id=Galtrid
        team_name=player
        user_team_name= _ "Player"
        recruit={ELVES}
        gold=0
        {ai/aliases/stable_singleplayer.cfg}  #note that this MUST be given OUTSIDE the 'ai' tag
        [ai]
            {AI_NO_SCOUTS}
            {AI_SIMPLE_ALWAYS_ASPECT recruitment_pattern "healer,archer,fighter,archer,fighter,archer,healer,scout"}
        [/ai]
    [/side]

    #### Side3 code ####
    [side]
        side=3
        controller=ai
        allow_player=no
        {FLAG_VARIANT undead}
        no_leader=yes
        team_name=orcs
        fog=yes
        shroud=yes
        share_view=yes
        gold=0
        recruit=""
        [ai]
            version=10703
            [stage]
                id=leader_retreat
                engine=fai
                name=side_formulas
                #retreat on > half HP lost  or turn>=3
                move="if(my_leader!=null,if( (my_leader.hitpoints<my_leader.max_hitpoints/2) or (turn>=3),move(my_leader.loc,next_hop(my_leader.loc,loc(20,6))),move(my_leader.loc,my_leader.loc)),null)"
            [/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
        {FLAG_VARIANT undead}
        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
        {FLAG_VARIANT undead}
        no_leader=yes
        team_name=orcs
        shroud=yes
        fog=yes
        share_view=yes
#ifdef EASY
        recruit={ORCS1}, Orcish Crossbowman, Goblin Pillager, Goblin Knight
#endif
#ifdef NORMAL
        recruit={ORCS1}, Orcish Crossbowman, Goblin Pillager, Goblin Knight, Orcish Slayer, Goblin Impaler, Goblin Rouser, Orcish Warrior
#endif
#ifdef HARD
        recruit={ORCS1}, 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
        controller=human
        team_name=player
        user_team_name= _ "Player"
        recruit={ELVES}
        save_id=Landar
        fog=yes
        share_view=yes
        {GOLD 300 200 100} 
        {EL_ISOMITHIR}
        # wmllint: recognize El_Isomithir
        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 add -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]
                        [message]
                            message=_ " $orc_battlefield_strategy changed to attack "
                        [/message]
                        {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 ####

    #### Player's code ####
    [event]
        name=prestart

        [store_unit]
            variable=elves
            kill=yes
            [filter]
                side=1,6
                [not]
                    id=Galtrid
                [/not]
                [not]
                    id=El_Isomithir
                [/not]
            [/filter]
        [/store_unit]

        {UNIT 1 "Elvish Scout" 21 20 (id=guard) }
        # wmllint: recognize guard

        #TODO split to sides
#ifdef MULTIPLAYER
        {GENERIC_UNIT 6 "Elvish Scout" 17 22}
#else
        {GENERIC_UNIT 1 "Elvish Scout" 17 22}
        {GENERIC_UNIT 1 "Elvish Scout" 25 22}
#endif
      

        [store_gold]
            side=1
            variable=kalenz_gold
        [/store_gold]
#ifdef MULTIPLAYER
        [store_gold]
            side=6
            variable=landar_gold
        [/store_gold]
#endif

        [modify_side]
            side=1
#ifdef EASY
            gold=160
#endif
#ifdef NORMAL
            gold=100
#endif
#ifdef HARD
            gold=50
#endif
        [/modify_side]

#ifdef MULTIPLAYER
        [modify_side]
            side=6
#ifdef EASY
            gold=160
#endif
#ifdef NORMAL
            gold=100
#endif
#ifdef HARD
            gold=50
#endif
        [/modify_side]
#endif
        
    [/event]
    #### /Player's code ####

    #### Kalenz arrives ####

    [event]
        name="time over"

        {REPLACE_SCENARIO_MUSIC the_city_falls.ogg}

        {APPEND_MUSIC wanderer.ogg}
        #TODO add some more titles
        {APPEND_MUSIC suspense.ogg}

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

        {MODIFY_UNIT (side=1,6
        x=1-99
        y=1-99) side 2}

        [store_villages]
            variable=villages
            owner_side=1
        [/store_villages]

        {FOREACH villages village}
            [capture_village]
                side=2
                x=$villages[$village].x
                y=$villages[$village].y
            [/capture_village]
        {NEXT village}

        {CLEAR_VARIABLE villages}

        {FOREACH elves elf}
            [unstore_unit]
                variable=elves[$elf]
                x=recall
                y=recall
            [/unstore_unit]
        {NEXT elf}

        {CLEAR_VARIABLE kalenz}

        [recall]
            id=Kalenz
            x=33
            y=11
        [/recall]
        [recall]
            id=Landar
            x=31
            y=11
        [/recall]
        {RECALL_LOYALS}

        [store_gold]
            variable=galdrid_gold
            side=1
        [/store_gold]

        [modify_side]
            side=1
            gold=$kalenz_gold
            fog=no
        [/modify_side]

        [modify_side]
            side=2
            gold=$galdrid_gold
        [/modify_side]

#ifdef MULTIPLAYER
        [modify_side]
            side=6
            gold=$landar_gold
            fog=no
        [/modify_side]
#endif

        {CLEAR_VARIABLE kalenz_gold}
        {CLEAR_VARIABLE galdrid_gold}

        [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]
            [objective]
                description= _ "Turns run out"
                condition=lose
            [/objective]
            note={EARLY_FINISH_BONUS_NOTE}
        [/objectives]

        [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 wit 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 help!"
        [/message]

        {AI_CONTROLLER_ALLOW_LEADER_CONTROL 1 2}

        [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= _ "Death of Galtrid"
                condition=lose
            [/objective]
            [objective]
                description= _ "Turns run out"
                condition=win
            [/objective]
            [objective]
                description= _ "<span color='gold'>Bonus objective: Defeat Urudin </span>"
                condition=win
            [/objective]
        [/objectives]
    [/event]

    [event]
        name=start
        [scroll_to]
            x,y=21,22
        [/scroll_to]
        [delay]
            time=3000 #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 = Gg^Dr
            x,y=19,13
        [/terrain]
        {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]

        {GENERIC_UNIT 1 "Elvish Fighter" 20 17}
        {GENERIC_UNIT 1 "Elvish Fighter" 22 17}
        {GENERIC_UNIT 1 "Elvish Fighter" 22 24}
        {GENERIC_UNIT 1 "Elvish Fighter" 20 24}
        {GENERIC_UNIT 1 "Elvish Archer" 17 23}
        {GENERIC_UNIT 1 "Elvish Archer" 25 23}

#ifdef MULTIPLAYER
        {GENERIC_UNIT 6 "Elvish Archer" 17 21}
        {GENERIC_UNIT 6 "Elvish Fighter" 18 19}
        {GENERIC_UNIT 6 "Elvish Fighter" 24 19}
        {GENERIC_UNIT 6 "Elvish Archer" 25 21}
        {GENERIC_UNIT 6 "Elvish Archer" 19 25}
        {GENERIC_UNIT 6 "Elvish Archer" 23 25}
#else
        {GENERIC_UNIT 1 "Elvish Archer" 17 21}
        {GENERIC_UNIT 1 "Elvish Fighter" 18 19}
        {GENERIC_UNIT 1 "Elvish Fighter" 24 19}
        {GENERIC_UNIT 1 "Elvish Archer" 25 21}
        {GENERIC_UNIT 1 "Elvish Archer" 19 25}
        {GENERIC_UNIT 1 "Elvish Archer" 23 25}
#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]

        [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}
#undef ORC_BATTLEFIELD_EVALUATION
#undef ORC_BATTLEFIELD_EVALUATION_SUCCESS
#undef ORC_BATTLEFIELD_EVALUATION_FAILURE
    [/event]

    {campaigns/Legend_of_Wesmere/utils/deaths.cfg}

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