#textdomain wesnoth-Invasion_from_the_Unknown

#define STORYTXT_INIT_WARNING
    [story]
        [part]
            music="data/core/sounds/ambient/wardrums.ogg"

            {CAMPAIGN_INTRO_HEADER}

#ifdef CAMPAIGN_INVASION_FROM_THE_UNKNOWN_EPISODE_II
            story={CAMPAIGN_INTRO_WARNING_TITLE}+{CAMPAIGN_INTRO_GAMEPLAY_WARNING}+{CAMPAIGN_INTRO_PADDING}+{CAMPAIGN_INTRO_CONTENT_WARNING}+{CAMPAIGN_INTRO_PADDING}+_"If you have not completed Episode I of Invasion from the Unknown, you definitely should not play this episode yet."+{CAMPAIGN_INTRO_PADDING}+{CAMPAIGN_INTRO_OPTIONS_WARNING}
#else
            story={CAMPAIGN_INTRO_WARNING_TITLE}+{CAMPAIGN_INTRO_GAMEPLAY_WARNING}+{CAMPAIGN_INTRO_PADDING}+{CAMPAIGN_INTRO_CONTENT_WARNING}+{CAMPAIGN_INTRO_PADDING}+{CAMPAIGN_INTRO_OPTIONS_WARNING}
#endif
        [/part]
    [/story]
#enddef

#define STORYTXT_INTRO
    {STORYTXT_INIT_WARNING}
    [story]
        [part]
            music=knolls.ogg
            story= _ "From the personal journal of Lord Galas of the Forest Elves."
        [/part]
        [part]
            story= _ "“Our ancestors settled this land ages ago, seeking shelter from the hostile outside world. They hailed from forests which have long withered away; the endless expanse of sand could not possibly offer our kind much more than vicious enemies and a slow, agonizing death. It is said that thousands of elves fell before the survivors finally came across this green valley. As if by the grace of the Lords of Light themselves, it emerged from the ruins of a once green and lush world in our moment of dire need.

Defending our valley from intruders has never been an easy task. A small portion of our troops are trained in the ways of navigating and fighting in the sands from a young age and assigned to patrol groups in charge of warding our frontiers. It is not a particularly rewarding mission, but it has allowed us to prosper as a united people."
        [/part]
        [part]
            story= _ "My father was on duty leading his group one night, against a band of nomadic humans. Barbarians unwilling to converse with speaking creatures not born of their kin’s blood, and only intent on conquering and taking what they believed theirs by right.

A sling bullet broke his skull as he defended an injured comrade."
        [/part]
        [part]
            story= _ "At the time I was shocked by his death — a graceless end to a valiant life. I cried for the last time at his funeral. On memory of him I swore to become the best, advancing beyond the ranks of my comrades until I was one of the best fighters and commanders amongst my people, despite my age.

Anlindë has taken care of me like her own son since then. She has been to me the mother I never had, often spending far too much time caring for me rather than her own duties with the wounded and infirm."
        [/part]
        [part]
            {STORYTXT_TITLE_CARD_SIMPLE S1 _"Border Patrol"}
            music=loyalists.ogg
            story= _ "Recently, the frequency and intensity of the hostile incursions has increased. We can detect no single hand behind them, but it is as if they were thrust into our domains by some force greater than their own petty greed and rage. They throw themselves onto our blades and arrows as if death were a better alternative than retreat. Our patrol groups are growing in size to resist, but the pace of recruiting is becoming harder to maintain. Most people do not crave the chance to risk their lives in combat against such determined foes.

Then one day, we discovered the source of the outsiders’ frenzy."
        [/part]
    [/story]
#enddef

#define STORYTXT_A_REAL_CONFRONTATION
    [story]
        [part]
            {STORYTXT_TITLE_CARD_SIMPLE S2 _"A Real Confrontation"}
            music=underground.ogg
            story= _ "It was quite a success, but the fighting technique of those humans was more professional, coordinated, and accurate than those of the regular nomadic skirmisher. That worried me initially, and I would have organized a scouting party into the desert if we had been in any condition to do so.

Our group was greatly weakened by the battle, so we withdrew back to the main keep in the valley. Another patrol group took our place and was scheduled to return in three days. That was not to happen. Instead, enemies came to us with our kin’s skulls mounted atop their banner-poles. Driving them forth would not be easy."
        [/part]
    [/story]
#enddef

#define STORYTXT_HORRORS_FROM_THE_DEPTHS
    [story]
        [part]
            music=underground.ogg
            story= _ "We were shocked when we tallied our numbers. Barely a thousand of us survived the battle in the valley. Most of the dead likely perished in the villages burnt by our foes, helpless and frightened. Alas, they met one of the most painful deaths one could ever imagine.

When I thought about what forced us from our ancient home, the one place we had lived in safety on this war-torn and barren world, I felt my stomach clench in terror. Anlindë was a wise sorceress, but I regretted not being strong enough to ignore her counsel. I could not help but think that had we stayed, we could have fought back and somehow emerged victorious."
        [/part]
        [part]
            {STORYTXT_TITLE_CARD_SIMPLE S3 _"Memories from the Depths"}
            story= _ "I but hoped that fleeing into the depths was a wise decision, and that Lédinor’s efforts were not wasted."
        [/part]
    [/story]
#enddef

#define STORYTXT_OVER_THE_SANDS
    [story]
        [part]
            music=knolls.ogg
            story= _ "Northwest. That was the direction we had to go, if Mal Keshar’s words were to be believed. We were to seek our saviors in the depths of the largest mountain range within our reach; a place formerly inhabited by the artisans of the earth, the dwarves of Knalga.

According to Anlindë, he was a tormented soul. A man who began his journey fighting for what he believed to be a noble cause before veering off the road into an eternal abyss that tainted and twisted and destroyed him. Now that man’s shadow walked alongside us under the surface of Irdya. I fear what future generations will think of us who allowed such a monster on our side... if we survive long enough to leave any descendants, that is.

In spite of his evident bitterness, the necromancer did not make a second attempt against us. I wondered if this was a ruse or he was just daunted by Anlindë’s close watch."
        [/part]
        [part]
            {STORYTXT_TITLE_CARD_SIMPLE S4 _"Over the Sands"}
            story= _ "My uneasiness throughout the journey underground was not solely due to the dark sorcerer’s presence, though.

Anlindë shunned my questions about the ‘catastrophe’ mentioned by her and Mal Keshar during their initial conversation. It was no surprise to me that the lich would refuse to answer my questions, but why would Anlindë shun my curiosity as well? Is the order of sorcerers she belongs to not dedicated to preserving and communicating our lore to any elf who would display an interest in it? And how could she, with her words alone, weaken such a peculiar adversary where other sorcerers would fail?"
        [/part]
    [/story]
#enddef

# Scenario 5 branch A
#define STORYTXT_CROSSFIRE
    [story]
        [part]
            music=wanderer.ogg
            # po: NOTE: The second paragraph in this block is reused for scenario 5b's
            # po:       story text below.
            story= _ "We left Lady Unarye in charge of the Eisenstone clan’s lands for a few weeks, allowing our civilians to advance over the sands relatively unhindered as we continued to clear the path ahead. We tried to make up for the clan’s losses as best as we could, trading knowledge, weapons, and valuables with the locals. Their distrust and hatred slowly gave way to a more peaceful cultural exchange — an advantageous outcome for both parties.

The long desert march drew the attention of many more desert dwellers in the region, most of them fearful of our numbers, weapons, allies... and our species. However, once curiosity overcame their initial fear, some of them approached us with no ill intentions. Mal Keshar saw it fitting to take advantage of this situation."
        [/part]
        [part]
            # po: NOTE: This whole block must match S5b's second story text block below.
            story= _ "The more magically adept travelers chose to apprentice under Mal Keshar to learn necromancy or hone their craft. Things quickly reached a point where the lich’s minions nearly outnumbered our own capable spell casters... and yet...

But Mal Keshar was not the only one hiding something from me. Anlindë refused to tell me about the previous trials faced by our kind at the hands of the demons; Mal Keshar would tell me to ask Anlindë whenever I attempted to inquire. I wondered if perhaps the Lady of Light and the Master of Darkness would be willing to give me answers?"
        [/part]
        [part]
            {STORYTXT_TITLE_CARD_SIMPLE S5a _"Crossfire"}
            story= _ "After some time we reached a river, which we then followed along the southern side. Small tributaries from the north gradually increased the river’s speed and depth. The fresh water and the sparse vegetation thriving along the riverbank seemed a sure sign that life, however little remained in this harsh world, still existed outside our homeland. I was increasingly eager to find the valley Mal Keshar mentioned in his instructions."
        [/part]
    [/story]
#enddef

