#textdomain wesnoth-utbs

[scenario]
    id=04_Descending_into_Darkness
    name= _ "Descending into Darkness"
    next_scenario=05_A_Subterranean_Struggle
    {UTBS_MAP 04_Descending_into_Darkness.map}
    victory_when_enemies_defeated=no
    snapshot="no"

    {TWO_SUNS_DEFAULT_SCHEDULE}
    {TURNS 50 48 46}

    {INTRO_AND_SCENARIO_MUSIC "northerners.ogg" "suspense.ogg"}
    {EXTRA_SCENARIO_MUSIC "vengeful.ogg"}
    {EXTRA_SCENARIO_MUSIC "frantic.ogg"}

    {STORY_DESCENDING_INTO_DARKNESS}

    [side]
        side=1
        id=Kaleh
        type=Desert Fighter
        canrecruit=yes
        gold=200
        {INCOME 6 4 2}
        controller=human
        shroud=yes
        fog=no
        {FLAG_VARIANT long}
        user_team_name= _ "team_name^Quenoth Elves"
    [/side]

    # Orcish leaders

    # The front line leader is a goblin who recruits goblins and orcs,
    # more scouts/weaker units than the other orcs.
    # He is also more aggressive.
    [side]
        side=2
        id=Panok
        name= _ "Panok"
#ifdef HARD
        type=Direwolf Rider
#else
        type=Goblin Knight
#endif
        canrecruit=yes

        {INCOME 3 5 7}
        {GOLD 75 100 125}
        controller=ai
        shroud=no
        fog=no
        team_name=evil
        user_team_name=_"Evil"
#ifdef EASY
        recruit=Orcish Grunt,Wolf Rider,Goblin Spearman,Orcish Archer
#endif
#ifdef NORMAL
        recruit=Orcish Grunt,Wolf Rider,Goblin Impaler,Orcish Archer,Goblin Knight
#endif
#ifdef HARD
        recruit=Orcish Warrior,Wolf Rider,Goblin Impaler,Orcish Crossbowman,Goblin Knight
#endif
        [ai]
            #orc leader guarding front lines is more aggressive
            aggression=0.8
            caution=0.1

#ifdef EASY
            recruitment_pattern=scout,scout,fighter,fighter,archer
#endif
#ifdef NORMAL
            recruitment_pattern=scout,scout,fighter,fighter,fighter,archer
#endif
#ifdef HARD
            recruitment_pattern=scout,scout,fighter,fighter,archer,fighter
#endif
        [/ai]
        {FLAG_VARIANT ragged}
    [/side]

    # this orc tribe specialized in ranged combat
    [side]
        side=3
        id=Turg
        name= _ "Turg"
#ifdef EASY
        type=Orcish Warrior
#else
        type=Orcish Warlord
#endif
        canrecruit=yes

        {INCOME 1 3 5}
        {GOLD 75 100 125}
        controller=ai
        shroud=no
        fog=no
        team_name=evil
        user_team_name=_"Evil"
#ifdef EASY
        recruit=Orcish Grunt,Wolf Rider,Orcish Archer,Orcish Assassin,Orcish Crossbowman
#endif
#ifdef NORMAL
        recruit=Orcish Grunt,Wolf Rider,Orcish Archer,Orcish Crossbowman,Orcish Slayer,Orcish Warrior
#endif
#ifdef HARD
        recruit=Orcish Warrior,Wolf Rider,Orcish Crossbowman,Orcish Slayer
#endif

        [ai]
            aggression=0.5
            recruitment_pattern=scout,fighter,archer,fighter,archer,mixed fighter

#ifdef EASY
            recruitment_pattern=scout,fighter,archer,fighter,fighter,mixed fighter
#endif
        [/ai]
        {FLAG_VARIANT ragged}
    [/side]

    # this orc tribe specialized in melee combat
    [side]
        side=4
        id="Ug'lok"
        name= _ "Ug’lok"
#ifdef EASY
        type=Orcish Warrior
#else
        type=Orcish Warlord
#endif
        canrecruit=yes
        {INCOME 1 3 5}
        {GOLD 75 100 125}
        controller=ai
        shroud=no
        fog=no
        team_name=evil
        user_team_name=_"Evil"
#ifdef EASY
        recruit=Orcish Grunt,Wolf Rider,Orcish Archer,Orcish Assassin,Orcish Warrior
