# Level 7.1: Dealing with Dwarves

[scenario]
#textdomain wesnoth-utbs

id="7_1_DwarfInterlude"
name= _ "Dealing with Dwarves"
label= _ "Dealing with Dwarves"

{DESERTMAP 7_1DwarfInterlude2}

[music]
name=underground.ogg
[/music]

next_scenario=8_OutoftheFryingPan

#no turn limit for this cutscene
turns=-1

#don't display snapshot of map in saved games
snapshot=no
victory_when_enemies_defeated=no

{UNDERGROUND}

[side]
	side=1
	description=Kaleh
	type=Desert Fighter
	canrecruit=1
	{INCOME -2 -2 -2}
	controller=human
	#recruit=Desert Fighter3, Desert Archer3, Desert Hunter3, Desert Shaman3, Desert Scout3
	shroud=no
	fog=no
	team_name=ally
[/side]

#side=2 Dwarf king
[side]
	description=King Thurongar
	unit_description= _ "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
[/side]


[story]
	[part]
	story= _ "Chapter 7: We returned quickly and found the rest of our people, safely hidden a few miles back from the fighting. Seeing Grendel with us, a troop of dwarves silently appeared out of adjoining secret passages. Once we had assured the rest of the elves that they were friends, Grendel led us silently and quickly through a maze of secret tunnels towards the Dwarves' home."
	[/part]

	[part]
	story= _ "I do not know how long we tramped through those tiny dark passages; time seemed to flow differently down there, deep under the earth. But when we finally got to our destination, what I saw was breathtaking. We entered into a large cavern, where the dwarves had built a huge city out of stone. Protected by stone walls and gates that were bigger than I had ever seen, the place seemed virtually impregnable. As we entered I marveled at their stonework and I saw that the place was crawling with dwarves. It was bigger than any village I had ever seen."
	[/part]

	[part]
	story= _ "The dwarves led us through to the far side of the city, where they let us stay in several auxiliary caverns, which normally served as store rooms. The accommodations were a bit cramped, but for the first time since I had plunged into the earth, I felt safe."
	[/part]

	[part]
	story= _ "The dwarf king was away cleaning up after the recent battle, and would not be back for several days. I happily spent what little time I had learning as much as I could about these strange people. I was very impressed by their craftmanship; they made weapons and armor of a quality I had never seen before. We were also quite the curiosity to the dwarves; I have no idea when they last saw an elf. While some seemed suspicious or frightened of us, the dwarves overall were very polite and met our every need. Finally the summons came to meet with the dwarven king..."
	[/part]