# Scenario 5 branch B
#define STORYTXT_CURSED_PLATEAU
    [story]
        [part]
            music=underground.ogg
            # po: NOTE: This block is the second paragraph from scenario 5a's first story text block.
            story= _ "The long desert march drew the attention of many more desert dwellers in the region, most of them fearful of our numbers, weapons, allies... and our species. However, once curiosity overcame their initial fear, some of them approached us with no ill intentions. Mal Keshar saw it fitting to take advantage of this situation."
        [/part]
        [part]
            {STORYTXT_TITLE_CARD_SIMPLE S5b _"Cursed Plateau"}
            # NOTE: This whole block must match S5a's second story text block above.
            # NOTE: The previous comment is intentionally *not* a wmlxgettext comment.
            story= _ "The more magically adept travelers chose to apprentice under Mal Keshar to learn necromancy or hone their craft. Things quickly reached a point where the lich’s minions nearly outnumbered our own capable spell casters... and yet...

But Mal Keshar was not the only one hiding something from me. Anlindë refused to tell me about the previous trials faced by our kind at the hands of the demons; Mal Keshar would tell me to ask Anlindë whenever I attempted to inquire. I wondered if perhaps the Lady of Light and the Master of Darkness would be willing to give me answers?"
        [/part]
    [/story]
#enddef

# Convergence: scenario 6
#define STORYTXT_THE_MOON_VALLEY
    [story]
        [part]
            music=underground.ogg
            story= _ "We continued northwest following the river, the mountains growing taller and steeper. The green missing from the lowlands was all around us now; a new hope filled our hearts as we saw how well the forest plants flourished beneath the suns.

We had left the desert.

If the armies of the Empire had claimed this corner of the world, they would have no doubt defiled and destroyed this revivifying beauty for their unholy feast. But there was something amiss about the whole situation. They were adamant about stopping our march at all costs. They didn’t even give us an opportunity to take prisoners. Their devotion to the supreme leader of their realm and accursed names that were mostly unheard of amongst our kind seems to be the sole drive for their existence."
        [/part]
        [part]
            story= _ "‘Uria’, ‘Yechnagoth’... Other than Uria being a forgotten, fictitious symbol of corruption and decay invented in a primeval epoch of superstition and self-discovery, Anlindë knew nothing about the names.

It suddenly occurred to me that our enemies could be seeking the same power we did. Subverting or destroying the figures who wrought the last downfall of the demons on Irdya would be a logical strategy, wouldn’t it? Especially now that their bodies lie defenseless and frozen in time.

Could that be the necromancer’s true intention as well? But..."
        [/part]
        [part]
            story= _ "At times, Mal Keshar would stare at the river in silent contemplation. I wondered for how long he had walked Irdya in undeath. What tales could he tell? What scenes from ages past did he see where I saw but rushing water? How would it be to walk the world for so long, to watch civilizations fall and rise, to see everything you once knew destroyed, washed away like dust after rain? Was there anything in the old world he truly missed?"
        [/part]
        [part]
            {STORYTXT_TITLE_CARD_SIMPLE S6 _"The Moon Valley"}
            story= _ "We finally found the entrance to the fabled green valley. While at first the pass seemed to be completely uninhabited, the keen eyes of our scouts could discern some forlorn watch towers of crude construction."
        [/part]
    [/story]
#enddef

#define STORYTXT_THE_GOLIATH
    [story]
        [part]
            music=underground.ogg
            story= _ "And thus we entered the caves, leaving the bulk of our forces behind so we could explore the place without risking catastrophic losses. None of us knew for certain what kind of dangers lurked beneath the land said to be the heart of Irdya.

Only Anlindë, the lich, and I planned on proceeding underground, but some of our people would not hear of us going in alone and instead accompanied us down into the darkness."
        [/part]
        [part]
            {STORYTXT_TITLE_CARD_SIMPLE S7 _"Goliath"}
            story= _ "According to our historians, multiple kingdoms of dwarves occupied the Heart Mountains during the Golden Age, prosperous and powerful. Mal Keshar says that all that came to an end when the humans of Wesnoth single-handedly brought about the Fall.

We had not ventured too deep underground when we began to find signs of a recent civilization. Albeit in ruins, the entire place was adorned with fine dwarvish architecture and handcraft. Could the dwarves have attempted to reclaim their domains after so long? What kind of disaster might have struck their efforts?

Mal Keshar and Anlindë seemed uneasy about the whole situation."
        [/part]
    [/story]
#enddef

#define STORYTXT_ERRAND_OF_HOPE
    [story]
        [part]
            music=underground.ogg
            story= _ "After exploring for a while, we emerged at nightfall to tell our people to follow us in. It was a difficult decision, but we feared leaving our poorly-trained civilians between the pursuing scouts and the cliffs.

The very thought of approaching the place where the Lady of Light and the Master of Darkness had been seen for the last time was good for morale. It was well that the ancient tale lit a flame in our hearts, for there was little other light to be had in those forsaken tunnels."
        [/part]
        [part]
            {STORYTXT_TITLE_CARD S8 _"An Errand of Hope" _"Royal Meeting"}
            story= _ "As we went deeper and deeper, the contrived openings in the ceiling that permitted us a scarce beam of sunlight diminished until they vanished entirely. By contrast, the subterranean water streams became more abundant, both in quantity and volume. Oh, the irony! In the caves we had all the water we had so sorely lacked in the desert, but we had to struggle to see our steps.

Under the world’s skies we could see the moon tracing out its cycle by night — by day, the suns would announce the time. Here we had no notion of how much time was passing as we traveled underground. It was as if time itself had been frozen and bound to the rocks."
        [/part]
    [/story]
#enddef

#define STORYTXT_ROYAL_MEETING
    [story]
        [part]
            music=the_deep_path.ogg
            story= _ "This dwarf, Althurin by name, led us through curving tunnels that opened upon a great cavern. There lay a sprawling city, the capital of their kingdom.

This greedy race was one tremendously despised by many of our ancestors due in part to their disinterest in protecting the beautiful and green places of their world. Indeed, it was said amongst us that the dwarves would destroy Irdya’s beauty for wealth and power. And yet, their masons shaped structures of great beauty from rock, their smiths fashioned marvelous wonders out of metal and other materials they found underground — these were things that we elves could not help but admire."
        [/part]
        [part]
            story= _ "Their mastery of ancient magic was also remarkable. By carving runes onto surfaces such as shields, hammers, or even walls, and imbuing them with a force not understood by even the mightiest elven sorcerers, they could work powerful and complex spells. Some of these rune-workings were used in defensive structures against enemies, and had to be temporarily suppressed in order to allow Anlindë and the lich access into the heart of the city — the castle of the King."
        [/part]
    [/story]
#enddef

#define STORYTXT_THE_LIBRARY
    [story]
        [part]
            music=underground.ogg
            story= _ "Certainly, as Althurin said, we would encounter all sorts of exotic creatures that could only thrive in the eternal shadows of Irdya. Most were understandably frightened by our presence. From their perspective, we were invaders, terrifying monsters who could end their pitiful lives in an instant with our fire and magic. But unlike the invaders we had faced in our Valley, we did not intend to harm or kill every living thing standing in our way."
        [/part]
        [part]
            {STORYTXT_TITLE_CARD_SIMPLE S9 _"The Library"}
            story= _ "Deeper and deeper we went, through the labyrinthine dark caverns, until we reached the igneous passages that the late mentor of our dwarf guide first found for us."
        [/part]
    [/story]
#enddef

#define STORYTXT_THE_SOURCE_OF_LIGHT
    [story]
        [part]
            music=underground.ogg
            {STORYTXT_TITLE_CARD_SIMPLE S10 _"The Source of Light"}
        [/part]
    [/story]
#enddef

#define STORYTXT_ELYNIA
    # FIXME: stub!
#enddef

#define STORYTXT_THE_FALL
    # FIXME: stub!
#enddef

#define STORYTXT_STRIKE_ON_HERTHGAR
    [story]
        [part]
            music=nunc_dimittis.ogg
            story= _ "The Lady of Light seemed and acted less like a majestic elven sorceress of untold might and more like a young nymph of the forests, her luminous aspect notwithstanding. Anlindë said that she had always been more closely bound to our faerie nature than other elves, and hence for most of her life she frequented the wilderness, away from civilization. This became more evident as her harsh exterior slowly gave way to her true self, as we all shared stories and experiences on the long way back to Herthgar’s capital.

I do not know if it is because I had always been the reserved sort and never met many women outside the circles of my duty, or because our race changed over generations in some way that was not evident to the eye; whichever the case is, I found the Lady of Light alluring, like a dream of an age long gone. I wondered if every elf was as radiant as her back in the Golden Age."
        [/part]
        [part]
            story= _ "But her mystifying appearance was merely a distraction for the unwary, for those who had not yet heard her name or accounts of her legendary feats. Soon, we would bear witness to her combat prowess, and learn how fierce and frightening she could be as the situation demanded.

Because, once we neared Herthgar’s capital, we saw not the bustling dwarven settlements that welcomed us after saving Althurin and his men from doom; instead, what we saw were Anlindë’s fears, realized in our absence."
        [/part]
        [part]
            music=battle.ogg
            {STORYTXT_TITLE_CARD_SIMPLE S11 _"Strike on Herthgar"}
            story= _ "We made haste towards the keep, in fear that we had arrived too late..."
        [/part]
    [/story]
#enddef

