"S6L1_finish.sce"
{
	INT joan_recno
	INT charlies_recno
	INT alencon_recno

	INT sector_six_farmland_place

	init 
	{
		joan_recno = FUNC("search_unit_by_name", "Jeanne d'Arc") 
		charlies_recno = FUNC("search_unit_by_name", "Karl VII")
		alencon_recno = FUNC("search_unit_by_name", "Herzog von Alençon")

		sector_six_farmland_place = FUNC("search_place_by_name", "S6L1_6_Farmland_Place")
	}

// ********* Main Goal ******
// *** 1 *****
	// Capture Auxerre

// *** 2 *****
	// Capture Troyes

// *** 3 ****
	// Capture Chalons

// *** 4 ****
	// Defeat William de la Pole and Jean de Luxembourg

// ********* Lose Goal *********

// *** 5 ****
	// Joan defeat
	if ( FUNC("get_end_condition_finish", 5) == 0 )
	{
		if ( FUNC("is_unit_dead", joan_recno) == 1)
		{
			if( FUNC("get_scenario_bit_flag", 9) == 1 )
			{
				WAIT{ FUNC("pause_script", 2000) }
				FUNC("show_ending", 1)
				//WAIT{ FUNC("pause_script", 10000) }	
			}
			else
			{
				FUNC("call_gameover_msg", "[0001N]Alas you have failed in your attempt to safely escort the future king of France to the coronation!")
				WAIT{ FUNC("pause_script", 4000) }	
				FUNC("set_end_condition_finish" , 5, "LOSE")
			}
		}
	}

// *** 6 ****
	// Charlies defeat
	if ( FUNC("get_end_condition_finish", 6) == 0 )
	{
		if ( FUNC("is_unit_dead", charlies_recno) == 1)
		{
			FUNC("call_gameover_msg", "[0002N]You have failed in your attempt to safely escort the future king of France to the coronation!")
			WAIT{ FUNC("pause_script", 4000) }	
			FUNC("set_end_condition_finish" , 6, "LOSE")	
		}
	}

// *** 9 ****
	// Alencon defeat
	if ( FUNC("get_end_condition_finish", 9) == 0 )
	{
		if ( FUNC("is_unit_dead", alencon_recno) == 1)
		{
			FUNC("call_gameover_msg", "[0003N]Duke of Alencon has been slain in battle - you have failed to keep the Duke of Alencon alive throughout the mission!")
			WAIT{ FUNC("pause_script", 4000) }	
			FUNC("set_end_condition_finish" , 9, "LOSE")	
		}
	}

// *** 10 ****
	// clear the enemies in farmland
	if ( FUNC("get_end_condition_finish", 10) == 0 )
	{
		if( FUNC("people_by_nation_exist_in_place", sector_six_farmland_place, "ENGLISH") == 0 )
		{
			FUNC("set_territory_nation", "Sézanne-sur-Champagne", "French")
			FUNC("set_end_condition_finish", 10, "WIN")
			FUNC("attention_call_message", "[0004N]You have eliminated all the enemies in Sézanne-sur-Champagne!")
			FUNC("add_reputation", 3)
			FUNC("attention_call_message", FUNC("format_string", "[0005N]Charles VII's reputation has increased by %1d as a result of your success!", 3) )
			FUNC("set_minimap_icon_display_enable", "etown_s6l6", 0)
			FUNC("set_minimap_icon_display_enable", "ftown_s6l6", 1)
		}
	}

// *** 11 ***
	if ( FUNC("get_end_condition_finish", 11) == 0 )
	{
		if( FUNC("get_reputation") > 79 )
		{
			FUNC("set_end_condition_finish", 11, "WIN")
		}
	}

// *** 12 ***
	if ( FUNC("get_end_condition_finish", 12) == 0 )
	{
		if( FUNC("get_reputation") > 89 )
		{
			FUNC("set_end_condition_finish", 12, "WIN")
		}
	}


	exit
}
