#textdomain wesnoth-httt
[scenario]
    id=08_The_Princess_of_Wesnoth
    name= _ "The Princess of Wesnoth"
    map_data="{campaigns/Heir_To_The_Throne/maps/08_The_Princess_of_Wesnoth.map}"
    {TURNS 31 28 25}

    {DEFAULT_SCHEDULE}

    next_scenario=09_The_Valley_of_Death

    {SCENARIO_MUSIC "loyalists.ogg"}
    {EXTRA_SCENARIO_MUSIC "the_city_falls.ogg"}
    {EXTRA_SCENARIO_MUSIC "battle.ogg"}
    {EXTRA_SCENARIO_MUSIC "casualties_of_war.ogg"}
    {EXTRA_SCENARIO_MUSIC "siege_of_laurelmor.ogg"}

    [event]
        name=prestart
        [objectives]
            side=1
            [objective]
                description= _ "Force Li’sar’s surrender"+{OBJECTIVE_FOOTNOTE ( _ "(reduce her hitpoints to 0 or lower)")}
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Konrad"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Delfador"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Kalenz"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

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

    [story]
        [part]
            story= _ "...but one of the orcs survived long enough to send the news to the queen..."
        [/part]
        [part]
            story= _ "...and she sent her most able commander."
        [/part]
    [/story]

    {HTTT_TRACK {JOURNEY_08_NEW} }

    [label]
        x,y=20,13
        text=_"Elmar’s Crossing"    # wmllint: no spellcheck
    [/label]

    [label]
        x,y=21,14
        text=_"Elbridge"    # wmllint: no spellcheck
    [/label]

    [side]
        type=Commander
        id=Konrad
        name= _ "Konrad"
        unrenamable=yes
        profile=portraits/konrad-human.png
        side=1
        canrecruit=yes
        team_name=elves
        user_team_name=_"Rebels"
        controller=human
        {GOLD 300 200 200}
        {FLAG_VARIANT long}
    [/side]

    [side]
        type=Princess
        id="Li'sar"
        name= _ "Li’sar"
        profile=portraits/lisar.png
        side=2
        canrecruit=yes
        facing=sw

        {GOLD 140 190 280}
        {INCOME 8 12 16}

        recruit=Spearman,Mage,Bowman,Fencer,Cavalryman,Swordsman,Red Mage,Pikeman,Javelineer,Longbowman,Duelist

        [ai]
            passive_leader=yes
            #she’s a smart leader and thinks deeply
            {ATTACK_DEPTH 4 5 5}
            [goal]
                name=target
                # While assassins target Konrad, all other units target Delfador
                [criteria]
                    id=Delfador
                [/criteria]
                value=9.0
            [/goal]
            leader_value=6.0

            [aspect]
                id=recruitment_instructions

                [facet]
                    [value]
                        [recruit]
                            type=Cavalryman
                            number=1
                            importance=4
                            blocker=no
                        [/recruit]
                        [recruit]
                            type=Duelist
                            number=1
                            importance=3
                            blocker=no
                        [/recruit]
                        [recruit]
                            type=Fencer
                            number=1
                            importance=2
                            blocker=no
                        [/recruit]
                        [recruit]
                            type=Spearman,Mage,Bowman,Swordsman,Red Mage,Pikeman,Javelineer,Longbowman
                            importance=1
                        [/recruit]

                        [limit]
                            type=Duelist
#ifdef EASY
                            max=1
#else
                            max=2
