#textdomain wesnoth-utbs

# Scenario 1: The Morning After

[scenario]

    id="1_The_Morning_After"
    name= _ "The Morning After"

    map_data="{campaigns/Under_the_Burning_Suns/maps/01_The_Morning_After.map}"

    next_scenario=2_Across_the_Harsh_Sands

    {TURNS 34 32 30}

    victory_when_enemies_defeated=no

    {DAWN1}
    {MORNING1}
    {MIDDAY1}
    {AFTERNOON1}
    {DUSK1}
    {SHORTDARK}
    {DAWN2}
    {MORNING2}
    {MIDDAY2}
    {AFTERNOON2}
    {DUSK2}
    {LONGDARK1}
    {LONGDARK2}
    {LONGDARK3}
    {LONGDARK4}

    [music]
        name=revelation.ogg
    [/music]

    [story]
        [part]
            story= _ "Note: This campaign is probably not the best one for beginners. It changes certain Wesnoth standards, such as the elves' stats and the day/night cycle. This campaign emphasizes role-playing elements and tends to have longer scenarios with changing objectives. For these reasons I strongly suggest that you occasionally save your game mid-scenario, so you won't lose all your progress if you get stuck and have to start over."
        [/part]

        [part]
            background="misc/kaleh_story.jpg"
            story= _ "This is the chronicle of the journey of the Quenoth elves from their homeland in the Great Southern Desert. I write this story so that our descendants may know of our travels, and remember the sacrifices we made."
        [/part]

        [part]
            background="misc/kaleh_story.jpg"
            story= _ "Chapter 1: I, Kaleh, grew up amidst the shifting sands, under our two suns Sela and Naia. It was a land of hot dry days and cold nights, of roaming horrors, where water was more valuable than gold. We had lived among the sands ever since the forests fell eons ago. It was a hard savage land, but we were tougher still, and we managed to survive settled around a rare oasis. We had heavily fortified our village against any marauders and we were the biggest encampment we knew of. My uncle, Tanuil, led us for many years, and trained us to be self-sufficient and strong against all enemies. A people struggling in an ocean of sand, we thought we were ready for anything. All that changed one fateful night, when the sky rained fire..."
        [/part]

        [part]
            background="misc/night_of_fallen_stars.jpg"
            story= _ "I remember that night as if it were yesterday. I was not prone to dreaming, but as I slept I had a strange vision. I didn't have long to ponder it though, because I was woken in the dark by the sound of deafening crashes, splintering wood and shouting elves. That night the sky rained flaming rocks, boulders bigger than you could imagine. They smote the landscape like lightning bolts, setting fire to whatever could burn and crushing houses, walls, and elves. There was nowhere to hide, nowhere to go for protection. I was so afraid, I thought that if I tried to flee I would be smashed, so I hid and prayed to Eloh. I never prayed before as hard as I did that night. I heard cries and screams outside, but I could not force myself to move. And somehow, eventually the thin yellow tendrils of a sickly dawn stole over the horizon, as if Naia herself were shocked by the devastation she saw."
        [/part]
    [/story]

    [side]
        side=1
        description=Kaleh
        user_description= _ "Kaleh"
        type=Kaleh
        upkeep=free
        variation=Youth
        [modifications]
            {TRAIT_RESILIENT}
            {TRAIT_INTELLIGENT}
        [/modifications]
        canrecruit=yes
        gold=0
        {INCOME 4 2 0}
        controller=human
        shroud=yes
        fog=no

        # Start with Kaleh and Nym

        [unit]
            type=Nym Hunter
            description=Nym
            user_description= _ "Nym"
            upkeep=loyal
            side=1
            x=27
            y=22
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
            {IS_HERO}
        [/unit]
    [/side]

    # Monster side, mostly mudcrawlers
    [side]
        no_leader=yes
        side=2
        controller=ai
        shroud=no
        fog=no
        team_name=evil
        [ai]
            aggression=1.0
            caution=0.0
            # weak ai
            {ATTACK_DEPTH 1 2 3}
        [/ai]
    [/side]

    # Undead side, doesn't start with a leader
    [side]
        no_leader=yes
        side=3
        controller=ai
        shroud=no
        fog=no
        team_name=evil
        {GOLD 100 100 100}
        {INCOME -2 -2 -2}
#ifdef EASY
        recruit=Skeleton, Skeleton Archer, Vampire Bat, Ghoul, Dark Adept
#endif

#ifdef NORMAL
        recruit=Skeleton, Skeleton Archer, Blood Bat, Ghoul, Dark Adept
#endif

#ifdef HARD
        recruit=Revenant, Blood Bat, Necrophage, Dark Adept
#endif

        [ai]
            recruitment_ignore_bad_movement=yes

#ifdef HARD
            recruitment_pattern=scout,fighter,fighter,fighter,archer
#else
            recruitment_pattern=scout,fighter,archer,fighter
#endif

            aggression=0.80
            caution=0.10
            {ATTACK_DEPTH 2 3 4}
        [/ai]
    [/side]

    # macro for setting up the village occupants

#define VILLAGE_EVENT TYPE NAME
    {VARIABLE villager[$village_events].type {TYPE}}
    {VARIABLE villager[$village_events].name {NAME}}
    {VARIABLE_OP village_events add 1}
