#textdomain wesnoth-low
[scenario]
    name= _ "The Uprooting"
    id=01_The_Uprooting
    next_scenario=02_Hostile_Mountains

    random_start_time=no
    allow_new_game=yes
    new_game_title= _ "Chapter One: Flight and Fight"
    force_lock_settings=yes

    experience_modifier=100
    {LOW_MAP  Lintanir.map}
    {LOW_MASK 01_The_Uprooting.mask 1 1}

    {TURNS 20 17 14}

    {INTRO_AND_SCENARIO_MUSIC elf-land.ogg breaking_the_chains.ogg}
    {EXTRA_SCENARIO_MUSIC elvish-theme.ogg}
    {EXTRA_SCENARIO_MUSIC nunc_dimittis.ogg}
    {EXTRA_SCENARIO_MUSIC casualties_of_war.ogg}
    {EXTRA_SCENARIO_MUSIC silvan_sanctuary.ogg}

    {DEFAULT_SCHEDULE_DUSK}
    {STARTING_VILLAGES_ALL 3}

    [story]
        [part]
            title= _ "<i>The Legend of Wesmere</i>
Chapter One"
        [/part]
        [part]
            title= _ "Chapter One
<i>Flight and Fight</i>"
        [/part]
        [part]
            story=_ "The great elven heroes Kalenz and Landar were born in a quiet green wood in Lintanir on the fringes of the Great Northern Forest."
            {LOW_BIGMAP}
            {NEW_REST 1094 444}
        [/part]
        [part]
            story=_ "Though not of noble birth, Kalenz showed early promise in the arts of his people. His quick intelligence gained him more than usual respect among elders normally inclined to pay little heed to anyone younger than a century old."
            background="story/characters/kalenz.webp"
            scale_background=no
        [/part]
        [part]
            story=_ "Landar and Kalenz were friends from childhood. He too attracted the attention of elders, at first because of a knack for mischief and pranks. But there was no real harm in the boy, and his jokes made him popular among the younger elves."
            background="story/characters/landar.wevp"
            scale_background=no
        [/part]
        [part]
            story=_ "Perhaps the elders sensed that changing times would require more flexible minds; these were the years when humans from the Green Isle were establishing themselves south of the Great River, and the known world was changing more rapidly than it had for a thousand years before."
        [/part]
        [part]
            story=_ "Some changes were good. The elves, awakened as from a long dream, began to increase in population. But some were very bad, and the worst of those was the coming of the orcs, the wreckers, the tree-killers. The years of their long childhoods were a golden age, and the last time of untroubled peace."
        [/part]
        [part]
            story=_ "The elves had never been a martial people, and they were not prepared for the inevitable war with the orcs. The friends came of age in the very year that Erlornas of Wesmere fought the first orcish raiders. Within the next decade orcish raids greatly increased, and their shadow loomed ever greater over the elves.

This is the story of Kalenz, Landar, and of the elves in the first days of the humans in Wesnoth."
            background="story/landscape-battlefield.webp"
        [/part]
    [/story]
    {LOW_TRACK {FLIGHT_STAGE1} }

    #### Kalenz's side ####
#define SINGLEPLAYER_GOLD
    {GOLD 240 200 180}
    {INCOME -2 -2 -2}
    village_gold=1
#enddef

#define MULTIPLAYER_GOLD
    {GOLD 140 120 100}
    {INCOME -2 -2 -2}
    village_gold=1
#enddef

    # wmllint: validate-off
    [side]
        side=1
        {PLAYABLE}
        # wmllint: who KALENZ_YOUNG is Kalenz
        {KALENZ_YOUNG}
        save_id=Kalenz
        x=16
        y=15

#ifndef MULTIPLAYER
        [unit]
            # wmllint: who LANDAR_YOUNG is Landar
            {LANDAR_YOUNG}
            x=18
            y=15
        [/unit]
        [unit]
            # wmllint: who ARKILDUR is Arkildur
            {ARKILDUR}
            x=19
            y=16
        [/unit]
        {SINGLEPLAYER_GOLD}
#else
        disallow_shuffle=yes
        {MULTIPLAYER_GOLD}
