[scenario]
	id=Elf_Lords
	#textdomain wesnoth-trow
	name= _ "The Ka'lian"
	map_data="{campaigns/The_Rise_Of_Wesnoth/maps/Elf_Lords.map}"
	turns=30

	{AFTERNOON}

	next_scenario=A_Spy_in_the_Woods

	[music]
	name="elf-land.ogg"
	[/music]

	{campaigns/The_Rise_Of_Wesnoth/utils/trow-deaths.cfg}

	[story]
		[if]
			[variable]
			name=last_done
			equals=none
			[/variable]
			[then]
				[part]
					background=story/the_great_continent.png
					show_title=yes
					{DOT 240 260}
					{DOT 265 265}
					{DOT 280 250}
					{DOT 295 235}
					{DOT 305 210}
					{CROSS 310 176}
				[/part]
			[/then]
			[else]
				[part]
					background=story/the_great_continent.png
					show_title=yes
					{CROSS 315 180}
				[/part]
			[/else]
		[/if]
	[/story]

	[side]
		side=1
		type=Noble Commander
		description=Prince Haldric
		user_description= _ "Prince Haldric"
		unrenamable=yes
		canrecruit=1
		controller=human
		team_name=Haldric
	[/side]

	[side]
		side=2
		type=Elvish Shyde
		description=Lord Dionli
		user_description= _ "Lord Dionli"
		profile="portraits/dionli.png"
		team_name=Elves
	[/side]

	[side]
		side=3
		type=Elvish Champion
		description=Lord Logalmier
		user_description= _ "Lord Logalmier"
		profile="portraits/logalmier.png"
		image="units/kalian-elvish-champion.png"
		team_name=Elves
	[/side]

	[side]
		side=4
		type=Elvish Sharpshooter
		description=Lord Aryad
		user_description= _ "Lord Aryad"
		profile="portraits/aryad.png"
		team_name=Elves
	[/side]

	[event]
	name=prestart

		{PLACE_IMAGE (scenery/pine2.png) 13 12}

		[recall]
			description=Lady Jessica
		[/recall]

		[recall]
			description=Burin the Lost
		[/recall]

		[recall]
			description=Sir Ruddry
		[/recall]

		[recall]
			description=Sir Ladoc
		[/recall]

		[recall]
			description=Minister Edmond
		[/recall]

		[teleport]
			[filter]
				description=Prince Haldric
			[/filter]
			x=13
			y=21
		[/teleport]

		[teleport]
			[filter]
				description=Lady Jessica
			[/filter]
			x=15
			y=20
		[/teleport]

		[teleport]
			[filter]
				description=Burin the Lost
			[/filter]
			x=11
			y=21
		[/teleport]

		[teleport]
			[filter]
				description=Sir Ruddry
			[/filter]
			x=12
			y=21
		[/teleport]

		[teleport]
			[filter]
				description=Sir Ladoc
			[/filter]
			x=12
			y=21
		[/teleport]

		[teleport]
			[filter]
				description=Minister Edmond
			[/filter]
			x=15
			y=22
		[/teleport]

		{HERO (Elvish Marshal) (Lord El'Isomithir) ( _ "Lord El'Isomithir") 4 13 14 ("portraits/isomithir.png")}

	[/event]

#define DRAGON
			[option]
				message= _ "I think I'll fight the Dragon!"

				[command]
					[message]
					description=Prince Haldric
					message= _ "Lord Logalmier, I shall defeat your Dragon."
					[/message]
					[if]
					[variable]
						name=the_dragon
						numerical_equals=0
					[/variable]
					[then]
						[endlevel]
							result=continue
							next_scenario=The_Dragon
						[/endlevel]
					[/then]
					[else]
						[message]
							description=Lady Jessica
							message= _ "Umm, you already beat the dragon, Haldric."
						[/message]
					[/else]
					[/if]
				[/command]
			[/option]
#enddef

#define BEACH
			[option]
				message= _ "Let's get those Saurians and Nagas on that beach!"

				[command]
					[message]
					description=Prince Haldric
					message= _ "Those cold blooded monsters will feel my wrath!"
					[/message]
					[if]
					[variable]
						name=a_beach
						numerical_equals=0
					[/variable]
					[then]
						[endlevel]
							result=continue
							next_scenario=A_Beach
						[/endlevel]
					[/then]
					[else]
						[message]
							description=Lady Jessica
							message= _ "Umm, you already cleared the beach."
						[/message]
					[/else]
					[/if]
				[/command]
			[/option]
#enddef

#define HOLE
			[option]
				message= _ "Let's clear out that Troll Hole!"

				[command]
					[message]
					description=Prince Haldric
					message= _ "So what exactly is a Troll?"
					[/message]
					[if]
					[variable]
						name=troll_hole
						numerical_equals=0
					[/variable]
					[then]
						[endlevel]
							result=continue
							next_scenario=Troll_Hole
						[/endlevel]
					[/then]
					[else]
						[message]
							description=Lady Jessica
							message= _ "Haldric, the trolls, scales and fangs - you don't remember?"
						[/message]
					[/else]
					[/if]
				[/command]
			[/option]
#enddef

#define ISLE
			[option]
				message= _ "Let's put those souls to rest on the Cursed Isle!"

				[command]
					[message]
					description=Prince Haldric
					message= _ "Undead. Bah! We're pros at fighting them."
					[/message]
					[if]
					[variable]
						name=cursed_isle
						numerical_equals=0
					[/variable]
					[then]
						[endlevel]
							result=continue
							next_scenario=Cursed_Isle
						[/endlevel]
					[/then]
					[else]
						[message]
							description=Lady Jessica
							message= _ "How could you possibly forget the horror of the Isle of Tears?"
						[/message]
					[/else]
					[/if]
				[/command]
			[/option]
#enddef

#define QUEST_CHOICES
		[message]
			description=Prince Haldric
			message= _ "In the name of peace between our peoples:"
			{DRAGON}
			{BEACH}
			{HOLE}
			{ISLE}
		[/message]
#enddef

#define QUESTS
	[if]
		[variable]
		name=the_dragon
		numerical_equals=0
		[/variable]
		[then]
			[message]
				description=Lord Logalmier
				message= _ "I fear my kin are too easy on you. I decree that you should be made to fight the Dragon of the Green Swamp and its saurian minions. If you can defeat him, you will have truly earned your place in this land."
			[/message]
		[/then]
	[/if]

	[if]
		[variable]
		name=a_beach
		numerical_equals=0
		[/variable]
		[then]
			[message]
				description=Lord Dionli
				message= _ "There is a group of saurians, friends of the dragon I'm sure, who are trading metal with the nagas of the sea. We should put a stop to this. They are located on a beach near here."
			[/message]
		[/then]
	[/if]

	[if]
		[variable]
		name=troll_hole
		numerical_equals=0
		[/variable]
		[then]
			[message]
				description=Lord Aryad
				message= _ "We are having a problem with a troll-hole in the Brown Hills. While I find the thought of those dwarves stumbling on the trolls vaguely amusing, this should make an adequate quest for you."
			[/message]
		[/then]
	[/if]

	[if]
		[variable]
		name=cursed_isle
		numerical_equals=0
		[/variable]
		[then]
			[message]
				description=Lord El'Isomithir
				message= _ "Long ago a clan of elves on the  Isle of Tears fell under the sway of a dark curse. Their souls still haunt that place and no elf will go there. You should clear this isle, and put their souls to rest."
			[/message]
		[/then]
	[/if]

#enddef

#define GREET
	[if]
		[variable]
			name=last_done
			equals="Dragon"
		[/variable]
		[then]
			[message]
				description=Lord Logalmier
				message= _ "Ahh, you have defeated the dragon, man of the west-north, you are truly impressive for a human."
			[/message]
		[/then]
	[/if]
	[if]
		[variable]
			name=last_done
			equals="Hole"
		[/variable]
		[then]
			[message]
				description=Lord Aryad
				message= _ "So, you have defeated the trolls. Welcome back, Haldric."
			[/message]
		[/then]
	[/if]
	[if]
		[variable]
			name=last_done
			equals="Isle"
		[/variable]
		[then]
			[message]
				description=Lord El'Isomithir
				message= _ "Finally the souls of our poor kin may rest. Thank you."
			[/message]
		[/then]
	[/if]
	[if]
		[variable]
			name=last_done
			equals="Beach"
		[/variable]
		[then]
			[message]
				description=Lord Dionli
				message= _ "Our beaches are free again. I knew I could trust you, Haldric."
			[/message]
		[/then]
	[/if]
#enddef

	[event]
		name=start
		[message]
			speaker=narrator
			message= _ "Haldric and his companions find themselves before the Ka'lian, or the Council of Elven Lords."
		[/message]

		[if]
			[variable]
			name=num_done
			numerical_equals=0
			[/variable]

			[then]
				[message]
					description=Lord Logalmier
					message= _ "Dionli, why have you brought these humans before us?"
				[/message]
				[message]
					description=Lord Dionli
					message= _ "They are of the same people as the Prince of Southbay. They come as refugees. I can see a use for them."
				[/message]
				[message]
					description=Lord Aryad
					message= _ "What use would that be? What need could we have for the shortliveds here?"
				[/message]
				[message]
					description=Lord Dionli
					message= _ "The dwarves have come to the Brown Hills. While they live long, even they grow like weeds when in an empty field. There is trouble brewing."
				[/message]
				[message]
					description=Lord Dionli
					message= _ "It is better to be the greater of three than the lesser of two. The Prince of Southbay was good, he was a credit to his people. Maybe these ones are made of the same stuff."
				[/message]
				[message]
					description=Lord El'Isomithir
					message= _ "But why then do they come as refugees? Speak, human."
				[/message]
				[message]
					description=Prince Haldric
					message= _ "Our people come in peace. There was a war in our homeland. We are refugees. We come seeking a new home, since our island to the west and north is now forfeit."
				[/message]
				[message]
					description=Lord El'Isomithir
					message= _ "So you come to steal our land? We know your kind, humans of the west-north."
				[/message]
				[message]
					description=Prince Haldric
					message= _ "We only wish to live in peace. The dwarves are peoples of mountain and hill, the elves are people of the forests, we only seek some of the space in between."
				[/message]
				[message]
					description=Lord Dionli
					message= _ "I suggest that we grant these humans the plains to the north and south of the great river."
				[/message]
				[message]
					description=Lord Aryad
					message= _ "They should be put to the test before such a grant is made."
				[/message]
				[message]
					description=Lord El'Isomithir
					message= _ "A quest for each of us then?"
				[/message]
				[message]
					description=Lord Dionli
					message= _ "Agreed."
				[/message]
				[message]
					description=Lord Aryad
					message= _ "Agreed."
				[/message]
				[message]
					description=Lord Logalmier
						message= _ "Agreed. (Sigh)"
				[/message]
				[message]
					description=Prince Haldric
					message= _ "Umm, agreed."
				[/message]
				[message]
					description=Lord Aryad
					message= _ "Well then, human. Each of us lords has a specific quest for you. If you complete them all you will be granted all of the plains in our domain and the hills south of the Great River, if not you will be forced to depart. So which quest do you wish to undertake first?"
				[/message]
				{QUESTS}

				#will have to use a [do] here if the future choices...
				{QUEST_CHOICES}
			[/then]
		[/if]

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

			[then]
				{GREET}

				[message]
					description=Lord Logalmier
						message= _ "Very good, but this is just the start, human. There is still much more for you to do."
				[/message]

				{QUESTS}

				[while]
				[variable]
					less_than=4
					name=num_done
				[/variable]
				[do]
					{QUEST_CHOICES}
				[/do]
				[/while]
			[/then]
		[/if]

		[if]
			[variable]
			name=num_done
			numerical_equals=2
			[/variable]

			[then]
				{GREET}

				[message]
					description=Lord Logalmier
						message= _ "You are victorious again. You may yet earn your place in this land."
				[/message]

				{QUESTS}

				[while]
				[variable]
					less_than=4
					name=num_done
				[/variable]
				[do]
					{QUEST_CHOICES}
				[/do]
				[/while]
			[/then]
		[/if]

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

			[then]
				{GREET}

				[message]
					description=Lord Logalmier
						message= _ "Ahh, my young prince, you're not as soft as I thought."
				[/message]

				{QUESTS}

				[while]
				[variable]
					less_than=4
					name=num_done
				[/variable]
				[do]
					{QUEST_CHOICES}
				[/do]
				[/while]
			[/then]
		[/if]

		[if]
			[variable]
			name=num_done
			numerical_equals=4
			[/variable]
			[then]
			{GREET}

				[message]
					description=Lord Dionli
					message= _ "You were successful, Prince Haldric. I knew you could do it."
				[/message]

				[message]
					description=Lord Logalmier
						message= _ "Man of the west-north, you have earned your place on this great continent."
				[/message]

				[message]
					description=Lord Aryad
					message= _ "As per our agreement, you and your people -"
				[/message]

				[message]
					description=Lord El'Isomithir
					message= _ "may stay."
				[/message]

				[message]
					description=Lord Logalmier
						message= _ "We hereby grant you the plains to the north of the Great River, and the plains and hills to the south of the Great River. Be kind to the land. In a time of need we may call upon you, remember our generosity."
				[/message]

				[message]
					description=Prince Haldric
					message= _ "Fair enough. I decree a 'Pact of Mutual Aid' between our peoples. But, aren't you setting us in conflict with the Dwarves?"
				[/message]

				[message]
					description=Lord Logalmier
						message= _ "No. The dwarves have returned to the north. But humans mine as well. No? They are your resources to guard now. In the future we would be willing to trade with you."
				[/message]

				[move_unit_fake]
					type=Lieutenant
					x=20,20,19
					y=25,24,24
				[/move_unit_fake]

				{HERO (Lieutenant) (Commander Aethyr) ( _ "Commander Aethyr") 1 19 24 ("portraits/aethyr.png")}

				[message]
					description=Lord Logalmier
						message= _ "Who is this?"
				[/message]

				[message]
					description=Prince Haldric
					message= _ "It's Commander Aethyr, of Clearwater Port. I was sure you perished in the fighting there?"
				[/message]

				[message]
					description=Commander Aethyr
					message= _ "No, sir. I was leading the final survivors of Clearwater Port. We were making our last stand at the lighthouse when one of your ships came. One of my men conked me on the head, then I woke up at sea."
				[/message]

				[message]
					description=Commander Aethyr
					message= _ "I come bearing news. Some 'old friends' have decided to make an appearance. You should go 'greet' them."
				[/message]

				[message]
					description=Lady Jessica
					message= _ "(whispered) I fear our friend has said too much. You go on ahead, I'll catch up with you."
				[/message]

				{CLEAR_VARIABLE num_done}
				{CLEAR_VARIABLE a_beach}
				{CLEAR_VARIABLE cursed_isle}
				{CLEAR_VARIABLE the_dragon}
				{CLEAR_VARIABLE troll_hole}
				{CLEAR_VARIABLE last_done}

				[endlevel]
					result=continue
					next_scenario=A_Spy_in_the_Woods
				[/endlevel]
			[/then]
		[/if]

	[/event]

[/scenario]
