#textdomain wesnoth-utbs

[scenario]
    id=06b_In_the_Domain_of_the_Dwarves
    name= _ "In the Domain of the Dwarves"

    {UTBS_MAP 06b_In_the_Domain_of_the_Dwarves.map}

    {STORY_IN_THE_DOMAIN_OF_THE_DWARVES}

    {SCENARIO_MUSIC "knolls.ogg"}

    next_scenario=07b_Talking_with_Trolls
    snapshot="no"
    {TURNS 62 58 56}

    victory_when_enemies_defeated=no

    {UNDERGROUND}

    #Side=1 elf player
    [side]
        side=1
        id=Kaleh
        type=Desert Fighter
        canrecruit=yes
        gold=200
        {INCOME 5 3 1}
        controller=human
        shroud=yes
        fog=no
        team_name=Allies
        user_team_name= _ "team_name^Quenoth Elves"
        {FLAG_VARIANT long}
    [/side]

    #Side=2 dwarf 1 (guarding advance base)
    [side]
        side=2
        color=orange
        no_leader=yes
        gold=0
        income=0
        controller=ai
        shroud=no
        fog=no
        #so that the lake bats won't go after dwarves
        team_name=enemies
        user_team_name=_"Enemies"

        [ai]
            aggression=0.9
            caution=0.1

            #defend advance outpost, don't retreat
            [avoid]
                x,y=19-26,30-32
            [/avoid]

            [avoid]
                x,y=16-18,33-35
            [/avoid]
        [/ai]
        {FLAG_VARIANT knalgan}
    [/side]

    #Side=3 troll 3 (troll allies)
    [side]
        side=3
        no_leader=yes
        gold=0
        income=0
        controller=ai
        shroud=no
        fog=no
        team_name=Allies
        user_team_name=_"Allies"
    [/side]

    #Side=4 vampire bats
    [side]
        side=4
        no_leader=yes
        gold=0
        {NO_INCOME}
        color=white
        controller=ai
        shroud=no
        fog=no
        team_name=enemies
        user_team_name=_"Enemies"

#ifdef EASY
        recruit=Vampire Bat, Blood Bat
#endif

#ifdef NORMAL
        recruit=Vampire Bat, Blood Bat, Dread Bat
#endif

#ifdef HARD
        recruit=Vampire Bat, Blood Bat, Dread Bat
#endif

        [ai]
            aggression=0.8
            caution=0.1

            village_value=0

            recruitment_pattern=scout
            recruitment_ignore_bad_combat=yes

            #bats can't go down SW tunnel
            [avoid]
                x,y=24-42, 23-50
            [/avoid]

            #bats cant go west and attack dwarves
            [avoid]
                x,y=33-35,13-15
            [/avoid]

            passive_leader=yes
        [/ai]
    [/side]

    #Side=5 Secrets & Tentacles
    [side]
        side=5
        no_leader=yes
        gold=0
        income=0
        controller=ai
        shroud=yes
        fog=no
        team_name=enemies
        user_team_name=_"Enemies"
        color=brown

        [ai]
            aggression=0.90
            caution=0.10
        [/ai]
        [goal]
            name=target
            [criteria]
                id=Kaleh
            [/criteria]
            value=20
        [/goal]
    [/side]

    #Side=6 dwarf 2 (main base guards)
    [side]
        side=6
        type=Dwarvish Lord
        id=Dwarf Chieftain
        name= _ "Dwarf Chieftain"
        canrecruit=yes
        color=purple
        x=6
        y=16
        side=6
        [modifications]
            {TRAIT_STRONG}
            {TRAIT_RESILIENT}
        [/modifications]
        gold=0
        # set income extra low to compensate for prestart villages
        income=-20
        controller=ai
        shroud=no
        fog=no
        #so that lake bats won't go after dwarves
        team_name=enemies
        user_team_name=_"Enemies"

#ifdef EASY
        recruit=Dwarvish Fighter, Dwarvish Steelclad, Dwarvish Thunderer, Dwarvish Berserker, Dwarvish Thunderguard, Dwarvish Guardsman, Dwarvish Pathfinder
#endif

#ifdef NORMAL
        recruit=Dwarvish Fighter, Dwarvish Steelclad, Dwarvish Thunderer, Dwarvish Berserker, Dwarvish Thunderguard, Dwarvish Guardsman, Dwarvish Pathfinder, Dwarvish Explorer
#endif

#ifdef HARD
        recruit=Dwarvish Fighter, Dwarvish Steelclad, Dwarvish Thunderer, Dwarvish Berserker, Dwarvish Thunderguard, Dwarvish Guardsman, Dwarvish Dragonguard, Dwarvish Sentinel, Dwarvish Pathfinder, Dwarvish Explorer
#endif

        [ai]
#ifdef EASY
            recruitment_pattern=scout,fighter,mixed fighter,mixed fighter,fighter
#endif

#ifdef NORMAL
            recruitment_pattern=scout,fighter,mixed fighter,mixed fighter,fighter
#endif

#ifdef HARD
            recruitment_pattern=scout,fighter,mixed fighter,mixed fighter,fighter,archer
#endif

            aggression=0.6

            # makes the dwarves group defensively
            grouping=defensive
        [/ai]
        {FLAG_VARIANT knalgan}
    [/side]

#ifdef EASY
    {LIMIT_CONTEMPORANEOUS_RECRUITS 4 "Vampire Bat" 2}
    {LIMIT_CONTEMPORANEOUS_RECRUITS 4 "Blood Bat" 2}
