[scenario]
	id=2_Proven_By_The_Sword
	#textdomain wesnoth-tsg

	name= _ "Proven By The Sword"
	next_scenario=3_A_Desperate_Errand
	[music]
		name=gameplay03.ogg
		ms_before=500
	[/music]
	[music]
		name=wesnoth-2.ogg
		ms_before=500
		append=yes
	 [/music]
	 [music]
		name=main_menu_new.ogg
		ms_before=500
		append=yes
	 [/music]


	{SG_MAP 2_Proven_By_The_Sword}
	{@campaigns/The_South_Guard/utils/sg_deaths.cfg}
	{@campaigns/The_South_Guard/utils/sg_help.cfg}

	[label]
		x,y=22,16
		text=_"Westin"
	[/label]

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

	{TURNS 40 32 28}


# Scenario Introduction - Not all is right in Westin.

{SG_PROVEN_BY_THE_SWORD}

# 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 130 100 85}

	canrecruit=1
	recruit=Peasant,Bowman,Spearman

[/side]

# The Bandit Armies

[side]
	side=2
	type=Outlaw
	description=Urza Nalmath
	user_description= _ "Urza Nalmath"

	team_name=bandits
	controller=ai

	{GOLD 20 30 40}
	{INCOME 0 2 4}

	canrecruit=1
	#ifdef EASY
		recruit=Thief,Footpad
	#endif
	#ifdef NORMAL
		recruit=Thug,Thief,Poacher
	#endif
	#ifdef HARD
		recruit=Footpad,Thug,Thief,Poacher,Trapper
	#endif

	[ai]
		{ATTACK_DEPTH 2 3 4}
		recruitment_pattern=fighter,archer,fighter,scout,fighter
		grouping=no
		{NO_SCOUTS}
		village_value=3
	[/ai]


[/side]

# The Bandit Armies - Hidden Criminals

[side]
	side=3
	no_leader=yes

	team_name=bandits

	{SG_AMBUSHER Footpad Criminal (_"Criminal") 2 28 13}

	#ifdef MEDIUM
		{SG_AMBUSHER Footpad Criminal (_"Criminal") 2 34 14}
	#endif

	#ifdef HARD
		{SG_AMBUSHER Footpad Criminal (_"Criminal") 2 34 14}
		{SG_GUARD Thief Criminal (_"Criminal") 2 22 12}
	#endif

	{SG_GUARD Footpad Criminal (_"Criminal") 2 22 16}
	#ifdef MEDIUM
		{SG_GUARD Poacher Criminal (_"Criminal") 2 18 22}
	#endif
	#ifdef HARD
		{SG_GUARD Thief Criminal (_"Criminal") 2 18 22}
	#endif
[/side]

[event]
	name=prestart

	# The Bandit Armies control almost all of the villages.

	{STARTING_VILLAGES 2 30}

	# Add a useful village on 'trivial' difficulty'.
	#ifdef EASY
		{SG_CHANGE_TERRAIN 26 20 v}
	#endif

	# Modify the size of the keep of the enemy on 'simple' and 'easy' difficulties.
	#ifdef MEDIUM
		{SG_CHANGE_TERRAIN 18 27 n}
	#endif
	#ifdef HARD
		{SG_CHANGE_TERRAIN 18 27 n}
		{SG_CHANGE_TERRAIN 19 28 n}
	#endif

	#make Urza Nalmath water-phobic
	[object]
		silent=yes
		[filter]
			side=2
			canrecruit=1
		[/filter]
		[effect]
			apply_to=movement_costs
			replace=true
			[movement_costs]
				deep_water=99
				shallow_water=99
				swamp_water=99
			[/movement_costs]
		[/effect]
	[/object]
[/event]

[event]
	name=start

	[recall]
		description=Sir Gerrick
	[/recall]

	#ifdef EASY
		[recall]
			type=Royal Guard, Pikeman, Swordsman, Javelineer, Master Bowman, Longbowman
		[/recall]
		[recall]
			type=Royal Guard, Pikeman, Swordsman, Javelineer, Master Bowman, Longbowman
		[/recall]
	#endif
	#ifdef MEDIUM
		[recall]
			type=Royal Guard, Pikeman, Swordsman, Javelineer, Master Bowman, Longbowman
		[/recall]
	#endif

	[message]
		speaker=Deoran
		message= _ "Look!  There is smoke coming from Westin.  That can only mean that bandits have overrun the garrison and are sacking the city!"
	[/message]
	[message]
		speaker=Sir Gerrick
		message= _ "If too much time passes and they are unchecked, they will leave the city in ruins and make a great slaughter of all who live therein.  We must act quickly."
	[/message]
	[message]
		speaker=Urza Nalmath
		message= _ "What!?  If there are soldiers of Wesnoth coming from the northern forts, then my brother Mathin is surely dead...  They will pay for his death, just as Sir Loris paid for his pride!"
	[/message]

	[objectives]
		side=1
			[objective]
				description= _ "Take the Citadel at Westin before ten turns pass."
				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]

