#textdomain wesnoth-low

#define HIGH_PRIORITY_TARGETS
    [target]
        id=Kalenz
        value=200
    [/target]
#enddef

[scenario]
    id=21_Elvish_Assassins
    name= _ "Elvish Assassins"
    {LOW_MAP  Lintanir.map}
    {LOW_MASK 21_Elvish_Assassins.mask 1 1}

    {TURNS 20 16 12}

    {INTRO_AND_SCENARIO_MUSIC revelation.ogg the_dangerous_symphony.ogg}
    {EXTRA_SCENARIO_MUSIC the_king_is_dead.ogg}
    {EXTRA_SCENARIO_MUSIC sad.ogg}

    {DEFAULT_SCHEDULE}

    {LOW_PRESTART}

    next_scenario=22_Northern_Battle
    [story]
        [part]
            delay=4000
            show_title=yes
            {TO_ELVISH_ASSASSINS}
        [/part]
        [part]
            story= _ "After the council's decision, Kalenz and Cleodil retired in the North."
            {TO_ELVISH_ASSASSINS_BATTLE}
        [/part]
        [part]
            story= _ "Free of the pressure of war, they took delight in each other. The heart-bond they had formed amidst peril and death grew closer, and all but vanquished the remnant evil Crelanu's philter had left in Kalenz. The two began to think of having children."
            delay=8000
        [/part]
        [part]
            story= _ "But their peace was not to last. In the outer world, the blood tides were rising. And in the heart of Landar, who had once been their friend, evil was not vanquished, but festered and grew..."
            delay=8000
        [/part]
    [/story]

    # wmllint: validate-off
    [side]
        {KALENZ}
        # wmllint: recognize Kalenz
        x=11
        y=18
        team_name=player
        user_team_name= _ "Player"
        recruit={ELVES}
        #TODO differentiate the gold
        {GOLD 100 100 100}
        [unit]
            {CLEODIL}
            #wmllint: recognize Cleodil
            placement=leader
        [/unit]
    [/side]
    {STARTING_VILLAGES_ALL 1}
    # wmllint: validate-on
    [event]
        name=prestart

        [store_unit]
            kill=yes
            variable=kalenz_loyals
            [filter]
                side=1
                [not]
                    #wmllint: recognize Anduilas
                    id=Anduilas
                [/not]
                [not]
                    id=Kalenz
                [/not]
                [not]
                    id=Cleodil
                [/not]
            [/filter]
        [/store_unit]
        [recall]
            id=Anduilas
            x=16
            y=18
        [/recall]
    [/event]
    [event]
        name=start
        [scroll_to_unit]
            id=Kalenz
        [/scroll_to_unit]
        [message]
            speaker=narrator
            message= _ "Kalenz begins this scenario in retirement, and is not able to recall his veteran troops."
            image=wesnoth-icon.png
        [/message]
    [/event]

    [event]
        name=victory

        {FOREACH kalenz_loyals loyal_one}
            [unstore_unit]
                variable=kalenz_loyals[$loyal_one]
                x,y=recall,recall
            [/unstore_unit]
        {NEXT loyal_one}
        {CLEAR_VARIABLE loyal_one}
        {CLEAR_VARIABLE kalenz_loyals}
    [/event]

    #### Betrayer's code ####

    [event]
        name=prestart

        [set_variable]
            name=betraying_side
            random=2..3
        [/set_variable]

        [role]
            side=$betraying_side
            canrecruit=yes
            role=betrayer
        [/role]

        {STORE_UNIT_VAR (role=betrayer) name betrayer}
    [/event]

#define BETRAY_SPEECH
    [message]
        speaker=unit
        message= _ "As you command, my lord."
    [/message]
    [message]
        id=Cleodil
        message= _ "You turn on us? I cannot believe it! How has elf come to strive against elf so bitterly?"
    [/message]
    [message]
        id=Kalenz
        message= _ "Evil takes many forms, my love. Today we see another of its faces...and must defeat it again. Prepare to die, $betrayer|!"
    [/message]
    [message]
        role=betrayer
        message= _ "Only Landar has the will to do what must be done to save the Elves!"
    [/message]

    [modify_side]
        side=$betraying_side
        team_name=assassins
        user_team_name= _ "Enemies"
    [/modify_side]

    [store_unit]
        [filter]
            id=$unit.id
        [/filter]
        variable=to_restore
        kill=yes
        #TODO uncomment when the attribute animate is supported
        #animate=no
    [/store_unit]
    [event]
        name=attack end
        [unstore_unit]
            variable=to_restore
        [/unstore_unit]
        {CLEAR_VARIABLE to_restore}
    [/event]
