#textdomain wesnoth-did
[scenario]
    id=Saving_Parthyn
    next_scenario=Peaceful_Valley

    name=_ "Saving Parthyn"
    map_data="{campaigns/Descent_Into_Darkness/maps/Saving_Parthyn.map}"
    turns=15
    victory_when_enemies_defeated=no
    {DEFAULT_SCHEDULE}

    {INTRO_AND_SCENARIO_MUSIC the_city_falls.ogg northerners.ogg}
    {EXTRA_SCENARIO_MUSIC loyalists.ogg}
    {EXTRA_SCENARIO_MUSIC battle.ogg}

    # wmllint: local spellings stewpots
    [story]
        [part]
            story=_ "Malin Keshar was born 10 years after the death of Haldric IV. He grew up in the northern border town of Parthyn, the second child and eldest son of the baron of the city. Every summer when the mountain passes became clear, orcs came down from the north to prove themselves in battle. Every year Parthyn's guards repelled the raids, though some of the townsfolk were always lost. Malin's father led raiding parties to disrupt the orc encampments and send the orcs back to the north."
            background=story/parthyn.jpg
            scale_background=no
        [/part]
        [part]
            story=_ "When Malin was 10, a mage who passed through the town sensed strong magical abilities in the boy. His parents, seeing a chance for him to live away from the constant battles with the orcs, arranged for him to be sent to the mage community on the Isle of Alduin. There he studied for eight years, while back at home the orc raids increased in their frequency and ferocity. Before Malin could finish his training, however, he was expelled."
            background=story/parthyn.jpg
            scale_background=no
        [/part]
        [part]
            # good to have an arrow that arcs across the screen here
            story=_ "Malin returned to Parthyn just as summer began only to encounter more misfortune. Even as he arrived, an early, unexpected orc raid was being conducted against Parthyn. Malin watched as his father took an arrow in the chest and fell lifeless to the ground."
            background=story/parthyn.jpg
            scale_background=no
        [/part]
        [part]
            story=_ "Shaken by the loss of their commander, the human defense began to falter. As the orcs roared in anticipation of victory, skeleton warriors poured out of the woods to the orcs' rear. The soldiers watched in amazement as the skeletons cut down orc after orc and then melted back into the forest."
            background=story/parthyn.jpg
            scale_background=no
        [/part]
        # wmllint: local spelling misdoubt
        [part]
            # background=misc/blank.png
            # [image]
            #   # need my own necromancer picture
            #   file=gwiti.png
            #   x,y=284,204
            # [/image]
            story=_ "Shortly a man dressed in the robes of a necromancer emerged from the trees. 'Allow me to introduce myself. I am Darken Volk. While I know your kingdom does not love my kind, I think it vital that we put aside our differences for the moment. The orc menace grows in the North, and I misdoubt any of the border towns can stand without some assistance. For now, I ask only to rest in your town for a few days.'"
            background=story/parthyn.jpg
            scale_background=no
        [/part]
        [part]
            story=_ "Drogan, the captain of the guard, replied, 'Surely you know that the penalty for necromancy is death. For your aid we will promise you rest and safety. Upon your departure, however, you are banished from these lands, not to return on pain of death. We thank you for your help, but need no alliances with those who deal only in dark magic.'"
            background=story/parthyn.jpg
            scale_background=no
        [/part]
        [part]
            show_title=yes
            {TO_SAVING_PARTHYN}
        [/part]
    [/story]

    [side]
        side=1
        controller=human
        team_name=town guard
        user_team_name=_"Defenders"
        type=Apprentice Mage
        id=Malin Keshar
        name=_ "Malin Keshar"
        profile=portraits/malyoung.png
        unrenamable=yes
        canrecruit=yes
        recruit=Walking Corpse
        fog=no
        gold=70
    [/side]

    [side]
        side=2
        controller=ai
        team_name=orcs
        user_team_name=_"Orcs"
        type=Orcish Warrior
        id="Kreg'a'shar Trr"
        name=_ "Kreg'a'shar Trr"
        canrecruit=yes
        recruit=Orcish Grunt,Orcish Archer,Wolf Rider,Orcish Crossbowman
        {GOLD 100 140 160}
        [ai]
            aggression=0.8
            leader_value=3
            grouping=offensive
            caution=0.1
            recruitment_pattern=fighter,archer,scout
        [/ai]
    [/side]

    [side]
        side=3
        controller=ai
        team_name=town guard
        user_team_name=_"Defenders"
        type=Sergeant
        id=Drogan
        name=_ "Drogan"
        unrenamable=yes
        {GOLD 50 25 25}
        canrecruit=yes
        recruit=Peasant,Woodsman,Spearman
        [ai]
            village_value=0
            [protect_unit]
                id=Malin Keshar
                value=4
            [/protect_unit]
            caution=0.5
            #don't block Malins keep
            [avoid]
                x=30
                y=12
            [/avoid]
        [/ai]
    [/side]

    {STARTING_VILLAGES 3 10}

    [event]
        name=prestart

        # FIXME: Merge this map with the one for Return To Parthyn.
        # Scattering random trees on here would be a bad idea,
        # since we visit it twice.

        [objectives]
            side=1
            [objective]
                condition=win
                description=_ "Defend the river fort for two nights"
            [/objective]
            [objective]
                condition=lose
                description=_ "Orcs break through the river fort defenses"
            [/objective]
            [objective]
                condition=lose
                description=_ "Death of Malin Keshar"
            [/objective]
            [objective]
                condition=lose
                description=_ "Death of Drogan"
            [/objective]

            note={EARLY_FINISH_BONUS_NOTE}+{NEW_GOLD_CARRYOVER_NOTE_40}
        [/objectives]

        # Place signpost to mark area defended
        {PLACE_IMAGE scenery/signpost.png 27 13}
        {PLACE_IMAGE scenery/signpost.png 24 20}

        # Place starting units for Drogan and Malin
        {LOYAL_UNIT 1 (Spearman) 30 11}
        {LOYAL_UNIT 1 (Bowman) 31 12}
        {LOYAL_UNIT 1 (Spearman) 31 13}

        {LOYAL_UNIT 3 (Spearman) 5 17}
        {LOYAL_UNIT 3 (Swordsman) 6 17}
        {LOYAL_UNIT 3 (Spearman) 6 18}

        {VARIABLE malin_used_necromancy 0}
    [/event]

    [event]
        name=start

        [message]
            speaker=narrator
            message=_ "Malin, troubled by his father's death, argues to no avail that Darken Volk be allowed to stay to help defend the town. The necromancer leaves Parthyn without incident."
            image=wesnoth-icon.png
        [/message]
        [message]
            speaker=narrator
            message=_ "Several weeks pass..."
            image=wesnoth-icon.png
        [/message]
        [message]
            speaker=Drogan
            message=_ "Although I dislike sending a raiding party out so early, they should clear out the orc encampments and leave us a relatively quiet summer."
        [/message]
        [message]
            speaker=Malin Keshar
            message=_ "So much for quiet, Drogan. Orcs mass north of the river!"
        [/message]
        [message]
            speaker=Drogan
            message=_ "Curse them! You must hold the river fort, Malin, or they shall surely overrun the town. I will bring what soldiers remain to your aid. The raiding party is due to return in two days, and the orcs will not dare fight with such a force attacking from behind."
        [/message]
    [/event]

    # In-scenario Events
    [event]
        name=recruit
        first_time_only=yes
        [filter]
            type=Walking Corpse
        [/filter]

        [message]
            speaker=Drogan
            message=_ "What in blazes is that thing? Has the necromancer returned?"
        [/message]
        [message]
            speaker=Malin Keshar
            message=_ "No, Drogan. I raised this corpse with the skills Darken Volk taught to me before he left. While I have no love for it, without the help of the dead we consign ourselves and our families to orcish stewpots! Surely you can see that!"
        [/message]
        [message]
            speaker=Drogan
            message=_ "No benefit is worth the price of defiling the bodies of our dead! You have been very close-mouthed about why the mages sent you home from Alduin; if it was for dabbling in such arts, it is no wonder they cast you out!"
        [/message]
        [message]
            speaker=Malin Keshar
            message=_ "No! No...it was nothing like that...but I will not stand by and allow the orcs to destroy my home while I have the skills to prevent it!"
        [/message]

        {VARIABLE malin_used_necromancy 1}
    [/event]

    [event]
        name=moveto
        [filter]
            side=1
            x,y=27,13
        [/filter]
        [message]
            speaker=narrator
            message=_ "Welcome to Parthyn"
            image=scenery/signpost.png
        [/message]

        [allow_undo][/allow_undo]
    [/event]

    [event]
        name=moveto
        [filter]
            x,y=24,20
        [/filter]
        [message]
            speaker=narrator
            message=_ "Fear is the path to the dark side. Fear leads to anger. Anger leads to hate. Hate leads to suffering."
            image=wesnoth-icon.png
        [/message]
    [/event]

    # Defeat Conditions
    [event]
        name=moveto
        [filter]
            side=2
            x=0-27
            y=13-20
        [/filter]
        [message]
            speaker=Drogan
            message=_ "The orcs have broken through our line. Parthyn is open to attack!"
        [/message]
        [endlevel]
            result=defeat
        [/endlevel]
    [/event]

    {MALIN_DEATH}

    [event]
        name=die
        [filter]
            speaker=Drogan
        [/filter]
        [message]
            speaker=unit
            message=_ "Who will be left to defend Parthyn?"
        [/message]
        [endlevel]
            result=defeat
        [/endlevel]
    [/event]