#define STORYTXT_THE_ESCAPE
    [story]
        [part]
            music=wanderer.ogg
            story= _ "After that exchange, I stayed behind in the dwarven throne room, and talked to Anlindë a last time before bidding her farewell.

She had always been there to guide me since my father’s death. Even now, at the premature end of our journey together, she imparted her wisdom to me. She spoke of our past leaders and the sacrifices they had to make for the sake of others; the great losses suffered by Telchior’s people before finding the Valley; the pact with Zhangor; the story of Kalenz and Landar; the betrayal of the humans and the war with the orcs..."
        [/part]
        [part]
            story= _ "But I could barely retain any of that, for my heart was too fraught with grief to pay heed to her words.

Once we had nothing more left to say, I left the room only to find a pair of dispassionate amber orbs waiting behind the doors. I did my best to ignore Lady Elynia and continued ahead, hoping her eyes did not spy the tears in my own."
        [/part]
        [part]
            story= _ "Even though Anlindë had kept such dark secrets from me all these years, I could not resent her. First Mal Keshar, and then Anlindë... Perhaps I am too easily forgiving to be the kind of leader Lédinor and Anlindë expected.

Will this never end? How many more will have to give up their lives to protect the rest of us from the Chaos Empire and the demons of Uria?"
        [/part]
        [part]
            {STORYTXT_TITLE_CARD_SIMPLE S12 _"The Escape"}
            story= _ "I longed for the return of peace. I desperately wanted to get away from the incessant strife and bloodshed and find a new home in one of the remaining forests, or even the underground.

I was absorbed in those foolish thoughts when, suddenly, reason came back to me; and then I knew what ought to be my next mission.

Because even in the deep darkness of Irdya’s fractured heart, we still had the guidance of the Lady of Light and our hope on our side; and I knew there had to be a way to throw the Empire into utter disarray so it would wither and die like its predecessor did."
        [/part]
    [/story]
#enddef

#define STORYTXT_FACE_YOUR_FATE
    [story]
        [part]
            music=into_the_shadows.ogg
            {STORYTXT_TITLE_CARD_SIMPLE S13 _"Face your Fate"}
        [/part]
    [/story]
#enddef

#define STORYTXT_BYE_AND_BEHOLD
    # Display initial warning if playing episode II only
#ifdef CAMPAIGN_INVASION_FROM_THE_UNKNOWN_EPISODE_II
    {STORYTXT_INIT_WARNING}
#endif
    [story]
        [part]
            music=silvan_sanctuary.ogg
            story= _ "What lay in front of us was unlike anything I ever had imagined: it was not simply a small valley guarding its green life from the scorching suns, but rather an endless expanse of vegetated lands. It was like being home again... No — the scenery was more akin to a dreamland conjured from the memories of a long gone age.

The Lady of Light had not seen such a landscape for hundreds, thousands, perhaps millions, of years, and she rejoiced at the view while the fresh northern winds blew in her face. The dwarves, on the other hand, were too used to their underground abodes to feel at ease on the surface. I understood them, and regretted that we could not have their company for our next journey. The prospect of marching into the northern humans’ territory uninvited was not very encouraging."
        [/part]
        [part]
            {STORYTXT_TITLE_CARD S14 _"Bye and Behold" _"The Grand Council"}
            story= _ "I knew that from that point onwards, I would have to make decisions for our people on my own, as Anlindë was no longer there to provide me with her — seldom unwise — counsel and guidance. And I knew there was a possibility that I might come to regret some of those decisions. But someone had to take the reins of our fractured civilization and move us forward. And that someone, at least for the moment, had to be me."
        [/part]
    [/story]
#enddef

#define STORYTXT_THE_ARAGWAITHI
    [story]
        [part]
            music=underground.ogg
            story= _ "Many of us grew up listening to horror stories about savage humans who murdered every living creature in sight to procure food. Nobody ever suspected that far beyond our domains some of them had gathered to build such an impressive civilization ruled not by force, but rather by wisdom.

The Aragwaith country was governed not by a single person, but rather by a council representing communities from every corner of the Far North. Instead of scavengers, there were farmers and ranchers, smiths and carpenters, builders and architects, and so on. Their military arm was a well-organized and highly-trained body, practical experience nonwhistanding; it had not seen serious conflict in over a century. Theirs was a peaceful and prosperous civilization, a hard-won luxury, one seeded by the bones of tyrants past and watered with the bloodshed of countless wars."
        [/part]
        [part]
            story= _ "Such was the extent of the country’s success after the civil war that even orc merchants from the western regions and coasts of the Great Continent were allowed within its borders. Mal Keshar did not take kindly to the sight, but Elynia reminded me that there was a time when the human kingdoms comprising the old Empire had fruitful relations with the orcish clans of the Far North.

Bearing witness to the wonders of civilization rekindled my faith in Irdya’s ability to heal its profound wounds after the Fall. There was simply no way we could allow the dark forces of Uria to take all this from us. I knew what had to be done — the matter was deciding upon an approach that would not result in our self-destruction.

So I gathered as much information as possible from Erathan and his men, rehearsed my plan, and prepared for the inevitable meeting with the Grand Council. And, as much as it pained me, I decided to keep it secret from Elynia and Mal Keshar, at least for the time being."
        [/part]
        [part]
            background=story/raelthyn.png
            story= _ "Eventually we arrived at the outskirts of Raelthyn, the northern capital. Even from a distance, the city was far larger than any other northern settlements we had seen thus far. Dominating the landscape was a tall, ominous castle."
        [/part]
    [/story]
#enddef

#define STORYTXT_SHADOWS_OF_TIME
    [story]
        [part]
            music=underground.ogg
            background=story/raelthyn-at-night.png
            story= _ "We rested for that night in the safety and hospitality of Raelthyn — or at least, most of us did. Having spent so many months on the field sleeping in crude sacks at night, I felt uncomfortable on the luxurious metal beds that civilization had to offer. Every once in a while I would get up and see Elynia standing or sitting on a nearby balcony, gazing at the moon. I felt compelled to go talk to her, but I knew there was nothing I could say to remedy the situation. The best I could do was to try and open up to her later once her resentment subsided.

When dawn broke, we immediately prepared for our journey into orcish territory. I had to confront Elynia’s eyes again. Truth to be told, when we first met I never thought those gentle amber orbs could hold such contempt towards a living creature."
        [/part]
        [part]
            story= _ "To keep us in check, the Grand Council assigned us Erathan and a few other men — all highly skilled with the bow and arrow — under the pretense of protecting us from any potential attempts against our lives.

Even though Mal Keshar would disagree with me, it did not seem like the orcs ever considered causing any harm to us. At most they seemed displeased by the Council’s choice of diplomats, as well as the fact that they hardly knew anything about our race and origins. But our insistence paid off in the end. We were finally granted an audience with Quogar Ratham, the local orcish chieftain."
        [/part]
        [part]
            {STORYTXT_TITLE_CARD S15 _"Shadows of Time" _"Parting Ways"}
            story= _ "Of all the things that I had been through during this twisting journey across the continent, playing ambassador to an orcish chieftain was amongst the most bizarre of them. We had gone from killing orcs on the sands without a single thought to having relatively amicable conversations with their kin in the west.

Little did I suspect then how things would soon take a darker turn."
        [/part]
    [/story]
#enddef

#define STORYTXT_PARTING_WAYS
    [story]
        [part]
            music=underground.ogg
            background=story/raelthyn.png
            story= _ "We spent the next few weeks resting in the peaceful Aragwaith capital, gathering intelligence on our target and making preparations for our final mission. Since we feared that they might refuse to sign the alliance pact otherwise, we kept our plans a secret from the Council.

As time passed on, the border skirmishes grew in number and intensity, and the Far North denizens began to take the threat more seriously. The timing could not be more convenient, as the news of the Chaos Empire’s hostile advances helped quell the humans’ instinctive distrust of our kind. To think that there once was an era when elves were the custodians of the Great Continent rather than humans..."
        [/part]
        [part]
            background=story/raelthyn.png
            story= _ "Finally, the decisive day came and the entire Council gathered once more to decide our destiny."
        [/part]
    [/story]
#enddef

#define STORYTXT_DAWN_OF_THE_GREAT_WAR
    [story]
        [part]
            music=underground.ogg
            story= _ "Throughout Irdya’s relatively short recorded history, elves seldom participated in wars. On the few occasions they did, the results were grim and devastating for everyone involved: the orc invasion following the humans’ arrival, a civil war amongst our forefathers, a war against an empire led by a great Necromancer, and the final doom of Wesmere under Zhangor’s rule.

We had agreed that our sacrifice was necessary to keep the elves’ involvement in this new war to a minimum. Lord Inodien and Lady Unarye would see that our people would not be senselessly dispatched to the battlefield to die. Meanwhile, Elynia, Mal Keshar and I would hopefully earn our people a swift victory by bringing down the orchestrator of our suffering, the brain behind the machine that is the Chaos Empire."
        [/part]
        [part]
            story= _ "I wondered if we would ever return to the northern country as victors; whether we would become stranded in enemy territory and die before accomplishing our mission, or be killed by the demons after vanquishing their leader.

