//==========================================================================================
//
//	country_road_jp.gm
//
//	Who	When		What
//------------------------------------------------------------------------------------------
//	d00d	29 January 2013	Improved waypoints, added this script
//	theMaker	August 2012	Waypoints
//
//==========================================================================================
//

global Map =
{
	Allied_Gold_Taken = function()
	{
		SetAvailableMapGoals( TEAM.AXIS, true, "ATTACK_axiscap.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_axiscap.*" );
		Util.MapDebugPrint( "Allied_Gold_Taken" );
	},

	Axis_Gold_Taken = function()
	{
		SetAvailableMapGoals( TEAM.AXIS, true, "ATTACK_alliescap.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_alliescap.*" );
		Util.MapDebugPrint( "Axis_Gold_Taken" );
	},

	Allied_Gold_Returned = function()
	{
		SetAvailableMapGoals( TEAM.AXIS, false, "ATTACK_axiscap.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_axiscap.*" );
		Util.MapDebugPrint( "Allied_Gold_Returned" );
	},

	Axis_Gold_Returned = function()
	{
		SetAvailableMapGoals( TEAM.AXIS, false, "ATTACK_alliescap.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_alliescap.*" );
		Util.MapDebugPrint( "Axis_Gold_Returned" );
	},

	Allied_Gold_Secured = function()
	{
		Util.MapDebugPrint( "Allied_Gold_Secured" );
	},

	Axis_Gold_Secured = function()
	{
		Util.MapDebugPrint( "Axis_Gold_Secured" );
	},

	lake_flag_Axis_Captured = function()
	{
		Util.RandomSpawn( TEAM.AXIS, 5 );
		Util.MapDebugPrint( "lake_flag_Axis_Captured" );
	},

	lake_flag_Allies_Captured = function()
	{
		Util.RandomSpawn( TEAM.ALLIES, 5 );
		Util.MapDebugPrint( "lake_flag_Allies_Captured" );
	},

	school_flag_Axis_Captured = function()
	{
		Util.RandomSpawn( TEAM.AXIS, 3 );
		Util.MapDebugPrint( "school_flag_Axis_Captured" );
	},

	school_flag_Allies_Captured = function()
	{
		Util.RandomSpawn( TEAM.ALLIES, 3 );
		Util.MapDebugPrint( "school_flag_Allies_Captured" );
	},

	shintoshrine_flag_Axis_Captured = function()
	{
		Util.RandomSpawn( TEAM.AXIS, 4 );
		Util.MapDebugPrint( "shintoshrine_flag_Axis_Captured" );
	},

	shintoshrine_flag_Allies_Captured = function()
	{
		Util.RandomSpawn( TEAM.ALLIES, 4 );
		Util.MapDebugPrint( "shintoshrine_flag_Allies_Captured" );
	},

};

global OnMapLoad = function()
{
	// Register callback functions
	OnTrigger( "Axis have stolen Allied Gold!", Map.Allied_Gold_Taken );
	OnTrigger( "Allies have stolen Axis Gold!", Map.Axis_Gold_Taken );
	OnTrigger( "Flag returned Gold2!", Map.Allied_Gold_Returned );
	OnTrigger( "Flag returned gold1!", Map.Axis_Gold_Returned );
	OnTrigger( "Axis have secured the Gold!", Map.Allied_Gold_Secured );
	OnTrigger( "Allies have secured the Gold!", Map.Axis_Gold_Secured );
	OnTrigger( "Axis captures the Lake Area!", Map.lake_flag_Axis_Captured );
	OnTrigger( "Allies capture the Lake Area!", Map.lake_flag_Allies_Captured );
	OnTrigger( "Axis captures the School Area!", Map.school_flag_Axis_Captured );
	OnTrigger( "Allies capture the School Area!", Map.school_flag_Allies_Captured );
	OnTrigger( "Axis captures the Shinto Shrine Area!", Map.shintoshrine_flag_Axis_Captured );
	OnTrigger( "Allies capture the Shinto Shrine Area!", Map.shintoshrine_flag_Allies_Captured );

	// Initial goal availability
	//~Util.DisableGoal( ".*", true ); // all but routes
	SetAvailableMapGoals( TEAM.AXIS, false, {
		"SNIPE_.*",
		"ATTACK_.*",
		"CAPPOINT_allies",
	});
	SetAvailableMapGoals( TEAM.ALLIES, false, {
		"SNIPE_.*",
		"ATTACK_.*",
		"CAPPOINT_axis",
	});

	// Max users per goal
	Util.SetMaxUsers( 3, "FLAG_.*" );
	Util.SetMaxUsers( 2, "CHECKPOINT_.*" );
	Util.SetMaxUsers( 1, "DEFEND_.*" );

	// Camp times
	SetMapGoalProperties( "ATTACK_.*", {MinCampTime=1, MaxCampTime=30} );
	SetMapGoalProperties( "SNIPE_.*", {MinCampTime=10, MaxCampTime=60} );
	SetMapGoalProperties( "MOBILEMG42_.*", {MinCampTime=10, MaxCampTime=60} );

	Util.MapDebugPrint( "Omni-bot map script for " + GetMapName() + " executed." );
};

global OnBotJoin = function( bot )
{
	bot.MaxViewDistance = 2600;
};

global InitializeRoutes = function()
{
	MapRoutes =
	{
		FLAG_gold1 =
		{
			ROUTE_allied_spawn =
			{
				ROUTE_center = {},
				ROUTE_north_east = {},
			}
		},
		FLAG_Gold2 =
		{
			ROUTE_axis_spawn =
			{
				ROUTE_center = {},
				ROUTE_north_east = {},
			}
		},
		CAPPOINT_allies =
		{
			ROUTE_axis_gold =
			{
				ROUTE_center = {},
				ROUTE_north_east = {},
			}
		},
		CAPPOINT_axis =
		{
			ROUTE_allied_gold =
			{
				ROUTE_center = {},
				ROUTE_north_east = {},
			}
		},
	};
	Util.Routes(MapRoutes);
};
