#textdomain wesnoth-utbs
# Level 7.b: Talking with Trolls

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

    map_data="{campaigns/Under_the_Burning_Suns/maps/07b_Talking_with_Trolls.map}"

    {STORY_TALKING_WITH_TROLLS}

    {SCENARIO_MUSIC "northerners.ogg"}

    next_scenario=8_Out_of_the_Frying_Pan

    #no turn limit for this cutscene
    turns=-1

    #don't display snapshot of map in saved games
    snapshot=no
    victory_when_enemies_defeated=no

    {UNDERGROUND}

    [side]
        side=1
        id=Kaleh
        type=Desert Fighter
        canrecruit=yes
        gold=0
        {INCOME -2 -2 -2}
        controller=human
        #recruit=Desert Fighter3, Desert Archer3, Desert Hunter3, Desert Shaman3, Desert Scout3
        shroud=no
        fog=no
        team_name=ally
        user_team_name=_"Allies"
    [/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]

        #keep cost of units constant from previous scenario
        [if]
            [variable]
                name=scen3
                numerical_equals=2
            [/variable]

            [then]
                #go from 3 to 4

                [disallow_recruit]
                    type=Desert Fighter, Desert Archer, Desert Hunter, Desert Shaman, Desert Scout
                    side=1
                [/disallow_recruit]

                [disallow_recruit]
                    type=Desert Fighter2, Desert Archer2, Desert Hunter2, Desert Shaman2, Desert Scout2
                    side=1
                [/disallow_recruit]

                [disallow_recruit]
                    type=Desert Fighter3, Desert Archer3, Desert Hunter3, Desert Shaman3, Desert Scout3
                    side=1
                [/disallow_recruit]

                [allow_recruit]
                    type=Desert Fighter4, Desert Archer4, Desert Hunter4, Desert Shaman4, Desert Scout4
                    side=1
                [/allow_recruit]
            [/then]

            [else]
                [if]
                    [variable]
                        name=scen3
                        numerical_equals=1
                    [/variable]

                    [then]
                        #go from 2 to 3

                        [disallow_recruit]
                            type=Desert Fighter, Desert Archer, Desert Hunter, Desert Shaman, Desert Scout
                            side=1
                        [/disallow_recruit]

                        [disallow_recruit]
                            type=Desert Fighter2, Desert Archer2, Desert Hunter2, Desert Shaman2, Desert Scout2
                            side=1
                        [/disallow_recruit]

                        [allow_recruit]
                            type=Desert Fighter3, Desert Archer3, Desert Hunter3, Desert Shaman3, Desert Scout3
                            side=1
                        [/allow_recruit]
                    [/then]
                [/if]

                [if]
                    [variable]
                        name=scen3
                        numerical_equals=3
                    [/variable]

                    [then]
                        #go from 4 to 5

                        [disallow_recruit]
                            type=Desert Fighter, Desert Archer, Desert Hunter, Desert Shaman, Desert Scout
                            side=1
                        [/disallow_recruit]

                        [disallow_recruit]
                            type=Desert Fighter2, Desert Archer2, Desert Hunter2, Desert Shaman2, Desert Scout2
                            side=1
                        [/disallow_recruit]

                        [disallow_recruit]
                            type=Desert Fighter3, Desert Archer3, Desert Hunter3, Desert Shaman3, Desert Scout3
                            side=1
                        [/disallow_recruit]

                        [disallow_recruit]
                            type=Desert Fighter4, Desert Archer4, Desert Hunter4, Desert Shaman4, Desert Scout4
                            side=1
                        [/disallow_recruit]

                        [allow_recruit]
                            type=Desert Fighter5, Desert Archer5, Desert Hunter5, Desert Shaman5, Desert Scout5
                            side=1
                        [/allow_recruit]
                    [/then]
                [/if]
            [/else]
        [/if]

        #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
        [/recall]
        [recall]
            id=Zhul
        [/recall]
        [recall]
            id=Elyssa
        [/recall]

        #recall other dwarves
        [recall]
            id=Grog
        [/recall]

        [recall]
            id="Thu'lok"
        [/recall]
        [recall]
            id=Harpo
        [/recall]
        [recall]
            id=Groucho
        [/recall]
        [recall]
            id=Chico
        [/recall]
        [recall]
            id=Groo
        [/recall]

        #teleport trolls to correct locations

        [teleport]
            [filter]
                id=Grog
            [/filter]
            x,y=8,12
        [/teleport]

        [teleport]
            [filter]
                id="Thu'lok"
            [/filter]
            x,y=12,12
        [/teleport]

        [teleport]
            [filter]
                id=Harpo
            [/filter]
            x,y=11,13
        [/teleport]

        [teleport]
            [filter]
                id=Groucho
            [/filter]
            x,y=13,12
        [/teleport]

        [teleport]
            [filter]
                id=Chico
            [/filter]
            x,y=12,13
        [/teleport]

        [teleport]
            [filter]
                id=Groo
            [/filter]
            x,y=13,13
        [/teleport]

        #teleport heroes to correct locations
        [teleport]
            [filter]
                id=Elyssa
            [/filter]
            x,y=10,11
        [/teleport]

        [teleport]
            [filter]
                id=Zhul
            [/filter]
            x,y=11,10
        [/teleport]

        [teleport]
            [filter]
                id=Nym
            [/filter]
            x,y=9,10
        [/teleport]

        #convert Thu'lok, Groucho, Harpo, Chico, Groo to side 2

        [store_unit]
            [filter]
                id="Thu'lok"
            [/filter]
            variable=trollstats
        [/store_unit]

        [set_variable]
            name=trollstats.side
            value=2
        [/set_variable]

        [unstore_unit]
            variable=trollstats
        [/unstore_unit]

        [store_unit]
            [filter]
                id=Groucho
            [/filter]
            variable=trollstats
        [/store_unit]

        [set_variable]
            name=trollstats.side
            value=2
        [/set_variable]

        [unstore_unit]
            variable=trollstats
        [/unstore_unit]

        [store_unit]
            [filter]
                id=Harpo
            [/filter]
            variable=trollstats
        [/store_unit]

        [set_variable]
            name=trollstats.side
            value=2
        [/set_variable]

        [unstore_unit]
            variable=trollstats
        [/unstore_unit]

        [store_unit]
            [filter]
                id=Chico
            [/filter]
            variable=trollstats
        [/store_unit]

        [set_variable]
            name=trollstats.side
            value=2
        [/set_variable]

        [unstore_unit]
            variable=trollstats
        [/unstore_unit]

        [store_unit]
            [filter]
                id=Groo
            [/filter]
            variable=trollstats
        [/store_unit]

        [set_variable]
            name=trollstats.side
            value=2
        [/set_variable]

        [unstore_unit]
            variable=trollstats
        [/unstore_unit]

        {CLEAR_VARIABLE trollstats}

        #initialize starting variables

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        [unit]
            type=Troll Whelp
            id=Troll Guard
            name= _ "Troll Guard"
            x=14
            y=11
            side=2
            ai_special=guardian
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
        [/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 aboveground, 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]

        [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. $troll_name has volunteered to protect you and lead you back to the sunlight lands."
        [/message]

        [if]
            [variable]
                name=saw_troll_prisoner
                numerical_equals=1
            [/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=$troll_name
                    message= _ "You did trolls big service. $troll_name like to wander in tunnels, and chief say that he knows the upper tunnels the best. $troll_name 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]

        [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, $troll_name|."
        [/message]

        [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]
            [/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]
                message= _ "Yes, I'll take it."

                [command]
                    [object]
                        [filter]
                            x=10
                            y=10
                            side=1
                        [/filter]

                        id=FlamingSword
                        image=items/flame-sword.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]
                [/command]

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

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

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

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

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

    {@campaigns/Under_the_Burning_Suns/utils/kaleh-abilities.cfg}
    #{@campaigns/Under_the_Burning_Suns/utils/deaths.cfg}
[/scenario]
