#textdomain wesnoth-sof
[scenario]
    name= _ "Searching for the Runecrafter"
    id=3_Searching_for_the_Runecrafter
    turns=20
    map_file=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}
        {GOLD 160 140 120}
    [/side]

    {STARTING_VILLAGES 1 3}

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

    [story]
        [part]
            story= _ "It was a couple more weeks of marching along the tracks before a chill breeze touched Rugnur’s group, washing over them from a side tunnel leading up to the surface. Had they reached the Northlands?"
        [/part]
        [part]
            story= _ "Much to his chagrin, Alanin was dispatched to scout further up the rails, but he soon came back and claimed the rails ended — the main tunnel was unfinished to the north. For this reason, Rugnur led the dwarves up the cold passage and began to search for the runesmith named Thursagan. 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]
                            # wmllint: recognize Krawg
                            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]
                            # wmllint: recognize Thursagan
                            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]
        [redraw]
            side=1
            clear_shroud=yes
        [/redraw]
        [delay]
            time=300
        [/delay]

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

        [message]
            speaker=Alanin
            message= _ "Now where are we going, anyway? I’ve had to ride down cold, dark, unknown caves... it’s been quite harrowing, this trip had better be worth all that!"
        [/message]
        [message]
            speaker=Baglur
            message= _ "We need to find the sage 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? I’ve heard 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
            x,y=5,24
            side=1
            [modifications]
                {TRAIT_LOYAL_HERO}
                {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
            message= _ "Screech!
<i>(Makes eye contact, bobs and cocks head.)</i>"
        [/message]
        [message]
            speaker=Rugnur
            message= _ "It’s talking to us! What do you want, gryphon?"
        [/message]
        [message]
            speaker=Krawg
            message= _ "Krawg!
<i>(Looks out over the icy taiga, turns gaze back toward the dwarves.)</i>"
        [/message]
        [message]
            speaker=Krawg
            message= _ "Urrrsagan?"
        [/message]
        [message]
            speaker=Rugnur
            message= _ "Well, um, yes, Thursagan. Why, can you help us find him?"
        [/message]
        [message]
            speaker=Krawg
            message= _ "Yes...
<i>(Quickly shifts gaze to nearby woods, adopts a hostile stance, then glances back at the dwarves.)</i>"
        [/message]
        [message]
            speaker=Baglur
            message= _ "Aye, trolls and wolves are closing in... sure, Krawg, we’ll help you fight them."
        [/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
                    message= _ "Screech!
<i>(Nods at the middle distance.)</i>"
                [/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.webp
                    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 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
            profile=portraits/thursagan.webp
            [modifications]
                {TRAIT_LOYAL_HERO}
                {TRAIT_STRONG}
                [object]
                    [effect]
                        [filter]
                            type=Dwarvish Runemaster
                        [/filter]
                        apply_to=remove_advancement
                        amlas=amla_default
                    [/effect]
                    [effect]
                        [filter]
                            type=Dwarvish Runemaster
                        [/filter]
                        apply_to=new_advancement
                        replace=yes
                        types=Dwarvish Arcanister
                    [/effect]
                    [effect]
                        [filter]
                            type=Dwarvish Runemaster
                        [/filter]
                        apply_to=max_experience
                        set=210
                    [/effect]
                [/object]
            [/modifications]
        [/unit]
        [message]
            speaker=Thursagan
            message= _ "What do you people want?! Leave me alone!"
        [/message]
        [message]
            speaker=Rugnur
            message= _ "Old sage, 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? It would be quite a challenge, I could see why you wouldn’t want to touch it!"
        [/message]
        [message]
            speaker=Thursagan
            message= _ "Whoa, now! 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 the King of Wesnoth want us to do with it?"
        [/message]
        [message]
            speaker=Rugnur
            message= _ "Contain and intensify its power."
        [/message]
        [message]
            speaker=Thursagan
            message= _ "I see. The king would cast fire like a mage. Well, good for him. Send him my regards!"
        [/message]
        [message]
            speaker=Rugnur
            message= _ "No wait, I wasn’t clear! We need to contain this power, build some sort of magical cage!"
        [/message]
        [message]
            speaker=Baglur
            message= _ "Aye, a cage, and we can’t do it on our own, Thursagan. We need your skill and expertise!"
        [/message]
        [message]
            speaker=Thursagan
            message= _ "Hrmph, so you need to deliver this power to the king, but also seek to contain that foolish man... I see your dilemma, and I do love a challenge, so let’s build this powerful artifact. I expect it will take 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]

    # Event to tell players about Thursagan's rune shop so they do not need to discover it by chance

    [event]
        name=moveto
        [filter]
            x=5-8
            y=25-29
            id=Thursagan
        [/filter]
        [message]
            speaker=Thursagan
            message= _ "If we want to make this work, we will need every rune-blasted edge we can get. If I have some time to set up shop at a keep, I can prepare a little rune-craft for your troops. My goods do not come cheap though, I will not stoop to trifling apprentice-work..."
        [/message]
    [/event]

    # Thursagan reaches the signpost

    [event]
        name=moveto
        [filter]
            x,y=4,28
            id=Thursagan
        [/filter]
        [message]
            speaker=Rugnur
            message= _ "Well, we can finally get back in our caves — away from these trolls and ogres! Come on, let’s head back south, to the city."
        [/message]
        {MAKE_LOYAL_NORMAL Baglur}
        {CLEAR_VARIABLE thur_x,thur_y}
        {SOF_CLEAR_RUNE_VARS 1}
        [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