#else
    {LIMIT_CONTEMPORANEOUS_RECRUITS 4 "Dread Bat" 2}
#endif

    {UTBS_INCLUDE utils/dialog-macros.cfg}

    # Prestart functions:
    # set starting scenario objectives
    # increase cost of recruiting units
    # place item images on map
    # recall main heroes
    # initialize starting variables
    # remove keep
    # create elf units
    # create AI=guardian starting units

    [event]
        name=prestart

        #set starting scenario objectives
        [objectives]
            summary= _ "Starting Objectives:"
            [objective]
                description= _ "Kill Dwarf Chieftain"
                condition=win
            [/objective]

            [objective]
                description= _ "Death of Kaleh"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Nym"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Zhul"
                condition=lose
            [/objective]

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

        {INCREASE_RECRUIT_COSTS 1}

        #secret tomb furnishings
        {PLACE_IMAGE items/rune-violet2.png 45 21}
        {PLACE_IMAGE items/coffin-closed.png 49 24}

        #recall heroes
        [unit]
            {NYM}
            placement=leader
        [/unit]

        [unit]
            {ZHUL}
            placement=leader
        [/unit]

        [recall]
            id=Elyssa
        [/recall]

        #initialize starting variables

        [set_variable]
            name=tentacle_count
            value=0
        [/set_variable]

        # Pre-set units

        # Event 2.1
        # Dwarvish sergeant guardian

        [unit]
            type=Dwarvish Steelclad
            id=Dwarf Sergeant
            name= _ "Dwarf Sergeant"
            x=11
            y=36
            side=2
            ai_special=guardian
            facing=nw
            [modifications]
                {TRAIT_RESILIENT}
                {TRAIT_STRONG}
            [/modifications]
        [/unit]

        # Event 2.2
        # Vengeful Dwarf

        [unit]
            type=Dwarvish Fighter
            id=Vengeful Dwarf
            name= _ "Vengeful Dwarf"
            x=7
            y=29
            side=2
            ai_special=guardian
            [modifications]
                {TRAIT_RESILIENT}
                {TRAIT_QUICK}
            [/modifications]
        [/unit]

        #Troll ally shaman, doesn't move
        [unit]
            type=Troll Shaman
            id=Zurg
            name= _ "Zurg"
            x=33
            y=30
            side=3
            ai_special=guardian
            [modifications]
                {TRAIT_STRONG}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]

        # Event 3: Tunnel cave-ins

        [unit]
            type=Dwarvish Stalwart
            id=East Scout
            name= _ "Dwarf Scout"
            x=22
            y=30
            side=6
            ai_special=guardian
            [modifications]
                {TRAIT_STRONG}
                {TRAIT_RESILIENT}
                [object]
                    id=o1
                    silent=yes
                    [effect]
                        apply_to=movement_costs
                        replace=true
                        [movement_costs]
                            cave={UNREACHABLE}
                            flat={UNREACHABLE}
                        [/movement_costs]
                    [/effect]
                [/object]
            [/modifications]
        [/unit]

        [unit]
            type=Dwarvish Stalwart
            id=West Scout
            name= _ "Dwarf Scout"
            x=17
            y=31
            side=6
            ai_special=guardian
            [modifications]
                {TRAIT_STRONG}
                {TRAIT_RESILIENT}
                [object]
                    id=o2
                    silent=yes
                    [effect]
                        apply_to=movement_costs
                        replace=true
                        [movement_costs]
                            cave={UNREACHABLE}
                            flat={UNREACHABLE}
                        [/movement_costs]
                    [/effect]
                [/object]
            [/modifications]
        [/unit]

        #capture dwarf chieftan's villages

        [capture_village]
            x= 6, 8, 9,14,11
            y=11,14,19,16,10
            side=6
        [/capture_village]

        # show where to go at start
        {PLACE_IMAGE items/gohere.png 28 32}
    [/event]

    # starting events

    [event]
        name=start

        # starting dialogue

        [message]
            speaker=Zurg
            message= _ "This amazing tunnel, it leads very close to dwarves’ main lair. You can hear their tiny footsteps just on other side of wall. All that separates us from the dwarves is a thin wall of stone. When you move a unit adjacent to the final wall, on your order Zurg will destroy it with fire magic. Dwarf chieftain is only lightly guarded, he send best warriors to hunt trolls. Heh, we give you easy task. You know dwarf chieftain when you see him, he shorter and uglier than most."
        [/message]

        [message]
            speaker=Zhul
            message= _ "Did you dig these tunnels all by yourselves?"
        [/message]

        [message]
            speaker=Zurg
            message= _ "No, most are tiny dwarf tunnels. We like natural tunnels, big and tall enough for mighty trolls. When the world was young, Griknagh cut many tunnels and caverns into the rock far below us. We traveled deep deep down, following the trickle of ancient streams, far deeper than the puny dwarves. But now we come back up, great leader say there bad things now deep below. Bad for trolls. We come back up to reclaim ancient lands. But we find them filled with many many little stinky dwarves. All the beautiful stones are gone, greedy dwarves take them all. So we fight to reclaim our lands. But Zurg talk too much. We have job to do. Find dwarven leader and kill him and we will reward you well."
        [/message]

        [message]
            speaker=Kaleh
            message= _ "It shall be done."
        [/message]
    [/event]

    # Event 1: Blow up wall, encounter advance dwarf guards

    # when player moves next wall trigger variable
    [event]
        name=moveto

        [filter]
            x,y=28,32
            side=1
        [/filter]

        [message]
            speaker=Zurg
            message= _ "Once you done moving into position, Zurg will destroy wall."
        [/message]

        {REMOVE_IMAGE 28 32}

        # at start of player’s next turn, blow charges and destroy wall
        [event]
            name=new turn

            # Place dwarf guards

            # EASY: 1 dwarf steelclad, 2 thunderer, 3 scouts
            # NORMAL: 1 dwarf steelclad, 2 thunderguard, 3 scouts
            # HARD: 1 dwarf steelclad, 2 thunderguard, 3 pathfinders

            # 1 Dwarf Sergeant
            {NAMED_NOTRAIT_UNIT 2 (Dwarvish Fighter) 22 33 (Advance Sergeant) ( _ "Dwarf Sergeant")}

            # 2 Dwarf shooters
