#textdomain wesnoth-sof
[scenario]
    name= _ "Hills of the Shorbear Clan"
    id=5_Hills_of_the_Shorbear_Clan
    turns=24
    map_data="{campaigns/Sceptre_of_Fire/maps/5_Hills_of_the_Shorbear_Clan.map}"
    next_scenario=6_Towards_the_Caves

    # the music will change in the end of the opening dialogue
    {SCENARIO_MUSIC knolls.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"
        [village]
            x,y=5,2
        [/village]
        [village]
            x,y=10,1
        [/village]
        {FLAG_VARIANT knalgan}
    [/side]

    [side]
        type=Dwarvish Lord
        id=Glonoin
        name= _ "Glonoin"
        side=2
        canrecruit=yes
        {RECRUIT (Dwarvish Fighter,Dwarvish Steelclad,Dwarvish Thunderer,Dwarvish Guardsman) (Dwarvish Steelclad,Dwarvish Thunderguard,Dwarvish Thunderer,Dwarvish Guardsman) (Dwarvish Steelclad,Dwarvish Thunderguard,Dwarvish Thunderer,Dwarvish Stalwart,Dwarvish Pathfinder,Dwarvish Scout)}
        {GOLD 200 300 400}
        [ai]
            recruitment_pattern=fighter,fighter,fighter,mixed fighter
            aggression=-0.5
            caution=0.5
            village_value=0.1
            leader_value=0
            villages_per_scout=0
            grouping=defensive
            [goal]
                name=protect_unit
                [criteria]
                    side=2
                    canrecruit=yes
                [/criteria]
                protect_radius=4
                value=2
            [/goal]
        [/ai]
        team_name=enemies
        user_team_name= _ "Enemies"
        {FLAG_VARIANT knalgan}
    [/side]

    {STARTING_VILLAGES 2 6}

    [side]
        no_leader=yes
        side=3
        {RECRUIT (Elvish Ranger,Elvish Scout,Elvish Hero) (Elvish Ranger,Elvish Marksman,Elvish Scout,Elvish Hero) (Elvish Ranger,Elvish Marksman,Elvish Scout,Elvish Hero)}
        {GOLD 250 300 350}
        [ai]
            recruitment_pattern=scout,scout,fighter,archer
            turns=1-6
            aggression=1.0
            caution=0.1
            village_value=2
            leader_value=1
            grouping=no
            [goal]
                name=protect_unit
                [criteria]
                    side=3
                    canrecruit=yes
                [/criteria]
                value=0.5
            [/goal]
        [/ai]
        [ai]
            recruitment_pattern=fighter,fighter,archer
            turns=6-20
            aggression=0.5
            caution=0.2
            village_value=2
            grouping=offensive
            [goal]
                name=protect_unit
                [criteria]
                    side=3
                    canrecruit=yes
                [/criteria]
                value=1
            [/goal]
        [/ai]
        [ai]
            recruitment_pattern=fighter,fighter,archer,scout
            turns=20-24
            aggression=1.0
            caution=0
            village_value=0
            leader_value=10
            grouping=no
            [goal]
                name=protect_unit
                [criteria]
                    side=3
                    canrecruit=yes
                [/criteria]
                value=0
            [/goal]
        [/ai]
        team_name=enemies
        user_team_name= _ "Enemies"
        {FLAG_VARIANT wood-elvish}
    [/side]

    [story]
        [part]
            story= _ "All dwarves are known for a love of gold and a heart of stone. The Shorbears were no exception. They were crafters of crafters — they made tools. The best in the land. And they bartered well."
        [/part]
    [/story]

    {SOF_TRACK {JOURNEY_05_NEW} }

    {SOF_DEATHS}

    [label]
        x,y=19,17
        text= _ "Shorbear caves"
    [/label]

    [event]
        name=prestart
        [objectives]
            side=1
            [objective]
                description= _ "Defeat Glonoin, the Shorbear clan leader"
                condition=win
                [show_if]
                    [have_unit]
                        id=Glonoin
                    [/have_unit]
                [/show_if]
            [/objective]
            [objective]
                description= _ "Have all heroes, and no enemies, in the Shorbear caves"
                condition=win
                [show_if]
                    {VARIABLE_CONDITIONAL elves_come boolean_equals yes}
                [/show_if]
            [/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]
            [objective]
                description= _ "Death of Durstorn"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

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

    # wmllint: directory spelling Shorbear Shorbears
    [event]
        name=start
        #durstorn, noiraran and kuhnar
        [unit]
            x,y=11,1
            type=Dwarvish Lord
            id=Durstorn
            name= _ "Durstorn"
            unrenamable=yes
            side=1
            {IS_HERO}
            profile=portraits/durstorn-insane.png
            random_traits=no
            [modifications]
                {TRAIT_LOYAL}
            [/modifications]
        [/unit]
        [unit]
            x,y=11,1
            type=Dwarvish Thunderguard
            id=Noiraran
            name= _ "Noiraran"
            side=1
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_INTELLIGENT}
            [/modifications]
            {IS_LOYAL}
        [/unit]
        [unit]
            x,y=11,1
            type=Dwarvish Steelclad
            id=Kuhnar
            name= _ "Kuhnar"
            side=1
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_QUICK}
            [/modifications]
            {IS_LOYAL}
        [/unit]
        #alanin, baglur, krawg and thursagan
        [recall]
            id=Alanin
        [/recall]
        [recall]
            id=Baglur
        [/recall]
        [recall]
            id=Krawg
        [/recall]
        [recall]
            id=Thursagan
        [/recall]

        {MODIFY_UNIT id=Alanin profile "portraits/alanin-old.png~BLIT(portraits/alanin-winter-overlay.png,0,0)"}

        #dialogue starts
        [message]
            speaker=Kuhnar
            message= _ "Here we are; the hills of the Shorbear clan. What are we here for, anyway?"
        [/message]
        [message]
            speaker=Rugnur
            message= _ "If I understand it correctly, we’re here to bargain with the Shorbears, and arrange for us to use their tools to cut the ruby."
        [/message]
        [message]
            speaker=Thursagan
            message= _ "Exactly."
        [/message]
        [message]
            speaker=Durstorn
            message= _ "And I’ll be doing the talking; I remember what happened last time you negotiated a deal! We lost five thousand pieces of silver."
        [/message]
        [message]
            speaker=Glonoin
            message= _ "Och, it’s some o’ them cave-dwarves. What business do you have here?"
        [/message]
        [message]
            speaker=Durstorn
            message= _ "I’m Lord Durstorn, king of my tribe. I have been told you are great jeweler-workers, and so we come to rent some of your tools for a short time, a few years at most."
        [/message]
        [message]
            speaker=Glonoin
            message= _ "You’re a king?! Must be a pretty small kingdom for you to come yourself to bargain with us!"
        [/message]
        [message]
            speaker=Durstorn
            message= _ "You insult me! Do you want my business, or not?"
        [/message]
        [message]
            speaker=Glonoin
            message= _ "Well, fine, I’ll hear your offer."
        [/message]
        [message]
            speaker=Durstorn
            message= _ "We’d like to rent your best tools for a short period of time. We’ll only be cutting one jewel with it. My starting offer is two hundred silver."
        [/message]
        [message]
            speaker=Glonoin
            message= _ "It must be worth a lot for you to come this way and offer that much! How much are you going to sell it for, eh?"
        [/message]
        [message]
            speaker=Durstorn
            message= _ "That’s none of your concern!"
        [/message]
        [message]
            speaker=Glonoin
            message= _ "I’ll take twenty-five hundred, minimum."
        [/message]
        [message]
            speaker=Rugnur
            message={WHISPER _"Durstorn, that would be a quarter of all our profits!"}
        [/message]
        [message]
            speaker=Durstorn
            message= _ "I know that. Uh, Glonoin, how about five hundred?"
        [/message]
        [message]
            speaker=Glonoin
            message= _ "Twenty-three hundred is my lowest offer. I can tell I don’t need the money as much as you need the jewel cut!"
        [/message]
        [message]
            speaker=Durstorn
            message= _ "You must be mad! I’ll offer one thousand, but no higher!"
        [/message]
        [message]
            speaker=Glonoin
            message= _ "Two thousand, and I’ll go no lower!"
        [/message]
        [message]
            speaker=Rugnur
            message={WHISPER _"What are we going to do? We can’t go much higher!"}
        [/message]
        [message]
            speaker=Baglur
            message= {WHISPER _"Offer him fifteen hundred, but don’t go up, even if he refuses."}
        [/message]
        [message]
            speaker=Durstorn
            message= {WHISPER _"Bah! Getting this cut isn’t worth that much; what with Rugnur’s mistake earlier, and all the other expenses, if we pay more than a thousand we’ll barely even make a profit!"}
        [/message]
        [message]
            speaker=Thursagan
            message= {WHISPER _"So what are you going to do?"}
        [/message]
        [message]
            speaker=Durstorn
            message= {WHISPER _"Fight him, and take the tools by force."}
        [/message]
        [message]
            speaker=Thursagan
            message= {WHISPER _"Are you mad?!"}
        [/message]
        [message]
            speaker=Durstorn
            message= _ "Of course not! Now, Glonoin; one thousand was my final offer. If you won’t accept it, we will take the tools from you by force!"
        [/message]
        [message]
            speaker=Glonoin
            message= _ "I’d like to see you try!"
        [/message]
        [message]
            speaker=Thursagan
            message= _ "You’re making a mistake, Durstorn."
        [/message]

        [music]
            name=the_city_falls.ogg
            immediate=yes
            append=no
        [/music]
        [music]
            name=battle.ogg
            append=yes
        [/music]

        [message]
            speaker=Durstorn
            message= _ "Shut up, all of you! Attack them!"
        [/message]

        [message]
            speaker=narrator
            message= _ "You may now recruit Gryphon Riders."
            image=wesnoth-icon.png
        [/message]

        [allow_recruit]
            side=1
            type=Gryphon Rider
        [/allow_recruit]
    [/event]

    [event]
        name=turn 3
        [unit]
            x,y=1,35
            side=3
            id=Lyndar
            name= _ "Lyndar"
            canrecruit=yes
            type=Elvish Marshal
        [/unit]
        {MOVE_UNIT id=Lyndar 3 33}
        [terrain]
            terrain=Cea
            x,y=3,33
            radius=1
        [/terrain]
        [terrain]
            terrain=Ke
            x,y=3,33
        [/terrain]
        [terrain]
            terrain=Ce
            x,y=2,33
        [/terrain]
        [message]
            speaker=Lyndar
            message= _ "Aha! I’ve spent years looking for you dwarves, but now I’ve found you! Prepare to die!"
        [/message]
        [message]
            speaker=Glonoin
            message= _ "Who the devil are you?"
        [/message]
        [message]
            speaker=Rugnur
            message= _ "I thought we left the elves behind at the gates four years ago! It seems we have two enemies now."
        [/message]
        [message]
            speaker=Glonoin
            message= _ "So, elves, are you against these dwarves too? They’re attacking my clan for absolutely no reason!"
        [/message]
        [message]
            speaker=Lyndar
            message= _ "I see. So you don’t have the ruby?"
        [/message]
        [message]
            speaker=Glonoin
            message= _ "No, they do. They wanted to rent my tools to cut it, but they didn’t offer me nearly enough!"
        [/message]
        [message]
            speaker=Lyndar
            message= _ "How about this — I help you defeat them, and you let me keep the ruby when we have?"
        [/message]
        [message]
            speaker=Glonoin
            message= _ "Deal!"
        [/message]
        [message]
            speaker=Durstorn
            message= _ "Ah, they don’t scare me! We can take both of them!"
        [/message]
        [message]
            speaker=Thursagan
            message= _ "Don’t be a fool! We can’t take the elves, and it was a mistake to attack these dwarves, but if we have to fight we should retreat once we get what we came for, the tools!"
        [/message]

        {VARIABLE elves_come yes}
        [show_objectives]
        [/show_objectives]
    [/event]

