#textdomain wesnoth-httt
[scenario]
    id=12_Northern_Winter
    name= _ "Northern Winter"
    map_file=12_Northern_Winter.map

    {TURNS 36 32 28}
    [event]
        name=prestart
        [store_turns]
            variable=turn_limit
        [/store_turns]
        [set_variable]
            name=turn_limit
            add=1
        [/set_variable]
    [/event]

    {DEFAULT_SCHEDULE}

    next_scenario=13_The_Dwarven_Doors

    {SCENARIO_MUSIC "elvish-theme.ogg"}
    {EXTRA_SCENARIO_MUSIC "nunc_dimittis.ogg"}
    {EXTRA_SCENARIO_MUSIC "suspense.ogg"}
    {EXTRA_SCENARIO_MUSIC "silvan_sanctuary.ogg"}
    {EXTRA_SCENARIO_MUSIC "weight_of_revenge.ogg"}

    [event]
        name=prestart
        [objectives]
            side=1
            [objective]
                description= _ "Defeat all enemy leaders"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Konrad"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Delfador"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Kalenz"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

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

    # wmllint: local spelling thutter
    [story]
        [part]
            story= _ "Across the river were lands few humans had ever visited. The occasional distant thutter of orcish signal drums made the abundant pine forests nestled in rolling foothills both breathtaking and ominous."
            {HTTT_BIGMAP}
            show_title=no
        [/part]
        [part]
            story= _ "Swirling, snow-laden winds tore at Konrad’s army, signaling the final exit of autumn and the onset of what would be a harsh winter."
            {HTTT_BIGMAP}
            show_title=no
        [/part]
    [/story]

    {HTTT_TRACK {JOURNEY_12_NEW} }

    [side]
        type=Commander
        id=Konrad
        name= _ "Konrad"
        unrenamable=yes
        profile=portraits/konrad-human.webp
        side=1
        canrecruit=yes
        team_name=elves
        user_team_name=_"Rebels"
        controller=human
        {GOLD 200 180 160}
        {FLAG_VARIANT long}
    [/side]

    [side]
        type=Orcish Warrior
        id="Halgar Du'nar"
        name= _ "Halgar Du’nar"
        experience=0
        side=2
        canrecruit=yes
        recruit=Orcish Grunt,Wolf Rider,Orcish Archer,Troll Whelp,Ogre
        [ai]
            recruitment_pattern=scout,scout,fighter,fighter,archer
        [/ai]
        [ai]
            time_of_day=dusk,first_watch,second_watch
            aggression=0.75
            caution=-1.0
        [/ai]
        {GOLD 80 130 180}
        {INCOME 2 4 6}
        team_name=orcs
        user_team_name=_"Orcs"
        {FLAG_VARIANT6 ragged}
    [/side]

    {STARTING_VILLAGES 2 5}

    [side]
        type=Orcish Warrior
        id="Gorlak"
        name= _ "Gorlak"
        experience=0
        side=3
        canrecruit=yes
        recruit=Orcish Grunt,Wolf Rider,Orcish Archer,Troll
        [ai]
            recruitment_pattern=scout,scout,fighter,fighter,archer
        [/ai]
        [ai]
            time_of_day=dusk,first_watch,second_watch
            aggression=0.75
            caution=-1.0
        [/ai]
        {GOLD 80 130 180}
        {INCOME 2 4 6}
        team_name=orcs
        user_team_name=_"Orcs"
        {FLAG_VARIANT6 ragged}
    [/side]

    {STARTING_VILLAGES 3 5}

    [event]
        name=prestart

        [role]
            role=human-advisor
            [auto_recall][/auto_recall]

            type="Thief," +
                "Poacher,Footpad,Thug," +
                "Mage," +
                "Horseman," +
                "Rogue," +
                "Trapper,Outlaw,Bandit," +
                "Red Mage,White Mage," +
                "Lancer,Knight," +
                "Assassin," +
                "Ranger,Huntsman,Fugitive,Highwayman," +
                "Silver Mage,Arch Mage,Mage of Light," +
                "Grand Knight,Paladin," +
                "Great Mage"
            [else]
                [unit]
                    side=1
                    type=Thief
                    role=human-advisor
                    placement=leader
                [/unit]
            [/else]
        [/role]
        {NEED_DELFADOR placement=leader}
        {NEED_KALENZ placement=leader}
    [/event]

    [event]
        name=start
        [message]
            speaker=Konrad
            message= _ "This winter is bitterly cold! Perhaps we should stop here and rest a while."
        [/message]
        [message]
            speaker=Kalenz
            message= _ "Stop and rest? My lord, we must go hard after the Sceptre of Fire, lest it fall into the hands of our enemies!"
        [/message]
        [message]
            speaker=Konrad
            message= _ "We have had a hard march ever since we were besieged by the undead in that foul valley. Now winter bears down upon us, and we have spent most of our money. This land looks fertile enough. Surely we can settle here for the winter!"
        [/message]
        [message]
            role=human-advisor
            message= _ "Yes, let us rest a while! I am sure there are many challenges ahead, and I do not think I could endure another like the fording of the river for many days."
        [/message]
        [message]
            speaker=Kalenz
            message= _ "We are pursued by the forces of your arch-enemy, chasing the Sceptre of Fire, the fate of the realm in our hands, and you humans want to stop and rest? Onward, I say!"
        [/message]
        [message]
            speaker=Delfador
            message= _ "They are right, Kalenz. I had wanted to acquire the Sceptre within a moon, but it is not to be. Our soldiers will begin to desert if they do not rest soon. But in these wild north lands, we must fight even for the right to rest. Look to the north! Those foul orcs will not allow us any peace!"
        [/message]
        [message]
            speaker=Konrad
            {KONRAD_VARIATION mad}
            message= _ "Then we shall wrest control of the land from them. To arms!"
        [/message]
    [/event]

    [event]
        name=turn 2

        [message]
            speaker=Konrad
            message= _ "More snow is falling. We must finish this battle quickly. Onward, men!"
        [/message]

        # This event makes snow fall on random non-snowy locations at such a
        # constant pace that snow will be everywhere exactly when turns run out
        [event]
            name=new turn
            first_time_only=no
            delayed_variable_substitution=yes

            [random_placement]
                num_items="(size / ($turn_limit - $turn_number))"
                variable=loc
                allow_less=yes

                [filter_location]
                    terrain=Gs,Gd,Co,Ko,Gll^Fp,Gll^Fmw,Gll^Fdw,Gd^Vo,Gd^Vc,Hhd^Vo
                [/filter_location]

                [command]
                    [switch]
                        variable=loc.terrain

                        [case]
                            value=Gs

                            {VARIABLE terrain Aa}
                        [/case]

                        [case]
                            value=Gd

                            {VARIABLE terrain Aa}
                        [/case]

                        [case]
                            value=Co

                            {VARIABLE terrain Coa}
                        [/case]

                        [case]
                            value=Ko

                            {VARIABLE terrain Koa}
                        [/case]

                        [case]
                            value=Gll^Fp

                            {VARIABLE terrain Aa^Fpa}
                        [/case]

                        [case]
                            value=Gll^Fmw

                            {VARIABLE terrain Aa^Fma}
                        [/case]

                        [case]
                            value=Gll^Fdw

                            {VARIABLE terrain Aa^Fda}
                        [/case]

                        [case]
                            value=Gd^Vo

                            {VARIABLE terrain Aa^Voa}
                        [/case]

                        [case]
                            value=Gd^Vc

                            {VARIABLE terrain Aa^Vca}
                        [/case]

                        [case]
                            value=Hhd^Vo

                            {VARIABLE terrain Ha^Voa }
                        [/case]
                    [/switch]

                    [terrain]
                        x,y=$loc.x,$loc.y
                        terrain=$terrain
                    [/terrain]

                    {CLEAR_VARIABLE terrain}
                [/command]
            [/random_placement]
        [/event]
    [/event]

    [event]
        name=turn 10

        [message]
            speaker=Konrad
            {KONRAD_VARIATION concerned}
            message= _ "We must make haste before the snow overwhelms us!"
        [/message]
    [/event]

    [event]
        name=enemies defeated
        [message]
            speaker=Delfador
            message= _ "Victory is ours! We have secured the land from the orcs. Now we can rest here while the cold winter passes."
        [/message]
        [message]
            speaker=Kalenz
            message= _ "Let us not rest for too long though, friends. We must still reach the ancient dwarven lands before our foes do."
        [/message]

        [if]
            [variable]
                name=get_gryphons
                boolean_equals=yes
            [/variable]
            [then]
                [message]
                    speaker=narrator
                    image="wesnoth-icon.png"
                    message= _ "A camp was pitched in a secluded valley that protected its occupants from the worst of the winter weather and roving orc patrols. During this time, the valley walls echoed with the squeaks of gryphon hatchlings, who happily frolicked across the camp."
                [/message]
                [message]
                    speaker=narrator
                    image="wesnoth-icon.png"
                    message= _ "Konrad set his shamans to the task of corralling the animals. The elvish shamans had a natural rapport with the gryphlets, whose wings were still too small to carry a mount."
                [/message]
                [message]
                    speaker=narrator
                    image="wesnoth-icon.png"
                    message= _ "Konrad finally decided he could not wait until the gryphons grew to maturity — Delfador’s insistence that the Sceptre must be recovered was too compelling. And so after many days of rest, the party set out once again for the dwarven kingdom..."
                [/message]
            [/then]
            [else]
                [message]
                    speaker=narrator
                    image="wesnoth-icon.png"
                    message= _ "A camp was pitched in a secluded valley that protected its occupants from the worst of the winter weather and roving orc patrols."
                [/message]
                [message]
                    speaker=narrator
                    image="wesnoth-icon.png"
                    message= _ "Eventually Delfador’s insistence that the Sceptre must be recovered proved too compelling, even when it meant dismantling the camp without the spring having yet fully arrived. And so after many days of rest, the party set out once again for the dwarven kingdom..."
                [/message]
            [/else]
        [/if]

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

    [event]
        name=victory

        {VARIABLE_OP turn_limit sub 1}
        {VARIABLE snowCoverage $turn_number}
        {VARIABLE_OP snowCoverage sub 1}
        {VARIABLE_OP snowCoverage divide $turn_limit}
        {CLEAR_VARIABLE turn_limit}
    [/event]

    {campaigns/Heir_To_The_Throne/utils/deaths.cfg}
[/scenario]
