[scenario]
	id=20_North_Elves
	#textdomain wesnoth-httt
	name= _ "Home of the North Elves"
	map_data="{campaigns/Heir_To_The_Throne/maps/20_North_Elves.map}"
	{SCENARIO_MUSIC "revelation.ogg"}
	{TURNS 21 18 15}

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

	next_scenario=21_Elven_Council

	[event]
	name=prestart
		[objectives]
		side=1
		note= _ "Your encampment will be dismantled after the first turn"
			[objective]
				description= _ "Konrad must reach the elvish forest and hold that position until the turn is over"
				condition=win
			[/objective]
			[objective]
				description= _ "Death of Konrad"
				condition=lose
			[/objective]
			[objective]
				description= _ "Death of Delfador"
				condition=lose
			[/objective]
			[objective]
				description= _ "Death of Li'sar"
				condition=lose
			[/objective]
			[objective]
				description= _ "Death of Kalenz"
				condition=lose
			[/objective]
			[objective]
				description= _ "Turns run out before reaching the forest"
				condition=lose
			[/objective]
		[/objectives]
	[/event]

	{BIGMAP_HOME_OF_THE_NORTH_ELVES}

	[side]
	team_name=elves
	type=Commander
	description=Konrad
	user_description= _ "Konrad"
	hitpoints=45
	experience=0
	unrenamable=yes
	side=1
	canrecruit=1
	controller=human
	fog=yes
	gold=120
	[/side]

	[side]
	type=Orcish Warlord
	description=Kior-Dal
	user_description= _ "Kior-Dal"
	side=2
	canrecruit=1
#ifdef EASY
	recruit=Wolf Rider,Orcish Grunt,Orcish Archer
#endif
#ifdef NORMAL
	recruit=Wolf Rider,Orcish Grunt,Orcish Archer,Orcish Warrior
#endif
#ifdef HARD
	recruit=Orcish Warrior,Goblin Knight,Wolf Rider,Orcish Grunt,Orcish Archer,Troll Whelp,Troll,Orcish Assassin
#endif
		[ai]
		{ATTACK_DEPTH 4 5 6}
		passive_leader=yes
		simple_targetting=yes
		recruitment_pattern=scout,fighter,fighter,archer
		villages_per_scout=0
		village_value=0
			[target]
			description=Herbert
			value=100
			[/target]
			[target]
			description=Konrad
			value=0
			[/target]
			[target]
			description=Delfador
			value=0
			[/target]
			[target]
			description=Li'sar
			value=0
			[/target]
		[/ai]
		[ai]
		time_of_day=dusk
		aggression=0.7
		caution=0.25
		[/ai]
		[ai]
		time_of_day=first_watch,second_watch
		aggression=1.0
		caution=0.0
		[/ai]
	{GOLD 370 400 460}
	{INCOME 8 12 16}
	[/side]

	[side]
	type=General
	description=Herbert
	user_description= _ "Herbert"
	side=3
	canrecruit=1
#ifdef EASY
	recruit=Cavalryman,Spearman,Bowman
#endif
#ifdef NORMAL
	recruit=Cavalryman,Spearman,Bowman,Swordsman,Red Mage
#endif
#ifdef HARD
	recruit=Cavalryman,Swordsman,Pikeman,Ogre,Dragoon,Red Mage,White Mage,Shock Trooper
#endif
		[ai]
		{ATTACK_DEPTH 4 5 6}
		passive_leader=yes
		simple_targetting=yes
		recruitment_pattern=scout,fighter,fighter,mixed fighter
		villages_per_scout=0
		village_value=0
			[target]
			description=Kior-Dal
			value=100
			[/target]
			[target]
			description=Konrad
			value=0
			[/target]
			[target]
			description=Delfador
			value=0
			[/target]
			[target]
			description=Li'sar
			value=0
			[/target]
		[/ai]
		[ai]
		time_of_day=dawn
		aggression=0.7
		caution=0.25
		[/ai]
		[ai]
		time_of_day=morning,afternoon
		aggression=1.0
		caution=0.0
		[/ai]
	{GOLD 370 400 460}
	{INCOME 12 16 20}
	[/side]

	[side]
	team_name=elves
	type=Elvish Marshal
	description=El'rien
	user_description= _ "El'rien"
	side=4
	canrecruit=1
	recruit=Elvish Fighter,Elvish Archer,Elvish Ranger,Elvish Scout,Elvish Hero,Elvish Marksman

	{GOLD 600 475 350}
	income=20
		[ai]
		passive_leader=yes
		villages_per_scout=0
		village_value=0
		caution=0.9
		aggression=0.6
		grouping=defensive
		#
		# The Elves focus on getting to Konrad so they can
		# protect him
		#
		# The previous value was 15
		#
			[target]
			description=Konrad
			value=4
			[/target]
		[/ai]
	[/side]

	{STARTING_VILLAGES 4 24}