#ifdef EASY
            {NAMED_NOTRAIT_UNIT 2 (Dwarvish Thunderer) 21 34 (Dwarf Guard) ( _ "Dwarf Guard")}
            {NAMED_NOTRAIT_UNIT 2 (Dwarvish Thunderer) 23 34 () ( _ "Dwarf Guard")}
#else
            {NAMED_NOTRAIT_UNIT 2 (Dwarvish Thunderguard) 21 34 () ( _ "Dwarf Guard")}
            {NAMED_NOTRAIT_UNIT 2 (Dwarvish Thunderguard) 23 34 () ( _ "Dwarf Guard")}
#endif

            # 3 dwarf scouts occupy base and villages

#ifdef HARD
            {NAMED_NOTRAIT_UNIT 2 (Dwarvish Pathfinder) 22 34 () ( _ "Dwarf Guard")}
            {NAMED_NOTRAIT_UNIT 2 (Dwarvish Pathfinder) 20 34 () ( _ "Dwarf Guard")}
            {NAMED_NOTRAIT_UNIT 2 (Dwarvish Pathfinder) 24 34 () ( _ "Dwarf Guard")}
#else
            {NAMED_NOTRAIT_UNIT 2 (Dwarvish Scout) 22 34 () ( _ "Dwarf Guard")}
            {NAMED_NOTRAIT_UNIT 2 (Dwarvish Scout) 20 34 () ( _ "Dwarf Guard")}
            {NAMED_NOTRAIT_UNIT 2 (Dwarvish Scout) 24 34 () ( _ "Dwarf Guard")}
#endif

            # Have Zurg cast spell to destroy wall

            [message]
                speaker=Zurg
                message= _ "Fist and fire, crumble stone!"
            [/message]

            # Have screen flash red

            [color_adjust]
                red,green,blue=255,0,0
            [/color_adjust]

            [redraw]
            [/redraw]

            [delay]
                time=100
            [/delay]

            [color_adjust]
                red,green,blue=0,0,0
            [/color_adjust]

            [redraw]
            [/redraw]

            # Have wall shake, then be replaced by dirt, then add rubble

            {UTBS_SHAKE_SCREEN}

            [terrain]
                x=27-28
                y=33
                terrain=Re
            [/terrain]

            {PLACE_IMAGE scenery/rubble.png 27 33}
            {PLACE_IMAGE scenery/rubble.png 28 33}

            # Reveal dwarven cavern
            [remove_shroud]
                x=19-30
                y=32-39
                side=1
            [/remove_shroud]

            [redraw][/redraw]

            # Have Zurg say goodbye

            [message]
                speaker=Zurg
                message= _ "My work here is done. Zurg must report back to Great Leader. Many things to do and dwarves to kill before rest. Zurg return later to see how little elves are doing. Fight well!"
            [/message]

            # Have Zurg leave

            [move_unit]
                id=Zurg
                to_x=39
                to_y=31
            [/move_unit]

            [kill]
                id=Zurg
                animate=no
                fire_event=no
            [/kill]

            [terrain]
                x,y=45,36
                terrain=Xu
            [/terrain]

            {PLACE_IMAGE scenery/rubble.png 44 35}

            # Have dwarf guards talk

            [message]
                speaker=Dwarf Guard
                message= _ "Intruders! Sound the alarm!"
            [/message]

            # If player tries to go back up escape passage
            [event]
                name=moveto

                [filter]
                    x,y=42-44,33-36
                    side=1
                [/filter]

                [message]
                    speaker=unit
                    message= _ "Zurg must have collapsed the tunnel. Perhaps he didn’t want to give the dwarves an easy access route if they defeated us. So much for an escape route, I guess we’ll just have to be sure not to fail."
                [/message]
            [/event]
        [/event]
    [/event]

    # Event 2.1 2.2: Dwarf Sergeant and his Conscripts

    # moveto version, when dwarf sees enemy (sighted version disabled)

    [event]
        name=moveto

        [filter]
            x,y=9-16,35-38
            side=1
        [/filter]

        #[filter]
        #   id=Dwarf Sergeant
        #[/filter]

        #[filter_second]
        #   side=1
        #[/filter_second]

        [remove_shroud]
            side=1
            x=8-14
            y=33-38
        [/remove_shroud]

        # if Hard, add a third Dwarf Conscript

        {NAMED_GENERIC_UNIT 2 (Dwarvish Thunderer) 9 36 (Dwarf Conscript) ( _ "Dwarf Conscript")}
        {NAMED_GENERIC_UNIT 2 (Dwarvish Scout) 10 34 () ( _ "Dwarf Conscript")}