[/story]


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

	#keep cost of units constant from previous scenario
	[if]

		[variable]
		name=scen3
		numerical_equals=2
		[/variable]

		[then]

		#go from 3 to 4

		[disallow_recruit]
			type=Desert Fighter, Desert Archer, Desert Hunter, Desert Shaman, Desert Scout
			side=1
		[/disallow_recruit]

		[disallow_recruit]
			type=Desert Fighter2, Desert Archer2, Desert Hunter2, Desert Shaman2, Desert Scout2
			side=1
		[/disallow_recruit]

		[disallow_recruit]
			type=Desert Fighter3, Desert Archer3, Desert Hunter3, Desert Shaman3, Desert Scout3
			side=1
		[/disallow_recruit]

		[allow_recruit]
			type=Desert Fighter4, Desert Archer4, Desert Hunter4, Desert Shaman4, Desert Scout4
			side=1
		[/allow_recruit]

		[/then]

		[else]

		[if]
			[variable]
			name=scen3
			numerical_equals=1
			[/variable]

			[then]

			#go from 2 to 3

			[disallow_recruit]
				type=Desert Fighter, Desert Archer, Desert Hunter, Desert Shaman, Desert Scout
				side=1
			[/disallow_recruit]

			[disallow_recruit]
				type=Desert Fighter2, Desert Archer2, Desert Hunter2, Desert Shaman2, Desert Scout2
				side=1
			[/disallow_recruit]

			[allow_recruit]
				type=Desert Fighter3, Desert Archer3, Desert Hunter3, Desert Shaman3, Desert Scout3
				side=1
			[/allow_recruit]

			[/then]
		[/if]

		[if]
			[variable]
			name=scen3
			numerical_equals=3
			[/variable]

			[then]

			#go from 4 to 5

			[disallow_recruit]
				type=Desert Fighter, Desert Archer, Desert Hunter, Desert Shaman, Desert Scout
				side=1
			[/disallow_recruit]

			[disallow_recruit]
				type=Desert Fighter2, Desert Archer2, Desert Hunter2, Desert Shaman2, Desert Scout2
				side=1
			[/disallow_recruit]

			[disallow_recruit]
				type=Desert Fighter3, Desert Archer3, Desert Hunter3, Desert Shaman3, Desert Scout3
				side=1
			[/disallow_recruit]

			[disallow_recruit]
				type=Desert Fighter4, Desert Archer4, Desert Hunter4, Desert Shaman4, Desert Scout4
				side=1
			[/disallow_recruit]

			[allow_recruit]
				type=Desert Fighter5, Desert Archer5, Desert Hunter5, Desert Shaman5, Desert Scout5
				side=1
			[/allow_recruit]

			[/then]
		[/if]

		[/else]
	[/if]


	#add furnishings

	{PUT_IMG items/dragonstatue-old.png 8 7}
	{PUT_IMG items/dragonstatue-old.png 12 7}

	#recall heroes
	[recall]
		description=Nym
	[/recall]
	[recall]
		description=Zhul
	[/recall]
	[recall]
		description=Elyssa
	[/recall]

	#recall other dwarves
	[recall]
		description=Rogrimir
	[/recall]

	[recall]
		description=Dwalim
	[/recall]
	[recall]
		description=Moin
	[/recall]
	[recall]
		description=Nordi
	[/recall]
	[recall]
		description=Byorn
	[/recall]
	[recall]
		description=Runin
	[/recall]

	#teleport dwarves to correct locations

	[teleport]
		[filter]
			description=Rogrimir
		[/filter]
		x,y=8,12
	[/teleport]

	[teleport]
		[filter]
			description=Dwalim
		[/filter]
		x,y=12,12
	[/teleport]

	[teleport]
		[filter]
			description=Moin
		[/filter]
		x,y=11,13
	[/teleport]

	[teleport]
		[filter]
			description=Nordi
		[/filter]
		x,y=13,12
	[/teleport]

	[teleport]
		[filter]
			description=Byorn
		[/filter]
		x,y=12,13
	[/teleport]

	[teleport]
		[filter]
			description=Runin
		[/filter]
		x,y=13,13
	[/teleport]


	#teleport heroes to correct locations
	[teleport]
		[filter]
			description=Elyssa
		[/filter]
		x,y=10,11
	[/teleport]

	[teleport]
		[filter]
			description=Nym
		[/filter]
		x,y=9,10
	[/teleport]

	[teleport]
		[filter]
			description=Zhul
		[/filter]
		x,y=11,10
	[/teleport]

	#convert Dwalim, Moin, Nordi, Byorn, and Runin to side 2

	[store_unit]
	[filter]
		description=Dwalim
	[/filter]
	variable=dwarfstats
	[/store_unit]

	[set_variable]
	name=dwarfstats.side
	value=2
	[/set_variable]

	[unstore_unit]
	variable=dwarfstats
	[/unstore_unit]

	[store_unit]
	[filter]
		description=Moin
	[/filter]
	variable=dwarfstats
	[/store_unit]

	[set_variable]
	name=dwarfstats.side
	value=2
	[/set_variable]

	[unstore_unit]
	variable=dwarfstats
	[/unstore_unit]

	[store_unit]
	[filter]
		description=Nordi
	[/filter]
	variable=dwarfstats
	[/store_unit]

	[set_variable]
	name=dwarfstats.side
	value=2
	[/set_variable]

	[unstore_unit]
	variable=dwarfstats
	[/unstore_unit]

	[store_unit]
	[filter]
		description=Byorn
	[/filter]
	variable=dwarfstats
	[/store_unit]

	[set_variable]
	name=dwarfstats.side
	value=2
	[/set_variable]

	[unstore_unit]
	variable=dwarfstats
	[/unstore_unit]

	[store_unit]
	[filter]
		description=Runin
	[/filter]

	variable=dwarfstats
	[/store_unit]

	[set_variable]
	name=dwarfstats.side
	value=2
	[/set_variable]

	[unstore_unit]
	variable=dwarfstats
	[/unstore_unit]

	{CLEAR_VARIABLE dwarfstats}


	#initialize starting variables

	[if]
		[have_unit]
			description=Rogrimir
		[/have_unit]

		[then]

		[set_variable]
			name=dwarf_name
			value=Rogrimir
		[/set_variable]

		[/then]

		[else]

		[set_variable]
			name=dwarf_name
			value=Jarl
		[/set_variable]

		# Jarl's traits are is intentionally inferior to Rogrimir's
		[unit]
		type=Dwarvish Stalwart
		description=Jarl
		user_description= _ "Jarl"
		profile=portraits/rogrimir.png
		x=8
		y=12
		side=1
		[modifications]
			{TRAIT_INTELLIGENT}
			{TRAIT_LOYAL}
		[/modifications]
		[/unit]

		[/else]
	[/if]

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

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

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

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

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

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

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

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

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

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

	[unit]
	type=Dwarvish Dragonguard
	description=Dwarf Guard
	user_description= _ "Dwarf Guard"
	x=14
	y=11
	side=2
	ai_special=guardian
	[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."
[/message]

[message]
	description=King Thurongar
	message= _ "Hail Kaleh, I am Thurongar, King of the Dwarves."
[/message]

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

[message]
	description=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]
	description=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]
	description=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]
	description=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]
	description=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]

[message]
	description=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, $dwarf_name here has volunteered to lead you to the surface."
[/message]

[if]
	[variable]
		name=saw_dwarf_prisoner
		numerical_equals=1
	[/variable]

	[then]

	[message]
		description=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]
		description=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]
	description=$dwarf_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]

[message]
	description=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, $dwarf_name ."
[/message]

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

	[then]

	[message]
		description=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]
		description=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]
		description=Elyssa
	[/have_unit]

	[then]

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

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

	[message]
		description=Elyssa
		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 scepter of fire. Imagine if I could find the dwarves who helped build such an artifact!"
	[/message]

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

	[message]
		description=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]
		description=Kaleh
		message= _ "If your mind is set, then I won't try to convince you. But we will miss you."
	[/message]

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

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

	[message]
		description=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]

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

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

	[message]
		description=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."
	[/message]

	[/then]

	[else]

	[message]
		description=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]
		description=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=continue
	[/endlevel]

	[/else]
[/if]

[/event]

[event]
name=moveto
first_time_only=no

	[filter]
	x=10
	y=10
	[not]
		description=Elyssa
	[/not]
	side=1
	[/filter]


	[message]
	speaker=unit

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

		[command]

			[object]

			[filter]
			x=10
			y=10
			side=1
			[/filter]

			id=FlamingSword
			image=items/flame-sword.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]
		[/command]

		[command]

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

		[command]
			[message]
			description=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]
		[/command]

		[command]
			[message]
			description=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]
		[/command]

		[command]
			[endlevel]
			result=continue
			[/endlevel]
		[/command]

	[/option]

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

	[/message]

[/event]

[/scenario]