#define GUARDIAN TYPE SIDE X_LOC Y_LOC
	[unit]
	side={SIDE}
	type={TYPE}
	x,y={X_LOC},{Y_LOC}
	ai_special=guardian
	[/unit]
#enddef

	[event]
	name=prestart

	#
	# Variable cleanup from last scenario
	#
	{CLEAR_VARIABLE armored_knight}

	#
	# Add a bunch of strong guardians to discourage you from attacking the leaders
	# These are full-fledged war camps, after all
	#

	#
	# Camp guards
	#
	{GUARDIAN (Troll Warrior) 2 28 4}
	{GUARDIAN (Troll Warrior) 2 34 4}
	{GUARDIAN (Orcish Warrior) 2 30 4}
	{GUARDIAN (Orcish Warrior) 2 32 4}
	{GUARDIAN (Orcish Warrior) 2 29 6}
	{GUARDIAN (Orcish Warrior) 2 31 6}
	{GUARDIAN (Orcish Warrior) 2 33 6}
	{GUARDIAN (Orcish Slurbow) 2 30 6}
	{GUARDIAN (Orcish Slurbow) 2 32 6}
	#
	# Army members
	#
	{GUARDIAN (Orcish Grunt) 2 31 3}
	{GUARDIAN (Orcish Grunt) 2 32 2}
	{GUARDIAN (Troll Whelp) 2 33 2}
	{GUARDIAN (Orcish Grunt) 2 33 1}
	{GUARDIAN (Orcish Grunt) 2 27 4}
	{GUARDIAN (Troll Whelp) 2 26 3}
	{GUARDIAN (Orcish Grunt) 2 25 3}
	{GUARDIAN (Orcish Grunt) 2 24 1}
	{GUARDIAN (Orcish Grunt) 2 25 1}
	{GUARDIAN (Orcish Grunt) 2 26 1}
	{GUARDIAN (Orcish Warrior) 2 24 3}
	{GUARDIAN (Orcish Grunt) 2 23 4}
	{GUARDIAN (Troll Whelp) 2 22 3}
	{GUARDIAN (Orcish Grunt) 2 22 2}
	{GUARDIAN (Orcish Warrior) 2 21 3}
	{GUARDIAN (Orcish Grunt) 2 21 2}
	{GUARDIAN (Orcish Grunt) 2 20 2}
	{GUARDIAN (Orcish Grunt) 2 20 1}
	{GUARDIAN (Orcish Warrior) 2 21 1}
	#
	# Camp guards
	#
	{GUARDIAN (Lieutenant) 3 68 34}
	{GUARDIAN (Lieutenant) 3 67 35}
	{GUARDIAN (Lieutenant) 3 69 35}
	{GUARDIAN (Great Mage) 3 67 36}
	{GUARDIAN (Great Mage) 3 69 36}
	{GUARDIAN (Iron Mauler) 3 68 33}
	{GUARDIAN (Iron Mauler) 3 66 34}
	{GUARDIAN (Iron Mauler) 3 70 34}
	{GUARDIAN (Iron Mauler) 3 66 36}
	{GUARDIAN (Iron Mauler) 3 70 36}
	#
	# Army members
	#
	{GUARDIAN (Swordsman) 3 72 35}
	{GUARDIAN (Swordsman) 3 72 36}
	{GUARDIAN (Swordsman) 3 72 37}
	{GUARDIAN (Swordsman) 3 72 38}
	{GUARDIAN (Swordsman) 3 73 35}
	{GUARDIAN (Swordsman) 3 73 36}
	{GUARDIAN (Swordsman) 3 73 37}
	{GUARDIAN (Swordsman) 3 73 38}
	{GUARDIAN (Swordsman) 3 74 35}
	{GUARDIAN (Swordsman) 3 74 36}
	{GUARDIAN (Swordsman) 3 74 37}
	{GUARDIAN (Swordsman) 3 74 38}
	{GUARDIAN (Royal Guard) 3 73 34}
	{GUARDIAN (Sergeant) 3 74 34}
	{GUARDIAN (Swordsman) 3 62 35}
	{GUARDIAN (Swordsman) 3 62 36}
	{GUARDIAN (Swordsman) 3 62 37}
	{GUARDIAN (Swordsman) 3 62 38}
	{GUARDIAN (Swordsman) 3 63 35}
	{GUARDIAN (Swordsman) 3 63 36}
	{GUARDIAN (Swordsman) 3 63 37}
	{GUARDIAN (Swordsman) 3 63 38}
	{GUARDIAN (Swordsman) 3 64 35}
	{GUARDIAN (Swordsman) 3 64 36}
	{GUARDIAN (Swordsman) 3 64 37}
	{GUARDIAN (Swordsman) 3 64 38}
	{GUARDIAN (Royal Guard) 3 63 34}
	{GUARDIAN (Sergeant) 3 64 34}
	[/event]

	[event]
	name=start
		#
		# Allow the player to have some >6MP loyal units to compensate for the loss of recruiting
		#
		[recall]
		description=Delfador
		[/recall]
		[recall]
		description=Kalenz
		[/recall]
		[recall]
		description=Li'sar
		[/recall]
		[recall]
		description=Haldiel
		[/recall]
		[recall]
		description=Delurin
		[/recall]
		[recall]
		description=Reglok
		[/recall]
		[recall]
		description=Niodien
		[/recall]
		[redraw]
		[/redraw]

		[message]
		description=Kalenz
		message= _ "At last, friends, we have almost reached the home of my people, the North Elves."
		[/message]
		[message]
		description=Li'sar
		message= _ "After being in this wilderness for so long, it will be good to get some rest!"
		[/message]
		[message]
		description=Konrad
		message= _ "But there is a great fog around us again! We don't know what dangers may lie ahead!"
		[/message]
		[message]
		description=Kalenz
		message= _ "So long as we move ahead with caution and prudence, I am sure we will reach the safety and hospitality of the elves."
		[/message]

		[sound]
		name=horse-canter.wav
		[/sound]

		[move_unit_fake]
		type=Elvish Rider
		x=20,7
		y=17,18
		[/move_unit_fake]

		[unit]
		description=Eonihar
		user_description= _ "Eonihar"
		type=Elvish Rider
		side=1
		x=7
		y=18
		facing=reverse
		[modifications]
			{TRAIT_LOYAL}
			{TRAIT_DEXTROUS}
		[/modifications]
		[/unit]

		[redraw]
		[/redraw]

		[message]
		description=Eonihar
		message= _ "My lords! I have found you at last."
		[/message]

		[message]
		description=Kalenz
		message= _ "Greetings, Eonihar, old friend! Why have you been searching for us?"
		[/message]

		[message]
		description=Eonihar
		message= _ "When my lord learned of your coming, he sent riders out looking for you! There is trouble afoot!"
		[/message]

		[message]
		description=Konrad
		message= _ "Trouble? What kind of trouble?"
		[/message]

		[message]
		description=Eonihar
		message= _ "We have sighted a great host to the south, a host of the men of Wesnoth. And we believe they are looking for you! There is not a moment to lose. You must make haste to the elvish forest. Only there will you be safe!"
		[/message]

		[message]
		description=Konrad
		message= _ "I only hope we can avoid them. We will have to bear north-east."
		[/message]
		[message]
		description=Eonihar
		message= _ "That is not all, my lord. The foul orcs have heard of the coming of these men, and are even now gathering a great host to oppose them to the north! It is now certain that there will be a great battle."
		[/message]
		[message]
		description=Li'sar
		message= _ "This sounds very dangerous. Perhaps we should retreat to the West, and hide until the battle is over?"
		[/message]
		[message]
		description=Konrad
		message= _ "I think these wild lands are too dangerous for that! Anyhow... I expected you to be on the side of Wesnoth, Princess?"
		[/message]
		[message]
		description=Li'sar
		message= _ "I am an honorable princess, not an impostor like you! I promised that I would be on your side until we made it out of these lands, and I will keep my promise!"
		[/message]
		[message]
		description=Eonihar
		message= _ "Sir, madam, there is no time to lose! You must make it east, to the home of my people. Only there will you be safe!"
		[/message]
		[message]
		description=Konrad
		message= _ "Rider, do not fool with us. You yourself say men and orcs wage war on this plain that lies ahead. Do you propose we fly to the great woods of the east?"
		[/message]
		[message]
		description=Eonihar
		message= _ "My lord, you must rush across the field before the main host of each army makes it to the battle. It is the only way to avoid this great calamity."
		[/message]
		[message]
		description=Kalenz
		message= _ "I was afraid that's what you were going to say."
		[/message]
		[message]
		description=Li'sar
		message= _ "Come then, Konrad, let us go. We will do what must be done."
		[/message]
		[message]
		description=Eonihar
		message= _ "My lord has begun assembling a party of elves to come and escort you into the forest. Beware, for we are all in great danger!"
		[/message]
		[message]
		description=Delfador
		message= _ "Konrad, the encampment must be torn down. Any delay and these armies will crush us. Any evidence of our passage through here, and they will chase us."
		[/message]
	[/event]

