#textdomain wesnoth-sof
[scenario]
    name= _ "Searching for the Runecrafter"
    id=3_Searching_for_the_Runecrafter
    turns=20
    map_data="{campaigns/Sceptre_of_Fire/maps/3_Searching_for_the_Runecrafter.map}"
    next_scenario=3t_The_Council_Regathers
    victory_when_enemies_defeated=no

    {SCENARIO_MUSIC wanderer.ogg}
    {EXTRA_SCENARIO_MUSIC elvish-theme.ogg}

    {DEFAULT_SCHEDULE}

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

    {STARTING_VILLAGES 1 3}

    [side]
        no_leader=yes
        side=2
        team_name=monsters
        user_team_name= _ "Monsters"
    [/side]

    [story]
        [part]
            story= _ "The journey to the far northern wastelands was long and perilous. For the tunnels were winding and treacherous, and the paths were not safe from orcs, or worse. Nevertheless, they did reach the Northlands, and began to search for the runesmith named Thursagan — the sage of fire."
        [/part]
    [/story]

    {SOF_TRACK {JOURNEY_03_NEW} }

#define WINTERENEMY X Y
    [set_variable]
        name=typeofenemy
        rand=Wolf,Ogre,Troll,Troll Whelp
    [/set_variable]
    [unit]
        x,y={X},{Y}
        generate_name=yes
        random_traits=yes
        type=$typeofenemy
        side=2
    [/unit]
    [if]
        [variable]
            name=typeofenemy
            equals=Wolf
        [/variable]
        [then]
            [unit]
                x,y={X},{Y}
                type=Wolf
                side=2
            [/unit]
            [unit]
                x,y={X},{Y}
                type=Wolf
                side=2
            [/unit]
#ifdef HARD
            [unit]
                x,y={X},{Y}
                type=Wolf
                side=2
            [/unit]
#endif
        [/then]
    [/if]
    [clear_variable]
        name=typeofenemy
    [/clear_variable]
#enddef

    {SOF_DEATHS}

    [event]
        name=prestart

        [objectives]
            side=1
            [objective]
                description= _ "Find Thursagan and convince him to come back to the dwarvish city"
                condition=win
                [show_if]
                    [not]
                        [have_unit]
                            id=Krawg
                        [/have_unit]
                    [/not]
                [/show_if]
            [/objective]
            [objective]
                description= _ "Find Thursagan and convince him to come back to the dwarvish city, then bring him back to the caves"
                condition=win
                [show_if]
                    [have_unit]
                        id=Krawg
                    [/have_unit]
                    [not]
                        [have_unit]
                            id=Thursagan
                        [/have_unit]
                    [/not]
                [/show_if]
            [/objective]
            [objective]
                description= _ "Move Thursagan to the signpost"
                condition=win
                [show_if]
                    [have_unit]
                        id=Thursagan
                    [/have_unit]
                [/show_if]
            [/objective]
            [objective]
                description= _ "Death of Rugnur"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Alanin"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Baglur"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Krawg"
                condition=lose
                [show_if]
                    [have_unit]
                        id=Krawg
                    [/have_unit]
                [/show_if]
            [/objective]
            [objective]
                description= _ "Death of Thursagan"
                condition=lose
                [show_if]
                    [have_unit]
                        id=Thursagan
                    [/have_unit]
                [/show_if]
            [/objective]

            {TURNS_RUN_OUT}

            [gold_carryover]
                bonus=yes
                carryover_percentage=40
            [/gold_carryover]
        [/objectives]
        {WINTERENEMY 5 5}
        {WINTERENEMY 15 15}
        {WINTERENEMY 25 25}
        {WINTERENEMY 25 10}
#ifdef NORMAL
        {WINTERENEMY 30 18}
#endif
#ifdef HARD
        {WINTERENEMY 30 18}
        {WINTERENEMY 20 2}
