#textdomain wesnoth-low
[scenario]
#define HIGH_PRIORITY_TARGETS

    [goal]
        [criteria]
            # wmllint: recognize Kalenz
            id=Kalenz
        [/criteria]
        value=200
    [/goal]
#enddef

    id=21_Elvish_Assassins
    name= _ "Elvish Assassins"
    experience_modifier=100

    random_start_time=no
    allow_new_game=no

    {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}

    disallow_recall=yes

    next_scenario=22_Northern_Battle
    [story]
        [part]
            story= _ "After the council’s decision, Kalenz and Cleodil retired in the North."
            {LOW_BIGMAP}
            {CIVILWAR_STAGE1}
        [/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."
        [/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..."
        [/part]
    [/story]

#define PLAYER_GOLD
    {GOLD 260 200 140}
#enddef
#define MULTIPLAYER_GOLD
    {GOLD 160 130 100}
#enddef

    # wmllint: validate-off
    [side]
        side=1
        {PLAYABLE}
        {KALENZ}
        disallow_shuffle=yes
        x=11
        y=18

#ifndef MULTIPLAYER
        {PLAYER_GOLD}
        [unit]
            {CLEODIL}
            placement=leader
        [/unit]
#else
        {MULTIPLAYER_GOLD}
#endif
    [/side]
    # wmllint: validate-on
    {STARTING_VILLAGES_ALL 1}

    [event]
        name=prestart

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

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

    [event]
        name=prestart

        [set_variable]
            name=betraying_side
            rand=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
        allow_player=no
        {PLAYER_TEAM}
        type=Elvish Ranger
        id=Antaril
        name=_ "Antaril"
        canrecruit=yes
        x=5
        y=15
        random_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
        allow_player=no
        {PLAYER_TEAM}
        type=Elvish Captain
        id=East
        generate_name=yes
        random_traits=yes
        canrecruit=yes
        x=17
        y=15
#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}
#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
        allow_player=no
        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
        random_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
        {INCOME 4 8 12}
        {GOLD 300 400 500}
        [ai]
            {NO_SCOUTS}
            {HIGH_PRIORITY_TARGETS}
#ifndef HARD
            recruitment_pattern=archer, fighter
#else
            recruitment_pattern=archer, fighter, mixed fighter
#endif
        [/ai]
    [/side]

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

#ifdef MULTIPLAYER
    [side]
        side=6

        no_leader=yes
        [unit]
            {CLEODIL}
            x=11
            y=18
        [/unit]
        disallow_shuffle=yes
        {PLAYABLE}
        {MULTIPLAYER_GOLD}
    [/side]
#endif

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

            {TURNS_RUN_OUT}

            [gold_carryover]
                bonus=yes
                carryover_percentage=40
            [/gold_carryover]
        [/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
            {NEW_GOLD_CARRYOVER 40}
        [/endlevel]
    [/event]

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