#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
    {TURNS 60 58 56}

    victory_when_enemies_defeated=no

    {UNDERGROUND}

    #Side=1 elf player
    [side]
        side=1
        id=Kaleh
        type=Quenoth Youth
        canrecruit=yes
        {GOLD 235 190 135}
        {INCOME 8 6 4}
        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=19-26,16-18
                y=30-32,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

            #bats can't go down SW tunnel or go west and attack dwarves
            [avoid]
                x=24-42,33-35
                y=23-50,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]
    [/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 guards avoid weird retreats, has to be modified after guards are defeated
            [avoid]
                x=12-15,22-27
                y=19-22,18-25
            [/avoid]
            # 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

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

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

            {TURNS_RUN_OUT}

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

        {INCREASE_RECRUIT_COSTS 1}

        # Try simulating tentacles preferring Kaleh as a target.
        # No more than 2 tentacles should focus him, the others
        # will choose other victims.
        [micro_ai]
            side=5
            ai_type=simple_attack
            action=add

            [filter_second]
                id=Kaleh
                [not]
                    [filter_adjacent]
                        side=5
                        count=3-6
                    [/filter_adjacent]
                [/not]
            [/filter_second]
        [/micro_ai]

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

        #recall heroes
        [recall]
            id=Nym
        [/recall]

        [recall]
            id=Zhul
        [/recall]

        [recall]
            id=Elyssa
        [/recall]

        #initialize starting variables

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

        {VARIABLE Grog_found no}
        {VARIABLE hermit_trigger no}

        #possible locations for tentacle spawning (27-30 & 13-17 -> 4*5=20)

        [for]
            end=20
            [do]
                [store_locations]
                    x=27-30
                    y=13-17
                    terrain=Ww*, Wo*
                    variable=locs
                [/store_locations]
            [/do]
        [/for]

        # 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
        {NAMED_NOTRAIT_UNIT 3 (Troll Shaman) 33 30 (Zurg) ( _ "Zurg")} {GUARDIAN}

        # 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
                    [effect]
                        apply_to=movement_costs
                        replace=yes
                        [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
                    [effect]
                        apply_to=movement_costs
                        replace=yes
                        [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}

        # create Grog

        [unit]
            type=Troll
            id=Grog
            name= _ "Grog"
            profile=portraits/trolls/troll-hero-alt.png
            x=7
            y=28
            side=3
            unrenamable=yes
            hitpoints=25
            facing=s
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_STRONG}
            [/modifications]
        [/unit]
    [/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 Steelclad) 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) ( _ "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]

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

            [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}
            [sound]
                name=rumble.ogg
            [/sound]

            [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=48,38
                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=47-48,37
                    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]

        # make sure the sergeant is not facing the player's unit
        [modify_unit]
            [filter]
                id=Dwarf Sergeant
            [/filter]
            facing=nw
        [/modify_unit]

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

        [switch]
            variable=unit.race
            [case]
                value=quenoth, elf
                [message]
                    x,y=9,36
                    message= _ "No, it’s an elf!"
                [/message]
                [modify_unit]
                    [filter]
                        id=Dwarf Sergeant
                    [/filter]
                    facing=se
                [/modify_unit]
                [message]
                    id=Dwarf Sergeant
                    message= _ "What...?! Right... First task, boys, kill the intruder!"
                [/message]
            [/case]
            [case]
                value=troll
                [message]
                    x,y=9,36
                    message= _ "I’m too young to die, save me!"
                [/message]
                [modify_unit]
                    [filter]
                        id=Dwarf Sergeant
                    [/filter]
                    facing=se
                [/modify_unit]
                [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]
            [/case]
            [case]
                value=human
                [message]
                    x,y=10,34
                    message= _ "No, it’s a... human?"
                [/message]
                [modify_unit]
                    [filter]
                        id=Dwarf Sergeant
                    [/filter]
                    facing=se
                [/modify_unit]
                [message]
                    speaker=Dwarf Sergeant
                    message= _ "What is a human doing here? Come on, boys, kill the intruder!"
                [/message]
            [/case]
            [case]
                value=monster
                [message]
                    x,y=10,34
                    #po: "it" is referring to the dust devil
                    message= _ "No, it’s a... what is that?"
                [/message]
                [modify_unit]
                    [filter]
                        id=Dwarf Sergeant
                    [/filter]
                    facing=se
                [/modify_unit]
                [message]
                    speaker=Dwarf Sergeant
                    #po: 'earth’s guts' references the underground. What is being talked about is the dust devil.
                    message= _ "What in the earth’s guts is that? Kill it!"
                [/message]
            [/case]
            [else]
                [message]
                    x,y=9,36
                    message= _ "No, look behind you!"
                [/message]
                [modify_unit]
                    [filter]
                        id=Dwarf Sergeant
                    [/filter]
                    facing=se
                [/modify_unit]
                [message]
                    id=Dwarf Sergeant
                    message= _ "What...?! Right... First task, boys, kill the intruder!"
                [/message]
            [/else]
        [/switch]
    [/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)

    # Grog and the Dwarf cannot kill eachother unless dwarf advances (many turns)

    [event]
        name=attack
        first_time_only=no

        [filter]
            id=Grog, Vengeful Dwarf
        [/filter]

        [store_unit]
            [filter]
                id=Grog
            [/filter]
            variable=Grog_var
        [/store_unit]
        [store_unit]
            [filter]
                id=Vengeful Dwarf
            [/filter]
            variable=VDwarf_var
        [/store_unit]
    [/event]

    {FORCE_CHANCE_TO_HIT id="Vengeful Dwarf" id=Grog 0 (
        [variable]
            name=Grog_var.hitpoints
            less_than_equal_to=24
        [/variable]
        [variable]
            name=VDwarf_var.level
            equals=1
        [/variable]
    )}
    {FORCE_CHANCE_TO_HIT id=Grog id="Vengeful Dwarf" 0 (
        [variable]
            name=VDwarf_var.hitpoints
            less_than_equal_to=31
        [/variable]
        [variable]
            name=VDwarf_var.level
            equals=1
        [/variable]
    )}

    # Everytime Grog is attacked, he loses 1 xp and the dwarf loses 2 xp until the fight is found

    [event]
        name=attack end
        first_time_only=no

        [filter]
            id=Vengeful Dwarf, Grog
        [/filter]

        [filter_second]
            id=Grog, Vengeful Dwarf
        [/filter_second]

        [filter_condition]
            [and]
                [variable]
                    name=Grog_found
                    equals=no
                [/variable]
            [/and]
        [/filter_condition]

        [modify_unit]
            [filter]
                id=Grog
            [/filter]
            [effect]
                apply_to=experience
                set=0
            [/effect]
        [/modify_unit]

        [modify_unit]
            [filter]
                id=Vengeful Dwarf
            [/filter]
            [effect]
                apply_to=experience
                set=0
            [/effect]
        [/modify_unit]
    [/event]

    # When Grog is found, the following event triggers.

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

        {CLEAR_VARIABLE Grog_found}

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

        {CHECK_SPEAKER}
        [message]
            speaker=$speaking_unit.id
            message= _ "How did a troll get stuck all the way back here?"
        [/message]
        {CLEAR_VARIABLE speaking_unit}
    [/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]

                [sound]
                    name=explosion.ogg
                [/sound]
                {UTBS_SHAKE_SCREEN}
                [sound]
                    name=rumble.ogg
                [/sound]

                [terrain]
                    x,y=22,30
                    terrain=Xu
                [/terrain]
                {SCROLL_TO 22 30}
                {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]

                [sound]
                    name=explosion.ogg
                [/sound]
                {UTBS_SHAKE_SCREEN}
                [sound]
                    name=rumble.ogg
                [/sound]

                [terrain]
                    x,y=16,31
                    terrain=Xu
                [/terrain]
                {SCROLL_TO 16 31}
                [if]
                    [have_unit]
                        x,y=16,31
                    [/have_unit]
                    [then]
                        [teleport]
                            [filter]
                                x,y=16,31
                            [/filter]
                            x=15
                            y=32
                        [/teleport]
                    [/then]
                [/if]

                {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 Steelclad) 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")}
#ifdef HARD
        {NAMED_GENERIC_UNIT 6 (Dwarvish Explorer) 20 25 () ( _ "Dwarf Guard")}
#else
        {NAMED_GENERIC_UNIT 6 (Dwarvish Pathfinder) 20 25 () ( _ "Dwarf Guard")}
#endif

#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
    [sound]
        name=explosion.ogg
    [/sound]
    {UTBS_SHAKE_SCREEN}
    [sound]
        name=rumble.ogg
    [/sound]

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

        [remove_event]
            id=move_blows_charges
        [/remove_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}

        [remove_event]
            id=death_blows_charges
        [/remove_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 12 16}
            {GOLD 75 110 145}
        [/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]

        {CHECK_SPEAKER}
        [message]
            speaker=$speaking_unit.id
            message= _ "Incoming! Ugh, it’s big, hairy, and nasty. I hate bats, I really hate bats."
        [/message]
        {CLEAR_VARIABLE speaking_unit}
    [/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=enter_hex

        [filter]
            x=27-29,28-29
            y=17,18
            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=yes
        [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]

        {CREATE_TENTACLE}
        {CREATE_TENTACLE}
#ifndef EASY
        {CREATE_TENTACLE}
#endif
#ifdef HARD
        {CREATE_TENTACLE}
#endif

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

                    #once all the tentacles have been killed, locs is no longer needed
                    {CLEAR_VARIABLE locs}

                    [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 10 15 20}
            {GOLD 100 150 200}
        [/modify_side]
        # Delete the avoidance factor
        [modify_ai]
            side=6
            action=delete
            path=aspect[avoid].facet[*]
        [/modify_ai]

        #create dwarven defenders:

        #on EASY difficulty, don't create Dwarvish Pathfinder

#ifdef HARD
        {NAMED_GENERIC_UNIT 6 (Dwarvish Steelclad) 11 10 () ( _ "Dwarf High Guard")}
#else
        {NAMED_GENERIC_UNIT 6 (Dwarvish Fighter) 11 10 () ( _ "Dwarf High Guard")}
#endif
#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 Stalwart) 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]

        [gold]
            amount={ON_DIFFICULTY 80 120 160}
            side=6
        [/gold]
    [/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]

        {CHECK_SPEAKER}
        [message]
            speaker=$speaking_unit.id
            message= _ "And so, at last, it ends."
        [/message]
        {CLEAR_VARIABLE speaking_unit}

        [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 3 (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

    # The two following events are mutually exclusive

    [event]
        name=moveto

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

        [if]
            [variable]
                name=hermit_trigger
                equals=no
            [/variable]
            [then]
                [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]
                {CLEAR_VARIABLE hermit_trigger}
            [/then]
        [/if]
    [/event]

    [event]
        name=attack

        [filter]
            id=Dwarf Hermit
        [/filter]

        [if]
            [variable]
                name=hermit_trigger
                equals=no
            [/variable]
            [then]
                [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]
                {CLEAR_VARIABLE hermit_trigger}
            [/then]
        [/if]
    [/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]

            [remove_event]
                id=door_message
            [/remove_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=Quenoth Sun Sylph,Quenoth Shyde
            [/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]
                label= _ "I fear no ghosts, I’ll take it."
                [command]
                    [remove_event]
                        id=take_belt
                    [/remove_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]
                label= _ "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

        [micro_ai]
            side=5
            ai_type=simple_attack
            action=delete
        [/micro_ai]

        {CLEAR_VARIABLE tentacle_count,Grog_var,VDwarf_var}
    [/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/deaths.cfg}
[/scenario]


#textdomain wesnoth-utbs

[scenario]
    id=07a_Dealing_with_Dwarves
    name= _ "Dealing with Dwarves"

    {UTBS_MAP 07a_Dealing_with_Dwarves.map}

    {STORY_DEALING_WITH_DWARVES}

    {SCENARIO_MUSIC "knalgan_theme.ogg"}

    next_scenario=08_Out_of_the_Frying_Pan
    turns=unlimited
    victory_when_enemies_defeated=no

    {UNDERGROUND}

    [side]
        side=1
        id=Kaleh
        type=Quenoth Youth
        canrecruit=yes
        gold=0
        {NO_INCOME}
        controller=human
        shroud=no
        fog=no
        team_name=ally
        user_team_name= _ "team_name^Quenoth Elves"
        {FLAG_VARIANT long}
    [/side]

    #side=2 Dwarf king
    [side]
        id=King Thurongar
        name= _ "King Thurongar"
        type=Dwarvish Lord
        side=2
        canrecruit=no
        [modifications]
            {TRAIT_INTELLIGENT}
            {TRAIT_RESILIENT}
        [/modifications]
        ai_special=guardian
        gold=0
        income=0
        controller=ai
        shroud=no
        fog=no
        team_name=ally
        user_team_name=_"Allies"
        {FLAG_VARIANT knalgan}
    [/side]

    # Prestart functions:
    # set starting scenario objectives
    # keep cost of recruiting units the same
    # recall main heroes
    # initialize starting variables
    # create starting guards

    [event]
        name=prestart

        # set starting scenario objectives

        [objectives]
            summary= _ "Starting Objectives:"
            [objective]
                description= _ "Choose a unit to take the Fire Blade"
                condition=win
            [/objective]
        [/objectives]

        #add furnishings
        [item]
            image=items/dragonstatue.png
            x,y=8,7
        [/item]

        [item]
            image=items/dragonstatue.png~FL()
            x,y=12,7
        [/item]

        #recall heroes

        [recall]
            id=Nym
            x,y=9,10
        [/recall]

        [recall]
            id=Zhul
            x,y=11,10
        [/recall]

        [recall]
            id=Elyssa
            x,y=10,11
        [/recall]

        #recall other dwarves
        [recall]
            id=Rogrimir
            x,y=8,12
        [/recall]

        [recall]
            id=Dwalim
            x,y=12,12
        [/recall]
        [recall]
            id=Moin
            x,y=11,13
        [/recall]
        [recall]
            id=Nordi
            x,y=13,12
        [/recall]
        [recall]
            id=Byorn
            x,y=12,13
        [/recall]
        [recall]
            id=Runin
            x,y=13,13
        [/recall]

        [modify_unit]
            [filter]
                id=Dwalim,Moin,Nordi,Byorn,Runin
            [/filter]
            side=2
        [/modify_unit]

        #initialize starting variables

        [if]
            [have_unit]
                id=Rogrimir
            [/have_unit]

            [then]
                [set_variable]
                    name=ally_name
                    value=Rogrimir
                [/set_variable]
            [/then]

            [else]
                [set_variable]
                    name=ally_name
                    value=Jarl
                [/set_variable]

                # Jarl's traits are intentionally inferior to Rogrimir's
                [unit]
                    type=Dwarvish Stalwart
                    id=Jarl
                    name= _ "Jarl"
                    profile=portraits/dwarves/fighter-2.png
                    x=8
                    y=12
                    side=1
                    unrenamable=yes
                    [modifications]
                        {TRAIT_LOYAL}
                        {TRAIT_INTELLIGENT}
                    [/modifications]
                [/unit]
            [/else]
        [/if]

        #create starting dwarf guards
        #all have special AI guardian, so that they won't move

        [unit]
            type=Dwarvish Sentinel
            name= _ "Dwarf Guard"
            x=9
            y=14
            side=2
            ai_special=guardian
            facing=se
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]

        [unit]
            type=Dwarvish Sentinel
            name= _ "Dwarf Guard"
            x=11
            y=14
            side=2
            ai_special=guardian
            facing=sw
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_QUICK}
            [/modifications]
        [/unit]

        [unit]
            type=Dwarvish Steelclad
            name= _ "Dwarf Guard"
            x=9
            y=6
            side=2
            ai_special=guardian
            facing=se
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_STRONG}
            [/modifications]
        [/unit]

        [unit]
            type=Dwarvish Steelclad
            name= _ "Dwarf Guard"
            x=11
            y=6
            side=2
            ai_special=guardian
            facing=se
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_INTELLIGENT}
            [/modifications]
        [/unit]

        [unit]
            type=Dwarvish Berserker
            name= _ "Dwarf Guard"
            x=7
            y=8
            side=2
            ai_special=guardian
            facing=se
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_QUICK}
            [/modifications]
        [/unit]

        [unit]
            type=Dwarvish Berserker
            name= _ "Dwarf Guard"
            x=13
            y=8
            side=2
            ai_special=guardian
            facing=sw
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]

        [unit]
            type=Dwarvish Dragonguard
            name= _ "Dwarf Guard"
            x=6
            y=9
            side=2
            ai_special=guardian
            facing=se
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]

        [unit]
            type=Dwarvish Dragonguard
            name= _ "Dwarf Guard"
            x=6
            y=11
            side=2
            ai_special=guardian
            facing=se
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]

        [unit]
            type=Dwarvish Dragonguard
            name= _ "Dwarf Guard"
            x=14
            y=9
            side=2
            ai_special=guardian
            facing=sw
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]

        [unit]
            type=Dwarvish Dragonguard
            name= _ "Dwarf Guard"
            x=14
            y=11
            side=2
            ai_special=guardian
            facing=sw
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]
    [/event]

    # starting dialogue
    [event]
        name=start

        [message]
            speaker=narrator
            message= _ "This chamber is beautifully decorated. Ornate frescoes and dwarven runes cover the walls, and the room is dominated by a large intricately-carved stone throne. Flanking the throne are two detailed statues of some sort of beast you aren’t familiar with. The floor is covered in dark slate, and a path of smooth tiles directs visitors up to a small stone seat which faces the throne."
            image=wesnoth-icon.png
        [/message]

        # wmllint: local spelling Thurongar
        [message]
            speaker=King Thurongar
            message= _ "Hail Kaleh, I am Thurongar, King of the Dwarves."
        [/message]

        [message]
            speaker=Kaleh
            message= _ "I am Kaleh, leader of the Quenoth Elves."
        [/message]

        [message]
            speaker=King Thurongar
            message= _ "I’ve heard of your recent exploits against the troll menace. They’ve been quite a thorn in our side for a while now. They used to be just an occasional pest, but now wherever we go we find another infestation. They’ve been getting smarter with their tactics; we’ve lost several of our outlying settlements to their attacks. Still, we’re not done fighting and with your recent victory perhaps this battle is turning in our favor. But tell me, what are so many elves doing so deep under the earth?"
        [/message]

        [message]
            speaker=Kaleh
            message= _ "It’s a long story, but we come from the south, where we lived in the desert. Our village was destroyed, and I am leading my people on a journey to find a new home. Our god Eloh appeared to me in a vision, and told me to go north, but when we came to the mountains she said I should go under them instead of trying to cross the snowy peaks. So that’s how several thousand of us ended up down here."
        [/message]

        [message]
            speaker=King Thurongar
            message= _ "Interesting. We’d offer to let you live with us, but I’m afraid we don’t have much free space; this city is almost filled to capacity. And looking at you, I don’t think that the under-realm is quite the place for your kind. I think your god may have somewhere else intended for you."
        [/message]

        [message]
            speaker=Kaleh
            message= _ "Indeed, although I admire this great city you have carved from the rock, I think many of my people find these tunnels scary and alien. All we really want to do is to find a way back to the surface on the northern side of the mountains."
        [/message]

        [message]
            speaker=King Thurongar
            message= _ "That I may be able to help you with. We haven’t sent anyone to the surface in years, but we do know of a passage that leads to the ancient northern gate. Several generations ago we used to trade heavily with humans that lived north of the mountains, but then some new human came to power and decreed that all contact with us should be cut off. We sent messengers to find out why, but they never returned."
        [/message]

        [if]
            [variable]
                name=ally_name
                equals=Rogrimir
            [/variable]

            [then]
                [message]
                    speaker=King Thurongar
                    message= _ "But dwarves are excellent delvers, and we keep meticulous maps of all the tunnels we have explored. We should still have maps of the tunnels leading back to the surface. Of course I doubt you would be able to understand them, so, Rogrimir here has volunteered to lead you to the surface."
                [/message]
            [/then]

            [else]
                [message]
                    speaker=King Thurongar
                    message= _ "But dwarves are excellent delvers, and we keep meticulous maps of all the tunnels we have explored. We should still have maps of the tunnels leading back to the surface. Of course I doubt you would be able to understand them, so, Jarl here has volunteered to lead you to the surface."
                [/message]
            [/else]
        [/if]

        [if]
            [variable]
                name=saved_rogrimir
                boolean_equals=yes
            [/variable]

            [then]
                [message]
                    speaker=Rogrimir
                    message= _ "You saved my life and my debt to you is still unpaid. Showing you the way to the surface and protecting you is the least I can do."
                [/message]

                [message]
                    speaker=Jarl
                    message= _ "You rescued my brother, and though he died fighting, he died a warrior’s death instead of a coward’s. For that I thank you. I will take his place and help you get to the surface."
                [/message]
            [/then]

            [else]
                [message]
                    speaker=$ally_name
                    message= _ "You did a great service for my brothers. In exchange, as much as I hate the light, I am the one who knows the upper tunnels the best, so I’ll be your guide."
                [/message]
            [/else]
        [/if]
        {CLEAR_VARIABLE saved_rogrimir}

        [if]
            [variable]
                name=ally_name
                equals=Rogrimir
            [/variable]

            [then]
                [message]
                    speaker=Kaleh
                    message= _ "Thank you very much for your help. We were worried about getting lost in all these twisting tunnels. And we would be honored to have you come with us, Rogrimir."
                [/message]
            [/then]

            [else]
                [message]
                    speaker=Kaleh
                    message= _ "Thank you very much for your help. We were worried about getting lost in all these twisting tunnels. And we would be honored to have you come with us, Jarl."
                [/message]
            [/else]
        [/if]

        [if]
            [have_unit]
                x,y=12-14,12-14
            [/have_unit]

            [then]
                [message]
                    speaker=King Thurongar
                    message= _ "The dwarves who fought by your side have come to pay their respects as well."
                [/message]

                [message]
                    x,y=12-14,12-14
                    message= _ "You helped us strike a huge blow against those savages and it was an honor to fight by your side. You are the bravest elves we have ever known. We’d like to come with you, but, well, we don’t like going that close to the surface, and besides there’s still lots of fighting to be done down here. Don’t you worry, we won’t rest until we have killed every one of trolls."
                [/message]

                [message]
                    speaker=Kaleh
                    message= _ "I understand. Thank you, you were a huge help to us. It was an honor to fight by your side."
                [/message]
            [/then]
        [/if]

        [if]
            [have_unit]
                id=Elyssa
            [/have_unit]

            [then]
                [message]
                    speaker=Elyssa
                    message= _ "I’m afraid, Kaleh, that the time has come for our paths to separate."
                [/message]

                [message]
                    speaker=Kaleh
                    message= _ "What?!"
                [/message]

                [message]
                    speaker=Elyssa
                    #the sceptre of fire always has the 're' writing, this is intentional!
                    message= _ "I have learned a lot about the dwarves in my time here, and yet there’s so much more to learn. Have you seen their forges? They really know how to work fire and use it in amazing ways. They have some interesting ideas about how they might improve their smithing with my magical fire. And have you seen their records? They have kept records of their dealings that go back generations upon generations. They even know of the dwarven clan who helped craft the Sceptre of Fire. Imagine if I could find the dwarves who helped build such an artifact!"
                [/message]

                [message]
                    speaker=Nym
                    message= _ "But we need you! What would we do without you?"
                [/message]

                [message]
                    speaker=Elyssa
                    message= _ "With the help of the dwarves, I think you will do just fine. I don’t know what home your god has planned for you, Kaleh, but I believe in you, and I know that you will find a place for your people. My place is here, with the dwarves. And you don’t really need me, you have each other."
                [/message]

                [message]
                    speaker=Kaleh
                    message= _ "If your mind is set, then I won’t try to convince you. But we will miss you."
                [/message]

                [message]
                    speaker=Zhul
                    message= _ "I thank Eloh for the brief time that she has let you spend with us."
                [/message]

                [message]
                    speaker=Nym
                    message= _ "You take care of yourself, and someday maybe we’ll meet again."
                [/message]

                [message]
                    speaker=Elyssa
                    message= _ "Thank you. And I owe you so much for helping me meet the dwarves. I never would have come down here myself. With some help from the dwarves I have enchanted this fire blade for you. May its flames always light your path, and strike down your enemies. I give this to all of you as a token of my gratitude."
                [/message]

                {PLACE_IMAGE items/flame-sword.png 10 10}

                [message]
                    speaker=Kaleh
                    message= _ "A flaming sword. That’s amazing. I just don’t know who should use it."
                [/message]

                [message]
                    speaker=Elyssa
                    message= _ "I will let you decide; use it in the best way that you see fit."
                [/message]

                [message]
                    speaker=narrator
                    message= _ "You can choose which unit you want to take the flaming sword. If you want another unit to wield the sword, Kaleh can recruit or recall other units."
                    image=wesnoth-icon.png
                [/message]

                # here we store the player’s actual gold and set it to 100 instead,
                # since otherwise they might be unable to recruit or recall due to
                # lack of gold
                [store_side]
                    side=1
                    variable=stored_side_1
                [/store_side]

                [modify_side]
                    side=1
                    gold=100
                [/modify_side]
            [/then]

            [else]
                [message]
                    speaker=King Thurongar
                    message= _ "And now I think you should be off as soon as possible. The trolls have retreated into their holes for the present, but who knows when they will strike again."
                [/message]

                [message]
                    speaker=Nym
                    message= _ "This is a marvelous city, but I for one can’t wait to feel the sun upon my face again and the wind in my hair."
                [/message]

                [endlevel]
                    result=victory
                    carryover_report=no
                    {NEW_GOLD_CARRYOVER 100}
                [/endlevel]
            [/else]
        [/if]
    [/event]

    [event]
        name=moveto
        first_time_only=no

        [filter]
            x=10
            y=10
            [not]
                id=Elyssa
            [/not]
            [not]
                type=Dust Devil
            [/not]
            side=1
        [/filter]

        [message]
            speaker=unit

            message= _ "Should I take this sword?"
            [option]
                label= _ "Yes, I’ll take it."

                [command]
                    [object]
                        [filter]
                            # TODO: decide which units should be able to take it,
                            # or change the item into something else
                            x=10
                            y=10
                            side=1
                        [/filter]

                        id=FlamingSword
                        image=attacks/sword-flaming.png
                        name= _ "Flaming Sword"
                        description= _ "This sword will make all your melee attacks do fire damage."

                        [effect]
                            apply_to=attack
                            range=melee
                            set_type=fire
                            [set_specials]
                                mode=append
                                {WEAPON_SPECIAL_MAGICAL}
                            [/set_specials]
                        [/effect]
                    [/object]

                    [message]
                        speaker=unit
                        message= _ "I will wield this blade proudly, and whenever I look upon it I shall remember you, Elyssa."
                    [/message]

                    [message]
                        speaker=King Thurongar
                        message= _ "And now I think you should be off as soon as possible. The trolls have retreated back into their holes for the present, but who knows when they will strike again."
                    [/message]

                    [message]
                        speaker=Nym
                        message= _ "This is a marvelous city, but I for one can’t wait to feel the sun upon my face again and the wind in my hair."
                    [/message]

                    # let's give the player their actual starting gold back
                    [modify_side]
                        side=1
                        gold=$stored_side_1.gold
                    [/modify_side]

                    {CLEAR_VARIABLE stored_side_1}

                    [endlevel]
                        result=victory
                        carryover_report=no
                        {NEW_GOLD_CARRYOVER 100}
                    [/endlevel]
                [/command]
            [/option]

            [option]
                label= _ "No, I think someone else should wield it."

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


