#textdomain wesnoth-ei

[scenario]
    id=04a_An_Elven_Alliance
    name= _ "An Elven Alliance"
    map_data="{campaigns/Eastern_Invasion/maps/04a_An_Elven_Alliance.map}"
    turns=18
    next_scenario=05_Northern_Outpost

    {DEFAULT_SCHEDULE_MORNING}

    {SCENARIO_MUSIC       silvan_sanctuary.ogg}
    {EXTRA_SCENARIO_MUSIC traveling_minstrels.ogg}
    {EXTRA_SCENARIO_MUSIC elvish-theme.ogg}

    {AMBIENT_BIRDS 12 21}
    {AMBIENT_BIRDS 5  14}
    {AMBIENT_BIRDS 33 17}
    {AMBIENT_BIRDS 29 7 }

    [story]
        [part]
            music=elf-land.ogg
            story=_ "But Gweddry and Dacyn were to find no respite within the borders of Wesnoth. They marched out of the foothills of the Estmarks into an unknown forest..."
            {EI_BIGMAP}
        [/part]
    [/story]

    {EI_TRACK {JOURNEY_04A_NEW} }

    # wmllint: validate-off
    [side]
        side=1
        controller=human
        {GOLD 200 150 100}
        team_name=good
        user_team_name= _ "Allies"
        {FLAG_VARIANT loyalist}

        # wmllint: recognize Gweddry
        {CHARACTER_STATS_GWEDDRY}
    [/side]
    # wmllint: validate-on

    [side]
        side=2
        controller=ai
        recruit=Elvish Fighter,Elvish Shaman,Elvish Scout
        {GOLD 140 90 70}
        income=-2
        team_name=good
        user_team_name= _ "Allies"
        {FLAG_VARIANT wood-elvish}

        type=Elvish Ranger
        id=Volas
        name= _ "Volas"
        canrecruit=yes

        [ai]
            passive_leader=yes
        [/ai]
    [/side]

    [side]
        side=3
        controller=ai
#ifdef EASY
        recruit=Troll Whelp,Wolf Rider,Orcish Grunt,Orcish Archer
#else
        recruit=Troll Whelp,Wolf Rider,Orcish Grunt,Orcish Archer,Goblin Pillager
#endif
        {GOLD 180 220 270}
        team_name=orcs
        user_team_name= _ "Orcs"
        {FLAG_VARIANT6 ragged}

        type=Orcish Warrior
        id=Gruga-Har
        name= _ "Gruga-Har"
        canrecruit=yes

        [ai]
            aggression=0.7
            leader_value=5
        [/ai]
    [/side]

    {AI_CONTROLLER () 1 2 ()}

    {STARTING_VILLAGES 2 999}
    {STARTING_VILLAGES 3 3}

#ifndef EASY
    {LIMIT_RECRUITS 3 (Goblin Pillager) 2}
#endif

    # To make Nafga more of a threat.

    {FORCE_CHANCE_TO_HIT (id=Nafga) (side=2) 100 ()}

    [event]
        name=prestart

        [micro_ai]
            side=3
            ai_type=recruit_rushers
            action=add
        [/micro_ai]

        [objectives]
            side=1
            [objective]
                description= _ "Defeat enemy leader"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Gweddry"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Dacyn"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Volas"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

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

            {AI_CONTROLLER_NOTE}
        [/objectives]

        [recall]
            id=Dacyn
        [/recall]
    [/event]

    [event]
        name=start
        #hide Gruga-Har until he arrives
        [hide_unit]
            id=Gruga-Har
        [/hide_unit]

        [message]
            speaker=Volas
            message= _ "Greetings, travelers! Welcome to my realm."
        [/message]

        [message]
            speaker=Gweddry
            message= _ "Would it be possible for us to rest in your lands for a while? We have been pursued by fell undead, although they did not dare follow us into the forest... yet."
        [/message]

        [message]
            speaker=Volas
            message= _ "Certainly."
        [/message]

        [message]
            speaker=Dacyn
            message= _ "Good. Now, you should be warned: this undead warlord is very powerful. If you choose to fight, even if you are victorious, few will survive. I invite you to join us, and head north."
        [/message]

        [message]
            speaker=Volas
            message= _ "I thank you for your offer. But I will not leave my homeland. These undead cannot be as powerful as you say; I will fight them."
        [/message]

        [message]
            speaker=Dacyn
            message= _ "This is not a wise choice, but it is yours to make. If you will not join us, will you at least help us reach the northern outpost? We wish to warn our comrades there."
        [/message]

        [message]
            speaker=Volas
            message= _ "I will aid you. Although, I too, think that yours is the foolish choice. You should stay, and fight."
        [/message]

        [message]
            speaker=Dacyn
            message= _ "After we rest for a short while, we will leave. We have little time to spare."
        [/message]

        #Gruga-Har arrives
        [move_unit_fake]
            type=Orcish Warrior
            side=3
            x=17,17,17
            y=1,2,3
        [/move_unit_fake]

        [unhide_unit][/unhide_unit]

        [message]
            speaker=Gruga-Har
            message= _ "Intruders!"
        [/message]

        [message]
            speaker=Dacyn
            message= _ "What? Orcs! Where did they come from?"
        [/message]

        [message]
            speaker=Volas
            message= _ "I know not. But they have made camp on the northern path. You will have to fight them to move on."
        [/message]

        [message]
            speaker=Gruga-Har
            message= _ "Bring forth the assassins, we may be able to poison them!"
        [/message]

        [move_unit_fake]
