#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}
    {./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}

    [story]
        [part]
            story= _ "Kalenz and Cleodil managed to reach the North Elves to ask for help. Very soon, Landar's army appeared..."
            delay=4000
            {TO_NORTHERN_BATTLE}
        [/part]
    [/story]

    #wmllint: validate-off
    [side]
        side=1
        no_leader=yes
        save_id=Kalenz
        team_name=kalenz
        controller=human
        recruit={ELVES}
        {GOLD 100 100 100}
    [/side]
    # wmllint: recognize Kalenz
    {RECALL_KALENZ 42 29}

    [side]
        side=2
        no_leader=yes
        team_name=kalenz
        recruit={ELVES}
        [unit]
            {URADREDIA}
            x=24
            y=7
        [/unit]
    [/side]
    #wmllint: validate-on

    [side]
        # Landar gets unstored here
        no_leader=yes
        side=3
        team_name=assassins
#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]
        [ai]
            passive_leader=yes
            time_of_day=dusk,first_watch,second_watch
            aggression=0.75
            caution=0.0
            grouping=no
        [/ai]
        {INCOME 4 8 12}
    [/side]
    [side]
        side=4
        no_leader=yes
        team_name=assassins
        [unit]
            type=Elvish Captain
            id=Crintil
            name=_ "Crintil"
            canrecruit=yes
            x=46
            y=39
        [/unit]
#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]
        [ai]
            time_of_day=dusk,first_watch,second_watch
            aggression=0.75
            caution=0.0
            grouping=no
        [/ai]
        {INCOME 4 8 12}
    [/side]

    [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]
        [/objectives]

        {RECALL_LOYALS}

        {CHECK_CLEODIL}

        {FOREACH healer_store i}
            [unstore_unit]
                variable=healer_store[$i]
            [/unstore_unit]
        {NEXT i}

        {CLEAR_VARIABLE healer_store}

        {CHECK_LANDAR_STORE ()}

        {VARIABLE landar_store.side 3}
        {VARIABLE landar_store.canrecruit yes}
        {VARIABLE landar_store.x   15}
        {VARIABLE landar_store.y   38}

        [unstore_unit]
            variable=landar_store # wmllint: recognize Landar
        [/unstore_unit]
        {CLEAR_VARIABLE landar_store}

        {REMOVE_HERO_ICON (id=Landar)}

        #TODO unstore troop_store
    [/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! Let 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]

    [event]
        name=victory

        [store_unit]
            variable=landar_store
            kill=yes
            [filter]
                id=Landar
            [/filter]
        [/store_unit]
    [/event]

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