#textdomain wesnoth-sotbe
[scenario]
    id=11_Clash_of_Armies
    name= _ "Clash of Armies"
    map_file=11_Clash_of_Armies.map
    turns=24

    {DEFAULT_SCHEDULE_SECOND_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= _ "You don’t control all 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]
        side=1
        id="Kapou'e"
        type=Orcish Leader
        controller=human
        team_name=Kapoue
        user_team_name=_ "Kapou’e"
        {GOLD 280 240 200}
        {INCOME 6 5 4}
        {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
            grouping=no
            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 250 300}
        {FLAG_VARIANT wood-elvish}
    [/side]

    {STARTING_VILLAGES 2 10}

    [side]
        type=Dwarvish Steelclad
        id=Darstang
        name= _ "Darstang"
        side=3
        canrecruit=yes
        [ai]
            aggression=1.0
            caution=0.0
            villages_per_scout=0
            grouping=no
            village_value=20

            [aspect]
                id=recruitment_instructions
                [facet]
                    turns=1-2
                    [value]
                        [recruit]
                            type=Gryphon Rider
                            number=1
                            importance=1
                        [/recruit]
                        [recruit]
                            importance=0
                            type=Dwarvish Fighter, Dwarvish Thunderer, Dwarvish Scout, Bandit
                        [/recruit]
                    [/value]
                [/facet]
                [facet]
                    turns=3-24
                    [value]
                        [recruit]
                            type=Gryphon Rider
#ifdef HARD
                            number=3
#else
                            number=2
#endif
                            total=yes
                            importance=1
                        [/recruit]
                        [recruit]
                            importance=0
                            type=Dwarvish Fighter, Dwarvish Thunderer, Dwarvish Scout, Bandit
                        [/recruit]
                    [/value]
                [/facet]
            [/aspect]
        [/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}

    [side]
        type=General
        id="Earl Lanbec'h"
        name= _ "Earl Lanbec’h"
        profile=portraits/lanbech.webp
        side=4
        canrecruit=yes
        facing=sw
        [ai]
            aggression=1.0
            grouping=no
            leader_value=20
            village_value=20
        [/ai]
        recruit=Swordsman, Red Mage, Pikeman, Heavy Infantryman, Fencer, Bowman
        team_name=villains
        user_team_name=_"Villains"
        {GOLD 400 500 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]

    {SOTBE_TRACK {JOURNEY_11_NEW} }

    [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
            [auto_recall]
                x,y=18,11
            [/auto_recall]
        [/role]

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

        {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 leadership of the horde for themselves, and the humans will be able to break through our defenses."
        [/message]

        [message]
            role=cannonfodder
            message= _ "Great."
        [/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]
            array=transport.variables.landing_party
            [do]
                [kill]
                    x=$this_item.x
                    y=$this_item.y
                    fire_event=no
                [/kill]

                [move_unit_fake]
                    x=$this_item.x,$transport.x
                    y=$this_item.y,$transport.y
                    type=$this_item.type
                    gender=$this_item.gender
                    side=4
                [/move_unit_fake]

                {VARIABLE this_item.moves 0}
                {VARIABLE this_item.attacks_left 0}
                {CLEAR_VARIABLE this_item.variables.boarding_transport}
            [/do]
        [/foreach]

        [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]
            array=moving_transports
            [do]
                [if]
                    [variable]
                        name=this_item.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 $this_item.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 this_item.goto_x $goto_x}
                        {VARIABLE this_item.goto_y $goto_y}

                        #{DEBUG_MSG "Setting transport $this_item.variables.transport_num to goto $goto_x|,$goto_y"}

                        [unstore_unit]
                            variable=this_item
                            find_vacant=no
                        [/unstore_unit]
                    [/then]
                [/if]
            [/do]
        [/foreach]

        {CLEAR_VARIABLE moving_transports,landing_sites,x,goto_x,goto_y,random}
    [/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,random}
    [/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]
            array=moving_to_transport
            [do]
                # 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=$this_item.x,$this_item.y
                        [/filter]

                        radius=$this_item.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 this_item.goto_x $boarding_locs[$random].x}
                {VARIABLE this_item.goto_y $boarding_locs[$random].y}

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

                [unstore_unit]
                    variable=this_item
                    find_vacant=no
                [/unstore_unit]
            [/do]
        [/foreach]

        {CLEAR_VARIABLE moving_to_transport,boarding_locs,random}
    [/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]
            array=unit.variables.landing_party
            [do]
                [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=$this_item.type
                    gender=$this_item.gender
                    side=4
                [/move_unit_fake]

                [unstore_unit]
                    variable=this_item
                    x,y=$disembark_loc.x,$disembark_loc.y
                [/unstore_unit]
            [/do]
        [/foreach]

        {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,disembark_loc}

        {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]
            array=returning_transports
            [do]
                {VARIABLE this_item.goto_x $this_item.variables.dock_x}
                {VARIABLE this_item.goto_y $this_item.variables.dock_y}

                #{DEBUG_MSG "Setting transport $this_item.variables.transport_num to return to $this_item.variables.dock_x|,$this_item.variables.dock_y"}

                [unstore_unit]
                    variable=this_item
                [/unstore_unit]
            [/do]
        [/foreach]

        {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}
        [if]
            [variable]
                name=i
                less_than=4
            [/variable]

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

            [else]
                {VARIABLE i 1}
            [/else]
        [/if]
        [while]
            [not]
                [have_unit]
                    type=Transport Galleon

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

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

            [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]
#ifdef EASY
        name=turn 6,turn 10,turn 14
#endif
#ifdef NORMAL
        name=turn 6,turn 10,turn 14, turn 18
#endif
#ifdef HARD
        name=turn 6,turn 10,turn 14, turn 18, turn 22
#endif
        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]
#ifdef EASY
        name=turn 4,turn 8,turn 12
#endif
#ifdef NORMAL
        name=turn 4,turn 8,turn 12,turn 16
#endif
#ifdef HARD
        name=turn 4,turn 8,turn 12,turn 16,turn 20
#endif
        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 1 11 1 Pirk _"Pirk"}
        {OLD_ORCISH_SHAMAN 1 11 1 Gork _"Gork"}
        {NOVICE_ORCISH_SHAMAN 1 11 1 Vraurk _"Vraurk"}
        # wmllint: whofield clear
        {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/grunt-6.webp
                [/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/grunt-5.webp
                [/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 will help you 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 the humans. Now they are retreating to their fortresses and will not venture out again 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,landing_parties_landed,landing_parties_landed,ships_boarded}

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

    {HERO_DEATHS}
[/scenario]