#endif
    [/event]

    [event]
        name=turn 5
        {WINTERENEMY 10 10}
        {WINTERENEMY 20 20}
        {WINTERENEMY 30 30}
    [/event]

    [event]
        name=turn 15
        {WINTERENEMY 18 6}
        {WINTERENEMY 30 7}
    [/event]

    [event]
        name=start
        [recall]
            id=Baglur
        [/recall]
        [recall]
            id=Alanin
        [/recall]

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

        [message]
            speaker=Alanin
            message= _ "Now where are we going, anyway? We have been taking wrong turns and fighting orcs for months. This trip better have a good payoff to be worth that."
        [/message]
        [message]
            speaker=Baglur
            message= _ "We need to find the mage Thursagan and convince him to return to the citadel with us. He’s somewhere up here."
        [/message]
        [message]
            speaker=Rugnur
            message= _ "Well, how are we supposed to find him?"
        [/message]
        [message]
            speaker=Baglur
            message= _ "His will probably be the only house up here. No one else is insane enough to live this far north! Even the elves won’t challenge us here."
        [/message]
        [message]
            speaker=Alanin
            message= _ "Except for trolls and ogres, right? They live in the far Northlands. They’re probably lurking around here somewhere."
        [/message]
        [message]
            speaker=Baglur
            message= _ "Right. We’ll probably have to fight our way through to his house."
        [/message]
        {RANDOM 1..5}
        [if]
            [variable]
                name=random
                equals=1
            [/variable]
            [then]
                [set_variable]
                    name=thur_x
                    value=2
                [/set_variable]
                [set_variable]
                    name=thur_y
                    value=6
                [/set_variable]
            [/then]
        [/if]
        [if]
            [variable]
                name=random
                equals=2
            [/variable]
            [then]
                [set_variable]
                    name=thur_x
                    value=15
                [/set_variable]
                [set_variable]
                    name=thur_y
                    value=2
                [/set_variable]
            [/then]
        [/if]
        [if]
            [variable]
                name=random
                equals=3
            [/variable]
            [then]
                [set_variable]
                    name=thur_x
                    value=27
                [/set_variable]
                [set_variable]
                    name=thur_y
                    value=9
                [/set_variable]
            [/then]
        [/if]
        [if]
            [variable]
                name=random
                equals=4
            [/variable]
            [then]
                [set_variable]
                    name=thur_x
                    value=28
                [/set_variable]
                [set_variable]
                    name=thur_y
                    value=16
                [/set_variable]
            [/then]
        [/if]
        [if]
            [variable]
                name=random
                equals=5
            [/variable]
            [then]
                [set_variable]
                    name=thur_x
                    value=29
                [/set_variable]
                [set_variable]
                    name=thur_y
                    value=30
                [/set_variable]
            [/then]
        [/if]
        [clear_variable]
            name=random
        [/clear_variable]
        [terrain]
            x,y=$thur_x,$thur_y
            terrain=Aa^Vha
        [/terrain]
    [/event]

    [event]
        name=moveto
        [filter]
            x=1-32,17-32
            y=1-21,1-31
            side=1
        [/filter]
        [move_unit_fake]
            type=Gryphon
            side=1
            x=1,5
            y=16,24
        [/move_unit_fake]
        [unit]
            type=Gryphon
            id=Krawg
            name= _ "Krawg"
            unrenamable=yes
            {IS_HERO}
            x,y=5,24
            side=1
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_INTELLIGENT}
            [/modifications]
        [/unit]
        [message]
            speaker=Krawg
            #po: Krawg's speech is purposely very distorted -- he has the
            #po: vocal tract of a bird and is speaking through a beak.
            #po: "Will you speak with us?"
            message= _ "Kwill yooo spakkk wit uus?!" # wmllint: no spellcheck
        [/message]
        [message]
            speaker=Alanin
            # wmllint: local spelling Aah
            message= _ "Aah! What is that?!"
        [/message]
        [message]
            speaker=Baglur
            message= _ "Is that... is that a gryphon?"
        [/message]
        [message]
            speaker=Krawg
            #po: "Yes. You speak with us now?"
            message= _ "Kwes! Yooo spakkk wit uuus nuu?" # wmllint: no spellcheck
        [/message]
        [message]
            speaker=Rugnur
            message= _ "It’s talking to us! What do you want, gryphon?"
        [/message]
        [message]
            #po: "My name is Krawg. You is looking for a runemaster?"
            speaker=Krawg
            message= _ "Myy namm ees Krawgg. Yooo ees oooking forr a uunmasta?" # wmllint: no spellcheck
        [/message]
        [message]
            speaker=Rugnur
            message= _ "Well, um, yes. Why, can you help us?"
        [/message]
        [message]
            speaker=Krawg
            #po: "Yes. If you kill the trolls and ogres, we'll help you."
            message= _ "Ess... if yooo ills ka rolls aan ogras, us’ll elp yoo!" # wmllint: no spellcheck
        [/message]
        [message]
            speaker=Baglur
            message= _ "Sure, we’ll help you fight trolls and ogres."
        [/message]
        #[message]
        #    speaker=Krawg
        #    message= _ "Kwe... yoo ants to ide uuus, nooa? Kwe, uus kan..." # wmllint: no spellcheck
        #[/message]
        [show_objectives]
        [/show_objectives]

        [redraw]
            clear_shroud=yes
        [/redraw]
    [/event]

    [event]
        name=moveto

        [filter]
            side=1
        [/filter]
        [filter_condition]
            [have_location]
                x,y=$thur_x,$thur_y
                [filter_vision]
                    visible=yes
                    respect_fog=yes
                    side=1
                [/filter_vision]
            [/have_location]
        [/filter_condition]

        [scroll_to]
            x,y=$thur_x,$thur_y
        [/scroll_to]
        [delay]
            time=250
        [/delay]
        [if]
            [variable]
                name=unit.id
                equals=Krawg
            [/variable]
            [then]
                [message]
                    speaker=Krawg
                    #po: "I see a house in the distance!"
                    message= _ "Iii zeee hoose iiin eee d’zztaaan’eee!" # wmllint: no spellcheck
                [/message]
            [/then]
            [else]
                [message]
                    speaker=unit
                    message= _ "I see a house in the distance!"
                [/message]
            [/else]
        [/if]
    [/event]

    # Birds reach Thursagan's (variable) location

    # wmllint: recognize Thursagan
    [event]
        name=moveto
        [filter]
            x,y=$thur_x,$thur_y
            side=1
            type=Gryphon
        [/filter]

        [if]
            [not]
                [have_unit]
                    id=Thursagan
                [/have_unit]
            [/not]

            [then]
                [message]
                    speaker=narrator
                    caption=_"Thursagan"
                    image=portraits/thursagan.png
                    message= _ "Go away, you birds! Or I shall burn you out of the air!"
                [/message]
                [message]
                    speaker=Baglur
                    message= _ "He doesn’t want to talk to the gryphons, apparently. I think we’ll have to get someone there he will talk to..."
                [/message]
            [/then]
        [/if]

        [allow_undo][/allow_undo]
    [/event]

    # Something other than a bird reaches Thursagan's (variable) location

    [event]
        name=moveto
        [filter]
            x,y=$thur_x,$thur_y
            side=1
            [not]
                type=Gryphon
            [/not]
        [/filter]

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

        [unit]
            x,y=$thur_x,$thur_y
            side=1
            type=Dwarvish Runemaster
            id=Thursagan
            name= _ "Thursagan"
            unrenamable=yes
            {IS_HERO}
            profile=portraits/thursagan.png
            advances_to=Dwarvish Arcanister
            max_experience=210
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_STRONG}
            [/modifications]
        [/unit]
        [message]
            speaker=Thursagan
            message= _ "What do you people want?! Leave me alone!"
        [/message]
        [message]
            speaker=Rugnur
            message= _ "Old mage, we come with a message from Lord Durstorn. He asks you to come back to the city."
        [/message]
        [message]
            speaker=Thursagan
            message= _ "Ha! That fool thinks he can order me around. Why does he want me to go back, anyway?"
        [/message]
        [message]
            speaker=Baglur
            message= _ "We have entered into a bargain with the king of Wesnoth to craft a sceptre for him."
        [/message]
        [message]
            speaker=Thursagan
            message= _ "Oh, and now I suppose Durstorn wants me to craft it, eh? Well I’m not going to."
        [/message]
        [message]
            speaker=Rugnur
            message= _ "You don’t want to make a sceptre to contain the power of the ruby of fire? Very well, your choice is made."
        [/message]
        [message]
            speaker=Thursagan
            message= _ "The ruby of fire, what is that, some worthless Wesnothian gem?"
        [/message]
        [message]
            speaker=Baglur
            message= _ "It is a Wesnothian gem, but it is also supposedly the most powerful magical artifact ever seen. Even an untrained hand can use it to cast fiery bolts as powerful as those of arch mages."
        [/message]
        [message]
            speaker=Thursagan
            message= _ "Oh, really? And what does Haldric want us to do with it?"
        [/message]
        [message]
            speaker=Rugnur
            message= _ "Contain and intensify its power."
        [/message]
        [message]
            speaker=Thursagan
            message= _ "I see. Fine then, I will help you craft this sceptre... into the most powerful magic artifact ever seen. This will be a true test of my skill. I expect it will take many years."
        [/message]
        [message]
            speaker=Baglur
            message= _ "Good. Now, there are still wild animals here... We have to get back into the caves."
        [/message]
        {WINTERENEMY 19 30}
        {WINTERENEMY 1 21}
        {WINTERENEMY 31 21}
        {WINTERENEMY 1 15}
