// Map script for Decrypted 2 (b2) by d00d
// TODO: check routes

global Map =
{

	Debug = false,
	DefendingTeam = TEAM.AXIS,

	doorsOpen = function()
	{
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_docs.*" );
		Util.MapDebugPrint( "doorsOpen!!!" );
	},

	wallBlown = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "ROUTE_brickwall" );
		Util.MapDebugPrint( "wallBlown!!!" );
	},

	docsCaptured = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_cappoint.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_cappoint.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_docs.*" );
		Util.MapDebugPrint( "docsCaptured!!!" );
	},

	docsLost = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_cappoint.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_cappoint.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_docs.*" );
		Util.MapDebugPrint( "docsLost!!!" );
	},

	comPostBuilt = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "CHECKPOINT_spawn_flag" );
		SetAvailableMapGoals( TEAM.AXIS, false, "CHECKPOINT_spawn_flag" );
		Util.MapDebugPrint( "comPostBuilt!!!" );
	},

	comPostDestroyed = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "CHECKPOINT_spawn_flag" );
		SetAvailableMapGoals( TEAM.AXIS, true, "CHECKPOINT_spawn_flag" );
		Util.MapDebugPrint( "comPostDestroyed!!!" );
	},

};

global OnMapLoad = function()
{
	OnTrigger( "mainwall_axis_breach", Map.doorsOpen );
	OnTrigger( "Allies have blow the Brick Wall", Map.wallBlown );
	OnTrigger( "Allies have stolen The Decripted Message!", Map.docsCaptured );
	OnTrigger( "Flag returned documents!", Map.docsLost );
	OnTrigger( "Allied Command Post constructed. Charge speed increased! Forward flag r", Map.comPostBuilt );
	OnTrigger( "Axis team has destroyed the Allied Command Post!", Map.comPostDestroyed );

	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_.*" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_.*" );

	Util.AddUsePoint( "PLANT_Brick_Wall", { Vector3(1500,-1000,-80), Vector3(1550,-1000,-80) } );
	Util.SetGoalOffset( 20, 20, -130, "PLANT_Main_Doors" );

	iw1 = OnTriggerRegion( AABB(3185.125,-2400.304,-355.885,3618.312,-2210.155,-261.221), RegionTrigger.IntrusionWarning );
	iw2 = OnTriggerRegion( AABB(3469.391,-2093.695,-393.574,3684.250,-1822.126,-268.404), RegionTrigger.IntrusionWarning );

	Util.SetMaxUsers( 1, "BUILD_.*" );
	Util.SetMaxUsers( 1, "PLANT_.*" );
	Util.SetMaxUsers( 2, "CHECKPOINT_.*" );
	Util.SetMaxUsersInProgress( 3, "FLAG_.*" );

	// *** ROUTES ***
	Maproutes =
	{
		FLAG_documents =
		{
			ROUTE_doors =
			{
				ROUTE_leftdoor = {},
				ROUTE_rightdoor = {},
				ROUTE_pipe = {},
			},
			ROUTE_allied_spawn =
			{
				ROUTE_doors =
				{
					ROUTE_leftdoor = {},
					ROUTE_rightdoor = {},
					ROUTE_pipe = {},
				},
				ROUTE_brickwall2 =
				{
					ROUTE_leftdoor = {},
					ROUTE_rightdoor = {},
					ROUTE_pipe = {},
				}
			},
			ROUTE_forward_spawn =
			{
				ROUTE_leftdoor = {},
				ROUTE_rightdoor = {},
				ROUTE_pipe = {},
			}
		},
		CAPPOINT_197 =
		{
			ROUTE_docs =
			{
				ROUTE_stairs = {},
				ROUTE_brickwall = {},
			}
		},
		CHECKPOINT_spawn_flag =
		{
			ROUTE_allied_spawn =
			{
				ROUTE_stairs = {},
				ROUTE_brickwall2 = {},
			}
		},
	};
	Util.Routes(Maproutes);

	SetAvailableMapGoals( TEAM.ALLIES, false, "ROUTE_brickwall" );

	Util.MapDebugPrint("Omni-bot map script for Decrypted 2 executed.");
};

global OnBotJoin = function( bot )
{
	bot.TargetBreakableDist = 90;
};
