#textdomain wesnoth-did

[scenario]
    id=02_Peaceful_Valley
    name= _ "Peaceful Valley"
    map_file=02_Peaceful_Valley.map
    victory_when_enemies_defeated=no
    {TURNS 19 17 15}
    next_scenario=03_A_Haunting_in_Winter

    {DEFAULT_SCHEDULE_MORNING}

    {SCENARIO_MUSIC       nunc_dimittis.ogg}
    {EXTRA_SCENARIO_MUSIC knolls.ogg}
    {EXTRA_SCENARIO_MUSIC casualties_of_war.ogg}

    [story]
        [part]
            music=the_king_is_dead.ogg
            story= _ "Bitter and alone, Malin follows the back-trail of the orcish band north from Parthyn. He curses the mages for casting him out from the Isle of Alduin only half-trained, unprepared for conflict. He curses Drogan for lacking the resolve to make the necessary sacrifices to protect their home. Most fiercely, he curses the orcs for their mindless savagery, pillagers and raiders who view violence as little more than sport."
            {STORYTXT_BACKGROUND_BIGMAP_DID}
        [/part]
        [part]
            story= _ "Three days’ travel northeast, Malin stumbles upon Darken Volk, the necromancer who had saved Parthyn and taught him to raise the dead. The dark mage suggests that they travel together; Malin obliges, having been abandoned by his kinsmen. As the weeks pass, Darken Volk teaches Malin more dark magic."
            {STORYTXT_BACKGROUND travel.webp}
        [/part]
    [/story]

    {DID_TRACK {JOURNEY_02_NEW}}

    # wmllint: validate-off
    [side]
        side=1
        controller=human
        recruit=Walking Corpse,Vampire Bat
        {GOLD 105 90 75}
        team_name=good
        user_team_name= _ "Malin Keshar"
        {FLAG_VARIANT undead}
        color=darkblue

        # wmllint: recognize Malin Keshar
        {CHARACTER_STATS_MALIN_KESHAR}

        fog=yes
        shroud=yes
        facing=nw

        [unit]
            x,y=15,12
            facing=nw

            # wmllint: recognize Darken Volk
            {CHARACTER_STATS_DARKEN_VOLK}
        [/unit]
    [/side]
    # wmllint: validate-on

    [side]
        side=2
        controller=ai
        recruit=Goblin Rouser,Goblin Impaler,Wolf Rider
        {GOLD 25 40 55}
        team_name=goblins
        user_team_name= _ "Goblins"
        {FLAG_VARIANT6 ragged}
        color=white

        type=Goblin Knight
        id="T'shar Lggi"
        name= _ "T’shar Lggi"
        canrecruit=yes

        fog=yes
        facing=se

        [ai]
            village_value=2
            caution=0.5
            recruitment_pattern=scout,fighter
        [/ai]
    [/side]

    {STARTING_VILLAGES_ALL 2}
    {PLACE_IMAGE items/scarecrow.png 11 4}
    {PLACE_IMAGE items/straw-bale2.png 9 3}
    {PLACE_IMAGE items/key.png 7 9}
    {PLACE_IMAGE items/cage.png 4 12}
    {PLACE_IMAGE scenery/whitefang-flag.png 6 2}

    [event]
        name=prestart

        {CLEAR_CORPSE_HORDE}

        [objectives]
            side=1
            [objective]
                condition=win
                description= _ "Occupy all of the goblin villages"
            [/objective]
            [objective]
                condition=lose
                description= _ "Death of Malin Keshar"
            [/objective]
            [objective]
                condition=lose
                description= _ "Death of Darken Volk"
            [/objective]

            {TURNS_RUN_OUT}

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

        [item]
            x,y=8,2
            image=terrain/castle/encampment/tent2.png
        [/item]

        {VARIABLE key 0}
    [/event]

    [event]
        name=start

        [message]
            speaker=Darken Volk
            message= _ "In truth, I share your hatred for the orcs. The Northlands have been my home for many years and the orcs have been a growing infestation in recent times. They despoil the beauty of the land wherever they go, hacking and burning everything without care or concern. If you are interested, I would be happy to take you on as my... apprentice... so that I can teach you to fight against them."
        [/message]

        [message]
            speaker=Malin Keshar
            message= _ "Yes! These orcs have threatened my friends and my home for too long. It’s time I gained the power to put them in their place."
        [/message]

        [message]
            speaker=Darken Volk
            message= _ "Yes, perhaps removing the threat of orcish raids will persuade the people of Parthyn to welcome you back. But for now, I must train you. The orcs are powerful in the hills, strong enough that even I dare not confront them directly."
        [/message]

        [message]
            speaker=Malin Keshar
            message= _ "Then what shall we do?"
        [/message]

        [message]
            speaker=Darken Volk
            message= _ "Strike at them where they are weak. A goblin village lies in this valley, just ahead. They are the bastard children of the orcs, feeble creatures individually, but annoying enough in large numbers. Subduing them will provide us a supply of fresh corpses and souls to use against the orcs."
        [/message]

        [message]
            speaker=Darken Volk
            message= _ "... It will be a worthwhile test of your skills."
        [/message]
    [/event]

    # In-scenario events
    [event]
        name=capture
        first_time_only=yes
        [filter]
            side=1
        [/filter]

        [message]
            speaker=Darken Volk
            message= _ "Beware the goblin guards in the villages."
        [/message]
    [/event]

    [event]
        name=moveto
        [filter]
            x,y=7,9
            id=Malin Keshar
        [/filter]
        [message]
            speaker=Malin Keshar
            message= _ "Someone dropped a key here."
        [/message]
        {REMOVE_IMAGE 7 9}
        {VARIABLE key 1}
    [/event]

    [event]
        name=moveto
        [filter]
            x,y=4,12
            id=Malin Keshar
        [/filter]
        [filter_condition]
            [variable]
                name=key
                numerical_equals=1
            [/variable]
        [/filter_condition]

        [message]
            speaker=Malin Keshar
            message= _ "There are some rotten corpses in this cage."
        [/message]

        [message]
            speaker=Darken Volk
            message= _ "Make use of them."
        [/message]

        [delay]
            time=1000
        [/delay]

        [message]
            speaker=Darken Volk
            message= _ "A necromancer must always use whatever supplies he is given. Do it."
        [/message]

        [message]
            speaker=Malin Keshar
            message= _ "..."
        [/message]

        [animate_unit]
            [filter]
                id=Malin Keshar
            [/filter]
            [primary_attack]
                range=ranged
            [/primary_attack]
            flag=attack
        [/animate_unit]

        [delay]
            time=300
        [/delay]

        [sound]
            name=zombie-hit-2.ogg
        [/sound]

        [delay]
            time=300
        [/delay]

        [unit]
            side=1
            x,y=4,12
            type=Walking Corpse
            variation=goblin
            animate=yes
        [/unit]

        [unit]
            side=1
            x,y=4,12
            type=Soulless
            variation=goblin
            animate=yes
        [/unit]

        {REMOVE_IMAGE 4 12}
        {VARIABLE key 2}
    [/event]

    [event]
        name=attack
        [filter]
            id=Malin Keshar
        [/filter]

        [message]
            speaker=second_unit
            message= _ "Eeeek! Don’t kill me!"
        [/message]

        [message]
            speaker=Malin Keshar
            message= _ "..."
        [/message]

        [message]
            speaker=Darken Volk
            message= _ "Why do you hesitate? Did the orcs show your people any mercy when they attacked Parthyn?"
        [/message]

        # Malin answers first. For the time being, he's not deadened to merciless killing
        [message]
            speaker=Malin Keshar
            message= _ "... No."
        [/message]

        [delay]
            time=1000
        [/delay]
    [/event]

    [event]
        name=attack
        [filter]
            type=Ghoul
        [/filter]

        [message]
            speaker=second_unit
            message= _ "Ruuuun! The monster’s going to eat us!"
        [/message]
    [/event]

    [event]
        name=capture
        first_time_only=no
        [filter]
            side=1
        [/filter]

        [filter_condition]
            [variable]
                name=village_$x1|_$y1|_cleared
                boolean_not_equals=yes
            [/variable]
            [have_location]
                terrain=*^V*

                [not]
                    owner_side=1
                [/not]
            [/have_location]
        [/filter_condition]
        {VARIABLE_OP number_of_guards rand "0..2"}
        [random_placement]
            num_items="$number_of_guards"
            allow_less=yes
            variable=guard_location
            [filter_location]
                [filter_adjacent_location]
                    x,y=$x1,$y1
                [/filter_adjacent_location]
                [not]
                    [filter]
                    [/filter]
                [/not]
            [/filter_location]
            [command]
                [move_unit_fake]
                    side=2
                    type=Goblin Spearman
                    x=$x1,$guard_location.x
                    y=$y1,$guard_location.y
                [/move_unit_fake]

                [unit]
                    id=guard_$x1|_$y1|_$guard_location.n
                    name= _ "Villager"
                    type=Goblin Spearman
                    side=2
                    x,y=$guard_location.x,$guard_location.y
                    random_traits=yes
                [/unit]
            [/command]
        [/random_placement]
        {VARIABLE village_$x1|_$y1|_cleared yes}

        # Trigger an easter egg sometime after three villages have been taken
        [if]
            [variable]
                name=done_shaun
                not_equals=yes
            [/variable]
            [variable]
                name=number_of_guards
                numerical_equals=2
            [/variable]
            [have_location]
                owner_side=1
                count=3-infinity
            [/have_location]

            # Make sure the guards actually exist, in case there was no space for them
            [have_unit]
                # wmllint: recognize guard_$x1|_$y1|_1
                id=guard_$x1|_$y1|_1
            [/have_unit]
            [have_unit]
                # wmllint: recognize guard_$x1|_$y1|_2
                id=guard_$x1|_$y1|_2
            [/have_unit]

            [then]
                [modify_unit]
                    [filter]
                        id=guard_$x1|_$y1|_1
                    [/filter]
                    #po: Shaun and Ed are characters from the zombie film "Shaun of the Dead".
                    #po: If the names cannot be translated into your language so that the
                    #po: movie reference remains recognizable, then simply translate these the
                    #po: same as "Villager" above.
                    name= _ "Shaun"
                [/modify_unit]
                [modify_unit]
                    [filter]
                        id=guard_$x1|_$y1|_2
                    [/filter]
                    name= _ "Ed"
                [/modify_unit]

                {VARIABLE done_shaun yes}
            [/then]
        [/if]

        # If there was a goblin next to the village before the guards spawned, the player may have
        # already commanded their unit to attack. But as there are now more enemies, give the
        # player a chance to choose a different opponent.
        [if]
            [variable]
                name=number_of_guards
                greater_than=0
            [/variable]
            [then]
                [cancel_action][/cancel_action]
            [/then]
        [/if]

        {CLEAR_VARIABLE number_of_guards,guard_location}
    [/event]

    [event]
        name=enter hex
        [filter]
            side=1
            x,y=13-19,8-10
        [/filter]

        [message]
            speaker=Darken Volk
            message= _ "Ahhh... I did not realize there was a swamp near this village. Malin, it would be beneficial for your training if we were to investigate."
        [/message]
    [/event]

    [event]
        name=moveto
        [filter]
            id=Darken Volk,Malin Keshar
            [filter_location]
                terrain=Ss,Ss^*,Sm,Sm^*
            [/filter_location]
        [/filter]

        [message]
            speaker=Darken Volk
            message=_ "Rise from the realms of death and decay!"
        [/message]

        [scroll_to]
            x,y=19,6
        [/scroll_to]

        {GENERIC_UNIT 1 Ghoul 19 6}
        [+unit]
            facing=sw
        [/unit]

        {GENERIC_UNIT 1 Ghoul 20 5}
        [+unit]
            facing=sw
        [/unit]

        {GENERIC_UNIT 1 Ghoul 20 6}
        [+unit]
            facing=sw
        [/unit]

        [redraw]
            side=1
            clear_shroud=yes
        [/redraw]

        [delay]
            time=1000
        [/delay]

        [redraw]
            side=1
        [/redraw]

        [message]
            speaker=Malin Keshar
            message= _ "What are these things?"
        [/message]

        [message]
            speaker=Darken Volk
            message= _ "They are ghouls — noxious beings fashioned from living flesh into carcasses of disease and poison. Those that outlive their masters gravitate towards the natural decay present in swamps and bogs."
        [/message]

        [message]
            speaker=Malin Keshar
            message= _ "Isn’t it cruel to turn men into such hideous forms?"
        [/message]

        [message]
            speaker=Darken Volk
            message= _ "You need not pity them. Once, these were... evil men... murderers and outlaws, no better than the orcs you hunt. I have transformed them so their physical forms match the spirits within. Is that not fitting? No punishment is too great for their kind."
        [/message]

        [message]
            speaker=Malin Keshar
            message= _ "I suppose so..."
        [/message]
    [/event]

    [event]
        name=die
        [filter]
            id="T'shar Lggi"
        [/filter]

        [message]
            speaker=Malin Keshar
            message= _ "The big wolf is done with."
        [/message]
    [/event]

    # Victory Condition
    [event]
        name=capture
        first_time_only=no
        [filter]
            side=1
        [/filter]
        # When capturing a village we check if we own all villages of the map
        [filter_condition]
            [not]
                [have_location]
                    terrain=*^V*

                    [not]
                        owner_side=1
                    [/not]
                [/have_location]
            [/not]
        [/filter_condition]

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

    [event]
        name=victory

        [message]
            speaker=Malin Keshar
            message= _ "Sacking goblin villages is all well and good, but corpses and bats will not stand up to full orcish warriors."
        [/message]

        [message]
            speaker=Darken Volk
            message= _ "Have some patience. We have only just begun your training. These carcasses will supply you sufficient resources for practice. When you have mastered the basics, we will then assault the orcs and you will see your forces grow quickly."
        [/message]

        [store_villages]
            variable=villages
        [/store_villages]

        [foreach]
            array=villages
            [do]
                {VARIABLE_OP village_var value "village_$this_item.x|_$this_item.y|_cleared"}

                {CLEAR_VARIABLE $village_var}
            [/do]
        [/foreach]

        {CLEAR_VARIABLE villages,village_var,done_shaun,key}
    [/event]

    {HERODEATH_MALIN}
    {HERODEATH_VOLK}

    {TIME_OVER_DEFEAT}
[/scenario]