#endif
        [unit]
            # wmllint: who ANDUILAS is Anduilas
            {ANDUILAS}
            x=15
            y=16
        [/unit]
    [/side]
    # wmllint: validate-on

    [event]
        name=last breath
        [filter_second]
            id=Kalenz
        [/filter_second]
        [message]
            speaker=second_unit
            message= _ "You trifled with the wrong elf!"
        [/message]
    [/event]
    [event]
        name=last breath
        [filter_second]
            id=Landar
        [/filter_second]
        [message]
            speaker=second_unit
            message= _ "Take that, you orcish scum!"
        [/message]
    [/event]
    #### /Kalenz side ####

    #### Landar's side ####
    # wmllint: skip-side
    {MP_SIDE 2 (
        {PLAYABLE}
        {LANDAR_YOUNG}
        save_id=Landar
        x=18
        y=15
        disallow_shuffle=yes

        {MULTIPLAYER_GOLD}

        [unit]
            {ARKILDUR}
            x=19
            y=16
        [/unit]
    )}
    #### Landar's side ####

    [side]
        side=3
        id=Velon
        {ELF_SETUP}
        village_gold=1
        controller=ai
        allow_player=no
        name= _ "Velon"
        {PLAYER_TEAM}
        recruit=Elvish Fighter,Elvish Archer
        {GOLD 150 180 200}
        type=Elvish Captain
        profile="portraits/velon.webp"
        canrecruit=yes
        x=5
        y=15
        [modifications]
            {TRAIT_AGED}
            {TRAIT_INTELLIGENT}
        [/modifications]
        [ai]
            {AI_SIMPLE_ALWAYS_ASPECT village_value 0}
            {AI_SIMPLE_ALWAYS_ASPECT leader_value 0}
            {AI_SIMPLE_ALWAYS_ASPECT_VALUE avoid (
                x=1-30,1-30,1-3,7-30
                y=1-13,17-30,1-30,1-30
            )}
        [/ai]
    [/side]

    [side]
        side=4
        id=Tbaran
        name= _ "T’baran"
        team_name=orcs
        user_team_name= _ "Enemies"
        allow_player=no
        controller=ai
        {ORC_SETUP}
        #{FLAG_VARIANT undead}
        type=Orcish Warrior
        canrecruit=yes
        x=27
        y=14
#ifdef EASY
        recruit=Orcish Archer, Orcish Assassin, Orcish Grunt, Wolf Rider, Orcish Crossbowman, Goblin Knight, Goblin Pillager
#endif
#ifdef NORMAL
        recruit=Orcish Archer, Orcish Assassin, Orcish Grunt, Wolf Rider, Orcish Crossbowman, Goblin Knight, Goblin Pillager, Orcish Slayer
#endif
#ifdef HARD
        recruit=Orcish Archer, Orcish Assassin, Orcish Grunt, Wolf Rider, Orcish Crossbowman, Goblin Knight, Goblin Pillager, Orcish Slayer, Orcish Warrior
#endif
        {GOLD 120 160 200}
        {INCOME 10 20 30}
        [ai]
            {AI_NO_SCOUTS}
            {AI_SIMPLE_ALWAYS_ASPECT recruitment_pattern "fighter,fighter,archer,fighter,fighter,mixed fighter,scout"}
            {AI_SIMPLE_ALWAYS_ASPECT aggression 0.75}
            {AI_SIMPLE_ALWAYS_ASPECT caution 0}
            {AI_SIMPLE_ALWAYS_ASPECT grouping no}
        [/ai]
    [/side]

    [side]
        side=5
        allow_player=no
        controller=ai
        id=Wrulf
        name= _ "Wrulf"
        team_name=orcs
        user_team_name= _ "Enemies"
        {ORC_SETUP}
        #{FLAG_VARIANT undead}
        type=Orcish Warrior
        canrecruit=yes
        x=7
        y=29
        recruit=Orcish Archer, Orcish Assassin, Orcish Grunt

        {GOLD 120 140 160}
        {INCOME 10 20 30}
        [ai]
            {AI_NO_SCOUTS}
            {AI_SIMPLE_ALWAYS_ASPECT recruitment_pattern "fighter,mixed fighter,archer,mixed fighter"}
            {AI_SIMPLE_ALWAYS_ASPECT grouping no}

            {AI_SIMPLE_ALWAYS_ASPECT aggression 0.75}
#ifdef EASY
            {AI_SIMPLE_NIGHT_ASPECT leader_aggression 0.5}
#endif
#ifdef NORMAL
            {AI_SIMPLE_NIGHT_ASPECT leader_aggression -0.5}
