#textdomain wesnoth-did
[scenario]
    id=04_Beginning_of_the_Revenge
    next_scenario=05_Orc_War

    name=_ "Beginning of the Revenge"
    map_data="{campaigns/Descent_Into_Darkness/maps/04_Beginning_of_the_Revenge.map}"
    turns=36
    victory_when_enemies_defeated=yes
    {DUSK}
    {FIRST_WATCH}
    {SECOND_WATCH}
    {DAWN}
    {MORNING}
    {AFTERNOON}

    {INTRO_AND_SCENARIO_MUSIC revelation.ogg vengeful.ogg}
    {EXTRA_SCENARIO_MUSIC nunc_dimittis.ogg}
    {EXTRA_SCENARIO_MUSIC knalgan_theme.ogg}
    {EXTRA_SCENARIO_MUSIC northerners.ogg}

    [story]
        [part]
            story=_ "Burning inside with a desire to take his revenge against the orcs and push them further north, Malin spends the winter learning as much from Darken Volk as he can. His years of study with the mages serve him well, and his power grows quickly."
            background=story/travel.jpg
            scale_background=no
        [/part]
        [part]
            story=_ "When spring comes, the two head north to a mountain pass known to Darken Volk. In the higher reaches the snow is just beginning to melt, making the passage treacherous. The elder necromancer insists that they press on. He says that he hopes to catch the orc fighters unprepared by arriving early in the year, thereby inflicting as much damage as possible."
            background=story/travel.jpg
            scale_background=no
        [/part]
        [part]
            show_title=yes
            {TO_BEGINNING_OF_THE_REVENGE}
        [/part]
    [/story]

    [side]
        side=1
        controller=human
        type=Apprentice Mage
        id=Malin Keshar
        name=_ "Malin Keshar"
        profile=portraits/malin_old.png
        unrenamable=yes
        canrecruit=yes
        recruit=Walking Corpse,Vampire Bat,Ghost,Ghoul,Skeleton Archer,Skeleton
        fog=no
        shroud=no
        gold=140
        {FLAG_VARIANT undead}
    [/side]

    [side]
        side=2
        controller=ai
        team_name=orcs
        user_team_name=_"Orcs"
        type=Orcish Warlord
        id="Gron'r Hronk"
        name=_ "Gron’r Hronk"
        canrecruit=yes
        recruit=Orcish Archer,Orcish Crossbowman,Wolf Rider,Orcish Grunt
        {GOLD 120 150 180}
        fog=no
        shroud=no
        [ai]
            aggression=0.5
            caution=0.1
            villages_per_scout=8
            village_value=0.5
            recruitment_pattern=scout,archer,archer,fighter
        [/ai]
        {FLAG_VARIANT ragged}
    [/side]

    {STARTING_VILLAGES 2 8}

    [side]
        side=3
        controller=ai
        team_name=orcs
        user_team_name=_"Orcs"
        type=Orcish Warlord
        id="K'rrlar Oban"
        name=_ "K’rrlar Oban"
        canrecruit=yes
        recruit=Orcish Crossbowman,Wolf Rider,Goblin Pillager,Orcish Grunt
        {GOLD 130 170 210}
        fog=no
        shroud=no
        [ai]
            aggression=0.5
            caution=0.2
            villages_per_scout=6
            recruitment_pattern=archer,scout,fighter
        [/ai]
        {FLAG_VARIANT ragged}
    [/side]

    {STARTING_VILLAGES 3 8}

    [event]
        name=prestart

        [objectives]
            side=1
            [objective]
                condition=win
                description=_ "Move Malin to the end of the mountain pass"
            [/objective]
            [objective]
                {ALTERNATIVE_OBJECTIVE_CAPTION}
                condition=win
                description=_ "Kill the orc leaders"
            [/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]

        # Signpost at the end of the pass
        {PLACE_IMAGE scenery/signpost.png 18 1}

        # {SCATTER_IMAGE (terrain=Gg) 2 scenery/oak-leaning.png}
        # {SCATTER_IMAGE (terrain=Gg) 3 scenery/snowbits.png}

        [recall]
            id=Darken Volk
        [/recall]

        {MODIFY_UNIT (id=Malin Keshar) profile (portraits/malin_old.png)}
    [/event]

    [event]
        name=start

        [message]
            speaker=Darken Volk
            message=_ "Orcs block the way out of the mountain pass. Destroy them, and we will move on to bigger targets."
        [/message]
        [message]
            speaker=Malin Keshar
            message=_ "With the might of the undead at my command, many orcs will die this day. They shall pay for getting me banished from Parthyn."
        [/message]
    [/event]

    # In-scenario events
    [event]
        name=die
        first_time_only=yes
        [filter]
            race=orc
        [/filter]

        [filter_second]
            side=1
        [/filter_second]

        [message]
            speaker=Malin Keshar
            message=_ "Feel my wrath, vile creature!"
        [/message]
    [/event]

    [event]
        name=moveto

        [filter]
            side=1

            [not]
                type=Ghost,Wraith,Spectre,Shadow,Nightgaunt,Vampire Bat,Blood Bat,Dread Bat
            [/not]

            [filter_location]
                terrain=Ai
            [/filter_location]
        [/filter]

        [message]
            speaker=Malin Keshar
            message=_ "The ice doesn’t look very thick..."
        [/message]

        #[message]
        #    speaker=Darken Volk
        #    message=_ "..."
        #[/message]

        [allow_undo]
        [/allow_undo]
    [/event]

    [event]
        name=new turn
        first_time_only=no

        [store_locations]
            [filter]
                [not]
                    type=Ghost,Wraith,Spectre,Shadow,Nightgaunt,Vampire Bat,Blood Bat,Dread Bat
                [/not]
            [/filter]

            find_in=weakened_ice

            variable=breaking_ice
        [/store_locations]

        {FOREACH breaking_ice i}
            [scroll_to]
                x,y=$breaking_ice[$i].x,$breaking_ice[$i].y
            [/scroll_to]

            [terrain]
                x,y=$breaking_ice[$i].x,$breaking_ice[$i].y
                terrain=Wo
            [/terrain]

            [remove_item]
                x,y=$breaking_ice[$i].x,$breaking_ice[$i].y
                image=misc/weakened-ice.png
            [/remove_item]

            [redraw]
            [/redraw]

            [if]
                [have_unit]
                    x,y=$breaking_ice[$i].x,$breaking_ice[$i].y
                    race=undead
                [/have_unit]

                [then]
                    [message]
                        speaker=narrator
                        message=_ "The weak ice gives way beneath the undead creature, who becomes mired in the thick mud at the lake’s bottom."
                        image=wesnoth-icon.png
                    [/message]
                [/then]

                [else]
                    [message]
                        speaker=narrator
                        message=_ "The weak ice gives way beneath the heavy warrior, who drowns in the frigid mountain waters."
                        image=wesnoth-icon.png
                    [/message]
                [/else]
            [/if]

            [sound]
                name=water-blast.wav
            [/sound]

            [kill]
                x,y=$breaking_ice[$i].x,$breaking_ice[$i].y
                animate=yes
                fire_event=yes
            [/kill]
        {NEXT i}

        [store_locations]
            terrain=Ai

            [filter]
                [not]
                    type=Ghost,Wraith,Spectre,Shadow,Nightgaunt,Vampire Bat,Blood Bat,Dread Bat
                [/not]
            [/filter]

            [or]
                terrain=Ai

                find_in=weakened_ice
            [/or]

            variable=weakened_ice
        [/store_locations]

        {FOREACH weakened_ice i}
            [item]
                x,y=$weakened_ice[$i].x,$weakened_ice[$i].y
                image=misc/weakened-ice.png
            [/item]
        {NEXT i}

        {CLEAR_VARIABLE breaking_ice}
    [/event]

    # Defeat Conditions
    {MALIN_DEATH}
    {VOLK_DEATH}
    {TIME_OUT_LOSE}

    # Victory Condition
    [event]
        name=moveto
        [filter]
            id=Malin Keshar
            x,y=18,1
        [/filter]

        {CLEAR_VARIABLE weakened_ice}

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

    [event]
        name=enemies defeated

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