[scenario]
	id=06_The_Siege_of_Elensefar
	#textdomain wesnoth-httt
	name= _ "The Siege of Elensefar"
	map_data="{campaigns/Heir_To_The_Throne/maps/06_The_Siege_of_Elensefar.map}"
	{SCENARIO_MUSIC "knolls.ogg"}
	{TURNS 40 32 29}

	{DAWN}
	{MORNING}
	{AFTERNOON}
	{DUSK}
	{FIRST_WATCH}
	{SECOND_WATCH}

	next_scenario=07_Crossroads

	[event]
	name=prestart
		[objectives]
		side=1
			[objective]
				description= _ "Defeat all enemy leaders"
				condition=win
			[/objective]
			[objective]
				description= _ "Death of Konrad"
				condition=lose
			[/objective]
			[objective]
				description= _ "Turns run out"
				condition=lose
			[/objective]
		[/objectives]
	[/event]

	[label]
	x,y=16,28
	text="Elensefar"
	[/label]

	{BIGMAP_SIEGE_OF_ELENSEFAR}

	[side]
	type=Commander
	description=Konrad
	user_description= _ "Konrad"
	unrenamable=yes
	side=1
	canrecruit=1
	controller=human
	recruit=Elvish Scout,Elvish Fighter,Elvish Archer,Horseman,Mage,Elvish Shaman,Merman Fighter
	team_name=elves
#ifdef EASY
	gold=200
#else
	gold=140
#endif
	[/side]

	[side]
	type=Orcish Warlord
	description=Agadla
	user_description= _ "Agadla"
	side=2
	canrecruit=1
	recruit=Orcish Warrior,Orcish Assassin,Orcish Crossbowman

	{GOLD 100 180 240}
	team_name=orcs

		[ai]
		recruitment_pattern=fighter,fighter,archer
		leader_value=10.0
		aggression=0.0
		caution=1.0
		grouping=defensive
		{ATTACK_DEPTH 1 3 5}
		[/ai]

		[ai]
		time_of_day=dusk
		aggression=0.6
		grouping=defensive
		[/ai]
		[ai]
		time_of_day=first_watch,second_watch
		aggression=0.7
		caution=0.25
		grouping=offensive
		[/ai]
	[/side]

	[side]
	type=Dark Sorcerer
	description=Muff Jaanal
	user_description= _ "Muff Jaanal"
	side=3
	canrecruit=1

	recruit=Skeleton Archer,Skeleton

	{GOLD 100 160 220}

	team_name=orcs

		[ai]
		recruitment_pattern=fighter,fighter,archer
		leader_value=10.0
		{ATTACK_DEPTH 1 3 5}
		[/ai]

		[ai]
		time_of_day=dusk,first_watch,second_watch
		aggression=1.0
		grouping=no
		[/ai]
	[/side]

	[time_area]
		x=13-22
		y=1-5
		{UNDERGROUND}
	[/time_area]

	[event]
	name=prestart

	#start the orcs/undead with most of the villages on the map
#ifdef EASY
	{STARTING_VILLAGES 2 5}
	{STARTING_VILLAGES 3 0}
#endif
#ifdef MEDIUM
	{STARTING_VILLAGES 2 10}
	{STARTING_VILLAGES 3 20}
#endif
#ifdef HARD
	{STARTING_VILLAGES 2 10}
	{STARTING_VILLAGES 3 20}
