#textdomain wesnoth-low
[scenario]
    name= _ "Northern Battle"
    id=22_Northern_Battle
    next_scenario=23_End_of_War

    {LOW_MAP  North_Elves.map}
    {LOW_MASK 22_Northern_Battle.mask 1 1}
    {./North_elves_utils.cfg}

    {TURNS 40 36 32}
    {DEFAULT_SCHEDULE}

    # TODO find better music
    {INTRO_AND_SCENARIO_MUSIC elf-land.ogg breaking_the_chains.ogg}
    {EXTRA_SCENARIO_MUSIC legends_of_the_north.ogg}
    {EXTRA_SCENARIO_MUSIC elvish-theme.ogg}
    {EXTRA_SCENARIO_MUSIC the_city_falls.ogg}

    {LOW_PRESTART}

    [story]
        [part]
            story= _ "It was clear to Kalenz and Cleodil that there would be no sanctuary for them while Landar lived. But during their years in seclusion thee fame of their deeds had only grown. Many healers and sorceresses responded to Cleodil's call, and Kalenz found that recruits came to him as readily as if he were still High Lord in name."
        [/part]
        [part]
            story= _ "Kalenz's veterans joined the host of the Northern Elves under Uradredia. Very soon, Landar's army appeared..."
            delay=4000
            {TO_NORTHERN_BATTLE}
        [/part]
    [/story]

    #wmllint: validate-off
    [side]
        {KALENZ}
        # wmllint: recognize Kalenz
        team_name=player
        user_team_name= _ "Player"
        controller=human
        recruit={ELVES}
        {GOLD 100 100 100}
        x=42
        y=29
        [unit]
            {CLEODIL}
            placement=leader
            #wmllint: recognize Cleodil
        [/unit]
    [/side]

    [event]
        name=prestart

        # transfer our veterans except Anduilas to side 2
        # wmllint: recognize Anduilas
        [store_unit]
            #TODO spellcheck
            variable=steal_wearer
            kill=yes
            [filter]
                side=1
                # role=kalenz_loyal
                [not]
                    id=Kalenz
                [/not]
                # wmllint: recognize Anduilas
                [not]
                    id=Anduilas
                [/not]
                # wmllint: recognize Landar
                [not]
                    id=Landar
                [/not]
                [not]
                    type={SHAMANS}
                [/not]
            [/filter]
        [/store_unit]

        {FOREACH steal_wearer unit}
            {VARIABLE steal_wearer[$unit].side 2}
            [unstore_unit]
                variable=steal_wearer[$unit]
                x,y=recall,recall
            [/unstore_unit]
        {NEXT unit}
        {CLEAR_VARIABLE unit}
        {CLEAR_VARIABLE steal_wearer}

        {LOW_STEAL_UNIT_TO "Landar" 3}

        # recall our loyals
        {RECALL_LOYALS}
    [/event]

    # wmllint: recognize Uradredia
    [event]
        name=victory
        {MODIFY_UNIT (side=2
        [not]
            id=Uradredia
        [/not]) side 1}
    [/event]

    [event]
        name=start
        [message]
            speaker=narrator
            message= _ "Kalenz can only recall shamans and their advancements from his former army; the rest of his men joined Uradredia before he arrived."
            image=wesnoth-icon.png
        [/message]
    [/event]

    [side]
        {URADREDIA}
        #wmllint: recognize Uradredia
        persistent=yes
        save_id=Uradredia
        side=2
        team_name=player
        user_team_name= _ "Player"
        recruit={ELVES}
        x=24
        y=7
    [/side]

    [side]
        [unit]
            {LANDAR}
            #wmllint: recognize Landar
            x=15
            y=38
        [/unit]
        side=3
        no_leader=yes
        team_name=landar
        persistent=yes
        save_id=Landar
        user_team_name= _ "Enemies"
#ifdef EASY
        recruit=Elvish Archer, Elvish Fighter
#endif
#ifdef NORMAL
        recruit=Elvish Archer, Elvish Fighter, Elvish Hero
#endif
#ifdef HARD
        recruit=Elvish Archer, Elvish Fighter, Elvish Hero, Elvish Ranger
#endif
        {GOLD 400 600 750}
        [ai]
            passive_leader=yes
            {NO_SCOUTS}
            recruitment_ignore_bad_movement=yes
#ifndef HARD
            recruitment_pattern=archer, fighter
#else
            recruitment_pattern=archer, fighter, mixed fighter
#endif
        [/ai]
        {INCOME 4 8 12}
    [/side]
    #wmllint: validate-on
    [event]
        name=prestart
        {MODIFY_UNIT id=Landar canrecruit yes}
    [/event]

    [side]
        side=4
        persistent=yes
        save_id=Crintil
        team_name=landar
        user_team_name= _ "Enemies"
        type=Elvish Marshal
        id=Crintil
        name=_ "Crintil"
        canrecruit=yes
        x=46
        y=39
#ifdef EASY
        recruit=Elvish Archer, Elvish Fighter
#endif
#ifdef NORMAL
        recruit=Elvish Archer, Elvish Fighter, Elvish Hero
#endif
#ifdef HARD
        recruit=Elvish Archer, Elvish Fighter, Elvish Hero, Elvish Ranger
#endif

        {GOLD 200 200 200}
        [ai]
            {NO_SCOUTS}
            recruitment_ignore_bad_movement=yes
#ifndef HARD
            recruitment_pattern=archer, fighter
#else
            recruitment_pattern=archer, fighter, mixed fighter
#endif
        [/ai]
    [/side]
    [event]
        name=prestart
        [allow_recruit]
            side=4
#ifdef EASY
            type=Elvish Archer, Elvish Fighter
#endif
#ifdef NORMAL
            type=Elvish Archer, Elvish Fighter, Elvish Hero
#endif
#ifdef HARD
            type=Elvish Archer, Elvish Fighter, Elvish Hero, Elvish Ranger
#endif
        [/allow_recruit]
    [/event]

    [event]
        name=prestart

        [objectives]
            side=1
            [objective]
                description= _ "Defeat all enemy leaders"
                condition=win
            [/objective]
            [objective]
                description= _ "Survive for six days"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Kalenz"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Cleodil"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Uradredia"
                condition=lose
            [/objective]
            note={EARLY_FINISH_BONUS_NOTE}
        [/objectives]
    [/event]

    [event]
        name=start
        [message]
            id=Kalenz
            message= _ "Landar, listen to me! It does not have to come to this. I know about the potion. Let us help!"
        [/message]
        [message]
            id=Landar
            message= _ "Here is Kalenz. There can be no talk with traitors! Leave none of them alive!"
        [/message]
    [/event]

    [event]
        name=moveto

        [filter]
            side=1,2
            [filter_adjacent]
                id=Landar
            [/filter_adjacent]
        [/filter]

        [message]
            id=Landar
            message= _ "Things are not going well! Retreat! We will meet again, traitors!"
        [/message]
        [endlevel]
            result=victory
        [/endlevel]
    [/event]

    [event]
        name=time over

        [message]
            id=Landar
            message= _ "We have yet to break their defenses! While we are getting weaker, the enemy is getting stronger! Retreat!"
        [/message]
        [message]
            id=Kalenz
            message= _ "We won!"
        [/message]

        [endlevel]
            result=victory
        [/endlevel]
    [/event]

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