#ifdef HARD
        {NAMED_GENERIC_UNIT 2 (Dwarvish Fighter) 9 35 () ( _ "Dwarf Conscript")}
#endif

        [message]
            speaker=Dwarf Sergeant
            message= _ "Do you know what the first task of any dwarven warrior is, runt?"
        [/message]

        [message]
            x,y=10,34
            message= _ "Sir?"
        [/message]

        [message]
            speaker=Dwarf Sergeant
            message= _ "Constant vigilance, boys; the enemy could be anywhere!"
        [/message]

        [message]
            x,y=9,36
            message= _ "But sir—"
        [/message]

        [message]
            speaker=Dwarf Sergeant
            message= _ "Did I give you permissions to speak? Did I?"
        [/message]

        [message]
            speaker=Dwarf Sergeant
            message= _ "I was killing trolls when you were in swaddling clothes. I wrote the book on killing trolls. And you’re not going anywhere until I’m done with you."
        [/message]

        [message]
            x,y=10,34
            message= _ "But sir, behind you...!"
        [/message]

        [message]
            speaker=Dwarf Sergeant
            message= _ "Oh let me guess, a big nasty troll, right? And when I turn around you flee like the cowards you are. Do you think I’m stupid enough to fall for that one?"
        [/message]

        [if]
            [variable]
                name=unit.race
                equals=elf
            [/variable]
            [then]
                [message]
                    x,y=9,36
                    message= _ "No, it’s an elf!"
                [/message]

                [message]
                    id=Dwarf Sergeant
                    message= _ "What...?! Right... First task, boys, kill the intruder!"
                [/message]
            [/then]
            [else]
                [message]
                    x,y=9,36
                    message= _ "I’m too young to die, save me!"
                [/message]

                [message]
                    speaker=Dwarf Sergeant
                    message= _ "Oh, grow a backbone... Huh? Hey, for once the runt was telling the truth. Come on, boys, kill the intruder!"
                [/message]
            [/else]
        [/if]
    [/event]

    # funny death message from one of the conscripts
    [event]
        name=last breath

        [filter]
            id=Dwarf Conscript
        [/filter]

        [filter_condition]
            [have_unit]
                id=Dwarf Sergeant
            [/have_unit]
        [/filter_condition]

        [message]
            speaker=unit
            message= _ "I love you, Sarge..."
        [/message]
    [/event]

    # Event 2.2: Wounded Troll

    # When player sees Vengeful Dwarf and troll prisoner (sighted version disabled)

    [event]
        name=moveto

        [filter]
            x,y=6-8,28-34
            side=1
        [/filter]

        [remove_shroud]
            side=1
            x=5-9
            y=27-34
        [/remove_shroud]

        [unit]
            type=Troll
            id=Grog
            name= _ "Grog"
            profile=portraits/grog.png
            x=7
            y=28
            side=3
            hitpoints=25
            unrenamable=yes
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_STRONG}
            [/modifications]
            {IS_LOYAL}
        [/unit]

        [message]
            speaker=Vengeful Dwarf
            message= _ "Ha, you’re trapped. I’ve got you right where I want you, and this time no one is gonna save you."
        [/message]

        [message]
            speaker=second_unit
            message= _ "How did a troll get stuck all the way back here?"
        [/message]
    [/event]

    # When Vengeful Dwarf dies
    [event]
        name=die

        [filter]
            id=Vengeful Dwarf
        [/filter]

        [filter_condition]
            [have_unit]
                id=Grog
            [/have_unit]
        [/filter_condition]

        {VARIABLE saved_grog yes}

        [message]
            speaker=Grog
            message= _ "Thank you. Grog got lost and there were so many smelly dwarves. If you hadn’t come Grog would have been killed. Grog owes you his life."
        [/message]

        [modify_unit]
            [filter]
                id=Grog
            [/filter]
            side=1
            moves=5
        [/modify_unit]
    [/event]

    # Event 3: Tunnel cave-ins

    # Eastern tunnel
    [event]
        name=moveto

        [filter]
            x,y=22-24,30-32
            side=1
        [/filter]

        [if]
            [have_location]
                x,y=16,31
                terrain=Xu
                count=0
            [/have_location]

            [then]
                [delay]
                    time=200
                [/delay]

                [message]
                    speaker="East Scout"
                    message= _ "Here they come! Blow the charges!"
                [/message]

                [kill]
                    id="East Scout"
                    animate=no
                [/kill]

                [move_unit_fake]
                    type=Dwarvish Stalwart
                    side=6
                    x=22,21,20,20,20,19,18,18
                    y=30,30,29,28,27,27,26,25
                [/move_unit_fake]

                {UTBS_SHAKE_SCREEN}

                [terrain]
                    x,y=22,30
                    terrain=Xu
                [/terrain]

                {PLACE_IMAGE scenery/rubble.png 21 30}
                {PLACE_IMAGE scenery/rubble.png 23 30}
            [/then]

            [else]
                [message]
                    speaker="East Scout"
                    message= _ "They’re coming this way too! Blow the charges!"
                [/message]

                [redraw]
                [/redraw]

                [delay]
                    time=1000
                [/delay]

                [message]
                    speaker="East Scout"
                    message= _ "What?! Nothing happened! Who rigged the darn charges anyway? I’m going to have to hold them off by myself."
                [/message]
            [/else]
        [/if]
    [/event]

    # Western tunnel

    [event]
        name=moveto

        [filter]
            x,y=15-16,31-34
            side=1
        [/filter]

        [if]
            [have_location]
                x,y=22,30
                terrain=Xu
                count=0
            [/have_location]

            [then]
                [delay]
                    time=200
                [/delay]

                [message]
                    speaker=West Scout
                    message= _ "Here they come! Blow the charges!"
                [/message]

                [kill]
                    id=West Scout
                    animate=no
                [/kill]

                [move_unit_fake]
                    type=Dwarvish Stalwart
                    side=6
                    x=17,18,18,18,18,18,18,18,17,17
                    y=31,30,29,28,27,26,25,24,24,23
                [/move_unit_fake]

                {UTBS_SHAKE_SCREEN}

                [terrain]
                    x,y=16,31
                    terrain=Xu
                [/terrain]

                {PLACE_IMAGE scenery/rubble.png 15 32}
                {PLACE_IMAGE scenery/rubble.png 17 31}
            [/then]

            [else]
                [message]
                    speaker="West Scout"
                    message= _ "They’re coming this way too! Blow the charges!"
                [/message]

                [redraw]
                [/redraw]

                [delay]
                    time=1000
                [/delay]

                [message]
                    speaker="West Scout"
                    message= _ "What?! Nothing happened! Who rigged the darn charges anyway? I’m going to have to hold them off by myself."
                [/message]
            [/else]
        [/if]
    [/event]

    # Event 4: Bridge/Chasm Fight

    # Dwarf guards challenge elves to stand and fight, Jorgi doesn't want
    # to have to resort to trickery

    [event]
        name=moveto

        [filter]
            x=17-21
            y=24-31
            side=1
        [/filter]

        [remove_shroud]
            x=16-23
            y=23-32
            side=1
        [/remove_shroud]

        {NAMED_GENERIC_UNIT 6 (Dwarvish Sentinel) 19 25 (Jorgi) ( _ "Jorgi")}

