global Map =
{
	Holy_Documents 					= 	"MAP_FLAG_cross_docs",
	Holy_Documents_cappoint			= 	"MAP_CAPPOINT_Holy_Documents",

	Generator_Flag 					= 	"CHECKPOINT_generator_spawn_flag",

	Destroy_Generator_Controls		= 	"MAP_DYNAMITE_TARGET_generator_controls",
	Destroy_Castle_Wall				= 	"MAP_DYNAMITE_TARGET_castle_wall",
	Destroy_Dracula_Chest			= 	"MAP_DYNAMITE_TARGET_dracula_chest",
	
	Build_Castle_Wall				= 	"MAP_CONSTRUCTION_castle_wall",	
	
	Holy_Docs_Status = 0,
	Generator_Status = 0,

	Generator_Flag_status = 0,
	
	Castle_Wall_Status = 0,
	
	Dracula_Chest_Dynamites = 0,



	Allies_Capture_Flag = function( trigger )
	{
		Map.Generator_Flag_status = 1;
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Generator_Flag );
		SetAvailableMapGoals( TEAM.AXIS  , true , Map.Generator_Flag );
		Util.ResetGoals();
		print( "Allies_Capture_Flag" );
	},
	Axis_Capture_Flag = function( trigger )
	{
		Map.Generator_Flag_status = 0;
		SetAvailableMapGoals( TEAM.ALLIES, true , Map.Generator_Flag );
		SetAvailableMapGoals( TEAM.AXIS  , false, Map.Generator_Flag );
		Util.ResetGoals();
		print( "Axis_Capture_Flag" );
	},

	Generator_Controls_Destroyed = function( trigger )
	{
		Map.Generator_Status = 1;
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Destroy_Generator_Controls );
		if( Map.Holy_Docs_Status == 1 )
			{
			SetAvailableMapGoals( TEAM.ALLIES, true , Map.Generator_Flag );
			SetAvailableMapGoals( TEAM.AXIS  , true , Map.Generator_Flag );
			}
		SetAvailableMapGoals( TEAM.ALLIES, true , Map.Destroy_Castle_Wall );
		SetAvailableMapGoals( TEAM.ALLIES, true , Map.Destroy_Dracula_Chest );
		
		
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Generator_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true , "DEFEND_Castle_Defend.*" );
		SetAvailableMapGoals( TEAM.AXIS  , false, "DEFEND_Generator_.*" );
		SetAvailableMapGoals( TEAM.AXIS  , true , "DEFEND_Castle_Defend.*" );
		SetAvailableMapGoals( TEAM.AXIS  , true , "PLANT_MINE_GOAL_Castle_Wall_.*" );
		Util.ResetGoals();
		print( "Generator_Controls_Destroyed" );
	},



	Documents_Stolen = function( trigger )
	{
		Map.Holy_Docs_Status = 0;
		SetAvailableMapGoals( TEAM.ALLIES, false, "MAP_FLAG_cross_docs" );
		SetAvailableMapGoals( TEAM.ALLIES, true , "MAP_CAPPOINT_Holy_Documents" );
		SetAvailableMapGoals( TEAM.AXIS  , false, "DEFEND_Generator_.*" );
		SetAvailableMapGoals( TEAM.AXIS  , false, "DEFEND_Holy_Documents_.*" );
		SetAvailableMapGoals( TEAM.AXIS  , true , "DEFEND_Holy_Documents_cappoint_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Generator_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Holy_Documents_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true , "DEFEND_Holy_Documents_cappoint_.*" );
		Util.ResetGoals();
		print( "Documents_Stolen" );
	},
	Documents_Returned = function( trigger )
	{
		Map.Holy_Docs_Status = -1;
		SetAvailableMapGoals( TEAM.ALLIES, true , "MAP_FLAG_cross_docs" );
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Holy_Documents_cappoint );
		SetAvailableMapGoals( TEAM.AXIS  , true , "DEFEND_Generator_.*" );
		SetAvailableMapGoals( TEAM.AXIS  , true , "DEFEND_Holy_Documents_.*" );
		SetAvailableMapGoals( TEAM.AXIS  , false, "DEFEND_Holy_Documents_cappoint_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true , "DEFEND_Generator_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true , "DEFEND_Holy_Documents_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Holy_Documents_cappoint_.*" );
		Util.ResetGoals();
		print( "Documents_Returned" );
	},
	Documents_Captured = function( trigger )
	{
		Map.Holy_Docs_Status = 1;
		SetAvailableMapGoals( TEAM.ALLIES, false, "MAP_FLAG_cross_docs" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "MAP_CAPPOINT_Holy_Documents" );
		if( Map.Generator_Status == 1 )
			{
			SetAvailableMapGoals( TEAM.ALLIES, true , Map.Generator_Flag );
			SetAvailableMapGoals( TEAM.AXIS  , true , Map.Generator_Flag );
			}
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Holy_Documents_.*" );
		SetAvailableMapGoals( TEAM.AXIS  , false, "DEFEND_Holy_Documents_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true , "DEFEND_Generator_.*" );
		SetAvailableMapGoals( TEAM.AXIS  , true , "DEFEND_Generator_.*" );
		Util.ResetGoals();
		print( "Documents_Captured" );
	},
	
	
	Castle_Wall_Built = function( trigger )
	{
		Map.Castle_Wall_Status = 0;
		SetAvailableMapGoals( TEAM.ALLIES, true , Map.Destroy_Castle_Wall );
		SetAvailableMapGoals( TEAM.AXIS  , false, Map.Build_Castle_Wall );
		Util.ResetGoals();
		print( "Castle_Wall_Built" );
	},
	Castle_Wall_Destroyed = function( trigger )
	{
		Map.Castle_Wall_Status = 1;
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Destroy_Castle_Wall );
		SetAvailableMapGoals( TEAM.AXIS  , true , Map.Build_Castle_Wall );
		Util.ResetGoals();
		print( "Castle_Wall_Destroyed" );
	},
	
	
	Dracula_Chest_Planted = function( trigger )
	{
		Map.Dracula_Chest_Dynamites += 1;
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Generator_Flag );
		SetAvailableMapGoals( TEAM.AXIS  , false, Map.Generator_Flag );
		
		Util.ResetGoals();
		print( "Castle_Wall_Built" );
	},
	Dracula_Chest_Defused = function( trigger )
	{
		Map.Dracula_Chest_Dynamites -= 1;
		if(Dracula_Chest_Dynamites == 0)
			{
			SetAvailableMapGoals( TEAM.ALLIES, true , Map.Generator_Flag );
			SetAvailableMapGoals( TEAM.AXIS  , true , Map.Generator_Flag );
			Util.ResetGoals();
			}
		print( "Castle_Wall_Destroyed" );
	},

};