[/event]

# Someone from the South Guard reaches the citadel and holds it.

[event]
	name=moveto
	[filter]
		side=1
		x,y=22,16
	[/filter]

	{VARIABLE citadel_secured "yes"}
	# check if it is Deoran. If not, tell him to go to Westin
	[if]
		[have_unit]
			x,y=22,16
			[not]
				description=Deoran
			[/not]
		[/have_unit]
		[then]
			[message]
				speaker=unit
				message= _ "At last the citadel is secured."
			[/message]
			[message]
				speaker=Sir Gerrick
				message= _ "Now Deoran, take your post of command at the Citadel of Westin."
			[/message]
			[objectives]
				side=1
					[objective]
						description= _ "Bring Deoran to the Citadel of Westin."
						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]
		[/then]
	[/if]
[/event]

# Deoran arrives at the citadel

[event]
	name=moveto
	[filter]
		description=Deoran
		x,y=22,16
	[/filter]

	[unit]
		type=White Mage
		description=Minister Hylas
		profile=portraits/hylas.png
		user_description= _ "Minister Hylas"
		{IS_HERO}
		side=1
		x,y=21,16
		traits_description=_"loyal," + _"intelligent"
		[modifications]
			{SG_LOYAL}
			{SG_INTELLIGENT}
		[/modifications]
	[/unit]

	[message]
		speaker=Deoran
		image=portraits/deoran-mad.png
		message= _ "More bandits?!  They'll feel the deadly bite of my lance!"
	[/message]
	[message]
		speaker=Minister Hylas
		message= _ "Peace! for I am no enemy.  I am Minister Hylas, advisor to Sir Loris!  You came just in time!  We couldn't have held them off another day..."
	[/message]
	[message]
		speaker=Deoran
		message= _ "Indeed, our arrival was timely.  But where is Sir Loris?  Where is the garrison of the city?  I was sent by Haldric to relieve him and take command of the South Guard, for the king has heard no news from Westin in two months."
	[/message]
	[message]
		speaker=Minister Hylas
		message= _ "Alas, Sir Loris will find no relief now.  He is buried northwest of the city where he fell.  For weeks we warned him of the new power of these bandits.  And yet he would never lead his men against them until their strength had waxed and ours waned."
	[/message]
	[message]
		speaker=Deoran
		image=portraits/deoran-sad.png
		message= _ "It grieves me to learn of his death, foolish though he may have been!  Now, though, there are more pressing matters.  Rise men of Wesnoth!  We must drive these bandits from our city!"
	[/message]

	{SG_UNIT Peasant (Ufes) (_"Ufes") 1 18 15}
	{SG_UNIT Peasant (Joran) (_"Joran") 1 18 16}
	{SG_UNIT Peasant (Makees) (_"Makees") 1 19 18}
	{SG_UNIT Peasant (Tyborg) (_"Tyborg") 1 20 18}

	[message]
		speaker=Ufes
		message= _ "We will do our best to hold the city - you lead your men across the river and kill the bandit leader!"
	[/message]

	[objectives]
		side=1
			[objective]
				description= _ "Kill Urza Nalmath, the bandit leader."
				condition=win
			[/objective]
			[objective]
				description= _ "Death of Deoran"
				condition=lose
			[/objective]
			[objective]
				description= _ "Death of Sir Gerrick"
				condition=lose
			[/objective]
			[objective]
				description= _ "Death of Minister Hylas"
				condition=lose
			[/objective]
			[objective]
				description= _ "Time runs out"
				condition=lose
			[/objective]
	[/objectives]

	[allow_recruit]
		side=2
		#ifdef EASY
			type=Walking Corpse
		#endif
		#ifdef MEDIUM
			type=Walking Corpse, Skeleton, Vampire Bat
		#endif
		#ifdef HARD
			type=Skeleton, Skeleton Archer, Vampire Bat, Blood Bat
		#endif
	[/allow_recruit]

	[disallow_recruit]
		side=2
		#ifdef EASY
			type=Thief
		#endif
		#ifdef MEDIUM
			type=Thug, Thief, Poacher
		#endif
		#ifdef HARD
			type=Thug, Thief, Poacher, Trapper
		#endif
	[/disallow_recruit]

	[gold]
		side=2
		amount={15 30 60}
	[/gold]