Even though the Aragwaithi had gathered enough information on our target to guide us on our mission, there were still many questions left to answer. Most importantly, are we to believe that Uria actually exists and is behind everything? Could Yechnagoth have survived the battle against our desert kin somehow? Did Anlindë manage to vanquish the Warlord, or was her sacrifice in vain? Could she be alive in a dungeon somewhere, tortured by our enemies, or would she have taken her own life before?"
        [/part]
        [part]
            {STORYTXT_TITLE_CARD_SIMPLE S16 _"Dawn of War"}
            story= _ "But there was one thing we did know for sure: this was the beginning of the end, the dawn of our war against the Empire of Chaos. Us three were at the center of the storm, and we would make sure the Empire and Uria herself would feel the wrath of the peoples of Irdya."
        [/part]
    [/story]
#enddef

#define STORYTXT_VOICE_OF_THE_ARMAGEDDON
    [story]
        [part]
            music=underground.ogg
            story= _ "And thus the long march began.

We were warned that these mountains were treacherous and rife with hostile creatures, but the sight of more of those metallic birds flying about still proved a surprise. They seemed to roam freely across the land without a particular purpose, as if they had become part of the local fauna. Perhaps they were once part of the many experiments the Chaos Empire performed on living creatures... even persons."
        [/part]
        [part]
            story= _ "Although we had spent much time together since we found her in the Heart Mountains, it was only now that I noticed an odd habit Elynia had: she much preferred to walk like us commoners than to float above ground as other elves or faeries possessing the capability did.

Out of curiosity and lacking anything better to speak of, I decided to ask her about this peculiar habit. She revealed she has done this for as long as she remembers, perhaps because her mentor and guardian did as well. It was then that it occurred to me that I knew nothing of Elynia’s past life in the Golden Age beyond her history lessons. I wondered if her childhood had been like mine, with her guardian taking over for her missing parents."
        [/part]
        [part]
            story= _ "She gazed at me, her eyes as alluring as the setting sun. Then she smiled, and I saw for a brief moment a glimpse of something else hiding beneath the surface.

I decided to not ask her about her mentor, for fear of bringing back sad memories. Like Mal Keshar, she has lived for longer than any other creature on Irdya, and seems intent on leaving her past behind."
        [/part]
        [part]
            {STORYTXT_TITLE_CARD_SIMPLE S17 _"Voice of the Armageddon"}
            story= _ "Two days into our journey, we came across a road quite evidently built by our enemies amidst the tall mountains not long ago. A new confrontation was imminent."
        [/part]
    [/story]
#enddef

#define STORYTXT_WESMERE
    [story]
        [part]
            music=underground.ogg
            background=
            story= _ "Following our second encounter with the vile necromancer, we felt less inclined to stop to rest and sleep during the night. Most of the demons we had encountered thus far seemed more adept at fighting in the darkness than under daylight. Moreover, we did not know for certain if Hekuba could be watching us from afar, planning his next strike; it would not do us any good to suffer more casualties before reaching our objective.

After only a couple of days, we succumbed to the fatigue and set up camp during the long dark."
        [/part]
        [part]
            story= _ "Sleeping was not an easy task. Even though we were tired and perfectly able to drift off in a matter of seconds, we had to take turns watching over the encampment while others slept. Mal Keshar, of course, made sure to keep us awake during each shift telling us stories of his past feats; rather unfortunately for us, most of them involved the deaths of innocent — and sometimes not-so-innocent — people described in vivid detail.

We continued to use the same strategy every night afterwards, with Elynia taking over for Mal Keshar at times to keep our living companions entertained with less grisly anecdotes. She boasted that she did not need to sleep as often or for as long as most of us normal people, but as I came to witness, that was simply not true."
        [/part]
        [part]
            story= _ "It was at the end of one of my shifts. I went to Elynia’s tent to wake her up for hers, but this time I did not find her up and ready to take her place; she had clearly made the attempt and somehow tumbled back into bed instead.

I opted to let her sleep and went back to keeping guard with Mal Keshar by my side, doing my best effort to ignore his teasing until dawn broke. And then, I had to endure Elynia scolding me for breaking protocol."
        [/part]
        [part]
            {STORYTXT_TITLE_CARD_SIMPLE S18 _"Ashes of Wesmere"}
            story= _ "Six more days passed before we reached the end of the mountains, and we came upon the desolate landscape that once saw three godlike beings do battle for Irdya’s fate."
        [/part]
    [/story]
#enddef

#define STORYTXT_UNDER_THE_SANDS
    [story]
        [part]
            music=underground.ogg
            story= _ "I have never been the kind of elf who would sit in a tree’s shade and reflect on the trials and tribulations of life or record profound thoughts onto paper. However, Anlindë thought that others could benefit from reading a personal chronicle of our journey across the continent, especially if something were to happen to me on the field.

In hindsight, I may have been far too reckless and brash in battle, putting my life in danger too often without any consideration for my friends and subjects. For that I wish to apologize to whomever may read this, in case I never have the chance to do so in the flesh."
        [/part]
        [part]
            {STORYTXT_TITLE_CARD S19 _"Under the Sands" _"Crossroads"}
            story= _ "I do not know for certain whether I would have changed our fate had I the power. There was a lesson to be learned from our next encounter with the enemy, and perhaps, in time, it would prove crucial for our survival.

Because soon after entering the caverns we would begin to realize the full breadth of the menace that threatened to end all life on Irdya, and I would personally bear witness to the terrifying power of Chaos."
        [/part]
    [/story]
#enddef

#define STORYTXT_CROSSROADS
    [story]
        [part]
            music=underground.ogg
            story= _ "The devastated landscapes of the lands of Chaos were easily the best weapon at the Empire’s disposal. Not only did they offer very little in the way of shelter, water and food, but they were also plagued with all manner of hostile creatures residing in artificial hives under the ground; the desert surrounding our long lost home was a sandy paradise compared to this nightmarish unknown. Bearing this in mind, perhaps the existence of a whole culture dedicated to the conquest and destruction of other peoples under the orders of a bellicose goddess was not as implausible as it first seemed.

Exactly how they managed to sustain themselves on a day-to-day basis was an entirely different mystery, though."
        [/part]
        [part]
            story= _ "I tried my best to keep my mind clear at night, but the memories of my brief encounter with the Emperor continued to haunt me during my sleep. That vision of twisted metal and flesh, those ominous glowing eyes... his metallic voice booming and echoing in the darkness of a cavern, overlapping the constant noise of machines and creatures I had never heard before. Next to him stood somebody else, the silhouette of a woman holding a book of some sort.

“She sees you as little more than a burden she constantly has to watch and protect while she and the necromancer do all the actual fighting.”

“She knew that Anlindë’s sacrifice would hardly serve any purpose at all. She let her go, and you did nothing to prevent that tragedy.”"
        [/part]
        [part]
            story= _ "“I am not any more responsible for your mentor’s death than the Lady of Light whom you swore to protect, yet you came to my lands seeking vengeance.”

“Do you not see that she is within your reach right now?”

“You know what you must do.”"
        [/part]
        [part]
            # po: The quoted line is also used in scenario 19.
            story= _ "Then a voice, an alluring voice belonging, perhaps, to the woman. She spoke in a language I could not understand. I focused on averting my mind from the scene just as I felt my arms begin to move on their own.

“On the surface or underground, it makes no difference to me, Galas. You will not last long if you stay in my domain, unless you abandon this foolish quest of yours and pledge allegiance to Uria and me!”

Then, a sudden flash of red, followed by complete darkness."
        [/part]
        [part]
            story= _ "Since that incident, the Emperor stopped trying to reach me and take control of my body for some reason. Perhaps even with his rumored power, it was not a tactic that he could use too often. Besides, with us approaching the heart of his domain there was little reason to keep wasting energy when he could patiently sit and wait for his prey to come.

I was absorbed in those thoughts one morning, when we were distracted by an unexpected encounter. Up to that point, we had never suspected we were not the only band of travelers on a mission in these lands."
        [/part]
    [/story]
#enddef

#define STORYTXT_THE_HEART
    [story]
        [part]
            music=underground.ogg
            story= _ "Thus the battle preparations began.

Many times throughout this endless journey, I had hesitated to continue for fear of putting our people’s survival at risk. But now that they were in the safety of the Far North and under the command of more capable leaders than I, my only fear was being manipulated by our enemies and becoming the instrument of my friends’ demise. Elynia reassured me that she would not let that happen as long as she could draw breath."
        [/part]
        [part]
            story= _ "“What if you could not prevent it, though?”, I asked. “What if the unholy power the Emperor wields surpasses even your own and it becomes impossible to stop me?”

She could not offer a concrete answer to the question, but I thought I could read the solution in her eyes; and, as Lord Galas of the elves, I would have certainly agreed that it was a reasonable course of action. Now I was no longer sure. I remembered the dwarves’ stories of our desert kin, and wondered if my own story would soon reach as bitter an end as had many of Kalehssar’s allies."
        [/part]
        [part]
            {STORYTXT_TITLE_CARD_SIMPLE S20 _"The Heart"}
            story= _ "Then I decided I would not go down without a fight. This so-called Emperor would feel my wrath. He would pay dearly for what he did to Anlindë, to my lord Lédinor, and to the thousands of elves he tortured and killed in the Valley. This would be the end of his reign of blood and destruction."
        [/part]
    [/story]