#textdomain wesnoth-utbs

[scenario]
    id=07b_Talking_with_Trolls
    name= _ "Talking with Trolls"

    {UTBS_MAP 07b_Talking_with_Trolls.map}

    {STORY_TALKING_WITH_TROLLS}

    {SCENARIO_MUSIC "northerners.ogg"}

    next_scenario=08_Out_of_the_Frying_Pan
    turns=unlimited
    victory_when_enemies_defeated=no

    {UNDERGROUND}

    [side]
        side=1
        id=Kaleh
        type=Quenoth Youth
        canrecruit=yes
        gold=0
        {NO_INCOME}
        controller=human
        shroud=no
        fog=no
        team_name=ally
        user_team_name= _ "team_name^Quenoth Elves"
        {FLAG_VARIANT long}
    [/side]

    #side=2 Troll Leader
    [side]
        id=Great Leader Darmog
        name= _ "Great Leader Darmog"
        # wmllint: local spelling Darmog
        type=Great Troll
        side=2
        canrecruit=no
        [modifications]
            {TRAIT_INTELLIGENT}
            {TRAIT_STRONG}
        [/modifications]
        ai_special=guardian
        gold=0
        income=0
        controller=ai
        shroud=no
        fog=no
        team_name=ally
        user_team_name=_"Allies"
    [/side]

    # Prestart functions:
    # set starting scenario objectives
    # keep cost of recruiting units the same
    # recall main heroes
    # initialize starting variables
    # create starting guards

    [event]
        name=prestart

        # set starting scenario objectives

        [objectives]
            summary= _ "Starting Objectives:"
            [objective]
                description= _ "Choose a unit to take the Fire Blade"
                condition=win
            [/objective]
        [/objectives]

        #add rubble and other items
        {PLACE_IMAGE scenery/rubble.png 9 9}
        {PLACE_IMAGE scenery/rubble.png 12 9}
        {PLACE_IMAGE scenery/rubble.png 11 7}
        {PLACE_IMAGE scenery/rubble.png 13 10}
        {PLACE_IMAGE scenery/rubble.png 7 12}

        {PLACE_IMAGE scenery/rubble.png 8 7}
        {PLACE_IMAGE scenery/rubble.png 12 7}

        #recall heroes
        [recall]
            id=Nym
            x,y=9,10
        [/recall]

        [recall]
            id=Zhul
            x,y=11,10
        [/recall]

        [recall]
            id=Elyssa
            x,y=10,11
        [/recall]

        #recall other trolls
        [recall]
            id=Grog
            x,y=8,12
        [/recall]

        [recall]
            id="Thu'lok"
            x,y=12,12
        [/recall]
        [recall]
            id=Harpo
            x,y=11,13
        [/recall]
        [recall]
            id=Groucho
            x,y=13,12
        [/recall]
        [recall]
            id=Chico
            x,y=12,13
        [/recall]
        [recall]
            id=Groo
            x,y=13,13
        [/recall]

        [modify_unit]
            [filter]
                id="Thu'lok,Groucho,Harpo,Chico,Groo"
            [/filter]
            side=2
        [/modify_unit]

        #initialize starting variables

        [if]
            [have_unit]
                id=Grog
            [/have_unit]

            [then]
                [set_variable]
                    name=ally_name
                    value=Grog
                [/set_variable]
            [/then]

            [else]
                [set_variable]
                    name=ally_name
                    value=Nog
                [/set_variable]

                # Nog's traits are intentionally inferior to Grog's
                [unit]
                    type=Troll
                    id=Nog
                    name= _ "Nog"
                    profile=portraits/trolls/troll-hero-alt.png
                    x=8
                    y=12
                    side=1
                    unrenamable=yes
                    [modifications]
                        {TRAIT_LOYAL}
                        {TRAIT_QUICK}
                    [/modifications]
                [/unit]
            [/else]
        [/if]

        #create starting dwarf guards
        #all have special AI guardian, so that they won't move

        [unit]
            type=Troll
            name= _ "Troll Guard"
            x=9
            y=14
            side=2
            ai_special=guardian
            facing=se
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]

        [unit]
            type=Troll
            name= _ "Troll Guard"
            x=11
            y=14
            side=2
            ai_special=guardian
            facing=sw
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_QUICK}
            [/modifications]
        [/unit]

        [unit]
            type=Troll Shaman
            id=Spiritual Advisor
            name= _ "Spiritual Advisor"
            x=9
            y=6
            side=2
            ai_special=guardian
            facing=se
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_STRONG}
            [/modifications]
        [/unit]

        [unit]
            type=Troll Shaman
            name= _ "Spiritual Advisor"
            x=11
            y=6
            side=2
            ai_special=guardian
            facing=se
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_INTELLIGENT}
            [/modifications]
        [/unit]

        [unit]
            type=Troll Rocklobber
            name= _ "Troll Guard"
            x=7
            y=8
            side=2
            ai_special=guardian
            facing=se
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_QUICK}
            [/modifications]
        [/unit]

        [unit]
            type=Troll Rocklobber
            name= _ "Troll Guard"
            x=13
            y=8
            side=2
            ai_special=guardian
            facing=sw
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]

        [unit]
            type=Troll Whelp
            name= _ "Troll Guard"
            x=6
            y=9
            side=2
            ai_special=guardian
            facing=se
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]

        [unit]
            type=Troll Whelp
            name= _ "Troll Guard"
            x=6
            y=11
            side=2
            ai_special=guardian
            facing=se
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]

        [unit]
            type=Troll Whelp
            name= _ "Troll Guard"
            x=14
            y=9
            side=2
            ai_special=guardian
            facing=sw
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]

        [unit]
            type=Troll Whelp
            name= _ "Troll Guard"
            x=14
            y=11
            side=2
            ai_special=guardian
            facing=sw
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]
    [/event]

    # starting dialogue
    [event]
        name=start

        [message]
            speaker=narrator
            message= _ "It is clear that this chamber used to be quite ornately decorated, but almost all of it has been destroyed, revealing a stone and dirt floor. What remains is a large stone throne, which has been covered with skulls and animal skins and bright paint. The walls were once covered with frescoes and dwarven runes, but several trolls are busy chipping them off. The floor was once tiled in dark slate, but only two small patches of tiles remain around the two chairs in this chamber. You’re surprised to see that small tile path running up the center of the chamber has been left untouched. It leads to a small stone chair facing the large throne."
            image=wesnoth-icon.png
        [/message]

        [message]
            speaker=Great Leader Darmog
            message= _ "I, Great Leader Darmog, greet you, Kaleh."
        [/message]

        [message]
            speaker=Kaleh
            message= _ "I Kaleh, leader of the Quenoth Elves, thank you for meeting with me."
        [/message]

        [message]
            speaker=Great Leader Darmog
            message= _ "On behalf of all trolls, Darmog thank you for great victory over the dwarves. You have helped drive back the nasty dwarves and given us time to strengthen our defenses. Us trolls not always enemies of dwarves. Until recently we not have much contact with small people. But dwarves invade our tunnels, defile our holy places and kill our women and young. Dwarf not care about anything except gold and pretty gems. The shamans say that the spirits of our kin cry out for vengeance and Darmog will not rest until every dwarf is dead!"
        [/message]

        [message]
            speaker=Spiritual Advisor
            message= _ "But I am curious, we do not know of your kind. We thank you for your help, but who are you and why do you come down here with so many of your people?"
        [/message]

        [message]
            speaker=Kaleh
            message= _ "It’s a long story, but we come from the south, where we lived above ground in the desert. Our village was destroyed, and I am leading my people on a journey to find a new home. Our god Eloh appeared to me in a vision, and told me to go north, but when we came to the mountains she said I should go under them instead of trying to cross the snowy peaks. We do not want to live down here, we are just trying to find a way to the other side of the mountains."
        [/message]

        [message]
            speaker=Great Leader Darmog
            message= _ "Darmog has never been above ground, but Darmog understand your story. A leader must protect and care for his people. Every people deserve to find their own home. If we can help you we will."
        [/message]

        [if]
            [variable]
                name=ally_name
                equals=Grog
            [/variable]

            [then]
                [message]
                    speaker=Spiritual Advisor
                    message= _ "We may be able to help you find a way back to the sunlit lands. In our temples we do keep records of the past. We have not walked above the earth for many many generations, not since the darkness drove us underground. But we are masters of the underground lands, and we have explored many tunnels. Recently one of our scouts found a path that leads north back to the sunlit lands, I think it may be the way you are trying to go. In reward for your achievements, we will help you. Grog has volunteered to protect you and lead you back to the sunlight lands."
                [/message]
            [/then]

            [else]
                [message]
                    speaker=Spiritual Advisor
                    message= _ "We may be able to help you find a way back to the sunlit lands. In our temples we do keep records of the past. We have not walked above the earth for many many generations, not since the darkness drove us underground. But we are masters of the underground lands, and we have explored many tunnels. Recently one of our scouts found a path that leads north back to the sunlit lands, I think it may be the way you are trying to go. In reward for your achievements, we will help you. Nog has volunteered to protect you and lead you back to the sunlight lands."
                [/message]
            [/else]
        [/if]

        [if]
            [variable]
                name=saved_grog
                boolean_equals=yes
            [/variable]

            [then]
                [message]
                    speaker=Grog
                    message= _ "You saved Grog’s life. Grog still owe you a debt of thanks. In return Grog will protect little elves and show them the way back to lighted lands."
                [/message]

                [message]
                    speaker=Nog
                    message= _ "You rescued Nog’s brother, and he died like a warrior in battle, not like a coward in chains. Nog is very grateful. You proved yourselves to be brave strong warriors, and Nog will help you find way back to lighted lands."
                [/message]
            [/then]

            [else]
                [message]
                    speaker=Nog
                    message= _ "You did trolls big service. Nog like to wander in tunnels, and Chief say that he knows the upper tunnels the best. Nog want to help elves so even though he not want to leave battle, he agrees to show elves way back to lighted lands."
                [/message]
            [/else]
        [/if]
        {CLEAR_VARIABLE saved_grog}

        [if]
            [variable]
                name=ally_name
                equals=Grog
            [/variable]

            [then]
                [message]
                    speaker=Kaleh
                    message= _ "Thank you very much for your help. We were worried about getting lost in all these twisting tunnels. And we would be honored to have you come with us, Grog."
                [/message]
            [/then]

            [else]
                [message]
                    speaker=Kaleh
                    message= _ "Thank you very much for your help. We were worried about getting lost in all these twisting tunnels. And we would be honored to have you come with us, Nog."
                [/message]
            [/else]
        [/if]

        [if]
            [have_unit]
                x,y=12-14,12-14
            [/have_unit]

            [then]
                [message]
                    speaker=Great Leader Darmog
                    message= _ "The trolls who fought with you also want to thank you. They tell great tales of your valor."
                [/message]

                [message]
                    x,y=12-14,12-14
                    message= _ "We thank you for all you have done for trolls. You are bravest small people we know. We will tell stories of your battles to all our families so that none will forget. We wish we could come with you and fight more, but Great Leader need us to protect this city. Many dwarves still left, much fighting still to do. Griknagh will protect us, may he watch over you too."
                [/message]

                [message]
                    speaker=Kaleh
                    message= _ "I understand. Thank you, you were a huge help to us. It was an honor to fight by your side."
                [/message]
            [/then]
        [/if]

        [if]
            [have_unit]
                id=Elyssa
            [/have_unit]

            [then]
                [message]
                    speaker=Elyssa
                    message= _ "I’m afraid, Kaleh, that the time has come for our paths to separate."
                [/message]

                [message]
                    speaker=Kaleh
                    message= _ "What?!"
                [/message]

                [message]
                    speaker=Elyssa
                    message= _ "I have learned a lot about the trolls in my time here, and yet there’s so much more to learn. Their magic is amazing. Have you seen their shamans? They make fire with their bare hands. They are very interested in my magic and they have offered to teach me how they create fire. I thought I was one of the last people still practicing magic, who knew I would find trolls still teaching it deep under the earth? There is just so much that I can learn from them, I can’t leave now."
                [/message]

                [message]
                    speaker=Nym
                    message= _ "But we need you! What would we do without you?"
                [/message]

                [message]
                    speaker=Elyssa
                    message= _ "With the help of the trolls, I think you will do just fine. I don’t know what home your god has planned for you, Kaleh, but I believe in you, and I know that you will find a place for your people. My place is here, with the trolls. And you don’t really need me, you have each other."
                [/message]

                [message]
                    speaker=Kaleh
                    message= _ "If your mind is set, then I won’t try to convince you. But we will miss you."
                [/message]

                [message]
                    speaker=Zhul
                    message= _ "I thank Eloh for the brief time that she has let you spend with us."
                [/message]

                [message]
                    speaker=Nym
                    message= _ "You take care of yourself, and someday maybe we’ll meet again."
                [/message]

                [message]
                    speaker=Elyssa
                    message= _ "Thank you. And I owe you so much for helping me discover the trolls. I never would have come down here myself. I found this sword when we were fighting the dwarves and with some help from the trolls I have enchanted this fire blade for you. May its flames always light your path, and strike down your enemies. I give this to all of you as a token of my gratitude."
                [/message]

                {PLACE_IMAGE items/flame-sword.png 10 10}

                [message]
                    speaker=Kaleh
                    message= _ "A flaming sword. That’s amazing. I just don’t know who should use it."
                [/message]

                [message]
                    speaker=Elyssa
                    message= _ "I will let you decide; use it in the best way that you see fit."
                [/message]

                [message]
                    speaker=narrator
                    message= _ "You can choose which unit you want to take the flaming sword. If you want another unit to wield the sword, Kaleh can recruit or recall other units."
                    image=wesnoth-icon.png
                [/message]

                # here we store the player’s actual gold and set it to 100 instead,
                # since otherwise they might be unable to recruit or recall due to
                # lack of gold
                [store_side]
                    side=1
                    variable=stored_side_1
                [/store_side]

                [modify_side]
                    side=1
                    gold=100
                [/modify_side]
            [/then]

            [else]
                [message]
                    speaker=Great Leader Darmog
                    message= _ "And now Darmog think you should be off as soon as possible. The dwarves are sneaky, they retreat today but may attack again tomorrow. The sooner you leave the safer you will be."
                [/message]

                [message]
                    speaker=Nym
                    message= _ "I heartily agree, I for one can’t wait to feel the sun upon my face again and the wind in my hair."
                [/message]

                [endlevel]
                    result=victory
                    carryover_report=no
                    {NEW_GOLD_CARRYOVER 100}
                [/endlevel]
            [/else]
        [/if]
    [/event]

    [event]
        name=moveto
        first_time_only=no

        [filter]
            x=10
            y=10
            [not]
                id=Elyssa
            [/not]
            [not]
                type=Dust Devil
            [/not]
            side=1
        [/filter]

        [message]
            speaker=unit

            message= _ "Should I take this sword?"
            [option]
                label= _ "Yes, I’ll take it."

                [command]
                    [object]
                        [filter]
                            # TODO: decide which units should be able to take it,
                            # or change the item into something else
                            x=10
                            y=10
                            side=1
                        [/filter]

                        id=FlamingSword
                        image=attacks/sword-flaming.png
                        name= _ "Flaming Sword"
                        description= _ "This sword will make all your melee attacks do fire damage."

                        [effect]
                            apply_to=attack
                            range=melee
                            set_type=fire
                        [/effect]
                    [/object]

                    [message]
                        speaker=unit
                        message= _ "I will wield this blade proudly, and whenever I look upon it I shall remember you, Elyssa."
                    [/message]

                    [message]
                        speaker=Great Leader Darmog
                        message= _ "And now Darmog think you should be off as soon as possible. The dwarves are sneaky, they retreat today but may attack again tomorrow. The sooner you leave the safer you will be."
                    [/message]

                    [message]
                        speaker=Nym
                        message= _ "This is a marvelous city, but I for one can’t wait to feel the sun upon my face again and the wind in my hair."
                    [/message]

                    # let's give the player their actual starting gold back
                    [modify_side]
                        side=1
                        gold=$stored_side_1.gold
                    [/modify_side]

                    [endlevel]
                        result=victory
                        carryover_report=no
                        {NEW_GOLD_CARRYOVER 100}
                    [/endlevel]
                [/command]
            [/option]

            [option]
                label= _ "No, I think someone else should wield it."

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