[scenario]
	id=3_A_Desperate_Errand
	#textdomain wesnoth-tsg

	name= _ "A Desperate Errand"
	next_scenario=4_Vale_of_Tears
	[music]
		name=wesnoth-1.ogg
		ms_before=500
	[/music]
	[music]
		name=wesnoth-2.ogg
		ms_before=500
		append=yes
	[/music]
	[music]
		name=gameplay02.ogg
		ms_before=500
		append=yes
	[/music]

	{SG_MAP 3_A_Desperate_Errand}
	{@campaigns/The_South_Guard/utils/sg_deaths.cfg}

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

	victory_when_enemies_defeated=no
	{TURNS 30 24 20}


# The South Guard

[side]
	side=1
	type=Horseman Commander
	description=Deoran
	user_description= _ "Deoran"
	unrenamable=yes

	team_name=South_Guard
	controller=human
	{CUSTOM_SG_FLAG}

	{GOLD 120 105 75}

	canrecruit=1
	recruit= Peasant,Bowman,Spearman
[/side]

# The Bandit Armies

[side]
	side=2
	type=Rogue
	description=Urza Fastik
	user_description= _ "Urza Fastik"

	team_name=bandits
	controller=ai

	{GOLD 20 40 70}
	{INCOME 2 4 7}

	canrecruit=1
	[ai]
		recruitment_pattern=fighter,scout,archer,scout
		{QUANTITY aggression 0.55 0.75 0.85}
		{ATTACK_DEPTH 3 4 5}
		[target]
			description=Deoran
			value=10.0
		[/target]
	[/ai]

	#ifdef EASY
		recruit=Thug,Footpad,Vampire Bat
	#endif
	#ifdef NORMAL
		recruit=Thug,Thief,Poacher,Vampire Bat,Skeleton
	#endif
	#ifdef HARD
		recruit=Footpad,Thief,Poacher,Vampire Bat,Skeleton,Skeleton Archer
	#endif

[/side]

[event]
	name=prestart

	# The Bandit Armies control several villages.
	{STARTING_VILLAGES 2 15}

	# Modify the map to add the target location for Deoran to move towards.
	{PUT_IMG (items/gohere.png) 17 7}

	# Reduce the size of the enemy camp on 'trivial' difficulty
	#ifdef EASY
		{SG_CHANGE_TERRAIN 8 18 g}
		{SG_CHANGE_TERRAIN 10 19 g}
	#endif

[/event]