#endif
                        [/limit]
                        [limit]
                            type=Fencer
                            max=2
                        [/limit]
                        [limit]
                            type=Cavalryman
                            max=2
                        [/limit]
                    [/value]
                [/facet]
            [/aspect]
        [/ai]
        team_name=asheviere
        user_team_name=_"Asheviere"
        {FLAG_VARIANT loyalist}
    [/side]

    {STARTING_VILLAGES 2 16}
    {STARTING_VILLAGES_AREA 2 33 26 4}

    [event]
        name=prestart

        [micro_ai]
            side=2
            ai_type=assassin
            action=add

            [filter]
                type_adv_tree=Fencer
                role=target_Konrad
            [/filter]
            [filter_second]
                id=Konrad
            [/filter_second]
            [prefer]
                [not]
                    x=1-43,29-43
                    y=1-7,30-41
                [/not]
            [/prefer]
        [/micro_ai]

        [micro_ai]
            side=2
            ai_type=assassin
            action=add

            [filter]
                type_adv_tree=Fencer
                role=target_Delfador
            [/filter]
            [filter_second]
                id=Delfador
            [/filter_second]
            [prefer]
                [not]
                    x=1-43,29-43
                    y=1-7,30-41
                [/not]
            [/prefer]
        [/micro_ai]

        {NEED_DELFADOR placement=leader}
        {NEED_KALENZ placement=leader}
        {STORE_LISAR}
        [role]
            role=Advisor
            [auto_recall][/auto_recall]

            type="Elvish Sylph,Great Mage," +

                "Elvish Marshal,Elvish Champion,Elvish Avenger,Elvish Sharpshooter,Elvish Shyde,Elvish Enchantress,Elvish Outrider," +
                "Paladin,Grand Knight," +
                "Mage of Light,Arch Mage,Silver Mage," +
                "Merman Triton,Merman Hoplite,Merman Javelineer,Merman Entangler,Mermaid Diviner,Mermaid Siren," +
                "Highwayman,Fugitive,Huntsman,Ranger," +
                "Assassin," +

                "Elvish Captain,Elvish Hero,Elvish Ranger,Elvish Marksman,Elvish Druid,Elvish Sorceress,Elvish Rider," +
                "Knight,Lancer," +
                "White Mage,Red Mage," +
                "Merman Warrior,Merman Spearman,Merman Netcaster,Mermaid Priestess,Mermaid Enchantress," +
                "Bandit,Outlaw,Trapper," +
                "Rogue," +

                "Elvish Fighter,Elvish Archer,Elvish Shaman,Elvish Scout," +
                "Horseman," +
                "Mage," +
                "Merman Fighter,Merman Hunter,Mermaid Initiate," +
                "Thug,Footpad,Poacher," +
                "Thief"
            [else]
                [unit]
                    side=1
                    type=Elvish Fighter
                    role=Advisor
                    placement=leader
                [/unit]
            [/else]
        [/role]
    [/event]

    # The assassins target Konrad, except if they have a chance to hit Delfador
    [event]
        name=side 2 turn
        first_time_only=no

        [store_unit]
            [filter]
                side=2
                type_adv_tree=Fencer
            [/filter]

            kill=no
            variable=assassins
        [/store_unit]

        [for]
            array=assassins

            [do]
                [store_reachable_locations]
                    [filter]
                        id=$assassins[$i].id
                    [/filter]

                    range=attack
                    moves=max
                    variable=assassin_reach
                [/store_reachable_locations]

                [if]
                    [have_unit]
                        id=Delfador

                        [filter_location]
                            find_in=assassin_reach
                        [/filter_location]
                    [/have_unit]

                    [then]
                        {MODIFY_UNIT id=$assassins[$i].id role "target_Delfador"}
                    [/then]

                    [else]
                        {MODIFY_UNIT id=$assassins[$i].id role "target_Konrad"}
                    [/else]
                [/if]
            [/do]
        [/for]

        {CLEAR_VARIABLE assassins,assassin_reach}
    [/event]

    # Makes assassins more effective by ensuring they're all quick
    [event]
        name=recruit
        first_time_only=no

        [filter]
            side=2
            type=Fencer,Duelist
        [/filter]

        [unit]
            x,y=$x1,$y1
            side=2
            type=$unit.type
            placement=map_overwrite
            moves=0
            attacks_left=0
            [modifications]
                {TRAIT_QUICK}
            [/modifications]
        [/unit]
    [/event]

    [event]
        name=start
        [message]
            speaker=narrator
            image="wesnoth-icon.png"
            message= _ "On the road to Knalga, the party was opposed by the forces of Asheviere."
        [/message]
        [message]
            speaker="Li'sar"
            message= _ "The Queen has sent me to stop you, impostor!"
        [/message]
        [message]
            role=Advisor
            message= _ "That’s the princess, Li’sar. The daughter of the Queen, and her successor!"
        [/message]
        [message]
            speaker=Konrad
            message= _ "I’m no impostor. It seems that your mother has lied to you."
        [/message]
        [message]
            speaker="Li'sar"
            {LISAR_VARIATION mad}
            message= _ "This is treason! Your lies will perish with you!"
        [/message]
        [message]
            speaker=Delfador
            message= _ "There is no use in reasoning. She will understand only one thing. To arms!"
        [/message]
    [/event]

    [event]
        name=last breath
        [filter]
            id="Li'sar"
        [/filter]

        {VARIABLE unit.hitpoints 1}

        [unstore_unit]
            variable=unit
        [/unstore_unit]

        [message]
            speaker=unit
            {LISAR_VARIATION defeat}
            message= _ "I surrender! Don’t hurt me, impostor."
        [/message]
        [message]
            speaker=Konrad
            message= _ "I said before I’m not an impostor, but if you yield, I will spare your life."
        [/message]
        [message]
            speaker=unit
            {LISAR_VARIATION defeat}
            message= _ "Let me go!"
        [/message]
        [message]
            speaker=Konrad
            {KONRAD_VARIATION concerned}
            message= _ "Think about the story of the old king. Ask somebody who knew of him."
        [/message]
        [message]
            speaker=unit
            {LISAR_VARIATION defeat}
            message= _ "The old king? I have heard about that, but I know it is not true. My mother told me."
        [/message]
        [message]
            speaker=Delfador
            message= _ "Your mother has lied to you, child. Now I suggest you reconsider, and either join us, or flee as an exile. There will be a great battle soon, and if you are on the wrong side of it, we may not have the opportunity to spare your life a second time."
        [/message]
        [message]
            speaker=unit
            {LISAR_VARIATION defeat}
            message= _ "I am not a child, and I do not want to talk about it! You said you would spare me, so be on your way. The northern road should be safe for you."
        [/message]
        [message]
            speaker=Konrad
            message= _ "Good day to you, then. Come, men, to the northern road!"
        [/message]
        [message]
            speaker=unit
            {LISAR_VARIATION defeat}
            message= _ "(Ha ha, little do they know just how many undead have wandered the northern road of late. Surely they are doomed!)"
        [/message]

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

    [event]
        name=victory

        {CLEAR_VARIABLE trap_sprung}

        {RESTORE_LISAR}
    [/event]

#define SECOND_WAVE
#ifdef EASY
    [gold]
        side=2
        amount=90
    [/gold]
#endif

#ifdef NORMAL
    [gold]
        side=2
        amount=120
    [/gold]
#endif

#ifdef HARD
    [gold]
        side=2
        amount=150
    [/gold]
#endif
#enddef

    {campaigns/Heir_To_The_Throne/utils/deaths.cfg}
[/scenario]

#undef SECOND_WAVE