#
# Turn 2: dismantle your castle
#
	[event]
	name=turn 2
		[terrain]
		x=3-5,4
		y=18-19,17
		letter=Re
		[/terrain]
	[/event]

#
# Turn 3: some dialog to help you along
#
	[event]
	name=turn 3
		[message]
		description=Li'sar
		message= _ "So, Konrad, do you think we can simply trot across the battlefield?"
		[/message]
		[message]
		description=Konrad
		message= _ "Stop for a moment, princess. Look - you can barely see them in the distance there, but the advance scouts have found each other. The Queen's troops are marching full speed for the orcs' camp, and vice-versa. These armies are out for blood."
		[/message]
		[message]
		description=Li'sar
		message= _ "But they will not neglect to notice our presence in their midst! We are walking into slaughter!"
		[/message]
		[message]
		description=Konrad
		message= _ "(hushed) Our soldiers will defend us as we rush across the field. Sorry to be blunt, princess, but you and I are the only ones who need to make it across alive."
		[/message]
		[message]
		description=Delfador
		message= _ "..."
		[/message]
		[message]
		description=Konrad
		message= _ "...and Delfador, of course. And Kalenz... and.."
		[/message]
		[message]
		description=Li'sar
		message= _ "Ach! I understand, Konrad. I am no stranger to the burden of command. Onward!"
		[/message]
	[/event]

