#textdomain wesnoth-ei

[scenario]
    id=02_The_Escape_Tunnel
    name= _ "The Escape Tunnel"
    map_data="{campaigns/Eastern_Invasion/maps/02_The_Escape_Tunnel.map}"
    {TURNS 26 24 22}
    next_scenario=03_An_Unexpected_Appearance
    victory_when_enemies_defeated=no

    {UNDERGROUND}

    {INTRO_AND_SCENARIO_MUSIC the_city_falls.ogg underground.ogg}
    {EXTRA_SCENARIO_MUSIC the_deep_path.ogg}
    {EXTRA_SCENARIO_MUSIC revelation.ogg}

    {EI_TRACK {JOURNEY_02_NEW} }

    # wmllint: validate-off
    [side]
        side=1
        controller=human
        {GOLD 180 140 100}
        team_name=wesnothians
        user_team_name= _ "Wesnothians"
        {FLAG_VARIANT loyalist}

        # wmllint: recognize Gweddry
        {CHARACTER_STATS_GWEDDRY}

        shroud=yes
        fog=yes
    [/side]
    # wmllint: validate-on

    [side]
        side=2
        controller=ai
        recruit=Troll Whelp
        {GOLD 55 70 80}
        {INCOME 2 3 4}
        team_name=monster
        user_team_name= _ "Monsters"

        type=Troll
        id=Kabak
        name= _ "Kabak"
        canrecruit=yes

        [ai]
            aggression=1.0
            grouping=no
            passive_leader=yes
        [/ai]
    [/side]

    [side]
        side=3
        controller=ai
        recruit=Dwarvish Fighter,Dwarvish Thunderer,Dwarvish Scout
        {GOLD 65 50 45}
        {INCOME 6 4 4}
        team_name=wesnothians
        user_team_name= _ "Wesnothians"
        {FLAG_VARIANT knalgan}

        type=Dwarvish Steelclad
        id=Knutan
        name= _ "Knutan"
        canrecruit=yes
        shroud=yes
        fog=yes
        share_vision=none

        [ai]
            grouping=no
            [goal]
                [criteria]
                    side=2
                [/criteria]
                value=100
            [/goal]
            [goal]
                [criteria]
                    side=4
                [/criteria]
                value=1
            [/goal]
        [/ai]
    [/side]

    [side]
        side=4
        controller=null
#ifndef EASY
        recruit=Vampire Bat,Ghost,Skeleton,Ghoul,Revenant
#else
        recruit=Vampire Bat,Ghost,Skeleton,Ghoul
#endif
        {GOLD 140 185 230}
        {INCOME 8 10 12}
        team_name=undead
        user_team_name= _ "Undead"
        {FLAG_VARIANT undead}

        no_leader=yes
        hidden=yes

        village_gold=3
        village_support=2

        [ai]
            recruitment_pattern=fighter,scout
            aggression=0.7
            {NO_SCOUTS}
            [goal]
                [criteria]
                    side=1
                [/criteria]
                value=50
            [/goal]
            [goal]
                [criteria]
                    side=2
                [/criteria]
                value=1
            [/goal]
            [goal]
                [criteria]
                    side=3
                [/criteria]
                value=5
            [/goal]
        [/ai]
    [/side]

    {LIMIT_CONTEMPORANEOUS_RECRUITS 4 Revenant 1}

    # Treasure chest
    {PLACE_IMAGE items/chest.png 35 8}

    # The signpost
    {PLACE_IMAGE scenery/signpost.png 29 10}

    [event]
        name=prestart

        [objectives]
            side=1
            [objective]
                description= _ "Move Gweddry to the tunnel exit"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Gweddry"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Dacyn"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

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

#ifndef HARD
            [note]
                description= _ "Get moving quickly."
            [/note]