#endif
#ifdef NORMAL
        recruit=Orcish Warrior,Wolf Rider,Orcish Archer,Orcish Slayer,Orcish Crossbowman
#endif
#ifdef HARD
        recruit=Orcish Warrior,Wolf Rider,Orcish Crossbowman,Orcish Slayer
#endif

        [ai]
            aggression=0.5
            recruitment_pattern=scout,fighter,archer,fighter,archer,mixed fighter
        [/ai]
        {FLAG_VARIANT ragged}
    [/side]

    # assassin's side
    [side]
        side=5
        no_leader=yes
        controller=ai
        shroud=no
        fog=no
        team_name=evil
        user_team_name=_"Evil"

        [ai]
            aggression=1.0
            caution=0.0
            [goal]
                name=target
                [criteria]
                    id=Kaleh
                [/criteria]
                value=1000
            [/goal]
        [/ai]
    [/side]

    {UTBS_INCLUDE utils/dialog-macros.cfg}

    # Prestart functions:
    # set scenario objectives
    # increase cost of recruiting units
    # recall main heroes
    # initialize starting variables
    # added extra NW bridge in EASY
    # randomly close one of the two exit tunnels at north of map
    # if EASY open up NW cave entrance bottleneck
    # give side 3 (green) control of cave villages
    # place features on map
    # increase speed of goblin knight Panok

    [event]
        name=prestart

        [objectives]
            summary= _ "Objectives:"
            [objective]
                description= _ "Kaleh must reach the exit tunnel at the north edge of the map"
                condition=win
            [/objective]

            [objective]
                description= _ "Death of Kaleh"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Nym"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Zhul"
                condition=lose
            [/objective]

            [gold_carryover]
                bonus=yes
                carryover_percentage=40
            [/gold_carryover]
        [/objectives]

        #recall heroes
        [unit]
            {NYM}
            placement=leader
        [/unit]

        [unit]
            {ZHUL}
            placement=leader
        [/unit]

        [recall]
            id=Elyssa
        [/recall]

        #initialize variables
        [set_variable]
            name=naga_ambush
            value=0
        [/set_variable]

        #close one of the two northern tunnels
        {RANDOM 1..10}

        [if]
            [variable]
                name=random
                less_than_equal_to=5
            [/variable]
            [then]
                #Western tunnel
                #to cavewall: 10,4

                [terrain]
                    x=10
                    y=4
                    terrain=Xu
                [/terrain]
            [/then]

            [else]
                #Eastern tunnel
                #to cavewall: 25,4 25,6 26,6 also 26,5 24,4
                #to shallow water 25,5

                [terrain]
                    x=24,25,25,26,26
                    y=4,4,6,5,6
                    terrain=Xu
                [/terrain]

                [terrain]
                    x=25
                    y=5
                    terrain=Wwg
                [/terrain]
            [/else]
        [/if]

        #on EASY difficulty, weaken orcs by deleting 2 towns
#ifdef EASY
        [terrain]
            x= 4,23
            y=19,11
            terrain=Uu
        [/terrain]