#
# Turn 5: some of the riders who didn't find you catch up!
#
	[event]
	name=turn 5

		[store_unit]
		variable=konrad_store
			[filter]
			description=Konrad
			[/filter]
		[/store_unit]
		{VARIABLE temp_x $konrad_store.x}
		{VARIABLE temp_y $konrad_store.y}
#ifdef EASY
		[move_unit_fake]
		type=Elvish Rider
		x=1,$temp_x
		y=1,$temp_y
		side=4
		[/move_unit_fake]
		{UNIT (Elvish Rider) (Glarilon) ( _ "Glarilon") 4 $temp_x $temp_y}
		[message]
		description=Glarilon
		message= _ "My lords! I have found you at last."
		[/message]
#endif
		[move_unit_fake]
		type=Elvish Rider
		x=1,$temp_x
		y=38,$temp_y
		side=4
		[/move_unit_fake]
		{UNIT (Elvish Rider) (Thalindil) ( _ "Thalindil") 4 $temp_x $temp_y}
		[message]
		description=Thalindil
		message= _ "(exhausted) We have... (pant) finally found you!"
		[/message]
		{CLEAR_VARIABLE konrad_store}
		{CLEAR_VARIABLE temp_x}
		{CLEAR_VARIABLE temp_y}
	[/event]

#
# Turn 7: another rider finds you!
#
	[event]
	name=turn 7

		[store_unit]
		variable=konrad_store
			[filter]
			description=Konrad
			[/filter]
		[/store_unit]
		{VARIABLE temp_x $konrad_store.x}
		{VARIABLE temp_y $konrad_store.y}
		[move_unit_fake]
		type=Elvish Rider
		x=77,$temp_x
		y=18,$temp_y
		side=4
		[/move_unit_fake]
		{UNIT (Elvish Rider) (Rholandir) ( _ "Rholandir") 4 $temp_x $temp_y}
		[message]
		description=Rholandir
		message= _ "Lord Kalenz, Lord Konrad, our forces are nigh! Do not lose hope!"
		[/message]
		{CLEAR_VARIABLE konrad_store}
		{CLEAR_VARIABLE temp_x}
		{CLEAR_VARIABLE temp_y}
	[/event]