#endif
        [/objectives]

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

    [event]
        name=start

        [message]
            speaker=Gweddry
            message= _ "Where are we? I can’t see where we are going."
        [/message]

        [message]
            speaker=Dacyn
            message= _ "This is an old escape route for the outpost. Unfortunately these caves are currently inhabited by trolls, who are blocking our path through the tunnel."
        [/message]

        [scroll_to]
            x,y=15,7
        [/scroll_to]
        [remove_shroud]
            side=1
            x,y=15,7
            radius=1
        [/remove_shroud]
        [delay]
            time=750
        [/delay]

        [scroll_to]
            x,y=22,5
        [/scroll_to]
        [remove_shroud]
            side=1
            x,y=22,5
            radius=1
        [/remove_shroud]
        [delay]
            time=750
        [/delay]

        [scroll_to]
            x,y=28,6
        [/scroll_to]
        [remove_shroud]
            side=1
            x,y=28,6
            radius=1
        [/remove_shroud]
        [delay]
            time=750
        [/delay]

        [scroll_to]
            x,y=34,5
        [/scroll_to]
        [remove_shroud]
            side=1
            x,y=34,5
            radius=1
        [/remove_shroud]
        [delay]
            time=750
        [/delay]

        [message]
            speaker=Dacyn
            message= _ "We must make haste to escape before the undead catch up."
        [/message]

        [message]
            speaker=Gweddry
            message= _ "Wait, before we go anywhere — who were those undead?"
        [/message]

        [message]
            speaker=Dacyn
            message= _ "I will explain later. For now, suffice to say they are much too powerful for us; our only hope is to head north."
        [/message]
    [/event]

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

        [message]
            speaker=unit
            image=scenery/signpost.png
            message= _ "TROL TREZZUR HOLE: KEEP OWT" # wmllint: no spellcheck
        [/message]

        [allow_undo][/allow_undo]
    [/event]

    # Find the dwarves
    [event]
        name=sighted,moveto
        [filter]
            side=3
        [/filter]
        [filter_second]
            side=1
        [/filter_second]

        [remove_shroud]
            side=1
            x,y=8-30,2-10
        [/remove_shroud]
        [remove_shroud]
            side=1
            x,y=31-37,4-11
        [/remove_shroud]
        [remove_shroud]
            side=1
            x,y=37-38,4-5
        [/remove_shroud]
        [modify_side]
            side=3
            share_vision=all
        [/modify_side]

        [message]
            speaker=unit
            message= _ "Who goes there?"
        [/message]

        [message]
            speaker=Gweddry
            message= _ "We are soldiers of the king of Wesnoth. Will you help us fight these trolls?"
        [/message]

        [message]
            speaker=unit
            message= _ "Aye, we’ll help ye, for we have nae love for the trolls. Anyone attacked by them deserves some help, I think."
        [/message]

        [if]
            {VARIABLE_CONDITIONAL undead boolean_equals yes}
            [then]
                [message]
                    speaker=Dacyn
                    # po: shown only if the undead have arrived
                    message= _ "Thank you. Now, I invite you to join us. Undead have followed us into these caves, and they will kill you if you stay behind."
                [/message]
            [/then]
            [else]
                [message]
                    speaker=Dacyn
                    # po: shown if the undead didn't show up yet
                    message= _ "Thank you. Now, I invite you to join us. Undead are in these lands, and they will find these caves."
                [/message]
            [/else]
        [/if]

        [message]
            speaker=unit
            message= _ "My clan ha’ lived in these caves for centuries. We’ll no’ be scattered now by a few undead."
        [/message]

        [message]
            speaker=Dacyn
            message= _ "Very well. The best of luck in your battle. Gweddry, we may be able to avoid the bulk of the trolls by going through the dwarves’ tunnel."
        [/message]
    [/event]

    {HOLY_AMULET 12 2}

    # opening the door to the treasure room
    [event]
        name=moveto
        [filter]
            x=30,32
            y=9,10
        [/filter]

        [sound]
            name=club.ogg
        [/sound]
        [terrain]
            x=31
            y=10
            terrain=^Pw/o
            layer=overlay
        [/terrain]
    [/event]

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

        [sound]
            name=gold.ogg
        [/sound]

        [message]
            speaker=unit
            message= _ "It seems these trolls were hiding some gold. I think I can count fifty gold pieces!"
        [/message]

        [gold]
            side=1
            amount=50
        [/gold]

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

    # Mal-Bakral arrives
    [event]
        name=turn 6

        {VARIABLE undead yes}

        [terrain]
            x=2,3,4,2
            y=4,4,4,5
            terrain=Uu^Ii
        [/terrain]

        [redraw][/redraw]

        {GENERIC_UNIT 4 (Wraith) 2 5}
        {GENERIC_UNIT 4 (Wraith) 4 5}
        {GENERIC_UNIT 4 (Necrophage) 2 4}
        {GENERIC_UNIT 4 (Necrophage) 4 4}

#ifdef HARD
        {GENERIC_UNIT 4 (Bone Shooter) 3 5}
        {GENERIC_UNIT 4 (Bone Shooter) 3 4}
#endif

        [remove_shroud]
            side=1
            x,y=3,3
            radius=1
        [/remove_shroud]
        [lift_fog]
            [filter_side]
                side=1
            [/filter_side]
            x,y=3,3
            radius=1
        [/lift_fog]

        [modify_side]
            side=4
            controller=ai
            hidden=no
        [/modify_side]

        [unit]
            type=Necromancer
            id=Mal-Bakral
            name= _ "Mal-Bakral"
            side=4
            canrecruit=yes
            x,y=3,3
        [/unit]

        {INCIDENTAL_MUSIC knalgan_theme.ogg}

        [message]
            speaker=Mal-Bakral
            message= _ "We have found you, fleshbag! Prepare to die!"
        [/message]

        [message]
            speaker=Dacyn
            message= _ "They follow us... we must escape through this tunnel. That is unfortunate, for it will take us into the Estmark hills, beyond the borders of Wesnoth. But it is our only option."
        [/message]

        [objectives]
            side=1
            silent=yes
            [objective]
                description= _ "Move Gweddry to the tunnel exit"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Gweddry"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Dacyn"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

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

    [event]
        name=moveto
        [filter]
            x,y=39,6
            id=Gweddry
        [/filter]

        [message]
            speaker=Gweddry
            message= _ "We have reached the end of the tunnel. I see daylight above us!"
        [/message]

        {CLEAR_VARIABLE undead}

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

    {EARLY_DEFEAT}

    {HERODEATH_GWEDDRY}
    {HERODEATH_DACYN}
[/scenario]