#endif

            {AI_SIMPLE_DAY_ASPECT caution 0}
        [/ai]
    [/side]

    [side]
        side=6
        allow_player=no
        controller=ai
        team_name=orcs
        user_team_name= _ "Enemies"
        {ORC_SETUP}
        #{FLAG_VARIANT undead}
        type=Orcish Warrior
        id=Qumseh
        name= _ "Qumseh"
        profile=portraits/orcs/warlord.webp
        canrecruit=yes
        x=28
        y=2
#ifdef EASY
        recruit=Orcish Archer, Orcish Assassin, Orcish Grunt, Wolf Rider, Orcish Crossbowman, Goblin Pillager, Goblin Knight
#endif
#ifdef NORMAL
        recruit=Orcish Archer, Orcish Assassin, Orcish Grunt, Wolf Rider, Orcish Crossbowman, Goblin Knight, Orcish Slayer
#endif
#ifdef HARD
        recruit=Orcish Archer, Orcish Assassin, Orcish Grunt, Wolf Rider, Orcish Crossbowman, Orcish Warrior, Goblin Knight, Goblin Pillager, Orcish Slayer
#endif
        {GOLD 100 130 160}
        {INCOME 10 30 50}
        [ai]
            {AI_NO_SCOUTS}
            {AI_SIMPLE_ALWAYS_ASPECT recruitment_pattern "scout"}
            {AI_SIMPLE_ALWAYS_ASPECT aggression 0.75}
            {AI_SIMPLE_ALWAYS_ASPECT village_value 0}
            {AI_SIMPLE_ALWAYS_ASPECT caution 0}
            {AI_SIMPLE_ALWAYS_ASPECT grouping no}
        [/ai]
    [/side]
    [side]
        side=7
        allow_player=no
        controller=ai
        team_name=orcs
        user_team_name= _ "Enemies"
        {ORC_SETUP}
        #{FLAG_VARIANT undead}
        type=Orcish Warrior
        id=Graur-Tan
        name= _ "Graur-Tan"
        profile=portraits/orcs/warlord.webp
        canrecruit=yes
        x=2
        y=4
#ifdef EASY
        recruit=Orcish Archer, Orcish Assassin, Orcish Grunt, Wolf Rider, Orcish Crossbowman, Goblin Pillager, Goblin Knight
#endif
#ifdef NORMAL
        recruit=Orcish Archer, Orcish Assassin, Orcish Grunt, Wolf Rider, Orcish Crossbowman, Goblin Knight, Orcish Slayer
#endif
#ifdef HARD
        recruit=Orcish Archer, Orcish Assassin, Orcish Grunt, Wolf Rider, Orcish Crossbowman, Orcish Warrior, Goblin Knight, Goblin Pillager, Orcish Slayer