#
# Give the armies a gold infusion near the end to keep the pressure on
#
	[event]
	name=turn 10
		[gold]
		side=2
		amount=1000
		[/gold]
		[gold]
		side=3
		amount=1000
		[/gold]
	[/event]

	[event]
	name=sighted
		[filter]
		side=2
		[/filter]
		[music]
		name="northerners.ogg"
		[/music]
		[message]
		description=Delfador
		message= _ "There are some orcs! We must let them fight the men of Wesnoth, and avoid engaging them at all costs!"
		[/message]
	[/event]

	[event]
	name=sighted
		[filter]
		side=3
		[/filter]
		[message]
		speaker=unit
		message= _ "There they are! Charge!"
		[/message]
		[music]
		name="loyalists.ogg"
		[/music]
	[/event]

	[event]
	name=sighted
		[filter]
		side=4
		[not]
			description=Glarilon
		[/not]
		[not]
			description=Thalindil
		[/not]
		[not]
			description=Rholandir
		[/not]
		[/filter]
		[message]
		speaker=unit
		message= _ "There you are! You must come quickly to the home of the elves in the east!"
		[/message]
	[/event]

# event when moving to Elvish castle
	[event]
	name=moveto
		[filter]
		description=Konrad
		x=75-79
		y=17-19
		[/filter]
		[message]
		description=El'rien
		message= _ "Greetings, Elf-friend! Welcome to Emetria. You must take shelter here until the battle passes. If you stay with me here for a little while, we will all be safe."
		[/message]
		[message]
		description=Konrad
		message= _ "Thank you, Lord El'rien. The hospitality of the North Elves is as generous as that of your kin in the south! My men will help you hold out against our enemies."
		[/message]
	[/event]

# Once you make it far enough, TELL THE PLAYER!
	[event]
	name=moveto
		[filter]
		description=Konrad
			x=66-80,67-80,68-80,69-80,70-80,71-80,73-80,74-80
			y= 1- 8, 9-14,   15,16-17,18-20,   21,22-25,26-28
		[/filter]
		[message]
		description=Delfador
		message= _ "Konrad, you have made it to the domain of the North Elves. Continue moving east and let the elves guard your rear."
		[/message]
	[/event]

#
# Check if Konrad is inside forest, loosely defined -- but include
# Eastern woods, and a bit of grassland nearby
#
# This event makes you win if Konrad is inside the forest at the start of the
# next turn - that way the enemy still has one last shot to kill you
#
	[event]
	name=new turn
	first_time_only=no
		[if]
			[have_unit]
			description=Konrad
			x=66-80,67-80,68-80,69-80,70-80,71-80,73-80,74-80
			y= 1- 8, 9-14,   15,16-17,18-20,   21,22-25,26-28
			[/have_unit]
			[then]
				[endlevel]
				result=victory
				[/endlevel]
			[/then]
		[/if]
	[/event]

#
# Check if Konrad is inside forest, loosely defined -- but include
# Eastern woods and a bit of grassland nearby
#
# This event makes you win if Konrad is inside the forest at the end of the scenario -
# just in case the new turn even never fires (you make it there on the last turn)
#
	[event]
	name=time over
		[if]
			[have_unit]
			description=Konrad
			x=66-80,67-80,68-80,69-80,70-80,71-80,73-80,74-80
			y= 1- 8, 9-14,   15,16-17,18-20,   21,22-25,26-28
			[/have_unit]
			[then]
				[endlevel]
				result=victory
				[/endlevel]
			[/then]
			[else]
				[message]
				description=Delfador
				message= _ "We have not yet reached the forest, and the battle still rages. We are caught between two vast armies and cannot escape to safety! We are defeated!"
				[/message]
			[/else]
		[/if]
	[/event]

	[event]
	name=victory
		[message]
		description=El'rien
		message= _ "Elf-friends, you have made it to safety!"
		[/message]
		[message]
		description=Kalenz
		message= _ "El'rien, we have the Scepter of Fire with us! We must escort them to Elensia!"
		[/message]
		[message]
		description=El'rien
		message= _ "Indeed. We will escort you to our capital, where we will make Council."
		[/message]
	[/event]

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