#textdomain wesnoth-sof
[scenario]
    name= _ "Towards the Caves"
    id=6_Towards_the_Caves
    turns=12
    map_data="{campaigns/Sceptre_of_Fire/maps/6_Towards_the_Caves.map}"
    next_scenario=7_Outriding_the_Outriders

    {SCENARIO_MUSIC breaking_the_chains.ogg}
    {EXTRA_SCENARIO_MUSIC the_king_is_dead.ogg}
    {EXTRA_SCENARIO_MUSIC battle.ogg}

    {DEFAULT_SCHEDULE}

    [side]
        type=Dwarvish Fighter
        id=Rugnur
        side=1
        canrecruit=yes
        controller=human
        recruit=Dwarvish Fighter,Dwarvish Thunderer,Dwarvish Guardsman,Dwarvish Scout,Gryphon Rider
        gold=200
        team_name=dwarves
        user_team_name= _ "Dwarves"
        {FLAG_VARIANT knalgan}
    [/side]

    # Rugnur starts with all villages within the captured Shorbear keep.
    # Elves will start munching on them fairly soon.
    {STARTING_VILLAGES 1 6}

    [side]
        type=Elvish Marshal
        id=Gaenlar
        name= _ "Gaenlar"
        side=2
        canrecruit=yes
        recruit=Elvish Rider,Elvish Hero,Elvish Marksman,Elvish Ranger,Elvish Druid
        {GOLD 300 350 400}
        team_name=elves
        user_team_name= _ "Elves"
        [ai]
            [protect_location]
                x,y=36,3
                radius=10
                value=100
            [/protect_location]
            [target]
                type=Gryphon,Gryphon Rider,Gryphon Master
                value=10
            [/target]
            [target]
                id=Alanin
                value=2
            [/target]
            [target]
                race=dwarf
                value=1
            [/target]
        [/ai]
        {FLAG_VARIANT long}
    [/side]

    {STARTING_VILLAGES 2 12}

    [side]
        type=Elvish Marshal
        id=Glinan
        name= _ "Glinan"
        side=3
        canrecruit=yes
        recruit=Elvish Rider,Elvish Hero,Elvish Marksman,Elvish Ranger,Elvish Druid

        {GOLD 250 300 350}
        team_name=elves
        user_team_name= _ "Elves"
        [ai]
            [protect_location]
                x,y=36,3
                radius=10
                value=100
            [/protect_location]
            [target]
                race=dwarf
                value=10
            [/target]
            [avoid]
                x=1-18
                y=1-38
            [/avoid]
        [/ai]
        {FLAG_VARIANT long}
    [/side]

    {STARTING_VILLAGES 3 8}
    {STARTING_VILLAGES_AREA 3 34 10 8}

    [side]
        type=Elvish Captain
        id=Kalnar
        name= _ "Kalnar"
        side=4
        canrecruit=yes
        recruit=Elvish Scout,Elvish Fighter,Elvish Archer,Elvish Shaman
        {GOLD 150 200 250}
        team_name=elves
        user_team_name= _ "Elves"
        [ai]
            [target]
                id=Alanin
                value=10
            [/target]
            [target]
                race=dwarf
                value=1
            [/target]
        [/ai]
        {FLAG_VARIANT long}
    [/side]

    {STARTING_VILLAGES 4 11}

    [story]
        [part]
            story= _ "Durstorn’s rash action led to many problems. Not the least of which was being surrounded by elves."
        [/part]
        [part]
            story= _ "The dwarves spent several years trapped in those caves, the elves besieging them. The dwarves could not leave, for there were far too many elves, and there was no way out of the caverns other than above ground. But the elves could not enter, for the magical dwarven gates were closed."
        [/part]
        [part]
            story= _ "During this time, Thursagan crafted the Sceptre of Fire, first cutting the jewel, then putting it, the gold and the cold steel into the heat of the flame. The sceptre was crafted, but something was not right. No matter what enchantment of runes he put on the Sceptre, it did not fulfill its original purpose."
        [/part]
        [part]
            show_title=yes
            {TO_TOWARDS_THE_CAVES}
        [/part]
    [/story]

    {SOF_DEATHS}

    [event]
        name=prestart

        # {SCATTER_IMAGE (terrain=Gg) 2 scenery/snowbits.png}
        # {SCATTER_IMAGE (terrain=Gg) 6 scenery/pine1.png}

        [objectives]
            side=1
            [objective]
                description= _ "Move Rugnur to the northeast cave entrance"
                condition=win
            [/objective]
            [objective]
                description= _ "Move Alanin to the southern border east of the river"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Rugnur"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Alanin"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Krawg"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Thursagan"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

            [gold_carryover]
                bonus=no
                carryover_percentage=40
            [/gold_carryover]
        [/objectives]
    [/event]

    [event]
        name=start
        #alanin, baglur, krawg and thursagan
        [recall]
            id=Thursagan
            x,y=18,16
        [/recall]
        [recall]
            id=Durstorn
            x,y=19,16
        [/recall]
        [recall]
            id=Alanin
        [/recall]
        [recall]
            id=Baglur
        [/recall]
        [recall]
            id=Krawg
        [/recall]
        #dialogue starts
        [message]
            speaker=Rugnur
            message= _ "Well, Thursagan has reached a conclusion. He can’t make the sceptre with the materials he has here, but he has the final plans for it, and all the jewels and gold he needs. Shouldn’t we leave now?"
        [/message]
        [message]
            speaker=Durstorn
            message= _ "All this time and he couldn’t make it? Fine, we should try to leave... but it’s not like we could leave if we wanted to. We’re surrounded!"
        [/message]
        [if]
            [have_unit]
                id=Baglur
            [/have_unit]
            [then]
                [message]
                    speaker=Baglur
                    message= _ "If ye’ll permit me to say so, sir, ye’re wrong. We could—"
                [/message]
                [message]
                    speaker=Durstorn
                    message= _ "Shut up, Baglur! You don’t know what you’re talking about. I’ve analyzed the situation, and we’re doomed. Our best hope is to surrender. Perhaps if we give the elves the plans for the Sceptre of Fire they will let us survive."
                [/message]
            [/then]
            [else]
                [message]
                    speaker=Rugnur
                    message= _ "If you’ll permit me to say so, sir, you’re wrong. We could —"
                [/message]
                [message]
                    speaker=Durstorn
                    message= _ "Shut up, Rugnur! You don’t know what you’re talking about. I’ve analyzed the situation, and we’re doomed. Our best hope is to surrender. Perhaps if we give the elves the plans for the Sceptre of Fire they will let us survive."
                [/message]
            [/else]
        [/if]
        [message]
            speaker=Rugnur
            message= _ "Yes, of course, let’s just all be cowards! What happened to your honor, Durstorn?!"
        [/message]
        [message]
            speaker=Durstorn
            message= _ "You little fool, honor is less important than life! So, I’m ordering Thursagan to give the plans and the ruby to the elves, as a peace offering. Then maybe we’ll walk out of here alive."
        [/message]
        [message]
            speaker=Thursagan
            message= _ "You don’t have authority over me, Durstorn. And I wouldn’t give the Sceptre to them even if you did. It’s not yours to give, its mine, and Rugnur’s, and Baglur’s. Krawg’s done more for its existence than you have! And yet, you still get the profits from selling it to Haldric."
        [/message]
        [message]
            speaker=Durstorn
            message= _ "So what, all of you want to die? Fine by me, but I won’t die with you! And if you won’t give the Sceptre to the elves, I’ll take it from you!"
        [/message]
        [animate_unit]
            flag=attack

            [filter]
                id=Durstorn
            [/filter]

            [primary_attack]
                name=battle axe
            [/primary_attack]

            hits=no
            text= _ "<i>Swoosh!</i>"
            red=255
            green=0
            blue=0

            [facing]
                [filter]
                    id=Thursagan
                [/filter]
            [/facing]

            [animate]
                flag=defend

                [filter]
                    id=Thursagan
                [/filter]

                hits=no

                [facing]
                    [filter]
                        id=Durstorn
                    [/filter]
                [/facing]
            [/animate]
        [/animate_unit]
        [message]
            speaker=Thursagan
            message= _ "Nice try, Durstorn, but you missed. Now, I’d say that attacking an ally constitutes treason, wouldn’t you?"
        [/message]
        [message]
            speaker=Durstorn
            message= _ "You’re not my ally. You’re more against me than the elves are; all they want is the ruby, but you want us dead!"
        [/message]
        [message]
            speaker=Rugnur
            message= _ "If that’s what you’re thinking, you’re not fit to be ruler over us! So step down, or we’ll force you."
        [/message]
        [message]
            speaker=Durstorn
            message= _ "Never!"
        [/message]
        [animate_unit]
            flag=attack

            [filter]
                id=Thursagan
            [/filter]

            [primary_attack]
                name=hammer
            [/primary_attack]

            hits=yes

            [facing]
                [filter]
                    id=Durstorn
                [/filter]
            [/facing]

            [animate]
                flag=defend

                [filter]
                    id=Durstorn
                [/filter]

                hits=yes
                text= _ "<i>Thud!</i>"
                red=255
                green=0
                blue=0

                [facing]
                    [filter]
                        id=Thursagan
                    [/filter]
                [/facing]
            [/animate]
        [/animate_unit]
        [kill]
            id=Durstorn
            animate=yes
        [/kill]
        #change music?
        [message]
            speaker=Rugnur
            message= _ "Well, I suppose we were right to silence him, but I don’t like this. In any case, now we should try to get out of here."
        [/message]
        [message]
            speaker=Thursagan
            message= _ "Yes. So, see the area to the northeast of us?"
        [/message]
        [scroll_to]
            x,y=36,3
        [/scroll_to]
        [delay]
            time=1000
        [/delay]
        [message]
            speaker=Thursagan
            message= _ "That’s where there are the least elvish guards, so we have the greatest chance of success there. I think we should try to get to it."
        [/message]
        [message]
            speaker=Alanin
            message= _ "This plan, it isn’t worse than staying here to be killed, but it isn’t likely to succeed either. Even if it does, what will it accomplish? We will be cornered there."
        [/message]
        [message]
            speaker=Thursagan
            message= _ "I don’t know if we will be cornered. That cave looks like it goes deep, and we can lose the elves in the caves, they move so slow there. Once we get out, we’ll make our way back to Knalga."
        [/message]
        [message]
            speaker=Rugnur
            message= _"The country between here and Knalga will be swarming with elves. We had better head back to the abandoned mines north of the Arkan-thoria, where we gathered our gold and coal. At least there Alanin will have some hope of finding us."
        [/message]
        [message]
            speaker=Alanin
            message= _ "That’s fine for you, you can run fast in caves, but I can’t! What am I supposed to do?"
        [/message]
        [message]
            speaker=Rugnur
            message= _ "Well, you are a member of the Wesnothian army. Why don’t you rejoin it? See if you can run past those elves to our southeast..."
        [/message]
        [scroll_to]
            x,y=31,37
        [/scroll_to]
        [delay]
            time=1000
        [/delay]
        [message]
            speaker=Rugnur
            message= _ "... and then ride south until you reach one of your outposts."
        [/message]
        [message]
            speaker=Alanin
            message= _ "I’m not going to do that, its suicide! And in any case, I’ve been with you for ten years, almost as long as I was in the Wesnothian army; I’d prefer to fight with you."
        [/message]
        [message]
            speaker=Thursagan
            message= _ "You going south has more of a chance of success for you than staying here or going back to the mines! And getting news to Haldric of what has happened is also the best way to get help to us."
        [/message]
        [message]
            speaker=Alanin
            message= _ "I suppose..."
        [/message]
        [message]
            speaker=Gaenlar
            message= _ "Come out, dwarves, and surrender! Or die in that cave, your choice."
        [/message]
    [/event]

    [event]
        name=turn 4
        [gold]
            side=2
            amount=200
        [/gold]
        [gold]
            side=3
            amount=200
        [/gold]
        [gold]
            side=4
            amount=200
        [/gold]
    [/event]

    [event]
        name=moveto
        [filter]
            id=Alanin
            x=22-40
            y=38
        [/filter]
        [if]
            [have_unit]
                id=Rugnur
            [/have_unit]
            [then]
                [message]
                    speaker=Rugnur
                    message= _ "Alanin, ride as fast as you can south. Tell Haldric we are heading northeast, towards the old eastern mines, and if he wants his precious sceptre he should send forces to meet us there as soon as he can!"
                [/message]
                [store_unit]
                    [filter]
                        id=Alanin
                    [/filter]
                    variable=alanin
                    kill=yes
                [/store_unit]
                {VARIABLE alanin.canrecruit yes}
                [objectives]
                    side=1
                    [objective]
                        description= _ "Move Rugnur to the northeast cave entrance"
                        condition=win
                    [/objective]
                    [objective]
                        description= _ "Death of Rugnur"
                        condition=lose
                    [/objective]
                    [objective]
                        description= _ "Death of Krawg"
                        condition=lose
                    [/objective]
                    [objective]
                        description= _ "Death of Thursagan"
                        condition=lose
                    [/objective]

                    {TURNS_RUN_OUT}

                    [gold_carryover]
                        bonus=no
                        carryover_percentage=40
                    [/gold_carryover]
                [/objectives]
            [/then]
            [else]
                [message]
                    speaker=Alanin
                    message= _ "I have made it past those elves, but they will chase me, and elvish horses are faster than mine."
                [/message]
                [store_unit]
                    [filter]
                        id=Alanin
                    [/filter]
                    variable=alanin
                    kill=yes
                [/store_unit]
                {VARIABLE alanin.canrecruit yes}
                [endlevel]
                    result=victory
                    bonus=no
                    {NEW_GOLD_CARRYOVER 40}
                [/endlevel]
            [/else]
        [/if]
    [/event]

    [event]
        name=moveto
        [filter]
            id=Rugnur
            x,y=36,3
        [/filter]
        [if]
            [have_unit]
                id=Alanin
            [/have_unit]
            [then]
                [message]
                    speaker=Alanin
                    message= _ "Rugnur, I am going south. What should I tell Haldric?"
                [/message]
                [message]
                    speaker=Thursagan
                    message= _ "Tell him to send forces north to aid us and fight the elves, but that we are probably going to die. We will run northeast towards the old eastern mines, and if he wants his sceptre intact he’d best send troops to meet us there."
                [/message]
                {MODIFY_UNIT id=Alanin canrecruit yes}
                [store_unit]
                    [filter]
                        side=1

                        [not]
                            id=Alanin
                        [/not]
                    [/filter]
                    variable=dwarves
                    kill=yes
                [/store_unit]
                [set_recruit]
                    side=1
                    recruit=
                [/set_recruit]
                [objectives]
                    side=1
                    [objective]
                        description= _ "Move Alanin to the southern border east of the river"
                        condition=win
                    [/objective]
                    [objective]
                        description= _ "Death of Alanin"
                        condition=lose
                    [/objective]

                    {TURNS_RUN_OUT}

                    [gold_carryover]
                        bonus=no
                        carryover_percentage=40
                    [/gold_carryover]
                [/objectives]
            [/then]
            [else]
                [message]
                    speaker=Rugnur
                    message= _ "I don’t know what is in these caves, but whatever it is can’t be worse than staying here to die."
                [/message]
                [store_unit]
                    [filter]
                        side=1

                        [not]
                            id=Alanin
                        [/not]
                    [/filter]
                    variable=dwarves
                    kill=yes
                [/store_unit]
                [endlevel]
                    result=victory
                    bonus=no
                    {NEW_GOLD_CARRYOVER 40}
                [/endlevel]
            [/else]
        [/if]
    [/event]

    [event]
        name=enemies defeated

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

    [event]
        name=victory

        # This [if] is used only in the case the player happened to defeat all
        # the enemy leaders and didn't move Alanin to the signpost
        [if]
            [have_unit]
                id=Alanin
            [/have_unit]

            [then]
                [store_unit]
                    [filter]
                        id=Alanin
                    [/filter]
                    variable=alanin
                    kill=yes
                [/store_unit]
                {VARIABLE alanin.canrecruit yes}
            [/then]
        [/if]

        [unstore_unit]
            variable=alanin
        [/unstore_unit]

        # Let's make Alanin invisible in linger mode, will be unhidden at the
        # start of the next scenario

        [hide_unit]
            x,y=$alanin.x,$alanin.y
        [/hide_unit]

        {CLEAR_VARIABLE alanin}

        [store_side]
            side=1
            variable=stored_Rugnur_side
        [/store_side]
    [/event]
[/scenario]
