//==========================================================================================
//
//	wwgn3203.gm
//
//	Who                    	When		What
//------------------------------------------------------------------------------------------
//	^1{WeB}^7*^4GA^1NG$^4TA^7*	19 January 2016	Initial Script
//
//==========================================================================================
//

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

	Allied_Command_Post_Dyno = 0,
	Axis_Command_Post_Dyno = 0,
	stone_tunnel_Dyno = 0,
	train_Dyno = 0,

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

		Util.MapDebugPrint( "Allied_Command_Post_Built" );
	},

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

		Util.MapDebugPrint( "Axis_Command_Post_Built" );
	},

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

		Map.Allied_Command_Post_Dyno += 1;
		Util.MapDebugPrint( "Allied_Command_Post_Planted" );
	},

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

		Map.Axis_Command_Post_Dyno += 1;
		Util.MapDebugPrint( "Axis_Command_Post_Planted" );
	},

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

		Map.stone_tunnel_Dyno += 1;
		Util.MapDebugPrint( "stone_tunnel_Planted" );
	},

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

		Map.train_Dyno += 1;
		Util.MapDebugPrint( "train_Planted" );
	},

		gate_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }
                
		SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Gate_1" );
	        SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Gate_2" );
	        SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Gate_3" );
	        SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Gate_4" );
	        SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Gate_5" );
		
		Util.MapDebugPrint( "gate_Planted" );
	},
	
	Allied_Command_Post_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Allied_Command_Post_Dyno -= 1;
		Util.MapDebugPrint( "Allied_Command_Post_Defused" );
	},

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

		Map.Axis_Command_Post_Dyno -= 1;
		Util.MapDebugPrint( "Axis_Command_Post_Defused" );
	},

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

		Map.stone_tunnel_Dyno -= 1;
		Util.MapDebugPrint( "stone_tunnel_Defused" );
	},

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

		Map.train_Dyno -= 1;
		Util.MapDebugPrint( "train_Defused" );
	},

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

		Map.Allied_Command_Post_Dyno = 0;

		Util.MapDebugPrint( "Allied_Command_Post_Destroyed" );
	},

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

		Map.Axis_Command_Post_Dyno = 0;

		Util.MapDebugPrint( "Axis_Command_Post_Destroyed" );
	},

	stone_tunnel_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Tunnel_1" );
	        SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Tunnel_2" );
	        SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Tunnel_3" );
	        SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Tunnel_4" );
	        SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Tunnel_5" );
	        SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Tunnel_6" );	
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Tunnel2_1" );
	        SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Tunnel2_2" );
	        SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Tunnel2_3" );
	        SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Tunnel2_4" );

		Map.stone_tunnel_Dyno = 0;

		Util.MapDebugPrint( "stone_tunnel_Destroyed" );
	},

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

		Map.train_Dyno = 0;

		Util.MapDebugPrint( "train_Destroyed" );
	},

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

		Util.MapDebugPrint( "forward_flag_Axis_Captured" );
	},

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

		Util.MapDebugPrint( "forward_flag_Allies_Captured" );
	},
	
		Main_Gate_destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Train_2" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Train2_1" );
	        SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Train2_2" );
	        SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Train2_3" );
	        SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Train2_4" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Gate_1" );
	        SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Gate_2" );
	        SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Gate_3" );
	        SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Gate_4" );
	        SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Gate_5" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Axis_Command_Post" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Train_1" );
	        SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Train_2" );
	        SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Train_3" );
	        SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Train_4" );
	        SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Train_5" );
		SetAvailableMapGoals( TEAM.AXIS, false, "CHECKPOINT_forward_flag" );
		SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Allied_Command_Post" );

		Util.MapDebugPrint( "Main_Gate_destroyed" );
	},

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

		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_stone_tunnel" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Tunnel2_1" );
	        SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Tunnel2_2" );
	        SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Tunnel2_3" );
	        SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Tunnel2_4" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Train2_1" );
	        SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Train2_2" );
	        SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Train2_3" );
	        SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Train2_4" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Train_1" );
	        SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Train_2" );
	        SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Train_3" );
	        SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Train_4" );
	        SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Train_5" );
		SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Axis_Command_Post" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Tunnel_1" );
	        SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Tunnel_2" );
	        SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Tunnel_3" );
	        SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Tunnel_4" );
	        SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Tunnel_5" );
	        SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Tunnel_6" );

		Util.MapDebugPrint( "Train_2_Destroyed" );
	},
};

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

	// Register callback functions
	OnTrigger( "Allied Command Post constructed. Charge speed increased!", Map.Allied_Command_Post_Built );
	OnTrigger( "Axis Command Post constructed. Charge speed increased!", Map.Axis_Command_Post_Built );
	OnTrigger( "Planted at the Allied Command Post.", Map.Allied_Command_Post_Planted );
	OnTrigger( "Planted at the Axis Command Post.", Map.Axis_Command_Post_Planted );
	OnTrigger( "Planted at stone tunnel.", Map.stone_tunnel_Planted );
	OnTrigger( "Planted at Main gate.", Map.gate_Planted );
	OnTrigger( "Planted at train.", Map.train_Planted );
	OnTrigger( "Defused at the Allied Command Post.", Map.Allied_Command_Post_Defused );
	OnTrigger( "Defused at the Axis Command Post.", Map.Axis_Command_Post_Defused );
	OnTrigger( "Defused at the MISSING_STRING.", Map.stone_tunnel_Defused );
	OnTrigger( "Defused at the MISSING_STRING.", Map.train_Defused );
	OnTrigger( "Axis team has destroyed the Allied Command Post!", Map.Allied_Command_Post_Destroyed );
	OnTrigger( "Allied team has destroyed the Axis Command Post!", Map.Axis_Command_Post_Destroyed );
	OnTrigger( "The Allies have destroyed the tunnel!", Map.stone_tunnel_Destroyed );
	OnTrigger( "The Allies have destroyed the train!", Map.train_Destroyed );
	OnTrigger( "The Allies have destroyed the train!", Map.Train_2_Destroyed );
	OnTrigger( "The Allies have destroyed the gate!", Map.Main_Gate_destroyed );
	OnTrigger( "Axis have captured the Forward Flag!", Map.forward_flag_Axis_Captured );
	OnTrigger( "Allies have captured the Forward Flag!", Map.forward_flag_Allies_Captured );
	
	SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_train" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Train_2" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_stone_tunnel" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Main_gate" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Gate_1" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Gate_2" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Gate_3" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Gate_4" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Gate_5" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Train_1" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Train_2" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Train_3" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Train_4" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Train_5" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Tunnel_1" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Tunnel_2" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Tunnel_3" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Tunnel_4" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Tunnel_5" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Tunnel_6" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Train2_1" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Train2_2" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Train2_3" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Train2_4" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Tunnel2_1" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Tunnel2_2" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Tunnel2_3" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Tunnel2_4" );

	//~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_.*" );

	// Camp times
	SetMapGoalProperties( "MOUNTMG42_.*", {MinCampTime=15, MaxCampTime=90} );
	SetMapGoalProperties( "MOBILEMG42_.*", {MinCampTime=10, MaxCampTime=60} );


	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 =
	{
		BUILD_Allied_Command_Post =
		{
		},
		BUILD_Axis_Command_Post =
		{
		},
		PLANT_stone_tunnel =
		{
		},
		PLANT_train =
		{
		},
		PLANT_Allied_Command_Post =
		{
		},
		PLANT_Axis_Command_Post =
		{
		},
		CHECKPOINT_forward_flag =
		{
		},
	};
	Util.Routes(MapRoutes);
};
