#textdomain wesnoth-sotbe
[scenario]
    id=11_Clash_of_Armies
    name= _ "Clash of Armies"
    map_data="{campaigns/Son_Of_The_Black_Eye/maps/11_Clash_of_Armies.map}"
    turns=24

    {SECOND_WATCH}
    {DAWN}
    {MORNING}
    {AFTERNOON}
    {DUSK}
    {FIRST_WATCH}

    next_scenario=12_Giving_Some_Back

    {SCENARIO_MUSIC "battle.ogg"}
    {EXTRA_SCENARIO_MUSIC "the_city_falls.ogg"}

    [event]
        name=prestart
        [objectives]
            side=1
            [objective]
                description= _ "Defend Prestim successfully for four days"
                condition=win
                show_turn_counter=yes
            [/objective]
            [objective]
                description= _ "Enemies control any villages on the north side of the river when turns run out"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Kapou’e"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Grüü"
                condition=lose
            [/objective]

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

    [side]
        type=Orcish Leader
        id="Kapou'e"
        name= _ "Kapou’e"
        side=1
        canrecruit=yes
        controller=human
        recruit= Wolf Rider, Orcish Grunt, Troll Whelp, Orcish Archer
        team_name=Kapoue
        user_team_name=_ "Kapou’e"
        gold=200
        {BLACK_FLAG}
    [/side]

    {STARTING_VILLAGES 1 10}
    {STARTING_VILLAGES_AREA 1 5 5 6}
    {STARTING_VILLAGES_AREA 1 35 5 6}

    [side]
        type=Elvish Champion
        id=Thelarion
        name= _ "Thelarion"
        side=2
        canrecruit=yes
        facing=sw
        [ai]
            aggression=1.0
            recruitment_pattern=scout, scout, fighter, fighter, fighter, healer, archer
            grouping=no
            recruitment_ignore_bad_combat=yes
            recruitment_ignore_bad_movement=yes
            village_value=0.0
            leader_value=50.0
        [/ai]
        recruit=Elvish Captain, Elvish Fighter, Elvish Archer, Elvish Marksman, Elvish Druid, Elvish Scout
        team_name=villains
        user_team_name=_"Villains"
        {GOLD 200 200 250}
        {FLAG_VARIANT long}
    [/side]

    {STARTING_VILLAGES 2 10}

    [side]
        type=Dwarvish Steelclad
        id=Darstang
        name= _ "Darstang"
        side=3
        canrecruit=yes
        [ai]
            recruitment_pattern=scout, scout, scout, fighter, fighter, mixed fighter, mixed fighter
            aggression=1.0
            caution=0.0
            villages_per_scout=0
            grouping=no
            recruitment_ignore_bad_combat=yes
            recruitment_ignore_bad_movement=yes
            village_value=20
        [/ai]
        recruit=Dwarvish Fighter, Dwarvish Thunderer, Dwarvish Scout, Bandit, Gryphon Rider
        user_team_name=_"Villains"
        team_name=villains
        {GOLD 200 250 300}
        {FLAG_VARIANT knalgan}
    [/side]

    {STARTING_VILLAGES 3 11}

    {LIMIT_CONTEMPORANEOUS_RECRUITS 3 "Gryphon Rider" 2}

    [side]
        type=General
        id="Earl Lanbec'h"
        name= _ "Earl Lanbec’h"
        profile=portraits/lanbech.png
        side=4
        canrecruit=yes
        facing=sw
        [ai]
            aggression=1.0
            recruitment_pattern=fighter, archer, mixed fighter
            grouping=no
            recruitment_ignore_bad_combat=yes
            recruitment_ignore_bad_movement=yes
            leader_value=20
            village_value=20
        [/ai]
        recruit=Swordsman, Red Mage, Pikeman, Heavy Infantryman, Fencer, Bowman
        team_name=villains
        user_team_name=_"Villains"
        {GOLD 200 400 600}
        {FLAG_VARIANT loyalist}
    [/side]

    {STARTING_VILLAGES 4 8}
    {STARTING_VILLAGES_AREA 4 19 31 6}

    [side]
        side=5
        [ai]
            aggression=1.0
            caution=0.25
            village_value=10
        [/ai]
        team_name=villains
        user_team_name=_"Villains"
        no_leader=yes
    [/side]

    [story]
        [part]
            show_title=yes
            {TO_CLASH_OF_ARMIES}
        [/part]
    [/story]

    [event]
        name=prestart