global OnMapLoad = function()
{
	OnTrigger( "Allies have stolen Allies Holy Documents!"	, Map.Documents_Stolen );
	OnTrigger( "Axis have returned Allies Holy Documents!"	, Map.Documents_Returned );
	OnTrigger( "Holy Documents delivered!"					, Map.Documents_Captured );
	
	OnTrigger( "Generator has been destroyed!"				, Map.Generator_Controls_Destroyed );

	OnTrigger( "Allied captured generator spawn!"			, Map.Allies_Capture_Flag );
	OnTrigger( "Axis captured generator spawn!"				, Map.Axis_Capture_Flag );

	OnTrigger( "Axis team has built Castle wall."			, Map.Castle_Wall_Built );
	OnTrigger( "Allies team has destroyed the Castle wall!"	, Map.Castle_Wall_Destroyed );
	
	OnTrigger( "Planted at Dracula chest."					, Map.Dracula_Chest_Planted );
	OnTrigger( "Defused at Dracula chest."					, Map.Dracula_Chest_Defused );

	// Max users per goal
	Util.SetMaxUsersAttacking( 1, Map.Generator_Flag );
	Util.SetMaxUsersAttacking( 1, "ATTACK_Attack.*" );
	Util.SetMaxUsersDefending( 1, "DEFEND_Defend.*" );
	//Util.SetMaxUsersInProgress( 0, "MAP_MOUNTABLE_MG42_.*" );

	// Allied goals
	SetBiasGoals( 1.5, Map.Holy_Documents );
	SetBiasGoals( 1.3, Map.Destroy_Generator_Controls );
	
	SetBiasGoals( 1.4, Map.Destroy_Dracula_Chest );
	SetBiasGoals( 1.3, Map.Generator_Flag );
	SetBiasGoals( 1.3, Map.Destroy_Castle_Wall );
	SetAvailableMapGoals( TEAM.ALLIES, false, ".*" );

	SetAvailableMapGoals( TEAM.ALLIES, true , Map.Holy_Documents );
	SetAvailableMapGoals( TEAM.ALLIES, true , Map.Destroy_Generator_Controls );
	SetAvailableMapGoals( TEAM.ALLIES, true , "DEFEND_Holy_Documents.*" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Holy_Documents_cappoint_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, true , "MAP_SNIPER_SPOT_Snipe_.*" );
	
	SetAvailableMapGoals( TEAM.ALLIES, true , "HEALTH_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "HEALTH_CABINET_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, true , "AMMO_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "AMMO_CABINET_.*" );
	
	// Axis goals
	SetBiasGoals( 1.4, Map.Generator_Flag );
	
	SetBiasGoals( 1.5, "DEFEND_Holy_Documents_.*");
	SetBiasGoals( 1.5, "DEFEND_Holy_Documents_cappoint_.*");
	SetBiasGoals( 1.3, "DEFEND_Generator_.*");
	SetBiasGoals( 1.5, "DEFEND_Castle_Defend.*");
	SetBiasGoals( 1.2, "PLANT_MINE_GOAL_.*");
	SetAvailableMapGoals( TEAM.AXIS  , false, ".*" );

	SetAvailableMapGoals( TEAM.AXIS  , true , "DEFEND_Holy_Documents_.*" );
	SetAvailableMapGoals( TEAM.AXIS  , false, "DEFEND_Holy_Documents_cappoint_.*" );
	SetAvailableMapGoals( TEAM.AXIS  , true , "DEFEND_Generator_.*" );
	
	SetAvailableMapGoals( TEAM.AXIS  , true , "HEALTH_.*" );
	SetAvailableMapGoals( TEAM.AXIS  , false, "HEALTH_CABINET_.*" );
	SetAvailableMapGoals( TEAM.AXIS  , true , "AMMO_.*" );
	SetAvailableMapGoals( TEAM.AXIS  , false, "AMMO_CABINET_.*" );

	
// 37: ROUTE_Allied_Spawn_1 -> 0011 serial 20 bias 1.00
// 38: ROUTE_Allied_Spawn_2 -> 0011 serial 21 bias 1.00
// 39: ROUTE_Between_Houses -> 0011 serial 38 bias 1.00
// 40: ROUTE_Castle_2nd_Floor_Left -> 0011 serial 57 bias 1.00
// 41: ROUTE_Castle_2nd_Floor_Right -> 0011 serial 58 bias 1.00
// 42: ROUTE_Castle_Broken_Wall -> 0011 serial 56 bias 1.00
// 43: ROUTE_Castle_Front -> 0011 serial 60 bias 1.00
// 44: ROUTE_Castle_Left -> 0011 serial 59 bias 1.00
// 45: ROUTE_Castle_Stairs -> 0011 serial 53 bias 1.00
// 46: ROUTE_Center -> 0011 serial 26 bias 1.00
// 47: ROUTE_Cewer -> 0011 serial 61 bias 1.00
// 48: ROUTE_Church_Back -> 0011 serial 39 bias 1.00
// 49: ROUTE_Church_Front -> 0011 serial 43 bias 1.00
// 50: ROUTE_Church_Left -> 0011 serial 42 bias 1.00
// 51: ROUTE_Church_Left_Back -> 0011 serial 41 bias 1.00
// 52: ROUTE_Church_Right -> 0011 serial 34 bias 1.00
// 53: ROUTE_Church_Right_Back -> 0011 serial 40 bias 1.00
// 54: ROUTE_Church_Spawn_1 -> 0011 serial 35 bias 1.00
// 55: ROUTE_Church_Spawn_2 -> 0011 serial 44 bias 1.00
// 56: ROUTE_Generator_Spawn_1 -> 0011 serial 52 bias 1.00
// 57: ROUTE_Generator_Spawn_2 -> 0011 serial 51 bias 1.00
// 58: ROUTE_Left -> 0011 serial 25 bias 1.00
// 59: ROUTE_Near_Well -> 0011 serial 31 bias 1.00
// 60: ROUTE_Over_Wall -> 0011 serial 30 bias 1.00
// 61: ROUTE_Right -> 0011 serial 22 bias 1.00
// 62: ROUTE_Roof -> 0011 serial 45 bias 1.00
// 63: ROUTE_Roof_Church -> 0011 serial 47 bias 1.00
// 64: ROUTE_Roof_Left -> 0011 serial 46 bias 1.00
// 65: ROUTE_Roof_Right -> 0011 serial 48 bias 1.00
// 66: ROUTE_Well -> 0011 serial 50 bias 1.00
	
	
    // MapRoutes =
    // {
	// MAP_FLAG_cross_docs =
		// {
		// ROUTE_Allied_Spawn_1 =
			// {
			// ROUTE_Left =
				// {
				// ROUTE_Well =
					// {
					// },
				// },
			// ROUTE_Center =
				// {
				// },
			// ROUTE_Right =
				// {
				// },
			// ROUTE_Roof =
				// {
				// ROUTE_Roof_Right =
					// {
					// },
				// },
			// },
		// ROUTE_Allied_Spawn_2 =
			// {
			// ROUTE_Left =
				// {
				// ROUTE_Well =
					// {
					// },
				// },
			// ROUTE_Center =
				// {
				// },
			// ROUTE_Right =
				// {
				// },
			// ROUTE_Roof =
				// {
				// ROUTE_Roof_Right =
					// {
					// },
				// },
			// },
		// },
	// MAP_CAPPOINT_Holy_Documents =
		// {
		// ROUTE_Right =
			// {
			// ROUTE_Center =
				// {
				// ROUTE_Church_Back =
					// {
					// },
				// },
			// ROUTE_Roof =
				// {
				// ROUTE_Roof_Left =
					// {
					// ROUTE_Roof_Church =
						// {
						// },
					// },
				// },
			// },
		// ROUTE_Near_Well =
			// {
			// },
		// ROUTE_Between_Houses =
			// {
			// },
		// },
	// MAP_DYNAMITE_TARGET_generator_controls =
		// {
		// ROUTE_Church_Spawn_1 =
			// {
			// ROUTE_Church_Left =
				// {
				// },
			// ROUTE_Church_Front =
				// {
				// },
			// ROUTE_Church_Right =
				// {
				// Weight = 10,
				// },
			// },
		// ROUTE_Church_Spawn_2 =
			// {
			// ROUTE_Church_Left =
				// {
				// },
			// ROUTE_Church_Front =
				// {
				// },
			// ROUTE_Church_Right =
				// {
				// Weight = 10,
				// },
			// },
		// },
	// MAP_DYNAMITE_TARGET_dracula_chest =
		// {
		// ROUTE_Castle_2nd_Floor_Left =
			// {
			// },
		// ROUTE_Castle_2nd_Floor_Right =
			// {
			// },
		// },
    // };

	// Util.Routes(MapRoutes);
	print( "All done! xD" );
};

global OnBotJoin = function( bot )
{
	bot.TargetBreakableDist = 100.0;
	team = bot.GetTeam();
	class = bot.GetClass();
	
	if( team == TEAM.ALLIES && class != CLASS.ENGINEER)
	{
		if(RandInt(0,1)<1)
		{
			bot.ChangeSpawnPoint(4); 
		}
	}
	
	if ( class == CLASS.SOLDIER )
	{
		bot.SetGoalProperty("ATTACK", "MinCampTime", 9999);
		bot.SetGoalProperty("ATTACK", "MaxCampTime", 9999);
		
		if ( team == TEAM.AXIS )
		{
			bot.SetGoalProperty("DEFEND", "MinCampTime", 9999);
			bot.SetGoalProperty("DEFEND", "MaxCampTime", 9999);
			bot.SetGoalProperty("GET_HEALTH", "Bias", 0.1);
			bot.SetGoalProperty("HEALTH_CABINET", "Bias", 0.0);
		}
	}
	
	if ( class == CLASS.MEDIC )
	{
		bot.SetGoalProperty("ATTACK", "MinCampTime", 9999);
		bot.SetGoalProperty("ATTACK", "MaxCampTime", 9999);
	}
	
	if ( class == CLASS.ENGINEER )
	{
		bot.SetGoalProperty("ATTACK", "MinCampTime", 9999);
		bot.SetGoalProperty("ATTACK", "MaxCampTime", 9999);
		
		if ( team == TEAM.AXIS )
		{
			bot.SetGoalProperty("DEFEND", "MinCampTime", 9999);
			bot.SetGoalProperty("DEFEND", "MaxCampTime", 9999);
			bot.SetGoalProperty("GET_HEALTH", "Bias", 0.6);
		}
	}

	if ( class == CLASS.FIELDOPS )
	{
		bot.SetGoalProperty("ATTACK", "MinCampTime", 9999);
		bot.SetGoalProperty("ATTACK", "MaxCampTime", 9999);
		
		if ( team == TEAM.AXIS )
		{
			bot.SetGoalProperty("DEFEND", "MinCampTime", 9999);
			bot.SetGoalProperty("DEFEND", "MaxCampTime", 9999);
			bot.SetGoalProperty("GET_HEALTH", "Bias", 0.2);
		}
	}

	if ( class == CLASS.COVERTOPS )
	{
		if ( team == TEAM.AXIS )
		{
			bot.SetGoalProperty("DEFEND", "MinCampTime", 9999);
			bot.SetGoalProperty("DEFEND", "MaxCampTime", 9999);
			bot.SetGoalProperty("GET_HEALTH", "Bias", 0.2);
		}
	}
};