#textdomain wesnoth-utbs
# Level 13: Epilogue

[scenario]
    id="13_Epilogue"
    name= _ "Epilogue"

    map_data="{campaigns/Under_the_Burning_Suns/maps/13_Epilogue.map}"

    {STORY_EPILOGUE}

    {SCENARIO_MUSIC "elf-land.ogg"}
    {EXTRA_SCENARIO_MUSIC "journeys_end.ogg"}
    {EXTRA_SCENARIO_MUSIC "love_theme.ogg"}

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

    # no turn limit
    turns="-1"

    {DAWN1}

    #side 1: elves
    [side]
        side=1
        id=Kaleh
        type=Desert Fighter
        canrecruit=yes
        gold=0
        {NO_INCOME}
        controller=human
        shroud=no
        fog=no
    [/side]

    # Prestart functions:

    [event]
        name=prestart

        # scenario testing units

        # recall Nym

        [recall]
            id=Nym
        [/recall]

        # teleport Nym

        [teleport]
            [filter]
                id=Nym
            [/filter]
            x,y=30,38
        [/teleport]

        # store/remove Nym

        [store_unit]
            [filter]
                id=Nym
            [/filter]
            kill=yes
            variable=stored_nym
        [/store_unit]

        # initialize starting variables

        # capture all villages for side 1

        [capture_village]
            x=0-50
            y=0-50
            side=1
        [/capture_village]
    [/event]

    # Event 1: Starting dialogue

    [event]
        name=start

        [message]
            speaker=Kaleh
            message= _ "I stumbled out into the daylight, scarcely believing that we were victorious. Looking out over the island it took me a moment to realize what had changed. The fetid darkness had lifted from the land and I saw the suns shining brightly for what seemed like the first time in ages. Gazing across the bright green trees and sparkling ocean I realized that once this had been a place of beauty. Several of our brethren were waiting for me and I was overjoyed to discover that they were no longer the mindless slaves I had seen before. They too had broken free from their enchantment."
        [/message]

        [message]
            speaker=Kaleh
            message= _ "Indeed with Yechnagoth's death it seems that all of her minions reverted to their original chaotic tendencies. Luckily we had already destroyed most of the island's foul inhabitants, and lacking their former discipline we had no trouble exterminating the remaining orcs and undead. The naga too fled before us, and they have not bothered us since. For once we seemed to be safe from imminent danger."
        [/message]

        [message]
            speaker=Kaleh
            message= _ "A few days later Melusand herself appeared and she declared the cleansing of this island a miracle. We made a pact between elf and merfolk and vowed to live together in peace and prosperity. Melusand blessed the island, and named it 'Quenoth Isle' in honor of our people. The merfolk have been very helpful in teaching us how to adapt to this strange land, though I still have trouble getting used to being surrounded by water. It used to be more precious than gold. Still, I could hardly imagine a better home for my people. Between the bounty of the sea and the many fruits of the jungle there is no shortage of food. We are isolated from the chaos on the mainland and the merfolk guard the waters. Melusand says now is a time for peace and prosperity. Part of me didn't think we would survive our journey, there were so many close calls. Coming here almost does seem like a miracle. If only I could forget the price we paid..."
        [/message]

        # change depending on how many friends died

        [if]
            [variable]
                name=allies_killed
                numerical_equals=0
            [/variable]

            [then]
                [message]
                    speaker=Kaleh
                    message= _ "If you had told me at the start of our journey the price I was to pay in blood, I do not know if I would have had the strength to take that first step. I suppose I should have known that my friends would not let me confront Yechnagoth alone. And it is only through Eloh's grace and a good bit of luck that none of them died in that bloody battle. But so many others that I grew up with were not so lucky. Why did so many of us have to die? I wish I could go back and do it all over again."
                [/message]
            [/then]

            [else]
                {INCIDENTAL_MUSIC sad.ogg}
            [/else]
        [/if]

        # if only 1 friend dies, then have 3 different texts depending on who died

        [if]
            [variable]
                name=allies_killed
                numerical_equals=1
            [/variable]

            [then]
                [if]
                    [variable]
                        name=nym_dead
                        numerical_equals=1
                    [/variable]

                    [then]
                        [message]
                            speaker=Kaleh
                            message= _ "If you had told me at the start of our journey the price I was to pay in blood, I do not know if I would have had the strength to take that first step. I suppose I should have known that my friends would not let me confront Yechnagoth alone. But I would gladly give up my life today if I could bring Nym back. She followed me faithfully and fought by my side for so long, to lose her at the end... I wish I could go back and do it all over again."
                        [/message]
                    [/then]
                [/if]

                [if]
                    [variable]
                        name=zhul_dead
                        numerical_equals=1
                    [/variable]

                    [then]
                        [message]
                            speaker=Kaleh
                            message= _ "If you had told me at the start of our journey the price I was to pay in blood, I do not know if I would have had the strength to take that first step. I suppose I should have known that my friends would not let me confront Yechnagoth alone. But I would gladly give up my life today if I could bring Zhul back. She followed me faithfully and fought by my side for so long, to lose her at the end... I wish I could go back and do it all over again."
                        [/message]
                    [/then]
                [/if]

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

                    [then]
                        [message]
                            speaker=Kaleh
                            message= _ "If you had told me at the start of our journey the price I was to pay in blood, I do not know if I would have had the strength to take that first step. I suppose I should have known that my friends would not let me confront Yechnagoth alone. But I would gladly give up my life today if I could bring $intl_ally_name back. He left his homeland to fight faithfully by my side, and then to lose him at the end... I wish I could go back and do it all over again."
                        [/message]
                    [/then]
                [/if]
            [/then]
        [/if]

        [if]
            [variable]
                name=allies_killed
                greater_than=1
            [/variable]

            [then]
                [message]
                    speaker=Kaleh
                    message= _ "If you had told me at the start of our journey the price I was to pay in blood, I do not know if I would have had the strength to take that first step. I suppose I should have known that my friends would not let me confront Yechnagoth alone. But I would gladly give up my life today if I could bring any one of them back. They followed me faithfully and fought by my side for so long, to lose them at the end... I wish I could go back and do it all over again."
                [/message]
            [/then]
        [/if]

        [if]
            [variable]
                name=allies_killed
                numerical_equals=1
            [/variable]

            [then]
                [if]
                    [variable]
                        name=nym_dead
                        numerical_equals=1
                    [/variable]

                    [then]
                        [message]
                            speaker=Kaleh
                            message= _ "Although I believe that our battle in the black citadel was our finest hour, I am still haunted by Nym's death in that dark place. And so every morning at sunrise I come out to the southeastern tip of the island and look out upon the waters, upon the world that we sacrificed so much to preserve. I remind myself what Zhul said, and they all believed, that despite all the death and fighting we saw in our journey, this world was a beautiful and good enough place that Nym was willing to sacrifice her life to save it. Looking out over the waters, and back upon the prosperity of my people, I tell myself it was worth it. But sometimes that seems a small consolation."
                        [/message]
                    [/then]
                [/if]

                [if]
                    [variable]
                        name=zhul_dead
                        numerical_equals=1
                    [/variable]

                    [then]
                        [message]
                            speaker=Kaleh
                            message= _ "Although I believe that our battle in the black citadel was our finest hour, I am still haunted by Zhul's death in that dark place. And so every morning at sunrise I come out to the southeastern tip of the island and look out upon the waters, upon the world that we sacrificed so much to preserve. I remind myself what Zhul said, and they all believed, that despite all the death and fighting we saw in our journey, this world was a beautiful and good enough place that Zhul was willing to sacrifice her life to save it. Looking out over the waters, and back upon the prosperity of my people, I tell myself it was worth it. But sometimes that seems a small consolation."
                        [/message]
                    [/then]
                [/if]

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

                    [variable]
                        name=ally_died_in_final_fight
                        boolean_equals=yes
                    [/variable]

                    [then]
                        [message]
                            speaker=Kaleh
                            message= _ "Although I believe that our battle in the black citadel was our finest hour, I am still haunted by the death of $intl_ally_name in that dark place. And so every morning at sunrise I come out to the southeastern tip of the island and look out upon the waters, upon the world that we sacrificed so much to preserve. I remind myself what Zhul said, and they all believed, that despite all the death and fighting we saw in our journey, this world was a beautiful and good enough place that $intl_ally_name was willing to sacrifice his life to save it. Looking out over the waters, and back upon the prosperity of my people, I tell myself it was worth it. But when I think of the desperate war that his people are probably still fighting underground, it seems a small consolation."
                        [/message]
                    [/then]
                [/if]
            [/then]
        [/if]

        [if]
            [variable]
                name=allies_killed
                greater_than=1
            [/variable]

            [then]
                [message]
                    speaker=Kaleh
                    message= _ "Although I believe that our battle in the black citadel was our finest hour, I am still haunted by my friends' deaths in that dark place. And so every morning at sunrise I come out to the southeastern tip of the island and look out upon the waters, upon the world that we sacrificed so much to preserve. I remind myself what Zhul said, and they all believed, that despite all the death and fighting we saw in our journey, this world was a beautiful and good enough place that they were willing to sacrifice their lives to save it. Looking out over the waters, and back upon the prosperity of my people, I tell myself it was worth it. But I still miss each one of them horribly."
                [/message]
            [/then]
        [/if]

        [if]
            [variable]
                name=nym_dead
                numerical_equals=1
            [/variable]

            [then]
                [message]
                    speaker=Kaleh
                    image=portraits/nym.png
                    message= _ "We carried Nym to a small island to the north which had a single peak with a beautiful view of the surrounding islands. It seemed to me to be a lookout that Nym would appreciate. So I and a few others climbed to the top of the peak and dug a grave for Nym so that she might always look down upon us and see all that we accomplished with her gift. For she gave us the gift of life, and every day I strive to make the most use of it I can. I will always remember her. Nym, who was with me ever since I was a child and during every step of the journey, who was always faithful, but never hesitated to speak her mind, who managed to crack a joke no matter how grim the situation. How I miss her laugh, her smile, her..."
                [/message]
            [/then]
        [/if]

        [if]
            [variable]
                name=zhul_dead
                numerical_equals=1
            [/variable]

            [then]
                [message]
                    speaker=Kaleh
                    image=portraits/zhul.png
                    message= _ "Zhul's funeral was a huge ceremony, like those she told us about from ages ago. I led a procession of our few remaining priestesses and all of the faithful around the entire island, so that she might see all that she had given to us. Being a priestess of the desert sands we buried her in one of the large beaches at the northwest end of the island. At the final battle she was one of the oldest elves left and I suppose I should thank Eloh that she did not die during our journey. She was my guide and my faith and my link to the past. I am sorry that she did not live to see the fruits of her labors, but I hope that she is with Eloh now, in a better place."
                [/message]
            [/then]
        [/if]

        # if ally dies in the final battle
        [if]
            [variable]
                name=ally_dead
                boolean_equals=yes
            [/variable]

            [variable]
                name=ally_died_in_final_fight
                boolean_equals=yes
            [/variable]

            [then]
                [if]
                    [variable]
                        name=ally_race
                        equals=Dwarf
                    [/variable]

                    [then]
                        [message]
                            speaker=Kaleh
                            image=portraits/rogrimir.png
                            message= _ "I am saddened by the death of $intl_ally_name, but by saving my life in the end he did fulfill his life debt to me. I think he also would have been glad to have died in battle. I considered leading an expedition to go back and return his body to his people, but my fellow elves have been weakened by our long journey and I do not want to risk losing any more. Instead I searched all across the islands and at last in the rocky outcroppings to the northwest I found a series of caves. They were not as deep as his homeland but I thought $intl_ally_name would have appreciated being laid to rest under some solid rock. And so we buried him with much honor and will long remember the service that his kind has done for our people."
                        [/message]
                    [/then]

                    [else]
                        [message]
                            speaker=Kaleh
                            image=portraits/grog.png
                            message= _ "I am saddened by the death of $intl_ally_name, but by saving my life in the end he did fulfill his life debt to me. I think he also would have been glad to have died in battle. I considered leading an expedition to go back and return his body to his people, but my fellow elves have been weakened by our long journey and I do not want to risk losing any more. Instead I searched all across the islands and at last in the rocky outcroppings to the northwest I found a series of caves. They were not as deep as his homeland but I thought $intl_ally_name would have appreciated being laid to rest under some solid rock. And so we buried him with much honor and will long remember the service that his kind has done for our people."
                        [/message]
                    [/else]
                [/if]
            [/then]
        [/if]

        # if nym doesn't die
        [if]
            [variable]
                name=nym_dead
                numerical_equals=0
            [/variable]

            [then]
                [message]
                    speaker=Kaleh
                    image=portraits/nym.png
                    message= _ "Although I am not as devout as Zhul is, I thank Eloh every day that Nym survived that horrible battle in the Black Citadel. No one has been more enthusiastic than she in embracing our life among the islands. She delights in swimming and sailing among the shallows and spends so much time in the water that sometimes I think she is half mermaid herself. Her sparkling laugh and quick wit are a daily gift to us. She entertains the children with thrilling (though often slightly embellished) tales of our great journey, and at times when I get moody, she reminds me what a joy it is to be alive in this great land. She is a living testament to the fact that even though we were born among the sands we can thrive anywhere we have the will to live."
                [/message]
            [/then]
        [/if]

        # if zhul doesn't die
        [if]
            [variable]
                name=zhul_dead
                numerical_equals=0
            [/variable]

            [then]
                [message]
                    speaker=Kaleh
                    image=portraits/zhul.png
                    message= _ "The oldest of the surviving elves, Zhul is moving slower now, but she still has that sparkle in her eye. Despite the hardships of our journey and Yechnagoth's deceptions, our victory has only strengthened her faith. She will be as quick as always to correct the error of your ways if you ever express a disbelief in the powers of Eloh. She told me recently that all the trials and triumphs of our journey were but parts of Eloh's great plan for us, and this new home is our reward. She is spending her time now teaching a whole new generation of priestesses and telling all the old stories to the children so that they won't be forgotten. She has started designing a sacred grove in the jungle for Eloh, as our people did in the olden times. I am still not quite used to seeing so many trees, but perhaps, as some people say, it is a sign that the peace and prosperity of old has come again."
                [/message]
            [/then]
        [/if]

        # if ally doesn't die
        [if]
            [variable]
                name=ally_dead
                boolean_equals=no
            [/variable]

            [then]
                [if]
                    [variable]
                        name=ally_race
                        equals=Dwarf
                    [/variable]

                    [then]
                        [message]
                            speaker=Kaleh
                            image=portraits/rogrimir.png
                            message= _ "By saving my life, $intl_ally_name fulfilled his life debt to me, but we convinced him to hang around for a while and revel in the celebrations that we held after our great victory. We celebrated for days and days, thanking Eloh and the merfolk's god, and delighting in the bounty and beauty of our new home. Afterwards we set to work building new dwellings for our people. $intl_ally_name stayed to help us with the construction, he was the hardest worker among us. But after a while he came to me and told me that he had to return to his own people. $intl_ally_name said his time with us had been like a wonderful dream, and he promised he would remember us always, but his people needed him and he had to go back home. He said that someday he would return and visit us again, but I doubt I shall ever see him again in life. All the same I treasure the memory of him and his kind, and I will long remember his steadfast loyalty and all that he did to aid us in our struggle."
                        [/message]
                    [/then]

                    [else]
                        [message]
                            speaker=Kaleh
                            image=portraits/grog.png
                            message= _ "By saving my life, $intl_ally_name fulfilled his life debt to me, but we convinced him to hang around for a while and revel in the celebrations that we held after our great victory. We celebrated for days and days, thanking Eloh and the merfolk's god, and delighting in the bounty and beauty of our new home. And afterwards we set to work building new dwellings for our people. $intl_ally_name stayed to help us with the construction, he was the hardest worker among us. But after a while he came to me and told me that he had to return to his own people. $intl_ally_name said his time with us had been like a wonderful dream, and he promised he would remember us always, but his people needed him and he had to go back home. He said that someday he would return and visit us again, but I doubt I shall ever see him again in life. All the same I treasure the memory of him and his kind, and I will long remember his steadfast loyalty and all that he did to aid us in our struggle. "
                        [/message]
                    [/else]
                [/if]
            [/then]
        [/if]

        # if ally died before the final battle
        [if]
            [variable]
                name=ally_dead
                boolean_equals=yes
            [/variable]

            [variable]
                name=ally_died_in_final_fight
                boolean_equals=no
            [/variable]

            [then]
                [if]
                    [variable]
                        name=ally_race
                        equals=Dwarf
                    [/variable]

                    [then]
                        [message]
                            speaker=Kaleh
                            image=portraits/rogrimir.png
                            message= _ "And I will always remember $intl_ally_name who died along our journey. A braver warrior I have never seen, and though he was taken from us too soon, I am glad for the short time that I knew him."
                        [/message]
                    [/then]

                    [else]
                        [message]
                            speaker=Kaleh
                            image=portraits/grog.png
                            message= _ "And I will always remember $intl_ally_name who died along our journey. A braver warrior I have never seen, and though he was taken from us too soon, I am glad for the short time that I knew him."
                        [/message]
                    [/else]
                [/if]
            [/then]
        [/if]

        [message]
            speaker=Kaleh
            image=portraits/garak.png
            message= _ "So much has happened since we left the desert, but looking back upon our journey I do not want to forget Garak and his sacrifice. I doubt that we would have made it out of the sands alive if it was not for his strength and guidance. I remember how he used to smile when charging into battle, and how he would pray over the bodies of his fallen friends afterwards. I think of him sometimes, buried in the sands with his fellow warriors. I think he would have been proud of us. He was both a great warrior and a great teacher. He will be remembered."
        [/message]

        [message]
            speaker=Kaleh
            message= _ "As for the Black Citadel, after much discussion we decided to go back to the ancient rituals for purifying unclean land, with fire. We filled the entire structure with wood and oil and set the place ablaze to make sure that any remnants of Yechnagoth's infestation would be purged by holy fire. We then tore the citadel down, stone by stone. I was tempted to save the stones for construction in the future, but I did not know what foul magics might still linger in them, and I did not want to take any chances. So with the help of the merfolk, we carried the stones far out into the water and cast them down to the bottom of the ocean. Once the last stone had been removed, we decided that no matter what we built or grew around it, that area would be left bare as a reminder of the evil that once dwelt here and all those who gave their lives to destroy it."
        [/message]

        [message]
            speaker=Kaleh
            message= _ "It has been several years since the events that I chronicle here, and I'm not quite as spry and limber as I used to be, so I decided it was about time that I write this all down lest something happen to me. My one wish is that our descendants do not forget all those who made the ultimate sacrifice so that there might be a future for our people. Looking at the ruins of the ancient empires, I know that time erases all things. We have forgotten so much about the Golden Age. Do not let our story suffer the same fate. For as long as the tales of those now departed are still told, in some sense they are still alive and still with us. Honor those who have died. Remember our mistakes so you will not repeat them. And most of all, treasure every day, for it is a gift, from us to you."
        [/message]

        # if both Nym and Zhul survived, then play special bonus conclusion
        [if]
            [variable]
                name=nym_dead
                numerical_equals=0
            [/variable]

            [variable]
                name=zhul_dead
                numerical_equals=0
            [/variable]

            [then]
                [unstore_unit]
                    variable=stored_nym
                    find_vacant=yes
                [/unstore_unit]

                [store_unit]
                    [filter]
                        id=Nym
                    [/filter]
                    variable=stored_unit
                [/store_unit]

                [hide_unit]
                    x,y=30,38
                [/hide_unit]

                [move_unit_fake]
                    type=$stored_unit.type
                    side=1
                    x=30,31,32,32,33,34,34,35,36
                    y=38,38,38,39,40,40,41,42,42
                [/move_unit_fake]

                {CLEAR_VARIABLE stored_unit}

                [teleport]
                    [filter]
                        id=Nym
                    [/filter]
                    x,y=36,42
                [/teleport]

                [unhide_unit]
                [/unhide_unit]

                [redraw]
                [/redraw]

                [delay]
                    time=300
                [/delay]

                [message]
                    speaker=Nym
                    message= _ "Hey Kaleh, how's the writing going?"
                [/message]

                [message]
                    speaker=Kaleh
                    message= _ "Actually I just finished."
                [/message]

                [message]
                    speaker=Nym
                    message= _ "You've been working on that thing for months. I'm impressed."
                [/message]

                [message]
                    speaker=Kaleh
                    message= _ "Yes, it feels good to finally be done."
                [/message]

                [message]
                    speaker=Nym
                    message= _ "Well, your timing was perfect. Zhul is dedicating the new grove to Eloh, and you know there'll be one heck of a celebration afterwards."
                [/message]

                [message]
                    speaker=Kaleh
                    message= _ "I suppose we wouldn't want to miss that. I wonder if they will still have any of that wine left from last year?"
                [/message]

                [message]
                    speaker=Nym
                    message= _ "We'll just have to find out. Come on!"
                [/message]

                [redraw]
                [/redraw]

                [store_unit]
                    [filter]
                        id=Nym
                    [/filter]
                    kill=yes
                    variable=stored_unit
                [/store_unit]

                [move_unit_fake]
                    type=$stored_unit.type
                    side=1
                    x=36,35,35,34,34,33,33,33,33
                    y=42,42,41,40,39,39,38,37,36
                [/move_unit_fake]

                {CLEAR_VARIABLE stored_unit}

                [store_unit]
                    [filter]
                        id=Kaleh
                    [/filter]
                    variable=stored_unit
                [/store_unit]

                [hide_unit]
                    x,y=37,44
                [/hide_unit]

                [move_unit_fake]
                    type=$stored_unit.type
                    side=1
                    x=37,36,35,35,34,34,33,33,33,33,33
                    y=44,43,43,42,41,40,40,39,38,37,36
                [/move_unit_fake]

                [delay]
                    time=1500
                [/delay]
            [/then]

            [else]
                [redraw]
                [/redraw]

                [delay]
                    time=2000
                [/delay]
            [/else]
        [/if]

        [endlevel]
            carryover_report=no
            save=no
            linger_mode=no
        [/endlevel]
    [/event]

    # Event 13: VICTORY!

    [event]
        name=victory

        {CLEAR_VARIABLE stored_nym}
    [/event]

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