#textdomain wesnoth-did
[scenario]
    id=06_Return_to_Parthyn
    next_scenario=07_A_Small_Favor

    name=_ "Return to Parthyn"
    map_data="{campaigns/Descent_Into_Darkness/maps/06_Return_to_Parthyn.map}"
    turns=-1
    victory_when_enemies_defeated=no
    {DEFAULT_SCHEDULE}

    {INTRO_AND_SCENARIO_MUSIC breaking_the_chains.ogg the_city_falls.ogg}
    {EXTRA_SCENARIO_MUSIC knolls.ogg}
    {EXTRA_SCENARIO_MUSIC elvish-theme.ogg}

    [story]
        [part]
            story=_ "Two days travel south of the previous battle, Malin loses the trail of the regrouped orcish warriors, but soon picks it up again. The trail moves unfailingly south for several days. As soon as it crosses the Great River it immediately turns west."
            background=story/parthyn.jpg
            scale_background=no
        [/part]
        [part]
            story=_ "Within a few days, Malin recognizes some familiar surroundings..."
            background=story/parthyn.jpg
            scale_background=no
        [/part]
        [part]
            show_title=yes
            {TO_RETURN_TO_PARTHYN}
        [/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,Dark Adept DiD
        {GOLD 200 150 100}
        {FLAG_VARIANT undead}
    [/side]

    # A fallback leader is defined for side 2 here just in case the stored unit
    # doesn't exist for some reason, like if the player has used debug mode to
    # jump to this scenario.
    [side]
        side=2
        controller=ai
        type=Orcish Warlord
        id=Borth
        name=_ "Borth"
        profile=portraits/orcs/transparent/warlord.png
        canrecruit=yes
        {GOLD 120 160 200}
#ifdef EASY
        recruit=Wolf Rider,Orcish Archer,Orcish Grunt,Troll Whelp
#else
        recruit=Wolf Rider,Goblin Knight,Orcish Archer,Orcish Crossbowman,Orcish Grunt,Troll Whelp
#endif
        [ai]
            aggression=0.8
            villages_per_scout=8
            village_value=0.5
        [/ai]
        {FLAG_VARIANT ragged}
    [/side]

    [side]
        side=3
        controller=ai
        team_name=guardsmen
        user_team_name=_"Guardsmen"
        type=Lieutenant
        id=Drogan
        name=_ "Drogan"
        profile=portraits/drogan.png
        {GOLD 16 30 45}
        canrecruit=yes
        recruit=Spearman,Bowman
        [ai]
            aggression=0.2
            caution=0.5
        [/ai]
        {FLAG_VARIANT loyalist}
    [/side]

    {STARTING_VILLAGES 3 6}

    [side]
        side=4
        controller=ai
        team_name=guardsmen
        user_team_name=_"Defenders"
        type=Frontier Baroness
        id=Dela Keshar
        name=_ "Dela Keshar"
        profile=portraits/dela.png
        gold=200
        income=25
        canrecruit=yes
        recruit=Spearman,Bowman,Swordsman,Pikeman,Longbowman,Thug,Poacher,Footpad
        [ai]
            [protect_unit]
                id=Drogan
                value=2
            [/protect_unit]
            [target]
                id=Malin Keshar
                value=2
            [/target]
        [/ai]
        {FLAG_VARIANT loyalist}
    [/side]

    {STARTING_VILLAGES 4 10}

    # For storyline purposes, make it impossible to kill Dela.
    {FORCE_CHANCE_TO_HIT side=1,2 id="Dela Keshar" 0 ()}

    [event]
        name=prestart

        [objectives]
            side=1
            [objective]
                condition=win
                description= _ "Remove the traitor Drogan"
            [/objective]
            [objective]
                condition=lose
                description= _ "Kill any people from Parthyn but Drogan"
            [/objective]
            [objective]
                condition=lose
                description= _ "Death of Malin Keshar"
            [/objective]

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

        # Replace the fallback orcish leader with the stored one from the
        # previous scenario
        [if]
            [variable]
                name=orc_leader_store.side
                not_equals=$empty
            [/variable]

            [then]
                [set_variable]
                    name=orc_leader_store.x
                    value=29
                [/set_variable]
                [set_variable]
                    name=orc_leader_store.y
                    value=2
                [/set_variable]
                [set_variable]
                    name=orc_leader_store.side
                    value=2
                [/set_variable]
                [unstore_unit]
                    variable=orc_leader_store
                    find_vacant=no
                [/unstore_unit]
                {CLEAR_VARIABLE orc_leader_store}
            [/then]
        [/if]

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

        # Place signpost
        {PLACE_IMAGE scenery/signpost.png 27 13}

        # Drogan has some guards at the river fort
        {NAMED_LOYAL_UNIT 3 (Spearman) 30 11 () ( _ "River fort guard")}
        {NAMED_LOYAL_UNIT 3 (Bowman) 31 12 () ( _ "River fort guard")}
        {NAMED_LOYAL_UNIT 3 (Spearman) 31 13 () ( _ "River fort guard")}
    [/event]

    [event]
        name=start
        {CREATE_ADVISOR}

        [message]
            speaker=Malin Keshar
            message=_ "I bring word of a great victory against the orcs, Drogan."
        [/message]
        [message]
            speaker=Drogan
            message=_ "I had hoped you would never return, Malin. You have been banished, and now return. You give me no choice but to order my soldiers to attack you."
        [/message]
        [message]
            role=advisor
            message=_ "Master, do not listen to the lies he tells. There is always a choice, and he chooses to attack you. He jeopardizes the safety of Parthyn!"
        [/message]
        [message]
            speaker=Malin Keshar
            message=_ "Silence from you."
        [/message]
        [message]
            speaker=Malin Keshar
            message=_ "I have eliminated two orc chieftains. I doubt that we will see any orc raids this summer. The beasts will be too busy trying to regroup."
        [/message]
        [message]
            speaker=Dela Keshar
            message=_ "You are mistaken, brother. Even now the orcs camp north of the river."
        [/message]
        [message]
            speaker=Malin Keshar
            message=_ "I have been tracking that band since they fled the field at my great victory! But how did they get north of the river? Let my forces be and I will deal with them."
        [/message]
        [message]
            speaker=Drogan
            message=_ "A nice story. I find it more likely that you brought your orcish allies here with you to take your revenge upon the city. If we stand down your undead will no doubt kill us where we stand. Watching you grow up, I never could have believed you would turn into a traitor."
        [/message]
        [message]
            role=advisor
            message=_ "Master, he threatens the safety of the city by standing in your way."
        [/message]
        [message]
            speaker=Malin Keshar
            message=_ "Then you are the traitor, Drogan, for preventing me from protecting the city. I will defend Parthyn, and if you stand in my way I will cut you down for the treason you commit."
        [/message]
    [/event]

    # In-scenario Events
    [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]

    # Dela Keshar can't actually die here, she needs to reappear in
    # Alone At Last.  It's not easy to get to this contingency, which
    # is why we settle for a relatively crude fallback here.
    [event]
        name=last breath
        [filter]
            id=Dela Keshar
        [/filter]
        [message]
            speaker=Dela Keshar
            message=_ "I am defeated but not dead, foul thing that was once my brother. Watch your back, because I will be coming for you..."
        [/message]
    [/event]

    # Defeat Conditions
    [event]
        name=die
        [filter]
            side=3,4
        [/filter]
        [filter_second]
            side=1
        [/filter_second]
        [if]
            [have_unit]
                id=Drogan
            [/have_unit]
            [then]
                [message]
                    speaker=Malin Keshar
                    message=_ "Now the people of Parthyn will never accept me back!"
                [/message]
                [endlevel]
                    result=defeat
                [/endlevel]
            [/then]
        [/if]
    [/event]

    {MALIN_DEATH}

    # Victory Conditions

    [event]
        name=die
        [filter]
            id=Drogan
        [/filter]

        [message]
            speaker=Malin Keshar
            message=_ "See what your traitorous ways have won you, Drogan?"
        [/message]
        [message]
            speaker=Dela Keshar
            message=_ "You will pay for Drogan’s death. Now that I have seen the true evil to which you have come, I will commit every guardsman to your demise. It pains me to think that you were once my brother."
        [/message]
        [message]
            speaker=Malin Keshar
            message=_ "Even with my new power, I cannot fight the entire town as well as the orcs. I must flee to the west to find Darken Volk!"
        [/message]

        {HIGHLIGHT_IMAGE 8 1 scenery/signpost.png ()}

        [objectives]
            side=1
            [objective]
                condition=win
                description=_ "Escape to the northwest"
            [/objective]
            [objective]
                condition=lose
                description= _ "Death of Malin Keshar"
            [/objective]

            [gold_carryover]
                bonus=no
                carryover_percentage=40
            [/gold_carryover]
        [/objectives]
        {INCIDENTAL_MUSIC loyalists.ogg}
        [event]
            name=moveto
            [filter]
                id=Malin Keshar
                x,y=8,1
            [/filter]

            [message]
                speaker=Dela Keshar
                message=_ "While our forces must stay here to fight off your pet orcs, when we are done I shall come after you. You are my brother no longer."
            [/message]
            [message]
                speaker=Malin Keshar
                # wmllint: local spelling zephrin
                message=_ "Gods of Darkness, how did it come to this? My own sister determined on my death. Nothing has gone right since... since that day the fat toad Zephrin mocked my up-country accent and I lost my temper and cursed him with boils. <i>“A life curse goes beyond a joke,”</i> they said. <i>“Poor judgment,”</i> they said, and expelled me from the Academy."
            [/message]
            [message]
                speaker=Malin Keshar
                message=_ "Now the only being who still wants to keep me alive is a necromancer. Curse them all! Live or die, I’ll have my revenge on those that have wronged me."
            [/message]

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

        [event]
            name=die
            [filter]
                side=3,4
                [not]
                    id=Drogan
                [/not]
            [/filter]
            [filter_second]
                side=1
            [/filter_second]

            [message]
                speaker=Malin Keshar
                message=_ "See how you die when you spurn the help of Malin Keshar!"
            [/message]
        [/event]
    [/event]
[/scenario]