#enddef

    # prestart events:
    # set starting scenario objectives
    # teleport starting characters
    # set starting variables

    [event]
        name=prestart

        # set starting scenario objectives

        [objectives]
            summary= _ "Starting Objectives:"
            [objective]
                description= _ "Rescue Surviving Elves"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Kaleh, Nym, Garak or Zhul"
                condition=lose
            [/objective]
        [/objectives]

        # There are 3 mudcrawler encounter spots, in the NW and SW corner and in the barracks.
        # Depending on which way you circle around the village, you will
        # encounter the NW or barracks first.

        # At start seen a mudcrawler is false
        {VARIABLE seen_mudcrawler 0}

        # Grasslands dialogue has happened
        {VARIABLE grasslands_dialogue 0}

        # Can't end scenario until all elves have been rescued and counter=5
        {VARIABLE rescued_elves 0}

        # Elves in outlying villages - preset array index
        {VARIABLE abandoned_villages 0}
        {VARIABLE village_events 0}

        # possible village encounters
        {VILLAGE_EVENT "Desert Scout"   _"Lrea"}
        {VILLAGE_EVENT "Desert Archer"  _"Danu"}
        {VILLAGE_EVENT "Desert Hunter"  _"Hamuil"}
        {VILLAGE_EVENT "Desert Scout"   _"Vemuil"}
        {VILLAGE_EVENT "Desert Archer"  _"Frea"}
        {VILLAGE_EVENT "Desert Fighter" _"Piyru"}
        {VILLAGE_EVENT "Desert Hunter"  _"Anioh"}
        {VILLAGE_EVENT "Desert Scout"   _"Taliu"}
    [/event]

    # Dialogue at start of scenario
    [event]
        name=start

        [message]
            description=Nym
            message= _ "Hey Kaleh, are you in there?"
        [/message]

        [message]
            description=Kaleh
            message= _ "Nym, is that you?"
        [/message]

        [message]
            description=Nym
            message= _ "Yes, come on out already. The storm has passed. With the morning light Naia has ended the terrible night."
        [/message]

        [message]
            description=Kaleh
            message= _ "Has the sky really stopped falling?"
        [/message]

        [message]
            description=Nym
            message= _ "I already told you, the sky is clear and empty. Now come quickly, silly, others may need our help."
        [/message]

        [message]
            description=Kaleh
            message= _ "What's happened? Oh Eloh, the craters are everywhere, everything is gone, ruined. I can hardly recognize our village. I didn't think it could be this bad."
        [/message]

        [message]
            description=Nym
            message= _ "C'mon Kaleh, we have to go see if anyone is hurt or needs help. I think I hear people calling from the south. Now is not a time for fear, we must be strong. After all you are the nephew of Tanuil, our leader, and you must answer to the call of duty. Perhaps in the light of day things won't be as bad as you think. Let's explore the village and see who else has survived the night."
        [/message]

        [message]
            description=Kaleh
            message= _ "Wait, our keep is just to the east. Our leader Tanuil must surely be recruiting others to help deal with the devastation. Perhaps we should go to the keep, before we explore the rest of the village."
        [/message]
    [/event]

    # Dialogue when Nym and Kaleh see the ruined keep
    [event]
        name=moveto

        [filter]
            x=33-40
            y=19-26
            side=1
        [/filter]

        [allow_undo]
        [/allow_undo]

        [message]
            description=Kaleh
            message= _ "Tanuil's keep, our beautiful fortress, it is destroyed. How will we summon our people to battle?"
        [/message]
        [message]
            description=Nym
            message= _ "We must rally those survivors we can find amidst the rubble. It doesn't look like anyone survived, but at least we can thank Eloh it was a quick death. But come on, we can't dwell on the dead, we must help the living."
        [/message]
        [message]
            description=Kaleh
            message= _ "But if Tanuil is dead, who will lead us?"
        [/message]
        [message]
            description=Nym
            message= _ "That's a question for another time. Let's keep exploring the wreckage."
        [/message]
    [/event]

    # Desert Village event
    # Some of the outer villages have elves hiding in them. If the player
    # reaches them before the undead do, they can rescue the elves

    [event]
        name=capture
        first_time_only=no
        [filter]
            side=1,3
            #!-- Fixes bug 10418, reduces potential number of elves found in the desert to max four
            [not]
                x=40-60
                y=1-12
            [/not]
            [filter_location]
                terrain=Dd^Vdt
            [/filter_location]
        [/filter]

        # check to see if the village has been captured
        # by the undead before
        [store_locations]
            variable=vill
            x=$x1
            y=$y1
            find_in=abandoned
        [/store_locations]

        [if]
            [variable]
                name=vill.length
                less_than=1
            [/variable]
            [then]
                [if]
                    [variable]
                        name=unit.side
                        numerical_equals=1
                    [/variable]

                    [then]
                        {RANDOM 1..10}

                        [if]
                            [variable]
                                name=random
                                less_than_equal_to=6
                            [/variable]

                            [then]
                                # pick one village occupant at random
                                {RANDOM 1..$village_events}
                                {VARIABLE_OP random add -1}

                                {VARIABLE unit_type $villager[$random].type}
                                {VARIABLE unit_name $villager[$random].name}

                                [unit]
                                    side=1
                                    type=$unit_type
                                    x=$x1
                                    y=$y1
                                    user_description=$unit_name
                                    upkeep=full
                                    animate=yes
                                    moves="0"
                                [/unit]

                                {CLEAR_VARIABLE unit_type}
                                {CLEAR_VARIABLE unit_name}

                                # remove this village inhabitant from array
                                {VARIABLE next_i $random}
                                {VARIABLE_OP next_i add 1}
                                [while]
                                    [variable]
                                        name=next_i
                                        less_than=$village_events
                                    [/variable]
                                    [do]
                                        {VARIABLE villager[$random].type $villager[$next_i].type}
                                        {VARIABLE villager[$random].name $villager[$next_i].name}
                                        {VARIABLE_OP random add 1}
                                        {VARIABLE_OP next_i add 1}
                                    [/do]
                                [/while]
                                {CLEAR_VARIABLE villager[$village_events].type}
                                {CLEAR_VARIABLE villager[$village_events].name}
                                {CLEAR_VARIABLE next_i}
                                {VARIABLE_OP village_events add -1}
                                [message]
                                    speaker=unit
                                    message= _ "Oh good, some elves have survived in this outer settlement. They've agreed to help us search for other survivors."
                                [/message]
                            [/then]

                            [else]
                                [message]
                                    speaker=unit
                                    message= _ "The encampment is empty. I wonder what happened to the inhabitants?"
                                [/message]
                            [/else]
                        [/if]
                    [/then]
                    [else]
                        # captured by undead -> abandon it
                        {VARIABLE abandoned[$abandoned_villages].x $x1}
                        {VARIABLE abandoned[$abandoned_villages].y $y1}
                        {VARIABLE_OP abandoned_villages add 1}
                    [/else]
                [/if]
            [/then]
            [else]
                [if]
                    [variable]
                        name=unit.side
                        equals=1
                    [/variable]
                    [then]
                        [message]
                            speaker=unit
                            message= _ "This encampment has been abandoned. There are signs of a struggle and a few bloodstains but nothing else. I fear for those elves who lived out here."
                        [/message]
                    [/then]
                [/if]
            [/else]
        [/if]
        {CLEAR_VARIABLE vill}
    [/event]

