#textdomain wesnoth-httt
[scenario]
    id=04_The_Bay_of_Pearls
    name= _ "The Bay of Pearls"
    map_file=04_The_Bay_of_Pearls.map
    {TURNS 27 24 21}

    {DEFAULT_SCHEDULE}

    next_scenario=05a_Muff_Malals_Peninsula

    {SCENARIO_MUSIC "breaking_the_chains.ogg"}
    {EXTRA_SCENARIO_MUSIC "battle.ogg"}
    {EXTRA_SCENARIO_MUSIC "siege_of_laurelmor.ogg"}
    {EXTRA_SCENARIO_MUSIC "casualties_of_war.ogg"}
    {EXTRA_SCENARIO_MUSIC "weight_of_revenge.ogg"}

    [event]
        name=prestart
        [objectives]
            side=1
            [objective]
                description= _ "Defeat one enemy leader, and resist the other until turns run out"
                condition=win
            [/objective]
            {ALTERNATIVE_OBJECTIVE_BONUS ( _ "Defeat all enemy leaders")}
            [objective]
                description= _ "Death of Konrad"
                condition=lose
            [/objective]
            [objective]
                description= _ "Turns run out with both enemy leaders standing"
                condition=lose
                show_turn_counter=yes
            [/objective]

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

    {HTTT_TRACK {JOURNEY_04_NEW} }

    [side]
        type=Commander
        id=Konrad
        name= _ "Konrad"
        unrenamable=yes
        profile=portraits/konrad-elvish.webp
        side=1
        canrecruit=yes
        team_name=elves
        user_team_name=_"Rebels"
        {GOLD 160 150 140}
        controller=human
        {FLAG_VARIANT long}
    [/side]

    [side]
        type=Orcish Warrior
        id=Dwaba-Kukai
        name= _ "Dwaba-Kukai"
        side=2
        canrecruit=yes
        profile=portraits/orcs/warlord.webp
        recruit=Vampire Bat,Naga Fighter
        [ai]
            recruitment_pattern=scout,fighter
        [/ai]
        team_name=orcs
        user_team_name=_"Orcs"
        {GOLD 30 60 90}
        {FLAG_VARIANT6 ragged}
    [/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}
        team_name=orcs
        user_team_name=_"Orcs"
        {FLAG_VARIANT6 ragged}
    [/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

        [disallow_recruit]
            side=1
            type=Merman Fighter,Merman Hunter,Mermaid Initiate
        [/disallow_recruit]
        #
        # 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-41
            terrain=Ww
        [/terrain]
#endif

        {NEED_DELFADOR placement=leader}

        #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
            random_traits=no
            profile=portraits/orcs/grunt-3.webp
            [modifications]
                {TRAIT_LOYAL}
            [/modifications]
        [/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]
        [/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]
        [/unit]

        {OBJ_TRIDENT_STORM 5 4 bop_stormtrident}

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

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

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

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

        {PLACE_IMAGE_SUBMERGED "units/merfolk/fighter.png~RC(magenta>red)" 3 10}
        {PLACE_IMAGE_SUBMERGED 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]

        {STORE_DELFADOR}
    [/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]
                [scroll_to_unit]
                    id=Bugg
                [/scroll_to_unit]

                [delay]
                    time=250
                [/delay]

                {ADVANCE_UNIT id=Bugg "Sea Orc"}

                [delay]
                    time=250
                [/delay]

                [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

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

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

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

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

    [event]
        name=moveto
        [filter]
            side=1
            x=11
            y=33
        [/filter]

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

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

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

    [event]
        name=moveto
        [filter]
            side=1
            x=7
            y=35
        [/filter]

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

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

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

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

    [event]
        name=moveto
        [filter]
            x=5
            y=38
            side=1
        [/filter]

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

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

#ifdef EASY
        [unit]
            side=1
            x=5
            y=38
            id=Gwarloa
            type=Merman Fighter
            name= _ "Gwarloa"
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
        [/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 merfolk is in the northwest!"
        [/message]
    [/event]

    [event]
        name=moveto
        [filter]
            side=1
            x=3
            y=10
        [/filter]

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

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

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

    [event]
        name=enemies defeated

        [message]
            speaker=Konrad
            {KONRAD_VARIATION_ELF glad}
            message= _ "At last, we have freed the merfolk. Go back to the ocean and live in peace."
        [/message]
#define MERMAN_SPEAKS
    [message]
        type="Merman Triton,Merman Hoplite,Merman Javelineer,Merman Entangler,Mermaid Diviner,Mermaid Siren," +
            "Merman Warrior,Merman Spearman,Merman Netcaster,Mermaid Priestess,Mermaid Enchantress," +
            "Merman Fighter,Merman Hunter,Mermaid Initiate"
        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]
#enddef
        {MERMAN_SPEAKS}
        [message]
            speaker=narrator
            image="wesnoth-icon.png"
            message= _ "You may now recruit the noble merfolk!"
        [/message]
        [allow_recruit]
            side=1
            type=Merman Fighter,Merman Hunter,Mermaid Initiate
        [/allow_recruit]
        [message]
            speaker=Konrad
            message= _ "Now where is Delfador? I hope he’s safe!"
        [/message]

        {RESTORE_DELFADOR}
        {NEED_DELFADOR (x,y=31,11)}

        [message]
            speaker=Delfador
            message= _ "I am perfectly safe, friend!"
        [/message]
        [message]
            speaker=Konrad
            {KONRAD_VARIATION_ELF glad}
            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
            {KONRAD_VARIATION_ELF concerned}
            message= _ "Oh no! What shall we do?"
        [/message]

        [message]
            speaker=Delfador
            message= _ "You must lead your men to the city. 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
            {KONRAD_VARIATION_ELF concerned}
            message= _ "But Delfador! I can’t do it on my own!"
        [/message]

        [message]
            type="Elvish Sylph,Great Mage,"+
                "Elvish Marshal,Elvish Champion,Elvish Avenger,Elvish Sharpshooter,Elvish Shyde,Elvish Enchantress,Elvish Outrider,Paladin,Grand Knight,Mage of Light,Arch Mage,Silver Mage,"+
                "Elvish Captain,Elvish Hero,Elvish Ranger,Elvish Marksman,Elvish Druid,Elvish Sorceress,Elvish Rider,Knight,Lancer,White Mage,Red Mage,"+
                "Elvish Fighter,Elvish Archer,Elvish Shaman,Elvish Scout,Horseman,Mage"
            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= _ "There are two ways to go, by ship or on foot. Each has its own dangers. You must choose between them."
            [option]
                label= _ "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]
                    [endlevel]
                        result=victory
                        next_scenario=05a_Muff_Malals_Peninsula
                        bonus=yes
                        {NEW_GOLD_CARRYOVER 40}
                    [/endlevel]
                [/command]
            [/option]
            [option]
                label= _ "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]
                    [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

        {RESTORE_DELFADOR}
        {NEED_DELFADOR (x,y=31,11)}

        #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
                    {KONRAD_VARIATION_ELF concerned}
                    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, 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
                    {KONRAD_VARIATION_ELF concerned}
                    message= _ "Oh no! What shall we do?"
                [/message]
                [message]
                    speaker=Delfador
                    message= _ "You must lead your men to the city. Help defend it, or recapture it if it falls before you arrive!"
                [/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]
                        [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]
                        [endlevel]
                            result=victory
                            bonus=no
                            next_scenario=05a_Muff_Malals_Peninsula
                            {NEW_GOLD_CARRYOVER 40}
                        [/endlevel]
                    [/else]
                [/if]
                {MERMAN_SPEAKS}
                [message]
                    speaker=narrator
                    image="wesnoth-icon.png"
                    message= _ "You may now recruit the noble merfolk!"
                [/message]
            [/else]
        [/if]
    [/event]

    {campaigns/Heir_To_The_Throne/utils/deaths.cfg}

    [event]
        name=victory

        [allow_recruit]
            side=1
            type=Merman Fighter
        [/allow_recruit]

        {RESTORE_DELFADOR}
    [/event]
[/scenario]

#undef MERMAN_SPEAKS
