[scenario]
	id=1_Born_To_The_Banner
	#textdomain wesnoth-tsg

	name= _ "Born to the Banner"
	next_scenario=2_Proven_By_The_Sword
	[music]
		name=knolls.ogg
		ms_before=500
	[/music]
	[music]
		name=wanderer.ogg
		ms_before=500
		append=yes
	 [/music]
	 [music]
		name=battle.ogg
		ms_before=500
		append=yes
	 [/music]


	map_data="{campaigns/The_South_Guard/maps/1_Born_To_The_Banner.map}"

	{campaigns/The_South_Guard/utils/sg_deaths.cfg}
	{campaigns/The_South_Guard/utils/sg_help.cfg}

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

	{TURNS 40 32 24}


# Scenario Introduction - Summer

{SG_BORN_TO_THE_BANNER}

# The South Guard

[side]
	side=1
	{QUANTITY type (Horseman Commander) (Junior Commander) (Junior Commander)}
	description=Deoran
	user_description= _ "Deoran"
	unrenamable=yes

	team_name=South_Guard
	controller=human
	{CUSTOM_SG_FLAG}

	{GOLD 120 100 80}
	{INCOME 4 1 0}

	canrecruit=1
	recruit=Peasant
[/side]

# The Bandit Armies

[side]
	side=2
	type=Bandit
	description=Urza Mathin
	user_description= _ "Urza Mathin"

	team_name=bandits
	controller=ai

	{GOLD 40 70 90}
	{INCOME 3 4 5}

	canrecruit=1
	#ifdef EASY
		recruit=Ruffian,Thug
	#endif

	#ifdef NORMAL
		recruit=Ruffian,Thug,Poacher
	#endif

	#ifdef HARD
		recruit=Footpad,Thief,Poacher,Thug
	#endif
	[ai]
		{ATTACK_DEPTH 1 2 3}
		#ifdef EASY
			recruitment_pattern=fighter
		#endif
		#ifdef MEDIUM
			recruitment_pattern=fighter,fighter,archer
		#endif
		#ifdef HARD
			recruitment_pattern=fighter,archer,archer
		#endif
	[/ai]

[/side]

[label]
	x,y=13,10
	text= _ "The River Fort"
[/label]

# Scenario Pre-start

[event]
	name=prestart

	[objectives]
		side=1
			[objective]
				description= _ "Investigate the river fort"
				condition=win
			[/objective]
			[objective]
				description= _ "Death of Deoran"
				condition=lose
			[/objective]
			[objective]
				description= _ "Time runs out"
				condition=lose
			[/objective]
	[/objectives]

	#ifdef EASY
		[variable]
			name=leader_attacked
			value=false
		[/variable]
	#endif

	# Add a useful village on 'trivial' difficulty'.
	#ifdef EASY
		{SG_CHANGE_TERRAIN 13 23 Gg^Vh}
	#endif

	# Modify the size of the keep of the enemy on 'simple' and 'easy' difficulties.
	#ifdef MEDIUM
		{SG_CHANGE_TERRAIN 20 22 Ce}
	#endif
	#ifdef HARD
		{SG_CHANGE_TERRAIN 20 22 Ce}
		{SG_CHANGE_TERRAIN 19 24 Ce}
	#endif


[/event]

# Scenario Start

