#textdomain wesnoth-utbs

[scenario]
    id=07a_Dealing_with_Dwarves
    name= _ "Dealing with Dwarves"

    {UTBS_MAP 07a_Dealing_with_Dwarves.map}

    {STORY_DEALING_WITH_DWARVES}

    {SCENARIO_MUSIC "knalgan_theme.ogg"}

    next_scenario=08_Out_of_the_Frying_Pan
    turns=unlimited
    victory_when_enemies_defeated=no

    {UNDERGROUND}

    [side]
        side=1
        id=Kaleh
        type=Quenoth Youth
        canrecruit=yes
        gold=0
        {NO_INCOME}
        controller=human
        shroud=no
        fog=no
        team_name=ally
        user_team_name= _ "team_name^Quenoth Elves"
        {FLAG_VARIANT long}
    [/side]

    #side=2 Dwarf king
    [side]
        id=King Thurongar
        name= _ "King Thurongar"
        type=Dwarvish Lord
        side=2
        canrecruit=no
        [modifications]
            {TRAIT_INTELLIGENT}
            {TRAIT_RESILIENT}
        [/modifications]
        ai_special=guardian
        gold=0
        income=0
        controller=ai
        shroud=no
        fog=no
        team_name=ally
        user_team_name=_"Allies"
        {FLAG_VARIANT knalgan}
    [/side]

    # Prestart functions:
    # set starting scenario objectives
    # keep cost of recruiting units the same
    # recall main heroes
    # initialize starting variables
    # create starting guards

    [event]
        name=prestart

        # set starting scenario objectives

        [objectives]
            summary= _ "Starting Objectives:"
            [objective]
                description= _ "Choose a unit to take the Fire Blade"
                condition=win
            [/objective]
        [/objectives]

        #add furnishings
        [item]
            image=items/dragonstatue.png
            x,y=8,7
        [/item]

        [item]
            image=items/dragonstatue.png~FL()
            x,y=12,7
        [/item]

        #recall heroes

        [recall]
            id=Nym
            x,y=9,10
        [/recall]

        [recall]
            id=Zhul
            x,y=11,10
        [/recall]

        [recall]
            id=Elyssa
            x,y=10,11
        [/recall]

        #recall other dwarves
        [recall]
            id=Rogrimir
            x,y=8,12
        [/recall]

        [recall]
            id=Dwalim
            x,y=12,12
        [/recall]
        [recall]
            id=Moin
            x,y=11,13
        [/recall]
        [recall]
            id=Nordi
            x,y=13,12
        [/recall]
        [recall]
            id=Byorn
            x,y=12,13
        [/recall]
        [recall]
            id=Runin
            x,y=13,13
        [/recall]

        [modify_unit]
            [filter]
                id=Dwalim,Moin,Nordi,Byorn,Runin
            [/filter]
            side=2
        [/modify_unit]

        #initialize starting variables

        [if]
            [have_unit]
                id=Rogrimir
            [/have_unit]

            [then]
                [set_variable]
                    name=ally_name
                    value=Rogrimir
                [/set_variable]
            [/then]

            [else]
                [set_variable]
                    name=ally_name
                    value=Jarl
                [/set_variable]

                # Jarl's traits are intentionally inferior to Rogrimir's
                [unit]
                    type=Dwarvish Stalwart
                    id=Jarl
                    name= _ "Jarl"
                    profile=portraits/dwarves/fighter-2.png
                    x=8
                    y=12
                    side=1
                    unrenamable=yes
                    [modifications]
                        {TRAIT_LOYAL}
                        {TRAIT_INTELLIGENT}
                    [/modifications]
                [/unit]
            [/else]
        [/if]

        #create starting dwarf guards
        #all have special AI guardian, so that they won't move

        [unit]
            type=Dwarvish Sentinel
            name= _ "Dwarf Guard"
            x=9
            y=14
            side=2
            ai_special=guardian
            facing=se
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
            {IS_LOYAL}
        [/unit]

        [unit]
            type=Dwarvish Sentinel
            name= _ "Dwarf Guard"
            x=11
            y=14
            side=2
            ai_special=guardian
            facing=sw
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_QUICK}
            [/modifications]
            {IS_LOYAL}
        [/unit]

        [unit]
            type=Dwarvish Steelclad
            name= _ "Dwarf Guard"
            x=9
            y=6
            side=2
            ai_special=guardian
            facing=se
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_STRONG}
            [/modifications]
            {IS_LOYAL}
        [/unit]

        [unit]
            type=Dwarvish Steelclad
            name= _ "Dwarf Guard"
            x=11
            y=6
            side=2
            ai_special=guardian
            facing=se
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_INTELLIGENT}
            [/modifications]
            {IS_LOYAL}
        [/unit]

        [unit]
            type=Dwarvish Berserker
            name= _ "Dwarf Guard"
            x=7
            y=8
            side=2
            ai_special=guardian
            facing=se
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_QUICK}
            [/modifications]
            {IS_LOYAL}
        [/unit]

        [unit]
            type=Dwarvish Berserker
            name= _ "Dwarf Guard"
            x=13
            y=8
            side=2
            ai_special=guardian
            facing=sw
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
            {IS_LOYAL}
        [/unit]

        [unit]
            type=Dwarvish Dragonguard
            name= _ "Dwarf Guard"
            x=6
            y=9
            side=2
            ai_special=guardian
            facing=se
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
            {IS_LOYAL}
        [/unit]

        [unit]
            type=Dwarvish Dragonguard
            name= _ "Dwarf Guard"
            x=6
            y=11
            side=2
            ai_special=guardian
            facing=se
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
            {IS_LOYAL}
        [/unit]

        [unit]
            type=Dwarvish Dragonguard
            name= _ "Dwarf Guard"
            x=14
            y=9
            side=2
            ai_special=guardian
            facing=sw
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
            {IS_LOYAL}
        [/unit]

        [unit]
            type=Dwarvish Dragonguard
            name= _ "Dwarf Guard"
            x=14
            y=11
            side=2
            ai_special=guardian
            facing=sw
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
            {IS_LOYAL}
        [/unit]
    [/event]

    # starting dialogue
    [event]
        name=start

        [message]
            speaker=narrator
            message= _ "This chamber is beautifully decorated. Ornate frescoes and dwarven runes cover the walls, and the room is dominated by a large intricately-carved stone throne. Flanking the throne are two detailed statues of some sort of beast you aren’t familiar with. The floor is covered in dark slate, and a path of smooth tiles directs visitors up to a small stone seat which faces the throne."
            image=wesnoth-icon.png
        [/message]

        # wmllint: local spelling Thurongar
        [message]
            speaker=King Thurongar
            message= _ "Hail Kaleh, I am Thurongar, King of the Dwarves."
        [/message]

        [message]
            speaker=Kaleh
            message= _ "I am Kaleh, leader of the Quenoth Elves."
        [/message]

        [message]
            speaker=King Thurongar
            message= _ "I’ve heard of your recent exploits against the troll menace. They’ve been quite a thorn in our side for a while now. They used to be just an occasional pest, but now wherever we go we find another infestation. They’ve been getting smarter with their tactics; we’ve lost several of our outlying settlements to their attacks. Still, we’re not done fighting and with your recent victory perhaps this battle is turning in our favor. But tell me, what are so many elves doing so deep under the earth?"
        [/message]

        [message]
            speaker=Kaleh
            message= _ "It’s a long story, but we come from the south, where we lived in the desert. Our village was destroyed, and I am leading my people on a journey to find a new home. Our god Eloh appeared to me in a vision, and told me to go north, but when we came to the mountains she said I should go under them instead of trying to cross the snowy peaks. So that’s how several thousand of us ended up down here."
        [/message]

        [message]
            speaker=King Thurongar
            message= _ "Interesting. We’d offer to let you live with us, but I’m afraid we don’t have much free space; this city is almost filled to capacity. And looking at you, I don’t think that the under-realm is quite the place for your kind. I think your god may have somewhere else intended for you."
        [/message]

        [message]
            speaker=Kaleh
            message= _ "Indeed, although I admire this great city you have carved from the rock, I think many of my people find these tunnels scary and alien. All we really want to do is to find a way back to the surface on the northern side of the mountains."
        [/message]

        [message]
            speaker=King Thurongar
            message= _ "That I may be able to help you with. We haven’t sent anyone to the surface in years, but we do know of a passage that leads to the ancient northern gate. Several generations ago we used to trade heavily with humans that lived north of the mountains, but then some new human came to power and decreed that all contact with us should be cut off. We sent messengers to find out why, but they never returned."
        [/message]

        [if]
            [variable]
                name=ally_name
                equals=Rogrimir
            [/variable]

            [then]
                [message]
                    speaker=King Thurongar
                    message= _ "But dwarves are excellent delvers, and we keep meticulous maps of all the tunnels we have explored. We should still have maps of the tunnels leading back to the surface. Of course I doubt you would be able to understand them, so, Rogrimir here has volunteered to lead you to the surface."
                [/message]
            [/then]

            [else]
                [message]
                    speaker=King Thurongar
                    message= _ "But dwarves are excellent delvers, and we keep meticulous maps of all the tunnels we have explored. We should still have maps of the tunnels leading back to the surface. Of course I doubt you would be able to understand them, so, Jarl here has volunteered to lead you to the surface."
                [/message]
            [/else]
        [/if]

        [if]
            [variable]
                name=saved_rogrimir
                boolean_equals=yes
            [/variable]

            [then]
                [message]
                    speaker=Rogrimir
                    message= _ "You saved my life and my debt to you is still unpaid. Showing you the way to the surface and protecting you is the least I can do."
                [/message]

                [message]
                    speaker=Jarl
                    message= _ "You rescued my brother, and though he died fighting, he died a warrior’s death instead of a coward’s. For that I thank you. I will take his place and help you get to the surface."
                [/message]
            [/then]

            [else]
                [message]
                    speaker=$ally_name
                    message= _ "You did a great service for my brothers. In exchange, as much as I hate the light, I am the one who knows the upper tunnels the best, so I’ll be your guide."
                [/message]
            [/else]
        [/if]
        {CLEAR_VARIABLE saved_rogrimir}

        [if]
            [variable]
                name=ally_name
                equals=Rogrimir
            [/variable]

            [then]
                [message]
                    speaker=Kaleh
                    message= _ "Thank you very much for your help. We were worried about getting lost in all these twisting tunnels. And we would be honored to have you come with us, Rogrimir."
                [/message]
            [/then]

            [else]
                [message]
                    speaker=Kaleh
                    message= _ "Thank you very much for your help. We were worried about getting lost in all these twisting tunnels. And we would be honored to have you come with us, Jarl."
                [/message]
            [/else]
        [/if]

        [if]
            [have_unit]
                x,y=12-14,12-14
            [/have_unit]

            [then]
                [message]
                    speaker=King Thurongar
                    message= _ "The dwarves who fought by your side have come to pay their respects as well."
                [/message]

                [message]
                    x,y=12-14,12-14
                    message= _ "You helped us strike a huge blow against those savages and it was an honor to fight by your side. You are the bravest elves we have ever known. We’d like to come with you, but, well, we don’t like going that close to the surface, and besides there’s still lots of fighting to be done down here. Don’t you worry, we won’t rest until we have killed every one of trolls."
                [/message]

                [message]
                    speaker=Kaleh
                    message= _ "I understand. Thank you, you were a huge help to us. It was an honor to fight by your side."
                [/message]
            [/then]
        [/if]

        [if]
            [have_unit]
                id=Elyssa
            [/have_unit]

            [then]
                [message]
                    speaker=Elyssa
                    message= _ "I’m afraid, Kaleh, that the time has come for our paths to separate."
                [/message]

                [message]
                    speaker=Kaleh
                    message= _ "What?!"
                [/message]

                [message]
                    speaker=Elyssa
                    #the sceptre of fire always has the 're' writing, this is intentional!
                    message= _ "I have learned a lot about the dwarves in my time here, and yet there’s so much more to learn. Have you seen their forges? They really know how to work fire and use it in amazing ways. They have some interesting ideas about how they might improve their smithing with my magical fire. And have you seen their records? They have kept records of their dealings that go back generations upon generations. They even know of the dwarven clan who helped craft the sceptre of fire. Imagine if I could find the dwarves who helped build such an artifact!"
                [/message]

                [message]
                    speaker=Nym
                    message= _ "But we need you! What would we do without you?"
                [/message]

                [message]
                    speaker=Elyssa
                    message= _ "With the help of the dwarves, I think you will do just fine. I don’t know what home your god has planned for you, Kaleh, but I believe in you, and I know that you will find a place for your people. My place is here, with the dwarves. And you don’t really need me, you have each other."
                [/message]

                [message]
                    speaker=Kaleh
                    message= _ "If your mind is set, then I won’t try to convince you. But we will miss you."
                [/message]

                [message]
                    speaker=Zhul
                    message= _ "I thank Eloh for the brief time that she has let you spend with us."
                [/message]

                [message]
                    speaker=Nym
                    message= _ "You take care of yourself, and someday maybe we’ll meet again."
                [/message]

                [message]
                    speaker=Elyssa
                    message= _ "Thank you. And I owe you so much for helping me meet the dwarves. I never would have come down here myself. With some help from the dwarves I have enchanted this fire blade for you. May its flames always light your path, and strike down your enemies. I give this to all of you as a token of my gratitude."
                [/message]

                {PLACE_IMAGE items/flame-sword.png 10 10}

                [message]
                    speaker=Kaleh
                    message= _ "A flaming sword. That’s amazing. I just don’t know who should use it."
                [/message]

                [message]
                    speaker=Elyssa
                    message= _ "I will let you decide; use it in the best way that you see fit."
                [/message]

                [message]
                    speaker=narrator
                    message= _ "You can choose which unit you want to take the flaming sword. If you want another unit to wield the sword, Kaleh can recruit or recall other units."
                    image=wesnoth-icon.png
                [/message]

                # here we store the player’s actual gold and set it to 100 instead,
                # since otherwise they might be unable to recruit or recall due to
                # lack of gold
                [store_side]
                    side=1
                    variable=stored_side_1
                [/store_side]

                [modify_side]
                    side=1
                    gold=100
                [/modify_side]
            [/then]

            [else]
                [message]
                    speaker=King Thurongar
                    message= _ "And now I think you should be off as soon as possible. The trolls have retreated into their holes for the present, but who knows when they will strike again."
                [/message]

                [message]
                    speaker=Nym
                    message= _ "This is a marvelous city, but I for one can’t wait to feel the sun upon my face again and the wind in my hair."
                [/message]

                [endlevel]
                    result=victory
                    carryover_report=no
                    {NEW_GOLD_CARRYOVER 100}
                [/endlevel]
            [/else]
        [/if]
    [/event]

    [event]
        name=moveto
        first_time_only=no

        [filter]
            x=10
            y=10
            [not]
                id=Elyssa
            [/not]
            [not]
                type=Dust Devil
            [/not]
            side=1
        [/filter]

        [message]
            speaker=unit

            message= _ "Should I take this sword?"
            [option]
                label= _ "Yes, I’ll take it."

                [command]
                    [object]
                        [filter]
                            # TODO: decide which units should be able to take it,
                            # or change the item into something else
                            x=10
                            y=10
                            side=1
                        [/filter]

                        id=FlamingSword
                        image=attacks/sword-flaming.png
                        name= _ "Flaming Sword"
                        description= _ "This sword will make all your melee attacks do fire damage."

                        [effect]
                            apply_to=attack
                            range=melee
                            set_type=fire
                            [set_specials]
                                {WEAPON_SPECIAL_MAGICAL}
                            [/set_specials]
                        [/effect]
                    [/object]

                    [message]
                        speaker=unit
                        message= _ "I will wield this blade proudly, and whenever I look upon it I shall remember you, Elyssa."
                    [/message]

                    [message]
                        speaker=King Thurongar
                        message= _ "And now I think you should be off as soon as possible. The trolls have retreated back into their holes for the present, but who knows when they will strike again."
                    [/message]

                    [message]
                        speaker=Nym
                        message= _ "This is a marvelous city, but I for one can’t wait to feel the sun upon my face again and the wind in my hair."
                    [/message]

                    # let's give the player their actual starting gold back
                    [modify_side]
                        side=1
                        gold=$stored_side_1.gold
                    [/modify_side]

                    {CLEAR_VARIABLE stored_side_1}

                    [endlevel]
                        result=victory
                        carryover_report=no
                        {NEW_GOLD_CARRYOVER 100}
                    [/endlevel]
                [/command]
            [/option]

            [option]
                label= _ "No, I think someone else should wield it."

                [command]
                    [allow_undo]
                    [/allow_undo]
                [/command]
            [/option]
        [/message]
    [/event]
[/scenario]