#endif

        # green (side 4) should control southern 4 cave villages at start
        # 2,15 4,19 6,17 9,16
        [capture_village]
            side=3
            x= 2, 4, 6, 9
            y=15,19,17,16
        [/capture_village]

        #side 1 (player) controls two villages at start
        [capture_village]
            side=1
            x=33,39
            y=39,38
        [/capture_village]

        {PLACE_IMAGE items/orcish-flag.png 36 33}
        {PLACE_IMAGE items/orcish-flag2.png 30 33}
        {PLACE_IMAGE items/orcish-flag.png 30 37}

        {PLACE_IMAGE items/orcish-flag2.png 31 16}
        {PLACE_IMAGE items/orcish-flag2.png 33 16}
        {PLACE_IMAGE items/orcish-flag.png 10 25}
        {PLACE_IMAGE items/orcish-flag.png 11 24}

        {PLACE_IMAGE scenery/signpost.png 7 1}

        #increase max moves by 1 (game engine will increase current moves to match)
        [object]
            id=FastGoblinKnight
            silent=yes

            [effect]
                apply_to=movement
                increase=1
            [/effect]

            [filter]
                id=Panok
            [/filter]
        [/object]

        # show the area outside the cave if the player found the map last scenario
        [if]
            [variable]
                name=sneak_up
                equals=1
            [/variable]
            [then]
                [remove_shroud]
                    [not]
                        time_of_day_id=underground
                    [/not]
                    radius=1
                    side=1
                [/remove_shroud]
            [/then]
        [/if]

        {CLEAR_VARIABLE sneak_up}
    [/event]

    # starting dialogue
    [event]
        name=start

        [message]
            speaker=Nym
            message= _ "Those mountains are huge! I never thought they would be so big. And what’s that white stuff on the tops of the peaks?"
        [/message]

        [message]
            speaker=Zhul
            message= _ "I wish Garak were here, he’d know more about these lands than I do. I’ve never been up here, but I heard stories from the few who have made the journey and returned. That white stuff is called snow, Nym, and the mountains are very cold. These smaller hills aren’t as hard to cross, but they are filled with orcs and goblins. It may look peaceful now, but they hide in the many caves and tunnels beneath the surface."
        [/message]

        [message]
            speaker=Kaleh
            message= _ "I had another vision last night, Eloh told me that we had to continue north, but instead of trying to go over the mountains, she said that we had to go underneath them."
        [/message]

        [message]
            speaker=Nym
            message= _ "Underneath them? But how?"
        [/message]

        [message]
            speaker=Zhul
            message= _ "Orcs and Goblins have been living here for hundreds of years and their network of tunnels and caves is more extensive than you might think. Who knows how far they go underground? We are ill-prepared for trekking over those frozen peaks. As much as I dislike those pitch-black caves, if we want to cross these mountains we may have no choice."
        [/message]

        [message]
            speaker=Elyssa
            message= _ "Other creatures besides orcs dig tunnels in the earth. Long ago dwarves mined mountains such as these, and huge trolls like to hide in the deep dark places under the earth. If your god is as omniscient as you seem to think, Kaleh, I wouldn’t be surprised if there were a way to cross under these mountains. I fear no darkness, and you won’t be lacking a source of fire or light."
        [/message]

        [message]
            speaker=Nym
            message= _ "Well if we are going to go under these mountains, we’re certainly going to have our hands full fighting all those orcs and goblins."
        [/message]

        [message]
            speaker=Zhul
            message= _ "Indeed. I want to warn you again, Kaleh, this isn’t the desert. The orcs love fighting in hills and caves, and we won’t have the advantages of fighting on the open sands. And with our recent losses we don’t have the numerical advantage we are used to. So we’d best be extra careful. Still if we can clear a path in the hills ahead of us, we should be able to escort our people into the tunnels. And hopefully underground it will be easier to protect them than out in the open."
        [/message]

        [message]
            speaker=Kaleh
            message= _ "Strike hard and fast and also be careful—right, this is going to be fun."
        [/message]
    [/event]

    # underground area should always have "underground" time,
    [time_area]
        x= 0-2,   3,   4,   5,   6,   7,   8,   9,  10,  11,12-13,14-15,16-17,18-21,22-25,26-31,  32,  33,34-38,39-41
        y=0-41,0-37,0-34,0-32,0-31,0-29,0-28,0-26,0-23,0-22, 0-21, 0-20, 0-19, 0-18, 0-17, 0-15,0-14,0-15, 0-14, 0-15
        {UNDERGROUND}
    [/time_area]

    # Event 1: goblins appear in nearby foothills

    # ambushes player at start of player’s turn after player invades hills

    [event]
        name=moveto

        [filter]
            x=30-40,23-31
            y=28-35,30-40
            side=1
        [/filter]

        [event]
            name=side 1 turn

            #If Easy: 5 goblins

            {NAMED_NOTRAIT_UNIT 2 (Goblin Spearman) 28 37 (Goblin Coward) ( _ "Goblin Coward")}
            {NAMED_NOTRAIT_UNIT 2 (Goblin Spearman) 29 33 (Goblin Scout) ( _ "Goblin Scout")}
            {NAMED_NOTRAIT_UNIT 2 (Goblin Spearman) 38 31 () ( _ "Goblin Scout")}
            {NAMED_NOTRAIT_UNIT 2 (Goblin Spearman) 37 34 () ( _ "Goblin Scout")}
            {NAMED_NOTRAIT_UNIT 2 (Goblin Spearman) 30 38 () ( _ "Goblin Scout")}

