#textdomain wesnoth-httt
[scenario]
    id=20a_North_Elves
    name= _ "Home of the North Elves"
    map_data="{campaigns/Heir_To_The_Throne/maps/20a_North_Elves.map}"
    {SCENARIO_MUSIC "the_dangerous_symphony.ogg"}
    {EXTRA_SCENARIO_MUSIC "nunc_dimittis.ogg"}
    {EXTRA_SCENARIO_MUSIC "vengeful.ogg"}
    {TURNS 21 18 15}

    {DEFAULT_SCHEDULE}

    next_scenario=21_Elven_Council

    [event]
        name=prestart
        [objectives]
            side=1
            [objective]
                description= _ "Konrad must reach the Lintanir Forest to the east and hold that position until the turn is over"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Konrad"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Delfador"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Li'sar"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Kalenz"
                condition=lose
            [/objective]
            [objective]
                description= _ "Turns run out before reaching the forest"
                condition=lose
            [/objective]

            note= _ "Note: your encampment will be dismantled after the first turn.
"+{EARLY_FINISH_BONUS_NOTE}+{NEW_GOLD_CARRYOVER_NOTE_40}
        [/objectives]
    [/event]

    {BIGMAP_HOME_OF_THE_NORTH_ELVES}

    [side]
        team_name=elves
        user_team_name=_"Allies"
        type=Commander
        id=Konrad
        name= _ "Konrad"
        unrenamable=yes
        side=1
        canrecruit=yes
        controller=human
        fog=yes
        gold=200
    [/side]

    [side]
        type=Orcish Warlord
        id=Kior-Dal
        name= _ "Kior-Dal"
        side=2
        canrecruit=yes
#ifdef EASY
        recruit=Wolf Rider,Orcish Grunt,Orcish Archer
#endif
#ifdef NORMAL
        recruit=Wolf Rider,Orcish Grunt,Orcish Archer,Orcish Warrior
#endif
#ifdef HARD
        recruit=Orcish Warrior,Goblin Knight,Wolf Rider,Orcish Grunt,Orcish Archer,Troll Whelp,Troll,Orcish Assassin
#endif
        [ai]
            {ATTACK_DEPTH 4 5 6}
            passive_leader=yes
            simple_targeting=yes
#ifndef HARD
            recruitment_pattern=scout,fighter,fighter,archer
#else
            recruitment_pattern=scout,fighter,fighter,mixed fighter,archer
#endif
            villages_per_scout=0
            village_value=0
            [target]
                id=Herbert
                value=100
            [/target]
            [target]
                id=Konrad
                value=0
            [/target]
            [target]
                id=Delfador
                value=0
            [/target]
            [target]
                id="Li'sar"
                value=0
            [/target]
        [/ai]
        [ai]
            time_of_day=dusk
            aggression=0.7
            caution=0.25
        [/ai]
        [ai]
            time_of_day=first_watch,second_watch
            aggression=1.0
            caution=0.0
        [/ai]
        {GOLD 370 400 460}
        {INCOME 8 12 16}
        team_name=orcs
        user_team_name=_"Orcs"
    [/side]

    [side]
        type=General
        id=Herbert
        name= _ "Herbert"
        side=3
        canrecruit=yes
#ifdef EASY
        recruit=Cavalryman,Spearman,Bowman
#endif
#ifdef NORMAL
        recruit=Cavalryman,Spearman,Bowman,Swordsman,Red Mage
#endif
#ifdef HARD
        recruit=Cavalryman,Swordsman,Pikeman,Ogre,Dragoon,Red Mage,White Mage,Shock Trooper
#endif
        [ai]
            {ATTACK_DEPTH 4 5 6}
            passive_leader=yes
            simple_targeting=yes
#ifdef EASY
            recruitment_pattern=scout,fighter,fighter,archer
#endif
#ifdef NORMAL
            recruitment_pattern=scout,fighter,fighter,mixed fighter,archer
#endif
#ifdef HARD
            recruitment_pattern=scout,fighter,fighter,mixed fighter,healer
