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

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

    {BIGMAP_02}

    {campaigns/Eastern_Invasion/utils/deaths.cfg}

    [side]
        type=Lieutenant
        id=Gweddry
        name= _ "Gweddry"
        side=1
        canrecruit=yes
        controller=human
        shroud=yes
        team_name=good
        user_team_name=_"Wesnothians"
        {GOLD 200 150 100}
        {FLAG_VARIANT loyalist}
    [/side]

    [side]
        type=Troll
        id=Kabak
        name= _ "Kabak"
        side=2
        canrecruit=yes
        controller=ai
        recruit=Troll Whelp
        {GOLD 60 70 80}
        team_name=monster
        user_team_name=_"Monsters"
    [/side]

    [side]
        type=Dwarvish Steelclad
        id=Knutan
        name= _ "Knutan"
        side=3
        canrecruit=yes
        controller=ai
        recruit=Dwarvish Fighter,Dwarvish Thunderer
        {GOLD 70 60 50}
        team_name=good
        user_team_name=_"Wesnothians"
        [ai]
            grouping=no
            [goal]
                [criteria]
                    side=2
                [/criteria]
                value=100
            [/goal]
            [goal]
                [criteria]
                    side=4
                [/criteria]
                value=1
            [/goal]
        [/ai]
        {FLAG_VARIANT knalgan}
    [/side]

    [side]
        no_leader=yes
        side=4
        controller=null
        hidden=yes
        recruit=Vampire Bat,Ghost
        {GOLD 150 200 250}
        team_name=undead
        user_team_name=_"Undead"
        {FLAG_VARIANT undead}
        [ai]
            {NO_SCOUTS}
        [/ai]
        {FLAG_VARIANT undead}
    [/side]

    [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]
        [/objectives]
    [/event]

    #beginning talking
    [event]
        name=start
        [recall]
            id=Dacyn
        [/recall]
        [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 tunnel for the outpost; unfortunately these caves are currently inhabited by trolls. Now hurry, we have to move quickly; the undead will surely follow us down here."
        [/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]
        [unit]
            type=Troll Whelp
            x,y=32,10
            side=2
        [/unit]
    [/event]

    #the signpost
    [item]
        x=29
        y=10
        image=scenery/signpost.png
    [/item]

    [event]
        name=moveto
        [filter]
            x=29
            y=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_vision]
                side=1
            [/filter_vision]
        [/filter]
        [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
                    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
                    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."
        [/message]
    [/event]

    {PICKUPPABLE_ITEM holy_amulet 12 2 side=1 items/ankh-necklace.png
    _"Wearing this amulet will cause every blow you deal to inflict <i>arcane</i> damage!"
    _"holy amulet^Take it"
    _"holy amulet^Leave it"
    _"I am not suited to using this item! Let another take it." (
        [object]
            name= _ "Holy Amulet"
            image=items/ankh-necklace.png
            duration=forever

            [effect]
                apply_to=attack
                range=melee
                set_type=arcane
            [/effect]
            [effect]
                apply_to=attack
                range=ranged
                set_type=arcane
            [/effect]
        [/object]
    )}

    #treasure chest
    [item]
        x=35
        y=8
        image=items/chest.png
    [/item]

    [event]
        name=moveto
        [filter]
            x=35
            y=8
            side=1
        [/filter]
        [sound]
            name=gold.ogg
        [/sound]
        [message]
            speaker=unit
            message= _ "There is a great fortune in this chest of treasure! I can count two hundred pieces of gold."
        [/message]
        [gold]
            side=1
            amount=200
        [/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 (Revenant) 2 5}
        {GENERIC_UNIT 4 (Revenant) 4 5}
        {GENERIC_UNIT 4 (Revenant) 2 4}
        {GENERIC_UNIT 4 (Revenant) 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=2-4,3
        [/remove_shroud]
        [modify_side]
            side=4
            controller=ai
            hidden=no
        [/modify_side]
        [unit]
            type=Dark Sorcerer
            id=Mal-Bakral
            name= _ "Mal-Bakral"
            side=4
            canrecruit=yes
            x,y=3,3
        [/unit]
        [message]
            speaker=Mal-Bakral
            message= _ "We have found you, fleshbag! Prepare to die!"
        [/message]
        [message]
            speaker=Dacyn
            message= _ "They follow us... we must get out of this tunnel. It looks like it is leading east. That is unfortunate, for it will take us beyond the borders of Wesnoth. But it is our only option."
        [/message]
    [/event]

    [event]
        name=moveto
        [filter]
            x=39
            y=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}
[/scenario]
