#textdomain wesnoth-did

[scenario]
    id=05_Schism
    name= _ "Schism"
    map_file=05_Schism.map
    victory_when_enemies_defeated=yes
    turns=37
    next_scenario=06_Return_to_Parthyn

    {DEFAULT_SCHEDULE_MORNING}

    {INTRO_AND_SCENARIO_MUSIC battle.ogg northerners.ogg}
    {EXTRA_SCENARIO_MUSIC northern_mountains.ogg}
    {EXTRA_SCENARIO_MUSIC siege_of_laurelmor.ogg}

    # this is a proper battle scenario really focused on armies for once, so this one doesn't have any really special events; it's nice to have just this one vanilla scenario in the campaign
    # there's also a lot less dialogue here intentionally because Malin's focused on fighting off the orcs
    # when he does kill a chieftain, he doesn't give them time to speak (it's a tough battle, he doesn't spare the time or the energy to deal with them)
    # noting that it's a tough battle, the scenario should be appropriately difficult

    [story]
        [part]
            story=_ "The cycle of the seasons churns and summer and fall roll around once more. Malin’s thoughts turn back to Parthyn frequently, where a year prior, he had still been among family and friends in the rustic little town that he still thinks of as his home. He has since become a forsaken wanderer, he thinks, but the still burning image of his father being cut down amidst the ruins of his home is stamped deep into his thoughts."
            {STORYTXT_BACKGROUND travel.webp}
        [/part]
        [part]
            story=_ "Companionship and peace... perhaps they are but a farce and certainly an impossibility with the threat of the orcish clans still looming. It was a choice to live and suffer the path of solitary vengeance rather than appease the law of his land... and thus watch his home burn. It was a choice, he admits, not destiny, not fate. It is a choice that he oft ponders, but usually comes to the same conclusion. Perhaps there is no point in reminiscing on his once tranquil, pastoral life. He has never been one for regrets."
            {STORYTXT_BACKGROUND travel.webp}
        [/part]
        [part]
            story=_ "Malin turns his attention to the task at hand. Darken Volk leads him through the heart of the Whitefang territory, where they terrorize and murder entire camps of orcs with their undead minions. Word spreads among the orcish towns, which begin to post more guards and dispatch frequent patrols to exterminate the two necromancers. All of their attempts fail."
            {STORYTXT_BACKGROUND travel.webp}
        [/part]
        [part]
            story=_ "As Malin and Darken Volk continue their raids on the orcs, they eventually force the usually fractious Whitefang chieftains to unite in opposition. The orcs pursue the two necromancers east toward the mouth of the river humans call the Longlier and elves call the Arkan-thoria, where they manage to surround the humans and force a fight."
            {STORYTXT_BACKGROUND travel.webp}
        [/part]
    [/story]

    {DID_TRACK {JOURNEY_05_NEW}}

    # wmllint: validate-off
    [side]
        side=1
        controller=human
        recruit=Walking Corpse,Vampire Bat,Ghost,Ghoul,Skeleton Archer,Skeleton
        {GOLD 190 170 150}
        team_name=good
        user_team_name= _ "Malin Keshar"
        {FLAG_VARIANT undead}
        color=darkblue

        # wmllint: recognize Malin Keshar
        {CHARACTER_STATS_MALIN_KESHAR}

        facing=sw
    [/side]
    # wmllint: validate-on

    [side]
        side=2
        controller=ai
        recruit=Goblin Spearman,Orcish Archer,Orcish Crossbowman,Orcish Grunt,Orcish Warrior
        {GOLD 30 40 50}
        {INCOME 4 7 10}
        team_name=orcs
        user_team_name=_"Orcs"
        {FLAG_VARIANT6 ragged}
        color=white

        type=Orcish Warlord
        id=Borth
        name= _ "Borth"
        profile=portraits/orcs/warlord.webp
        canrecruit=yes

        facing=se

        [ai]
            villages_per_scout=8
            village_value=0.5
            [goal]
                name=target
                [criteria]
                    id=Malin Keshar
                [/criteria]
                value=3
            [/goal]
            [goal]
                name=target
                [criteria]
                    id=Darken Volk
                [/criteria]
                value=3
            [/goal]
        [/ai]
    [/side]

    [side]
        side=3
        controller=ai
        recruit=Orcish Archer,Goblin Pillager,Orcish Grunt,Wolf Rider,Goblin Knight
        {GOLD 40 50 60}
        {INCOME 6 9 12}
        team_name=orcs
        user_team_name= _ "Orcs"
        {FLAG_VARIANT6 ragged}
        color=white

        type=Orcish Warlord
        id="P'Gareth"
        name= _ "P’Gareth"
        profile=portraits/orcs/grunt-3.webp
        canrecruit=yes

        facing=ne

        [ai]
            scout_village_targeting=2
            village_value=0.5
            [goal]
                name=target
                [criteria]
                    id=Malin Keshar
                [/criteria]
                value=3
            [/goal]
            [goal]
                name=target
                [criteria]
                    id=Darken Volk
                [/criteria]
                value=3
            [/goal]
        [/ai]
    [/side]

    [side]
        side=4
        controller=ai
        recruit=Orcish Archer,Troll Whelp,Troll,Troll Rocklobber,Orcish Assassin,Orcish Grunt
        {GOLD 30 45 60}
        {INCOME 4 7 10}
        team_name=orcs
        user_team_name= _ "Orcs"
        {FLAG_VARIANT6 ragged}
        color=white

        type=Orcish Warlord
        id="K'Vark"
        name= _ "K’Vark"
        profile=portraits/orcs/grunt-5.webp
        canrecruit=yes

        facing=nw

        [ai]
            villages_per_scout=6
            village_value=0.5
            [goal]
                name=target
                [criteria]
                    id=Malin Keshar
                [/criteria]
                value=3
            [/goal]
            [goal]
                name=target
                [criteria]
                    id=Darken Volk
                [/criteria]
                value=3
            [/goal]
        [/ai]
    [/side]

    [label]
        x,y=16,14
        text= _ "River Longlier"
    [/label]

    {STARTING_VILLAGES 1 6}
    {STARTING_VILLAGES 2 5}
    {STARTING_VILLAGES 3 6}
    {STARTING_VILLAGES 4 5}

    {PLACE_IMAGE scenery/whitefang-flag.png 35 10}
    {PLACE_IMAGE scenery/whitefang-flag.png 5 5}
    {PLACE_IMAGE scenery/whitefang-flag.png 6 22}

    [event]
        name=prestart

        {CLEAR_CORPSE_HORDE}

        {COLOR_ADJUST -12 -12 -12}

        [objectives]
            side=1
            [objective]
                condition=win
                description= _ "Kill the orcish 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]

        [recall]
            id=Darken Volk
        [/recall]

        {MODIFY_UNIT (side=1) facing sw}
    [/event]

    [event]
        name=start

        [message]
            speaker=Malin Keshar
            message= _ "Even before the very founding of Wesnoth, you have hounded my people at every turn. You have trampled our fields, slaughtered our livestock, and burned our houses. You have brought war to a place of peace and death to a place of life. You are nothing but remorseless killers and savage beasts. Your kind deserves no mercy and shall receive none. I will crush you into the dust and make you into my slaves for all eternity."
        [/message]

        [message]
            speaker=Borth
            message= _ "The silly necromancer is trying to talk us to death! You have caused us enough trouble, human. It is time for you to die."
        [/message]

        [message]
            speaker="P'Gareth"
            message= _ "Ummm... unless... you are already dead, like the skeletons?"
        [/message]

        [message]
            speaker="K'Vark"
            message= _ "Then it will be time for you to die again!"
        [/message]
    [/event]

    [event]
        name=die
        first_time_only=no
        [filter]
            side=2,3,4
            canrecruit=yes
        [/filter]
        [filter_condition]
            [have_unit]
                side=2,3,4
                canrecruit=yes

                [not]
                    side=$unit.side
                [/not]

                count=2
            [/have_unit]
        [/filter_condition]

        [message]
            speaker=Malin Keshar
            message= _ "How puny and weak you look in death."
        [/message]
    [/event]

    # Victory Condition
    [event]
        name=die
        first_time_only=no
        [filter]
            side=2,3,4
            canrecruit=yes
        [/filter]
        [filter_condition]
            [have_unit]
                side=2,3,4
                canrecruit=yes

                [not]
                    side=$unit.side
                [/not]

                count=1
            [/have_unit]
        [/filter_condition]

        [message]
            speaker=Malin Keshar
            message= _ "You and your kind deserve no eternal rest in death. After this battle, I’ll raise your corpse and make your bones dance for me, orc. But for now, I’ve one last one to take care of—"
        [/message]

        [store_unit]
            [filter]
                side=2,3,4
                canrecruit=yes

                [not]
                    side=$unit.side
                [/not]
            [/filter]

            kill=no
            variable=remaining_orc_leader
        [/store_unit]

        [switch]
            variable=remaining_orc_leader.side
            [case]
                value=2
                {VARIABLE escape_to_x 11}
                {VARIABLE escape_to_y 1}
            [/case]

            [case]
                value=3
                {VARIABLE escape_to_x 8}
                {VARIABLE escape_to_y 26}
            [/case]

            [case]
                value=4
                {VARIABLE escape_to_x 40}
                {VARIABLE escape_to_y 7}
            [/case]
        [/switch]

        [object]
            silent=yes

            [filter]
                x,y=$remaining_orc_leader.x,$remaining_orc_leader.y
            [/filter]

            [effect]
                apply_to=hitpoints
                heal_full=yes
            [/effect]
        [/object]

        [message]
            speaker=$remaining_orc_leader.id
            message= _ "Retreat!"
        [/message]

        [store_unit]
            [filter]
                x,y=$remaining_orc_leader.x,$remaining_orc_leader.y
            [/filter]

            kill=yes
            variable=orc_leader_store
        [/store_unit]

        {CLEAR_VARIABLE orc_leader_store.status.poisoned}

        [move_unit_fake]
            type=$remaining_orc_leader.type
            side=$remaining_orc_leader.side
            x=$remaining_orc_leader.x,$escape_to_x
            y=$remaining_orc_leader.y,$escape_to_y
        [/move_unit_fake]

        {CLEAR_VARIABLE remaining_orc_leader,escape_to_x,escape_to_y}

        [message]
            speaker=Malin Keshar
            message= _ "He flees! The coward!"
        [/message]

        [message]
            speaker=Darken Volk
            message= _ "That is no surprise. Orcs may like to make a show of strength, but will always flee in the face of an overwhelming force. Nevertheless, the Whitefangs are still numerous and have some ties to other orcish clans. You must hunt this chieftain down before he can alert the others, else we may soon have dozens more on our tail."
        [/message]

        [message]
            speaker=Malin Keshar
            message= _ "By ‘you’, you mean... on my own?"
        [/message]

        [message]
            speaker=Darken Volk
            message= _ "Your apprenticeship is nearly over; you are more than capable of handling a single, half-dead orc on your own. After you have dealt with him, I do have a small favor I will ask of you. It will constitute the last part of your... training. I have some other things that I must attend to in preparation. In a few weeks, meet with me to the west, near the town of Tath."
        [/message]

        [message]
            speaker=Malin Keshar
            message= _ "It will be done."
        [/message]

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

    [event]
        name=victory

        # Heal Darken Volk and store him for his return in A Small Favor
        {FULL_HEAL (id=Darken Volk)}

        [store_unit]
            [filter]
                id=Darken Volk
            [/filter]
            variable=darken_volk_store
            kill=yes
        [/store_unit]
    [/event]

    {HERODEATH_MALIN}
    {HERODEATH_VOLK}

    {TIME_OVER_DEFEAT}
[/scenario]
