global Map =
{
	MapName = "tounine_b2",
	Quiet = true,

	BUILD_Neutral_Command_Post = "BUILD_Neutral_Command_Post",
	BUILD_Tank = "BUILD_Tank",
	BUILD_Tank_Barrier_1 = "BUILD_Tank_Barrier_1",
	CAPPOINT_222 = "CAPPOINT_222",
	MOVER_tank = "MOVER_tank",
	PLANT_Tank_Barrier_1 = "PLANT_Tank_Barrier_1",
	PLANT_Neutral_Command_Post = "PLANT_Neutral_Command_Post",
	FLAG_obj = "FLAG_obj",

	//dyno counters
	bOneDyno = 0,

	//set status' for conditionals
	barrierone = 1,

	//arrive status
	arrive = 0,

	Allied_Command_Post_Built = function( trigger )
	{
		//TestMap.Pass();

		//Util.MapDebugPrint( "Neutral_Command_Post_Built" );
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"PLANT_Neutral_Command_.*",
			"BUILD_Neutral_Command_.*",
		});
		Util.ChangeSpawn( TEAM.ALLIES, 4, 2 );

	},

	Allied_Command_Post_Destroyed = function( trigger )
	{
		//TestMap.Pass();

		//Util.MapDebugPrint( "Neutral_Command_Post_Built" );
	},

	Axis_Command_Post_Built = function( trigger )
	{
		//TestMap.Pass();

		//Util.MapDebugPrint( "Neutral_Command_Post_Built" );

	},

	Axis_Command_Post_Destroyed = function( trigger )
	{
		//TestMap.Pass();

		Util.MapDebugPrint( "Neutral_Command_Post_Built" );
	},

	Tank_Built = function( trigger )
	{
		//TestMap.Pass();

		//Util.MapDebugPrint( "Tank_Built" );
		SetAvailableMapGoals( TEAM.AXIS, false, "PLANTMINE_Amine_.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Tank_.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"PLANT_Neutral_Command_.*",
			"ATTACK_tank_.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_Tankallies_.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "ATTACK_Barr_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"ATTACK_Allbar_.*",
			"BUILD_Tank",
			"MOVER_tank",
			"MOUNT_tank",
		});

	},

	Tank_Barrier_1_Built = function( trigger )
	{
		//TestMap.Pass();

		//Util.MapDebugPrint( "Tank_Barrier_1_Built" );

		Map.barrierone = 1;
		if ( Map.arrive > 0)
			{
			 	SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Tank" );
			}
		else
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Tank" );
			}
	},


	Tank_Barrier_1_Destroyed = function( trigger )
	{
		//TestMap.Pass();

		//Util.MapDebugPrint( "Tank_Barrier_1_Destroyed" );

		Map.barrierone = 0;
		Map.bOneDyno = 0;
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"MOVER_tank",
			"BUILD_Tank",
		});

	},

	Tank_Barrier_1_passed = function( trigger )
	{
		//TestMap.Pass();
		Map.arrive = 0;

		//Util.MapDebugPrint( "Tank_Barrier_1_passed" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Tank_.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Tank_.*" );

	},

	Bunker_destroyed = function( trigger )
	{
		//TestMap.Pass();

		//Util.MapDebugPrint( "Bunker_destroyed" );
		SetAvailableMapGoals( TEAM.AXIS, true, "PLANTMINE_Bmine_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Tank" );
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"CAPPOINT_222",
			"FLAG_obj",
			"ATTACK_ALLBunker_.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, "ATTACK_Bunker_.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "ATTACK_Barr_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_Allbar_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "MOVER_tank" );
		SetAvailableMapGoals( TEAM.AXIS, true, "MOVER_tank" );
		Util.ChangeSpawn( TEAM.ALLIES, 4, 4 );
	},

	obj_Taken = function( trigger )
	{
		//TestMap.Pass();

		//Util.MapDebugPrint( "obj_Taken" );

		SetAvailableMapGoals( TEAM.AXIS, true, "ATTACK_Barr_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_Allbar_.*" );

		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_ALLBunker_.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "ATTACK_Bunker_.*" );
	},

	obj_return = function( trigger )
	{
		//TestMap.Pass();

		//Util.MapDebugPrint( "obj_Return" );

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

		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_ALLBunker_.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "ATTACK_Bunker_.*" );
	},

	tank_at_barrier1 = function( trigger )
	{
		Map.arrive = 1;
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Tank_.*" );
		Util.ChangeSpawn( TEAM.ALLIES, 4, 2 );
		SetAvailableMapGoals( TEAM.AXIS, true, "MOUNT_tank" );
		//technically shouldn't need the 'else', but just to be sure
		if ( Map.barrierone > 0 && Map.bOneDyno < 1)
			{
			 	SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Tank" );
			}
		else
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Tank" );
			}

		Util.MapDebugPrint("tank_at_barrier1");
	},

	planted_at_Tank_Barrier_1 = function ( trigger )
	{
		//got a dyno down, build the tank if needed
		SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Tank" );

		Map.bOneDyno += 1;

		Util.MapDebugPrint("planted_at_Tank_Barrier_1");
	},

	defused_at_Tank_Barrier_1 = function ( trigger )
	{
		Map.bOneDyno -= 1;

		//focus back on planting dyno
		if ( Map.bOneDyno < 1 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Tank" );
		}

		Util.MapDebugPrint("defused_at_Tank_Barrier_1");
	},

	vehicle_at_location = function( trigger )
	{
		switch(Map.VehicleLocation)
		{
			case 1: // tank at barrier
			{
				Map.tank_at_barrier1();
			}
		}
	},
};


