//==========================================================================================
//
//	heli_m1.gm
//
//	Who  	When		What
//------------------------------------------------------------------------------------------
//	^4Tardis	07 June 2014	Initial Script
//
//==========================================================================================
//

global Map =
{
	Debug = 0, // please set to zero before distributing your script
	ShowMovers = false,

	Documents_Fence_Dyno = 0,
	constructible_ladder_Dyno = 0,
	plantare_dd_Dyno = 0,
	tank_barrier2_Dyno = 0,
	tank_barrier3_Dyno = 0,
	FlagStatus = 0, //no team owns it initially
	

	minicp_Built = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "minicp_Built" );
	},

	Documents_Fence_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Documents_Fence_Dyno += 1;
		Util.MapDebugPrint( "Documents_Fence_Planted" );
	},

	Documents_Fence_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Documents_Fence_Dyno -= 1;
		Util.MapDebugPrint( "Documents_Fence_Defused" );
	},

	Documents_Fence_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Documents_Fence_Dyno = 0;

		Util.MapDebugPrint( "Documents_Fence_Destroyed" );
	},

	minicp_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "minicp_Destroyed" );
	},
	
	access_codes_Taken = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "access_codes_Taken" );
	},

	access_codes_Returned = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "access_codes_Returned" );
	},

	access_codes_Secured = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "access_codes_Secured" );
	},

	castletop_flag_Axis_Captured = function( trigger )
	{
		if ( TestMap )
			{ return; }
		Map.FlagStatus = 1;
		
		Util.MapDebugPrint( "castletop_flag_Axis_Captured" );
	},

	castletop_flag_Allies_Captured = function( trigger )
	{
		if ( TestMap )
			{ return; }
		Map.FlagStatus = 2;
		Util.MapDebugPrint( "castletop_flag_Allies_Captured" );
	},
	
	heliport = function( trigger )
	{
		if ( TestMap )
			{ return; }
		Util.DisableGoal( "CHECKPOINT.*", true );
		Util.MapDebugPrint( "heliport time_is_up" );
	},
};

global OnMapLoad = function()
{
	if ( TestMapOn )
		{ Util.AutoTestMap(); }

	// Register callback functions
	OnTrigger( "The allies CP has been constructed!", Map.minicp_Built );
	OnTrigger( "Planted at the Documents Fence.", Map.Documents_Fence_Planted );
	OnTrigger( "Defused at the Documents Fence.", Map.Documents_Fence_Defused );
	OnTrigger( "Document fence is destroyed!", Map.Documents_Fence_Destroyed );
	OnTrigger( "The allies CP has been destroyed!", Map.minicp_Destroyed );
	OnTrigger( "The Allies have stolen Documents", Map.access_codes_Taken );
	OnTrigger( "The Axis have retrieved Documents", Map.access_codes_Returned );
	OnTrigger( "Allies win!", Map.access_codes_Secured );
	OnTrigger( "Axis Have Control of the Heliport Flag!", Map.castletop_flag_Axis_Captured );
	OnTrigger( "Allies Have Taken The Control of the Heliport!", Map.castletop_flag_Allies_Captured );
	OnTrigger( "Allies captured the Heliport^1!!", Map.heliport );

	//~Util.DisableGoal( ".*", true ); // all but routes
	//~SetAvailableMapGoals( TEAM.AXIS, true, "ATTACK_.*" );
	//~SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_.*" );
	// Max users per goal
	//Util.SetMaxUsers( 1, "DEFEND_.*" );
	//Util.SetMaxUsers( 1, "GRENADE_.*" );
	//Util.SetMaxUsers( 1, "MOUNTMG42_.*" );
	Util.DisableGoal( "MOBILEMG42_.*", true );

	SetAvailableMapGoals( TEAM.AXIS, false, "MOBILEMG42_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "MOBILEMG42_.*" );
	
	
	// Camp times
	SetMapGoalProperties( "MOUNTMG42_.*", {MinCampTime=0, MaxCampTime=0} );
	SetMapGoalProperties( "MOBILEMG42_.*", {MinCampTime=10, MaxCampTime=60} );

	Util.SetMaxUsers( 0, "MOUNTMG42_.*" );


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

global OnBotJoin = function( bot )
{
	// Uncomment for shootable breakables
	bot.TargetBreakableDist = 90.0;
	// Only set MaxViewDistance on maps with limited sight (e.g. fog)
	bot.MaxViewDistance = 2400;
};

global InitializeRoutes = function()
{
	MapRoutes =
	{
		PLANT_plantare_dd =
		{
		},
		PLANT_tank_barrier2 =
		{
		},
		PLANT_tank_barrier3 =
		{
		},
		BUILD_tank_barrier3 =
		{
		},
		BUILD_toblocada =
		{
		},
		BUILD_alta_reparare =
		{
		},
		BUILD_alta_reparare_da =
		{
		},
		BUILD_blocaduta =
		{
		},
		BUILD_repararea_reparare =
		{
		},
		BUILD_penblocada =
		{
		},
		BUILD_tank_barrier2 =
		{
		},
		BUILD_minicp =
		{
		},
		CHECKPOINT_castletop_flag =
		{
		},
		BUILD_constructible_ladder =
		{
		},
		PLANT_constructible_ladder =
		{
		},
		FLAG_access_codes =
		{
		},
		PLANT_Documents_Fence =
		{
		},
	};
	Util.Routes(MapRoutes);
};