[event]
	name=start
	[message]
		speaker=narrator
		message= _ "Deoran found himself put to the test early in his command. Loris, the previous commander, had squandered his time in games and diversions and bandits had overrun the land..."
	[/message]

	[move_unit_fake]
		{QUANTITY type Pikeman Spearman Peasant}
		x=18,18,18,19
		y=7,6,5,5
	[/move_unit_fake]

	[unit]
		{QUANTITY type Pikeman Spearman Peasant}
		description=Moreth
		user_description= _ "Moreth"
		side=1
		x,y=19,5
		traits_description=_"loyal," + _"resilient"
		[modifications]
			{SG_LOYAL}
			{SG_RESILIENT}
		[/modifications]

	[/unit]

	[message]
		speaker=Moreth
		message= _ "You'll never take this village! I've seen your kind kill too many townsmen, and I'll defend them to the death!"
	[/message]

	[message]
		speaker=Deoran
		image=portraits/deoran-mad.png
		message= _ "My kind? I am a soldier of Wesnoth, a messenger of King Haldric, and the new commander of the South Guard! What do you mean, 'my kind'?"
	[/message]

	[message]
		speaker=Moreth
		message= _ "Sorry, sir! I thought you were one of the bandits who have been ransacking the towns and killing the villagers. What are you doing here? Sir Gerrick and I were the last of the South Guard..."
	[/message]

	[message]
		speaker=Deoran
		message= _ "I have been sent to take command of the South Guard and set things right. We must arm the villagers and drive off the bandits before they can do any more harm!"
	[/message]

	[message]
		speaker=Moreth
		message= _ "You should head to the river fort! Sir Gerrick will want to know that reinforcements have arrived!"
	[/message]

	{PLACE_IMAGE (items/gohere.png) 13 10}
	[scroll_to]
		x=13
		y=10
	[/scroll_to]

	#ifdef EASY
		[message]
			speaker=narrator
			image=items/gohere.png
			message= _ "Whenever you see a target that looks like this, you should move your leader (or whatever unit the dialogue just suggested) onto the hex that contains it."
		[/message]
	#endif

	[message]
		speaker=Urza Mathin
		image=portraits/urza-mathin.png
		message= _ "Ha! This new commander doesn't stand a chance. His fate will be the same as that of that swine Loris!"
	[/message]

[/event]

# The River Fort - You find Sir Gerrick defending the citadel.

[event]
	name=moveto

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

	[unit]
		side=1
		type=South Guard Captain
		description=Sir Gerrick
		user_description= _ "Sir Gerrick"
		{IS_HERO}
		x,y=14,9
		traits_description=_"valiant," + _"resilient"
		[modifications]
			{SG_STRONG}
			{SG_RESILIENT}
		[/modifications]
	[/unit]

	[message]
		speaker=Sir Gerrick
		message= _ "My lord, it is good that King Haldric has sent you to our lands! Bandits have overrun the whole countryside, and are killing and pillaging without pity. You must raise the South Guard again and drive off the bandits!"
	[/message]

	[message]
		speaker=Deoran
		message= _ "No doubt I am needed here. Unfortunately I have seen only farm tools to arm our men with. They are valorous, but cannot fight bandits with pitchforks!"
	[/message]

	[message]
		speaker=Sir Gerrick
		message= _ "I will open the citadel's armory. We have a supply of spears and bows, and lacked only a leader to bring us to battle with them!"
	[/message]

#ifdef EASY
	[message]
		speaker=narrator
		image="gerrick/infantry-commander.png~TC(1,magenta)"
		message= _ "Sir Gerrick is an infantry commander. He is a strong warrior in his own right, but when he is near less experienced troops, he makes their attack better too!"
	[/message]

	[message]
		speaker=narrator
		image="misc/hero-icon.png"
		message= _ "Units that have a hero marker are vital to your campaign. If any of them die, you will lose the scenario, so guard them carefully!"
	[/message]
#endif

	[objectives]
		side=1
			[objective]
				description= _ "Defeat Urza Mathin"
				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
		[message]
			speaker=narrator
			image=items/gohere.png
			message= _ "Head back to the encampment where you started and recruit some troops!"
		[/message]

		[scroll_to]
			x=20
			y=4
		[/scroll_to]
		{PLACE_IMAGE (items/gohere.png) 20 4}
	#endif

	[removeitem]
		x,y=13,10
	[/removeitem]

	[allow_recruit]
		side=1
		type=Spearman, Bowman
	[/allow_recruit]
[/event]

# You return to the encampment and recruit troops.

#ifdef EASY
[event]
	name=moveto
	[filter]
		x,y=20,4
	[/filter]

	[message]
		speaker=narrator
		message= _ "While you're in your camp, you can recruit more troops. Build up a small force to use against the bandits that Urza Mathin recruits."
	[/message]
	[message]
		speaker=narrator
		image="human-loyalists/bowman-ranged-7.png~TC(1,magenta)"
		message= _ "Bowmen have a strong ranged attack, and are very effective against units that lack a ranged attack, like Thieves and Thugs. They also carry a sword and can defend themselves against melee attacks."
	[/message]
	[message]
		speaker=narrator
		image="human-loyalists/spearman-defend.png~TC(1,magenta)"
		message= _ "Spearmen have a strong melee attack, and are effective against most units. They also have a weak ranged attack. They form the backbone of the South Guard."
	[/message]
	[message]
		speaker=narrator
		message= _ "The best army will have a mix of units to deal with the different enemies that you will encounter. For now, concentrate on creating a small corps of experienced Bowmen."
	[/message]

	[removeitem]
		x,y=20,4
	[/removeitem]