global OnMapLoad = function()
{
		OnTrigger( "^3Allied Command Post constructed. Charge speed increased!", Map.Allied_Command_Post_Built );
		OnTrigger( "^3Axis team has destroyed the Allied Command Post", Map.Allied_Command_Post_Destroyed );
		OnTrigger( "^3Axis Command Post constructed. Charge speed increased!", Map.Axis_Command_Post_Built );
		OnTrigger( "Allied team has destroyed the Axis Command Post!", Map.Axis_Command_Post_Destroyed );
		OnTrigger( "The tank has been repaired", Map.Tank_Built );
		OnTrigger( "Tank Barrier has been destroyed.", Map.Tank_Barrier_1_Destroyed );
		OnTrigger( "Tank Barrier has been constructed.", Map.Tank_Barrier_1_Built );
		OnTrigger( "^3The Tank has passed Tank Barrier #1", Map.Tank_Barrier_1_passed );
		OnTrigger( "^1Allied team has opened the Bunker!", Map.Bunker_destroyed );
		OnTrigger( "Allies have stolen the Secret Documents!", Map.obj_Taken );
		OnTrigger( "Axis have returned the Secret Documents!", Map.obj_return );
		OnTrigger( "Planted at Tank Barrier.", Map.planted_at_Tank_Barrier_1 );
		OnTrigger( "Defused at Tank Barrier.", Map.defused_at_Tank_Barrier_1 );
		OnTrigger( "tank at location", Map.vehicle_at_location );
		barrier1 = OnTriggerRegion(AABB(-3065.782,-3850.733,268.748,-2697.993,-3426.687,363.125), RegionTrigger.VehicleTrigger);





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


		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"MOVER_tank",
			"BUILD_Tank",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"BUILD_Neutral_Command_Post",
			"PLANT_Neutral_Command_Post",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"PLANT_Neutral_Command_.*",
			"BUILD_Neutral_Command_.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, "ATTACK_tank_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_Tankallies_.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "PLANTMINE_Amine_.*" );


		Util.SetMaxUsersInProgress( 1, "BUILD_Neutral_Command_Post" );
		Util.AddInvVehicle("MOVER_tank");
		ETUtil.SetStartIndex("BUILD_Tank", 0);
		SetGoalPriority( "MOUNT_.*", 0.0, 0, CLASS.MEDIC );
		SetGoalPriority( "MOUNT_.*", 0.0, 0, CLASS.ENGINEER );

		SetMapGoalProperties( "ATTACK_.*", {MinCampTime=60, MaxCampTime=120});

		SetGoalPriority( Map.BUILD_Tank, 1.1, TEAM.ALLIES, CLASS.ENGINEER );
		SetGoalPriority( Map.BUILD_Neutral_Command_Post, 0.8 );
		SetGoalPriority( Map.PLANT_Neutral_Command_Post, 0.6, TEAM.ALLIES, CLASS.COVERTOPS );
		SetGoalPriority( Map.PLANT_Neutral_Command_Post, 0.0, TEAM.ALLIES, CLASS.ENGINEER );
		SetGoalPriority( Map.MOVER_tank, 0.9, TEAM.ALLIES );
		SetGoalPriority( Map.PLANT_Tank_Barrier_1, 0.95, TEAM.ALLIES, CLASS.ENGINEER );
		SetGoalPriority( Map.BUILD_Tank_Barrier_1, 0.95, TEAM.AXIS, CLASS.ENGINEER );

		Util.SetGoalOffset( 187, 132, 0, "PLANT_Tank_Barrier_1" );

		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"ROUTE_allyspawn",
			"ROUTE_spawn.*",
			"ROUTE_villagespawn",
			"ROUTE_cp.*",
			"ROUTE_bunker.*",
			"ROUTE_docs.*",
		});

		SetAvailableMapGoals( TEAM.AXIS, true, {
			"ROUTE_Axisspawn",
			"ROUTE_Axspawn_.*",
		});


		//set up some routing

		MapRoutes =
		{
		BUILD_Tank =
		{
			ROUTE_allyspawn =
			{
				ROUTE_spawnmid = {},
				ROUTE_spawnback =
					{	ROUTE_spawnback_1 = {},
						ROUTE_spawnback_2 = {},
					},
				Weight = 2,
				ROUTE_spawnlow = {},
			},
			ROUTE_cpspawn = {},
			ROUTE_villagespawn = {},
		},

		PLANT_Tank_Barrier_1 =
		{
			ROUTE_villagespawn =
			{
				ROUTE_allbarhigh = {},
			},

			ROUTE_cpspawn = {},
		},

		FLAG_obj =
		{
			ROUTE_villagespawn =
				{
					Weight = 2,
					ROUTE_bunkerback = {},
				},
			ROUTE_cpspawn =
			{
				ROUTE_cproute = {},
				ROUTE_cprouteright = {},

			},
		},

		CAPPOINT_222 =
		{
			ROUTE_docspawn =
			{
				ROUTE_bunkerback =
				{
					ROUTE_docsback = {},
				},

			},
		},

		ATTACK_Barr_1 =
		{
			ROUTE_Axisspawn =
			{
				ROUTE_Axspawn_high = {},
				Weight = 2,
				ROUTE_Axspawn_mid = {},
			},

		},

		ATTACK_Bunker_1 =
		{
			ROUTE_Axisspawn =
			{
				ROUTE_Axspawn_low1 = {},
				Weight = 2,
				ROUTE_Axspawn_low2 = {},
			},
		},
		};


		//routecopying

		MapRoutes.ATTACK_Tankallies_1 = MapRoutes.BUILD_Tank;
		MapRoutes.ATTACK_Tankallies_2 = MapRoutes.BUILD_Tank;
		MapRoutes.ATTACK_Tankallies_3 = MapRoutes.BUILD_Tank;
		MapRoutes.ATTACK_Tankallies_4 = MapRoutes.BUILD_Tank;

		MapRoutes.ATTACK_Allbar_1 = MapRoutes.PLANT_Tank_Barrier_1;
		MapRoutes.ATTACK_Allbar_2 = MapRoutes.PLANT_Tank_Barrier_1;
		MapRoutes.ATTACK_Allbar_3 = MapRoutes.PLANT_Tank_Barrier_1;
		MapRoutes.ATTACK_Allbar_4 = MapRoutes.PLANT_Tank_Barrier_1;

		MapRoutes.ATTACK_Barr_2 = MapRoutes.ATTACK_Barr_1;
		MapRoutes.ATTACK_Barr_3 = MapRoutes.ATTACK_Barr_1;
		MapRoutes.ATTACK_Barr_4 = MapRoutes.ATTACK_Barr_1;
		MapRoutes.ATTACK_Barr_5 = MapRoutes.ATTACK_Barr_1;
		MapRoutes.ATTACK_Barr_6 = MapRoutes.ATTACK_Barr_1;
		MapRoutes.ATTACK_Barr_7 = MapRoutes.ATTACK_Barr_1;
		MapRoutes.ATTACK_Barr_8 = MapRoutes.ATTACK_Barr_1;
		MapRoutes.ATTACK_Barr_9 = MapRoutes.ATTACK_Barr_1;

		MapRoutes.ATTACK_Bunker_2 = MapRoutes.ATTACK_Bunker_1;
		MapRoutes.ATTACK_Bunker_3 = MapRoutes.ATTACK_Bunker_1;
		MapRoutes.ATTACK_Bunker_4 = MapRoutes.ATTACK_Bunker_1;
		MapRoutes.ATTACK_Bunker_5 = MapRoutes.ATTACK_Bunker_1;
		MapRoutes.ATTACK_Bunker_6 = MapRoutes.ATTACK_Bunker_1;
		MapRoutes.ATTACK_Bunker_7 = MapRoutes.ATTACK_Bunker_1;

		Util.Routes(MapRoutes);

};

global OnBotJoin = function( bot )
{
	team = bot.GetTeam();
	class = bot.GetClass();

	if ( class == CLASS.SOLDIER )
		{ bot.ChangePrimaryWeapon( WEAPON.PANZERFAUST ); }

	if ( class == CLASS.COVERTOPS )
	{
		if ( team == TEAM.ALLIES )
			{ bot.ChangePrimaryWeapon( WEAPON.GARAND ); }
		else if ( team == TEAM.AXIS )
			{ bot.ChangePrimaryWeapon( WEAPON.STEN ); }
	};
};