#endif

	[role]
		type=Elvish Champion,Elvish Marshal,Elvish Captain,Elvish Hero,Knight,Elvish Outrider,Elvish Rider,Paladin,Mage,White Mage,Red Mage
		role=Advisor
	[/role]
	[recall]
		role=Advisor
	[/recall]

	[/event]

	[event]
	name=start
		[message]
		speaker=narrator
		image="wesnoth-icon.png"
		message= _ "The party arrived at Elensefar at last, but found that the city had already fallen to the savage orcs."
		[/message]
		[message]
		role=Advisor
		message= _ "My lord! It seems the city has already fallen!"
		[/message]
		[message]
		description=Konrad
		message= _ "This is terrible news! We must retake the city!"
		[/message]
		[message]
		role=Advisor
		message= _ "There are so many of them. This will not be easy! And look to the north! It seems that the undead are allied with the orcs!"
		[/message]
		[message]
		description=Muff Jaanal
		message= _ "Here come the elves! Our newly forged alliance with the orcs will give us the power to crush them with ease!"
		[/message]
		[message]
		role=Konrad
		message= _ "We must take the city, and destroy the evil undead before reinforcements arrive!"
		[/message]
	[/event]

	[event]
	name=turn 4
		[unit]
		description=Reglok
		user_description= _ "Reglok"
		type=Rogue
		side=1
		x=23
		y=40
		gender=male
		[modifications]
			{TRAIT_LOYAL}
			{TRAIT_INTELLIGENT}
		[/modifications]
		[/unit]
		#Make her female
		[store_unit]
		[filter]
			description=Reglok
		[/filter]
		kill=yes
		variable=tempthief
		[/store_unit]

		[set_variable]
		name=tempthief.gender
		value=female
		[/set_variable]

		[move_unit_fake]
			type=$tempthief.type
			x=24,24,23
			y=38,39,40
		[/move_unit_fake]

		[unstore_unit]
		variable=tempthief
		find_vacant=yes
		[/unstore_unit]

		[unit]
		description=Gelgar
		user_description= _ "Gelgar"
		type=Thief
		side=1
		x=22
		y=39
		gender=male
		[modifications]
			{TRAIT_LOYAL}
		[/modifications]
		[/unit]
		[unit]
		description=Gamlel
		user_description= _ "Gamlel"
		type=Thief
		side=1
		x=24
		y=40
		gender=male
		[modifications]
			{TRAIT_LOYAL}
		[/modifications]
		[/unit]

		[redraw]
		[/redraw]
		[delay]
		time=1250
		[/delay]

		[message]
		speaker=narrator
		image="wesnoth-icon.png"
		message= _ "As night began to fall, three dark figures crept out of the forest."
		[/message]
		[message]
		description=Konrad
		message= _ "Halt! Who goes there, friend or foe?"
		[/message]
		[message]
		description=Reglok
		message= _ "Greetings, friend. We are from the Elensefar Thieves' Guild. We would like to help you against the orcs!"
		[/message]
		[message]
		role=Advisor
		message= _ "Thieves, hmmm? Who says we can trust such as you?"
		[/message]
		[message]
		description=Gamlel
		message= _ "We would understand if you didn't trust us, of course, but it is in our mutual interest to rid the city of the orcs!"
		[/message]
		[message]
		description=Konrad
		message= _ "Very well. You may join us."
		[/message]
		[message]
		description=Reglok
		message= _ "We will serve you well, for we respect the help you are providing to our city. You shall find that there is honor, even among thieves."
		[/message]
		[message]
		description=Konrad
		message= _ "Yes, but where is your fighting force? How can you help us?"
		[/message]
		[message]
		description=Gelgar
		message= _ "We survive by stealth. We can help you sneak into the city and surround the orcs. Alternatively, we can lay in wait until you give us a signal then ambush the orcs' rear."
		[/message]
		[message]
		description=Konrad
		message= _ "Hmm... I have to consider this..."
		[option]
		message= _ "Help us infiltrate the city. We can do the rest."
			[command]
			[message]
			description=Reglok
			message= _ "Excellent. Two hours past midnight meet us on the west bank of the river, across from Elensefar's docks."
			[/message]
			[set_variable]
			name=thieves_ford
			value=yes
			[/set_variable]
			[allow_recruit]
			type=Thief
			[/allow_recruit]
			[/command]
		[/option]
		[option]
		message= _ "I want you to reinforce us once we break through their line."
			[command]
			[message]
			description=Reglok
			message= _ "Very well. When you raise your red banner over any building in the city proper, we will see the sign and attack from the city's northern gate."
			[/message]
			[message]
			description=Konrad
			message= _ "Agreed. But, will you be able to see our flag if it's dark?"
			[/message]
			[message]
			description=Reglok
			message= _ "Yes, we will see it. In fact, we prefer to fight at night. I pray you do not lead us into slaughter."
			[/message]
			[message]
			description=Konrad
			message= _ "Do not fear, friends. There will be a slaughter here, but it will be orcish blood staining the streets."
			[/message]
			#
			# Special event - if you chose to have the thieves ambush the orcs,
			# they appear when you capture one of the Elensefar villages
			#
			[event]
			name=moveto
				[filter]
				x=14,15,18,19,13,14,18,20,21
				y=28,30,30,27,24,22,23,23,25
				side=1
				[/filter]
				[message]
				speaker=narrator
				image="wesnoth-icon.png"
				message= _ "As the banner was raised, sounds of fighting could be heard from across the city."
				[/message]

			#create units

				[set_variable]
				name=tempthief.x
				value=16
				[/set_variable]

				[set_variable]
				name=tempthief.y
				value=22
				[/set_variable]

				[unstore_unit]
				variable=tempthief
				find_vacant=yes
				[/unstore_unit]

				{CLEAR_VARIABLE tempthief}

				[unit]
				description=Gelgar
				user_description= _ "Gelgar"
				type=Thief
				side=1
				x=14
				y=22
				gender=male
				[modifications]
					{TRAIT_LOYAL}
				[/modifications]
				[/unit]
				[unit]
				description=Gamlel
				user_description= _ "Gamlel"
				type=Thief
				side=1
				x=20
				y=23
				gender=male
				[modifications]
					{TRAIT_LOYAL}
				[/modifications]
				[/unit]
				[unit]
				description=Darglen
				user_description= _ "Darglen"
				type=Thief
				side=1
				x=18
				y=23
				[modifications]
					{TRAIT_LOYAL}
				[/modifications]
				[/unit]
			#dialog
				[message]
				description=Reglok
				message= _ "Let's expel these invaders! Today, the city is ours again!"
				[/message]
			[/event]
				[allow_recruit]
				type=Thief
				[/allow_recruit]
			[/command]
		[/option]
		[/message]
		[kill]
		type=Thief
		[/kill]
		[kill]
		type=Rogue
		[/kill]
	[/event]

