#textdomain wesnoth-httt
[scenario]
    id=03_The_Isle_of_Alduin
    name= _ "The Isle of Alduin"
    map_file=03_The_Isle_of_Alduin.map
    {TURNS 28 25 22}

    {DEFAULT_SCHEDULE_AFTERNOON}

    next_scenario=04_The_Bay_of_Pearls

    {SCENARIO_MUSIC "wanderer.ogg"}
    {EXTRA_SCENARIO_MUSIC "nunc_dimittis.ogg"}
    {EXTRA_SCENARIO_MUSIC "silvan_sanctuary.ogg"}
    {EXTRA_SCENARIO_MUSIC "knolls.ogg"}
    {EXTRA_SCENARIO_MUSIC "heroes_rite.ogg"}
    {EXTRA_SCENARIO_MUSIC "weight_of_revenge.ogg"}

    [event]
        name=prestart
        [objectives]
            side=1
            [objective]
                description= _ "Defeat the enemy leader"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Konrad"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Delfador"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

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

            [note]
                # po: a hint that the player has 3 scenarios before the first main test of their XP management
                description= _ "You’ll need experienced troops at Elensefar."
            [/note]
        [/objectives]
    [/event]

    {HTTT_TRACK {JOURNEY_03_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 130 120 110}
        controller=human
        {FLAG_VARIANT long}
    [/side]

    # wmllint: recognize Delfador

    [side]
        type=Orcish Warrior
        id="Usadar Q'kai"
        name= _ "Usadar Q’kai"
        side=2
        canrecruit=yes
        recruit=Orcish Grunt,Wolf Rider,Orcish Archer,Troll Whelp,Goblin Spearman
        team_name=orcs
        user_team_name=_"Orcs"
        {GOLD 30 40 50}
        [ai]
            recruitment_pattern=scout,scout,fighter,fighter,archer
        [/ai]

        #make the AI a lot more aggressive at night
        [ai]
            time_of_day=dusk,first_watch,second_watch
            aggression=0.75
            caution=0
            grouping=no
        [/ai]
        {FLAG_VARIANT6 ragged}
    [/side]

    #make the orcs start with all the villages
    {STARTING_VILLAGES 2 45}

    #if anyone moves next to the ship, they get a rebuke from Konrad
    [event]
        name=moveto
        [filter]
            side=1
            x=31,31,32
            y=9,10,11
        [/filter]
        [message]
            speaker=Konrad
            {KONRAD_VARIATION_ELF mad}
            message= _ "This is no time to return to our vessel! We must take control of the island!"
        [/message]
        [allow_undo]
        [/allow_undo]
    [/event]

    [event]
        name=prestart

        {PLACE_IMAGE scenery/rock3.png 25 30}

        [disallow_recruit]
            side=1
            type=Mage
        [/disallow_recruit]

        {NEED_DELFADOR (x,y=26,12)}
        [store_unit]
            variable=konrad_store
            kill=yes
            [filter]
                id=Konrad
            [/filter]
        [/store_unit]
        [store_unit]
            variable=delfador_store
            kill=yes
            [filter]
                id=Delfador
            [/filter]
        [/store_unit]
    [/event]

    [event]
        name=start

        #the ship that brought them here

        [sound]
            name=ambient/ship.ogg
        [/sound]

        [move_unit_fake]
            type=Galleon
            side=1
            x=33,32
            y=1,10
        [/move_unit_fake]

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

        #move Konrad out of the ship and onto the keep
        [move_unit_fake]
            type=$konrad_store.type
            side=1
            x=31,26
            y=11,13
        [/move_unit_fake]

        #show Konrad
        [unstore_unit]
            variable=konrad_store
        [/unstore_unit]
        {CLEAR_VARIABLE konrad_store}

        [redraw]
        [/redraw]

        #move Delfador out of the ship and onto the keep
        [move_unit_fake]
            type=$delfador_store.type
            side=1
            x=31,26
            y=11,12
        [/move_unit_fake]

        #show Delfador
        [unstore_unit]
            variable=delfador_store
        [/unstore_unit]
        {CLEAR_VARIABLE delfador_store}

        [redraw]
        [/redraw]

        [message]
            speaker=narrator
            image="wesnoth-icon.png"
            message= _ "And so the party landed on the Isle of Alduin."
        [/message]
        [message]
            speaker=Konrad
            message= _ "So this is Alduin. It looks a little... desolate."
        [/message]
        [message]
            speaker="Usadar Q'kai"
            message= _ "Who is that? Oh, a party of elves has landed. We shall drive them back into the sea!"
        [/message]
        [message]
            speaker=Delfador
            message= _ "If the orcs have come here, their forces at Elensefar must be even more numerous than I feared."
        [/message]
        [message]
            speaker=Delfador
            # po: a hint for players who are expecting campaigns to have a steadily-rising difficulty curve.
            message= _ "Konrad, training is important. If we only have inexperienced troops when we reach Elensefar, then our journey is likely to end in sight of the city’s gates."
        [/message]
        [message]
            speaker=Delfador
            message= _ "This island is the place where I was born, and where I learned magic; it used to be so beautiful. We must recapture it! To arms!"
        [/message]
    [/event]

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

        [unit]
            id=Elrian
            name= _ "Elrian"
            type=Mage
            x=20
            y=9
            side=1
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]

        [message]
            speaker=unit
            message= _ "I found someone hiding in the village!"
        [/message]
        [message]
            speaker=Elrian
            message= _ "My lords, I have been hiding in the village from the orcs, like many of the other magi here. I pledge myself to your service; let us move swiftly to recapture the island!"
        [/message]
        [message]
            speaker=Delfador
            message= _ "Certainly, let us join together to fight the evil ones."
        [/message]
        [message]
            speaker=narrator
            image="wesnoth-icon.png"
            message= _ "You can now recruit magi!"
        [/message]
