#textdomain wesnoth-httt
[scenario]
    id=03_The_Isle_of_Alduin
    name= _ "The Isle of Alduin"
    map_data="{campaigns/Heir_To_The_Throne/maps/03_The_Isle_of_Alduin.map}"
    {SCENARIO_MUSIC "wanderer.ogg"}
    {EXTRA_SCENARIO_MUSIC "nunc_dimittis.ogg"}
    {TURNS 34 24 21}

    {AFTERNOON}
    {DUSK}
    {FIRST_WATCH}
    {SECOND_WATCH}
    {DAWN}
    {MORNING}

    next_scenario=04_The_Bay_of_Pearls

    [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]
            [objective]
                description= _ "Turns run out"
                condition=lose
            [/objective]

            note={EARLY_FINISH_BONUS_NOTE}+{NEW_GOLD_CARRYOVER_NOTE_40}
        [/objectives]
    [/event]

    {BIGMAP_ISLE_OF_ALDUIN}

    [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]

    # 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 60 100}
        [ai]
            recruitment_pattern=scout,scout,fighter,fighter,archer
            {ATTACK_DEPTH 1 3 5}
        [/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]
    [/side]

    #make the orcs start with a whole slew of villages
#ifdef EASY
    {STARTING_VILLAGES 2 15}
#endif
#ifdef NORMAL
    {STARTING_VILLAGES 2 30}
#endif
#ifdef HARD
    {STARTING_VILLAGES 2 45}
#endif

    #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
            message= _ "This is no time to return to our vessel! We must take control of the island!"
        [/message]
    [/event]

    [event]
        name=prestart

        # {SCATTER_IMAGE (terrain=Gg) 12 scenery/pine1.png}
        {PLACE_IMAGE scenery/rock3.png 25 30}

        [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
        [move_unit_fake]
            type=Galleon
            side=1
            x=33,33,33,33,33,33,32,32,32,32,31
            y=1,2,3,4,5,6,7,8,9,10,11
        [/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=30,29,28,27,26,26
            y=11,11,11,12,12,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=30,29,28,27,26
            y=11,11,11,12,12
        [/move_unit_fake]

        #set Delfador's position
        {VARIABLE delfador_store.x 26}
        {VARIABLE delfador_store.y 12}

        #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=Delfador
            message= _ "I fear so, Konrad. It seems that the orcs have come even here. Here to the place where I was born, where I was trained."
        [/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= _ "I did not think the orcs would have come here. This island 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]
            {IS_LOYAL}
        [/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
            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
            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 will 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]
            {IS_LOYAL}
        [/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 Mermen, 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
                    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
                    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 will make short work of them."
                [/message]
#endif
                [allow_recruit]
                    side=1
                    type=Mage
                [/allow_recruit]
            [/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}
[/scenario]
