#textdomain wesnoth-httt
[scenario]
    id=04_The_Bay_of_Pearls
    name= _ "The Bay of Pearls"
    map_data="{campaigns/Heir_To_The_Throne/maps/04_The_Bay_of_Pearls.map}"
    {SCENARIO_MUSIC "breaking_the_chains.ogg"}
    {EXTRA_SCENARIO_MUSIC "battle.ogg"}
    {TURNS 27 24 21}

    {DEFAULT_SCHEDULE}

    next_scenario=05a_Muff_Malals_Peninsula

    [event]
        name=prestart
        [objectives]
            side=1
            [objective]
                description= _ "Defeat one enemy leader, and resist the other until time expires"
                condition=win
            [/objective]
            [objective]
                description= _ "<span color='white'>Alternative objective:</span>
<span color='green'>Defeat all enemy leaders</span> <small>(early finish bonus)</small>"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Konrad"
                condition=lose
            [/objective]
            [objective]
                description= _ "Turns run out"
                condition=lose
            [/objective]

            note={NEW_GOLD_CARRYOVER_NOTE_40}   # wmllint: ignore
        [/objectives]
    [/event]

    {BIGMAP_BAY_OF_PEARLS}

    [side]
        type=Commander
        id=Konrad
        name= _ "Konrad"
        unrenamable=yes
        profile=portraits/konrad.png
        side=1
        canrecruit=yes
        team_name=elves
        user_team_name=_"Rebels"
        gold=140
        controller=human
    [/side]

    [side]
        type=Orcish Warrior
        id=Dwaba-Kukai
        name= _ "Dwaba-Kukai"
        side=2
        canrecruit=yes
        profile=portraits/orcs/transparent/warlord.png
        recruit=Vampire Bat,Naga Fighter
        [ai]
            recruitment_pattern=scout,fighter
            {ATTACK_DEPTH 1 3 5}
        [/ai]
        team_name=orcs
        user_team_name=_"Orcs"
        {GOLD 30 60 110}
    [/side]

    [side]
        type=Orcish Warrior
        id="Managa'Gwin"
        name= _ "Managa'Gwin"
        recruit=Wolf Rider,Orcish Warrior,Troll Whelp,Orcish Archer
        side=3
        canrecruit=yes
        {GOLD 90 150 210}
        [ai]
            {ATTACK_DEPTH 1 3 5}
        [/ai]
        team_name=orcs
        user_team_name=_"Orcs"
    [/side]

    {STARTING_VILLAGES 2 14}
    {STARTING_VILLAGES 3 10}
    {STARTING_VILLAGES_AREA 3 27 29 5}
    {STARTING_VILLAGES_AREA 3 20 37 5}
    {STARTING_VILLAGES_AREA 3 10 37 1}
    {STARTING_VILLAGES_AREA 2 5 38 1}
    {STARTING_VILLAGES_AREA 2 9 34 2}
    {STARTING_VILLAGES_AREA 3 25 3 1}

    [event]
        name=prestart

        #
        # Grant an extra enchampment tile
        #
#ifdef EASY
        [terrain]
            x=2
            y=35
            terrain=Ce
        [/terrain]
#endif

        #
        # Remove the river ford hexes on hard
        #
#ifdef HARD
        [terrain]
            x=4-6
            y=40
            terrain=Ww
        [/terrain]
#endif

        [recall]
            id=Delfador
            show=no
        [/recall]

        #the ship they came on.
        {PLACE_IMAGE "units/transport/galleon.png~RC(magenta>red)" 2 34}

        [unit]
            type=Orcish Archer
            id=Bugg
            name= _ "Bugg"
            side=2
            x=16
            y=18
            ai_special=guardian
            [modifications]
                {TRAIT_LOYAL}
            [/modifications]
            {IS_LOYAL}
        [/unit]
        [unit]
#ifdef EASY
            type=Naga Fighter
#else
            type=Naga Warrior
#endif
            id=Xnamas
            name= _ "Xnamas"
            x=2
            y=10
            ai_special=guardian
            side=2
            [modifications]
                {TRAIT_LOYAL}
            [/modifications]
            {IS_LOYAL}
        [/unit]
        [unit]
#ifdef HARD
            type=Naga Warrior
#else
            type=Naga Fighter
