#textdomain wesnoth-httt
[scenario]
    id=01_The_Elves_Besieged
    name= _ "The Elves Besieged"
    next_scenario=02_Blackwater_Port
    victory_when_enemies_defeated=no
    map_data="{campaigns/Heir_To_The_Throne/maps/01_The_Elves_Besieged.map}"
    {TURNS 16 14 12}
    {DEFAULT_SCHEDULE}

    {SCENARIO_MUSIC "battle.ogg"}   # No story part
    {EXTRA_SCENARIO_MUSIC "elvish-theme.ogg"}
    {EXTRA_SCENARIO_MUSIC "the_king_is_dead.ogg"}

    # Chantal can't be killed for storyline reasons.
    # Prevent AIs from getting too close.
#define AVOID_CHANTAL
    [avoid]
        x,y=2-4,22-24
    [/avoid]
#enddef

    [event]
        name=prestart
        [objectives]
            side=1
            [objective]
                description= _ "Move Konrad to the signpost in the northwest"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Konrad"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Delfador"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

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

    {campaigns/Heir_To_The_Throne/utils/intro.cfg}
    {BIGMAP_ELVES_BESIEGED}

    {STARTING_VILLAGES 5 10}
    {STARTING_VILLAGES 6 10}
    {STARTING_VILLAGES 1 3}
    {STARTING_VILLAGES_AREA 6 7 10 6}
    {STARTING_VILLAGES_AREA 5 17 3 1}
    {STARTING_VILLAGES_AREA 6 9 40 10}
    {STARTING_VILLAGES_AREA 5 26 31 5}
    {STARTING_VILLAGES_AREA 5 29 46 1}

    # wmllint: recognize Kalenz

    [side]
        type=Fighter
        id=Konrad
        name= _"Konrad"
        unrenamable=yes
        profile=portraits/konrad.png
        side=1
        canrecruit=yes
        controller=human
        recruit=Elvish Scout,Elvish Fighter,Elvish Archer,Elvish Shaman
        gold=100
        team_name=elves
        user_team_name=_"Rebels"
        [unit]
            id=Delfador
            name= _ "Delfador"
            unrenamable=yes
            type=Elder Mage
            profile=portraits/delfador.png
            side=1
            x=19
            y=23
            {IS_HERO}
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_INTELLIGENT}
            [/modifications]
        [/unit]
        [ai]
            [target]
                id=Delfador
                value=3.0
            [/target]
            [protect_unit]
                id=Delfador
                radius=6
                value=20.0
            [/protect_unit]
            [protect_unit]
                id=Konrad
                radius=10
                value=20.0
            [/protect_unit]
            [target]
                id=Kalenz
                value=3.0
            [/target]
            [protect_unit]
                id=Kalenz
                radius=4
                value=20.0
            [/protect_unit]

            [avoid]
                x=20-31
                y=1-12
            [/avoid]

            [leader_goal]
                x,y=1,1
            [/leader_goal]
        [/ai]
        {FLAG_VARIANT long}
    [/side]

#ifdef HARD
#define HIGH_PRIORITY_TARGETS
    [target]
        id=Delfador
        value=100
    [/target]
    [target]
        id=Konrad
        value=100
    [/target]
#enddef
#endif

    #macro which tells the AI not to start thinking about
    #whether it's a bad idea to send trolls into the forest
    #against elves, and just do it
#define EBESIEGED_RECRUITMENT
    [ai]
        recruitment_ignore_bad_movement=yes
        recruitment_ignore_bad_combat=yes
        simple_targeting=yes
    [/ai]
#enddef

    [side]
        type=Orcish Warlord
        id=Urug-Telfar
        name= _ "Urug-Telfar"
        side=2
        canrecruit=yes
        recruit=Orcish Warrior,Goblin Knight,Goblin Pillager,Orcish Crossbowman,Orcish Assassin,Troll
        gold=400
        [ai]
            recruitment_pattern=scout,fighter,mixed fighter,archer
            {ATTACK_DEPTH 1 3 5}
            {AVOID_CHANTAL}
#ifdef HARD
            {HIGH_PRIORITY_TARGETS}
