#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]
        [part]
            show_title=yes
            {TO_SEARCHING_FOR_THE_RUNECRAFTER}
        [/part]
    [/story]

#define WINTERENEMY X Y
    [set_variable]
        name=typeofenemy
        rand=Wolf,Ogre,Troll,Wose
    [/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

        # {SCATTER_IMAGE (terrain=Gg) 2 scenery/snowbits.png}
        # {SCATTER_IMAGE (terrain=Aa^Fp) 24 scenery/pine1.png}

        [objectives]
            side=1
            [objective]
                description= _ "Find Thursagan and convince him to come back to the dwarvish city"
                condition=win
            [/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]

            {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]
        [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]
        #this is here so that a hacky "location sighted" event can take place
        #the unit will never actually be seen by the player
        [unit]
            side=2
            type=Galleon
            x,y=$thur_x,$thur_y
            ai_special=guardian
        [/unit]
        [hide_unit]
            x,y=$thur_x,$thur_y
        [/hide_unit]
    [/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"
            {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]
        [objectives]
            side=1
            [objective]
                description= _ "Find Thursagan and convince him to come back to the dwarvish city, then bring him back to the caves"
                condition=win
            [/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
            [/objective]

            {TURNS_RUN_OUT}

            [gold_carryover]
                bonus=yes
                carryover_percentage=40
            [/gold_carryover]
        [/objectives]
        [move_unit_fake]
            type=Gryphon Rider
            side=1
            x=1,5
            y=16,28
        [/move_unit_fake]
        [unit]
            id=Kawn # wmllint: ignore
            name= _ "Kawn"
            type=Gryphon Rider
            x,y=5,28
            side=1
            random_traits=yes
        [/unit]
        [allow_recruit]
            side=1
            type=Gryphon Rider
        [/allow_recruit]
    [/event]

    [event]
        name=sighted
        [filter]
            type=Galleon
        [/filter]
        [kill]
            x,y=$x1,$y1
        [/kill]
        [message]
            speaker=second_unit
            message= _ "I see a house in the distance!"
        [/message]
    [/event]

    # Birds reach Thursagan's (variable) location

    # wmllint: recognize Thursagan
    [event]
        name=moveto
        [filter]
            x,y=$thur_x,$thur_y
            side=1
            type=Gryphon Rider,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 Rider,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"
            {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 31}
        {WINTERENEMY 1 21}
        {WINTERENEMY 31 21}
        {WINTERENEMY 1 15}
#ifdef NORMAL
        {WINTERENEMY 32 1}
#endif
#ifdef HARD
        {WINTERENEMY 32 1}
        {WINTERENEMY 32 31}
#endif

        [modify_turns]
            add=10
        [/modify_turns]

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

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

        [objectives]
            side=1
            [objective]
                description= _ "Move Thursagan to the signpost"
                condition=win
            [/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
            [/objective]
            [objective]
                description= _ "Death of Thursagan"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

            [gold_carryover]
                bonus=yes
                carryover_percentage=40
            [/gold_carryover]
        [/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}
        [endlevel]
            result=victory
            bonus=yes
            {NEW_GOLD_CARRYOVER 40}
        [/endlevel]
    [/event]

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