#endif
            id=Inalai
            name= _ "Inalai"
            x=4
            y=10
            ai_special=guardian
            side=2
            [modifications]
                {TRAIT_LOYAL}
            [/modifications]
            {IS_LOYAL}
        [/unit]

        {OBJ_TRIDENT_STORM 5 4 bop_stormtrident}

        #when certain villages are entered, Merfolk are rescued
        {PLACE_IMAGE "units/merfolk/fighter.png~RC(magenta>red)" 5 38}
        {PLACE_IMAGE items/cage.png 5 38}

        {PLACE_IMAGE "units/merfolk/fighter.png~RC(magenta>red)" 7 35}
        {PLACE_IMAGE items/cage.png 7 35}

        {PLACE_IMAGE "units/merfolk/fighter.png~RC(magenta>red)" 11 33}
        {PLACE_IMAGE items/cage.png 11 33}

        {PLACE_IMAGE "units/merfolk/fighter.png~RC(magenta>red)" 19 23}
        {PLACE_IMAGE items/cage.png 19 23}

        {PLACE_IMAGE "units/merfolk/fighter.png~RC(magenta>red)" 3 10}
        {PLACE_IMAGE items/cage.png 3 10}
    [/event]

    [event]
        name=start
        [message]
            speaker=Konrad
            message= _ "So this is the Bay of Pearls. It looks like they have those merfolk working hard!"
        [/message]
        [message]
            speaker=Delfador
            message= _ "Indeed it does. It also looks like they have many, many troops. I should go around the bay and distract some of them. You and the rest rescue the merfolk!"
        [/message]
        [message]
            speaker=Konrad
            message= _ "Very well. Be careful!"
        [/message]

        #Delfador leaves the party
        [store_unit]
            variable=delfador_store
            kill=yes
            [filter]
                id=Delfador
            [/filter]
        [/store_unit]
    [/event]

    #comic relief with Bugg becoming a 'sea orc'
    [event]
        name=turn 3
        # ensure Bugg hasn't been killed
        [if]
            [have_unit]
                side=2
                id=Bugg
            [/have_unit]
            [then]
                [message]
                    speaker=Bugg
                    message= _ "But boss, why are we only using bats and nagas?"
                [/message]

                [message]
                    speaker=Dwaba-Kukai
                    message= _ "Because we need to control the seas and the merfolk, and nagas and bats are best for doing that!"
                [/message]

                [message]
                    speaker=Bugg
                    message= _ "But orcs are the most powerful race in all of..."
                [/message]

                [message]
                    speaker=Dwaba-Kukai
                    message= _ "Shut up, worm! I'm the boss!"
                [/message]
            [/then]
        [/if]
    [/event]

    [event]
        name=turn 4
        [if]
            [have_unit]
                side=2
                id=Bugg
            [/have_unit]
            [then]
                [store_unit]
                    variable=bugg_flip
                    [filter]
                        id=Bugg
                    [/filter]
                    kill=yes
                [/store_unit]

                {NAMED_LOYAL_UNIT 2 (Sea Orc) $bugg_flip.x $bugg_flip.y (Bugg) ( _ "Bugg")}

                {CLEAR_VARIABLE bugg_flip}

                [message]
                    speaker=Bugg
                    message= _ "Ha ha ha! Now orcs will rule over land and sea!"
                [/message]

                [message]
                    speaker=Dwaba-Kukai
                    message= _ "(Sigh) Will someone kill this idiot for me, please?"
                [/message]
            [/then]
        [/if]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Bugg
        [/filter]
        [message]
            speaker=unit
            message= _ "But... but... how can this be happening to me?"
        [/message]
        [message]
            speaker=second_unit
            message= _ "Who was that idiot?"
        [/message]
    [/event]

    [event]
        name=moveto

        [removeitem]
        [/removeitem]

        [filter]
            side=1
            x=19
            y=23
        [/filter]

        [unit]
            side=1
            x=19
            y=23
            id=Gwaba
            type=Merman Fighter
            name= _ "Gwaba"
            unrenamable=yes
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_STRONG}
            [/modifications]
            {IS_LOYAL}
        [/unit]
        [unit]
            side=1
            x=19
            y=23
            id=Nepba
            type=Merman Fighter
            name= _ "Nepba"
            unrenamable=yes
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_INTELLIGENT}
            [/modifications]
            {IS_LOYAL}
        [/unit]
        [unit]
            side=1
            x=19
            y=23
            id=Triram
            type=Merman Fighter
            name= _ "Triram"
            unrenamable=yes
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
            {IS_LOYAL}
        [/unit]

#ifdef EASY
        [unit]
            side=1
            x=19
            y=23
            id=Mriram
            type=Merman Fighter
            name= _ "Mriram"
            unrenamable=yes
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_STRONG}
            [/modifications]
            {IS_LOYAL}
        [/unit]
