#textdomain wesnoth-dm
[scenario]
    id=20_Prince_of_Wesnoth
    name= _ "Prince of Wesnoth"
    next_scenario=21_Clash_at_the_Manor
    {MEMOIRS_MAP 20_Prince_of_Wesnoth.map}
    {TURNS 20 22 24}
    {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]
            # The "generation" is the 26 years between 470YW and 496YW.
            # Delfador is 54 at this time.
            story= _ "Following the alliance’s victory and the peace treaty came a period of calm that lasted a generation. The new King had learned to trust Delfador at the battle of Abez Ford, and it was no surprise that Delfador became Garard II’s most valued advisor."
            delay=4000
        [/part]
        [part]
            story= _ "The elves knew that with Delfador close to the King, Wesnoth would be a reliable ally. And it was for a while."
            delay=4000
        [/part]
        [part]
            # Asheviere marries Garard II in 478.
            story= _ "But Delfador was not alone in having the King’s ear; there was one yet closer to him. The Queen’s power was rising..."
            delay=8000
            background="story/httt_story3.jpg"
        [/part]
        [part]
            # Eldred's raid takes place in 496
            story= _ "One day reports came of Wesnothian forces seizing elvish land on the border. Kalenz gathered a small force and hurried to the disputed country."
        [/part]
    [/story]
    {DM_TRACK {BOOK_STAGE1}}

    #### Kalenz's code ####
    #wmllint: validate-off
    [side]
        # wmllint: recognize Kalenz
        recruit={ELVES}
        side=1
        no_leader=yes
        controller=human
        team_name=allies
        user_team_name= _ "Elves"
        save_id=Player
        persistent=yes
        fog=yes
        [unit]
            {KALENZ}
            x=2
            y=19
            canrecruit=yes
        [/unit]
        {GOLD 130 100 100}
        {FLAG_VARIANT wood-elvish}
    [/side]
    #wmllint: validate-on

    {STARTING_VILLAGES_ALL 1}

    [event]
        name=prestart

        [recall]
            id=Kalenz
            x,y=2,19
        [/recall]

        {DELFADOR_JOINS_ELVES}
    [/event]
    #### /Kalenz's code

    [side]
        type=General
        id=Eldred
        name=_ "Eldred"
        profile="portraits/eldred.png"
        facing=sw
        side=2
        canrecruit=yes
        controller=ai
        team_name=enemies
        user_team_name= _ "Loyalists"
        recruit=Heavy Infantryman,Spearman,Bowman,Cavalryman,Horseman,Mage,Swordsman
        {GOLD 130 180 200}
        {INCOME 0 2 2}
        [ai]
            recruitment_pattern=fighter,archer,mixed fighter,scout
            aggression=1.0
            caution=0.0
            [goal]
                name=protect_unit
                [criteria]
                    side=2
                    canrecruit=yes
                [/criteria]
                value=3.0
            [/goal]
        [/ai]
        {FLAG_VARIANT loyalist}
    [/side]

    [side]
        type=General
        id=Lowel
        name=_ "Lowel"
        facing=sw
        side=3
        canrecruit=yes
        controller=ai
        recruit=Heavy Infantryman,Spearman,Bowman,Cavalryman,Horseman,Mage,Thug,Footpad,Poacher,Rogue,Thief,Outlaw,Bandit,Assassin
        team_name=enemies
        user_team_name= _ "Loyalists"
        {GOLD 150 230 290}
        [ai]
            recruitment_pattern=fighter,archer,mixed fighter,scout
            aggression=1.0
            caution=0.0
        [/ai]
        {FLAG_VARIANT loyalist}
    [/side]

    [event]
        name=prestart
        [objectives]
            side=1
            [objective]
                description= _ "Defeat Eldred"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Kalenz"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Chantal"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

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

    [event]
        name=start

        [recall]
            id=Chantal
        [/recall]
        {MODIFY_UNIT (side=1) facing ne}

        # remove fog from the generals so they can be seen during the dialog
        [lift_fog]
            [filter_side]
                side=1
            [/filter_side]
            x=34,31
            y=4,16
            radius=2
        [/lift_fog]

        [message]
            id=Kalenz
            message= _ "Generals of Wesnoth: you have attacked defenseless elvish land. You must leave immediately. I am Kalenz, High Lord of the Elves. Delfador the Great will confirm the treaty between us."
        [/message]
        [message]
            id=Eldred
            message= _ "This is elvish land no more. I, Eldred, prince of Wesnoth and heir to the throne, claim it for Wesnoth and Queen Asheviere. Delfador does not rule in Wesnoth!"
        [/message]
        [message]
            id=Kalenz
            message= _ "I did not want to spill human blood, but this arrogant prince leaves me no other choice."
        [/message]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Eldred
        [/filter]

        # Keep his unit on the board
        {MODIFY_UNIT id=Eldred hitpoints 1}
        [delay]
            time=500
        [/delay]

        # wmllint: recognize Delfador
        {DELFADOR_ARRIVES 26 20}
        [move_unit]
            id=Delfador
            to_x=26,25,25,24,24
            to_y=19,19,18,17,16
        [/move_unit]
        {MODIFY_UNIT (id=Delfador) facing ne}

        [endlevel]
            result=victory
        [/endlevel]
    [/event]

    [event]
        name=victory

        [scroll_to_unit]
            id=Delfador
        [/scroll_to_unit]

        {DELFADOR_LIGHTNING}

        [message]
            id=Delfador
            message= _ "Peace, friends! I have been riding nonstop for days to prevent this madness! Eldred, I have direct orders from the King to take you back to the Palace, where you will be reprimanded for your inexcusable actions. Kalenz, the King offers his deepest apologies for these events and promises to do anything in his power to make amends."
        [/message]
        [message]
            id=Kalenz
            message= _ "Delfador! I am glad to see you. We have no demands on the King, but I believe he should be very careful, for he does not seem to be the only ruler in Wesnoth!"
        [/message]
        [message]
            id=Chantal
            message= _ "Kalenz, I am very worried. There is a cloud of evil swirling around the Royal Palace, and it has more centers than the prince alone. I see dark days ahead..."
        [/message]
        [message]
            id=Kalenz
            message= _ "I wonder if the Book of Crelanu is not behind this. The Book is not evil in itself, but the power it gives tends to magnify any evil in the reader’s soul. Delfador, has anyone but you opened its covers since you got it from us?"
        [/message]
        [message]
            id=Delfador
            message= _ "I do not think so. But... Asheviere, Garard’s queen and Eldred’s mother, seemed to be hinting some months ago that I should teach her magery. She ceased all such talk when I did not respond, and I thought it merely the momentary whim of a proud and willful woman."
        [/message]
        [message]
            id=Chantal
            message= _ "I wonder if we have not dangerously misjudged her..."
        [/message]
        [message]
            id=Delfador
            message= _ "It may be so. Now that I think on it, I think I had best return to the Palace more swiftly than I came here, even if I have to kill three horses under me to do it."
        [/message]

        {DELFADOR_TAKES_CONTROL}
        [modify_side]
            side=1
            user_team_name= _ "Rebels"
        [/modify_side]
    [/event]

    [event]
        name=time over
        [message]
            id=Kalenz
            message= _ "We are too late! All is lost!"
        [/message]
    [/event]
    {MEMOIRS_DEATHS}
[/scenario]