#ifndef EASY
            #If Medium: +3 goblins (8)

            {NAMED_NOTRAIT_UNIT 2 (Goblin Spearman) 26 35 () ( _ "Goblin Scout")}
            {NAMED_NOTRAIT_UNIT 2 (Goblin Spearman) 33 32 () ( _ "Goblin Scout")}
            {NAMED_NOTRAIT_UNIT 2 (Goblin Spearman) 27 32 () ( _ "Goblin Scout")}

            #If Hard: +3 goblins (11)
#ifdef HARD
            {NAMED_NOTRAIT_UNIT 2 (Goblin Spearman) 29 36 () ( _ "Goblin Scout")}
            {NAMED_NOTRAIT_UNIT 2 (Goblin Spearman) 33 34 () ( _ "Goblin Scout")}
            {NAMED_NOTRAIT_UNIT 2 (Goblin Spearman) 31 31 () ( _ "Goblin Scout")}

#endif

#endif

            [message]
                speaker=Goblin Scout
                message= _ "Attack!"
            [/message]

            [message]
                speaker=Goblin Coward
                message= _ "Run away!"
            [/message]

            [message]
                speaker=Zhul
                message= _ "Goblins are so predictable."
            [/message]
        [/event]
    [/event]

    # Event 2: naga appear around western guardpost

    # when player approches western guardpost have a few goblins jump out of
    # the eastern hills, and a naga or three appear in the lake

    # Easy:
    # 1 orcish assassin 23,33
    # 3 naga fighters: 20,34 19,33 20,35
    # 2 goblins spearmen: 23,32 24,32 24,33

    # Medium: 1 orcish slayer, 2 goblin impalers, 1 naga warrior, 2 naga fighters
    # Hard: 1 orcish slayer, 2 goblin impalers, 3 naga warriors

#define NAGA_ATTACK

    #1 orcish assassin/slayer summons/leads any goblins

#ifdef EASY
    {NAMED_NOTRAIT_UNIT 2 (Orcish Assassin) 24 32 (Orac) ( _ "Orac")}
#else
    {NAMED_NOTRAIT_UNIT 2 (Orcish Slayer) 24 32 (Orac) ( _ "Orac")}
#endif

    #2 nagas appear at edge of lake

#ifdef EASY
    {NAMED_NOTRAIT_UNIT 2 (Naga Fighter) 20 34 (Scylla) ( _ "Scylla")}
#else
    {NAMED_NOTRAIT_UNIT 2 (Naga Warrior) 20 34 (Scylla) ( _ "Scylla")}
#endif
    #hack to make Scylla female
    [+unit]
        gender=female
    [/unit]

#ifdef HARD
    {NAMED_NOTRAIT_UNIT 2 (Naga Warrior) 19 34 () ( _ "Lake Naga")}
    {NAMED_NOTRAIT_UNIT 2 (Naga Warrior) 20 35 () ( _ "Lake Naga")}
#else
    {NAMED_NOTRAIT_UNIT 2 (Naga Fighter) 19 34 () ( _ "Lake Naga")}
    {NAMED_NOTRAIT_UNIT 2 (Naga Fighter) 20 35 () ( _ "Lake Naga")}
#endif

    [set_variable]
        name=naga_ambush
        value=1
    [/set_variable]

#enddef

    [event]
        name=moveto

        [filter]
            x=17-24
            y=29-36
            side=1
        [/filter]

        [filter_condition]
            [variable]
                name=naga_ambush
                numerical_equals=0
            [/variable]
        [/filter_condition]

        {NAGA_ATTACK}

#ifdef EASY
        {NAMED_NOTRAIT_UNIT 2 (Goblin Spearman) 24 31 () ( _ "Goblin Scout")}
        {NAMED_NOTRAIT_UNIT 2 (Goblin Spearman) 25 33 () ( _ "Goblin Scout")}
#else
        {NAMED_NOTRAIT_UNIT 2 (Goblin Impaler) 24 31 () ( _ "Goblin Scout")}
        {NAMED_NOTRAIT_UNIT 2 (Goblin Impaler) 25 33 () ( _ "Goblin Scout")}