#define VICTORY
    [kill]
        side=2
        animate=no
        event_fire=no
    [/kill]
    [if]
        [variable]
            name=malin_used_necromancy
            numerical_equals=1
        [/variable]
        [then]
            [message]
                speaker=Drogan
                message=_ "By all rights, I should have you executed on the spot, Malin. I certainly should have not given the necromancer the chance to corrupt you. Since I showed him mercy, however, I will give the same to you. You are hereby banished from Parthyn and all the Kingdom of Wesnoth."
            [/message]
            [message]
                speaker=Malin Keshar
                message=_ "Would you rather have let the orcs overrun the town and seen us both dead?"
            [/message]
            [message]
                speaker=Drogan
                message=_ "Aye, better that than to even dabble in dark magic. People would have rebuilt the town, just as they always have in the past. Would that the mages had taught you more sense."
            [/message]
            [message]
                speaker=Malin Keshar
                message=_ "The mages taught me enough. You won't truly banish me, will you, Drogan?"
            [/message]
            [message]
                speaker=Drogan
                message=_ "Begone, now. I've no wish to be forced to send the soldiers after you. Your father would be ashamed to see the end to which you've come."
            [/message]
        [/then]
        [else]
            [message]
                speaker=Drogan
                message=_ "That was bravely done, lad, holding the orcs off by yourself. The mages taught you well. But there is grave news from the village; your sister Dela was wounded in the attack. Healers attend her, but she may not live out the hour."
            [/message]
            [message]
                speaker=Malin Keshar
                message=_ "Orcs. Foul, pestilent creatures. The wide green world would be a better place with them all dead. Dead!"
            [/message]
            [message]
                speaker=Drogan
                message=_ "Perhaps, but if kings and great mages have not abolished them neither you nor I are ever likely to."
            [/message]
            [message]
                speaker=Malin Keshar
                message=_ "Perhaps I cannot kill them all...but I see the back-trail of this band we defeated, and there will be more orcs at the other end of it. I shall pursue them."
            [/message]
            [message]
                speaker=Drogan
                message=_ "And leave your sister?"
            [/message]
            [message]
                speaker=Malin Keshar
                message=_ "My hands were never apt for healing. But revenge I can give her."
            [/message]
            [message]
                speaker=Drogan
                message=_ "No! We need every man who can fight here, not lost in doomed attempt to harry the orcs in their own country!"
            [/message]
            [message]
                speaker=Malin Keshar
                message=_ "I am resolved."
            [/message]
            [message]
                speaker=Drogan
                message=_ "You'll go without my blessing or my men, then. I won't spare any on such an errand."
            [/message]
        [/else]
    [/if]
    [kill]
        side=1
        race=human
        [not]
            id=Malin Keshar
        [/not]
        animate=no
        fire_event=no
    [/kill]
    [endlevel]
        result=victory
        bonus=yes
        {NEW_GOLD_CARRYOVER 40}
    [/endlevel]
#enddef

    # Victory Conditions
    [event]
        name=time over

        [message]
            speaker=narrator
            message=_ "The raiding party returns, and the orcs flee in the face of a superior force."
            image=wesnoth-icon.png
        [/message]

        {VICTORY}
    [/event]

    # This is very unlikely, but just in case...
    [event]
        name=enemies defeated

        [message]
            speaker=narrator
            message=_ "The orcs are broken, dead or fled."
            image=wesnoth-icon.png
        [/message]

        {VICTORY}
    [/event]
[/scenario]
