#textdomain wesnoth-low
[scenario]
    id=02_Hostile_mountains
    name= _ "Hostile mountains"
    {LOW_MAP 02_Hostile_mountains.map}
    {TURNS 32 28 24}

    {INTRO_AND_SCENARIO_MUSIC sad.ogg knolls.ogg}
    {EXTRA_SCENARIO_MUSIC traveling_minstrels.ogg}
    {EXTRA_SCENARIO_MUSIC legends_of_the_north.ogg}
    {EXTRA_SCENARIO_MUSIC knalgan_theme.ogg}

    {DEFAULT_SCHEDULE}

    {STARTING_VILLAGES_ALL 3}
    {STARTING_VILLAGES_DWARF 2}

    next_scenario=03_Kalian
    [story]
        [part]
            story= _ "Kalenz and his band broke out of the orcish encirclement, only to discover that the country on the direct route to the Ka'lian was already swarming with orcs. The raid on Kalenz's home, it seemed, had been but one small part of a great migration south. There was no choice but to make a detour through territory the elves would rather have avoided..."
            delay=8000
            background="story/hostmountains.jpeg"
        [/part]
        [part]
            delay=4000
            {TO_HOSTILE_MOUNTAINS}
            show_title=yes
        [/part]
    [/story]

    ### Kalenz's code ###
    #wmllint: validate-off
    #wmllint: recognize Olurf
    [side]
        {KALENZ}
        {GOLD 200 180 100}
        # wmllint: recognize Kalenz
        recruit={ELVES}
    [/side]

    [event]
        name=die
        [filter_second]
            id=Kalenz
        [/filter_second]
        [message]
            speaker=second_unit
            message= _ "Payback time!"
        [/message]
    [/event]

    [event]
        name=prestart
        {RECALL_LOYALS}
        # wmllint: recognize Landar
        {CHECK_LANDAR}
    [/event]
    ### /Kalenz's code ###

    ### Olurf's Code ###
#define OLURFS_LAND
    x=20-24,19-30,17-30,16-30,14-30,12-30,11-30,10-30,7-30,8-30,10-30,13-30,15-30,18-30,19-30,20-30,22-30,23-30,24-30,23-30,22-30
    y=10,11,12,13-15,16-17,18-19,20,21,22,23,24,25,26,27,28-29,30,31-32 ,33-36,37,38-39,40
#enddef
#define NOT_OLURFS_LAND
    x=1-30,1-19,1-18,1-16,1-15,1-13,1-11,1-10,1-9,1-5,1-7,1-9,1-12,1-14,1-17,1-18,1-19,1-21,1-22 ,1-23,1-22,1-21,6
    y=1-9,10,11,12,13-15,16-17,18-19,20,21,22,23,24,25,26,27,28-29,30,31-32,33-36,37,38-39,40,22
#enddef

    [side]
        side=2
        {OLURF}
        canrecruit=yes
        {GOLD 150 120 120}
        recruit={DWARVES}
#ifdef EASY
        team_name=dwarves
#else
        team_name=trolls
#endif
        [ai]
            caution=0.5
            [avoid]
                {NOT_OLURFS_LAND}
            [/avoid]
        [/ai]
    [/side]
    #wmllint: validate-on
    #{MAKE_AI_SIDE_PERSISTENT 2}
    {LIMIT_RECRUITS 2 (Dwarvish Berserker) 2}

    #Olurf will return in a later scenario
    [event]
        name=victory

        [store_unit]
            variable=olurf_store
            [filter]
                id=Olurf
            [/filter]
            kill=no
        [/store_unit]

        [store_unit]
            variable=olurf_party
            [filter]
                [not]
                    id=Olurf
                [/not]
                side=2
            [/filter]
            kill=no
        [/store_unit]
    [/event]

    # Trolls have stepped on Olurf's land.
    [event]
        name=moveto
        first_time_only=yes
        [filter]
            side=3
            {OLURFS_LAND}
        [/filter]

        [message]
            id=Olurf
            message= _ "Those stinking trolls ha' stepped on OUR land! Attack!"
        [/message]

        [if]
            [variable]
                name=offended_by_elves
                boolean_equals=yes
            [/variable]
            # the elves have stepped onto already
            [then]
                [modify_side]
                    side=2
                    team_name=dwarves
                [/modify_side]
            [/then]
            [else]
                [modify_side]
                    side=2
                    team_name=kalenz
                [/modify_side]
            [/else]
        [/if]

        [modify_side]
            side=2
            [ai]
                caution=0.5
            [/ai]
        [/modify_side]
    [/event]

    # Elves have stepped on Olurf's land.
    [event]
        name=moveto
        first_time_only=yes
        [filter]
            side=1
            {OLURFS_LAND}
        [/filter]
        [message]
            id=Olurf
            message= _ "Those lying elves have stepped on OUR land! Attack!"
        [/message]

        [store_side]
            side=2
            variable=olurf_side
        [/store_side]

        [if]
            [variable]
                name=olurf_side.team_name
                equals=kalenz
            [/variable]
            [then]
                [modify_side]
                    side=2
                    team_name=dwarves
                [/modify_side]
            [/then]
            [else]
                [modify_side]
                    side=2
                    team_name=trolls
                [/modify_side]
            [/else]
        [/if]
        {CLEAR_VARIABLE olurf_side}
        {VARIABLE offended_by_elves yes}

        [modify_side]
            side=2
            [ai]
                caution=0.5
            [/ai]
        [/modify_side]
    [/event]