#endif

        [message]
            speaker=Orac
            message= _ "Come forth, creatures of the lake! Fulfill the oaths you have made and help us drive these hated creatures from our lands."
        [/message]

        [message]
            speaker=Scylla
            message= _ "Sssslay them all! In the name of the Ssscaled One!" # wmllint: no spellcheck
        [/message]
    [/event]

    #Event 3: The Goblin and The Ring (and maybe the Naga)

    # When the elves fight Panok they notice how fast he is
    [event]
        name=attack

        [filter]
            side=1
        [/filter]

        [filter_second]
            id=Panok
        [/filter_second]

        [message]
            speaker=Panok
            message= _ "These elves are stronger than we thought. Send for more reinforcements!"
        [/message]

        [message]
            speaker=Kaleh
            message= _ "How can he move that fast? He is faster than any goblin rider I have ever seen. It’s almost unnatural."
        [/message]
    [/event]

    # When Panok dies player gets ring and naga ambush is triggered if it
    # hasn't been already
    [event]
        name=last breath

        [filter]
            id=Panok
        [/filter]

        [message]
            speaker=Panok
            message= _ "Gaaghh!!" # wmllint: no spellcheck
        [/message]

        [kill]
            id=Panok
            animate=yes
        [/kill]

        {PLACE_IMAGE items/ring-silver.png $x1 $y1}

        {CHECK_SPEAKER}
        [message]
            speaker=$speaking_unit.id
            message= _ "Wait a minute. He was wearing a silver ring on one of his fingers. I think the ring might be magical. Maybe that’s why he was moving so fast."
        [/message]
        {CLEAR_VARIABLE speaking_unit}

        [message]
            speaker=Nym
            message= _ "I think, Kaleh, that you should take the ring."
        [/message]

        [message]
            speaker=Kaleh
            message= _ "Why me?"
        [/message]

        [message]
            speaker=Nym
            message= _ "Because you tend to move slowly and if we’re going into the caves you’ll need all the speed you can get. And besides, we can’t afford to lose you; you never know when being able to run a bit faster might be the difference between life and death."
        [/message]

        # Get Ring event
        [event]
            name=moveto
            id=take_ring
            delayed_variable_substitution=no
            first_time_only=no

            [filter]
                x=$x1
                y=$y1
                side=1
                [not]
                    type=Dust Devil
                [/not]
            [/filter]

            [message]
                speaker=unit

                message= _ "Should I take this ring?"
                [option]
                    message= _ "Yes, I’ll take it."

                    [command]
                        [object]
                            id=SpeedyRing
                            name= _ "Ring of Speed"
                            image=items/ring-gold.png
                            description= _ "This ring will increase your maximum speed by 1."
                            [filter]
                                x=$x1
                                y=$y1
                                side=1
                            [/filter]

                            [effect]
                                apply_to=movement
                                increase=1
                            [/effect]
                        [/object]

                        [remove_item]
                            x=$x1
                            y=$y1
                        [/remove_item]

                        [event]
                            id=take_ring
                            remove=true
                        [/event]
                    [/command]
                [/option]

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

                    [command]
                        [allow_undo]
                        [/allow_undo]
                    [/command]
                [/option]
            [/message]
        [/event]

        #when Panok dies, if player hasn't triggered naga ambush, then units attack

#ifndef EASY
        [if]
            [variable]
                name=naga_ambush
                numerical_equals=0
            [/variable]

            [then]
                {NAGA_ATTACK}

                [message]
                    speaker=Orac
                    message= _ "The elves have killed Panok the goblin! The other goblins may flee to the caves, but we will not give up these hills without a fight. Come forth, creatures of the lake! Fulfill the oaths you have made and help us drive these hated creatures from our lands."
                [/message]

                [message]
                    speaker=Scylla
                    message= _ "Sssslay them all! In the name of the Ssscaled One!" # wmllint: no spellcheck
                [/message]
            [/then]
        [/if]