#enddef

#define STORYTXT_INNUENDO
    [story]
        [part]
            music=underground.ogg
            {STORYTXT_TITLE_CARD_SIMPLE S21 _"Innuendo"}
        [/part]
    [/story]
#enddef

#define STORYTXT_GAUNTLET
    [story]
        [part]
            music=underground.ogg
            {STORYTXT_TITLE_CARD_SIMPLE S22A _"Face of the Enemy"}
        [/part]
    [/story]
#enddef

#define STORYTXT_DARK_HIVE
    [story]
        [part]
            music=underground.ogg
            {STORYTXT_TITLE_CARD_SIMPLE S22B _"The Dark Hive"}
        [/part]
    [/story]
#enddef

#define STORYTXT_INTO_THE_LAIR
    [story]
        [part]
            music=revelation.ogg
            story= _ "“There are things more important in this world than the lives of the few, and things worse than the death of the many.”

No matter how hard I tried to make sense of Elynia’s words, I could not see how they justified letting the demoness go. To take pity on her because of her condition seemed reckless and unnecessary. So what if she was only following orders? She certainly did not seem lacking of her own will."
        [/part]
        [part]
            {STORYTXT_TITLE_CARD_SIMPLE S23A _"Into the Lair"}
            story= _ "There certainly has been something amiss about Elynia, and even Mal Keshar, ever since we set foot in enemy territory; walking into the Heart fortress only appeared to make things worse. Then again, I did not exactly feel like myself either. I began to fear that the very atmosphere of this place was seeping into our heads and clouding our thoughts and that things would spiral out of control before we could achieve our objective."
        [/part]
    [/story]
#enddef

#define STORYTXT_DO_US_PART
    [story]
        [part]
            music=silence.ogg
            story= _ "An uneasy silence arose. The Chaos Emperor lay amongst the carnage, his mechanical body broken and singed, seeping rivulets of blood that streaked across the patterned floor. And Elynia... it was as if Argan’s death had shattered something inside her. She wailed, dragging her hands across the crimson floor as if she could gather her lover’s lifeblood in her hands.

I realized, then, that my presence was pointless; there was nothing I could do to ease her pain. She had held herself together this long by sheer force of will; now, that will was spent. I tightened my grip on my sword as she buried her face in her hands and wept, heedless of the smears of red they left behind. In all this time, I had thought I knew loss — Anlindë, who was like a mother to me, scores of my friends and kinsmen — but in truth, I did not. I did not know the weight of centuries she bore upon her shoulders, nor the heartbreak of dashed hopes and broken promises that now lay prone at her feet.

In truth, I could never aspire to become as strong of soul as she. She had foreseen this conclusion long before any of us, yet continued onwards. Would I have had the courage to do the same, were I faced with the same choice — strike down someone whom I loved, or die and let the world suffer for my selfishness?"
        [/part]
        [part]
            story= _ "I felt a sudden urge to embrace and comfort her, but I did not; I could not intrude upon her grief with my own foolish feelings.

Instead, I turned to Mal Keshar, and tried to see through his perpetually expressionless face. I had never given much thought to his story or his life. It may have been a silly thought, but for a brief moment I wondered if he had ever felt this loss himself. The way he uttered those words to Elynia seemed to suggest that he had at least researched the subject of resurrection in the past. For power, or to bring back a loved one? I doubt I will ever gather the courage to ask."
        [/part]
    [/story]
#enddef

#define STORYTXT_EPILOGUE
    [story]
        [part]
            {STORYTXT_TITLE_CARD_SIMPLE S24 _"Epilogue"}
            sound=data/core/music/victory2.ogg
            music=silence.ogg
        [/part]
        [part]
            music=wanderer.ogg
            story= _ "In the end, the entire valley where once stood the mighty capital of the Chaos Empire disappeared in a matter of minutes. Even the biomechanical monsters — which we once regarded as invincible foes — perished amidst the destruction that erased Argan’s fortress from existence. Enemies, allies... for the earth there were no colors or sides, only insignificant creatures caught in its clutches as it dragged everything down to the depths of hell.

Once nothing but an unfathomably large crater was left, the darkness of the night gave way to the dawn of a new day, and Naia shone through the dispersing smoke and clouds to announce the day when the ruler of Inferno tasted her first defeat."
        [/part]
        [if]
            {VARIABLE_BOOLEAN_EQUALS finale_stats.abandoned_ledinor yes}
            [then]
                [part]
                    story= _ "We abandoned the creature that once was Lord Lédinor to his death, much to my regret; even though Elynia assured me that there was no way to restore him to his old self, much like Argan, I hoped that perhaps we could have managed to restrain him while we figured out a cure with her help. Alas, it would have proved impossible to keep him from delaying our escape. I can only hope his death was swift enough, assuming there was anything of him left within that horrifying mutated mass of flesh.

Uria did this to him to show us, to remind us how powerless we mere mortals are against beings like her, especially now without the Union of Light and Darkness. Maybe if I had not witnessed Elynia’s resoluteness first, I would have bent and despaired like the goddess so wanted, but no; I would not give her that pleasure now, after so much."
                [/part]
            [/then]
            [else]
                [part]
                    story= _ "Even though Elynia assured me that there was no way to restore Lédinor to his old self, much like Argan, I hoped that perhaps we could have managed to restrain him while we figured out a cure with her help. Alas, it would have proved impossible to keep him from delaying our escape. At least we put an end to his suffering soon enough, assuming there was anything of him left within that horrifying mutated mass of flesh.

Uria did this to him to show us, to remind us how powerless we mere mortals are against beings like her, especially now without the Union of Light and Darkness. Maybe if I had not witnessed Elynia’s resoluteness first, I would have bent and despaired like the goddess so wanted, but no; I would not give her that pleasure now, after so much."
                [/part]
            [/else]
        [/if]
        [if]
            {VARIABLE_BOOLEAN_EQUALS finale_stats.igor_died no}
            [then]
                [part]
                    story= _ "Only us three made it out of the fortress alive, along with Igor. We tried to locate the dwarves, but enemy troops arrived to inspect the ruins of the Heart before we could finish our search. The evidence we found suggested that our allies had to retreat for some reason, possibly while we were busy battling Elyssa in the Dark Hive.

We ran. We ran as far as we could, and then continued traveling west, towards the ocean. The next few weeks went by in a hazy flash of sand and mountains, while we struggled to pass unnoticed through hostile territory. Fortunately, they were probably too busy mourning their Emperor’s death — if they even have such a custom — to bother with hunting us down."
                [/part]
            [/then]
            [else]
                [part]
                    story= _ "Only us three made it out of the fortress alive. We tried to locate the dwarves, but enemy troops arrived to inspect the ruins of the Heart before we could finish our search. The evidence we found suggested that our allies had to retreat for some reason, possibly while we were busy battling Elyssa in the Dark Hive.

We ran. We ran as far as we could, and then continued traveling west, towards the ocean. The next few weeks went by in a hazy flash of sand and mountains, while we struggled to pass unnoticed through hostile territory. Fortunately, they were probably too busy mourning their Emperor’s death — if they even have such a custom — to bother with hunting us down."
                [/part]
            [/else]
        [/if]
        [part]
            story= _ "The storm that drove us out of hiding is over now, but our journey has only just begun. Darker days are coming, and it will take our best effort to put an end to this war now that Uria has taken notice of our existence. Even now I worry for the safety of my kin up in the Far North.

But as long as we stick together, I feel that we may yet have a chance against the evil force that threatens to take Irdya from us.”"
        [/part]
    [/story]
#enddef

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-Invasion_from_the_Unknown

#define SOUND_LIST:UNION_HIT
union-[1~4].ogg #enddef
#define SOUND_LIST:UNION_MISS
union-[1~4].ogg #enddef

#define ABILITY_UNION
    [dummy]
        id=union
        name= _ "union"
        description= _ "This unit wields the ancient power of the Union of Light and Darkness."
    [/dummy]
#enddef

#define ABILITY_UNION_ID
    [dummy]
        id=union
    [/dummy]
#enddef

#
# General FIXME:
#
# Currently, it is possible for Elynia/Mal Keshar to use a non-Union attack
# first and let the other cast Union on an enemy before ending the current
# turn. This is because we can't currently filter on the assistant's
# attacks_left attribute, without using lua_function or [filter_wml] at least.
# Personally, I feel there's no need to fix this loophole, but I somehow
# suspect at least a dozen playtesters will report it as a bug anyway.
#
# Also, enemy Union casters (spoilers!) don't disable the player's ability to
# cast Union next turn. This is partly because the implementation would be too
# complicated (especially but not exclusively on 1.12.x without the 1.13.x
# [object] duration="turn end" attribute, but also because I'm not really sure
# it would make the gameplay more interesting as opposed to outright
# frustrating.
#