#ifdef HARD
        {NAMED_GENERIC_UNIT 6 (Dwarvish Steelclad) 18 26 () ( _ "Dwarf Guard")}
        {NAMED_GENERIC_UNIT 6 (Dwarvish Steelclad) 19 27 () ( _ "Dwarf Guard")}
        {NAMED_GENERIC_UNIT 6 (Dwarvish Steelclad) 20 26 () ( _ "Dwarf Guard")}
#else
        {NAMED_GENERIC_UNIT 6 (Dwarvish Fighter) 18 26 () ( _ "Dwarf Guard")}
        {NAMED_GENERIC_UNIT 6 (Dwarvish Fighter) 19 27 () ( _ "Dwarf Guard")}
        {NAMED_GENERIC_UNIT 6 (Dwarvish Fighter) 20 26 () ( _ "Dwarf Guard")}
#endif

        {NAMED_GENERIC_UNIT 6 (Dwarvish Pathfinder) 18 25 () ( _ "Dwarf Guard")}
        {NAMED_GENERIC_UNIT 6 (Dwarvish Pathfinder) 20 25 () ( _ "Dwarf Guard")}

#ifdef EASY
        {NAMED_GENERIC_UNIT 6 (Dwarvish Thunderguard) 19 26 () ( _ "Dwarf Guard")}
#else
        {NAMED_GENERIC_UNIT 6 (Dwarvish Dragonguard) 19 26 () ( _ "Dwarf Guard")}
#endif

        [message]
            speaker=Jorgi
            message= _ "It was a mistake to depend on trickery. We will defeat you fighting face to face. A true dwarf always looks his opponent in the eye when he kills him!"
        [/message]

        [message]
            speaker=Jorgi
            message= _ "So I challenge you, man to man. If you are not cowards, step out onto these bridges and meet your fate!"
        [/message]
    [/event]

    # defines macro to explode backup charges to destroy tunnel leading
    # directly to main dwarf base

#define BACKUP_CHARGES
    {UTBS_SHAKE_SCREEN}

    [terrain]
        x=12,12
        y=19,20
        terrain=Xu
    [/terrain]

    {PLACE_IMAGE scenery/rubble.png 11 19}
    {PLACE_IMAGE scenery/rubble.png 13 21}
#enddef

    # When Jorgi dies, blow charges to destroy tunnel leading to dwarf base

    [event]
        name=last breath
        id=death_blows_charges

        [filter]
            id=Jorgi
        [/filter]

        [message]
            speaker=Jorgi
            message= _ "I couldn’t do it. Blow the backup charges! If we can’t stop them then maybe the black lake will."
        [/message]

        {BACKUP_CHARGES}

        [event]
            id=move_blows_charges
            remove=true
        [/event]
    [/event]

    # if player crosses bridge before killing Jorgi, then blow charges
    # to destroy tunnel leading to dwarf base

    [event]
        name=moveto
        id=move_blows_charges

        [filter]
            x=12-21
            y=19-26
            side=1
        [/filter]

        [message]
            speaker=Jorgi
            message= _ "They’ve crossed the chasm! Blow the backup charges! If we can’t stop them then maybe the black lake will."
        [/message]

        {BACKUP_CHARGES}

        [event]
            id=death_blows_charges
            remove=true
        [/event]
    [/event]

    # Event 5: Vampire Bats

    [event]
        name=moveto

        [filter]
            x=25-34
            y=10-22
            side=1
        [/filter]

        {CHECK_EXPLORER}
        [message]
            speaker=$explorer.id
            message= _ "It’s a huge underground lake. The water looks dark and deep and is cold to the touch. There also seems to be some glowing moss on the walls which illuminates the cavern, making it easier to see."
        [/message]
        {CLEAR_VARIABLE explorer}
    [/event]

    #activate bats and create dwarvish hermit unit

    [event]
        name=moveto

        [filter]
            x=26-28
            y=15-20
            side=1
        [/filter]

        [unit]
            id=Extra Hairy Bat
            name= _ "Extra Hairy Bat"
            type=Dread Bat
            x=42
            y=9
            side=4
            canrecruit=yes
            [modifications]
                {TRAIT_STRONG}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]

        #on easy, don't allow side to recruit dread bats, but create one at start