#ifdef NORMAL
        {WINTERENEMY 32 1}
#endif
#ifdef HARD
        {WINTERENEMY 32 1}
        {WINTERENEMY 32 30}
#endif

        [modify_turns]
            add=10
        [/modify_turns]

        {HIGHLIGHT_IMAGE 4 28 scenery/signpost.png ()}

        [scroll_to]
            x,y=$x1,$y1
        [/scroll_to]

        [show_objectives]
        [/show_objectives]
    [/event]

    # Thursagan reaches the signpost

    [event]
        name=moveto
        [filter]
            x,y=4,28
            id=Thursagan
        [/filter]
        [message]
            speaker=Thursagan
            message= _ "Well, now we are in the caves again! Come on, back south, to the city."
        [/message]
        {UNMAKE_HERO Baglur}
        [unit_overlay]
            id=Baglur
            image=misc/loyal-icon.png
        [/unit_overlay]
        {CLEAR_VARIABLE thur_x,thur_y}
        [endlevel]
            result=victory
            bonus=yes
            {NEW_GOLD_CARRYOVER 40}
        [/endlevel]
    [/event]

    [event]
        name=die
        [filter]
            id=Baglur
        [/filter]
        [endlevel]
            result=defeat
        [/endlevel]
    [/event]
[/scenario]

#undef WINTERENEMY