#endif
        [message]
            speaker=Gwaba
            message= _ "Free at last! Now, death to the orcs!"
        [/message]
    [/event]

    [event]
        name=moveto
        [removeitem]
        [/removeitem]

        [filter]
            side=1
            x=11
            y=33
        [/filter]

        [unit]
            side=1
            x=11
            y=33
            id=Mabooa
            type=Merman Fighter
            name= _ "Mabooa"
            unrenamable=yes
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
            {IS_LOYAL}
        [/unit]

#ifdef EASY
        [unit]
            side=1
            x=11
            y=33
            id=Earooa
            type=Merman Fighter
            name= _ "Earooa"
            unrenamable=yes
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_STRONG}
            [/modifications]
            {IS_LOYAL}
        [/unit]
        [unit]
            side=1
            x=11
            y=33
            id=Nethuns
            type=Merman Fighter
            name= _ "Nethuns"
            unrenamable=yes
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_INTELLIGENT}
            [/modifications]
            {IS_LOYAL}
        [/unit]
#else
        [unit]
            side=1
            x=11
            y=33
            id=Gwoama
            type=Merman Fighter
            name= _ "Gwoama"
            unrenamable=yes
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
            {IS_LOYAL}
        [/unit]
#endif
        [message]
            speaker=Mabooa
            message= _ "Now that we are free, together we can defeat our oppressors!"
        [/message]
    [/event]

    [event]
        name=moveto
        [removeitem]
        [/removeitem]

        [filter]
            side=1
            x=7
            y=35
        [/filter]

        [unit]
            side=1
            x=7
            y=35
            id=Kaba
            type=Merman Fighter
            name= _ "Kaba"
            unrenamable=yes
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_QUICK}
            [/modifications]
            {IS_LOYAL}
        [/unit]

#ifdef EASY
        [unit]
            side=1
            x=7
            y=35
            id=Kwaboo
            type=Merman Fighter
            name= _ "Kwaboo"
            unrenamable=yes
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_INTELLIGENT}
            [/modifications]
            {IS_LOYAL}
        [/unit]
#endif

        [message]
            speaker=Kaba
            message= _ "Freedom! Now where are those orcs? Let me at 'em!"
        [/message]
    [/event]

    [event]
        name=moveto
        [removeitem]
        [/removeitem]

        [filter]
            x=5
            y=38
            side=1
        [/filter]

        [unit]
            side=1
            x=5
            y=38
            id=Gwimli
            type=Merman Fighter
            name= _ "Gwimli"
            unrenamable=yes
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_STRONG}
            [/modifications]
            {IS_LOYAL}
        [/unit]
        [unit]
            side=1
            x=5
            y=38
            id=Jarla
            type=Merman Fighter
            name= _ "Jarla"
            unrenamable=yes
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_INTELLIGENT}
            [/modifications]
            {IS_LOYAL}
        [/unit]

#ifdef EASY
        [unit]
            side=1
            x=5
            y=38
            id=Gwarloa
            type=Merman Fighter
            name= _ "Gwarloa"
            unrenamable=yes
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
            {IS_LOYAL}
        [/unit]
#endif
        [message]
            speaker=Gwimli
            message= _ "Thank you for rescuing us! Now we can help you fight the evil orcs! The main cage where they keep most of the mermen is in the northwest!"
        [/message]
    [/event]

    [event]
        name=moveto
        [removeitem]
        [/removeitem]

        [filter]
            side=1
            x=3
            y=10
        [/filter]

        [unit]
            side=1
            x=3
            y=10
            id=Heldaga
            type=Merman Fighter
            name= _ "Heldaga"
            unrenamable=yes
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_QUICK}
            [/modifications]
            {IS_LOYAL}
        [/unit]
        [unit]
            side=1
            x=3
            y=10
            id=Apalala
            type=Merman Hunter
            name= _ "Apalala"
            unrenamable=yes
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_STRONG}
            [/modifications]
            {IS_LOYAL}
        [/unit]
        [unit]
            side=1
            x=3
            y=10
            id=Oceania
            type=Mermaid Initiate
            name= _ "Oceania"
            unrenamable=yes
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_INTELLIGENT}
            [/modifications]
            {IS_LOYAL}
        [/unit]
#ifdef EASY
        [unit]
            side=1
            x=3
            y=10
            id=Elcmar
            type=Merman Fighter
            name= _ "Elcmar"
            unrenamable=yes
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_STRONG}
            [/modifications]
            {IS_LOYAL}
        [/unit]
        [unit]
            side=1
            x=3
            y=10
            id=Aigaion
            type=Merman Fighter
            name= _ "Aigaion"
            unrenamable=yes
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_QUICK}
            [/modifications]
            {IS_LOYAL}
        [/unit]