#ifdef EASY
        [unit]
            type=Dread Bat
            side=4
            x=41
            y=10
            moves=0
        [/unit]
#endif

        [modify_side]
            side=4
            {INCOME 8 10 12}
            {GOLD 90 110 130}
        [/modify_side]

        [unit]
            type=Dwarvish Stalwart
            id=Dwarf Hermit
            name= _ "Dwarf Hermit"
            x=21
            y=6
            side=6
            ai_special=guardian
            [modifications]
                {TRAIT_STRONG}
                {TRAIT_QUICK}
            [/modifications]
        [/unit]

        [capture_village]
            x,y=22,5
            side=6
        [/capture_village]
    [/event]

    # when player sees bats

    [event]
        name=sighted

        [filter]
            type=Vampire Bat,Blood Bat,Dread Bat
        [/filter]

        [filter_second]
            side=1
        [/filter_second]

        [message]
            speaker=second_unit
            message= _ "Incoming! Ugh, it’s big, hairy, and nasty. I hate bats, I really hate bats."
        [/message]
    [/event]

    [event]
        name=last breath

        # wmllint: recognize Big Hairy Bat
        [filter]
            id=Big Hairy Bat
        [/filter]

        [message]
            speaker=unit
            message= _ "Graaawk!" # wmllint: no spellcheck
        [/message]

        {CHECK_SPEAKER}
        [message]
            speaker=$speaking_unit.id
            message= _ "Good riddance."
        [/message]
        {CLEAR_VARIABLE speaking_unit}
    [/event]

    # Event 6: Tentacles attack

    # (2-3 level 1 tentacles appear every turn that player
    # is in 27-30,13-16) Give warning when player reaches edge of ledge

    # tentacles appear at start of player’s turn

    [event]
        name=moveto

        [filter]
            x=27
            y=17
            side=1
        [/filter]

        {CHECK_EXPLORER}

        [message]
            speaker=$explorer.id
            message= _ "The ledge just drops off here. The water might be shallow enough to wade across, but I think I vaguely see something moving underneath the surface. Maybe it’s just fish, but I don’t like the look of it."
        [/message]

        {CLEAR_VARIABLE explorer}
    [/event]

#define CREATE_TENTACLE
    {RANDOM 1..$locs.length}
    {VARIABLE_OP random sub 1}

    [unit]
        type=Tentacle of the Deep
        side=5
        x=$locs[$random].x
        y=$locs[$random].y
        placement=map_passable
        [modifications]
            {TRAIT_STRONG}
            {TRAIT_QUICK}
        [/modifications]
        role=large_tentacles
    [/unit]
#enddef

    # create a bunch of tentacles every time a side 1 unit is in area
    # do this 3 times, then stop

    [event]
        name=new turn
        first_time_only=no

        [filter_condition]
            [have_unit]
                x=27-30
                y=13-17
                side=1
            [/have_unit]
            [variable]
                name=tentacle_count
                less_than=3
            [/variable]
        [/filter_condition]

        [store_locations]
            x=28-31
            y=13-17
            terrain=Ww*, Wo*
            [filter]
            [/filter]
            variable=locs
        [/store_locations]

        {CREATE_TENTACLE}
        {CREATE_TENTACLE}
#ifndef EASY
        {CREATE_TENTACLE}
#endif
        {CLEAR_VARIABLE locs}

        #choose what message to say
        [if]
            [variable]
                name=tentacle_count
                numerical_equals=0
            [/variable]

            [then]
                [message]
                    x,y=24-30,12-20
                    side=1
                    message= _ "What are those?!"
                [/message]
            [/then]

            [else]
                [message]
                    x,y=24-30,12-20
                    side=1
                    message= _ "Here come more of them!"
                [/message]
            [/else]
        [/if]

        [set_variable]
            name=tentacle_count
            add=1
        [/set_variable]

        [if]
            [variable]
                name=tentacle_count
                equals=3
            [/variable]
            [then]
                [event]
                    name=die

                    [filter]
                        type=Tentacle of the Deep
                    [/filter]

                    [filter_condition]
                        [have_unit]
                            role=large_tentacles
                            count=0
                        [/have_unit]
                    [/filter_condition]

                    [message]
                        x,y=21-30,12-19
                        side=1
                        message= _ "The movement under the water has stopped. I think we killed the last of them. Whatever ‘them’ was."
                    [/message]

                    [modify_side]
                        side=4
                        income=2
                    [/modify_side]
                [/event]
            [/then]
        [/if]
    [/event]

    # Event 7: Trigger Dwarf Lord's side

    [event]
        name=moveto

        [filter]
            x=13-22
            y=11-17
            side=1
        [/filter]

        [modify_side]
            side=6
            {INCOME 2 4 6}
            {GOLD 120 140 160}
        [/modify_side]

        #create dwarven defenders:

        #on EASY difficulty, don't create Dwarvish Pathfinder

        {NAMED_GENERIC_UNIT 6 (Dwarvish Fighter) 11 10 () ( _ "Dwarf High Guard")}