#define MUDCRAWLER_TALK DESCRIPTION
    # Hasn't completed #1 encounter, do it now
    # If (hasn't seen mudcrawler) then (perform what-the-hell-is-that routine)

    {VARIABLE seen_mudcrawler 1}

    [message]
        description={DESCRIPTION}
        message= _ "Kaleh, Nym, help us!"
    [/message]
    [message]
        description=Nym
        message= _ "What in Uria's name is that?"
    [/message]
    [message]
        description={DESCRIPTION}
        message= _ "It came out of the stones that fell from the sky. I know not what it is, but more seem to be emerging from the craters. If we don't stop them there will be nothing left of our village or our people."
    [/message]
    [message]
        description=Kaleh
        message= _ "To battle, my friends! There are still those left who can fight."
    [/message]
#enddef

#define MUDCRAWLER_WARCRY

    # Has completed encounter #1 in SW corner, do #2 encounter
    # else (Seen mudcrawler, do let's-kick-their-ass performance)
    [message]
        description=Kaleh
        message= _ "There are more of our people fighting the mud monsters!"
    [/message]
    [message]
        description=Nym
        message= _ "Then let's join the battle!"
    [/message]
#enddef

#define MUDCRAWLER_ROUTINE DESCRIPTION
    [if]
        [variable]
            name=seen_mudcrawler
            numerical_equals=0
        [/variable]

        [then]
            {MUDCRAWLER_TALK {DESCRIPTION}}
        [/then]
        [else]
            {MUDCRAWLER_WARCRY}
        [/else]
    [/if]
#enddef

    # North-West mudcrawler/villager encounter
    # Elvish fighter and 2 archers fighting
    # Easy: 1 giant mudcrawler, 3 small mudcrawlers
    # Medium: 2 giant mudcrawler, 2 small mudcrawlers
    # Hard: 3 giant mudcrawlers, 2 small mudcrawlers
    [event]
        name=moveto
        [filter]
            x=17-26
            y=23-28
            side=1
        [/filter]

        {ADD rescued_elves 1}

        {RANDOM_TRAIT_UNIT 1 "Desert Fighter" 24 25 "Vecnu" ( _ "Vecnu") ()}
        {RANDOM_TRAIT_UNIT 1 "Desert Archer" 24 27 "Eranor" ( _ "Eranor") ()}
        {RANDOM_TRAIT_UNIT 1 "Desert Archer" 21 25 "Seela" ( _ "Seela") (gender="female")}

        {RANDOM_TRAIT_UNIT 2 "Giant Mudcrawler" 20 24 "Mudcrawler1" () ()}

#ifdef HARD
        {RANDOM_TRAIT_UNIT 2 "Giant Mudcrawler" 20 25 "Mudcrawler2" () ()}
#else
        {RANDOM_TRAIT_UNIT 2 "Small Mudcrawler" 20 25 "Mudcrawler3" () ()}