#endif
            villages_per_scout=0
            village_value=0
            [target]
                id=Kior-Dal
                value=100
            [/target]
            [target]
                id=Konrad
                value=0
            [/target]
            [target]
                id=Delfador
                value=0
            [/target]
            [target]
                id="Li'sar"
                value=0
            [/target]
        [/ai]
        [ai]
            time_of_day=dawn
            aggression=0.7
            caution=0.25
        [/ai]
        [ai]
            time_of_day=morning,afternoon
            aggression=1.0
            caution=0.0
        [/ai]
        {GOLD 370 400 460}
        {INCOME 12 16 20}
        team_name=asheviere
        user_team_name=_"Asheviere"
    [/side]

    [side]
        team_name=elves
        user_team_name=_"Allies"
        type=Elvish Marshal
        id="El'rien"
        name= _ "El'rien"
        side=4
        canrecruit=yes
        recruit=Elvish Fighter,Elvish Archer,Elvish Ranger,Elvish Scout,Elvish Hero,Elvish Marksman

        {GOLD 600 475 350}
        income=20
        [ai]
            passive_leader=yes
            villages_per_scout=0
            village_value=0
            caution=0.9
            aggression=0.6
            grouping=defensive
            #
            # The Elves focus on getting to Konrad so they can
            # protect him
            #
            # The previous value was 15
            #
            [target]
                id=Konrad
                value=4
            [/target]
        [/ai]
    [/side]

    {STARTING_VILLAGES 4 24}

    [event]
        name=prestart

        # {SCATTER_IMAGE (terrain=Gg) 12 scenery/pine2.png}

        #
        # Variable cleanup from last scenario
        #
        {CLEAR_VARIABLE armored_knight}

        #
        # Add a bunch of strong guardians to discourage you from
        # attacking the leaders These are full-fledged war camps,
        # after all
        #

        #
        # Camp guards
        #
        {UNIT 2 (Troll Warrior) 28 4 (ai_special=guardian)}
        {UNIT 2 (Troll Warrior) 34 4 (ai_special=guardian)}
        {UNIT 2 (Orcish Warrior) 30 4 (ai_special=guardian)}
        {UNIT 2 (Orcish Warrior) 32 4 (ai_special=guardian)}
        {UNIT 2 (Orcish Warrior) 29 6 (ai_special=guardian)}
        {UNIT 2 (Orcish Warrior) 31 6 (ai_special=guardian)}
        {UNIT 2 (Orcish Warrior) 33 6 (ai_special=guardian)}
        {UNIT 2 (Orcish Slurbow) 30 6 (ai_special=guardian)}
        {UNIT 2 (Orcish Slurbow) 32 6 (ai_special=guardian)}
        #
        # Army members
        #
        {UNIT 2 (Orcish Grunt) 31 3 (ai_special=guardian)}
        {UNIT 2 (Orcish Grunt) 32 2 (ai_special=guardian)}
        {UNIT 2 (Troll Whelp) 33 2 (ai_special=guardian)}
        {UNIT 2 (Orcish Grunt) 33 1 (ai_special=guardian)}
        {UNIT 2 (Orcish Grunt) 27 4 (ai_special=guardian)}
        {UNIT 2 (Troll Whelp) 26 3 (ai_special=guardian)}
        {UNIT 2 (Orcish Grunt) 25 3 (ai_special=guardian)}
        {UNIT 2 (Orcish Grunt) 24 1 (ai_special=guardian)}
        {UNIT 2 (Orcish Grunt) 25 1 (ai_special=guardian)}
        {UNIT 2 (Orcish Grunt) 26 1 (ai_special=guardian)}
        {UNIT 2 (Orcish Warrior) 24 3 (ai_special=guardian)}
        {UNIT 2 (Orcish Grunt) 23 4 (ai_special=guardian)}
        {UNIT 2 (Troll Whelp) 22 3 (ai_special=guardian)}
        {UNIT 2 (Orcish Grunt) 22 2 (ai_special=guardian)}
        {UNIT 2 (Orcish Warrior) 21 3 (ai_special=guardian)}
        {UNIT 2 (Orcish Grunt) 21 2 (ai_special=guardian)}
        {UNIT 2 (Orcish Grunt) 20 2 (ai_special=guardian)}
        {UNIT 2 (Orcish Grunt) 20 1 (ai_special=guardian)}
        {UNIT 2 (Orcish Warrior) 21 1 (ai_special=guardian)}
        #
        # Camp guards
        #
        {UNIT 3 (Lieutenant) 68 34 (ai_special=guardian)}
        {UNIT 3 (Lieutenant) 67 35 (ai_special=guardian)}
        {UNIT 3 (Lieutenant) 69 35 (ai_special=guardian)}
        {UNIT 3 (Great Mage) 67 36 (ai_special=guardian)}
        {UNIT 3 (Great Mage) 69 36 (ai_special=guardian)}
        {UNIT 3 (Iron Mauler) 68 33 (ai_special=guardian)}
        {UNIT 3 (Iron Mauler) 66 34 (ai_special=guardian)}
        {UNIT 3 (Iron Mauler) 70 34 (ai_special=guardian)}
        {UNIT 3 (Iron Mauler) 66 36 (ai_special=guardian)}
        {UNIT 3 (Iron Mauler) 70 36 (ai_special=guardian)}
        #
        # Army members
        #
        {UNIT 3 (Swordsman) 72 35 (ai_special=guardian)}
        {UNIT 3 (Swordsman) 72 36 (ai_special=guardian)}
        {UNIT 3 (Swordsman) 72 37 (ai_special=guardian)}
        {UNIT 3 (Swordsman) 72 38 (ai_special=guardian)}
        {UNIT 3 (Swordsman) 73 35 (ai_special=guardian)}
        {UNIT 3 (Swordsman) 73 36 (ai_special=guardian)}
        {UNIT 3 (Swordsman) 73 37 (ai_special=guardian)}
        {UNIT 3 (Swordsman) 73 38 (ai_special=guardian)}
        {UNIT 3 (Swordsman) 74 35 (ai_special=guardian)}
        {UNIT 3 (Swordsman) 74 36 (ai_special=guardian)}
        {UNIT 3 (Swordsman) 74 37 (ai_special=guardian)}
        {UNIT 3 (Swordsman) 74 38 (ai_special=guardian)}
        {UNIT 3 (Royal Guard) 73 34 (ai_special=guardian)}
        {UNIT 3 (Sergeant) 74 34 (ai_special=guardian)}
        {UNIT 3 (Swordsman) 62 35 (ai_special=guardian)}
        {UNIT 3 (Swordsman) 62 36 (ai_special=guardian)}
        {UNIT 3 (Swordsman) 62 37 (ai_special=guardian)}
        {UNIT 3 (Swordsman) 62 38 (ai_special=guardian)}
        {UNIT 3 (Swordsman) 63 35 (ai_special=guardian)}
        {UNIT 3 (Swordsman) 63 36 (ai_special=guardian)}
        {UNIT 3 (Swordsman) 63 37 (ai_special=guardian)}
        {UNIT 3 (Swordsman) 63 38 (ai_special=guardian)}
        {UNIT 3 (Swordsman) 64 35 (ai_special=guardian)}
        {UNIT 3 (Swordsman) 64 36 (ai_special=guardian)}
        {UNIT 3 (Swordsman) 64 37 (ai_special=guardian)}
        {UNIT 3 (Swordsman) 64 38 (ai_special=guardian)}
        {UNIT 3 (Royal Guard) 63 34 (ai_special=guardian)}
        {UNIT 3 (Sergeant) 64 34 (ai_special=guardian)}
    [/event]

    [event]
        name=start
        #
        # Allow the player to have some >6MP loyal units to compensate for the loss of recruiting
        #
        [recall]
            id=Delfador
        [/recall]
        [recall]
            id=Kalenz
        [/recall]
        [recall]
            id="Li'sar"
        [/recall]
        [recall]
            id=Haldiel
        [/recall]
        [recall]
            id=Delurin
        [/recall]
        [recall]
            id=Reglok
        [/recall]
        [recall]
            id=Niodien
        [/recall]
        [redraw]
        [/redraw]

        [message]
            speaker=Kalenz
            message= _ "At last, friends, we have almost reached the Lintanir Forest, the home of the North Elves. I was born not far east of here...more years ago than I care to remember."
        [/message]
        [message]
            speaker="Li'sar"
            message= _ "After being in this wilderness for so long, it will be good to get some rest!"
        [/message]
        [message]
            speaker=Konrad
            message= _ "But there is a great fog around us again! We don't know what dangers may lie ahead!"
        [/message]
        [message]
            speaker=Kalenz
            message= _ "So long as we move ahead with caution and prudence, I am sure we will reach the safety and hospitality of the elves."
        [/message]

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

        [move_unit_fake]
            type=Elvish Rider
            side=1
            x=20,7
            y=17,18
        [/move_unit_fake]

        [unit]
            id=Telerandor
            name= _ "Telerandor"
            type=Elvish Rider
            side=1
            x=7
            y=18
            facing=sw
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_DEXTROUS}
            [/modifications]
        [/unit]

        [redraw]
        [/redraw]

        [message]
            speaker=Telerandor
            message= _ "My lords! I have found you at last."
        [/message]

        [message]
            speaker=Kalenz
            message= _ "Greetings, Telerandor, herald of Lintanir! Why have you been searching for us?"
        [/message]

        [message]
            speaker=Telerandor
            message= _ "When my lord learned of your coming, he sent riders out looking for you! There is trouble afoot!"
        [/message]

        [message]
            speaker=Konrad
            message= _ "Trouble? What kind of trouble?"
        [/message]

        [message]
            speaker=Telerandor
            message= _ "We have sighted a great host to the south, a host of the men of Wesnoth. And we believe they are looking for you! There is not a moment to lose. You must make haste, east to Lintanir. Only there will you be safe!"
        [/message]

        [message]
            speaker=Konrad
            message= _ "I only hope we can avoid them. We will have to bear north-east."
        [/message]
        [message]
            speaker=Telerandor
            message= _ "That is not all, my lord. The foul orcs have heard of the coming of these men, and are even now gathering a great host to oppose them to the north! It is now certain that there will be a great battle."
        [/message]
        [message]
            speaker="Li'sar"
            message= _ "This sounds very dangerous. Perhaps we should retreat to the West, and hide until the battle is over?"
        [/message]
        [message]
            speaker=Konrad
            message= _ "I think these wild lands are too dangerous for that! Anyhow... I expected you to be on the side of Wesnoth, Princess?"
        [/message]
        [message]
            speaker="Li'sar"
            message= _ "I am an honorable princess, not an impostor like you! I promised that I would be on your side until we made it out of these lands, and I will keep my promise!"
        [/message]
        [message]
            speaker=Telerandor
            message= _ "Sir, madam, there is no time to lose! You must make it east, to the home of my people. Only there will you be safe!"
        [/message]
        [message]
            speaker=Konrad
            message= _ "Rider, do not fool with us. You yourself say men and orcs wage war on this plain that lies ahead. Do you propose we fly to the great woods of the east?"
        [/message]
        [message]
            speaker=Telerandor
            message= _ "My lord, you must rush across the field before the main host of each army makes it to the battle. It is the only way to avoid this great calamity."
        [/message]
        [message]
            speaker=Kalenz
            message= _ "I was afraid that's what you were going to say."
        [/message]
        [message]
            speaker="Li'sar"
            message= _ "Come then, Konrad, let us go. We will do what must be done."
        [/message]
        [message]
            speaker=Telerandor
            message= _ "My lord has begun assembling a party of elves to come and escort you into the forest. Beware, for we are all in great danger!"
        [/message]
        [message]
            speaker=Delfador
            message= _ "Konrad, the encampment must be torn down. Any delay and these armies will crush us. Any evidence of our passage through here, and they will chase us."
        [/message]
    [/event]

    #
    # Turn 2: dismantle your castle
    #
    [event]
        name=turn 2
        [terrain]
            x=3-5,4
            y=18-19,17
            terrain=Re
        [/terrain]
    [/event]

    #
    # Turn 3: some dialog to help you along
    #
    [event]
        name=turn 3
        [message]
            speaker="Li'sar"
            message= _ "So, Konrad, do you think we can simply trot across the battlefield?"
        [/message]
        [message]
            speaker=Konrad
            message= _ "Stop for a moment, princess. Look - you can barely see them in the distance there, but the advance scouts have found each other. The Queen's troops are marching full speed for the orcs' camp, and vice-versa. These armies are out for blood."
        [/message]
        [message]
            speaker="Li'sar"
            message= _ "But they will not neglect to notice our presence in their midst! We are walking into slaughter!"
        [/message]
        [message]
            speaker=Konrad
            message= _ "(hushed) Our soldiers will defend us as we rush across the field. Sorry to be blunt, princess, but you and I are the only ones who need to make it across alive."
        [/message]
        [message]
            speaker=Delfador
            message= _ "..."
        [/message]
        [message]
            speaker=Konrad
            message= _ "...and Delfador, of course. And Kalenz... and.."
        [/message]
        [message]
            speaker="Li'sar"
            # wmllint: local spelling Ach
            message= _ "Ach! I understand, Konrad. I am no stranger to the burden of command. Onward!"
        [/message]
    [/event]

    #
    # Turn 5: some of the riders who didn't find you catch up!
    #
    [event]
        name=turn 5

        [store_unit]
            variable=konrad_store
            [filter]
                id=Konrad
            [/filter]
        [/store_unit]
        {VARIABLE temp_x $konrad_store.x}
        {VARIABLE temp_y $konrad_store.y}