#enddef

    [event]
        name=attack
        [filter]
            side=$betraying_side
        [/filter]
        [filter_second]
            side=4
            [or]
                side=5
            [/or]
            #team=assassins
        [/filter_second]

        [message]
            role=betrayer
            message= _ "Hold, $unit.name|! Now we fight for Landar!"
        [/message]

        {BETRAY_SPEECH}
    [/event]

    [event]
        name=attack
        [filter]
            side=4
            [or]
                side=5
            [/or]
            #            team=assassins
        [/filter]
        [filter_second]
            side=$betraying_side
        [/filter_second]

        [message]
            side=$unit.side
            canrecruit=yes
            message= _ "Hold your hand, $unit.name|! $second_unit.name| is on our side!"
        [/message]

        [message]
            role=betrayer
            message= _ "I will not stand by as Kalenz betrays us to the Humans and Dwarves. We follow Landar now!"
        [/message]

        {BETRAY_SPEECH}
    [/event]

    #### /Betrayer's code ####

    [side]
        side=2
        team_name=player
        user_team_name= _ "Player"
        type=Elvish Ranger
        id=Antaril
        name=_ "Antaril"
        canrecruit=yes
        x=5
        y=15
        generate_traits=yes
#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 320 350}
        [ai]
#ifndef HARD
            recruitment_pattern=archer,fighter
#else
            recruitment_pattern=archer,fighter,mixed fighter
#endif
            #    {HIGH_PRIORITY_TARGETS}
        [/ai]
    [/side]

    [side]
        side=3
        team_name=player
        user_team_name= _ "Player"
        type=Elvish Captain
        id=East
        generate_name=yes
        generate_traits=yes
        canrecruit=yes
        x=17
        y=15
        generate_traits=yes
#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 320 350}
        [ai]
            #    {HIGH_PRIORITY_TARGETS}
            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]

    [side]
        #TODO Crintil shall not die
        side=4
        persistent=yes
        save_id=Crintil
        team_name=assassins
        user_team_name= _ "Enemies"
        type=Elvish Marshal
        id=Crintil
        name= _ "Crintil"
        canrecruit=yes
        x=11
        y=1
        generate_traits=yes
#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
        {NO_SCOUTS}
        {INCOME 4 8 12}
        {GOLD 300 400 500}
        [ai]
            {HIGH_PRIORITY_TARGETS}
            recruitment_ignore_bad_movement=yes
#ifndef HARD
            recruitment_pattern=archer, fighter
#else
            recruitment_pattern=archer, fighter, mixed fighter
#endif
        [/ai]
    [/side]

    [side]
        side=5
        team_name=assassins
        user_team_name= _ "Enemies"
        type=Elvish Captain
        canrecruit=yes
        x=10
        y=27
        id=Oblil
        name= _ "Oblil"
        generate_traits=yes
#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
        {NO_SCOUTS}
        {INCOME 4 8 12}
        {GOLD 200 250 300}
        [ai]
            {HIGH_PRIORITY_TARGETS}
            recruitment_ignore_bad_movement=yes
#ifndef HARD
            recruitment_pattern=archer, fighter
#else
            recruitment_pattern=archer, fighter, mixed fighter
#endif
        [/ai]
    [/side]
#undef HIGH_PRIORITY_TARGETS

    [event]
        name=prestart
        [objectives]
            side=1
            [objective]
                description= _ "Kalenz reaches the signpost"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Kalenz"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Cleodil"
                condition=lose
            [/objective]
            [objective]
                description= _ "Turns run out"
                condition=lose
            [/objective]
            note={EARLY_FINISH_BONUS_NOTE}
        [/objectives]
    [/event]

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

        [move_unit_fake]
            type=Elvish Scout
            x=10,11,12,13,14,15
            y=25,24,23,22,21,20
        [/move_unit_fake]

        [unit]
            id=Galenor
            name=_ "Galenor"
            type=Elvish Scout
            side=1
            x=15
            y=20
            facing=sw
        [/unit]

        [message]
            id=Galenor
            message= _ "My lord Kalenz, you are in great danger! You must leave here immediately."
        [/message]
        [message]
            id=Kalenz
            message= _ "What?!"
        [/message]
        [message]
            id=Galenor
            message= _ "Landar has seized control of the army. He has eliminated the council and proclaimed himself High Warlord of the Elves. What is worse, there is word out that he has already ordered your assassination."
        [/message]
        [message]
            id=Crintil
            message= _ "Too late! All traitors will die!"
        [/message]
        [message]
            id=Kalenz
            message= _ "Listen to me! We have fought and bled side by side. We must trust in each other and face the orcs together!"
        [/message]

        [message]
            id=Oblil
            message= _ "Do not listen to this traitor! You have all heard the order!"
        [/message]

        [message]
            id=Galenor
            message= _ "You should try to reach Uradredia and the North Elves. He too, has refused to join Landar. Word is that some troops still loyal to you are heading there."
        [/message]

        {HIGHLIGHT_IMAGE 1 30 scenery/signpost.png ()}

        [scroll_to_unit]
            id=Kalenz
        [/scroll_to_unit]
    [/event]

    [event]
        name=moveto
        [filter]
            x=1
            y=30
            id=Kalenz
        [/filter]
        [message]
            speaker=unit
            message= _ "Now we must fare swiftly to the North Elves!"
        [/message]
        [endlevel]
            result=victory
            bonus=yes
        [/endlevel]
    [/event]

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