#endif

#ifdef EASY
        {RANDOM_TRAIT_UNIT 2 "Small Mudcrawler" 23 27 "Mudcrawler4" () ()}
        {RANDOM_TRAIT_UNIT 2 "Small Mudcrawler" 25 28 "Mudcrawler5" () ()}
#else
        {RANDOM_TRAIT_UNIT 2 "Giant Mudcrawler" 23 27 "Mudcrawler6" () ()}
        {RANDOM_TRAIT_UNIT 2 "Small Mudcrawler" 24 28 "Mudcrawler7" () ()}
#endif

        {MUDCRAWLER_ROUTINE Vecnu}
    [/event]

    # South-West mudcrawler/villager encounter
    # Elvish archer and 2 hunters fighting
    # Easy: 4 small mudcrawlers
    # Medium: 1 giant mudcrawler, 3 small mudcrawlers
    # Hard: 2 giant mudcrawlers, 2 small mudcrawlers
    [event]
        name=moveto
        [filter]
            x=17-28
            y=29-36
            side=1
        [/filter]

        [set_variable]
            name=rescued_elves
            add=1
        [/set_variable]

        {RANDOM_TRAIT_UNIT 1 "Desert Hunter" 24 34 "Eloshi" ( _ "Eloshi") ()}
        {RANDOM_TRAIT_UNIT 1 "Desert Archer" 19 33 "Illuvia" ( _ "Illuvia") (gender="female")}
        {RANDOM_TRAIT_UNIT 1 "Desert Hunter" 21 35 "Raynor" ( _ "Raynor") ()}

        {RANDOM_TRAIT_UNIT 2 "Giant Mudcrawler" 25 34 "Mudcrawler8" () ()}
        {RANDOM_TRAIT_UNIT 2 "Small Mudcrawler" 21 36 "Mudcrawler9" () ()}

#ifdef HARD
        {RANDOM_TRAIT_UNIT 2 "Giant Mudcrawler" 24 35 "Mudcrawler10" () ()}
#else
        {RANDOM_TRAIT_UNIT 2 "Small Mudcrawler" 24 35 "Mudcrawler11" () ()}
#endif

#ifdef EASY
        {RANDOM_TRAIT_UNIT 2 "Small Mudcrawler" 20 34 "Mudcrawler12" () ()}
#else
        {RANDOM_TRAIT_UNIT 2 "Giant Mudcrawler" 20 34 "Mudcrawler13" () ()}
#endif

        {MUDCRAWLER_ROUTINE Eloshi}
    [/event]

    # Training ground encounter
    # Easy: 2 giant mudcrawler, 3 small mudcrawlers
    # Medium: 3 giant mudcrawlers, 2 small mudcrawlers
    # Hard: 4 giant mudcrawlers, 1 small mudcrawlers
    [event]
        name=moveto
        [filter]
            x=32-39
            y=32-36
            side=1
        [/filter]

        [capture_village]
            side=1
            x,y=36,34
        [/capture_village]

        {ADD rescued_elves 1}

        {RANDOM_TRAIT_UNIT 2 "Giant Mudcrawler" 34 33 "Rocky Horror1" ( _ "Rocky Horror") (role="Rocky Horror")}
        {RANDOM_TRAIT_UNIT 2 "Giant Mudcrawler" 34 34 "Rocky Horror2" ( _ "Rocky Horror") (role="Rocky Horror")}
        {RANDOM_TRAIT_UNIT 2 "Small Mudcrawler" 34 35 "Rocky Horror3" ( _ "Rocky Horror") (role="Rocky Horror")}

#ifdef HARD
        {RANDOM_TRAIT_UNIT 2 "Giant Mudcrawler" 35 33 "Rocky Horror4" ( _ "Rocky Horror") (role="Rocky Horror")}
#else
        {RANDOM_TRAIT_UNIT 2 "Small Mudcrawler" 35 33 "Rocky Horror5" ( _ "Rocky Horror") (role="Rocky Horror")}
#endif

#ifdef EASY
        {RANDOM_TRAIT_UNIT 2 "Small Mudcrawler" 36 32 "Rocky Horror6" ( _ "Rocky Horror") (role="Rocky Horror")}
#else
        {RANDOM_TRAIT_UNIT 2 "Giant Mudcrawler" 36 32 "Rocky Horror7" ( _ "Rocky Horror") (role="Rocky Horror")}