#define WEAPON_SPECIAL_UNION
    [dummy]
        id=union
        name= _ "union"
        description= _ "This attack is only available on offense, and requires an assistant unit with the same weapon special to be adjacent to both the target and the attacker. If this attack is used during a turn, the assistant will not be able to perform any additional actions for the current playing side’s turn."
    [/dummy]

    [disable]
        # Not available on defense.
        id=union_disable_on_defense
        active_on=defense
    [/disable]

    [disable]
        id=union_require_adjacent_casters
        active_on=offense
        [filter_self]
            [not]
                [filter_adjacent]
                    ability=union
                [/filter_adjacent]
            [/not]
        [/filter_self]
    [/disable]
#enddef

#define UNION_EFFECTS
    [effect]
        apply_to=new_ability
        [abilities]
            {ABILITY_UNION}
        [/abilities]
    [/effect]
    [effect]
        apply_to=hitpoints
        increase_total=20%
        heal_full=yes
    [/effect]
    [effect]
        # NOTE: this must be the last [effect] for UNION_ATTACK_STATS to work
        #       as intended!
        apply_to=new_attack
        name=union
        description=_"union"
        type=arcane
        [specials]
            {WEAPON_SPECIAL_MAGICAL}
            {WEAPON_SPECIAL_UNION}
        [/specials]
        damage=29
        number=3
        range=ranged
        icon=attacks/union.png
    [/effect]
#enddef

#define UNION_ATTACK_STATS _DMG _NUM
    [+effect]
        damage={_DMG}
        number={_NUM}
    [/effect]
#enddef

#
# Include the following in scenarios with Union users. Yes, I realize I could
# use ATTACH_EVENTS_TO_UNIT instead.
#

#define UNION_CAST_EVENTS
    [event]
        id=union_controller
        name=attack
        first_time_only=no
        [filter_attack]
            special=union
        [/filter_attack]
        # Kind of redundant, but we want the ability to toggle the union on and
        # off as needed.
        [filter]
            ability=union
        [/filter]

        [store_unit]
            [filter]
                ability=union
                [filter_adjacent]
                    x,y=$x1,$y1
                [/filter_adjacent]
                # Optimization for enemy union casters
                side=$side_number
            [/filter]
            variable=adjacent_union_units
            kill=no
        [/store_unit]

        [foreach]
            array=adjacent_union_units
            variable=union_unit
            [do]
                {VARIABLE_DEC union_unit.attacks_left}
                {VARIABLE     union_unit.moves      0}

                [unstore_unit]
                    find_vacant=no
                    variable=union_unit
                [/unstore_unit]
            [/do]
        [/foreach]

        {CLEAR_VARIABLE adjacent_union_units}
    [/event]
#enddef

#define UNION_ANIM_MAL_KESHAR
    [attack_anim]
        [filter_attack]
            name=union
        [/filter_attack]

        [if]
            hits=yes

            {UNION_FOG}

            {UNION_BEAM}

            sound1_start_time=-450
            [sound1_frame]
                sound={SOUND_LIST:HOLY}
            [/sound1_frame]

            sound2_start_time=-400
            [sound2_frame]
                sound={SOUND_LIST:UNION_HIT}
            [/sound2_frame]
        [/if]

        start_time=-650
        offset=0.0
        blend_color=16,0,32
        blend_ratio=0.0~0.6:500,0.6~0.0:200

        [frame]
            image="units/undead-necromancers/ancient-lich-magic-[1,2].png:100"
        [/frame]
        [frame]
            image="units/undead-necromancers/ancient-lich-magic-3.png:450"
        [/frame]
        [frame]
            image="units/undead-necromancers/ancient-lich-magic-[2,1].png:100"
        [/frame]

        {SOUND:HIT_AND_MISS magic-faeriefire.ogg magic-dark-miss.ogg -350}
    [/attack_anim]
#enddef

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-Invasion_from_the_Unknown

#
# Use to define a generic initial unit in a [side] definition. Units created
# this way always have zero upkeep, without any visual indication on purpose.
#
#define SIDE_GENERIC_UNIT _TYPE _X _Y
    [unit]
        type={_TYPE}
        x={_X}
        y={_Y}
        random_traits=yes
        random_gender=yes
        generate_name=yes
        upkeep=free
    [/unit]
#enddef

#
# Use to define a generic initial guardian unit in a [side] definition. Units
# created this way always have zero upkeep, without any visual indication on
# purpose.
#
#define SIDE_GENERIC_GUARD _TYPE _X _Y
    [unit]
        type={_TYPE}
        x={_X}
        y={_Y}
        random_traits=yes
        random_gender=yes
        generate_name=yes
        upkeep=free
        ai_special=guardian
    [/unit]
#enddef

# Macros PLACE_UNITS_RANDOMLY, RANDOM_PLACEMENT_AREA, CLEAR_PLACEMENT_AREA, RANDOM_PLACEMENT
# were written by Rhuvaen for UtBS (1.3.x), and directly copied with minor modifications
#
# Many macros were written by Shadow Master on 2006, others were on 2007-2008
# wmllint: validate-off
# wmllint: unbalanced-on
# wmlindent: start ignoring
#define DIRECTION_ALL
n,s,ne,nw,se,sw#enddef
# wmlindent: stop ignoring

#define RANDOM_PLACEMENT_AREA _SLF
    # set a placement area for subsequent random placement of units
    [store_locations]
        variable=temp_PUR_locs
        {_SLF}
    [/store_locations]
#enddef

#define PLACE_UNITS_RANDOMLY _TYPE _SIDE _NUM _UNIT_WML
    [repeat]
        times={_NUM}
        [do]
            {VARIABLE_RANDOM temp_PUR_n "0..$($temp_PUR_locs.length - 1)"}

            [unit]
                side={_SIDE}
                type={_TYPE}
                x,y=$temp_PUR_locs[$temp_PUR_n].x,$temp_PUR_locs[$temp_PUR_n].y

                random_gender=yes
                random_traits=yes
                generate_name=yes
                upkeep=full
                animate=yes

                {_UNIT_WML}
            [/unit]

            {CLEAR_VARIABLE temp_PUR_n}
        [/do]
    [/repeat]
#enddef

#define CLEAR_PLACEMENT_AREA
    {CLEAR_VARIABLE temp_PUR_locs}
#enddef

#define ROLE _ROLE_TAG _SUF
    [role]
        role={_ROLE_TAG}
        {_SUF}
    [/role]
    [if]
        [not]
            [have_unit]
                {NOT_ON_RECALL_LIST}
                role={_ROLE_TAG}
            [/have_unit]
        [/not]
        [then]
            {RECALL_SUF (role={_ROLE_TAG})}
        [/then]
    [/if]
#enddef

#define REMOVE_ROLE _ROLE_TAG
    [store_unit]
        [filter]
            role={_ROLE_TAG}
        [/filter]
        variable=temp_REMOVE_ROLE_units
    [/store_unit]

    [foreach]
        array=temp_REMOVE_ROLE_units
        variable=temp_REMOVE_ROLE_unit
        [do]
            {CLEAR_VARIABLE temp_REMOVE_ROLE_unit.role}

            [unstore_unit]
                variable=temp_REMOVE_ROLE_unit
                find_vacant=no
            [/unstore_unit]
        [/do]
    [/foreach]

    {CLEAR_VARIABLE temp_REMOVE_ROLE_unit}
#enddef

#define SHAXTHAL_SURFACE_VARIATION
    variation=surface
#enddef

# wmllint: unbalanced-off
# wmllint: validate-on

#define ELVISH_SUPPORTER_ROLE ROLE
    [role]
        role={ROLE}
        type=Elvish Sylph,Elvish Shyde,Elvish Avenger,Elvish Sharpshooter,Elvish Enchantress,Elvish Champion,Elvish Marshal,Elvish Outrider,Elvish Ranger,Elvish Marksman,Elvish Sorceress,Elvish Hero,Elvish Captain,Elvish Druid,Elvish Rider,Elvish Archer,Elvish Fighter,Elvish Shaman,Elvish Civilian,Elvish Prowler,Elvish Trapper,Elvish Hunter # (ordered according to portraits)
        side=1
        [not]
            id=Anlindë,Galas
        [/not]
    [/role]
#enddef

#define MAKE_TIMED_LOYAL _SUF
    [object]
        silent=yes
        duration=scenario
        [filter]
            {_SUF}
        [/filter]
        [effect]
            apply_to=loyal
        [/effect]
    [/object]
#enddef

#
# Tries to find a suitable elvish supporter for
# recall; if that fails, it creates them. This ensures
# dialogues can go on.
#
#define ELVISH_SUPPORTER R_ID
    [if]
        [not]
            [have_unit]
                role={R_ID}
                side=1
            [/have_unit]
        [/not]
        [then]
            {ELVISH_SUPPORTER_ROLE ({R_ID})}

            [recall]
                role={R_ID}
            [/recall]

            [if]
                [not]
                    [have_unit]
                        role={R_ID}
                        side=1
                    [/have_unit]
                [/not]
                [then]
                    {VARIABLE_RANDOM temp_ELVISH_SUPPORTER_type "Archer,Fighter,Hunter,Shaman,Scout,Civilian"}

                    [unit]
                        role={R_ID}
                        type="Elvish $temp_ELVISH_SUPPORTER_type"
                        side=1
                        placement=leader
                        generate_name=yes
                        random_gender=yes
                        random_traits=yes
                    [/unit]

                    {CLEAR_VARIABLE temp_ELVISH_SUPPORTER_type}
                [/then]
            [/if]

            {MAKE_TIMED_LOYAL (role={R_ID})}
        [/then]
    [/if]
