#textdomain wesnoth-utbs

[scenario]
    id=07b_Talking_with_Trolls
    name= _ "Talking with Trolls"

    {UTBS_MAP 07b_Talking_with_Trolls.map}

    {STORY_TALKING_WITH_TROLLS}

    {SCENARIO_MUSIC "northerners.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 Troll Leader
    [side]
        id=Great Leader Darmog
        name= _ "Great Leader Darmog"
        # wmllint: local spelling Darmog
        type=Great Troll
        side=2
        canrecruit=no
        [modifications]
            {TRAIT_INTELLIGENT}
            {TRAIT_STRONG}
        [/modifications]
        ai_special=guardian
        gold=0
        income=0
        controller=ai
        shroud=no
        fog=no
        team_name=ally
        user_team_name=_"Allies"
    [/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 rubble and other items
        {PLACE_IMAGE scenery/rubble.png 9 9}
        {PLACE_IMAGE scenery/rubble.png 12 9}
        {PLACE_IMAGE scenery/rubble.png 11 7}
        {PLACE_IMAGE scenery/rubble.png 13 10}
        {PLACE_IMAGE scenery/rubble.png 7 12}

        {PLACE_IMAGE scenery/rubble.png 8 7}
        {PLACE_IMAGE scenery/rubble.png 12 7}

        #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=Grog
            x,y=8,12
        [/recall]

        [recall]
            id="Thu'lok"
            x,y=12,12
        [/recall]
        [recall]
            id=Harpo
            x,y=11,13
        [/recall]
        [recall]
            id=Groucho
            x,y=13,12
        [/recall]
        [recall]
            id=Chico
            x,y=12,13
        [/recall]
        [recall]
            id=Groo
            x,y=13,13
        [/recall]

        [modify_unit]
            [filter]
                id="Thu'lok,Groucho,Harpo,Chico,Groo"
            [/filter]
            side=2
        [/modify_unit]

        #initialize starting variables

        [if]
            [have_unit]
                id=Grog
            [/have_unit]

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

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

                # Nog's traits are intentionally inferior to Grog's
                [unit]
                    type=Troll
                    id=Nog
                    name= _ "Nog"
                    profile=portraits/trolls/troll-hero-alt.png
                    x=8
                    y=12
                    side=1
                    unrenamable=yes
                    [modifications]
                        {TRAIT_LOYAL}
                        {TRAIT_QUICK}
                    [/modifications]
                    {IS_LOYAL}
                [/unit]
            [/else]
        [/if]

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

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

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

        [unit]
            type=Troll Shaman
            id=Spiritual Advisor
            name= _ "Spiritual Advisor"
            x=9
            y=6
            side=2
            ai_special=guardian
            facing=se
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_STRONG}
            [/modifications]
            {IS_LOYAL}
        [/unit]

        [unit]
            type=Troll Shaman
            name= _ "Spiritual Advisor"
            x=11
            y=6
            side=2
            ai_special=guardian
            facing=se
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_INTELLIGENT}
            [/modifications]
            {IS_LOYAL}
        [/unit]

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

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

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

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

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

        [unit]
            type=Troll Whelp
            name= _ "Troll 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= _ "It is clear that this chamber used to be quite ornately decorated, but almost all of it has been destroyed, revealing a stone and dirt floor. What remains is a large stone throne, which has been covered with skulls and animal skins and bright paint. The walls were once covered with frescoes and dwarven runes, but several trolls are busy chipping them off. The floor was once tiled in dark slate, but only two small patches of tiles remain around the two chairs in this chamber. You’re surprised to see that small tile path running up the center of the chamber has been left untouched. It leads to a small stone chair facing the large throne."
            image=wesnoth-icon.png
        [/message]

        [message]
            speaker=Great Leader Darmog
            message= _ "I, Great Leader Darmog, greet you, Kaleh."
        [/message]

        [message]
            speaker=Kaleh
            message= _ "I Kaleh, leader of the Quenoth Elves, thank you for meeting with me."
        [/message]

        [message]
            speaker=Great Leader Darmog
            message= _ "On behalf of all trolls, Darmog thank you for great victory over the dwarves. You have helped drive back the nasty dwarves and given us time to strengthen our defenses. Us trolls not always enemies of dwarves. Until recently we not have much contact with small people. But dwarves invade our tunnels, defile our holy places and kill our women and young. Dwarf not care about anything except gold and pretty gems. The shamans say that the spirits of our kin cry out for vengeance and Darmog will not rest until every dwarf is dead!"
        [/message]

        [message]
            speaker=Spiritual Advisor
            message= _ "But I am curious, we do not know of your kind. We thank you for your help, but who are you and why do you come down here with so many of your people?"
        [/message]

        [message]
            speaker=Kaleh
            message= _ "It’s a long story, but we come from the south, where we lived above ground 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. We do not want to live down here, we are just trying to find a way to the other side of the mountains."
        [/message]

        [message]
            speaker=Great Leader Darmog
            message= _ "Darmog has never been above ground, but Darmog understand your story. A leader must protect and care for his people. Every people deserve to find their own home. If we can help you we will."
        [/message]

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

            [then]
                [message]
                    speaker=Spiritual Advisor
                    message= _ "We may be able to help you find a way back to the sunlit lands. In our temples we do keep records of the past. We have not walked above the earth for many many generations, not since the darkness drove us underground. But we are masters of the underground lands, and we have explored many tunnels. Recently one of our scouts found a path that leads north back to the sunlit lands, I think it may be the way you are trying to go. In reward for your achievements, we will help you. Grog has volunteered to protect you and lead you back to the sunlight lands."
                [/message]
            [/then]

            [else]
                [message]
                    speaker=Spiritual Advisor
                    message= _ "We may be able to help you find a way back to the sunlit lands. In our temples we do keep records of the past. We have not walked above the earth for many many generations, not since the darkness drove us underground. But we are masters of the underground lands, and we have explored many tunnels. Recently one of our scouts found a path that leads north back to the sunlit lands, I think it may be the way you are trying to go. In reward for your achievements, we will help you. Nog has volunteered to protect you and lead you back to the sunlight lands."
                [/message]
            [/else]
        [/if]

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

            [then]
                [message]
                    speaker=Grog
                    message= _ "You saved Grog’s life. Grog still owe you a debt of thanks. In return Grog will protect little elves and show them the way back to lighted lands."
                [/message]

                [message]
                    speaker=Nog
                    message= _ "You rescued Nog’s brother, and he died like a warrior in battle, not like a coward in chains. Nog is very grateful. You proved yourselves to be brave strong warriors, and Nog will help you find way back to lighted lands."
                [/message]
            [/then]

            [else]
                [message]
                    speaker=Nog
                    message= _ "You did trolls big service. Nog like to wander in tunnels, and chief say that he knows the upper tunnels the best. Nog want to help elves so even though he not want to leave battle, he agrees to show elves way back to lighted lands."
                [/message]
            [/else]
        [/if]
        {CLEAR_VARIABLE saved_grog}

        [if]
            [variable]
                name=ally_name
                equals=Grog
            [/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, Grog."
                [/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, Nog."
                [/message]
            [/else]
        [/if]

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

            [then]
                [message]
                    speaker=Great Leader Darmog
                    message= _ "The trolls who fought with you also want to thank you. They tell great tales of your valor."
                [/message]

                [message]
                    x,y=12-14,12-14
                    message= _ "We thank you for all you have done for trolls. You are bravest small people we know. We will tell stories of your battles to all our families so that none will forget. We wish we could come with you and fight more, but Great Leader need us to protect this city. Many dwarves still left, much fighting still to do. Griknagh will protect us, may he watch over you too."
                [/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
                    message= _ "I have learned a lot about the trolls in my time here, and yet there’s so much more to learn. Their magic is amazing. Have you seen their shamans? They make fire with their bare hands. They are very interested in my magic and they have offered to teach me how they create fire. I thought I was one of the last people still practicing magic, who knew I would find trolls still teaching it deep under the earth? There is just so much that I can learn from them, I can’t leave now."
                [/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 trolls, 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 trolls. 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 discover the trolls. I never would have come down here myself. I found this sword when we were fighting the dwarves and with some help from the trolls 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=Great Leader Darmog
                    message= _ "And now Darmog think you should be off as soon as possible. The dwarves are sneaky, they retreat today but may attack again tomorrow. The sooner you leave the safer you will be."
                [/message]

                [message]
                    speaker=Nym
                    message= _ "I heartily agree, 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
                        [/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=Great Leader Darmog
                        message= _ "And now Darmog think you should be off as soon as possible. The dwarves are sneaky, they retreat today but may attack again tomorrow. The sooner you leave the safer you will be."
                    [/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]

                    [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]