#endif

        [unit]
            type=Desert Captain
            description=Garak
            user_description= _ "Garak"
            profile=portraits/garak.png
            upkeep=full
            x=35
            y=34
            side=1
            hitpoints=44	# A bit less than for a Desert Captain
            [modifications]
                {TRAIT_STRONG}
                {TRAIT_LOYAL}
                [object]
                    id=Garak_mod
                    [effect]
                        # !***The unit type restriction does not work, given the bonus for life***
                        apply_to=attack
                        range=ranged
                        increase_damage=1
                    [/effect]
                [/object]
            [/modifications]

            {IS_HERO}
        [/unit]

        {RANDOM_TRAIT_UNIT 1 "Desert Fighter" 36 33 "Jorazan" ( _ "Jorazan") ()}
        {RANDOM_TRAIT_UNIT 1 "Desert Fighter" 35 35 "Zyara" ( _ "Zyara") (gender="female")}

        [message]
            speaker=unit
            message= _ "This is our training ground. And look, there is Garak, the captain of the guard. He and his fighters have survived the night!"
        [/message]
        [if]
            [variable]
                name=seen_mudcrawler
                numerical_equals=0
            [/variable]
            [then]
                {MUDCRAWLER_TALK Garak}
            [/then]
            [else]
                [message]
                    description=Kaleh
                    message= _ "But they are fighting many mud creatures. Quick, we must help them!"
                [/message]
            [/else]
        [/if]

        # Garak's speech when they kill the Giant Mudcrawler

        [event]
            name=die
            first_time_only=no

            [filter]
                role="Rocky Horror"
            [/filter]

            [if]
                [not]
                    [have_unit]
                        role="Rocky Horror"
                    [/have_unit]
                [/not]
                [then]
                    [message]
                        speaker=second_unit
                        message= _ "Ha! They're destroyed at last."
                    [/message]
                    [message]
                        speaker=Garak
                        message= _ "Thanks for the help. I am glad to see that so many have survived the night. But there's no time to talk, we must save the rest of our people and crush any other of these earthen abominations back into the earth."
                    [/message]
                [/then]
            [/if]
        [/event]
    [/event]

    # Approaching bridge dialogue
    [event]
        name=moveto

        [filter]
            x=30-32
            y=29-35
            side=1
        [/filter]

        [allow_undo]
        [/allow_undo]

        [message]
            speaker=Kaleh
            message= _ "This bridge leads to the holy island at the center of our lake."
        [/message]
        [message]
            speaker=Nym
            message= _ "Hmmmm. Some of the druids that worship on the island may still be alive. We should go check."
        [/message]
        [message]
            speaker=Kaleh
            message= _ "Be careful. The bridge is broken, so we'll have to wade through the shallow water."
        [/message]
    [/event]

    # Finding druids
    [event]
        name=moveto

        [filter]
            x=30-32
            y=27-29
            side=1
        [/filter]

        {ADD rescued_elves 1}

        [message]
            speaker=Kaleh
            message= _ "The great tree! It has been buried under the rocks. Our most holy sanctuary, defiled. Oh, Eloh, what shall we do?"
        [/message]

        [message]
            speaker=Nym
            message= _ "Is anyone still alive?"
        [/message]

        [unit]
            # Zhul used to have her own unit type, but this was
            # just a way to keep her portrait displaying.
            type=Desert Druid
            description=Zhul
            user_description= _ "Zhul"
            profile=portraits/zhul.png
            upkeep=full
            x=31
            y=27
            side=1
            [modifications]
                {TRAIT_QUICK}
                {TRAIT_LOYAL}
            [/modifications]
            {IS_HERO}
        [/unit]

        {RANDOM_TRAIT_UNIT 1 "Desert Shaman" 30 27 "Ryoko" ( _ "Ryoko") ()}
        {RANDOM_TRAIT_UNIT 1 "Desert Shaman" 32 27 "Yuni" ( _ "Yuni") ()}

        [message]
            speaker=Zhul
            message= _ "Finally! We were worried that no one else had survived."
        [/message]

        [message]
            speaker=Nym
            message= _ "Mother priestess, are you all right?"
        [/message]

        [message]
            speaker=Zhul
            message= _ "There's no time to stand on ceremony. I'm fine. I'm afraid only a few of us survived, but we will lend you what skills we have. Show me to those who need healing."
        [/message]

        [message]
            speaker=Kaleh
            message= _ "But the great tree, it has been destroyed!"
        [/message]

        [message]
            speaker=Zhul
            message= _ "All things of this world come to an end, but the power of Eloh endures. A new one shall grow in its place. Come now, let us see to the needs of our people."
        [/message]

        [event]
            name=moveto

            [filter]
                x=30-32
                y=30-34
                side=1
            [/filter]

            [unit]
                type=Cuttle Fish
                description="Deep One"
                user_description=_"Deep One"
                unit_description= _ "The Deep Ones are gigantic aquatic monsters that lurk in the dark places of the world. Rarely do they come to the surface, and when they do the best way to survive an encounter with these monsters is to remain ashore. They can grab their opponents with strong tentacles, or spit a poisonous black ink from a distance."
                # !***Scraped Deep One custom unit -> a wimpy clone of Cuttle Fish***
                [modifications]
                    [trait]
                        id=Deep_one
                        [effect]
                            apply_to=attack
                            range=melee
                            increase_attacks=-4
                        [/effect]
                        [effect]
                            apply_to=hitpoints
                            increase_total=-27
                        [/effect]
                        [effect]
                            apply_to=defense
                            replace=yes
                            [defense]
                                shallow_water=50
                            [/defense]
                        [/effect]
                    [/trait]
                [/modifications]
                x=32
                y=30
                side=2
            [/unit]

            [message]
                description=Deep One
                message= _ "Raaaar!"
            [/message]

            [message]
                speaker=Nym
                message= _ "What in Uria's name is that?"
            [/message]

            [message]
                speaker=Zhul
                message= _ "I felt a great darkness in this lake, but I knew not what it was. The falling rocks must have woken it from its sleep."
            [/message]

            [message]
                speaker=Kaleh
                message= _ "Protect the priestesses, we shall send this monstrosity back to the depths it came from!"
            [/message]
        [/event]
    [/event]

    # Grasslands dialogue, when Kaleh and Nym approach the eastern fields

    [event]
        name=moveto
        [filter]
            x=39-44
            y=26-33
            side=1
        [/filter]

        {ADD rescued_elves 1}

        # only show this if the villages haven't been captured yet
        [if]
            [variable]
                name=grasslands_dialogue
                less_than=1
            [/variable]
            [then]
                {VARIABLE grasslands_dialogue 1}
                [message]
                    description=Kaleh
                    message= _ "These fields seem strangely vacant. Where are the horses?"
                [/message]
                [message]
                    description=Nym
                    message= _ "Maybe they're hiding in the stables. Let's go check."
                [/message]
            [/then]
        [/if]
    [/event]

    # Stables Encounters
    # Now wrapped into one - also includes the grasslands dialogue
    # if it hasn't been shown yet

    [event]
        name=capture
        first_time_only=no
        [filter]
            x=43,43
            y=29,32
        [/filter]

        # check to see if the undead have captured it
        [store_locations]
            variable=vill
            x=$x1
            y=$y1
            find_in=abandoned
        [/store_locations]

        [if]
            [variable]
                name=unit.side
                equals=1
            [/variable]
            [then]
                [if]
                    [variable]
                        name=vill.length
                        less_than=1
                    [/variable]
                    [then]
                        [if]
                            [variable]
                                name=grasslands_dialogue
                                less_than=1
                            [/variable]
                            [then]
                                {VARIABLE grasslands_dialogue 1}
                                [message]
                                    description=Kaleh
                                    message= _ "These fields seem strangely vacant. Where are the horses?"
                                [/message]
                                [message]
                                    description=Nym
                                    message= _ "Maybe they're hiding in the stables. Let's go check."
                                [/message]
                                [message]
                                    description=Nym
                                    message= _ "I think I see movement in the stables. Is anyone there?"
                                [/message]
                            [/then]
                        [/if]
                        [if]
                            [variable]
                                name=grasslands_dialogue
                                less_than=2
                            [/variable]
                            [then]
                                # first stable encounter
                                {VARIABLE grasslands_dialogue 2}
                                {RANDOM_TRAIT_UNIT 1 "Desert Scout" $x1 $y1 "Naru" ( _ "Naru") ()}
                                # wmllint: recognize Naru

                                [message]
                                    description=Naru
                                    message= _ "Is it safe to come out? I was so scared."
                                [/message]
                                [message]
                                    description=Kaleh
                                    message= _ "Where are all the other horses?"
                                [/message]
                                [message]
                                    description=Naru
                                    message= _ "A hunting party left just yesterday, so unless the rocks fell all over the land, many of the horses have probably survived. The few that remained here were scared by the falling rocks and fled into the night. It took all my skill to calm Yasi and keep him from running."
                                [/message]
                                [message]
                                    description=Kaleh
                                    message= _ "We'll need your help in checking to see if the outer settlements are okay. Who knows what kinds of damage they suffered in the night? And perhaps some of the people out in the desert have been able to round up some of the loose horses."
                                [/message]
                                [message]
                                    description=Nym
                                    message= _ "Well, let's hope that hunting party comes back soon."
                                [/message]
                            [/then]
                            [else]
                                # second stable encounter
                                [message]
                                    description=Naru
                                    message= _ "Hey Nisa, the rocks have stopped falling. You can come out now!"
                                [/message]
                                {RANDOM_TRAIT_UNIT 1 "Desert Scout" 43 31 "Nisa" ( _ "Nisa") (gender="female")}
                                # wmllint: recognize Nisa
                                [message]
                                    description=Nisa
                                    message= _ "Oh, thank Eloh, I thought they would never stop."
                                [/message]
                            [/else]
                        [/if]
                    [/then]
                [/if]
            [/then]
            [else]
                # the undead capture village - abandon it
                # this just prevents the stables encounters from happening again on recapturing the villages
                {VARIABLE abandoned[$abandoned_villages].x $x1}
                {VARIABLE abandoned[$abandoned_villages].y $y1}
                {VARIABLE_OP abandoned_villages add 1}
            [/else]
        [/if]
    [/event]

    # Undead leader shows up on dusk of the first long night, turn 11