#endif
        [/ai]
        {EBESIEGED_RECRUITMENT}
        team_name=orcs
        user_team_name=_"Orcs"
        {FLAG_VARIANT ragged}
    [/side]

    [side]
        type=Orcish Warlord
        id=Knafa-Tan
        name= _ "Knafa-Tan"
        side=3
        canrecruit=yes
        recruit=Orcish Warrior,Wolf Rider,Orcish Crossbowman,Orcish Assassin,Troll
        {EBESIEGED_RECRUITMENT}
        team_name=orcs
        user_team_name=_"Orcs"
        {GOLD 200 300 500}
        [ai]
            {ATTACK_DEPTH 1 3 5}
            {AVOID_CHANTAL}
#ifdef HARD
            {HIGH_PRIORITY_TARGETS}
#endif
        [/ai]
        {FLAG_VARIANT ragged}
    [/side]

    [side]
        type=Orcish Warlord
        id=Maga-Knafa
        name= _ "Maga-Knafa"
        side=4
        canrecruit=yes
        recruit=Orcish Warrior,Wolf Rider,Orcish Crossbowman,Troll Warrior,Orcish Slayer
        {EBESIEGED_RECRUITMENT}
        team_name=orcs
        user_team_name=_"Orcs"
        {GOLD 200 300 500}
        [ai]
            {ATTACK_DEPTH 1 3 5}
            {AVOID_CHANTAL}
#ifdef HARD
            {HIGH_PRIORITY_TARGETS}
#endif
        [/ai]
        {FLAG_VARIANT ragged}
    [/side]

    #allies of Konrad
    [side]
        type=Elvish Champion
        id=Galdrad
        name= _ "Galdrad"
        side=5
        canrecruit=yes
        recruit=Elvish Fighter,Elvish Archer,Elvish Ranger
        [ai]
            recruitment_pattern=fighter,archer,mixed fighter
        [/ai]
        gold=170
        team_name=elves
        user_team_name=_"Rebels"
        {FLAG_VARIANT long}
    [/side]

    [side]
        type=Elvish Shyde
        id=Chantal
        name= _ "Chantal"
        profile=portraits/chantal-shyde.png
        side=6
        canrecruit=yes
        recruit=Elvish Shaman,Elvish Archer,Elvish Fighter
        [ai]
            passive_leader="yes"
            passive_leader_shares_keep="yes"
            recruitment_pattern=archer,archer,fighter,fighter,healer
        [/ai]
        gold=170
        team_name=elves
        user_team_name=_"Rebels"
        {FLAG_VARIANT long}
    [/side]

    [event]
        name=start

        # {SCATTER_IMAGE (terrain=Gs^Fp) 10 scenery/pine1.png}
        # {SCATTER_IMAGE (terrain=Gs^Fp)  5 scenery/pine2.png}

        [message]
            speaker=narrator
            image="wesnoth-icon.png"
            message= _ "Sixteen years into her rule, Asheviere turned her attention to the wood elves living in the great forest southwest of Wesnoth, whom she despised. Orcish mercenaries were hired and dispatched to bring about their ruin."
        [/message]
        [message]
            speaker=Konrad
            message= _ "Master Delfador! Look, there are orcs coming from all directions! What shall we do?"
        [/message]
        [message]
            speaker=Delfador
            message= _ "There are too many to fight, far too many. We must escape!"
        [/message]
        [message]
            speaker=Konrad
            message= _ "But to where? This is the only home we have! What about the elves?"
        [/message]
        [message]
            speaker=Galdrad
            message= _ "We will fight them, but you must escape, Konrad. It is imperative that you escape!"
        [/message]
        [message]
            speaker=Delfador
            message= _ "We will go north. Perhaps we can reach the Isle of Alduin. If we can make it there, surely we will be safe. Konrad, we must recruit some elves to help us, and then you must make it to the sign post in the north-west. I will protect you!"
        [/message]
        [message]
            speaker=Konrad
            message= _ "Very well, let us hurry!"
        [/message]
        [message]
            speaker=Urug-Telfar
            image=portraits/orcs/transparent/grunt-2.png
            message= _ "Attack the elves, my grunts, and take their villages. Let us claim this land for the Queen!"
        [/message]

        #on hard level, the enemies will specifically target Delfador and Konrad
#ifdef HARD
        [message]
            speaker=Knafa-Tan
            image=portraits/orcs/transparent/warlord.png
            message= _ "Remember, it is rumored that the filthy mage and one that he protects are in these parts. They are the ones we want!"
        [/message]
#else
        [message]
            speaker=Knafa-Tan
            image=portraits/orcs/transparent/warlord.png
            message= _ "Ha ha! We will rip the filthy elves to pieces!"
        [/message]