#define IN_CAVES
    [filter_location]
        x,y=19,17
        radius=6
        # x=16-22,15-23,13-25,15-22,17-21
        # y=   11,   12,13-19,   20,   21
    [/filter_location]
#enddef

    [event]
        name=die
        [filter]
            id=Glonoin
        [/filter]
        [kill]
            id=Glonoin
            animate=no
            fire_event=no
        [/kill]
        [message]
            speaker=Durstorn
            message= _ "Ha! Now we can get those tools easily, and go back to our own caves."
        [/message]
        [message]
            speaker=Thursagan
            message= _ "And how do you plan on doing that? There are elves swarming these hills, trying to kill us."
        [/message]
        [message]
            speaker=Durstorn
            message= _ "You are right... well, we will be able to break out eventually, and while we’re here, we’ll be able to finally make the sceptre."
        [/message]
        [if]
            [have_unit]
                id=Rugnur
                {IN_CAVES}
            [/have_unit]
            [have_unit]
                id=Alanin
                {IN_CAVES}
            [/have_unit]
            [have_unit]
                id=Krawg
                {IN_CAVES}
            [/have_unit]
            [have_unit]
                id=Thursagan
                {IN_CAVES}
            [/have_unit]
            [have_unit]
                id=Durstorn
                {IN_CAVES}
            [/have_unit]
            [then]
                [if]
                    [have_unit]
                        side=2,3
                        {IN_CAVES}
                    [/have_unit]
                    [then]
                        [message]
                            speaker=Thursagan
                            message= _ "Well, back to the battle — we are all in the caves, but there are still enemies in here also!"
                        [/message]
                        [message]
                            speaker=Durstorn
                            message= _ "Indeed. Kill them! And make sure no more enter. Then we can close the gates."
                        [/message]

                        {VARIABLE ready_to_close yes}

                        [show_objectives]
                        [/show_objectives]
                    [/then]
                    [else]
                        [message]
                            speaker=Thursagan
                            message= _ "We have driven all of the dwarves and elves out of these caves. They are not ours, though, and we can’t stay here forever."
                        [/message]
                        [message]
                            speaker=Durstorn
                            message= _ "True. I suspect these elves will try to besiege us here."
                        [/message]
                        [endlevel]
                            result=victory
                            bonus=no
                            {NEW_GOLD_CARRYOVER 40}
                        [/endlevel]
                    [/else]
                [/if]
            [/then]
            [else]
                [message]
                    speaker=Thursagan
                    message= _ "Well, back to the battle — we need everyone to get into the Shorbear caves. And then stop any enemies from coming in here."
                [/message]
                [message]
                    speaker=Durstorn
                    message= _ "Indeed. Everyone to the caves, and kill those still inside!"
                [/message]

                {VARIABLE ready_to_close yes}

                [show_objectives]
                [/show_objectives]
            [/else]
        [/if]
    [/event]

    [event]
        name=die
        first_time_only=no

        [filter]
            side=2,3
        [/filter]

        [if]
            [variable]
                name=ready_to_close
                equals=yes
            [/variable]
            [have_unit]
                id=Rugnur
                {IN_CAVES}
            [/have_unit]
            [have_unit]
                id=Alanin
                {IN_CAVES}
            [/have_unit]
            [have_unit]
                id=Krawg
                {IN_CAVES}
            [/have_unit]
            [have_unit]
                id=Thursagan
                {IN_CAVES}
            [/have_unit]
            [have_unit]
                id=Durstorn
                {IN_CAVES}
            [/have_unit]
            [then]
                [if]
                    [have_unit]
                        side=2,3
                        {IN_CAVES}
                    [/have_unit]
                    [else]
                        [message]
                            speaker=Durstorn
                            message= _ "We have driven all of the dwarves and elves out of these caves! Now, seal the gates!"
                        [/message]
                        [endlevel]
                            result=victory
                            bonus=no
                            {NEW_GOLD_CARRYOVER 40}
                        [/endlevel]
                    [/else]
                [/if]
            [/then]
        [/if]
    [/event]

    [event]
        name=moveto
        first_time_only=no

        [filter]
            side=1

            [not]
                [not]
                    id=Rugnur
                [/not]
                [not]
                    id=Alanin
                [/not]
                [not]
                    id=Krawg
                [/not]
                [not]
                    id=Thursagan
                [/not]
                [not]
                    id=Durstorn
                [/not]
            [/not]
        [/filter]

        [if]
            [variable]
                name=ready_to_close
                equals=yes
            [/variable]
            [have_unit]
                id=Rugnur
                {IN_CAVES}
            [/have_unit]
            [have_unit]
                id=Alanin
                {IN_CAVES}
            [/have_unit]
            [have_unit]
                id=Krawg
                {IN_CAVES}
            [/have_unit]
            [have_unit]
                id=Thursagan
                {IN_CAVES}
            [/have_unit]
            [have_unit]
                id=Durstorn
                {IN_CAVES}
            [/have_unit]
            [then]
                [if]
                    [have_unit]
                        side=2,3
                        {IN_CAVES}
                    [/have_unit]
                    [then]
                        [allow_undo][/allow_undo]
                    [/then]
                    [else]
                        [message]
                            speaker=Durstorn
                            message= _ "We have driven all of the dwarves and elves out of these caves! Now, seal the gates!"
                        [/message]
                        [endlevel]
                            result=victory
                            bonus=no
                            {NEW_GOLD_CARRYOVER 40}
                        [/endlevel]
                    [/else]
                [/if]
            [/then]
            [else]
                [allow_undo][/allow_undo]
            [/else]
        [/if]
    [/event]

    [event]
        name=new turn
        first_time_only=no

        [if]
            [variable]
                name=ready_to_close
                equals=yes
            [/variable]
            [have_unit]
                id=Rugnur
                {IN_CAVES}
            [/have_unit]
            [have_unit]
                id=Alanin
                {IN_CAVES}
            [/have_unit]
            [have_unit]
                id=Krawg
                {IN_CAVES}
            [/have_unit]
            [have_unit]
                id=Thursagan
                {IN_CAVES}
            [/have_unit]
            [have_unit]
                id=Durstorn
                {IN_CAVES}
            [/have_unit]
            [then]
                [if]
                    [have_unit]
                        side=2,3
                        {IN_CAVES}
                    [/have_unit]
                    [else]
                        [message]
                            speaker=Durstorn
                            message= _ "We have driven all of the dwarves and elves out of these caves! Now, seal the gates!"
                        [/message]
                        [endlevel]
                            result=victory
                            bonus=no
                            {NEW_GOLD_CARRYOVER 40}
                        [/endlevel]
                    [/else]
                [/if]
            [/then]
        [/if]
    [/event]

    [event]
        name=enemies defeated

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

    [event]
        name=last breath
        [filter]
            id=Durstorn
        [/filter]
        [message]
            speaker=Durstorn
            message= _ "Gaanngh..." # wmllint: no spellcheck
        [/message]
        [endlevel]
            result=defeat
        [/endlevel]
    [/event]

    [event]
        name=victory

        {CLEAR_VARIABLE elves_come}
    [/event]

    [event]
        name=turn 10
        [gold]
            side=3
            amount=200
        [/gold]
    [/event]
[/scenario]

#undef IN_CAVES