#
# Special event - if you chose to have the thieves help you across the river,
# on turn 6 the ford appears
#
	[event]
	name=turn 6

	[if]
	[variable]
	name=thieves_ford
	equals=yes
	[/variable]
	[then]

		[message]
		speaker=narrator
		image="wesnoth-icon.png"
		message= _ "On the banks of Elensefar's port district, three shadowy figures appeared."
		[/message]
		[message]
		speaker=narrator
		image="wesnoth-icon.png"
		message= _ "To Konrad's surprise, they quickly made their way across the river's mouth. The turbulent waters hid a nearly invisible ford, wide enough for two soldiers to march shoulder-to-shoulder."
		[/message]
	#create units

		[set_variable]
		name=tempthief.x
		value=7
		[/set_variable]

		[set_variable]
		name=tempthief.y
		value=30
		[/set_variable]

		[unstore_unit]
		variable=tempthief
		find_vacant=yes
		[/unstore_unit]

		{CLEAR_VARIABLE tempthief}

		[unit]
		description=Gelgar
		user_description= _ "Gelgar"
		type=Thief
		side=1
		x=6
		y=30
		gender=male
		[modifications]
			{TRAIT_LOYAL}
		[/modifications]
		[/unit]

		[unit]
		description=Gamlel
		user_description= _ "Gamlel"
		type=Thief
		side=1
		x=6
		y=31
		gender=male
		[modifications]
			{TRAIT_LOYAL}
		[/modifications]
		[/unit]
	#create terrain
		[terrain]
		letter=Wwf
		x=7-8
		y=30-32
		[/terrain]
	#dialog
		[message]
		description=Reglok
		message= _ "Very few people know that the river can be forded here. The orcs have yet to discover this place. Bring your forces into the city, quickly now, and you can flank them."
		[/message]

	[/then]
	[/if]

	[/event]

	[event]
	name=victory
		[message]
		description=Konrad
		message= _ "Finally, we have retaken the city! Let us rest here, friends."
		[/message]
		[role]
		role=Thief
		type=Assassin,Rogue,Thief
		[/role]
		[message]
		role=Thief
		message= _ "Victory! The thieves of Elensefar will be in your service, my lord"
		[/message]
		[message]
		speaker=narrator
		image="wesnoth-icon.png"
		message= _ "The party rested for three days, after which an old friend returned."
		[/message]

		[move_unit_fake]
			type=Elder Mage
			x=25,24,24
			y=18,17,16
		[/move_unit_fake]

		{VARIABLE delfador_store.x 24}
		{VARIABLE delfador_store.y 16}

		#show Delfador
		[unstore_unit]
		variable=delfador_store
		[/unstore_unit]
		{CLEAR_VARIABLE delfador_store}
		[unit]
		description=Kalenz
		user_description= _ "Kalenz"
		unrenamable=yes
		type=Elvish Lord
		x=22
		y=16
		side=1
		{IS_HERO}
		[modifications]
			{TRAIT_LOYAL}
		[/modifications]
		[/unit]

		[redraw]
		[/redraw]

		[message]
		description=Delfador
		message= _ "Greetings, friends. I see that you have rescued the city! I knew that you could do it."
		[/message]

		[message]
		description=Konrad
		message= _ "Delfador! So good to see you! Where have you been?"
		[/message]

		[message]
		description=Delfador
		message= _ "I have been meeting with the Great Elven Council. This is Kalenz, a lord of the Northern Elves who came to the Council to offer us the support of the Northern Elves."
		[/message]

		[message]
		description=Kalenz
		message= _ "Greetings, friend."
		[/message]

		[message]
		description=Konrad
		message= _ "Delfador, we have captured this city, but surely Asheviere's men will come and attack us! What should we do?"
		[/message]

		[message]
		description=Delfador
		message= _ "The Council has met and decided: we must capture the Scepter of Fire."
		[/message]

		[message]
		description=Konrad
		message= _ "The Scepter of Fire? What's that?"
		[/message]

		[message]
		description=Delfador
		message= _ "The Scepter of Fire is the most ancient artifact of the realm of Wesnoth. It was forged by the dwarves of Knalga at the request of King Haldric II. It took their finest smiths years to make it, but soon after it was completed, the makers were chased underground, attacked by the elves. None know exactly what occurred, but the Scepter was lost somewhere in the great caverns. Years have passed, and the fortunes of the dwarves have waxed and waned, but the Scepter has never been found."
		[/message]

		[message]
		description=Konrad
		message= _ "But what has this to do with me?"
		[/message]

		[message]
		description=Delfador
		message= _ "When Garard II, your uncle, was deciding upon a successor, he issued an edict that whichever member of the royal family could retrieve the Scepter of Fire would rule the land."
		[/message]

		[message]
		description=Konrad
		message= _ "Oh, and you want me to get this scepter?"
		[/message]

		[message]
		description=Kalenz
		message= _ "We will help you retrieve it, my lord."
		[/message]

		[message]
		description=Delfador
		message= _ "Time is short. We think that Asheviere is also searching for the Scepter, to help seal her place as ruler. But if you find the Scepter first, the people will support you as the king."
		[/message]

		[message]
		description=Konrad
		message= _ "Me? King?"
		[/message]

		[message]
		description=Delfador
		message= _ "Yes, Konrad. I believe you will be king one day. Now let us make haste!"
		[/message]
	[/event]

	[event]
		name=moveto
		[filter]
			side=1
			x=16-17
			y=5-6
		[/filter]

		[message]
		description=Muff Jaanal
		message= _ "So you endeavor to fight me in my home. Foolish."
		[/message]

#ifdef EASY
		[gold]
			side=3
			amount=30
		[/gold]
#else
		[gold]
			side=3
			amount=60
		[/gold]
#endif

		[terrain]
			x=13
			y=2
			letter=Uu
		[/terrain]
		[sound]
			name=gunshot.wav
		[/sound]
#ifdef EASY
		{UNDEAD_UNIT (Skeleton) 3 13 2}
#else
		{UNDEAD_UNIT (Revenant) 3 13 2}
#endif
		[scroll_to_unit]
			x=13
			y=2
		[/scroll_to_unit]

		[terrain]
			x=22
			y=2
			letter=Uu
		[/terrain]
		[sound]
			name=gunshot.wav
		[/sound]
#ifdef HARD
		{UNDEAD_UNIT (Deathblade) 3 22 2}
#else
		{UNDEAD_UNIT (Skeleton) 3 22 2}
#endif
		[scroll_to_unit]
			x=22
			y=2
		[/scroll_to_unit]
	[/event]

	{campaigns/Heir_To_The_Throne/utils/deaths.cfg}
[/scenario]