#define DARKSORCERER_INTRO

    [unit]
#ifdef HARD
        type=Necromancer
#else
        type=Dark Sorcerer
#endif
        description=Xanthos
        user_description= _ "Xanthos"
        canrecruit=yes
        x=46
        y=3
        side=3
    [/unit]
    [modify_side]
        side=3
        {GOLD 150 175 200}
        {INCOME 12 15 20}
    [/modify_side]

    [remove_shroud]
        side=1
        x=44-48
        y=1-5
    [/remove_shroud]

    [message]
        description=Xanthos
        message= _ "This place reeks of the stench of death, I could smell it from miles away. Oh how I love it, it is the smell of power, the inevitable triumph of death over life. Puny elves, I shall use the corpses of your families to create an army of undead! All shall bow down before Xanthos the Necromancer!"
    [/message]

    [message]
        description=Nym
        message= _ "His timing couldn't be worse. I know that undead cultists often prey on small targets, but they haven't had the guts to attack us for years. Why has Eloh heaped so much misfortune upon us?"
    [/message]

    [message]
        description=Zhul
        message= _ "Have some more faith girl, the goddess does not give us more than we can handle. With Eloh's grace we shall yet triumph over this pretender."
    [/message]

    [message]
        description=Garak
        message= _ "Bah, I've fought these dark cultists before. They can be killed just like anyone else, and our elvish hunters can easily decimate their skeleton armies."
    [/message]

    [message]
        description=Kaleh
        message= _ "I have heard of your kind, foul necromancer. You travel the sands, daring to bring back and enslave those who have passed on. But we will prove to you that death is not all-powerful. You shall not desecrate the bodies of my kith and kin! You shall learn to fear the wrath of Eloh and the Quenoth elves!"
    [/message]

    [place_shroud]
        side=1
        x=44-48
        y=1-5
    [/place_shroud]

    [objectives]
        summary= _ "New Objectives:"
        show=yes
        [objective]
            description= _ "Rescue Surviving Elves"
            condition=win
        [/objective]
        [objective]
            description= _ "Defeat Xanthos"
            condition=win
        [/objective]
        [objective]
            description= _ "Death of Kaleh, Nym, Garak or Zhul"
            condition=lose
        [/objective]
    [/objectives]

