#textdomain wesnoth-low

#ifdef MULTIPLAYER
[multiplayer]
    name= _ "Legend of Wesmere"
    random_start_time=no
#else
[scenario]
    name= _ "The Uprooting"
#endif

    id=01_The_Uprooting

    {LOW_MAP  Lintanir.map}
    {LOW_MASK 01_Uprooting.mask 1 1}
#ifdef MULTIPLAYER
    {LOW_MASK 01_Uprooting_MP.mask 1 1}
#endif

    {TURNS 16 14 12}

    {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 journeys_end.ogg}

    {DEFAULT_SCHEDULE}
    {STARTING_VILLAGES 2 50}

    {LOW_PRESTART}

    next_scenario=02_Hostile_mountains
    victory_when_enemies_defeated=no

    [story]
        [part]
            delay=4000
            #show_title=yes
            title= _ "The Uprooting"
            {TO_THE_UPROOTING}
        [/part]
        [part]
            story=_ "The great elvish hero Kalenz was born in a quiet green wood in Lintanir on the fringes of the Great Northern Forest. Though not of noble birth, he 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."
            delay=4000
            background="story/characters/kalenz.png"
            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."
            delay=4000
            background="story/characters/kalenz.png"
            scale_background=no
        [/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 Kalenz's long childhood were a golden age, and the last time of untroubled peace."
            delay=4000
            background="story/characters/kalenz.png"
            scale_background=no
        [/part]
        [part]
            story=_ "The elves had never been a martial people, and they were not prepared for the inevitable war with the orcs. Kalenz 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, and of the Elves in the days of the humans in Wesnoth."
            delay=8000
            background="story/landscape-battlefield.jpg"
        [/part]
    [/story]

    #### Kalenz's side ####
    #wmllint: validate-off
#define PLAYER_GOLD
    {GOLD 240 200 180}
#enddef

    [side]
        side=1
        fog=no
        {KALENZ}
        # wmllint: recognize Kalenz
        save_id=Kalenz
        controller=human
        team_name=player
        user_team_name= _ "Player"
        recruit={ELVES}
        {PLAYER_GOLD}
        x=17
        y=15
#ifndef MULTIPLAYER
        [unit]
            {LANDAR}
            # wmllint: recognize Landar
            placement=leader
        [/unit]
#endif
        [unit]
            id=Anduilas
            name= _ "Anduilas"
            unrenamable=yes
            type=Elvish Fighter
            #TODO enable the coordinates after the persistence test phase
            #            x,y=19,15
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_STRONG}
                {TRAIT_INTELLIGENT}
            [/modifications]
            {IS_LOYAL}
            placement=leader
        [/unit]
    [/side]
    #wmllint: validate-on

    #TODO I have seen better solutions in NR
    [event]
        name=prestart
        {INIT_LANDAR}
    [/event]
    [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 ####

    [side]
        side=2
        controller=ai
        allow_player=no
        id=Velon
        name= _ "Velon"
        team_name=player
        user_team_name= _ "Player"
        recruit=Elvish Fighter,Elvish Archer,Elvish Shaman
        {GOLD 100 100 100}
        type=Elvish Captain
        profile="portraits/velon.png"
        canrecruit=yes
        team_name=player
        x=5
        y=15
        [modifications]
            {TRAIT_AGED}
            {TRAIT_INTELLIGENT}
        [/modifications]
        {ai/aliases/stable_singleplayer.cfg}
        [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=3
        id=Tbaran
        name= _ "T'baran"
        team_name=orcs
        user_team_name= _ "Enemies"
        allow_player=no
        controller=ai
        {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 150 230 300}
        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_NO_SCOUTS}
            {AI_SCALE_ATTACK_DEPTH_BY_DIFFICULTY}
            {AI_SIMPLE_ALWAYS_ASPECT recruitment_ignore_bad_movement yes}
            {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]
        {INCOME 4 8 12}
    [/side]

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

        {GOLD 150 230 300}
        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_NO_SCOUTS}
            {AI_SIMPLE_ALWAYS_ASPECT recruitment_ignore_bad_movement yes}
            {AI_SIMPLE_ALWAYS_ASPECT recruitment_pattern "fighter,mixed fighter,archer,mixed fighter"}
            {AI_SIMPLE_ALWAYS_ASPECT grouping no}
            {AI_SCALE_ATTACK_DEPTH_BY_DIFFICULTY}

            {AI_SIMPLE_DAY_ASPECT aggression 0.2}
            {AI_SIMPLE_NIGHT_ASPECT aggression 0.4}
#ifdef EASY
            {AI_SIMPLE_NIGHT_ASPECT leader_aggression 0.5}
#endif
#ifdef MEDIUM
            {AI_SIMPLE_NIGHT_ASPECT leader_aggression -0.5}