#ifndef EASY
        {NAMED_GENERIC_UNIT 6 (Dwarvish Pathfinder) 5 13 () ( _ "Dwarf High Guard")}
#endif
        {NAMED_GENERIC_UNIT 6 (Dwarvish Thunderguard) 7 15 () ( _ "Dwarf High Guard")}
        {NAMED_GENERIC_UNIT 6 (Dwarvish Guardsman) 7 19 () ( _ "Dwarf High Guard")}
    [/event]

    # Event 8: Dwarf Lord sighted event and death event

    [event]
        name=sighted

        [filter]
            id=Dwarf Chieftain
        [/filter]

        [filter_second]
            side=1
        [/filter_second]

        [message]
            speaker=Dwarf Chieftain
            message= _ "So you’ve come at last. Let it end, here and now!"
        [/message]
    [/event]

    [event]
        name=last breath

        [filter]
            id=Dwarf Chieftain
        [/filter]

        [message]
            speaker=Dwarf Chieftain
            message= _ "Faugh! Even in death I curse you! You will never escape these tunnels alive!"
        [/message]

        [message]
            speaker=second_unit
            message= _ "And so, at last, it ends."
        [/message]

        [message]
            side=6
            [not]
                canrecruit=yes
            [/not]
            message= _ "The chieftain has fallen! Flee for your lives!"
        [/message]

        [kill]
            side=6
            animate=no
        [/kill]

        [terrain]
            x=0,1,2,3,4,5,5,6
            y=20,21,21,22,21,21,20,19
            terrain=Uu
        [/terrain]

        [remove_shroud]
            x=2-7
            y=18-22
            side=1
        [/remove_shroud]

        [redraw][/redraw]

        [move_unit_fake]
            type=Troll Shaman
            side=2
            x=1,6
            y=21,19
        [/move_unit_fake]

        {NAMED_NOTRAIT_UNIT 2 (Troll Shaman) 6 19 (Zurg) ( _ "Zurg")}

        [delay]
            time=200
        [/delay]

        [message]
            speaker=Zurg
            message= _ "Little elves fight good. Zurg impressed. With dwarf chieftain dead, cowardly dwarves flee before us. Our struggle not over, still much more fighting, but elf and troll have won this battle. We thank you. Great Leader has allowed you to come speak with him. Great honor, never has one of your kind been allowed in his presence. But he wishes to talk with you and reward you. Please come with me."
        [/message]

        [message]
            speaker=Nym
            message= _ "With their knowledge of all these secret tunnels, you’d think they could have led us straight here instead of making us go through those ‘light defenses’. It would have saved us a lot of unnecessary fighting in actually getting to the dwarf chieftain."
        [/message]

        [message]
            speaker=Zhul
            message= _ "Perhaps they wanted to further test our prowess in battle. And besides, every dwarf we kill is one they don’t have to. Still, I think we caused a bigger distraction than they were expecting."
        [/message]

        [message]
            speaker=Kaleh
            message= _ "Shh, you two. Yes, of course, we would be honored to come and meet the Great Leader. But first, we left many of our people back up near the entrance to the great cave where you first met us and I fear that even now those caves aren’t safe. Can you help us escort my people to safety?"
        [/message]

        [message]
            speaker=Zurg
            message= _ "Hmm, yes, yes we can help. We have a few big caves you little people can stay in, and I get some big trolls to help escort you there. The Great Leader wouldn’t want any unpleasant surprises. Show me where your people are hiding and we will help you move them to our caves."
        [/message]

        [message]
            speaker=Kaleh
            message= _ "I thank you. Come on people, no celebrating yet, we still have work left to do!"
        [/message]

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

    # DWARF EASTER EGG EVENTS

    # Event 19: Hermit Intro and Death events (sighted intro version disabled)

    # Hermit lives alone on island in the lake, guarding his amulet

    [event]
        #name=sighted

        name=moveto

        [filter]
            x,y=18-24,3-8
            side=1
        [/filter]

        [message]
            speaker=Dwarf Hermit
            message= _ "They’ve come for my precious. It’s mine, yes it is. They shan’t have it, no they shan’t. We shall kill them all, yes, yes we will."
        [/message]
    [/event]

    [event]
        name=last breath

        [filter]
            id=Dwarf Hermit
        [/filter]

        [message]
            speaker=Dwarf Hermit
            message= _ "Curse them! We hates them!"
        [/message]

        {CHECK_SPEAKER}
        [message]
            speaker=$speaking_unit.id
            message= _ "What’s this? His clothes were in rags, and yet he had this ancient jeweled amulet hanging around his neck. It contains a huge amethyst that seems to glow faintly with a strange purple light. I wonder where he got such a trinket?"
        [/message]
        {CLEAR_VARIABLE speaking_unit}

        [event]
            name=open_door

            [message]
                speaker=unit
                message= _ "Hey, wait a minute, that amulet glows the same color as this rune. Maybe if I put the amulet on and step into the rune..."
            [/message]

            [color_adjust]
                red,green,blue=246,0,243
            [/color_adjust]

            {UTBS_SHAKE_SCREEN}

            [terrain]
                x,y=46,21
                terrain=Uu
            [/terrain]

            {PLACE_IMAGE scenery/rubble.png 46 21}

            [redraw][/redraw]

            [color_adjust]
                red,green,blue=0,0,0
            [/color_adjust]

            [remove_item]
                x,y=45,21
            [/remove_item]

            [message]
                speaker=unit
                message= _ "Whoa. That was pretty impressive. The amulet stopped glowing and the rune is gone, but what have they revealed?"
            [/message]

            [event]
                id=door_message
                remove=true
            [/event]
        [/event]
    [/event]

    # Event 19.5 baby tentacles attack any unit that tries to walk around
    # the edge of cave (except for flying shyde/star)
    # 2 if easy difficulty, 3 if challenging or hard difficulty

    [event]
        name=moveto

        [filter]
            [not]
                type=Desert Shyde, Desert Star
            [/not]
            x=17-21
            y=8-11
            side=1
        [/filter]