#enddef

    [event]
#ifdef EASY
        name=turn 11
#endif
#ifdef NORMAL
        name=turn 10
#endif
#ifdef HARD
        name=turn 9
#endif
        # If Xanthos does not exist and undead gold is unmodified it means he never showed up
        [store_side]
            side=3
            variable=temp
        [/store_side]

        [if]
            [not]
                [have_unit]
                    description=Xanthos
                [/have_unit]
            [/not]
            [variable]
                name=temp.gold
                numerical_equals=100
            [/variable]
            [then]
                {DARKSORCERER_INTRO}
            [/then]
        [/if]

        {CLEAR_VARIABLE temp}
    [/event]

    # When dark sorcerer dies, checks to make sure elves have been rescued
    # before ending the scenario
    [event]
        name=die
        [filter]
            description=Xanthos
        [/filter]

        [sound]
            name=wail-long.wav
        [/sound]

        [kill]
            side=3
            race=undead
            animate=yes
        [/kill]

        [message]
            description=Kaleh
            message= _ "The necromancer is finally vanquished."
        [/message]

        [message]
            description=Zhul
            message= _ "And at last the dead shall have their rest."
        [/message]

        [if]
            [variable]
                name=rescued_elves
                numerical_not_equals=5
            [/variable]
            [then]
                [message]
                    description=Kaleh
                    message= _ "The necromancer is dead, but I don't think we've explored the entire village. There may still be elves that need rescuing. We should go back and check. "
                [/message]
                [event]
                    name=die
                    first_time_only=no
                    [filter]
                        [not]
                            side=1
                        [/not]
                    [/filter]
                    [if]
                        [variable]
                            name=rescued_elves
                            numerical_equals=5
                        [/variable]

                        [then]
                            [message]
                                description=Kaleh
                                message= _ "We've explored the village and I think we've rescued the last of the survivors."
                            [/message]

                            [endlevel]
                                result=victory
                                bonus=yes
                            [/endlevel]
                        [/then]
                    [/if]
                [/event]
            [/then]
            [else]
                [endlevel]
                    result=victory
                    bonus=yes
                [/endlevel]
            [/else]
        [/if]
    [/event]

    # This event prevents player from running to dark sorcerer's base
    # before he shows up on turn 11. If the player approaches his base
    # before turn 11 he appears and attacks. Either way the unit moving
    # into the area also comments on the plight of those elves who
    # lived out in the open sands.
    [event]
        name=moveto
        [filter]
            x=37-60
            y=1-12
            side=1
        [/filter]

        [if]
            [not]
                [have_unit]
                    side=3
                [/have_unit]
            [/not]

            [then]
                {DARKSORCERER_INTRO}
            [/then]
        [/if]

        [message]
            speaker=unit
            message= _ "Some of our people felt crowded in the village, and wanted to live out on the open sands. They thought they could flee to the safety of our walls if danger came. I shudder to think what has happened to them."
        [/message]
    [/event]

    # Elvish hunting party shows up on turn 18 (changed to 16)

    [event]
        name=turn 16
        [remove_shroud]
            side=1
            x=24-32
            y=1-6
        [/remove_shroud]

        {RANDOM_TRAIT_UNIT 1 "Desert Hunter" 29 2 "Pythos" ( _ "Pythos") ()}
        {RANDOM_TRAIT_UNIT 1 "Desert Fighter" 28 2 "Shea" ( _ "Shea") ()}
        {RANDOM_TRAIT_UNIT 1 "Desert Fighter" 29 1 "Narn" ( _ "Narn") ()}
        {RANDOM_TRAIT_UNIT 1 "Desert Scout" 27 2 "Jokli" ( _ "Jokli") ()}
        {RANDOM_TRAIT_UNIT 1 "Desert Archer" 28 1 "Lyia" ( _ "Lyia") (gender="female")}
        # wmllint: recognize Pythos

        [message]
            description=Pythos
            message= _ "Hail, is anyone still alive?"
        [/message]

        [message]
            description=Kaleh
            message= _ "Yes, and we could certainly use your help. A necromancer has been attacking us, he intends to use our fallen comrades as fodder for his evil magics. Where have you been?"
        [/message]

        [message]
            description=Pythos
            message= _ "We were out far in the sands, searching for prey and roaming orcs. As soon as we saw the rock storm we raced back as fast as we could. I only wish we could have come sooner."
        [/message]

        [message]
            description=Nym
            message= _ "No use crying over spilt water. But we're sure glad you're here now."
        [/message]
    [/event]

    [event]
        name=victory

        [message]
            description=Nym
            message= _ "It seems that we finally have some peace. But what do we do now?"
        [/message]

        [message]
            description=Garak
            message= _ "Where is Tanuil and his family?"
        [/message]

        [message]
            description=Kaleh
            message= _ "The keep has been crushed by the rocks. We could find no survivors."
        [/message]

        [message]
            description=Zhul
            message= _ "Too many have died this night."
        [/message]

        [message]
            description=Nym
            message= _ "Our village is in ruins. The walls that were built by our ancestors over generations have been demolished in a space of hours. Most of our dwellings are destroyed. And the great tree itself is no more. One thing is obvious, we cannot stay here."
        [/message]

        [message]
            description=Garak
            message= _ "You are a fool to despair. This has always been our home. The water here is good, we know this land. We can rebuild; Eloh willing, we can thrive again."
        [/message]

        [message]
            description=Nym
            message= _ "Think for a moment. Who else has seen the rock storm? What other foes are coming to pick over the remains of our people? There is no mercy in the desert, and we have many enemies who would seek to gain in our time of weakness."
        [/message]

        [message]
            description=Garak
            message= _ "Impudent girl, you should not speak so to your elders, or to your betters."
        [/message]

        [message]
            description=Nym
            message= _ "I have a right to speak my mind!"
        [/message]

        [message]
            description=Zhul
            message= _ "Peace, please calm yourselves. In chaos there is nothing but death and destruction. Even in this time of trial we must show our fortitude, and follow our laws. Without laws we are like beasts in the desert, fighting over scraps of meat. Among the survivors Kaleh is by heritage the closest relative to Tanuil and thus our leader. What say you Kaleh?"
        [/message]

        [message]
            description=Kaleh
            message= _ "Last night, before the rock storm, I heard a voice in my sleep. It sounded like sweet music, and somehow I knew it was Eloh. I still remember her exact words: 'You must be strong, young elf, for you enter a time of peril. The home you know will be destroyed, and you must lead your people to a new land. To the north you will find salvation and peace. Cross the desert and head to the mountains. Fear not, for I will guide you and protect you.' I'm not sure why I'm the one she chose to appeal to, but if this is her will, I will see it done. Our home is gone and the desert is a harsh place. If Eloh has prepared a new home for us, then I will lead us there."
        [/message]

        [message]
            description=Garak
            message= _ "I fear what dangers lurk in the harsh sands and beyond to the north, but because you are our leader, I will follow your counsel."
        [/message]

        [message]
            description=Zhul
            message= _ "Then let us collect what supplies we can from the wreckage and head north with great haste. Our home is protection no longer, we must find a new haven for our people."
        [/message]

        [message]
            description=Nym
            message= _ "What about the bodies of the dead? We can't leave them to be torn by crows or desecrated by other dark mages."
        [/message]

        [message]
            description=Kaleh
            message= _ "I agree, we should not forget our dead. We should build a huge pyre and burn them with proper ceremony, so that the smoke may carry them on to the next realm."
        [/message]

        [message]
            description=Zhul
            message= _ "Kaleh, I don't want to tarry longer than necessary, but I agree that we must see to the dead before we leave. Garak, you and your men start collecting our dead. Nym, help me find oil and wood so that we may build a pyre."
        [/message]

        [message]
            speaker=narrator
            message= _ "And so it was done. The dead were laid reverently on top of what little wood we could find. But the fire was big enough to burn the bodies to ashes and speed their souls to the hereafter. I remember at the time that the death of so many of our people was not the best omen for the start of such a large journey. They were the first of our people to die in this great endeavor, but they were to be far from the last."
            image=wesnoth-icon.png
        [/message]

        # Clear variables
        {CLEAR_VARIABLE seen_mudcrawler}
        {CLEAR_VARIABLE rescued_elves}
        {CLEAR_VARIABLE villager}
        {CLEAR_VARIABLE abandoned_villages}
        {CLEAR_VARIABLE grasslands_dialogue}
        {CLEAR_VARIABLE village_events}
    [/event]

    [event]
        name=time over
        [message]
            description=Kaleh
            message= _ "What's that to the north? It looks like even more undead! The rock storm must have attracted other necromancers. There's no way we can defeat them all. We've run out of time. There's no escape. Eloh save us!"
        [/message]
    [/event]

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