#textdomain wesnoth-did
[scenario]
    id=Return_to_Parthyn
    next_scenario=A_Small_Favor

    name=_ "Return to Parthyn"
    map_data="{campaigns/Descent_Into_Darkness/maps/Return_to_Parthyn.map}"
    turns=-1

    victory_when_enemies_defeated=no
    {VICTORY_AND_DEFEAT_MUSIC}

    {STORY_RETURN_TO_HALAL}

    {DEFAULT_SCHEDULE}

    [side]
        side=1
        controller=human
        type=Apprentice Mage
        description=Malin Keshar
        user_description=_ "Malin Keshar"
        unrenamable=yes
        canrecruit=yes
        recruit=Walking Corpse,Vampire Bat,Ghost,Ghoul,Skeleton Archer,Skeleton,Dark Adept DiD
        gold=100
    [/side]

    [side]
        side=2
        controller=ai
        no_leader=yes
        {GOLD 120 160 200}
        recruit=Wolf Rider,Goblin Knight,Orcish Archer,Orcish Crossbowman,Orcish Grunt,Troll Whelp
        [ai]
            aggression=0.8
            villages_per_scout=8
            village_value=0.5
        [/ai]
    [/side]

    [side]
        side=3
        controller=ai
        team_name=guardsmen
        type=Lieutenant
        description=Drogan
        user_description=_ "Drogan"
        {GOLD 16 30 45}
        canrecruit=yes
        recruit=Spearman,Bowman
        [ai]
            aggression=0.2
            caution=0.5
        [/ai]
    [/side]

    {STARTING_VILLAGES 3 6}

    [side]
        side=4
        controller=ai
        team_name=guardsmen
        type=Frontier Baroness
        description=Dela Keshar
        user_description=_ "Dela Keshar"
        gender=female
        gold=200
        income=25
        canrecruit=yes
        recruit=Spearman,Bowman,Swordsman,Pikeman,Longbowman,Thug,Poacher,Footpad
        profile=portraits/dela.png
        [ai]
            [protect_unit]
                description=Drogan
                value=2
            [/protect_unit]
            [target]
                description=Malin Keshar
                value=2
            [/target]
        [/ai]
    [/side]

    {STARTING_VILLAGES 4 10}

    [event]
        name=prestart
        [music]
            name=revelation.ogg
        [/music]

        [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]
        [/objectives]

        # Place orcish leader
        [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}

        # 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
        {LOYAL_UNIT 3 (Spearman) 30 11 (River fort guard) ( _ "River fort guard")}
        {LOYAL_UNIT 3 (Bowman) 31 12 (River fort guard) ( _ "River fort guard")}
        {LOYAL_UNIT 3 (Spearman) 31 13 (River fort guard) ( _ "River fort guard")}
    [/event]

    [event]
        name=start
        {CREATE_ADVISOR}
        {DIALOGUE_RTH_START}
    [/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]

    # Defeat Conditions
    [event]
        name=die
        [filter]
            side=3,4
        [/filter]
        [filter_second]
            side=1
        [/filter_second]
        [if]
            [have_unit]
                description=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

#define ESCAPE_EVENT
    {PLACE_IMAGE scenery/signpost.png 8 1}
    [scroll_to]
        x,y=8,1
    [/scroll_to]
    [objectives]
        side=1
        [objective]
            condition=win
            description=_ "Escape to the northwest"
        [/objective]
        [objective]
            condition=lose
            description= _ "Death of Malin Keshar"
        [/objective]
    [/objectives]
    [music]
        name=loyalists.ogg
        append=no
        immediately=yes
    [/music]
    [event]
        name=moveto
        description=Malin Keshar
        [filter]
            x,y=8,1
        [/filter]
        {DIALOGUE_RTH_END}
        [endlevel]
            bonus=no
            result=continue
        [/endlevel]
    [/event]
#enddef

    [event]
        name=die
        [filter]
            description=Drogan
        [/filter]
        {DIALOGUE_RTH_DROGANDEATH}
        {ESCAPE_EVENT}
        [event]
            name=die
            [filter]
                side=3,4
                [not]
                    description=Drogan
                [/not]
            [/filter]
            [filter_second]
                side=1
            [/filter_second]
            {DIALOGUE_RTH_GUARDDEATH}
        [/event]
    [/event]

    {@campaigns/Descent_Into_Darkness/utils/global-events.cfg}
[/scenario]