[/event]

# Deoran is too late.

[event]
	name=turn 9
	[if]
		[variable]
			name=citadel_secured
			not_equals="yes"
		[/variable]
		[then]
			[message]
				speaker=Sir Gerrick
				message= _ "They are almost to the great hall!  Hurry, Deoran!  You must reach the citadel or all will be lost!"
			[/message]

			{PUT_IMG (items/gohere.png) 22 16}

			#ifdef EASY
				[message]
					speaker=narrator
					message= _ "You must move Deoran here by the end of the next turn, or Westin will fall and you will be defeated!"
				[/message]
			#endif
		[/then]
	[/if]

[/event]

[event]
	name=turn 10
	[if]
		[variable]
			name=citadel_secured
			not_equals="yes"
		[/variable]
		[then]
			[message]
				speaker=Sir Gerrick
				message= _ "We're too late!  They're burning the city..."
			[/message]
			[message]
				speaker=Deoran
				image=portraits/deoran-sad.png
				message= _ "Westin has fallen!  This is a problem too great for me to handle - I must return to Haldric and tell him of our loss..."
			[/message]

			[endlevel]
				result=defeat
			[/endlevel]
		[/then]
	[/if]

[/event]


# The undead attack

[event]
	name=recruit
	[filter]
		type=Skeleton, Skeleton Archer, Vampire Bat, Blood Bat, Walking Corpse
	[/filter]

	[scroll_to_unit]
		race=undead
	[/scroll_to_unit]

	[message]
		speaker=Urza Nalmath
		message= _ "Now the Guard will feel the wrath of my new friends!  It is time for the dead to wage war!  Rise warriors!"
	[/message]

	[message]
		speaker=Sir Gerrick
		message= _ "What devilry is this?!  Those are no living men that fight for him!"
	[/message]
	[message]
		speaker=Minister Hylas
		message= _ "He has made some pact with the undead - how could a mere brigand have gained such great powers?"
	[/message]
	[message]
		speaker=Deoran
		message= _ "However he has done this fell thing, we must defeat him!"
	[/message]

	#ifdef EASY
		[message]
			speaker=narrator
			image="human-magi/white-mage-magic-1.png~TC(1,magenta)"
			message= _ "Not only will Minister Hylas's Holy attack melt undead bones, but he can also heal wounded units near him."
		[/message]
	#endif

	[scroll_to_unit]
		race=undead
	[/scroll_to_unit]

[/event]

# Pillaging and burning the villages near Westin

[event]
	name=capture
	[filter]
		side=2
		race=human
	[/filter]

	first_time_only=no

	[message]
		speaker=Urza Nalmath
		message= _ "Leave nothing standing!  Burn their villages down and kill them all!"
	[/message]
	[message]
		speaker=unit
		message= _ "We will avenge your brother's death!"
	[/message]
	[message]
		speaker=Sir Gerrick
		message= _ "They are burning our villages!  We must stop them!"
	[/message]

	{PUT_IMG (misc/trash.png) $x1 $y1}

	{SG_CHANGE_TERRAIN $x1 $y1 d}

	[gold]
		side=2
		amount=10
	[/gold]

[/event]

# Victory

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

	[message]
		speaker=unit
		message= _ "My brother has died unavenged!  What have we done!?"
	[/message]

	[message]
		speaker=second_unit
		message= _ "Commander, how can a bandit have summoned undead?"
	[/message]

	[message]
		speaker=Minister Hylas
		message= _ "Just before the bandit raids began, an ambassador came to Sir Loris from the elves of the wood west of here.  He asked that a knight be sent to discuss a new threat to Wesnoth."
	[/message]

	[message]
		speaker=Deoran
		message= _ "And did Sir Loris go to the elves?"
	[/message]

	[message]
		speaker=Minister Hylas
		message= _ "No.  He suspected the elves of some trickery and made no reply to them.  Perhaps they know the origin of these dead warriors we now face."
	[/message]

	[message]
		speaker=Deoran
		message= _ "My men have been trained to fight the living.  I do not know that we can protect the city from foes so dark as these.  I shall go meet the elves and see if they can be of any aid!"
	[/message]

	[message]
		speaker=Minister Hylas
		message= _ "I will accompany you, my lord.  I have studied the arts of holy magic and my skill may be of some use against the dark ones."
	[/message]

	[message]
		speaker=narrator
		message= _ "Deoran sent a rider to request mounted reinforcements and set out at once towards the western forest..."
	[/message]

	{CLEAR_VARIABLE citadel_secured}

[/event]

[/scenario]