#else
        [unit]
            side=1
            x=3
            y=10
            id=Tini
            type=Merman Fighter
            name= _ "Tini"
            unrenamable=yes
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
            {IS_LOYAL}
        [/unit]
#endif

        [message]
            speaker=Heldaga
            message= _ "Death to the orcs! Come, my mer brethren, let us fight the orcs and drive them from our shores!"
        [/message]
    [/event]

    [event]
        name=enemies defeated

        [message]
            speaker=Konrad
            message= _ "At last, we have freed the mermen. Go back to the ocean and live in peace."
        [/message]
        [role]
            type=Merman Fighter,Merman Warrior,Merman Triton,Merman Hoplite
            role=ThankfulMerman
        [/role]
        [message]
            role=ThankfulMerman
            message= _ "My lord! You may need the help of some of us who have skill in the sea in future. We would like to come with you and offer you help."
        [/message]
        [message]
            speaker=narrator
            image="wesnoth-icon.png"
            message= _ "You may now recruit the noble merfolk!"
        [/message]
        [allow_recruit]
            type=Merman Fighter,Merman Hunter,Mermaid Initiate
        [/allow_recruit]
        [message]
            speaker=Konrad
            message= _ "Now where is Delfador? I hope he's safe!"
        [/message]
        [unit]
            x=14
            y=40
            id=Delfador
            type=Elder Mage
            side=1
            profile=portraits/delfador.png
            name= _ "Delfador"
            unrenamable=yes
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_INTELLIGENT}
            [/modifications]
            {IS_LOYAL}
        [/unit]
        [message]
            speaker=Delfador
            message= _ "I am perfectly safe, friend!"
        [/message]
        [message]
            speaker=Konrad
            message= _ "There you are! I am so glad you are all right! Now we may have a little rest."
        [/message]
        [message]
            speaker=Delfador
            message= _ "I am afraid there is no time for rest, Konrad. Asheviere has laid siege to Elensefar, breaking the century-old treaty between Wesnoth and the Elense city-state. If the city falls, there is no telling how many other lands she may swallow up!"
        [/message]

        [message]
            speaker=Konrad
            message= _ "Oh no! What shall we do?"
        [/message]

        [message]
            speaker=Delfador
            message= _ "You must lead our men to the city, and help defend it. Or recapture it if it falls before you arrive."
        [/message]

        [message]
            speaker=Konrad
            message= _ "I must do that? But what about you, Delfador? You're coming with me, right?"
        [/message]

        [message]
            speaker=Delfador
            message= _ "I am afraid not, Konrad. I have come across some important documents, and must make haste with them to the Elven Council. It seems that the time to stop Asheviere is shorter than I had thought."
        [/message]

        [message]
            speaker=Konrad
            message= _ "But Delfador! I can't do it on my own!"
        [/message]

        [role]
            type=Elvish Champion,Elvish Marshal,Elvish Captain,Elvish Hero,Knight,Elvish Rider,Elvish Outrider,Paladin,Mage,White Mage,Red Mage,Elvish Fighter,Elvish Archer,Elvish Shaman,Horseman
            role=Supporter
        [/role]
        [message]
            role=Supporter
            message= _ "On your own? My lord! We, your loyal soldiers, will support you!"
        [/message]
        [message]
            speaker=Delfador
            message= _ "You will prevail. I have faith in you. Head north. Elensefar is but three days' travel if you make haste."
        [/message]
        [message]
            speaker=Konrad
            message= _ "Very well. But how do I get there?"
        [/message]
        [message]
            speaker=Delfador
            message= _ "It is north-west of here, a few leagues inland. There are two ways to go, by ship or on foot. Each has its own dangers. You must choose between them."
            [option]
                message= _ "Ships? Ugh! I have been seasick for the last time. We shall walk!"
                [command]
                    [message]
                        speaker=Delfador
                        message= _ "Safe journey to you, Konrad. Until we meet again!"
                    [/message]
                    [kill]
                        id=Delfador
                    [/kill]
                    [endlevel]
                        result=victory
                        next_scenario=05a_Muff_Malals_Peninsula
                        bonus=yes
                        {NEW_GOLD_CARRYOVER 40}
                    [/endlevel]
                [/command]
            [/option]
            [option]
                message= _ "Going by ship we may at least get a little rest for ourselves. By sea it is!"
                [command]
                    [message]
                        speaker=Delfador
                        message= _ "Safe voyage to you then, Konrad. May the weather be fair."
                    [/message]
                    [kill]
                        id=Delfador
                    [/kill]
                    [endlevel]
                        result=victory
                        next_scenario=05b_Isle_of_the_Damned
                        bonus=yes
                        {NEW_GOLD_CARRYOVER 40}
                    [/endlevel]
                [/command]
            [/option]
        [/message]
    [/event]

    [event]
        name=time over

        [unit]
            x=14
            y=40
            id=Delfador
            type=Elder Mage
            side=1
            profile=portraits/delfador.png
            name= _ "Delfador"
            unrenamable=yes
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_INTELLIGENT}
            [/modifications]
            {IS_LOYAL}
        [/unit]

        #if neither of the enemies is dead, automatically lose
        [if]
            [have_unit]
                side=2
                canrecruit=yes
            [/have_unit]

            [have_unit]
                side=3
                canrecruit=yes
            [/have_unit]

            [then]
                [message]
                    speaker=Delfador
                    message= _ "Have you not been able to defeat our foes in all these days? They have summoned reinforcements. Surely now our doom is upon us!"
                [/message]
                [endlevel]
                    result=defeat
                [/endlevel]
            [/then]

            #if we have killed at least one orcish leader, we
            #go on to the next scenario
            [else]
                [message]
                    speaker=Delfador
                    message= _ "Konrad! We cannot spend any more time here. Though it would be good to defeat the orcs and free more of their prisoners, more urgent business calls us!"
                [/message]
                [message]
                    speaker=Konrad
                    message= _ "Delfador, thank goodness you have survived! This has been a tough battle, but why can we not finish it? Why must we leave?"
                [/message]
                [message]
                    speaker=Delfador
                    message= _ "I bear ill tidings. Asheviere has laid siege to Elensefar, breaking the century-old treaty between Wesnoth and the Elense city-state. If the city falls, there is no telling how many other lands she may swallow up!"
                [/message]
                [message]
                    speaker=Konrad
                    message= _ "I must do this? But you are coming with me, aren't you, Delfador?"
                [/message]
                [message]
                    speaker=Delfador
                    message= _ "I am afraid not, Konrad. I have found some important documents that need seeing to. I must ride at once to make council with the elves. I will meet you in Elensefar, after you have secured it."
                [/message]
                [message]
                    speaker=Konrad
                    message= _ "I fear I will struggle to do this on my own... but what must be must be. How do I get to Elensefar?"
                [/message]

                #if we killed the orc at sea, we travel by ship
                #if we killed the orc on land, we travel by land
                [if]
                    [have_unit]
                        side=3
                        canrecruit=yes
                    [/have_unit]
                    [then]
                        [message]
                            speaker=Delfador
                            message= _ "Since you have broken the orcs' hegemony over the seas, going by ship would be safest. Sail along the coast, and you can land mere miles from Elensefar. Make haste!"
                        [/message]
                        [kill]
                            id=Delfador
                        [/kill]
                        [role]
                            type=Merman Fighter,Merman Warrior,Merman Triton,Merman Hoplite
                            role=ThankfulMerman
                        [/role]
                        [message]
                            role=ThankfulMerman
                            message= _ "My lord! You may need the help of some of us who have skill in the sea in future. We would like to come with you and offer you help."
                        [/message]
                        [message]
                            speaker=narrator
                            image="wesnoth-icon.png"
                            message= _ "You may now recruit the noble merfolk!"
                        [/message]
                        [allow_recruit]
                            type=Merman Fighter
                        [/allow_recruit]
                        [endlevel]
                            result=victory
                            bonus=no
                            next_scenario=05b_Isle_of_the_Damned
                            {NEW_GOLD_CARRYOVER 40}
                        [/endlevel]
                    [/then]
                    [else]
                        [message]
                            speaker=Delfador
                            message= _ "With the orcs controlling the seas, going by ship would not be safe. Travel by land, Elensefar is only six days' march up the coast. Make haste!"
                        [/message]
                        [kill]
                            id=Delfador
                        [/kill]
                        [role]
                            type=Merman Fighter,Merman Warrior,Merman Triton,Merman Hoplite
                            role=ThankfulMerman
                        [/role]
                        [message]
                            role=ThankfulMerman
                            message= _ "My lord! You may need the help of some of us who have skill in the sea in future. We would like to come with you and offer you help."
                        [/message]
                        [message]
                            speaker=narrator
                            image="wesnoth-icon.png"
                            message= _ "You may now recruit the noble merfolk!"
                        [/message]
                        [allow_recruit]
                            type=Merman Fighter
                        [/allow_recruit]
                        [endlevel]
                            result=victory
                            bonus=no
                            next_scenario=05a_Muff_Malals_Peninsula
                            {NEW_GOLD_CARRYOVER 40}
                        [/endlevel]
                    [/else]
                [/if]
            [/else]
        [/if]
    [/event]

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