#endif
        {GOLD 100 130 160}
        {INCOME 10 30 50}
        [ai]
            {AI_NO_SCOUTS}
            {AI_SIMPLE_ALWAYS_ASPECT recruitment_pattern "fighter,scout,fighter,fighter,archer,scout,mixed fighter"}
            {AI_SIMPLE_ALWAYS_ASPECT aggression 0.75}
            {AI_SIMPLE_ALWAYS_ASPECT caution 0}
            {AI_SIMPLE_ALWAYS_ASPECT grouping no}
        [/ai]
    [/side]

    [event]
        name=start

        [message]
            id=Kalenz
            message= _ "Orcs are pressing on us from all directions! To arms!"
        [/message]
        [message]
            id=Velon
            message= _ "Hold, Kalenz. The Ka’lian Council should discuss our response. Maybe we can reach an agreement with them!"
        [/message]
        [message]
            id=Qumseh
            message= _ "Surrender or die, tree-shaggers!"
        [/message]
        [message]
            id=Velon
            message= _ "They are too many. We have no choice but to submit!"
        [/message]
        [message]
            id=Kalenz
            message= _ "Elves must never surrender to these foul beasts! Who will fight them beside me?"
        [/message]
        [message]
            #Changed the text from here on - The objectives changed from
            #reaching the signpost and bonus for the death of a leader
            #to death of an enemy leader for victory and bonus for not
            #loosing velon.
            id=Landar
            message= _ "We will follow you, Kalenz — but where can we go?"
        [/message]
        [message]
            id=Kalenz
            message= _ "We must reach the Elvish Council in Ka’lian and enlist their help to recapture our home."
        [/message]
        [message]
            id=Landar
            message= _ "We are surrounded!"
        [/message]
        [message]
            id=Kalenz
            message= _ "Then we must storm one of the orcs’ outposts to break the encirclement before more enemies arrive!"
        [/message]
        [message]
            id=Anduilas
            message= _ "Very well, Kalenz — lead us!"
        [/message]

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

    [event]
        name=start

        [objectives]
            side=0
            [objective]
                description= _ "Kill any of the orc leaders"
                condition=win
            [/objective]
            [objective]
                {BONUS_OBJECTIVE_CAPTION}
                description= _ "Keep Velon alive"+{EARLY_FINISH_BONUS_FOOTNOTE}
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Kalenz"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Landar"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

            [gold_carryover]
                carryover_percentage=40
            [/gold_carryover]
        [/objectives]
    [/event]

    [event]
        name=attack
        [filter_second]
            [filter_side]
                [has_unit]
                    id=Velon
                [/has_unit]
            [/filter_side]
        [/filter_second]

        {INCIDENTAL_MUSIC the_king_is_dead.ogg}

        [message]
            id=Velon
            message= _ "We surrender!"
        [/message]
        [message]
            id=Graur-Tan
            message= _ "Did I mention that we take no prisoners? Die!"
        [/message]
        #TODO Maybe that must change for multiplayer
        [message]
            id=Velon
            message= _ "Kalenz was right and I was wrong. Go; join Kalenz while yet you can. I and the remaining elders will cover your retreat as best we may."
        [/message]
    [/event]

    [event]
        name=victory
        #[message]
        #    id=Kalenz
        #TODO ESR
        #    message= _ "And Velon? What about him?"
        #    [show_if]
        #        [have_unit]
        #            id=Velon
        #        [/have_unit]
        #    [/show_if]
        #[/message]
        [message]
            id=Velon
            message= _ "Flee, Kalenz... find vengeance for us!"
        [/message]
        [message]
            id=Kalenz
            message= _ "Velon, I swear on the life of Irdya that I will not let you be forgotten while elves yet draw breath to sing."
            [show_if]
                [have_unit]
                    id=Velon
                [/have_unit]
            [/show_if]
        [/message]
        [message]
            id=Velon
            message= _ "Swords will aid us more than songs, Kalenz; you saw that before I."
        [/message]
        [message]
            id=Kalenz
            message= _ "Swordsmen you shall have, as swiftly as I can find them and return."
            [show_if]
                [have_unit]
                    id=Velon
                [/have_unit]
            [/show_if]
        [/message]

        [message]
            id=Landar
            message= _ "Velon has fallen. He counseled weakness, but did not deserve such an ugly death. We shall return with swords to avenge him!"
            [show_if]
                [not]
                    [have_unit]
                        id=Velon
                    [/have_unit]
                [/not]
            [/show_if]
        [/message]
        #[message]
        #    id=Kalenz
        #TODO ESR
        #    message= _ "Let's move on!"
        #[/message]

        [message]
            canrecruit=yes
            race=orc
            message= _ "You won’t get very far! After them!"
        [/message]
        [kill]
            id=Velon
            animate=no
        [/kill]
    [/event]

    [event]
        name=last breath
        [filter]
            canrecruit=yes
            race=orc
        [/filter]

        [message]
            speaker=unit
            message= _ "Curse you, tree-shaggers! We will feed your young to our wolves!"
        [/message]
    [/event]

    [event]
        name=die
        [filter]
            canrecruit="yes"
            race=orc
        [/filter]

        [message]
            speaker=second_unit
            message= _ "What is this? The orc held plunder!"
        [/message]
#ifdef MULTIPLAYER
        {LOOT 25 1}
        {LOOT 25 2}
#else
        {LOOT 50 1}
#endif

        [if]
            [have_unit]
                id=Velon
            [/have_unit]
            [then]
                [endlevel]
                    result=victory
#ifdef MULTIPLAYER
                    bonus=0.5
#else
                    bonus=yes
#endif
                    {NEW_GOLD_CARRYOVER 40}
                [/endlevel]
            [/then]
            [else]
                [endlevel]
                    result=victory
                    bonus=no
                    {NEW_GOLD_CARRYOVER 40}
                [/endlevel]
            [/else]
        [/if]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Velon
        [/filter]

        {INCIDENTAL_MUSIC sad.ogg}
        [message]
            id=Velon
            message= _ "Flee, Kalenz... Our hopes ride with you..."
        [/message]
    [/event]

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

#undef MULTIPLAYER_GOLD
#undef SINGLEPLAYER_GOLD