#define HUMAN_SHIP X Y FACING_VALUE ID_VALUE
    {GENERIC_UNIT 4 "Transport Galleon" {X} {Y}}
    [+unit]
        facing={FACING_VALUE}
        upkeep=free
        role="docked transport"

        [variables]
            transport_num={ID_VALUE}
            dock_x={X}
            dock_y={Y}
        [/variables]

        # Let's make the transports slightly more durable than usual so they're
        # not as easy to destroy...
        [modifications]
            [object]
                [effect]
                    apply_to=hitpoints
                    increase_total=20
                [/effect]
            [/object]
        [/modifications]
    [/unit]
#enddef

        {HUMAN_SHIP 24 16 sw 1}
        {HUMAN_SHIP 14 16 se 2}
        {HUMAN_SHIP 26 17 sw 3}
        {HUMAN_SHIP 12 17 se 4}

        [fire_event]
            name=start_boarding_next_transport
        [/fire_event]

        [role]
            type=Orcish Warlord,Troll Warrior,Orcish Warrior,Troll,Orcish Grunt
            role=cannonfodder
        [/role]
        [recall]
            role=cannonfodder
            x=18
            y=11
        [/recall]

        [role]
            role=cannonfodder2
            type=Orcish Crossbowman,Orcish Slayer,Orcish Archer,Orcish Assassin
        [/role]
        [recall]
            role=cannonfodder2
            x=20
            y=11
        [/recall]

        {RENAME_IF_DEAD thelarion_dead Thelarion (_"Telamir")}
        {RENAME_IF_DEAD darstang_dead Darstang (_"Angthur")}
    [/event]

    [event]
        name=start

        [recall]
            id=Grüü
        [/recall]
        [recall]
            id=Jetto
        [/recall]
        [recall]
            id=Inarix
        [/recall]
        [recall]
            id=Plonk
        [/recall]

        [message]
            role=cannonfodder
            message= _ "So here we are, and they are preparing to assault."
        [/message]

        [message]
            speaker="Grüü"
            message= _ "Prestim’s walls are rock-hard, they’ll waste themselves on them."
        [/message]

        [message]
            speaker="Kapou'e"
            message= _ "I’m not that sure. Every fortress has its own weakness. Prestim’s walls are strong but long and it is difficult to defend them from many directions at once. This Earl Lanbec’h must know they can’t break through by only fording the river where the bridge previously stood so he must have a better plan than that."
        [/message]

        [message]
            role=cannonfodder
            message= _ "We’ve received messengers from the Council, saying that they are gathering tribes into the Great Horde."
        [/message]

        [message]
            speaker="Grüü"
            message= _ "Great! When do they arrive?"
        [/message]

        [message]
            role=cannonfodder
            message= _ "In four days. I fear it will be too late."
        [/message]

        [message]
            speaker="Kapou'e"
            message= _ "Fool! We can hold that long. But we have to have Prestim firmly in control when the shamans arrive with the Great Horde. We can’t let the humans establish a foothold on this side of the river."
        [/message]

        [message]
            role=cannonfodder
            message= _ "Why?"
        [/message]

        [message]
            speaker="Kapou'e"
            message= _ "Because if we cannot decisively beat these humans, the other tribes won’t think us strong enough to lead them. Each chieftain will try to claim the leadership of the horde for themselves and the humans will be able to break through our defenses."
        [/message]

        [message]
            role=cannonfodder
            message= _ "Great."
        [/message]

        # TODO: Have Lanbec'h say something

        [message]
            speaker="narrator"
            message= _ "Then, the battle for Prestim began."
            image=wesnoth-icon.png
        [/message]
    [/event]

    # If a transport which is in the process of being boarded dies, free the
    # would-be-boarders and start boarding the next transport instead. This is
    # probably unnecessary as killing a transport which is about to be boarded
    # would require the player to reach the boarding areas, but better safe than
    # sorry...
    [event]
        name=die
        first_time_only=no

        [filter]
            type=Transport Galleon

            [filter_wml]
                [variables]
                    transport_num=$transport_to_board
                [/variables]
            [/filter_wml]
        [/filter]

        {MODIFY_UNIT (
            [filter_wml]
                [variables]
                    boarding_transport=yes
                [/variables]
            [/filter_wml]

            [filter_adjacent]
                x,y=$x1,$y1
            [/filter_adjacent]
        ) variables.boarding_transport no}

        [fire_event]
            name=start_boarding_next_transport
        [/fire_event]
    [/event]

    # This event triggers when the current transport to board has three adjacent
    # units ready to board it. Then it shows all three units board the
    # transport, stores those units in the transport's variables so they can be
    # unstored when the transport unloads.
    [event]
        name=side 4 turn refresh
        first_time_only=no

        [filter_condition]
            [have_unit]
                type=Transport Galleon

                [filter_wml]
                    [variables]
                        transport_num=$transport_to_board
                    [/variables]
                [/filter_wml]

                [filter_adjacent]
                    [filter_wml]
                        [variables]
                            boarding_transport=yes
                        [/variables]
                    [/filter_wml]

                    count=3
                [/filter_adjacent]
            [/have_unit]
        [/filter_condition]

        {VARIABLE_OP ships_boarded add 1}
        [switch]
            variable=ships_boarded

            [case]
                value=1

                [message]
                    speaker=Grüü
                    message= _ "Look, the humans are boarding a ship!"
                [/message]
            [/case]
        [/switch]

        [store_unit]
            [filter]
                type=Transport Galleon

                [filter_wml]
                    [variables]
                        transport_num=$transport_to_board
                    [/variables]
                [/filter_wml]
            [/filter]

            kill=no
            variable=transport
        [/store_unit]

        [store_unit]
            [filter]
                [filter_wml]
                    [variables]
                        boarding_transport=yes
                    [/variables]
                [/filter_wml]
            [/filter]

            kill=no
            variable=transport.variables.landing_party
        [/store_unit]

        {FOREACH transport.variables.landing_party i}
            [kill]
                x=$transport.variables.landing_party[$i].x
                y=$transport.variables.landing_party[$i].y
                fire_event=no
            [/kill]

            [move_unit_fake]
                x=$transport.variables.landing_party[$i].x,$transport.x
                y=$transport.variables.landing_party[$i].y,$transport.y
                type=$transport.variables.landing_party[$i].type
                gender=$transport.variables.landing_party[$i].gender
                side=4
            [/move_unit_fake]

            {VARIABLE transport.variables.landing_party[$i].moves 0}
            {VARIABLE transport.variables.landing_party[$i].attacks_left 0}
            {CLEAR_VARIABLE transport.variables.landing_party[$i].variables.boarding_transport}
        {NEXT i}

        [unstore_unit]
            variable=transport
            find_vacant=no
        [/unstore_unit]

        [fire_event]
            name=start_boarding_next_transport
        [/fire_event]

        {CLEAR_VARIABLE transport}
    [/event]

    # This makes each transport which has a landing party to move towards a
    # randomly selected landing spot.
    [event]
        name=side 4 turn refresh
        first_time_only=no

        [store_unit]
            [filter]
                type=Transport Galleon

                [filter_wml]
                    [variables]
                        [landing_party]
                        [/landing_party]
                    [/variables]
                [/filter_wml]
            [/filter]

            kill=no
            variable=moving_transports
        [/store_unit]

        {FOREACH moving_transports i}
            [if]
                [variable]
                    name=moving_transports[$i].x
                    less_than=19
                [/variable]

                [then]
                    {VARIABLE x "1-17"}
                [/then]

                [else]
                    {VARIABLE x "21-38"}
                [/else]
            [/if]

            [store_locations]
                x=$x
                y=7-11
                terrain=W*

                [filter_adjacent_location]
                    terrain=!,W*
                    count=2-6
                [/filter_adjacent_location]

                [not]
                    [filter]
                    [/filter]

                    radius=1
                [/not]

                variable=landing_sites
            [/store_locations]

            #{DEBUG_MSG "Found $landing_sites.length possible landing sites for transport $moving_transports[$i].variables.transport_num"}

            [if]
                [variable]
                    name=landing_sites.length
                    greater_than_equal_to=1
                [/variable]

                [then]
                    {RANDOM "0..$($landing_sites.length - 1)"}

                    {VARIABLE goto_x $landing_sites[$random].x}
                    {VARIABLE goto_y $landing_sites[$random].y}

                    {VARIABLE moving_transports[$i].goto_x $goto_x}
                    {VARIABLE moving_transports[$i].goto_y $goto_y}

                    #{DEBUG_MSG "Setting transport $moving_transports[$i].variables.transport_num to goto $goto_x|,$goto_y"}

                    [unstore_unit]
                        variable=moving_transports[$i]
                        find_vacant=no
                    [/unstore_unit]
                [/then]
            [/if]
        {NEXT i}

        {CLEAR_VARIABLE moving_transports,landing_sites,x,goto_x,goto_y}
    [/event]

    # This picks a nearby side 4 unit and flags it as one which should move
    # towards the transport. First looks for a unit which is within one turn's
    # movement, then for units within one turn's movement + 1 hex, then for
    # units within one turn's movement + 2 hex, etc, but doesn't pick units
    # which are more than 2 turns away and gives up when +6 is reached.
    [event]
        name=side 4 turn refresh
        first_time_only=no

        [filter_condition]
            [have_unit]
                [filter_wml]
                    [variables]
                        boarding_transport=yes
                    [/variables]
                [/filter_wml]

                count=0-2
            [/have_unit]
        [/filter_condition]

        {VARIABLE i 0}
        [while]
            [variable]
                name=possible_boarders.length
                less_than=1
            [/variable]

            [variable]
                name=i
                less_than=6
            [/variable]

            [do]
                [store_unit]
                    [filter]
                        side=4
                        canrecruit=no

                        [not]
                            type=Transport Galleon
                        [/not]

                        [filter_wml]
                            hitpoints=$this_unit.max_hitpoints
                        [/filter_wml]

                        [not]
                            [filter_wml]
                                [variables]
                                    boarding_transport=yes
                                [/variables]
                            [/filter_wml]
                        [/not]

                        [and]
                            [filter_location]
                                [filter]
                                    type=Transport Galleon

                                    [filter_wml]
                                        [variables]
                                            transport_num=$transport_to_board
                                        [/variables]
                                    [/filter_wml]
                                [/filter]

                                radius="$($this_unit.moves + min($i,$this_unit.moves))"

                                [filter_radius]
                                    terrain=G*,R*,C*,K*,*^V*,Wwf
                                [/filter_radius]
                            [/filter_location]
                        [/and]
                    [/filter]

                    kill=no
                    variable=possible_boarders
                [/store_unit]

                {VARIABLE_OP i add 1}
            [/do]
        [/while]

        [if]
            [variable]
                name=possible_boarders.length
                greater_than_equal_to=1
            [/variable]

            [then]
                {RANDOM "0..$($possible_boarders.length - 1)"}

                {VARIABLE possible_boarders[$random].variables.boarding_transport yes}

                #{DEBUG_MSG "Setting $possible_boarders[$random].name the $possible_boarders[$random].language_name to board transport $transport_to_board"}

                [unstore_unit]
                    variable=possible_boarders[$random]
                    find_vacant=no
                [/unstore_unit]
            [/then]

            #[else]
            #    {DEBUG_MSG "Found no one to go to board transport $transport_to_board|..."}
            #[/else]
        [/if]

        {CLEAR_VARIABLE possible_boarders}
    [/event]

    # This makes units which have been designated to board a transport to move
    # towards the current transport to board.
    [event]
        name=side 4 turn refresh
        first_time_only=no

        [store_unit]
            [filter]
                side=4

                [filter_wml]
                    [variables]
                        boarding_transport=yes
                    [/variables]
                [/filter_wml]

                [not]
                    [filter_adjacent]
                        [filter_wml]
                            [variables]
                                transport_num=$transport_to_board
                            [/variables]
                        [/filter_wml]
                    [/filter_adjacent]
                [/not]
            [/filter]

            kill=no
            variable=moving_to_transport
        [/store_unit]

        {FOREACH moving_to_transport i}
            # First we try to find a proper boarding location which the unit can
            # reach in one turn...
            [store_locations]
                terrain=!,W*

                [filter_adjacent_location]
                    [filter]
                        [filter_wml]
                            [variables]
                                transport_num=$transport_to_board
                            [/variables]
                        [/filter_wml]
                    [/filter]
                [/filter_adjacent_location]

                [not]
                    [filter]
                    [/filter]
                [/not]

                [and]
                    [filter]
                        x,y=$moving_to_transport[$i].x,$moving_to_transport[$i].y
                    [/filter]

                    radius=$moving_to_transport[$i].moves

                    [filter_radius]
                        terrain=G*,R*,C*,K*,*^V*,Wwf
                    [/filter_radius]
                [/and]

                variable=boarding_locs
            [/store_locations]

            # ...but if no such location was found, then we just make the unit
            # head for the transport itself for now.
            [if]
                [variable]
                    name=boarding_locs.length
                    less_than=1
                [/variable]

                [then]
                    [store_locations]
                        [filter]
                            [filter_wml]
                                [variables]
                                    transport_num=$transport_to_board
                                [/variables]
                            [/filter_wml]
                        [/filter]

                        variable=boarding_locs
                    [/store_locations]
                [/then]
            [/if]

            {RANDOM "0..$($boarding_locs.length - 1)"}

            {VARIABLE moving_to_transport[$i].goto_x $boarding_locs[$random].x}
            {VARIABLE moving_to_transport[$i].goto_y $boarding_locs[$random].y}

            #{DEBUG_MSG "Setting $moving_to_transport[$i].name the $moving_to_transport[$i].language_name to go to $boarding_locs[$random].x|,$boarding_locs[$random].y"}

            [unstore_unit]
                variable=moving_to_transport[$i]
                find_vacant=no
            [/unstore_unit]
        {NEXT i}

        {CLEAR_VARIABLE moving_to_transport,boarding_locs}
    [/event]

    [event]
        name=side 4 turn refresh
        first_time_only=no

        # Zero the movement of docked transports
        {MODIFY_UNIT (
            type=Transport Galleon
            x,y=$this_unit.variables.dock_x,$this_unit.variables.dock_y

            [not]
                [filter_wml]
                    [variables]
                        [landing_party]
                        [/landing_party]
                    [/variables]
                [/filter_wml]
            [/not]
        ) moves 0}

        # Zero the movement of units waiting to board a transport
        {MODIFY_UNIT (
            side=4

            [filter_wml]
                [variables]
                    boarding_transport=yes
                [/variables]
            [/filter_wml]
            [filter_adjacent]
                [filter_wml]
                    [variables]
                        transport_num=$transport_to_board
                    [/variables]
                [/filter_wml]
            [/filter_adjacent]
        ) moves 0}
    [/event]

    # When a transport reaches the northern shore in a spot which has at least 3
    # adjacent free non-deep hexes, so that there's enough space to unload the
    # whole landing party.
    [event]
        name=moveto
        first_time_only=no

        [filter]
            type=Transport Galleon

            [filter_location]
                x=1-38
                y=7-11

                [filter_adjacent_location]
                    [not]
                        [filter]
                        [/filter]
                    [/not]

                    terrain=!,W*
                    count=1-6
                [/filter_adjacent_location]

                [and]
                    [filter_adjacent_location]
                        [not]
                            [filter]
                            [/filter]
                        [/not]

                        terrain=!,Wo
                        count=3-6
                    [/filter_adjacent_location]
                [/and]
            [/filter_location]
        [/filter]

        {FOREACH unit.variables.landing_party i}
            [store_locations]
                terrain=!,W*

                [filter_adjacent_location]
                    x,y=$x1,$y1
                [/filter_adjacent_location]

                [not]
                    [filter]
                    [/filter]
                [/not]

                variable=disembark_loc
            [/store_locations]

            [if]
                [variable]
                    name=disembark_loc.length
                    less_than=1
                [/variable]

                [then]
                    [store_locations]
                        terrain=!,Wo

                        [filter_adjacent_location]
                            x,y=$x1,$y1
                        [/filter_adjacent_location]

                        [not]
                            [filter]
                            [/filter]
                        [/not]

                        variable=disembark_loc
                    [/store_locations]
                [/then]
            [/if]

            [move_unit_fake]
                x=$unit.x,$disembark_loc.x
                y=$unit.y,$disembark_loc.y
                type=$unit.variables.landing_party[$i].type
                gender=$unit.variables.landing_party[$i].gender
                side=4
            [/move_unit_fake]

            [unstore_unit]
                variable=unit.variables.landing_party[$i]
                x,y=$disembark_loc.x,$disembark_loc.y
            [/unstore_unit]
        {NEXT i}

        {VARIABLE_OP landing_parties_landed add 1}
        [switch]
            variable=landing_parties_landed

            [case]
                value=1

                [message]
                    x,y=$disembark_loc.x,$disembark_loc.y
                    message= _ "Charge!"
                [/message]
            [/case]

            [case]
                value=2

                [message]
                    x,y=$disembark_loc.x,$disembark_loc.y
                    message= _ "Get them!"
                [/message]
            [/case]
        [/switch]

        {CLEAR_VARIABLE unit.variables.landing_party}

        {VARIABLE unit.moves 0}

        [unstore_unit]
            variable=unit
            find_vacant=no
        [/unstore_unit]
    [/event]

    # This makes transports which have no landing party and aren't at their dock
    # location to return to their dock. This should only be the case when a
    # transport has unloaded their landing party but hasn't yet returned.
    [event]
        name=side 4 turn refresh
        first_time_only=no

        [store_unit]
            [filter]
                type=Transport Galleon

                [not]
                    x,y=$this_unit.variables.dock_x,$this_unit.variables.dock_y
                [/not]

                [not]
                    [filter_wml]
                        [variables]
                            [landing_party]
                            [/landing_party]
                        [/variables]
                    [/filter_wml]
                [/not]
            [/filter]

            kill=yes
            variable=returning_transports
        [/store_unit]

        {FOREACH returning_transports i}
            {VARIABLE returning_transports[$i].goto_x $returning_transports[$i].variables.dock_x}
            {VARIABLE returning_transports[$i].goto_y $returning_transports[$i].variables.dock_y}

            #{DEBUG_MSG "Setting transport $returning_transports[$i].variables.transport_num to return to $returning_transports[$i].variables.dock_x|,$returning_transports[$i].variables.dock_y"}

            [unstore_unit]
                variable=returning_transports[$i]
            [/unstore_unit]
        {NEXT i}

        {CLEAR_VARIABLE returning_transports}
    [/event]

    # This event simply cycles the variable $transport_to_board through values
    # of 1,2,3,4,1,2,3,4,1,2,..., starting from whatever value it is originally
    # set to (if not, then the first call to this sets it to 1).
    [event]
        name=start_boarding_next_transport
        first_time_only=no

        {VARIABLE i $transport_to_board}
        [while]
            [not]
                [have_unit]
                    type=Transport Galleon

                    [filter_wml]
                        [variables]
                            transport_num=$i
                        [/variables]
                    [/filter_wml]
                [/have_unit]
            [/not]

            [or]
                [variable]
                    name=i
                    numerical_equals=$transport_to_board
                [/variable]
            [/or]

            [do]
                [if]
                    [variable]
                        name=i
                        less_than=4
                    [/variable]

                    [then]
                        {VARIABLE_OP i add 1}
                    [/then]

                    [else]
                        {VARIABLE i 1}
                    [/else]
                [/if]
            [/do]
        [/while]

        #{DEBUG_MSG "Next transport to board is transport $i"}

        {VARIABLE transport_to_board $i}
    [/event]

    [event]
        name=turn 2

        [unit]
            side=5
            type=Merman Warrior
            id=Plouf
            name= _ "Plouf"
            x=1
            y=16
            random_traits=yes
        [/unit]

        {GENERIC_UNIT 5 (Merman Fighter) 1 15}
        {GENERIC_UNIT 5 (Merman Fighter) 1 17}

        [message]
            speaker="Plouf"
            message= _ "We arrive to honor our alliance, Earl Lanbec’h."
        [/message]

        [message]
            speaker="Kapou'e"
            message= _ "Curses! They have fish-men on their side."
        [/message]
    [/event]

    [event]
        name=turn 6,turn 10
        first_time_only=no

        [scroll_to]
            x,y=1,15
        [/scroll_to]

        {GENERIC_UNIT 5 (Merman Fighter) 1 15}
        {GENERIC_UNIT 5 (Merman Fighter) 1 16}