#ifdef HARD
        [unit]
            type=Tentacle of the Deep
            side=5
            x,y=18,10
            [modifications]
                {TRAIT_INTELLIGENT}
                {TRAIT_QUICK}
            [/modifications]
        [/unit]
#endif

        [unit]
            type=Tentacle of the Deep
            id=Smaller Tentacle
            side=5
            x,y=19,9
            [modifications]
                {TRAIT_INTELLIGENT}
                {TRAIT_QUICK}
            [/modifications]
        [/unit]

        [unit]
            type=Tentacle of the Deep
            side=5
            x,y=20,10
            [modifications]
                {TRAIT_INTELLIGENT}
                {TRAIT_QUICK}
            [/modifications]
        [/unit]

        [message]
            speaker=Smaller Tentacle
            message= _ "<i>Splash! Splash!</i>"
        [/message]

        {CHECK_EXPLORER}
        [message]
            speaker=$explorer.id
            message= _ "More tentacles?! What, did that thing have a baby?"
        [/message]
        {CLEAR_VARIABLE explorer}
    [/event]

    # Event 20: Moveto rune statue, open door events

    [event]
        name=moveto

        [filter]
            x,y=45,21
            side=1
            [not]
                type=Dust Devil
            [/not]
        [/filter]

        [message]
            speaker=unit
            message= _ "What in Eloh’s name is this? Someone has carved a glowing purple rune in the floor at the end of this passage. It must be magical. And this passage ends suddenly in a smooth stone wall. This can’t be a coincidence. But the wall seems quite solid. I wonder who carved that rune and why?"
        [/message]

        [fire_event]
            name=open_door
            [primary_unit]
                id=$unit.id
            [/primary_unit]
        [/fire_event]

        [event]
            name=moveto
            first_time_only=no
            id=door_message

            [filter]
                x,y=45,21
                side=1
                [not]
                    type=Dust Devil
                [/not]
            [/filter]

            [message]
                speaker=unit
                message= _ "The rune is still there, glowing mysteriously. I still have no idea why it was put here, but it’s obviously powerful and magical, a combination of things which I am hesitant to mess with."
            [/message]

            [fire_event]
                name=open_door
                [primary_unit]
                    id=$unit.id
                [/primary_unit]
            [/fire_event]
        [/event]
    [/event]

    # Event 21: Ransack Dwarven Tomb

    [event]
        name=moveto
        id=take_belt
        first_time_only=no

        [filter]
            x=49
            y=24
            side=1
            [not]
                type=Dust Devil
            [/not]
        [/filter]

        [message]
            speaker=unit

            message= _ "Based on the runes covering the walls this must be the tomb of some ancient dwarf. The tomb seems empty except for this ornate stone coffin. The skeleton inside the coffin has long since vanished into dust. All that’s left are a few ceremonial trinkets and this shining golden belt. Inscribed on this inside are the words: <i>“May you have the toughness to stay standing long after your enemies fall.”</i> Grave robbing is never a good thing to do, but this belt looks magical and its former owner certainly won’t miss it."
            [option]
                message= _ "I fear no ghosts, I’ll take it."
                [command]
                    [event]
                        id=take_belt
                        remove=true
                    [/event]

                    [message]
                        speaker=unit
                        message= _ "The belt fits perfectly! Somehow I feel stronger and tougher. This is too easy, there seem to have been no traps set upon the coffin. Today’s my lucky day."
                    [/message]

                    [object]
                        [filter]
                            x=49
                            y=24
                            side=1
                        [/filter]

                        id=DwarvenBelt
                        name= _ "Dwarven Belt"
                        description= _ "The maximum hit points of the unit who wears this belt will increase by 12."

                        [effect]
                            apply_to=hitpoints
                            increase_total=12
                        [/effect]
                    [/object]

                    {NAMED_NOTRAIT_UNIT 5 (Ghost) 47 22 (Angry Ghost) ( _ "Angry Ghost")}

                    [message]
                        speaker=Angry Ghost
                        message= _ "You who disturb my rest, come and join me in death!"
                    [/message]

                    [message]
                        speaker=unit
                        message= _ "Then again, maybe I spoke too soon."
                    [/message]
                [/command]
            [/option]

            [option]
                message= _ "On second thought, it’s better to leave the dead in peace."

                [command]
                    [allow_undo]
                    [/allow_undo]
                [/command]
            [/option]
        [/message]
    [/event]

    #at victory, clear variables:
    [event]
        name=victory

        {CLEAR_VARIABLE tentacle_count}
    [/event]

    [event]
        name=time over

        [message]
            speaker=Kaleh
            message= _ "Oh no, we took too long and enemy reinforcements have arrived. We’ll surely be overwhelmed now!"
        [/message]
    [/event]

    {UTBS_INCLUDE utils/kaleh-abilities.cfg}
    {UTBS_INCLUDE utils/deaths.cfg}
[/scenario]