#enddef

#define UNPETRIFY_UNITS_AT_TURN_START _SIDE _ADJACENT_TO_SUF
    [event]
        name="side "+{_SIDE}+" turn refresh"
        first_time_only=no

        [store_unit]
            [filter]
                side={_SIDE}
                status=petrified
                [filter_adjacent]
                    {_ADJACENT_TO_SUF}
                [/filter_adjacent]
            [/filter]
            variable=petrified_units
        [/store_unit]

        [foreach]
            array=petrified_units
            variable=petrified_unit
            [do]
                {CLEAR_VARIABLE petrified_unit.status.petrified}

                [unstore_unit]
                    variable=petrified_unit
                    find_vacant=no
                    male_text= _ "unpetrified"
                    female_text= _ "female^unpetrified"
                    {COLOR_HEAL}
                [/unstore_unit]
            [/do]
        [/foreach]

        {CLEAR_VARIABLE petrified_units}
    [/event]
#enddef

#define UNIT_TO_GLOBAL_STORE _ID _STORE_ID
    [store_unit]
        [filter]
            id={_ID}
        [/filter]
        variable=persist_store
        kill=no
        mode=replace
    [/store_unit]

    {WRITE_VARIABLE_INTO_GLOBAL persist_store {_STORE_ID} NAMESPACE={PERSISTENT_NS_IFTU}}

    {CLEAR_VARIABLE persist_store}
#enddef

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-Invasion_from_the_Unknown

#define FLASH_PURPLE ACTION_WML
    {COLOR_ADJUST 67 0 67}
    {COLOR_ADJUST 100 0 100}
    {ACTION_WML}
    {COLOR_ADJUST 33 0 33}
    {COLOR_ADJUST 0 0 0}
#enddef

#define REVEAL X Y
    [remove_shroud]
        x={X}
        y={Y}
        side=1
    [/remove_shroud]

    {SCROLL_TO_LOCATION_AND_RETURN_TO_PRIMARY_UNIT {X} {Y} }
#enddef

#define REVEAL_AREA X1 Y1 X2 Y2
    # X0 = (X2 - X1) / 2 + X1 = X2 / 2 - X1 / 2 + X1 = X2 / 2 + -X1 / 2 + 2 X1 / 2 = X2 / 2 + X1 / 2
    # Y0 = (Y2 + Y1) / 2
    #
    # This should be little runtime load in terms of CPU time

    {VARIABLE     temp_REVEAL_AREA_center.x {X2} }
    {VARIABLE_ADD temp_REVEAL_AREA_center.x {X1} }
    {VARIABLE     temp_REVEAL_AREA_center.y {Y2} }
    {VARIABLE_ADD temp_REVEAL_AREA_center.y {Y1} }

    {VARIABLE_DIV temp_REVEAL_AREA_center.x 2}
    {VARIABLE_DIV temp_REVEAL_AREA_center.y 2}

    [remove_shroud]
        x={X1}-{X2}
        y={Y1}-{Y2}
        side=1
    [/remove_shroud]

    {SCROLL_TO_LOCATION_AND_RETURN_TO_PRIMARY_UNIT $temp_REVEAL_AREA_center.x $temp_REVEAL_AREA_center.y}

    {CLEAR_VARIABLE temp_REVEAL_AREA_center}
#enddef

#define QUAKE_HEAVY _SOUND
    [quake_heavy]
        sound={_SOUND}
    [/quake_heavy]
#enddef

#define QUAKE_HEAVIER _SOUND
    [quake_heavier]
        sound={_SOUND}
    [/quake_heavier]
#enddef

#
# Place _NUM items on hexes matching _SLF, each a random image picked from
# _IMAGELIST. No collision checks are performed, so a single hex may wind up
# overlayed with multiple images.
#
#define SCATTER_RANDOM_IMAGE _SLF _NUM _IMAGELIST
    [scatter_images]
        {_SLF}
        image={_IMAGELIST}
        limit={_NUM}
    [/scatter_images]
#enddef

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-Invasion_from_the_Unknown

#define WEAPON_SPECIAL_DREAD
    [damage]
        id=dread
        name= _ "dread"
        name_inactive= _ "dread"
        description=_"When this attack is used offensively, this unit takes one third less damage in retaliation."
        description_inactive=_"When this attack is used offensively, this unit takes one third less damage in retaliation."
        special_note={SPECIAL_NOTE_DREAD}
        active_on=offense
        apply_to=opponent
        multiply=0.66
    [/damage]
#enddef

#
# The shrapnel weapon special used by the explosive rune arrows (items.cfg).
#
#define WEAPON_SPECIAL_SHRAPNEL
    [disable]
        # Not available on defense.
        id=shrapnel_disable_defense
        active_on=defense
    [/disable]

    [disable]
        # Not available on offense against non-living or Shaxthal targets
        # (we don't want it used against bosses)
        id=shrapnel_disable_offense_cond
        active_on=offense
        [filter_opponent]
            race=undead,elvish_spirits,shaxthal
            [or]
                status=not_living
            [/or]
        [/filter_opponent]
    [/disable]

    [chance_to_hit]
        id=shrapnel_cth
        value=100
        active_on=offense
    [/chance_to_hit]

    [dummy]
        id=shrapnel
        name= _ "shrapnel"
        description= _ "The unit immediately behind the target takes 80% of the base damage of this attack, regardless of its allegiance. This value is subject to the usual damage calculation, taking the attacker’s alignment and the second target’s resistances into account.

This attack is only available on offense against living targets, and always has a 100% chance to hit regardless of the defense attributes of the target."
    [/dummy]
#enddef

#
# Note to people who might want to copy this code for their own add-on:
#
# Currently, the event handler has a single id and removes itself as soon as
# a unit with the shrapnel special has its shrapnels counter go down to 0.
#
# This means that it's not possible to have multiple units with the shrapnel
# special play nice with each other. Fixing this is left as an exercise for the
# reader.
#
#define WEAPON_SPECIAL_SHRAPNEL_IMPLEMENTATION
    [event]
        id=shrapnel:hit_handler
        name=attacker hits
        first_time_only=no
        [filter_attack]
            special=shrapnel
        [/filter_attack]

        {BUG_ON
        ({VARIABLE_NUMERICAL_LESS_THAN_OR_EQUAL unit.variables.shrapnel.count 0})
        ("shrapnel count <= 0 at event start!")}

        [harm_unit]
            [filter]
                [filter_adjacent]
                    x,y=$x2,$y2
                    adjacent=$second_unit.facing
                [/filter_adjacent]
            [/filter]
            amount=$(0.80*$weapon.damage)
            alignment=$unit.alignment
            damage_type=$weapon.type
            kill=yes
            fire_event=yes
            animate=yes
        [/harm_unit]

        {VARIABLE_DEC unit.variables.shrapnel.count}

        [if]
            {VARIABLE_NUMERICAL_EQUALS unit.variables.shrapnel.count 0}

            #
            # Remove weapon and events.
            #
            [then]
                {VARIABLE k 0}
                [while]
                    {VARIABLE_NUMERICAL_LESS_THAN k $unit.event.length}
                    {VARIABLE_LEXICAL_NOT_EQUALS unit.event[$k].id shrapnel:hit_handler}
                    [do]
                        {VARIABLE_INC k}
                    [/do]
                [/while]

                {BUG_ON ({VARIABLE_NUMERICAL_EQUALS k $unit.event.length})
                ("shrapnel unit does not carry the shrapnel controller event!")}

                {CLEAR_VARIABLE unit.event[$k],unit.variables.shrapnel,k}

                # Update unit on map before applying objects.
                [unstore_unit]
                    variable=unit
                    find_vacant=no
                [/unstore_unit]

                [object]
                    silent=yes
                    [filter]
                        x,y=$x1,$y1
                    [/filter]
                    [effect]
                        apply_to=remove_attacks
                        name=shrapnel
                    [/effect]
                [/object]

                [remove_event]
                    id=shrapnel:hit_handler
                [/remove_event]
            [/then]
            #
            # Update counter in the attack name.
            #
            [else]
                # Update unit on map before applying objects.
                [unstore_unit]
                    variable=unit
                    find_vacant=no
                [/unstore_unit]

                [object]
                    silent=yes
                    [filter]
                        x,y=$x1,$y1
                    [/filter]
                    [effect]
                        apply_to=attack
                        name=shrapnel
                        set_description="$unit.variables.shrapnel.name ($unit.variables.shrapnel.count)"
                    [/effect]
                [/object]
            [/else]
        [/if]
    [/event]
#enddef

# kate: indent-mode normal; encoding utf-8; space-indent on;