#undef NOT_OLURFS_LAND

    [event]
        name=victory
        {CLEAR_VARIABLE offended_by_elves}
    [/event]
    ### /Olurf's Code ###

    ### Enemy Side ###
    [side]
#ifdef EASY
        type=Troll Hero
#else
        type=Great Troll
#endif
        id=Grugl
        name=_ "Grugl"
        side=3
        team_name=trolls
        canrecruit=yes
#ifdef EASY
        recruit=Troll Whelp
#endif
#ifdef NORMAL
        recruit=Troll Whelp, Troll, Troll Rocklobber
#endif
#ifdef HARD
        recruit=Troll Whelp, Troll, Troll Rocklobber, Troll Warrior
#endif
        {GOLD 170 240 270}

        [ai]
            #TODO does this make sense?
            #We don't have any scouts
            {NO_SCOUTS}
#ifdef EASY
            recruitment_pattern=fighter
#else
            recruitment_pattern=fighter,fighter,mixed fighter
#endif
            aggression=0.75
            [target]
                race=elf
                value=1.5
            [/target]

            [avoid]
    #            x=6
    #            y=22
                x=11-30
                y=1-11
                #{OLURFS_LAND}
            [/avoid]
        [/ai]
        [ai]
            time_of_day=dusk,first_watch,second_watch
            caution=0.0
            grouping=no
            [target]
                race=elf
                value=1.5
            [/target]
            [avoid]
   #             x=6
   #             y=22
                x=11-30
                y=1-11
                #{OLURFS_LAND}
            [/avoid]
        [/ai]
        {INCOME 4 8 12}
    [/side]
#undef OLURFS_LAND
#ifdef HARD
    {LIMIT_CONTEMPORANEOUS_RECRUITS 3 "Troll Warrior" 2}
#endif
   # [event]
   #     name=die
   #     [filter]
   #         side=3
   #     [/filter]
   #     [modify_side]
   #         side=3
   #         [ai]
   #             caution=0.0
   #             grouping=no
   #             [target]
   #                 race=elf
   #                 value=1.5
   #             [/target]
   #         [/ai]
   #     [/modify_side]
   # [/event]

    ### /Enemy Side ###

    #### Objectives and corresponding events ####
    [event]
        name=start
        [message]
            id=Kalenz
            message= _ "I had hoped to avoid these paths... The eastern way is through dwarvish territory and is shorter. I pray the dwarves will grant us safe passage, since the other path is through troll territory..."
        [/message]
        [message]
            id=Olurf
            message= _ "Not even in yer dreams, elf. These are dwarvish lands, and troubles we want no part of nip at yer heels. Get out and stay out!"
        [/message]
        [message]
            id=Landar
            message= _ "Our troubles will be yours, too, whether either of us will it or not. The orcs have come down from the north like a flood; if we squabble among ourselves they will feast on our discord."
        [/message]
        [message]
            id=Olurf
            message= _ "Bah. More smooth words and trickery, by my beard. We know yer kind...and who needs yer help anyway, weaklings? Leave now, or feel my axe! That same kiss of steel will greet all intruders. Anyone who sets foot on the eastern bank o' this river will rue the day he was born!"
        [/message]
        [message]
            id=Landar
            message= _ "I cannot see how trolls could be any less friendly."
        [/message]
        [message]
            id=Kalenz
            message= _ "Hmm... Perhaps the dwarves' intransigence can serve our purpose. Onwards, and no matter what you do, do NOT step on the eastern bank of the river!"
        [/message]

        {HIGHLIGHT_IMAGE 18 37 scenery/signpost.png ()}
    [/event]

    [event]
        name=prestart
        [objectives]
            side=1
            [objective]
                description= _ "Kalenz must reach the signpost"
                condition=win
            [/objective]
            [objective]
                description= _ "Defeat Grugl"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Kalenz"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Landar"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Olurf"
                condition=lose
            [/objective]
            [objective]
                description= _ "Turns run out"
                condition=lose
            [/objective]
        [/objectives]
    [/event]

    [event]
        name=moveto
        [filter]
            x=18
            y=37
            id=Kalenz
        [/filter]
        [message]
            speaker=unit
            message= _ "We made it. Onwards to Wesmere!"
        [/message]
        [message]
            id=Olurf
            message= _ "Crazy elves! But at least they felled a few trolls before they left."
        [/message]
        [endlevel]
            result=victory
#ifndef EASY
            bonus=no
#endif
        [/endlevel]
    [/event]

    [event]
        name=die
        [filter]
            id=Grugl
        [/filter]
        #TODO
        [endlevel]
            result=victory
#ifndef EASY
            bonus=no
#endif
        [/endlevel]
    [/event]

    {@campaigns/Legend_of_Wesmere/utils/deaths.cfg}
[/scenario]