#ifdef EASY
        [message]
            speaker=Konrad
            {KONRAD_VARIATION_ELF glad}
            message= _ "Surely no orc can stand against us with magi in our ranks! Their magical attacks almost always find their mark, even against well-defended troops."
        [/message]
        [message]
            speaker=Delfador
            {DELFADOR_MENTORING_ELF}
            message= _ "Caution, young prince. It is very difficult to train inexperienced magi in combat. When they fight on the front lines of battle, you must protect magi with stronger units, else the enemy would make short work of them."
        [/message]
#endif
        [allow_recruit]
            side=1
            type=Mage
        [/allow_recruit]

        {VARIABLE received_mages yes}
    [/event]

    [event]
        name=enemies defeated
        [unit]
            x=6
            y=35
            type=Arch Mage
            id=Seimus
            name= _ "Seimus"
            side=1
            [modifications]
                {TRAIT_LOYAL}
            [/modifications]
        [/unit]

        # The guy does not show up on the screen without some help
        [redraw]
        [/redraw]
        [delay]
            time=1250
        [/delay]

        [message]
            speaker=Seimus
            message= _ "Delfador, my old master! You have saved the island from the orcs!"
        [/message]

        [message]
            speaker=Delfador
            message= _ "My apprentice! How did the island fall to such as these?"
        [/message]

        [message]
            speaker=Seimus
            message= _ "You have not heard, master Delfador? Asheviere is trying to control the entire western coast. She hired many orcs and sent them here. They were holding me until a ship could arrive to take me to Weldyn where I am to stand trial for treason for training magi!"
        [/message]

        [message]
            speaker=Delfador
            message= _ "We have come from fighting her forces at Blackwater. Where else has she attacked?"
        [/message]

        [message]
            speaker=Seimus
            message= _ "She has taken control of the Bay of Pearls, long held by the mer, and has turned them into slaves. There they dive for pearls by which she grows richer every day. There are even rumors that she may break the ancient treaty and attack Elensefar!"
        [/message]

        [message]
            speaker=Konrad
            message= _ "Can’t we strike back at her? How many forces does she have at the Bay of Pearls? Can we take it back from her?"
        [/message]

        [message]
            speaker=Delfador
            message= _ "We must indeed go there. Let us therefore rest here a little, and then set sail for the Bay. Hopefully we will defeat her forces there!"
        [/message]

        [if]
            [variable]
                name=received_mages
                not_equals=yes
            [/variable]

            [then]
                [message]
                    speaker=narrator
                    image="wesnoth-icon.png"
                    message= _ "You can now recruit magi!"
                [/message]

#ifdef EASY
                [message]
                    speaker=Konrad
                    {KONRAD_VARIATION_ELF glad}
                    message= _ "Surely no orc can stand against us with magi in our ranks! Their magical attacks almost always find their mark, even against well-defended troops."
                [/message]
                [message]
                    speaker=Delfador
                    {DELFADOR_MENTORING_ELF}
                    message= _ "Caution, young prince. It is very difficult to train inexperienced magi in combat. When they fight on the front lines of battle, you must protect magi with stronger units, else the enemy would make short work of them."
                [/message]
#endif
            [/then]
        [/if]

        [kill]
            id=Seimus
        [/kill]

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

    {campaigns/Heir_To_The_Throne/utils/deaths.cfg}

    [event]
        name=victory

        [allow_recruit]
            side=1
            type=Mage
        [/allow_recruit]

        {CLEAR_VARIABLE received_mages}
    [/event]
[/scenario]
