#textdomain wesnoth-trow
[scenario]
    id=14_Rough_Landing
    name= _ "Rough Landing"
    next_scenario=15_A_New_Land
    bonus=yes
    map_data="{campaigns/The_Rise_Of_Wesnoth/maps/14_Rough_Landing.map}"

    {TURNS 35 32 29}
    {DEFAULT_SCHEDULE}

    {SCENARIO_MUSIC knolls.ogg}
    {EXTRA_SCENARIO_MUSIC wanderer.ogg}

    {TROW_ROUGH_LANDING_STORY}

    {TROW_DEATHS}

    [side]
        type=Noble Commander
        id=Prince Haldric
        name= _ "Prince Haldric"
        unrenamable=yes
        side=1
        canrecruit=yes
        gold=200
        controller=human
        team_name=Haldric
        user_team_name=_"Refugees"
        {FLAG_VARIANT loyalist}
    [/side]

    [side]
        type=Naga Warrior
        id=Abraxas
        name= _ "Abraxas"
        side=2
        canrecruit=yes
        {GOLD 90 145 230}
        {INCOME 2 4 8}
        team_name=Naga
        user_team_name=_"Naga"
#ifdef EASY
        recruit=Naga Fighter
#else
        recruit=Naga Fighter, Vampire Bat
#endif
        [ai]
            {NO_SCOUTS}
            recruitment_ignore_bad_movement=yes
            aggression=0.60
#ifdef EASY
            recruitment_pattern=fighter
#else
            recruitment_pattern=scout,fighter,fighter,fighter
#endif
            {ATTACK_DEPTH 4 5 5}
        [/ai]
    [/side]

    [side]
        type=Naga Warrior
        id=Xamalia
        name= _ "Xamalia"
        side=3
        canrecruit=yes
        {GOLD 90 145 230}
        {INCOME 2 4 8}
        team_name=Naga
        user_team_name=_"Naga"
#ifdef EASY
        recruit=Naga Fighter
#else
        recruit=Naga Fighter, Vampire Bat
#endif
        [ai]
            {NO_SCOUTS}
            recruitment_ignore_bad_movement=yes
            aggression=0.60
#ifdef EASY
            recruitment_pattern=fighter
#else
            recruitment_pattern=scout,fighter,fighter,fighter
#endif
            {ATTACK_DEPTH 4 5 5}
        [/ai]
    [/side]

    [side]
        type=Naga Warrior
        id=Gaxmail
        name= _ "Gaxmail"
        side=4
        canrecruit=yes
        {GOLD 90 145 230}
        {INCOME 2 4 8}
        team_name=Naga
        user_team_name=_"Naga"
#ifdef EASY
        recruit=Naga Fighter
#else
        recruit=Naga Fighter, Vampire Bat
#endif
        [ai]
            {NO_SCOUTS}
            recruitment_ignore_bad_movement=yes
            aggression=0.60
#ifdef EASY
            recruitment_pattern=fighter
#else
            recruitment_pattern=scout,fighter,fighter,fighter
#endif
            {ATTACK_DEPTH 4 5 5}
        [/ai]
    [/side]

    [event]
        name=prestart
        [recall]
            id=Lady Jessene
            x=8
            y=25
        [/recall]
        [recall]
            id=Burin the Lost
            x=8
            y=26
        [/recall]
        [recall]
            id=Sir Ruddry
            x=10
            y=25
        [/recall]

        [recall]
            id=Sir Ladoc
            x=10
            y=25
        [/recall]

        [recall]
            id=Minister Edren
            x=10
            y=26
        [/recall]

        [recall]
            id=Lord Typhon
            x=10
            y=24
        [/recall]

        {PLACE_IMAGE ("units/transport/galleon.png~RC(magenta>red)") 10 27}

        [objectives]
            side=1
            [objective]
                description= _ "Defeat all enemy leaders"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Prince Haldric"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Lady Jessene"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Lord Typhon"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

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

    [event]
        name=start
        [message]
            speaker=narrator
            message= _ "After a particularly bad series of storms the Eldaric has taken on water, and much of the fleet has been scattered. Lord Typhon suggests stopping at a group of small windswept islands to regroup."
            image=wesnoth-icon.png
        [/message]

        [message]
            speaker=Burin the Lost
            message= _ "I don’t think I can take much more of this. I’m feeling ill!"
            image=portraits/burin-annoyed.png
        [/message]

        [message]
            speaker=Lord Typhon
            message= _ "Be careful, these islands aren’t safe. We’re in Naga territory. But this is the only place to stop with soft sand beaches to make landfall... The Nagas like to scavenge metal from ships that they capture here."
        [/message]

        [message]
            speaker=Xamalia
            message= _ "Prey! Get them!"
        [/message]

        [message]
            speaker=Prince Haldric
            message= _ "The fleet must regroup here. We have to defeat these monsters."
        [/message]
    [/event]

    # Upon the first loss of an enemy side, a serpent is spawned in a location
    # from which it can't reach any player unit in one turn. The side 2 serpent
    # has a spawn delay of 1 turn, the side 3 serpent a delay of 2 turns and the
    # side 4 serpent a delay of 3 turns; this is done so that the serpents can't
    # all appear at once but will likely be spaced out more.
    [event]
        name=die
        first_time_only=no

        [filter]
            side=2,3,4
        [/filter]

        [filter_condition]
            [variable]
                name=side_$unit.side|_serpent_triggered
                boolean_not_equals=yes
            [/variable]
        [/filter_condition]

        {VARIABLE side_$unit.side|_serpent_triggered yes}

        [switch]
            variable=unit.side

            [case]
                value=2

                {VARIABLE serpent_name _"Chompey the Serpent"}
                {VARIABLE serpent_msg _"Graarrrrrr!"}
            [/case]

            [case]
                value=3

                {VARIABLE serpent_name _"Scaly the Serpent"}
                {VARIABLE serpent_msg _"Roarrrrrr!"}
            [/case]

            [case]
                value=4

                {VARIABLE serpent_name _"Toothey the Serpent"}
                {VARIABLE serpent_msg _"Hissssss!"}
            [/case]
        [/switch]

        # This gets set to 1 when this gets run for the first time
        {VARIABLE_OP serpent_spawn_delay add 1}

        {VARIABLE serpent_spawn_turn_number "$($turn_number + $serpent_spawn_delay)"}

        [event]
            name=new turn
            delayed_variable_substitution=no

            # We need to use this lengthy SLF twice, so macroify it here...