#endif
    [/event]

    # Event 4: elvish unit afraid when entering underground tunnels
    [event]
        name=moveto

        [filter]
            [filter_location]
                time_of_day_id=underground
            [/filter_location]
            side=1
        [/filter]

        [allow_undo]
        [/allow_undo]

        {CHECK_EXPLORER}
        [message]
            speaker=$explorer.id
            message= _ "Ugh! These tunnels are pitch black! It’s as bad as fighting in a moonless night, and it stinks of orc filth. I can hardly think of a place I would less like to go into."
        [/message]
        {CLEAR_VARIABLE explorer}

        [message]
            speaker=Kaleh
            message= _ "We have no choice. We cannot cross over these mountains, so we must go beneath them. If the orcs skulk in their tunnels and block our way, we must enter their dark places and fight them, no matter what the conditions."
        [/message]

        [message]
            speaker=Zhul
            message= _ "Remember, Kaleh, it’s nasty fighting underground. Marksmen and Sharpshooters who can shoot well anywhere will be invaluable, as will Captains and Marshals who can inspire our people."
        [/message]

        [message]
            speaker=Elyssa
            message= _ "Also, any time you find a particularly tough orc blocking a passage, my fireballs can blast him quick enough."
        [/message]
    [/event]

    # Event 5: Goblin guards a chest in NE corner of map

    [event]
        name=moveto

        [filter]
            x=31-37
            y=6-9
            side=1
        [/filter]

        {NAMED_NOTRAIT_UNIT 4 (Goblin Impaler) 35 7 (Greebo) ( _ "Greebo")}

        {PLACE_IMAGE items/chest-plain-closed.png 35 6}

        [message]
            speaker=Greebo
            # wmllint: local spelling shinies orcses
            message= _ "Greebo keeps shinies safe from nasty orcses. And ’specially stinking elves."
        [/message]
    [/event]

    # Chest contains gold for player

    [event]
        name=moveto

        [filter]
            x=35
            y=6
            side=1
        [/filter]

        {PLACE_IMAGE items/chest-plain-open.png 35 6}

        [sound]
            name=gold.ogg
        [/sound]

        {CHECK_EXPLORER}
        [message]
            speaker=$explorer.id
            message= _ "Looks like he’s been squirreling away his stolen loot in this cave. Not that he had much. Must be hard times."
        [/message]
        {CLEAR_VARIABLE explorer}

        [gold]
            amount={ON_DIFFICULTY 80 60 40}
            side=1
        [/gold]
    [/event]

    #Event 6: Cold dagger

    [event]
        name=moveto
        id=find_dagger
        first_time_only=no

        [filter]
            x=12
            y=16
            side=1
            [not]
                type=Dust Devil
            [/not]
        [/filter]

        [message]
            speaker=unit
            message= _ "How odd. Someone has carved a crude fountain out of the stone at the end of the passage. The freezing water pours out into a large pool. At the bottom of the pool I can see a skeleton still gripping a sword. The blade seems to glow faintly blue. The pool isn’t very deep, I could easily wade in and pick it up. But someone else has carved a crude message in the wall. <i>“If you dare to take this blade here, your greatest fear will surely appear.”</i> It looks like a nice sword, but do I dare chance it?"
            [option]
                message= _ "I fear no creature, I will take the blade!"
                [command]
                    [message]
                        speaker=unit
                        message= _ "The blade is chill to the touch and gives off a cold glow. I wonder how it came to be here."
                    [/message]

                    [object]
                        [filter]
                            x=12
                            y=16
                            side=1
                        [/filter]

                        id=ColdBlade
                        name= _ "Cold Blade"
                        description= _ "The unit who wields this blade will deal cold damage with its melee attack."

                        [effect]
                            apply_to=attack
                            range=melee
                            set_type=cold
                        [/effect]
                    [/object]

                    {NAMED_NOTRAIT_UNIT 3 (Dawarf) 14 15 (Purple Abomination) ( _ "Purple Abomination")}

                    [message]
                        speaker=Purple Abomination
                        message= _ "I am an abomination, please kill me."
                    [/message]

                    [message]
                        speaker=unit
                        message= _ "I’ve seen some ugly creatures in my day, but that thing is just wrong."
                    [/message]

                    [message]
                        speaker=Purple Abomination
                        message= _ "The voices say I have no choice, I must attack!"
                    [/message]

                    [event]
                        id=find_dagger
                        remove=true
                    [/event]
                [/command]
            [/option]

            [option]
                message= _ "I don’t like the sound of this. I’m out of here."
            [/option]
        [/message]
    [/event]

    #Event 7: End of the River

    [event]
        name=moveto

        # Dust devil is supposed to be mute. This isn't like the other cases,
        # where Nym could plausibly speak the line, so we just don't trigger the event.
        [filter]
            x=3
            y=10
            side=1
            [not]
                type=Dust Devil
            [/not]
        [/filter]

        [allow_undo]
        [/allow_undo]

        [message]
            speaker=$unit.id
            message= _ "This is the end of the line. The water is too deep for me to continue any further. I’m freezing cold, wet, and I can’t see a thing. I’m not exactly sure what I’m doing up here. Some strange influence made me want to come up here, but I don’t know what made me think it could be of any good."
        [/message]
    [/event]

    # Event 8: Enter the Assassin/Cloaked Figure (same guy, two names)

    # When Kaleh enters one of the caves, the cloaked figure pops up next turn
    # and attacks in a dramatic manner

    [event]
        name=moveto

        [filter]
            id=Kaleh
            [filter_location]
                time_of_day_id=underground
            [/filter_location]
        [/filter]

        [event]
            # Find the location of Kaleh and then find an adjacent
            # hex the cloaked figure can pop up in. (any hex that is not impassable)
            name=new turn

            [store_locations]
                [filter]
                    id=Kaleh
                [/filter]

                variable=dark_assassin_location
            [/store_locations]

            [unit]
                type=Dark Assassin1
                id=Cloaked Figure
                name= _ "Cloaked Figure"
                side=5
                x,y=$dark_assassin_location.x,$dark_assassin_location.y
                placement=map_passable
                [modifications]
                    {TRAIT_INTELLIGENT}
                    {TRAIT_RESILIENT}
                [/modifications]
            [/unit]
            {CLEAR_VARIABLE dark_assassin_location}

            [delay]
                time=200
            [/delay]

            [message]
                speaker=Cloaked Figure
                image=portraits/cloaked.png
                message= _ "Kaleh, I am death incarnate."
            [/message]

            [message]
                speaker=Cloaked Figure
                image=portraits/cloaked.png
                message= _ "And I shall avenge all those you have killed!"
            [/message]
        [/event]
    [/event]

    # Death event for dark assassin

    [event]
        name=last breath

        [filter]
            id=Cloaked Figure
        [/filter]

        [message]
            speaker=Cloaked Figure
            message= _ "I promise we shall meet again."
        [/message]

        [kill]
            id=Cloaked Figure
            animate=no
            fire_event=no
        [/kill]

        [message]
            speaker=Kaleh
            message= _ "He just disappeared. That’s odd."
        [/message]
    [/event]

    #Event 10: victory if Kaleh moves to north edge of map

    [event]
        name=moveto

        [filter]
            y=1
            side=1
            id=Kaleh
        [/filter]

        [endlevel]
            result=victory
            bonus=yes
            {NEW_GOLD_CARRYOVER 40}
        [/endlevel]
    [/event]

    #victory event
    [event]
        name=victory

        [message]
            speaker=Kaleh
            message= _ "This passage seems different from the other tunnels and caves. It is wide and smooth and leads sharply downwards. I bet this was the way that Eloh was talking about."
        [/message]

        [message]
            speaker=Elyssa
            message= _ "This is no natural passage, and the walls are too well carved and smooth to be made by orcs. I wouldn’t be surprised if this was once carved out by dwarves. I wonder if there are any still left in these mountains..."
        [/message]

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

            [then]
                [message]
                    speaker=Zhul
                    message= _ "Having killed all the orc and goblin leaders in the immediate vicinity, we can take our time and should have no trouble bringing the rest of our people down this way. It’s odd, I guess we’re trading the dangers we know for the dangers we don’t. We really are putting our lives in Eloh’s palm; may she guide us as well as she has before."
                [/message]
            [/then]

            [else]
                [message]
                    speaker=Zhul
                    message= _ "Now that you’ve found the way we should be able to get the rest of our people past the orcs. It’s odd, I guess we’re trading the dangers we know for the dangers we don’t. We really are putting our lives in Eloh’s palm, may she guide as well as she has before."
                [/message]
            [/else]
        [/if]

        [message]
            speaker=Nym
            message= _ "I’ll just be happy when I can breathe fresh air again and see the suns and stars. Still, who knows what we’ll encounter deep under the earth?"
        [/message]

        [message]
            speaker=Kaleh
            message= _ "Well, there’s only one way to find out."
        [/message]

        {CLEAR_VARIABLE naga_ambush}
    [/event]

    # if player runs out of time, display time over message
    [event]
        name=time over
        [message]
            speaker=Kaleh
            message= _ "We’ve taken too long to get our people into the tunnels! Even more orcs are coming across the foothills from the east and west and flanking us. There’s no way we can kill all these orcs and goblins. We’ll never make it to safety now."
        [/message]
    [/event]

    {UTBS_INCLUDE utils/kaleh-abilities.cfg}
    {UTBS_INCLUDE utils/deaths.cfg}
[/scenario]
