#textdomain wesnoth-httt
[scenario]
    id=06_The_Siege_of_Elensefar
    name= _ "The Siege of Elensefar"
    map_data="{campaigns/Heir_To_The_Throne/maps/06_The_Siege_of_Elensefar.map}"
    {SCENARIO_MUSIC "the_city_falls.ogg"}
    {EXTRA_SCENARIO_MUSIC "breaking_the_chains.ogg"}
    {EXTRA_SCENARIO_MUSIC "battle.ogg"}
    {TURNS 40 32 29}

    {DEFAULT_SCHEDULE}

    next_scenario=07_Crossroads

    [event]
        name=prestart
        [objectives]
            side=1
            [objective]
                description= _ "Defeat all enemy leaders"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Konrad"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

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

    [label]
        x,y=16,28
        text= _ "Elensefar"
    [/label]

    {BIGMAP_SIEGE_OF_ELENSEFAR}

    [side]
        type=Commander
        id=Konrad
        name= _ "Konrad"
        unrenamable=yes
        profile=portraits/konrad.png
        side=1
        canrecruit=yes
        controller=human
        team_name=elves
        user_team_name=_"Rebels"
        {GOLD 180 120 120}
        {FLAG_VARIANT long}
    [/side]

    # wmllint: recognize Delfador

    [side]
        type=Orcish Warlord
        id=Agadla
        name= _ "Agadla"
        side=2
        canrecruit=yes
        recruit=Orcish Warrior,Orcish Grunt,Orcish Assassin,Orcish Crossbowman,Orcish Archer
        {GOLD 100 180 240}
        team_name=orcs
        user_team_name=_"Evil"

        [ai]
            recruitment_pattern=fighter,fighter,mixed fighter,archer
            leader_value=10.0
            aggression=0.0
            caution=1.0
            grouping=defensive
            {ATTACK_DEPTH 1 3 5}
        [/ai]

        [ai]
            time_of_day=dusk
            aggression=0.6
            grouping=defensive
        [/ai]
        [ai]
            time_of_day=first_watch,second_watch
            aggression=0.7
            caution=0.25
            grouping=offensive
        [/ai]
        {FLAG_VARIANT ragged}
    [/side]

#ifndef HARD
    {LIMIT_CONTEMPORANEOUS_RECRUITS 2 "Orcish Warrior" 2}
    {LIMIT_CONTEMPORANEOUS_RECRUITS 2 "Orcish Crossbowman" 2}
#endif

    [side]
        type=Dark Sorcerer
        id=Muff Jaanal
        name= _ "Muff Jaanal"
        side=3
        canrecruit=yes

        recruit=Skeleton Archer,Skeleton

        {GOLD 100 160 220}

        team_name=orcs
        user_team_name=_"Evil"

        [ai]
            recruitment_pattern=fighter,fighter,archer
            leader_value=10.0
            {ATTACK_DEPTH 1 3 5}
        [/ai]

        [ai]
            time_of_day=dusk,first_watch,second_watch
            aggression=1.0
            grouping=no
        [/ai]
        {FLAG_VARIANT undead}
    [/side]

    # Start the orcs/undead with most of the villages on the map
#ifdef EASY
    {STARTING_VILLAGES 2 5}
    {STARTING_VILLAGES 3 0}
#endif
#ifdef NORMAL
    {STARTING_VILLAGES 2 10}
    {STARTING_VILLAGES 3 10}
#endif
#ifdef HARD
    {STARTING_VILLAGES 2 10}
    {STARTING_VILLAGES 3 20}