#ifndef EASY
        {GENERIC_UNIT 5 (Merman Fighter) 1 17}
#endif

        [delay]
            time=500
        [/delay]
    [/event]

    [event]
        name=turn 4,turn 8,turn 12
        first_time_only=no

        [scroll_to]
            x,y=38,14
        [/scroll_to]

        {GENERIC_UNIT 5 (Merman Fighter) 38 14}
        [+unit]
            facing=sw
        [/unit]
        {GENERIC_UNIT 5 (Merman Fighter) 38 13}
        [+unit]
            facing=sw
        [/unit]
#ifndef EASY
        {GENERIC_UNIT 5 (Merman Fighter) 38 12}
        [+unit]
            facing=sw
        [/unit]
#endif

        [delay]
            time=500
        [/delay]
    [/event]

    [event]
        name=turn 24

        [filter_condition]
            [have_location]
                terrain=*^V*
                y=1-11

                [not]
                    owner_side=1
                [/not]
            [/have_location]
        [/filter_condition]

        [message]
            speaker="Kapou'e"
            message= _ "The Great Horde is almost here! Drive them out of our villages <b>now</b>!"
        [/message]
    [/event]

    [event]
        name=time over

        {ORCISH_SHAMAN 11 1 Pirk _"Pirk"}
        {OLD_ORCISH_SHAMAN 11 1 Gork _"Gork"}
        {NOVICE_ORCISH_SHAMAN 11 1 Vraurk _"Vraurk"}
        {UNIT 1 "Orcish Warrior" 11 1 role=greathordeprops}
        {UNIT 1 "Orcish Warrior" 11 1 role=greathordeprops}
        {UNIT 1 "Orcish Crossbowman" 11 1 role=greathordeprops}
        {UNIT 1 "Orcish Crossbowman" 11 1 role=greathordeprops}
        {UNIT 1 "Orcish Slayer" 11 1 role=greathordeprops}
        {UNIT 1 "Orcish Slayer" 11 1 role=greathordeprops}
        {UNIT 1 "Orcish Warlord" 11 1 role=greathordewarlord1}
        {UNIT 1 "Orcish Crossbowman" 11 1 role=greathordeprops}
        {UNIT 1 "Goblin Pillager" 11 1 role=greathordeprops}
        {UNIT 1 "Goblin Pillager" 11 1 role=greathordeprops}
        {UNIT 1 "Orcish Warrior" 11 1 role=greathordeprops}
        {UNIT 1 "Orcish Warlord" 11 1 role=greathordewarlord2}

        [if]
            [have_location]
                terrain=*^V*
                y=1-11

                [not]
                    owner_side=1
                [/not]
            [/have_location]

            [then]
                [message]
                    speaker="Gork"
                    message= _ "Here we are!"
                [/message]

                [message]
                    role=greathordewarlord1
                    message= _ "What’s this? This weakling has let humans enter Prestim? I will lead the horde and push them to the river!"
                    image=portraits/orcs/transparent/grunt-6.png
                [/message]

                [message]
                    role=greathordewarlord2
                    message= _ "Bah! I’m the only one strong enough to drive out the humans! The Great Horde follows me!"
                    image=portraits/orcs/transparent/grunt-5.png
                [/message]

                [message]
                    speaker="Earl Lanbec'h"
                    message= _ "Look at that, the stupid orcs are starting to fight amongst themselves! Now’s our chance, everyone attack!"
                [/message]

                [endlevel]
                    result=defeat
                [/endlevel]
            [/then]

            [else]
                [message]
                    speaker="Gork"
                    message= _ "Here we are! Hold on Prestim, we arrive to push them to the river!"
                [/message]

                [message]
                    speaker="Earl Lanbec'h"
                    message= _ "They are too numerous now, RETREAT!"
                [/message]

                [kill]
                    side=5
                    animate=no
                [/kill]
                [kill]
                    side=2
                    animate=no
                [/kill]
                [kill]
                    side=3
                    animate=no
                [/kill]
                [kill]
                    side=4
                    animate=no
                [/kill]

                [message]
                    speaker="Kapou'e"
                    message= _ "The Great Horde at last! I was beginning to think they would never come."
                [/message]

                [message]
                    speaker="Gork"
                    message= _ "Your defense of Prestim was heroic, facing such opposition surely undermined the morale of humans. Now they are retreating to their fortresses and will not venture out anytime soon."
                [/message]

                [message]
                    speaker="Pirk"
                    message= _ "It is now time to show them who we are and to lead the Great Horde in pursuit. We will not rest until we destroy Earl Lanbec’h. Smite, stab, slay!"
                [/message]

                {CLEAR_VARIABLE transport_to_board}

                [endlevel]
                    result=victory
                    bonus=no
                    {NEW_GOLD_CARRYOVER 40}
                [/endlevel]
            [/else]
        [/if]
    [/event]

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