[scenario]
	id=8a_Vengeance
	#textdomain wesnoth-tsg

	name= _ "Vengeance"
	next_scenario=9a_Elf_Epilogue
	[music]
		name=main_menu.ogg
		ms_before=500
	[/music]
	[music]
		name=knolls.ogg
		ms_before=500
		append=yes
	[/music]


	map_data="{campaigns/The_South_Guard/maps/8a_Vengeance.map}"


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

	turns=-1
	victory_when_enemies_defeated=no


# The South Guard

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

	team_name=South_Guard
	controller=human
	{CUSTOM_SG_FLAG}


	{GOLD 125 100 80}
	{INCOME 4 2 0}

	fog=no
	shroud=no

	canrecruit=1
	recruit=Peasant, Bowman, Spearman, Cavalryman

	{SG_GUARD (Javelineer) (Westin Guard) (_"Westin Guard") 1 22 12}
	{SG_GUARD (Heavy Infantryman) (Westin Guard) (_"Westin Guard") 1 19 14}
	{SG_GUARD (Heavy Infantryman) (Westin Guard) (_"Westin Guard") 1 17 15}
	{SG_GUARD (Heavy Infantryman) (Westin Guard) (_"Westin Guard") 1 17 17}
	{SG_GUARD (Spearman) (Westin Guard) (_"Westin Guard") 1 16 19}
	{SG_GUARD (Spearman) (Westin Guard) (_"Westin Guard") 1 15 21}

[/side]

# The Enraged Elves

[side]
	side=2
	type=Elvish Marshal
	description=Ithelden
	user_description= _ "Ithelden"

	team_name=The_Enraged Elves
	controller=ai

	{GOLD 125 100 80}
	{INCOME 4 2 0}

	canrecruit=0
	[ai]
		passive_leader=yes
		aggression=0.0
		caution=1.0
		[target]
			description=Ethiliel
			value=2.0
		[/target]
	[/ai]
	[ai]
		passive_leader=yes
		time_of_day=dusk,first_watch,second_watch
		aggression=1.0
		caution=0
		grouping=no
	[/ai]