#textdomain wesnoth-Invasion_from_the_Unknown

[scenario]
    id=01_Border_Patrol
    name= _ "Border Patrol"
    {MAP 01_Border_Patrol.map}
    {TURNS 34 33 32}
    next_scenario=02_A_Real_Confrontation

    {SCENARIO_MUSIC       "loyalists.ogg"} {CONTINUE_PLAYING_STORY_MUSIC_FIRST}
    {EXTRA_SCENARIO_MUSIC "breaking_the_chains.ogg"}
    {EXTRA_SCENARIO_MUSIC "revelation.ogg"}

    {STORYTXT_INTRO}

    {TWO_SUNS_DEFAULT_SCHEDULE}

    # wmllint: validate-off
    [side]
        side=1
        controller=human
        team_name=heroes
        user_team_name= _ "team_name^Elves"

        {GOLD 230 190 170}
        recruit=Elvish Fighter,Elvish Archer,Elvish Shaman,Elvish Scout,Elvish Hunter

        # wmllint: recognize Galas
        {CHARACTER_STATS_GALAS}
    [/side]

    [side]
        side=2
        team_name=baddies
        user_team_name= _ "team_name^Humans"
        {CHAOS_FLAG}

        {GOLD 100 115 120}
        {INCOME 1 2 3}
        recruit=Chaos Raider,Chaos Invoker,Chaos Invader,Chaos Bowman

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_SIMPLE_ALWAYS_ASPECT leader_value        {DIFF 0.0 0.2 0.4} }
            {AI_SIMPLE_ALWAYS_ASPECT recruitment_pattern archer,archer,fighter,archer,fighter,scout,scout}
            {AI_SIMPLE_ALWAYS_ASPECT caution             0.2}
        [/ai]

        canrecruit=yes
        type=Chaos Arbalestier
        id=Surhan
        name= _ "Surhan"
        unrenamable=yes
        facing=nw
    [/side]

    [side]
        side=3
        team_name=baddies
        user_team_name= _ "team_name^Humans"
        {CHAOS_FLAG}

        {GOLD 110 120 130}
        recruit=Chaos Raider,Chaos Invoker,Chaos Invader,Chaos Bowman

        {ai/aliases/stable_singleplayer.cfg}
        [ai]
            {AI_SIMPLE_ALWAYS_ASPECT leader_value        {DIFF 0.1 0.25 0.5} }
            {AI_SIMPLE_ALWAYS_ASPECT recruitment_pattern archer,archer,fighter,archer,fighter,scout,fighter}
            {AI_SIMPLE_ALWAYS_ASPECT caution             0.0}
        [/ai]

        canrecruit=yes
        type=Doom Guard
        id=Grumnyr
        name= _ "Grumnyr"
        unrenamable=yes
        facing=nw
    [/side]

    [side]
        side=4
        team_name=baddies
        user_team_name= _ "team_name^Wild Animals"
        color=pink

        no_leader=yes
        hidden=yes

        # ???
        {IS_HOSTILE_NPC}

        {SIDE_GENERIC_GUARD (Falcon) 22 31}
        {SIDE_GENERIC_GUARD (Falcon) 12 24}
        {SIDE_GENERIC_GUARD (Falcon) 35 18}
        {SIDE_GENERIC_GUARD (Falcon) 26 13}
        {SIDE_GENERIC_GUARD (Falcon) 8 2}
    [/side]
    # wmllint: validate-on

    # Set NPC behaviour for side 4
    {NPC_BIRD_BEHAVIOR 4 1 40 1 35}

    {STARTING_VILLAGES 2 5}
    {STARTING_VILLAGES 3 4}

    {PLACE_IMAGE (items/bones.png) 9 33}
    {PLACE_IMAGE (items/bones.png) 23 35}
    {PLACE_IMAGE (items/bones.png) 40 22}

    {CONTINUOUS_SOUND_SOURCE campfire1 36 31 (ambient/campfire.ogg)}
    {SOUND_SOURCE_RANGE 1 8}
    {CONTINUOUS_SOUND_SOURCE campfire2 39 34 (ambient/campfire.ogg)}
    {SOUND_SOURCE_RANGE 1 8}
    {CONTINUOUS_SOUND_SOURCE campfire3 30 35 (ambient/campfire.ogg)}
    {SOUND_SOURCE_RANGE 1 8}
    {CONTINUOUS_SOUND_SOURCE campfire4 30 31 (ambient/campfire.ogg)}
    {SOUND_SOURCE_RANGE 1 8}

    [event]
        name=prestart

        {VARIABLE character_1st_time_help no}

        [capture_village]
            x=1-40
            y=1-16
            side=1
        [/capture_village]

        {RANDOM "Archer,Hunter,Fighter"}

        [unit]
            side=1
            type="Elvish $random"
            placement=leader
            generate_name=yes
            random_traits=yes
            random_gender=yes
            upkeep=full
            facing=se
        [/unit]

        {CLEAR_VARIABLE random}

        {FACE_DIRECTION id=Galas se}

        # Initialize objectives

        {OBJECTIVES (
            {OBJECTIVE_VICTORY ( _ "Hold out as long as possible")}
            {OBJECTIVE_DEFEAT  ( _ "Death of Galas")}

            {OBJECTIVE_NOTE    ( _ "Start recruiting units in advance, just in case")}

            {OBJECTIVE_CARRYOVER}
        )}
    [/event]

    [event]
        name=start

        [character_descriptions_prompt][/character_descriptions_prompt]

        [message]
            speaker=Grumnyr
            message= _ "Move on, you sluggards. Let’s claim these lands for the Master!"
        [/message]

        [message]
            speaker=Surhan
            message= _ "Be careful. We were warned that there are still elves in this valley."
        [/message]

        [message]
            speaker=Grumnyr
            message= _ "No matter. We’ll tear them to pieces if they dare oppose us!"
        [/message]

        [message]
            speaker=Galas
            message= _ "A host of humans in the southern dunes... It has been quite a long time since any of them have wandered here in such numbers."
        [/message]

        [message]
            side=1
            [not]
                id=Galas
            [/not]
            message= _ "What should we do?"
        [/message]

        [message]
            speaker=Galas
            message= _ "According to our laws, we should always grant refuge to wanderers — but I sense hostility from this group. It would be wise to observe them for a while, but let us be prepared for the worst nonetheless."
        [/message]

        [message]
            side=1
            [not]
                id=Galas
            [/not]
            message= _ "Very well."
        [/message]
    [/event]

    {GALAS_1ST_TIME_HELP}

    [event]
        name=attack
        [filter]
            side=1
        [/filter]
        [filter_second]
            [not]
                side=4
            [/not]
        [/filter_second]

        [fire_event]
            name=battle begin
            [primary_unit]
                x,y=$x1,$y1
            [/primary_unit]
        [/fire_event]
    [/event]

    [event]
        name=attack
        [filter]
            [not]
                side=4
            [/not]
        [/filter]
        [filter_second]
            side=1
        [/filter_second]

        [fire_event]
            name=battle begin
            [primary_unit]
                x,y=$x2,$y2
            [/primary_unit]
        [/fire_event]
    [/event]

    [event]
        name=turn 4

        [fire_event]
            name=battle begin
            [primary_unit]
                id=Galas
            [/primary_unit]
        [/fire_event]
    [/event]

    [event]
        name=battle begin
        first_time_only=yes

        [message]
            side=2,3
            canrecruit=yes
            message= _ "Attack! Leave no one alive!"
        [/message]

        [message]
            side=1
            [not]
                id=Galas
            [/not]
            message= _ "They are attacking us!"
        [/message]

        [message]
            speaker=Galas
            message= _ "Our laws are very clear and strict on this matter. We shall not let hostile outsiders enter our valley. Repel them!"
        [/message]

        {OBJECTIVES (
            {OBJECTIVE_VICTORY ( _ "Defeat both enemy leaders")}
            {OBJECTIVE_DEFEAT  ( _ "Death of Galas")}

            {TURNS_RUN_OUT}

            {OBJECTIVE_CARRYOVER}
        )}

        [scroll_to_unit]
            x,y=$x1,$y1
        [/scroll_to_unit]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Galas
        [/filter]

        [message]
            speaker=unit
            message= _ "Argh! I have been... defeated..."
        [/message]
    [/event]

    [event]
        name=die
        [filter]
            id=Galas
        [/filter]

        {ENDLEVEL_DEFEAT}
    [/event]

    [event]
        name=time over

        [message]
            speaker=Galas
            message= _ "They have summoned reinforcements! Our group is not strong enough to defend the valley against a full-sized army!"
        [/message]
    [/event]

    [event]
        name=enemies defeated

        {ENDLEVEL_VICTORY yes}
    [/event]

    [event]
        name=victory

        [message]
            speaker=Galas
            message= _ "We defeated them in time. But... that raiding party was quite large and well-organized for a tribe of humans, and their metalwork seems beyond the capabilities of regular sand-dwellers. This does not bode well..."
        [/message]
    [/event]
[/scenario]

# kate: indent-mode normal; encoding utf-8; space-indent on;