#define POSSIBLE_SERPENT_SPAWN_LOCS_SLF
    terrain=Wo*

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

    [not]
        [filter]
            side=1
        [/filter]

        radius=9
    [/not]

    [and]
        [filter]
            side=1
        [/filter]

        radius=10
    [/and]
#enddef

            [filter_condition]
                [variable]
                    name=turn_number
                    greater_than_equal_to=$serpent_spawn_turn_number
                [/variable]

                [have_location]
                    {POSSIBLE_SERPENT_SPAWN_LOCS_SLF}
                [/have_location]
            [/filter_condition]

            [store_locations]
                {POSSIBLE_SERPENT_SPAWN_LOCS_SLF}

                variable=possible_serpent_locs
            [/store_locations]

            {VARIABLE_OP serpent_loc_i rand "0..$|($|possible_serpent_locs.length - 1)"}

            [scroll_to]
                x,y=$|possible_serpent_locs[$|serpent_loc_i].x,$|possible_serpent_locs[$|serpent_loc_i].y
            [/scroll_to]

            [sound]
                name=water-blast.wav
            [/sound]

            {NAMED_LOYAL_UNIT $unit.side (Sea Serpent) $|possible_serpent_locs[$|serpent_loc_i].x $|possible_serpent_locs[$|serpent_loc_i].y () $serpent_name}
            [+unit]
                animate=yes
            [/unit]

            [message]
                x,y=$|possible_serpent_locs[$|serpent_loc_i].x,$|possible_serpent_locs[$|serpent_loc_i].y
                message=$serpent_msg
            [/message]

            [message]
                side=1
                [filter_location]
                    x,y=$|possible_serpent_locs[$|serpent_loc_i].x,$|possible_serpent_locs[$|serpent_loc_i].y
                    radius=10
                [/filter_location]
                message= _ "Look out, a serpent has emerged from the deep."
            [/message]

            {CLEAR_VARIABLE possible_serpent_locs,serpent_loc_i}
        [/event]

        {CLEAR_VARIABLE serpent_name,serpent_msg,serpent_spawn_turn_number}
    [/event]

    [event]
        name=enemies defeated
        [message]
            speaker=Prince Haldric
            message= _ "We’ve defeated the nagas. The fleet should be able to regroup here."
        [/message]

        [message]
            speaker=Lady Jessene
            message= _ "The next time we see land, it should be the great continent to the east."
        [/message]

        [message]
            speaker=Prince Haldric
            message= _ "I’ll be glad when this voyage is over. We’re almost there. Almost there."
        [/message]

        [move_unit_fake]
            type=Familiar
            side=4
            x=1,2,3
            y=25,25,26
        [/move_unit_fake]

        {LIVING_INTEL (Familiar) (Familiar) ( _ "Familiar") "portraits/familiar.png" 4 3 26}
        # wmllint: recognize Familiar

        [message]
            speaker=Familiar
            message= _ "<i>Clack</i>! <i>Clack!</i>"
        [/message]

        [kill]
            id=Familiar
        [/kill]

        [move_unit_fake]
            type=Familiar
            side=4
            x=3,3,2,1
            y=26,27,27,28
        [/move_unit_fake]

        [message]
            speaker=Lady Jessene
            message= _ "I think we’re being followed..."
        [/message]

        {CLEAR_VARIABLE side_2_serpent_triggered,side_3_serpent_triggered,side_4_serpent_triggered,serpent_spawn_delay}

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

    [event]
        name=time over
        [message]
            speaker=Lady Jessene
            message= _ "We were too slow... The fleet will be scattered to the four corners of the world!"
        [/message]
    [/event]
[/scenario]