#endif
        [message]
            speaker=Galdrad
            message= _ "Let them come. We will fight them with all we have!"
        [/message]
        [message]
            speaker=Chantal
            message= _ "Be careful, Konrad! Guard him well, Delfador!"
        [/message]
        [message]
            speaker=Delfador
            message= _ "Do not spend your life here, Chantal. Someone must warn the Northern Elves that the war we so long feared has begun."
        [/message]

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

        [scroll_to_unit]
            id=Konrad
        [/scroll_to_unit]
    [/event]

    [event]
        name=moveto
        [filter]
            x=1
            y=1
            id=Konrad
        [/filter]
        [message]
            speaker=unit
            message= _ "Very well, we have made it this far! But where do we go next?"
        [/message]
        [message]
            speaker=Delfador
            message= _ "We must travel north, and try to make it to the Isle of Alduin. Hopefully we will find refuge there."
        [/message]
        [message]
            speaker=unit
            message= _ "Of course you are right, Delfador. But what will become of the elves here?"
        [/message]
        [message]
            speaker=Delfador
            message= _ "The elves will fight. They may even prevail. But I fear things do not bode well for them. Let us not speak of it now. Onward!"
        [/message]
        [message]
            speaker=Chantal
            message= _ "Good luck, Konrad! Don’t worry about us, we will fight as best we can!"
        [/message]
        [endlevel]
            result=victory
            bonus=yes
            {NEW_GOLD_CARRYOVER 40}
        [/endlevel]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Konrad
        [/filter]
        [message]
            speaker=unit
            message= _ "I... I don’t think I can make it anymore."
        [/message]
        [message]
            speaker=Delfador
            message= _ "Prince... you must keep fighting! Nooooooo!"
        [/message]
        [message]
            speaker=unit
            message= _ "It is over. I am doomed..."
        [/message]
        [endlevel]
            result=defeat
        [/endlevel]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Delfador
        [/filter]
        [message]
            speaker=unit
            message= _ "I have... have failed in my duty to protect the prince! I am defeated."
        [/message]
        [message]
            speaker=Konrad
            message= _ "Don’t die, Delfador! Please, you have to stay alive!"
        [/message]
        [message]
            speaker=unit
            message= _ "Ugh!"
        [/message]
        [endlevel]
            result=defeat
        [/endlevel]
    [/event]

    [event]
        name=time over
        [message]
            speaker=Delfador
            message= _ "Oh, no! We have run out of time, they have arrived with reinforcements..."
        [/message]
    [/event]

    [event]
        name=die
        [filter]
            type=Orcish Warlord
        [/filter]
        {VARIABLE_OP warlord_count add 1}
    [/event]

    [event]
        name=die
        [filter_second]
            id=Konrad
        [/filter_second]
        [message]
            speaker=second_unit
            message= _ "Die, villain, die!"
        [/message]
    [/event]

    [event]
        name=die
        [filter_second]
            id=Delfador
        [/filter_second]
        [message]
            speaker=second_unit
            message= _ "Only the foolish oppose me!"
        [/message]
    [/event]

    [event]
        name=attack
        [filter_second]
            id=Galdrad
        [/filter_second]
        [message]
            speaker=Galdrad
            message= _ "I am Galdrad. You will have to fight me to get any further!"
        [/message]
    [/event]

    [event]
        name=attack
        [filter_second]
            id=Delfador
        [/filter_second]
        [message]
            speaker=Delfador
            message= _ "Only a fool would dare to attack me!"
        [/message]
    [/event]

    [event]
        name=attack
        [filter]
            id=Delfador
        [/filter]
        [message]
            speaker=Delfador
            message= _ "I am Delfador the Great. Prepare to die!"
        [/message]
    [/event]

    [event]
        name=attack
        [filter]
            id=Konrad
        [/filter]
        [message]
            speaker=Konrad
            image=portraits/konrad-angry.png
            message= _ "Let me through, you rogue!"
        [/message]
    [/event]

    #when a Goblin Knight moves onto one of the villages
    #that Delfador and Konrad start near
    [event]
        name=moveto
        [filter]
            side=2
            x=20,17
            y=25,23
        [/filter]
        [message]
            speaker=Konrad
            message= _ "Oh no! They are destroying our home!"
        [/message]
        [message]
            speaker=Delfador
            message= _ "There can be no looking back. We must go quickly!"
        [/message]
    [/event]
[/scenario]