[/side]

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

		{VARIABLE sir_gerrick_store.canrecruit 0}
		{VARIABLE sir_gerrick_store.x 21}
		{VARIABLE sir_gerrick_store.y 16}

		[unstore_unit]
			variable=sir_gerrick_store
			find_vacant=yes
			[effect]
				apply_to=hitpoints
				heal_full=yes
			[/effect]
		[/unstore_unit]

		[store_unit]
			variable=deoran_store
			kill=yes
			[filter]
				description=Deoran
			[/filter]
		[/store_unit]

		[set_variable]
			name=deoran_store.hitpoints
			value=38
		[/set_variable]

		[set_variable]
			name=deoran_store.type
			value=Horseman Commander
		[/set_variable]

		[unstore_unit]
			variable=deoran_store
			find_vacant=yes
		[/unstore_unit]

		{CLEAR_VARIABLE deoran_store}

		[disallow_recruit]
			side=1
			type=Elvish Fighter, Elvish Shaman
		[/disallow_recruit]

		[message]
			speaker=Sir Gerrick
			message= _ "Commander! I took your message to the council, and your deeds have pleased them. Are the undead finally gone from our lands?"
		[/message]
		[message]
			speaker=Deoran
			message= _ "The undead are gone! Perhaps now there will be peace for a time in Westin. You have our thanks Lady Ethiliel."
		[/message]
		[message]
			speaker=Ethiliel
			message= _ "Though the undead are vanquished, they have brought us much sorrow. Deoran, your people have restored their honor. Let us part in peace."
		[/message]
		[message]
			speaker=Deoran
			message= _ "Indeed. Neither the bandits nor the undead will trouble us for some time. We will tend our wounds and you yours."
		[/message]
		[message]
			speaker=narrator
			message= _ "Help!"
		[/message]

		[scroll_to_unit]
			description=Ithelden
		[/scroll_to_unit]

		[message]
			speaker=narrator
			message= _ "Help!"
		[/message]
		[move_unit_fake]
			type=Peasant
			x= 1, 2, 2, 2, 3, 4
			y=11,11,12,13,14, 14
		[/move_unit_fake]
		[unit]
			type=Peasant
			description=Poor Farmer
			user_description= _ "Poor Farmer"
			side=2
			x=4
			y=14
		[/unit]
		[message]
			speaker=Ithelden
			message= _ "You must pay for killing Mebrin!"
		[/message]
		[message]
			speaker=Poor Farmer
			message= _ "I am just a farmer! What did I do?!"
		[/message]
		[message]
			speaker=Ithelden
			message= _ "What did you do?! Your people kidnapped and murdered our greatest leader! And now you will pay!"
		[/message]
		[colour_adjust]
			red=255
			green=0
			blue=0
		[/colour_adjust]
		[sound]
			name=human-die-1.ogg
		[/sound]
		[colour_adjust]
			red=0
			green=0
			blue=0
		[/colour_adjust]
		[kill]
			description=Poor Farmer
			fire_event=no
		[/kill]
		[message]
			speaker=Sir Gerrick
			message= _ "He just killed that innocent farmer! We must stop him!"
		[/message]
		[message]
			speaker=Ethiliel
			message= _ "Stop, Ithelden! I have traveled with these humans, and they are not the ones who harmed Mebrin. They are our allies!"
		[/message]
		[message]
			speaker=Ithelden
			message= _ "You too, Ethiliel? All these menfolk are the same! They fell trees to till the earth; now they have felled our leader! We cannot brook such deeds! You will die with them!"
		[/message]
		[music]
			name=revelation.ogg
		[/music]

		{SG_UNIT (Elvish Fighter) (Disciple of Mebrin) (_"Disciple of Mebrin") 2 3 17}
		{SG_UNIT (Elvish Fighter) (Disciple of Mebrin) (_"Disciple of Mebrin") 2 7 15}
		{SG_UNIT (Elvish Druid) (Disciple of Mebrin) (_"Disciple of Mebrin") 2 6 19}
		{SG_UNIT (Elvish Ranger) (Disciple of Mebrin) (_"Disciple of Mebrin") 2 8 15}
		{SG_UNIT (Elvish Druid) (Disciple of Mebrin) (_"Disciple of Mebrin") 2 4 22}
		{SG_UNIT (Elvish Hero) (Disciple of Mebrin) (_"Disciple of Mebrin") 2 6 23}
		{SG_UNIT (Elvish Rider) (Disciple of Mebrin) (_"Disciple of Mebrin") 2 11 13}

		[objectives]
			side=1
				[objective]
					description= _ "Keep the enraged elves from sacking Westin"
					condition=win
				[/objective]
				[objective]
					description= _ "Death of Deoran"
					condition=lose
				[/objective]
				[objective]
					description= _ "Death of Ethiliel"
					condition=lose
				[/objective]
		[/objectives]

	[/event]

	[event]
		name=die
		[filter]
			side=2
		[/filter]
		first_time_only=no

		[set_variable]
			name=how_many_elves
			random=1..6
		[/set_variable]
		[set_variable]
			name=number_of_elves
			value=1
		[/set_variable]

		[while]
			[variable]
				name=number_of_elves
				less_than=$how_many_elves
			[/variable]
			[do]
				[set_variable]
					name=unit_type
					random=Elvish Fighter,Elvish Archer,Elvish Ranger,Elvish Shaman,Elvish Druid,Elvish Hero,Elvish Avenger,Elvish Rider,Elvish Fighter,Elvish Archer,Elvish Shaman
				[/set_variable]
				[unit]
					type=$unit_type
					description=Disciple of Mebrin
					user_description= _ "Disciple of Mebrin"
					side=2
					x,y=1,12
				[/unit]
				[set_variable]
					name=number_of_elves
					add=1
				[/set_variable]
			[/do]
		[/while]

		[message]
			speaker=Disciple of Mebrin
			message= _ "For every one of us you strike down, more will rise!"
		[/message]
	[/event]

	[event]
		name=die
		[filter]
			side=1
		[/filter]
		[message]
			speaker=Ethiliel
			message= _ "We won't be able to hold them off for long. I should go reason with them! They won't dare attack me."
		[/message]
		[message]
			speaker=Deoran
			message= _ "Are you sure that the elves will greet you any more kindly than they have met us? After all, you did lead us into the forests..."
		[/message]
		[message]
			speaker=Ethiliel
			message= _ "Perhaps not, but it is your only hope. I must reach Ithelden!"
		[/message]

		{PLACE_IMAGE (items/gohere.png) 6 15}

		[objectives]
			side=1
				[objective]
					description= _ "Bring Ethiliel to the Great Tree and parlay with Ithelden"
					condition=win
				[/objective]
				[objective]
					description= _ "Death of Deoran"
					condition=lose
				[/objective]
		[/objectives]
	[/event]

	[event]
		name=die
		[filter]
			description=Ethiliel
		[/filter]

		[endlevel]
			result=continue_no_save
		[/endlevel]

	[/event]

	[event]
		name=moveto
		[filter]
			description=Ethiliel
			x=6
			y=15
		[/filter]

		[endlevel]
			result=continue_no_save
		[/endlevel]

	[/event]
[/scenario]