#endif

            {AI_SIMPLE_DAY_ASPECT caution 0.3}
            {AI_SIMPLE_NIGHT_ASPECT caution 0.2}
            {MODIFY_AI_ADD_CANDIDATE_ACTION 4 main_loop {AI_CA_POISONING}}
        [/ai]
        {INCOME 4 8 12}
    [/side]

    [side]
        allow_player=no
        controller=ai
        side=5
        team_name=orcs
        user_team_name= _ "Enemies"
        {FLAG_VARIANT undead}
        type=Orcish Warrior
        id=Qumseh
        name= _ "Qumseh"
        profile=portraits/orcs/transparent/warlord.png
        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 150 230 300}
        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_NO_SCOUTS}
            {AI_SCALE_ATTACK_DEPTH_BY_DIFFICULTY}
            {AI_SIMPLE_ALWAYS_ASPECT recruitment_ignore_bad_movement yes}
            {AI_SIMPLE_ALWAYS_ASPECT recruitment_pattern "scout"}
            {AI_SIMPLE_ALWAYS_ASPECT aggression 0.75}
            {AI_SIMPLE_ALWAYS_ASPECT caution 0}
            {AI_SIMPLE_ALWAYS_ASPECT grouping no}
        [/ai]
        {INCOME 4 8 12}
    [/side]
    [side]
        allow_player=no
        controller=ai
        side=6
        team_name=orcs
        user_team_name= _ "Enemies"
        {FLAG_VARIANT undead}
        type=Orcish Warrior
        id=Graur-Tan
        name= _ "Graur-Tan"
        profile=portraits/orcs/transparent/warlord.png
        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 150 230 300}
        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_NO_SCOUTS}
            {AI_SCALE_ATTACK_DEPTH_BY_DIFFICULTY}
            {AI_SIMPLE_ALWAYS_ASPECT recruitment_ignore_bad_movement yes}
            {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]
        {INCOME 4 8 12}
    [/side]

#ifdef MULTIPLAYER
    #wmllint: validate-off
    [side]
        side=7
        fog=no    
        {LANDAR}
        save_id=Landar
        controller=human
        team_name=player
        user_team_name= _ "Player"
        recruit={ELVES}
        {PLAYER_GOLD}
        x=16
        y=15
        [unit]
            #TODO give him a name after the string frezze.
            id=Landulias
            generate_name=yes
            unrenamable=yes
            type=Elvish Archer
            gender=female
            [modifications]
                #TODO rethink them
                {TRAIT_DEXTROUS}
                {TRAIT_LOYAL}
                {TRAIT_INTELLIGENT}
            [/modifications]
            {IS_LOYAL}
            placement=leader
        [/unit]
    [/side]
    #wmllint: validate-on
#endif

    [event]
        name=prestart

        [objectives]
            side=0
            [objective]
                description= _ "Kalenz must reach the signpost"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Kalenz"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Landar"
                condition=lose
            [/objective]
            [objective]
                description= _ "Turns run out"
                condition=lose
            [/objective]
            note= _ "Early finish bonus: Defeat Wrulf" + {NEW_GOLD_CARRYOVER_NOTE_40}
        [/objectives]
    [/event]

    [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]
            id=Landar
            message= _ "We will follow you, Kalenz - but where can we go? We are surrounded!"
        [/message]
        [message]
            id=Kalenz
            message= _ "We must reach the elvish council in Ka'lian and enlist their help to recapture our home. Let's storm the orcs' southern outpost before more enemies arrive!"
        [/message]
        [message]
            id=Anduilas
            message= _ "Very well, Kalenz - lead us!"
        [/message]

        {HIGHLIGHT_IMAGE 1 30 scenery/signpost.png ()}
        [scroll_to_unit]
            id=Kalenz
        [/scroll_to_unit]
    [/event]

    [event]
        name=attack
        [filter_second]
            side=2
        [/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]
        [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]

#ifndef MULTIPLAYER
        {MODIFY_UNIT (side=2) side 1 }
        {MODIFY_UNIT (id=Velon) canrecruit no}
        {TRANSFER_VILLAGE_OWNERSHIP 2 1}
#endif
    [/event]

    [event]
        name=moveto
        [filter]
            x=1
            y=30
            [and]
                id=Kalenz
#ifdef MULTIPLAYER
                [or]
                    id=Landar
                [/or]
#endif
            [/and]

        [/filter]
        [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=Kalenz
            message= _ "Velon has fallen. He counseled weakness, but did not deserved 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]
            canrecruit=yes
            race=orc
            message= _ "You won't get very far! After them!"
        [/message]
        [if]
            [have_unit]
                id=Wrulf
            [/have_unit]
            [then]
                [endlevel]
                    result=victory
                    bonus=no
                    {NEW_GOLD_CARRYOVER 40}
                [/endlevel]
            [/then]
            [else]
                [endlevel]
                    result=victory
                    bonus=yes
                    {NEW_GOLD_CARRYOVER 40}
                [/endlevel]
            [/else]
        [/if]
    [/event]

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

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

    [event]
        name=die
        [filter]
            id=Wrulf
        [/filter]
        [filter_second]
            side=1
        [/filter_second]

        [message]
            speaker=second_unit
            message= _ "What is this? The orc held plunder!"
        [/message]
        {LOOT 50 1}
    [/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]

    [event]
        name=victory
        [kill]
            id=Velon
            animate=no
        [/kill]
    [/event]
    {campaigns/Legend_of_Wesmere/utils/deaths.cfg}

#ifndef MULTIPLAYER
[/scenario]
#else
[/multiplayer]
#endif

#undef PLAYER_GOLD