#ifdef EASY
        [move_unit_fake]
            type=Elvish Rider
            x=1,$temp_x
            y=1,$temp_y
            side=4
        [/move_unit_fake]
        {NAMED_LOYAL_UNIT 4 (Elvish Rider) $temp_x $temp_y (Glarilon) ( _ "Glarilon")}
        # wmllint: recognize Glarilon
        [message]
            speaker=Glarilon
            message= _ "My lords! I have found you at last."
        [/message]
#endif
        [move_unit_fake]
            type=Elvish Rider
            x=1,$temp_x
            y=38,$temp_y
            side=4
        [/move_unit_fake]
        {NAMED_LOYAL_UNIT 4 (Elvish Rider) $temp_x $temp_y (Thalindil) ( _ "Thalindil")}
        # wmllint: recognize Thalindil
        [message]
            speaker=Thalindil
            message= _ "(exhausted) We have... (pant) finally found you!"
        [/message]
        {CLEAR_VARIABLE konrad_store}
        {CLEAR_VARIABLE temp_x}
        {CLEAR_VARIABLE temp_y}
    [/event]

    #
    # Turn 7: another rider finds you!
    #
    [event]
        name=turn 7

        [store_unit]
            variable=konrad_store
            [filter]
                id=Konrad
            [/filter]
        [/store_unit]
        {VARIABLE temp_x $konrad_store.x}
        {VARIABLE temp_y $konrad_store.y}
        [move_unit_fake]
            type=Elvish Rider
            x=77,$temp_x
            y=18,$temp_y
            side=4
        [/move_unit_fake]
        {NAMED_LOYAL_UNIT 4 (Elvish Rider) $temp_x $temp_y (Rholandir) ( _ "Rholandir")}
        # wmllint: recognize Rholandir
        [message]
            speaker=Rholandir
            message= _ "Lord Kalenz, Lord Konrad, our forces are nigh! Do not lose hope!"
        [/message]
        {CLEAR_VARIABLE konrad_store}
        {CLEAR_VARIABLE temp_x}
        {CLEAR_VARIABLE temp_y}
    [/event]

    #
    # Give the armies a gold infusion near the end to keep the pressure on
    #
    [event]
        name=turn 10
        [gold]
            side=2
            amount=1000
        [/gold]
        [gold]
            side=3
            amount=1000
        [/gold]
    [/event]

    [event]
        name=sighted
        [filter]
            side=2
        [/filter]
        [music]
            name="northerners.ogg"
            immediate=no
            append=yes
        [/music]
        [message]
            speaker=Delfador
            message= _ "There are some orcs! We must let them fight the men of Wesnoth, and avoid engaging them at all costs!"
        [/message]
    [/event]

    [event]
        name=sighted
        [filter]
            side=3
        [/filter]
        [message]
            speaker=unit
            message= _ "There they are! Charge!"
        [/message]
        [music]
            name="loyalists.ogg"
            immediate=no
            append=yes
        [/music]
    [/event]

    [event]
        name=sighted
        [filter]
            side=4
            [not]
                id=Glarilon
            [/not]
            [not]
                id=Thalindil
            [/not]
            [not]
                id=Rholandir
            [/not]
        [/filter]
        [message]
            speaker=unit
            message= _ "There you are! You must come quickly east to Lintanir!!"
        [/message]
    [/event]

    # event when moving to Elvish castle
    [event]
        name=moveto
        [filter]
            id=Konrad
            x=75-79
            y=17-19
        [/filter]
        [message]
            speaker="El'rien"
            # wmllint: local spelling Emetria
            message= _ "Greetings, Elf-friend! Welcome to Emetria, my hold in Lintanir. You must take shelter here until the battle passes. If you stay with me here for a little while, we will all be safe."
        [/message]
        [message]
            speaker=Konrad
            message= _ "Thank you, Lord El'rien. The hospitality of the North Elves is as generous as that of your kin in the south! My men will help you hold out against our enemies."
        [/message]
    [/event]

    # Once you make it far enough, TELL THE PLAYER!
    [event]
        name=moveto
        [filter]
            id=Konrad
            x=66-80,67-80,68-80,69-80,70-80,71-80,73-80,74-80
            y= 1- 8, 9-14,   15,16-17,18-20,   21,22-25,26-28
        [/filter]
        [message]
            speaker=Delfador
            message= _ "Konrad, you have made it to the domain of the North Elves. Continue moving east and let the elves guard your rear."
        [/message]
    [/event]

    #
    # Check if Konrad is inside forest, loosely defined -- but include
    # Eastern woods, and a bit of grassland nearby
    #
    # This event makes you win if Konrad is inside the forest at the
    # start of the next turn - that way the enemy still has one last
    # shot to kill you
    #
    [event]
        name=new turn
        first_time_only=no
        [if]
            [have_unit]
                id=Konrad
                x=66-80,67-80,68-80,69-80,70-80,71-80,73-80,74-80
                y= 1- 8, 9-14,   15,16-17,18-20,   21,22-25,26-28
            [/have_unit]
            [then]
                [endlevel]
                    result=victory
                    bonus=yes
                    {NEW_GOLD_CARRYOVER 40}
                [/endlevel]
            [/then]
        [/if]
    [/event]

    #
    # Check if Konrad is inside forest, loosely defined -- but include
    # Eastern woods and a bit of grassland nearby
    #
    # This event makes you win if Konrad is inside the forest at the
    # end of the scenario - just in case the new turn even never fires
    # (you make it there on the last turn)
    #
    [event]
        name=time over
        [if]
            [have_unit]
                id=Konrad
                x=66-80,67-80,68-80,69-80,70-80,71-80,73-80,74-80
                y= 1- 8, 9-14,   15,16-17,18-20,   21,22-25,26-28
            [/have_unit]
            [then]
                [endlevel]
                    result=victory
                    bonus=yes
                    {NEW_GOLD_CARRYOVER 40}
                [/endlevel]
            [/then]
            [else]
                [message]
                    speaker=Delfador
                    message= _ "We have not yet reached the forest, and the battle still rages. We are caught between two vast armies and cannot escape to safety! We are defeated!"
                [/message]
            [/else]
        [/if]
    [/event]

    [event]
        name=victory
        [message]
            speaker="El'rien"
            message= _ "Elf-friends, you have made it to safety!"
        [/message]
        [message]
            speaker=Kalenz
            message= _ "El'rien, we have the Scepter of Fire with us! We must escort them to Elensiria!"
        [/message]
        [message]
            speaker="El'rien"
            message= _ "Indeed. We will escort you to our capital, where we will make Council."
        [/message]
    [/event]

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