[/event]
#endif

# Dusk - Sir Gerrick suggests that you should hold the north banks of the river.

#ifdef EASY
[event]
	name=turn 4

	[if]
		[have_unit]
			description=Sir Gerrick
		[/have_unit]
		[then]
			[message]
				speaker=Sir Gerrick
				message= _ "Sir, bandits are most dangerous at night. Let us hold the north bank of the river until dawn and press our attack in the morning!"
			[/message]

			[message]
				speaker=narrator
				image=misc/schedule-firstwatch.png
				message= _ "All of your units are 'lawful'. This means that they receive a combat bonus during the day, and a penalty at night. Urza Mathin's units are all 'chaotic', which means that they receive a bonus at night and a penalty during the day. You will be much more effective fighting during the day."
			[/message]
		[/then]
	[/if]

[/event]
#endif

# Dawn - Sir Gerrick suggests that you should attack now!

#ifdef EASY
[event]
	name=turn 7

	[if]
		[have_unit]
			description=Sir Gerrick
		[/have_unit]
		[then]
			[message]
				speaker=Sir Gerrick
				message= _ "My lord! The dawn is breaking - now is the time for us to attack and drive these bandits from our lands. To me men of the South Guard!"
			[/message]

			[message]
				speaker=narrator
				image=misc/schedule-dawn.png
				message= _ "During the day your units will deal more damage, and Urza Mathin's less. The more of his troops you can defeat during the day, the better!"
			[/message]
		[/then]
	[/if]

[/event]
#endif

# Mermen - You find mermen who will become allies and protect your waterways.

[event]
	name=moveto
	[filter]
		side=1
		x,y=6,10
	[/filter]
	[unit]
		side=1
		#ifdef EASY
			type=Merman Warrior
		#endif
		#ifdef MEDIUM
			type=Merman Warrior
		#endif
		#ifdef HARD
			type=Merman Fighter
		#endif
		description=Myssh
		user_description= _ "Myssh"
		traits_description=_"loyal," + _"intelligent"
		[modifications]
			{SG_LOYAL}
			{SG_INTELLIGENT}
		[/modifications]
		x,y=7,11
	[/unit]
	[unit]
		side=1
		#ifdef EASY
			type=Merman Spearman
		#endif
		#ifdef MEDIUM
			type=Merman Hunter
		#endif
		#ifdef HARD
			type=Merman Hunter
		#endif
		description=Ylla
		user_description= _ "Ylla"
		traits_description=_"loyal," + _"quick"
		[modifications]
			{SG_LOYAL}
			{SG_QUICK}
		[/modifications]
		x,y=5,10
	[/unit]

	[message]
		speaker=Myssh
		message= _ "Your people have been allies of our lord, King Typhon. We will help you drive these bandits from your land if you allow us to live here in peace."
	[/message]

	[message]
		speaker=Deoran
		message= _ "We welcome your aid in the fight against these criminals! The rivers of this land are yours if you will aid us in our battles."
	[/message]

#ifdef EASY
	[message]
		speaker=narrator
		image="merfolk/hunter-defend.png~TC(1,magenta)"
		message= _ "You may now recruit Merman Hunters. Mermen are aquatic creatures. Keep them in rivers and swamps and they will fight well! Put them on dry land and they're in trouble!"
	[/message]
#endif

	[allow_recruit]
		side=1
		type=Merman Hunter
	[/allow_recruit]
	{VARIABLE has_mermen "yes"}

[/event]

# Village Ambush - You find something unexpected in one of the villages.