#start
	[event]
		name=start
		[recall]
			description=Sir Gerrick
		[/recall]
		[recall]
			description=Minister Hylas
		[/recall]

		[message]
			speaker=narrator
			message= _ "Deoran and his men came to the border of the elvish woods..."
		[/message]

		[message]
			speaker=Deoran
			message= _ "Look, men!  There is the forest of the Elves to the north west.  Let us hasten across the river and the hills."
		[/message]

		[message]
			speaker=Minister Hylas
			message= _ "Be careful, Deoran.  No man has set foot in the Elvish woods for many a year.  We do not know how they will receive us.  Sir Loris thought that it was some trick of theirs trying to bring him into the woods..."
		[/message]

		[message]
			speaker=Deoran
			message= _ "But if we do not discover the source of these undead warriors, the whole province shall surely be swallowed up by them, and then their bandit masters will fare no better.  We cannot allow it!"
		[/message]

		[message]
			speaker=Urza Fastik
			message= _ "I have lost two brothers to Deoran - I shall not allow him to reach the accursed elves!  Deoran will die before he reaches the western forest!"
		[/message]

		[objectives]
			side=1
			[objective]
				description= _ "Move Deoran to the Elvish city in the northern woods"
				condition=win
			[/objective]
			[objective]
				description= _ "Death of Deoran"
				condition=lose
			[/objective]
			[objective]
				description= _ "Death of Sir Gerrick"
				condition=lose
			[/objective]
			[objective]
				description= _ "Time runs out"
				condition=lose
			[/objective]
		[/objectives]

		#ifdef EASY
			[scroll_to]
				x=17
				y=7
			[/scroll_to]
			[message]
				speaker=narrator
				message= _ "You must move Deoran to the center of the elvish citadel.  Be sure to recruit a force strong enough to drive off the bandits before moving Deoran from his encampment!"
			[/message]
		#endif
	[/event]

	[event]
		name=turn 1

		[message]
			speaker=Deoran
			message= _ "There is so much ground to cover.  If only our riders would arrive!"
		[/message]
	[/event]

	[event]
		name=turn 2

		[unit]
			side=1
			description=Jarek
			user_description= _ "Jarek"
			{QUANTITY type Cavalier Dragoon Cavalryman}
			x,y=41,33
			traits_description=_"strong," + _"quick"
			upkeep=full
			[modifications]
				{SG_STRONG}
				{SG_QUICK}
			[/modifications]
		[/unit]

		[message]
			speaker=Jarek
			message= _ "Commander, I received your request for reinforcements, and I have brought my riders with me!"
		[/message]

		[message]
			speaker=narrator
			image="human-loyalists/cavalryman-attack.png~TC(1,magenta)"
			message= _ "You may now recruit Cavalrymen.  They are fast and deadly on grassland, but weak in forests and hills.  They can keep up with Deoran, so use them to guard him!"
		[/message]

		[allow_recruit]
			side=1
			type=Cavalryman
		[/allow_recruit]
	[/event]

	[event]
		name=die
		[filter]
			speaker=Urza Fastik
		[/filter]

		[message]
			speaker=unit
			message= _ "What have we done?!  Even our undead allies cannot stand against this commander!"
		[/message]

		[role]
			role=second
			type=Spearman, Swordsman, Pikeman, Javelineer, Bowman, Longbowman,Cavalryman,Dragoon
		[/role]

		[message]
			role=second
			message= _ "I hope that's the last of the bandits!  How many more of these foul undead must we fight?"
		[/message]

		[message]
			speaker=Deoran
			message= _ "If we are to check the advance of the dead, I must reach the home of the elves!"
		[/message]
	[/event]

	[event]
		name=moveto
		[filter]
			description=Deoran
			x,y=17,7
		[/filter]

		{SG_UNIT (Elvish Ranger) (Ethiliel's Guard) (_"Ethiliel's Guard") 1 15 4}
		{SG_UNIT (Elvish Marksman) (Ethiliel's Guard) (_"Ethiliel's Guard") 1 19 4}
		{SG_UNIT (Elvish Ranger) (Ethiliel's Guard) (_"Ethiliel's Guard") 1 13 7}
		{SG_UNIT (Elvish Avenger) (Ethiliel's Guard) (_"Ethiliel's Guard") 1 21 7}
		{SG_UNIT (Elvish Hero) (Ethiliel's Guard) (_"Ethiliel's Guard") 1 15 10}
		{SG_UNIT (Elvish Outrider) (Ethiliel's Guard) (_"Ethiliel's Guard") 1 19 10}

		[unit]
			#ifdef EASY
				type=Elvish Shyde
			#endif
			#ifdef MEDIUM
				type=Elvish Druid
			#endif
			#ifdef HARD
				type=Elvish Druid
			#endif
			description=Ethiliel
			user_description= _ "Ethiliel"
			profile=portraits/ethiliel.png
			{IS_HERO}
			side=1
			x,y=18,6
			[modifications]
				{SG_LOYAL}
				{SG_QUICK}
			[/modifications]
		[/unit]

		[message]
			speaker=Ethiliel's Guard
			message= _ "Halt!  Who has entered our citadel without permission?"
		[/message]

		[message]
			speaker=Deoran
			message= _ "De..."
		[/message]

		[message]
			speaker=Ethiliel's Guard
			message= _ "Speak carefully, for the penalty for trespass in our lands is death, and your life is forfeit."
		[/message]

		[message]
			speaker=Deoran
			image=portraits/deoran-mad.png
			message= _ "Deora..."
		[/message]

		[message]
			speaker=Ethiliel
			message= _ "Stay a moment.  This man wears the colors of Wesnoth, and Kalenz told us the folk of Wesnoth were not all foes of the elves.  Tell us, then, what brings you to the hallowed citadel of Elrath?"
		[/message]

		[message]
			speaker=Deoran
			message= _ "My lady, we have come to the elves to seek guidance.  Bandits and criminals in our land have summoned the dead to help them plunder our farms and villages.  They are coming across the river from the great forest to the south of our lands, where no man has yet traveled."
		[/message]

		[message]
			speaker=Ethiliel
			message= _ "The elves know of the great southern forest, and have walked its paths many times.  What would you do, Deoran?"
		[/message]

		[message]
			speaker=Deoran
			message= _ "I would lead my men south of the river to find the source of these beings of dark that we might destroy it.  For surely we cannot stand against them for long."
		[/message]

		[message]
			speaker=Ethiliel
			message= _ "Indeed you are brave to face such foes.  But I fear that alone you will fail and fall.  One elf now lives who remembers the secrets of the undead that we learned when Haldric I came to our land.  His name is Mebrin, and he lives, secluded in the hills, near here.  I will take you to him."
		[/message]

		[message]
			speaker=Deoran
			image=portraits/deoran-glad.png
			message= _ "My thanks, lady."
		[/message]

		[kill]
			type=Elvish Ranger,Elvish Avenger,Elvish Outrider,Elvish Hero,Elvish Marksman
			animate=no
			fire_event=no
		[/kill]

		[endlevel]
			bonus=yes
			result=victory
		[/endlevel]

	[/event]

[/scenario]