#endif

    [time_area]
        x=13-22,23 ,24 ,25-26
        y=0-5  ,0-3,0-1,0-2
        {UNDERGROUND}
    [/time_area]

    [event]
        name=prestart

        # {SCATTER_IMAGE (terrain=Gg)  8 scenery/pine1.png}
        # {SCATTER_IMAGE (terrain=Gs^Fp)  5 scenery/pine2.png}
        # {SCATTER_IMAGE (terrain=Gg)  5 scenery/oak-leaning.png}
        {PLACE_IMAGE scenery/rock1.png 13 12}
        {PLACE_IMAGE scenery/rock2.png 25 28}

        [role]
            type=Elvish Champion,Elvish Marshal,Elvish Captain,Elvish Hero,Knight,Elvish Outrider,Elvish Rider,Paladin,Mage,White Mage,Red Mage
            role=Advisor
        [/role]
        [recall]
            role=Advisor
        [/recall]
    [/event]

    [event]
        name=start
        [message]
            speaker=narrator
            image="wesnoth-icon.png"
            message= _ "The party arrived at Elensefar at last, but found that the city had already fallen to the savage orcs."
        [/message]
        [message]
            role=Advisor
            message= _ "My lord! It seems the city has already fallen!"
        [/message]
        [message]
            speaker=Konrad
            message= _ "This is terrible news! We must retake the city!"
        [/message]
        [message]
            role=Advisor
            message= _ "There are so many of them. This will not be easy! And look to the north! It seems that the undead are allied with the orcs!"
        [/message]
        [message]
            speaker=Muff Jaanal
            message= _ "Here come the elves! Our newly forged alliance with the orcs will give us the power to crush them with ease!"
        [/message]
        [message]
            role=Konrad
            message= _ "We must take the city, and destroy the evil undead before reinforcements arrive!"
        [/message]
    [/event]

    [event]
        name=turn 4

        [move_unit_fake]
            type=Rogue
            side=1
            x=24,24,23
            y=38,39,40
        [/move_unit_fake]

        [unit]
            id=Reglok
            name= _ "Reglok"
            type=Rogue
            side=1
            x=23
            y=40
            gender=male
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_INTELLIGENT}
            [/modifications]
            {IS_LOYAL}
        [/unit]

        [unit]
            id=Gelgar
            name= _ "Gelgar"
            type=Thief
            side=1
            x=22
            y=39
            gender=male
            [modifications]
                {TRAIT_LOYAL}
            [/modifications]
            {IS_LOYAL}
        [/unit]
        [unit]
            id=Gamlel
            name= _ "Gamlel"
            type=Thief
            side=1
            x=24
            y=40
            gender=female
            [modifications]
                {TRAIT_LOYAL}
            [/modifications]
            {IS_LOYAL}
        [/unit]

        [redraw]
        [/redraw]
        [delay]
            time=1250
        [/delay]

        [message]
            speaker=narrator
            image="wesnoth-icon.png"
            message= _ "As night began to fall, three dark figures crept out of the forest."
        [/message]
        [message]
            speaker=Konrad
            message= _ "Halt! Who goes there, friend or foe?"
        [/message]
        [message]
            speaker=Reglok
            message= _ "Greetings, friend. We are from the Elensefar Thieves’ Guild. We would like to help you against the orcs!"
        [/message]
        [message]
            role=Advisor
            message= _ "Thieves, hmmm? Who says we can trust such as you?"
        [/message]
        [message]
            speaker=Gamlel
            message= _ "We would understand if you didn’t trust us, of course, but it is in our mutual interest to rid the city of the orcs!"
        [/message]
        [message]
            speaker=Konrad
            message= _ "Very well. You may join us."
        [/message]
        [message]
            speaker=Reglok
            message= _ "We will serve you well, for we respect the help you are providing to our city. You shall find that there is honor, even among thieves."
        [/message]
        [message]
            speaker=Konrad
            message= _ "Yes, but where is your fighting force? How can you help us?"
        [/message]
        [message]
            speaker=Gelgar
            message= _ "We survive by stealth. We can help you sneak into the city and surround the orcs. Alternatively, we can lay in wait until you give us a signal then ambush the orcs’ rear."
        [/message]
        [message]
            speaker=Konrad
            message= _ "Hmm... I have to consider this..."
            [option]
                message= _ "Help us infiltrate the city. We can do the rest."
                [command]
                    [message]
                        speaker=Reglok
                        message= _ "Excellent. Two hours past midnight meet us on the west bank of the river, across from Elensefar’s docks."
                    [/message]
                    [set_variable]
                        name=thieves_ford
                        value=yes
                    [/set_variable]
                    [allow_recruit]
                        side=1
                        type=Thief
                    [/allow_recruit]
                [/command]
            [/option]
            [option]
                message= _ "I want you to reinforce us once we break through their line."
                [command]
                    [message]
                        speaker=Reglok
                        message= _ "Very well. When you raise your red banner over any building in the city proper, we will see the sign and attack from the city’s northern gate."
                    [/message]
                    [message]
                        speaker=Konrad
                        message= _ "Agreed. But, will you be able to see our flag if it’s dark?"
                    [/message]
                    [message]
                        speaker=Reglok
                        message= _ "Yes, we will see it. In fact, we prefer to fight at night. I pray you do not lead us into slaughter."
                    [/message]
                    [message]
                        speaker=Konrad
                        message= _ "Do not fear, friends. There will be a slaughter here, but it will be orcish blood staining the streets."
                    [/message]
                    #
                    # Special event - if you chose to have the thieves
                    # ambush the orcs, they appear when you capture
                    # one of the Elensefar villages
                    #
                    [event]
                        name=moveto
                        [filter]
                            x=14,15,18,19,13,14,18,20,21
                            y=28,30,30,27,24,22,23,23,25
                            side=1
                        [/filter]
                        [message]
                            speaker=narrator
                            image="wesnoth-icon.png"
                            message= _ "As the banner was raised, sounds of fighting could be heard from across the city."
                        [/message]

                        #create units

                        [unit]
                            id=Reglok
                            name= _ "Reglok"
                            type=Rogue
                            side=1
                            x=16
                            y=22
                            gender=male
                            [modifications]
                                {TRAIT_LOYAL}
                                {TRAIT_INTELLIGENT}
                            [/modifications]
                            {IS_LOYAL}
                        [/unit]

                        [unit]
                            id=Gelgar
                            name= _ "Gelgar"
                            type=Thief
                            side=1
                            x=14
                            y=22
                            gender=male
                            [modifications]
                                {TRAIT_LOYAL}
                            [/modifications]
                            {IS_LOYAL}
                        [/unit]
                        [unit]
                            id=Gamlel
                            name= _ "Gamlel"
                            type=Thief
                            side=1
                            x=20
                            y=23
                            gender=female
                            [modifications]
                                {TRAIT_LOYAL}
                            [/modifications]
                            {IS_LOYAL}
                        [/unit]
                        [unit]
                            id=Darglen
                            name= _ "Darglen"
                            type=Thief
                            side=1
                            x=18
                            y=23
                            [modifications]
                                {TRAIT_LOYAL}
                            [/modifications]
                            {IS_LOYAL}
                        [/unit]
                        #dialog
                        [message]
                            speaker=Reglok
                            message= _ "Let’s expel these invaders! Today, the city is ours again!"
                        [/message]
                    [/event]
                    [allow_recruit]
                        side=1
                        type=Thief
                    [/allow_recruit]
                [/command]
            [/option]
        [/message]
        [kill]
            type=Thief
        [/kill]
        [kill]
            type=Rogue
        [/kill]
    [/event]

    #
    # Special event - if you chose to have the thieves help you across the river,
    # on turn 6 the ford appears
    #
    [event]
        name=turn 6

        [if]
            [variable]
                name=thieves_ford
                equals=yes
            [/variable]
            [then]
                [message]
                    speaker=narrator
                    image="wesnoth-icon.png"
                    message= _ "On the banks of Elensefar’s port district, three shadowy figures appeared."
                [/message]
                [message]
                    speaker=narrator
                    image="wesnoth-icon.png"
                    message= _ "To Konrad’s surprise, they quickly made their way across the river’s mouth. The turbulent waters hid a nearly invisible ford, wide enough for two soldiers to march shoulder-to-shoulder."
                [/message]
                #create units

                [unit]
                    id=Reglok
                    name= _ "Reglok"
                    type=Rogue
                    side=1
                    x=7
                    y=30
                    gender=male
                    [modifications]
                        {TRAIT_LOYAL}
                        {TRAIT_INTELLIGENT}
                    [/modifications]
                    {IS_LOYAL}
                [/unit]

                [unit]
                    id=Gelgar
                    name= _ "Gelgar"
                    type=Thief
                    side=1
                    x=6
                    y=30
                    gender=male
                    [modifications]
                        {TRAIT_LOYAL}
                    [/modifications]
                    {IS_LOYAL}
                [/unit]

                [unit]
                    id=Gamlel
                    name= _ "Gamlel"
                    type=Thief
                    side=1
                    x=6
                    y=31
                    gender=female
                    [modifications]
                        {TRAIT_LOYAL}
                    [/modifications]
                    {IS_LOYAL}
                [/unit]
                #create terrain
                [terrain]
                    terrain=Wwf # wmllint: ignore
                    x=7-8
                    y=30-32
                [/terrain]
                #dialog
                [message]
                    speaker=Reglok
                    message= _ "Very few people know that the river can be forded here. The orcs have yet to discover this place. Bring your forces into the city, quickly now, and you can flank them."
                [/message]
            [/then]
        [/if]
    [/event]

    [event]
        name=enemies defeated
        [message]
            speaker=Konrad
            message= _ "Finally, we have retaken the city! Let us rest here, friends."
        [/message]
        [role]
            role=Thief
            type=Assassin,Rogue,Thief
        [/role]
        [message]
            role=Thief
            message= _ "Victory! The thieves of Elensefar will be in your service, my lord."
        [/message]
        [message]
            speaker=narrator
            image="wesnoth-icon.png"
            message= _ "The party rested for three days, after which an old friend returned."
        [/message]

        [move_unit_fake]
            type=Elder Mage
            side=1
            x=25,24,24
            y=18,17,16
        [/move_unit_fake]

        {VARIABLE delfador_store.x 24}
        {VARIABLE delfador_store.y 16}

        #show Delfador
        [unstore_unit]
            variable=delfador_store
        [/unstore_unit]
        {CLEAR_VARIABLE delfador_store}
        [unit]
            id=Kalenz
            name= _ "Kalenz"
            profile=portraits/kalenz.png
            unrenamable=yes
            type=Elvish Lord
            x=22
            y=16
            side=1
            {IS_HERO}
            random_traits=no
            [modifications]
                {TRAIT_LOYAL}
            [/modifications]
        [/unit]

        [redraw]
        [/redraw]

        [message]
            speaker=Delfador
            message= _ "Greetings, friends. I see that you have rescued the city! I knew that you could do it."
        [/message]

        [message]
            speaker=Konrad
            message= _ "Delfador! So good to see you! Where have you been?"
        [/message]

        [message]
            speaker=Delfador
            message= _ "I have been meeting with the Ka’lian, the Great Council of the Elves. This is Kalenz, a great lord of the Northern Elves who came to the Council to offer us the support of his people."
            # See Legend of Wesmere; Kalenz is the former High Lord of
            # the elves. At this time in 517 YW, he is probably a leader or
            # legate of the elves of the Forest of Lintanir.  None of
            # this backstory existed when HttT was first written.
        [/message]

        [message]
            speaker=Kalenz
            message= _ "Greetings, friend."
        [/message]

        [message]
            speaker=Konrad
            message= _ "Delfador, we have captured this city, but surely Asheviere’s men will come and attack us! What should we do?"
        [/message]

        [message]
            speaker=Delfador
            message= _ "The Ka’lian has met and decided: we must capture the Sceptre of Fire."
        [/message]

        [message]
            speaker=Konrad
            message= _ "The Sceptre of Fire? What’s that?"
        [/message]

        [message]
            speaker=Delfador
            message= _ "The Sceptre of Fire is the most ancient artifact of the realm of Wesnoth. It was forged by the dwarves of Knalga at the request of King Haldric II. It took their finest smiths years to make it, but soon after it was completed, the makers were chased underground, attacked by the elves. None know exactly what occurred, but the Sceptre was lost somewhere in the great caverns. Years have passed, and the fortunes of the dwarves have waxed and waned, but the Sceptre has never been found."
        [/message]

        [message]
            speaker=Konrad
            message= _ "But what has this to do with me?"
        [/message]

        [message]
            speaker=Delfador
            message= _ "When Garard II, your uncle, was deciding upon a successor, he issued an edict that whichever member of the royal family could retrieve the Sceptre of Fire would rule the land."
        [/message]

        [message]
            speaker=Konrad
            message= _ "Oh, and you want me to get this scepter?"
        [/message]

        [message]
            speaker=Kalenz
            message= _ "We will help you retrieve it, my lord."
        [/message]

        [message]
            speaker=Delfador
            message= _ "Time is short. We think that Asheviere is also searching for the Sceptre, to help seal her place as ruler. But if you find the Sceptre first, the people will support you as the king."
        [/message]

        [message]
            speaker=Konrad
            message= _ "Me? King?"
        [/message]

        [message]
            speaker=Delfador
            message= _ "Yes, Konrad. I believe you will be king one day. Now let us make haste!"
        [/message]

        [message]
            speaker=Delfador
            message= _ "We cannot go to Wesmere, for Asheviere’s orcs have the approaches ringed about with steel; Kalenz and I barely escaped, and Chantal cannot get out. Until we are stronger, we must go where the orcs are not."
        [/message]

        [endlevel]
            result=victory
            bonus=yes
            {NEW_GOLD_CARRYOVER 40}
        [/endlevel]
    [/event]

    # Konrad's troops reach Muff Jaanal's citadel.

    [event]
        name=moveto
        [filter]
            side=1
            x=16-17
            y=5-6
        [/filter]

        [message]
            speaker=Muff Jaanal
            message= _ "So you endeavor to fight me in my home. Foolish."
        [/message]

#ifdef EASY
        [gold]
            side=3
            amount=30
        [/gold]
#else
        [gold]
            side=3
            amount=60
        [/gold]
#endif

        [terrain]
            x=13
            y=2
            terrain=Uu
        [/terrain]
        [sound]
            name=skeleton-big-die.ogg
        [/sound]
#ifdef EASY
        {LOYAL_UNDEAD_UNIT 3 (Skeleton) 13 2}
#else
        {LOYAL_UNDEAD_UNIT 3 (Revenant) 13 2}
#endif
        [scroll_to_unit]
            x=13
            y=2
        [/scroll_to_unit]

        [terrain]
            x=22
            y=2
            terrain=Uu
        [/terrain]
        [sound]
            name=skeleton-big-die.ogg
        [/sound]
#ifdef HARD
        {LOYAL_UNDEAD_UNIT 3 (Deathblade) 22 2}
#else
        {LOYAL_UNDEAD_UNIT 3 (Skeleton) 22 2}
#endif
        [scroll_to_unit]
            x=22
            y=2
        [/scroll_to_unit]
    [/event]

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