#textdomain wesnoth-httt
[scenario]
    id=11_The_Ford_of_Abez
    name= _ "The Ford of Abez"
    map_data="{campaigns/Heir_To_The_Throne/maps/11_The_Ford_of_Abez.map}"
    {TURNS 27 24 21}

    {DEFAULT_SCHEDULE}

    victory_when_enemies_defeated=no
    next_scenario=12_Northern_Winter

    {SCENARIO_MUSIC "loyalists.ogg"}
    {EXTRA_SCENARIO_MUSIC "battle-epic.ogg"}
    {EXTRA_SCENARIO_MUSIC "breaking_the_chains.ogg"}
    {EXTRA_SCENARIO_MUSIC "battle.ogg"}

    {HTTT_TRACK {JOURNEY_11_NEW} }

    [event]
        name=prestart
        [objectives]
            side=1
            [objective]
                description= _ "Move Konrad to the north side of the river"
                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]

    [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=200
        {FLAG_VARIANT long}
    [/side]

    [side]
        type=Princess
        id="Li'sar"
        name= _ "Li’sar"
        profile=portraits/lisar.png
        side=2
        canrecruit=yes
        recruit=Cavalryman,Swordsman,Spearman,Red Mage,Ogre,Duelist
        [ai]
            {ATTACK_DEPTH 4 5 5}
            recruitment_pattern=scout,fighter,fighter,fighter,mixed fighter
            aggression=1.0
            caution=-5.0
            grouping=no
            leader_value=100
        [/ai]
        gold=200
        income=50
        team_name=bad
        user_team_name=_"Asheviere"
        {FLAG_VARIANT loyalist}
    [/side]

    {STARTING_VILLAGES 2 5}

    [side]
        type=Orcish Warlord
        id=Gaga-Breuk
        name= _ "Gaga-Breuk"
        side=3
        canrecruit=yes
        team_name=orcs
        user_team_name=_"Orcs"
#ifdef EASY
        recruit=Orcish Warrior,Orcish Crossbowman,Wolf Rider
#endif

#ifdef NORMAL
        recruit=Orcish Warrior,Orcish Crossbowman,Goblin Knight
#endif

#ifdef HARD
        recruit=Orcish Warrior,Orcish Crossbowman,Blood Bat
#endif

        {GOLD 140 200 260}
        [ai]
            {ATTACK_DEPTH 4 5 5}
            aggression=1.0
            caution=-4.0
            grouping=no
            recruitment_pattern=scout,fighter,fighter,archer

            leader_value=100

            #target Konrad especially heavily
            [goal]
                name=target
                [criteria]
                    id=Konrad
                [/criteria]
                value=100
            [/goal]
        [/ai]
        {FLAG_VARIANT6 ragged}
    [/side]

    {STARTING_VILLAGES 3 5}

    [side]
        side=4
        hidden=yes
        no_leader=yes
        team_name=creature
        user_team_name=_"Monsters"
        [ai]
            aggression=1.0
            caution=-4.0
            grouping=no
            [avoid]
                x=1-100
                y=21-100
            [/avoid]
            [avoid]
                x=1-100
                y=1-12
            [/avoid]
            #target Konrad especially heavily
            [goal]
                name=target
                [criteria]
                    id=Konrad
                [/criteria]
                value=100
            [/goal]
            village_value=0
        [/ai]
    [/side]

    {OBJ_TRIDENT_STORM 16 17 ford_trident}

#define FORD_GUARD X Y
    [unit]
        type=Royal Guard
        generate_name=yes
        ai_special=guardian
        x={X}
        y={Y}
        side=2
        [modifications]
            {TRAIT_LOYAL}
        [/modifications]
        {IS_LOYAL}
    [/unit]
#enddef

    [event]
        name=prestart

        {FORD_GUARD 7 27}
        {FORD_GUARD 6 28}
        {FORD_GUARD 6 25}
        {FORD_GUARD 4 25}
        {FORD_GUARD 3 27}
        {FORD_GUARD 4 28}

        {NEED_DELFADOR placement=leader}
        {NEED_KALENZ placement=leader}
        {STORE_LISAR}
    [/event]

    [event]
        name=start
        [message]
            speaker=Delfador
            {DELFADOR_MENTORING}
            message= _ "This is the Ford of Abez. When we ford this river, we will be leaving Wesnoth, and entering the lands of the North. The dwarves once ruled these lands, but they are now filled only with chaos. This is where your father and uncle were betrayed, almost seventeen years ago now, Konrad."
        [/message]
        [message]
            speaker=Konrad
            message= _ "Really? So what happened, Delfador?"
        [/message]
        [message]
            speaker=Delfador
            message= _ "The forces of the king were encamped here, and the forces of the north were on the north side of the river. For three days and three nights the armies faced each other, neither willing to ford the river. On the fourth day, the northern armies crossed and attacked us."
        [/message]
        [message]
            speaker=Konrad
            message= _ "And then... we were defeated?"
        [/message]
        [message]
            speaker=Delfador
            message= _ "We were winning the battle. We were repelling them..."
        [/message]
        [message]
            speaker=Kalenz
            message= _ "And then the king’s son, in the heat of battle, turned upon the king!"
        [/message]
        [message]
            speaker=Konrad
            message= _ "But you avenged the murder. You killed the prince. Right, Delfador?"
        [/message]
        [message]
            speaker=Delfador
            message= _ "When I saw the king betrayed and his banner fallen, I fled the battle. I know not now whether it was wisdom or cowardice, but I did flee, seeing no further hope on that day."
        [/message]
        [message]
            speaker=Konrad
            message= _ "Oh, but the elves always told me that you killed the prince, Delfador, even though you never talked about it."
        [/message]
        [message]
            speaker=Delfador
            message= _ "That foolish boy killed himself."
        [/message]
        [message]
            speaker=Konrad
            message= _ "What do you mean?"
        [/message]
        [message]
            speaker=Delfador
            message= _ "I mustered men to fight against the traitor-king, and of course Asheviere too, for she was behind it all. We met them; not here, but on the road from Weldyn, at Tath. We were outnumbered, perhaps four to one. In the heat of battle, that boy, fool that he was, came charging at me, slashing wildly. I had little choice but to end his life."
        [/message]
        [message]
            speaker=Konrad
            message= _ "So it is true, you did kill him?"
        [/message]
        [message]
            speaker=Delfador
            message= _ "He did die in battle at my hand. It is sad that your brothers did not have the opportunity to experience such an honorable death, Konrad."
        [/message]
        [message]
            speaker=Kalenz
            message= _ "With all respect, my lords, we must make haste. We have to ford the river immediately. And, look! It seems that the guard-towers on the river banks are manned!"
        [/message]
        [message]
            speaker=Gaga-Breuk
            message= _ "Look! Some of the southerners, men of Wesnoth, are trying to cross into our lands! We will slaughter them by the river’s edge!"
        [/message]
        [message]
            speaker=Konrad
            message= _ "Isn’t there somewhere else we can cross? Maybe upstream?"
        [/message]
        [message]
            speaker=Delfador
            message= _ "Winter quickly bears down upon us. We have only a few days to make the crossing, and the nearest bridge is far upstream. To be trapped south of the river when winter arrives would be suicide. Asheviere would have us trapped like rats! Look to the west! Asheviere has a border fort, and it seems to be full of soldiers! We must cross here, and quickly!"
        [/message]
        [message]
            speaker="Li'sar"
            {LISAR_VARIATION mad}
            message= _ "There they are! So it is true, they foiled the undead. Now they are trying to leave Wesnoth. We can’t let them cross the river. After them, men!"
        [/message]

        [if]
            [variable]
                name=get_gryphons
                numerical_equals=1
            [/variable]
            [then]
                [message]
                    speaker=Konrad
                    message= _ "Not her again! We must hurry! Do not forget to bring the gryphon eggs. They must be allowed more time to hatch. Quickly!"
                [/message]
            [/then]
            [else]
                [message]
                    speaker=Konrad
                    message= _ "Not her again! Quickly! We must hurry!"
                [/message]
            [/else]
        [/if]
        [set_variable]
            name=lisar_still_here
            value=1
        [/set_variable]
    [/event]

    #if someone marches over to Li'sar's keep, reinforcements appear
    [event]
        name=moveto
        [filter]
            [not]
                side=2
            [/not]
        [/filter]
        [filter_condition]
            [have_unit]
                id="Li'sar"
            [/have_unit]
            [have_location]
                x,y=$x1,$y1
                [and]
                    x,y=5,27
                    radius=11
                [/and]
                [not]
                    terrain="Wo,Ww"
                [/not]
            [/have_location]
        [/filter_condition]
        [message]
            type=Royal Guard
            message= _ "Stop! You shall not pass!"
        [/message]
        {FORD_GUARD 1 29}
        {FORD_GUARD 1 27}
        {FORD_GUARD 1 25}
        {FORD_GUARD 7 24}
        {FORD_GUARD 9 25}
        {FORD_GUARD 9 27}
        {FORD_GUARD 9 29}
        {FORD_GUARD 7 30}
        {FORD_GUARD 5 31}
        {FORD_GUARD 3 30}
    [/event]

    #getting closer --> more reinforcements
    [event]
        name=moveto
        [filter]
            [not]
                side=2
            [/not]
        [/filter]
        [filter_condition]
            [have_unit]
                id="Li'sar"
            [/have_unit]
            [have_location]
                x,y=$x1,$y1
                [and]
                    x,y=5,27
                    radius=4
                [/and]
                [not]
                    terrain="Wo,Ww"
                [/not]
            [/have_location]
        [/filter_condition]
        [message]
            side=2
            [not]
                id="Li'sar"
            [/not]
            message= _ "Quick, reinforcements, protect the Princess!"
        [/message]
        {FORD_GUARD 5 25}
        {FORD_GUARD 7 26}
        {FORD_GUARD 7 28}
        {FORD_GUARD 5 29}
        {FORD_GUARD 3 28}
        {FORD_GUARD 3 26}
    [/event]

    #if anyone dares attack Li'sar's escort, they are pounced on by
    #many Royal Guards
    [event]
        name=attack
        [filter_second]
            type=Royal Guard
        [/filter_second]
        [message]
            speaker=second_unit
            message= _ "Quick, reinforcements!"
        [/message]
        {FORD_GUARD $x1 $y1}
        {FORD_GUARD $x1 $y1}
        {FORD_GUARD $x1 $y1}
        {FORD_GUARD $x1 $y1}
        {FORD_GUARD $x1 $y1}
    [/event]

    #Geez, talk about not taking a hint ...
    [event]
        name=attack
        [filter_second]
            id="Li'sar"
        [/filter_second]
        [message]
            side=2
            [not]
                id="Li'sar"
            [/not]
            message= _ "Protect the Princess!"
        [/message]
        {FORD_GUARD $x1 $y1}
        {FORD_GUARD $x1 $y1}
        {FORD_GUARD $x1 $y1}
        {FORD_GUARD $x1 $y1}
        {FORD_GUARD $x1 $y1}
    [/event]

    # Defeating Li'sar just sends her away
    [event]
        name=last breath
        [filter]
            id="Li'sar"
        [/filter]
        [filter_second]
            side=1
        [/filter_second]
        [message]
            speaker="Li'sar"
            {LISAR_VARIATION defeat}
            message= _ "You drive me from the field, but you have not vanquished me, impostor!"
        [/message]
        [set_variable]
            name=lisar_still_here
            value=0
        [/set_variable]
    [/event]

    [event]
        name=turn 5

        {NAMED_LOYAL_UNIT 4 (Water Serpent) 1 15 (Water Serpent) ( _ "Water Serpent")}

#define SEA_CREATURE
    {NAMED_LOYAL_UNIT 4 (Cuttle Fish) 1 15 () ( _ "Cuttle Fish")}
#enddef

        {SEA_CREATURE}
        {SEA_CREATURE}
        {SEA_CREATURE}

#ifdef NORMAL
        {SEA_CREATURE}
        {SEA_CREATURE}
#endif

#ifdef HARD
        {SEA_CREATURE}
        {SEA_CREATURE}
        {SEA_CREATURE}
        {SEA_CREATURE}
#endif
        [message]
            type=Water Serpent
            message= _ "Ruaarrrrrrrr!"  # wmllint: no spellcheck
        [/message]
        [message]
            speaker=Konrad
            message= _ "What is that?"
        [/message]
        [message]
            speaker=Kalenz
            message= _ "Creatures of the deep are upon us! This may be very dangerous. Be quick! We must get to the other side with all haste!"
        [/message]
    [/event]

    #moving Konrad to the other shore
    [event]
        name=moveto
        [filter]
            id=Konrad
            x=1-44
            y=1-8
        [/filter]

        [message]
            speaker=Konrad
            message= _ "We made it across the river safely! Where to now?"
        [/message]

        [message]
            speaker=Delfador
            message= _ "If we are to have any hope of penetrating into Knalga, we must continue north to seek help from the Dwarves of the Heart Mountains."
        [/message]

        [if]
            [variable]
                name=lisar_still_here
                numerical_equals=1
            [/variable]
            [then]
                [message]
                    speaker="Li'sar"
                    message= _ "I cannot believe it. They have made it away! We must make chase. After them, men! Let us cross the river too! We will meet again, foul impostor."
                [/message]

                [message]
                    speaker=Konrad
                    message= _ "Do you think she’s really going to chase us, Delfador?"
                [/message]

                [message]
                    speaker=Delfador
                    message= _ "It surely looks like she will try. But many more creatures than we have fought lurk in this river; that will make it difficult for her. We must continue onward. If she makes it across before winter, then so be it!"
                [/message]
            [/then]
        [/if]

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

    [event]
        name=victory

        {CLEAR_VARIABLE lisar_still_here}
        {RESTORE_LISAR}
    [/event]

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

#undef FORD_GUARD
#undef SEA_CREATURE