#ifdef HARD
            type=Orcish Nightblade
#else
            type=Orcish Slayer
#endif
            side=3
            x=18,18,18
            y=1,2,3
        [/move_unit_fake]

        [unit]
#ifdef HARD
            type=Orcish Nightblade
#else
            type=Orcish Slayer
#endif
            id=Nafga
            name= _ "Nafga"
            side=3
            x,y=18,3
        [/unit]

        [message]
            speaker=Nafga
            # wmllint: local spelling warlordship
            message= _ "Your Warlordship, I am the only assassin left! Do you want me to go poison their leader?"
        [/message]

        [message]
            speaker=Gruga-Har
            message= _ "Perfect! Go, into the forest!"
        [/message]

        [store_unit]
            [filter]
                id=Nafga
            [/filter]
            kill=yes
            variable=nafga_store
        [/store_unit]

        [move_unit_fake]
            type=$nafga_store.type
            side=3
            x=18,18,18,18
            y=3,4,5,6
        [/move_unit_fake]

        [message]
            speaker=Gweddry
            message= _ "They have sent an assassin into the forest. We will have to be careful, and make sure he does not come out and attack us unexpectedly."
        [/message]
    [/event]

    [event]
        name=turn 6

        {VARIABLE nafga_store.x 20}
        {VARIABLE nafga_store.y 16}

        [unstore_unit]
            variable=nafga_store
            find_vacant=yes
        [/unstore_unit]

        {CLEAR_VARIABLE nafga_store}

        [message]
            speaker=Nafga
            message= _ "Hahaha! Nafga will kill the elves!"
        [/message]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Nafga
        [/filter]

        [message]
            speaker=Nafga
            message= _ "No! This is the first time I have failed a mission, and it will be my last!"
        [/message]
    [/event]

    [event]
        name=die
        [filter]
            id=Nafga
        [/filter]

        [message]
            speaker=Gruga-Har
            message= _ "My assassin is dead! The elves must pay, not for his death, but for stopping him in his mission!"
        [/message]

        [gold]
            side=3
            amount=50
        [/gold]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Volas
        [/filter]

        [message]
            speaker=Volas
            message= _ "You have failed me, man of Wesnoth..."
        [/message]
    [/event]

    [event]
        name=die
        [filter]
            id=Volas
        [/filter]

        [endlevel]
            result=defeat
        [/endlevel]
    [/event]

    [event]
        name=enemies defeated

        [message]
            speaker=Volas
            message= _ "We have defeated the orcs! Now you can rest before your journey."
        [/message]

        [message]
            speaker=Dacyn
            message= _ "We have not the time. This battle has wasted too much of it already. We must leave now."
        [/message]

        [message]
            speaker=Volas
            message= _ "Very well. I will send guides to lead you north to your allies."
        [/message]

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

    {FOREIGN_DEFEAT}

    {HERODEATH_GWEDDRY}
    {HERODEATH_DACYN}
[/scenario]