[event]
	name=moveto
	[filter]
		side=1
		x,y=15,12
	[/filter]

	#ifdef EASY
		[unit]
			side=1
			type=Longbowman
			description=Aleron
			user_description= _ "Aleron"
			x,y=16,12
			traits_description= _"loyal," + _"quick"
			[modifications]
				{SG_LOYAL}
				{SG_QUICK}
			[/modifications]
		[/unit]

		[message]
			speaker=unit
			message= _ "Who goes there! Come out of the house now!"
		[/message]
		[message]
			speaker=Aleron
			message= _ "Stay! It's me, Aleron! The villagers hid me from the bandits when the town was overrun. They have kept me safe, though I was gravely wounded..."
		[/message]
		[message]
			speaker=Sir Gerrick
			message= _ "I am glad to find you alive Aleron, we feared the worst when you did not return after the battle!"
		[/message]
		[message]
			speaker=Aleron
			message= _ "Let us punish these bandits for their crimes and murders! My wounds are healed and I am ready for battle!"
		[/message]
		[message]
			speaker=narrator
			message= _ "Aleron is a longbowman, stronger and better trained than regular bowmen. His arrows are deadly to enemies without a ranged attack."
		[/message]
	#endif

	#ifdef NORMAL
		[unit]
			side=1
			type=Peasant
			description=Aleron
			user_description= _ "Aleron"
			traits_description= _"loyal," + _"strong"
			x,y=16,12
			[modifications]
				{SG_LOYAL}
				{SG_STRONG}
			[/modifications]
		[/unit]

		[message]
			speaker=Aleron
			message= _ "Not more bandits... We have nothing left. Begone!"
		[/message]
		[message]
			speaker=unit
			message= _ "We are no bandits. The banner of the South Guard flies again! Help us drive these criminals from your land."
		[/message]
		[message]
			speaker=Aleron
			message= _ "However I can, I will help you!"
		[/message]
		[message]
			speaker=Sir Gerrick
			message= _ "Garrison the villages behind our lines and keep the enemy from slipping around us at night."
		[/message]
	#endif

	#ifdef HARD
		[unit]
			side=2
			type=Footpad
			description=Glasar
			user_description= _ "Glasar"
			x,y=16,12
		[/unit]

		[message]
			speaker=Glasar
			message= _ "This village is ours to plunder! Begone or I will kill you all!"
		[/message]
		[message]
			speaker=unit
			message= _ "Do you not see the banners flying in the wind? The South Guard fights again. Flee while you can, or you will meet swift death on our spears!"
		[/message]
	#endif
[/event]

# If the player doesn't find Sir Gerrick in five turns, prompt him again.

#ifdef EASY

[event]
	name=turn 10
	[if]
		[have_unit]
			description=Sir Gerrick
		[/have_unit]
		[then]
		[/then]
		[else]
			[scroll_to]
				x=13
				y=10
			[/scroll_to]
			[message]
				speaker=narrator
				image=items/gohere.png
				message= _ "Remember, Moreth told you that you should go meet Sir Gerrick at the river fort. Move Deoran there and find out what Sir Gerrick has to say!"
			[/message]
		[/else]
	[/if]
[/event]

# Nothing happens for a while: remind the player of the objective.

[event]
	name=attack
	[filter_second]
		description=Urza Mathin
	[/filter_second]
	[variable]
		name=leader_attacked
		value=true
	[/variable]
[/event]

[event]
	name=turn 20
	[if]
		[variable]
			name=leader_attacked
			not_equals=true
		[/variable]
		[then]
			[scroll_to_unit]
				description=Urza Mathin
			[/scroll_to_unit]
			[message]
				speaker=narrator
				image="human-outlaws/bandit.png~TC(1,magenta)"
				message= _ "Remember, your job is to defeat Urza Mathin. He should be your main target. Archers will be especially effective against him, because he has no ranged attack. Surround him, and kill him!"
			[/message]
		[/then]
	[/if]
[/event]

#endif


# Victory - The bandits are defeated.

[event]
	name=die
	[filter]
		description=Urza Mathin
	[/filter]

	[message]
		speaker=Urza Mathin
		image=portraits/urza-mathin.png
		message= _ "My days of pillage and plunder are over! My brothers will avenge me..."
	[/message]

	[message]
		speaker=Sir Gerrick
		message= _ "He is dead! Congratulations, commander. We thought we would never see reinforcements - Did Sir Loris send you from Westin?"
	[/message]

	[message]
		speaker=Deoran
		message= _ "No. I have been sent by King Haldric to take command of the South Guard. The king has heard no news in weeks. How long have you and your men been shut up in the citadel?"
	[/message]

	[message]
		speaker=Sir Gerrick
		message= _ "Almost two months. Sir Loris took one of our patrols along the Westin road and never returned; and the next night, bandits struck and killed eight of my men. We held the citadel, and held out vain hope for reinforcement from Westin. We never thought we would see men sent from the King!"
	[/message]

	[message]
		speaker=Deoran
		image=portraits/deoran-sad.png
		message= _ "This is worse than even my darkest fears. We must ride to Westin at once, and hope that Sir Loris is there and well! Come men! Ride for Westin!"
	[/message]

[/event]

[/scenario]

