#textdomain wesnoth-dm
[scenario]
    id=21_Clash_at_the_Manor
    name= _ "Clash at the Manor"
    next_scenario="22_Face_of_the_Enemy"
    victory_when_enemies_defeated=false
    {MEMOIRS_MAP 21_Clash_at_the_Manor.map}
    {TURNS 40 32 30}
    {DEFAULT_SCHEDULE}

    {INTRO_AND_SCENARIO_MUSIC nunc_dimittis.ogg elvish-theme.ogg}
    {EXTRA_SCENARIO_MUSIC the_king_is_dead.ogg}
    {EXTRA_SCENARIO_MUSIC frantic.ogg}
    {EXTRA_SCENARIO_MUSIC the_city_falls.ogg}

    [story]
        [part]
            show_title=yes
        [/part]
        [part]
            # Asheviere was already having secret talks with
            # the orcs about the early HttT events and Lionel’s mission
            #po: "demesne" = the part of a feudal lord's lands reserved for
            #po: personal use.
            #po: The "Sceptre" spelling is intentional.
            story=_ "Upon his return to Weldyn, Delfador discovered that the queen had left with a strong escort to visit her family’s demesne and her ailing parents. Lionel, the King’s most trusted general, had been sent at Asheviere’s request on an errand to Knalga to retrieve the Sceptre of Fire. That mission would cost Lionel his life; and neither Lionel nor Delfador knew that Lionel’s mission had been compromised from the start."
        [/part]
        [part]
            story= _ "Although the King did reprimand Eldred for his actions, Delfador could sense that the military commanders were solidly behind Eldred and his mother. Asheviere had flattered them and beguiled them with promises of glory and plunder in a coming war."
            delay=4000
        [/part]
        [part]
            story= _ "Delfador was granted an audience with the King and expressed his concerns about the Book, but the King put off a decision until Asheviere returned to Weldyn, and ordered Delfador to take no further action. And for once, Delfador knew he could not obey the King’s order."
            delay=4000
        [/part]
        [part]
            story= _ "Since he could not ask even his personal guard to go against the King’s wishes, he turned to Kalenz and the elves. Traveling by night to remain unseen they reached Asheviere’s family demesne."
            delay=4000
        [/part]
    [/story]

    #### Delfador's code ####
    #wmllint: validate-off
    [side]
        {YOUNG_DELFADOR}
        profile="portraits/young_delfador.png"
        type=Journeyman Mage
        # wmllint: recognize Delfador
        canrecruit=yes
        recruit={ELVES}
        fog=yes
        {GOLD 130 100 100}
        {FLAG_VARIANT long}
    [/side]
    #wmllint: validate-on

    # wmllint: recognize Kalenz
    # wmllint: recognize Chantal
    [event]
        name=prestart
        {ELVISH_NPCS_REAPPEAR}
    [/event]
    #### /Delfador's code ####

    [side]
        type=General
        id=Pilafman
        name=_ "Pilafman"
        #    profile="portraits/eldred.png"
        side=2
        canrecruit=yes
        controller=ai
        team_name=wesnoth
        recruit=Heavy Infantryman,Spearman,Bowman,Cavalryman,Swordsman,Pikeman,Longbowman,Shock Trooper,Dragoon,Royal Guard
        {GOLD 130 180 200}
        {INCOME 0 2 2}
        [ai]
            #recruitment_pattern=fighter,archer,mixed fighter,scout
            aggression=1.0
            caution=0.0
            protect_leader=3.0
        [/ai]
        {FLAG_VARIANT loyalist}
    [/side]

    [event]
        name=prestart
        [objectives]
            side=1
            [objective]
                description= _ "Defeat Pilafman"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Delfador"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Kalenz"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Chantal"
                condition=lose
            [/objective]
            [objective]
                description= _ "Enemy unit reaches the signpost"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

            [gold_carryover]
                bonus=yes
                carryover_percentage=80
            [/gold_carryover]
        [/objectives]
    [/event]

    [event]
        name=start

        [set_variable]
            name=door_open
            value=no
        [/set_variable]
        [message]
            id=Delfador
            message= _ "I am grieved to have to resort to this. Yet the book must be recovered at all costs and no one should be left alive."
        [/message]
        [message]
            id=Kalenz
            message= _ "The book’s curse is already weighing heavy upon you, friend. But we cannot falter. We have acquired orcish weapons, as you have requested. Nobody will be able to link this to you or the elves."
        [/message]
        [message]
            id=Kalenz
            message= _ "Make sure everybody hears the orders. Nobody must escape."
        [/message]
        [message]
            id=Pilafman
            message= _ "Elves! And that traitor, Delfador is with them! Riders, quickly, go alert the queen. And guards, prepare to strike them down!"
        [/message]

        {HIGHLIGHT_IMAGE 1  19 scenery/signpost.png ()}
        {HIGHLIGHT_IMAGE 18 33 scenery/signpost.png ()}
    [/event]

    # next code lifted from Silent Siege in Unstoppable Legion (not
    # tested); the idea is to make the riders head for the signposts
    [event]
        name=recruit
        first_time_only=no
        [filter]
            type=Cavalryman,Dragoon
        [/filter]
        [set_variable]
            name=sentry
            rand=1..4
        [/set_variable]

        [if]
            [variable]
                name=sentry
                equals=1
            [/variable]
            [then]
                {MODIFY_UNIT (x,y=$x1,$y1) (goto_x) (1)  }
                {MODIFY_UNIT (x,y=$x1,$y1) (goto_y) (19) }
            [/then]
        [/if]
        [if]
            [variable]
                name=sentry
                equals=2
            [/variable]
            [then]
                {MODIFY_UNIT (x,y=$x1,$y1) (goto_x) (18) }
                {MODIFY_UNIT (x,y=$x1,$y1) (goto_y) (33) }
            [/then]
        [/if]
    [/event]

    # new objectives, find the book
    [event]
        name=new-objectives
        [message]
            id=Delfador
            message= _ "The guards are slain. Now we must look for the book."
        [/message]
        [objectives]
            side=1
            [objective]
                description= _ "New Objective: Find the secret door. Explore the manor."
                condition=win
            [/objective]
        [/objectives]
        # Create some new events for when we move to the right spot.
        [event]
            name=moveto
            [filter]
                side=1
                x,y=32,8
            [/filter]

            [music]
                name=northerners.ogg
                play_once=yes
            [/music]

            [message]
                id=$unit.id
                message= _ "This looks like a secret door. Let’s see where it leads..."
            [/message]
            [terrain]
                x=32
                y=9
                terrain=Uu
            [/terrain]
            [endlevel]
                result=victory
            [/endlevel]
        [/event]
    [/event]

    [event]
        name=die
        first_time_only=no
        [if]
            [not]
                [have_unit]
                    side=2
                [/have_unit]
            [/not]
            [then]
                [fire_event]
                    # Factored like this so the inner events
                    # won't trigger a false postive from wmllint.
                    name=new-objectives
                [/fire_event]
            [/then]
        [/if]
    [/event]

    [event]
        name=moveto
        [filter]
            side=2
            x,y=1,19
        [/filter]
        [endlevel]
            result=defeat
        [/endlevel]
    [/event]
    [event]
        name=moveto
        [filter]
            side=2
            x,y=18,33
        [/filter]
        [endlevel]
            result=defeat
        [/endlevel]
    [/event]

    [event]
        name=time over
        [message]
            id=Delfador
            message= _ "Reinforcements on the horizon. We are too late!"
        [/message]
        [endlevel]
            result=defeat
        [/endlevel]
    [/event]
    {MEMOIRS_DEATHS}
[/scenario]
