//
//	storehouse.gm
//
//	Who              	When			What
//------------------------------------------------------------------------------------------
//	native12		08 November 2010	Initial Script
//				20.11.2010		Final version
//				14.07.2011		Way updated
//	storehouse.way		14.07.2011
//	storehouse_goals.gm	20.11.2010
//==========================================================================================
//

global Map =
{
	Command_Post_Dyno = 0,
	Generator_Dyno = 0,
	Road_MG_Dyno = 0,
	Tank_Barrier_1_Dyno = 0,
	transmitter_Dyno = 0,
	plategate_exploded = false,
	TankPastTankBarrier = 0,
	TankIsAtBarrier1 = 0,
	TankBarrierBuilded = 0,
	TankStatus = 1,
	AxisCP = 0,
	AlliedCP = 0,
	MainEntranceDestroyed = 0,
	TransmitterBuild = 0,
	DocsTaken = 0,
	ForwardBunkerAllied = 0,

	Navigation =
	{
		//  	/bot waypoint_setproperty paththrough Navigation_PT:blachgate
		blachgate =
		{
			gotowp = "grenadeblachgate", // waypoint for the bot to go to before doing anything else
			EvalFunc = function() // if this function returns false, navigation will not run
			{
				return !Map.plategate_exploded;
			},
			navigate = function(_this)
			{
				if ( Map.plategate_exploded )
				{
					yield();
					return;
				}
				foreach ( id and bot in BotTable )
				{
					if ( bot.GetTeam()  == TEAM.AXIS )
					{
						_this.AddWeaponRequest(WEAPON.LUGER);
					}
					else
					{
						_this.AddWeaponRequest(WEAPON.COLT);
					}

					_this.AddAimRequest(Priority.High, "facing", Vector3(-0.947,-0.133,0.294));

					while( !Map.plategate_exploded ) {
						_this.Bot.HoldButton(BTN.ATTACK1, 1);
						yield();
					}

					_this.ReleaseAimRequest();
					_this.ReleaseWeaponRequest();
				}
			},
		},
		//  	/bot waypoint_setproperty paththrough Navigation_PT:blachgate1
		blachgate1 =
		{
			gotowp = "grenadeblachgate1", // waypoint for the bot to go to before doing anything else
			EvalFunc = function() // if this function returns false, navigation will not run
			{
				return !Map.plategate_exploded;
			},

			navigate = function(_this)
			{
				if ( Map.plategate_exploded ) {
					yield();
					return;
				}
				foreach ( id and bot in BotTable )
				{
					if ( bot.GetTeam()  == TEAM.AXIS )
					{
						_this.AddWeaponRequest(WEAPON.LUGER);
					}
					else
					{
						_this.AddWeaponRequest(WEAPON.COLT);
					}

					_this.AddAimRequest(Priority.High, "facing", Vector3(0.877,0.244,-0.414));

					while( !Map.plategate_exploded ) {
						_this.Bot.HoldButton(BTN.ATTACK1, 1);
						yield();
					}

					_this.ReleaseAimRequest();
					_this.ReleaseWeaponRequest();
				}
			},
		},
	},

	TankPastStone =
 	{
 		Name="TankPastStone",
		TriggerOnEntity = GetGoal("MOVER_tank").GetEntity(),
 		OnEnter = function(ent)
 		{
			Util.MapDebugPrint("Tank is next to Stone");
 		},
 		OnExit = function(ent)
 		{
			SetAvailableMapGoals( TEAM.AXIS, true, {
				"CALLARTILLERY_Axis_Start_3",
				"ARTILLERY_S_Axis_Start_4",
			});

			SetGoalPriority( "CALLARTILLERY_Axis_Start_3", 0.81, TEAM.AXIS, CLASS.FIELDOPS );
			SetGoalPriority( "ARTILLERY_S_Axis_Start_4", 0.81, TEAM.AXIS, CLASS.FIELDOPS );

			Util.MapDebugPrint("Tank passed Stone");
 		},
	},

	TankPastRoadMG42 =
 	{
 		Name="TankPastRoadMG42",
		TriggerOnEntity = GetGoal("MOVER_tank").GetEntity(),
 		OnEnter = function(ent)
 		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Bunker_Entrance" );
			sleep(0.5);
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Bunker_Entrance" );

			SetGoalPriority( "PLANT_Bunker_Entrance", 0.95, TEAM.ALLIES, CLASS.ENGINEER );

			Util.MapDebugPrint("Tank is next to RoadMG42");
 		},
 		OnExit = function(ent)
 		{
			SetAvailableMapGoals( TEAM.AXIS, true, {
				"CALLARTILLERY_Axis_Start_5",
				"ARTILLERY_S_Axis_Start_6",
			});

			SetGoalPriority( "CALLARTILLERY_Axis_Start_5", 0.82, TEAM.AXIS, CLASS.FIELDOPS );
			SetGoalPriority( "ARTILLERY_S_Axis_Start_6", 0.82, TEAM.AXIS, CLASS.FIELDOPS );

			Util.MapDebugPrint("Tank passed RoadMG42");
 		},
	},

	Tank_Built = function()
	{
		Map.TankStatus = 1;

		if ( Map.TankIsAtBarrier1 == 1 and Map.TankBarrierBuilded == 1 and Map.TankPastTankBarrier == 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "MOUNT_tank" );
			SetAvailableMapGoals( TEAM.ALLIES, false, {
				"ESCORT_tank",
				"BUILD_tank",
				"PLANT_Tank_Barrier_1",
			});
			sleep(0.5);
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Tank_Barrier_1" );

			SetGoalPriority( "PLANT_Tank_Barrier_1", 0.95, TEAM.ALLIES, CLASS.ENGINEER );

			Util.MapDebugPrint( "^3Tank_Built at barrier & barrier builded" );
		}
		else if ( Map.TankIsAtBarrier1 == 1 and Map.TankBarrierBuilded == 0 and Map.TankPastTankBarrier == 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"MOUNT_tank",
				"ESCORT_tank",
			});

			Util.MapDebugPrint( "^3Tank_Built at barrier & barrier not builded" );
		}
		else if ( Map.MainEntranceDestroyed == 1 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, {
				"MOUNT_tank",
				"ESCORT_tank",
			});
		}
		else
		{
			//SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_tank" );
			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"MOUNT_tank",
				"ESCORT_tank",
			});

			Util.MapDebugPrint( "^3Tank_Built" );
		}
	},

	Tank_Destroyed = function()
	{
		Map.TankStatus = 0;

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"MOUNT_tank",
			"ESCORT_tank",
		});

		if ( Map.TankIsAtBarrier1 == 1 and Map.TankBarrierBuilded == 1 and Map.TankPastTankBarrier == 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, {
				"BUILD_tank",
				"PLANT_Tank_Barrier_1",
			});
			sleep(0.5);
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Tank_Barrier_1" );

			SetGoalPriority( "PLANT_Tank_Barrier_1", 0.95, TEAM.ALLIES, CLASS.ENGINEER );
		}
		else if ( Map.MainEntranceDestroyed == 1 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_tank" );
		}
		else
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_tank" );
		}

		Util.MapDebugPrint( "^3Tank_Destroyed" );
	},

	Road_MG_Built = function()
	{
		//SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Road_MG" );

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"MOUNTMG42_Road_MG",
			"REPAIRMG42_Road_MG",
		});

		if ( Map.TankPastTankBarrier == 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"MOUNTMG42_Road_MG",
				"REPAIRMG42_Road_MG",
			});

			SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Road_MG" );
		}

		Util.MapDebugPrint( "^3Road_MG_Built" );
	},

	Road_MG_Planted = function()
	{
		Map.Road_MG_Dyno += 1;

		if ( Map.TankPastTankBarrier == 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "DEFUSE_Road_MG_.*" );
		}
		else
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "DEFUSE_Road_MG_.*" );
		}

		Util.MapDebugPrint( "^3Road_MG_Planted" );
	},

	Road_MG_Defused = function()
	{
		Map.Road_MG_Dyno -= 1;

		Util.MapDebugPrint( "^3Road_MG_Defused" );
	},

	Road_MG_Destroyed = function()
	{
		Map.Road_MG_Dyno = 0;

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"MOUNTMG42_Road_MG",
			"DEFUSE_Road_MG_.*",
		});

		SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Road_MG" );

		if ( Map.TankPastTankBarrier == 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"BUILD_Road_MG",
				"REPAIRMG42_Road_MG",
			});
		}

		Util.MapDebugPrint( "^3Road_MG_Destroyed" );
	},

	Side_Bunker_Entrance_Planted = function()
	{
		Util.MapDebugPrint( "^3Side_Bunker_Entrance_Planted" );
	},

	Side_Bunker_Entrance_Defused = function()
	{
		Util.MapDebugPrint( "^3Side_Bunker_Entrance_Defused" );
	},

	Side_Bunker_Entrance_Destroyed = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Bunker_Entrance" );

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

		if ( Map.TankPastTankBarrier == 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"CHECKPOINT_forward_bunkerflag",
				"BUILD_Generator",
				"HEALTHCAB_south_healthcabinet",
				"AMMOCAB_south_ammocabinet",
			});

			SetAvailableMapGoals( TEAM.AXIS, true, {
				"HEALTHCAB_south_healthcabinet",
				"AMMOCAB_south_ammocabinet",
			});
		}

		Util.MapDebugPrint( "^3Side_Bunker_Entrance_Destroyed" );
	},

	forward_bunkerflag_Axis_Captured = function()
	{
		Map.ForwardBunkerAllied = 0;

		if ( Map.MainEntranceDestroyed == 1 )
		{
			Util.ChangeSpawn( TEAM.AXIS, 2 );
			Util.ChangeSpawn( TEAM.ALLIES, 3 );
		}
		else if ( Map.MainEntranceDestroyed == 0 and Map.TankPastTankBarrier == 1 )
		{
			Util.ChangeSpawn( TEAM.AXIS, 3 );
			Util.ChangeSpawn( TEAM.ALLIES, 4 );
		}
		else if (Map.ForwardBunkerAllied == 1 and Map.MainEntranceDestroyed == 0 and Map.TankPastTankBarrier == 0 )
		{
			Util.ChangeSpawn( TEAM.ALLIES, 5 );
		}
		else
		{
			Util.ChangeSpawn( TEAM.AXIS, 4 );
			Util.ChangeSpawn( TEAM.ALLIES, 1 );
		}

		if ( Map.TankPastTankBarrier == 0 and Map.TankIsAtBarrier1 == 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "CALLARTILLERY_Allied_Start_9" );

			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"CHECKPOINT_forward_bunkerflag",
				"CALLARTILLERY_Allied_Start_7",
			});

			SetAvailableMapGoals( TEAM.AXIS, false, "CHECKPOINT_forward_bunkerflag" );

			SetAvailableMapGoals( TEAM.AXIS, true, {
				"CALLARTILLERY_Axis_Start_1",
				"ARTILLERY_S_Axis_Start_2",
				"CALLARTILLERY_Axis_Start_3",
				"ARTILLERY_S_Axis_Start_4",
			});
		}

		if ( Map.TankIsAtBarrier1 == 1 and Map.TankPastTankBarrier == 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, {
				"CALLARTILLERY_Allied_Start_9",
				"ATTACK_Allied_NearBarrier_.*",
				"AIRSTRIKE_Allied_NearBarrier_.*",
			});

			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"ATTACK_Allied_Start_.*",
				"CALLARTILLERY_Allied_Start_7",
				"CHECKPOINT_forward_bunkerflag",
			});

			if ( !Map.plategate_exploded )
			{
				SetAvailableMapGoals( TEAM.AXIS, false, "GRENADE_.*" );

				SetAvailableMapGoals( TEAM.ALLIES, false, "GRENADE_.*" );
			}
		}

		Util.MapDebugPrint( "^3forward_bunkerflag_Axis_Captured" );
	},

	forward_bunkerflag_Allies_Captured = function()
	{
		Map.ForwardBunkerAllied = 1;

		if ( Map.MainEntranceDestroyed == 1 )
		{
			Util.ChangeSpawn( TEAM.AXIS, 2 );
			Util.ChangeSpawn( TEAM.ALLIES, 3 );
		}
		else if ( Map.MainEntranceDestroyed == 0 and Map.TankPastTankBarrier == 1 )
		{
			Util.ChangeSpawn( TEAM.AXIS, 3 );
			Util.ChangeSpawn( TEAM.ALLIES, 4 );
		}
		else if (Map.ForwardBunkerAllied == 1 and Map.MainEntranceDestroyed == 0 and Map.TankPastTankBarrier == 0 )
		{
			Util.ChangeSpawn( TEAM.ALLIES, 5 );
		}
		else
		{
			Util.ChangeSpawn( TEAM.AXIS, 4 );
			Util.ChangeSpawn( TEAM.ALLIES, 1 );
		}

		if ( Map.TankPastTankBarrier == 0 and Map.TankIsAtBarrier1 == 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, {
				"CHECKPOINT_forward_bunkerflag",
				"CALLARTILLERY_Allied_Start_7",
			});

			SetAvailableMapGoals( TEAM.ALLIES, true, "CALLARTILLERY_Allied_Start_9" );

			SetAvailableMapGoals( TEAM.AXIS, false, {
				"CALLARTILLERY_Axis_Start_1",
				"ARTILLERY_S_Axis_Start_2",
				"CALLARTILLERY_Axis_Start_3",
				"ARTILLERY_S_Axis_Start_4",
			});

			SetAvailableMapGoals( TEAM.AXIS, true, "CHECKPOINT_forward_bunkerflag" );
		}

		if ( Map.TankIsAtBarrier1 == 1 and Map.TankPastTankBarrier == 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, {
				".*_Allied_Start_.*",
				"CHECKPOINT_forward_bunkerflag",
			});

			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"ATTACK_Allied_NearBarrier_.*",
				"AIRSTRIKE_Allied_NearBarrier_.*",
			});

			if ( !Map.plategate_exploded )
			{
				SetAvailableMapGoals( TEAM.AXIS, true, "GRENADE_.*" );

				SetAvailableMapGoals( TEAM.ALLIES, true, "GRENADE_.*" );
			}
		}

		Util.MapDebugPrint( "^3forward_bunkerflag_Allies_Captured" );
	},

	Generator_Built = function()
	{
		if ( Map.TankPastTankBarrier == 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Generator" );

			SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Generator" );
		}

		Util.MapDebugPrint( "^3Generator_Built" );
	},

	Generator_Planted = function()
	{
		Map.Generator_Dyno += 1;

		if ( Map.TankPastTankBarrier == 1 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "DEFUSE_Generator_.*" );
		}
		else
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "DEFUSE_Generator_.*" );
		}

		Util.MapDebugPrint( "^3Generator_Planted" );
	},

	Generator_Defused = function()
	{
		Map.Generator_Dyno -= 1;

		Util.MapDebugPrint( "^3Generator_Defused" );
	},

	Generator_Destroyed = function()
	{
		Map.Generator_Dyno = 0;

		SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Generator" );

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

		if ( Map.TankPastTankBarrier == 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Generator" );
		}

		Util.MapDebugPrint( "^3Generator_Destroyed" );
	},

	Tank_Barrier_1_Built = function()
	{
		Map.TankBarrierBuilded = 1;

		SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Tank_Barrier_1" );

		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Tank_Barrier_1" );

		if ( Map.TankIsAtBarrier1 == 1 )
		{
			//SetAvailableMapGoals( TEAM.ALLIES, false, "MOUNT_tank" );
			SetAvailableMapGoals( TEAM.ALLIES, false, "ESCORT_tank" );

			if ( Map.TankStatus == 0 )
			{
				SetAvailableMapGoals( TEAM.ALLIES, false, {
					"MOUNT_tank",
					"BUILD_tank",
					"PLANT_Tank_Barrier_1",
				});
				sleep(0.5);
				SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Tank_Barrier_1" );

				SetGoalPriority( "PLANT_Tank_Barrier_1", 0.95, TEAM.ALLIES, CLASS.ENGINEER );
			}
		}
		else
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_tank" );
		}

		Util.MapDebugPrint( "^3Tank_Barrier_1_Built" );
	},

	Tank_Barrier_1_Planted = function()
	{
		Map.Tank_Barrier_1_Dyno += 1;

		SetAvailableMapGoals( TEAM.AXIS, true, "DEFUSE_Tank_Barrier_1_.*" );

		Util.MapDebugPrint( "^3Tank_Barrier_1_Planted" );
	},

	Tank_Barrier_1_Defused = function()
	{
		Map.Tank_Barrier_1_Dyno -= 1;

		Util.MapDebugPrint( "^3Tank_Barrier_1_Defused" );
	},

	Tank_Barrier_1_Destroyed = function()
	{
		Map.Tank_Barrier_1_Dyno = 0;
		Map.TankBarrierBuilded = 0;

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

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

		if ( Map.TankPastTankBarrier == 0 )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Tank_Barrier_1" );

			Util.MapDebugPrint( "^3Tank_Barrier_1_Destroyed" );
		}
		if ( Map.TankIsAtBarrier1 == 1 and Map.TankStatus == 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_tank" );
			sleep(0.5);
			SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_tank" );

			SetGoalPriority( "BUILD_tank", 0.95, TEAM.ALLIES, CLASS.ENGINEER );

			Util.MapDebugPrint( "^3Tank_Barrier_1_Destroyed, tank at barrier & destroyed" );
		}
		else if ( Map.TankIsAtBarrier1 == 1 and Map.TankStatus == 1 )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Tank_Barrier_1" );

			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"MOUNT_tank",
				"ESCORT_tank",
			});

			Util.MapDebugPrint( "^3Tank_Barrier_1_Destroyed, tank at barrier & not destroyed" );
		}
		else
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Tank_Barrier_1" );

			Util.MapDebugPrint( "^3Tank_Barrier_1_Destroyed - not build it" );
		}
	},

	TankAtBarrier1 =
 	{
 		Name="TankAtBarrier1",
		TriggerOnEntity = GetGoal("MOVER_tank").GetEntity(),
 		OnEnter = function(ent)
 		{
			Map.TankIsAtBarrier1 = 1;

			if ( Map.ForwardBunkerAllied == 1 )
			{
				SetAvailableMapGoals( TEAM.ALLIES, false, ".*_Allied_Start_.*" );

				SetAvailableMapGoals( TEAM.ALLIES, true, {
					"ATTACK_Allied_NearBarrier_.*",
					"AIRSTRIKE_Allied_NearBarrier_.*",
				});

				if ( !Map.plategate_exploded )
				{
					SetAvailableMapGoals( TEAM.AXIS, true, "GRENADE_.*" );

					SetAvailableMapGoals( TEAM.ALLIES, true, "GRENADE_.*" );
				}
			}

			Util.MapDebugPrint("Tank is at Barrier 1");
 		},
 		OnExit = function(ent)
 		{
			Map.TankPastTankBarrier = 1;

			if ( Map.MainEntranceDestroyed == 1 )
			{
				Util.ChangeSpawn( TEAM.AXIS, 2 );
				Util.ChangeSpawn( TEAM.ALLIES, 3 );
			}
			else if ( Map.MainEntranceDestroyed == 0 and Map.TankPastTankBarrier == 1 )
			{
				Util.ChangeSpawn( TEAM.AXIS, 3 );
				Util.ChangeSpawn( TEAM.ALLIES, 4 );
			}
			else if (Map.ForwardBunkerAllied == 1 and Map.MainEntranceDestroyed == 0 and Map.TankPastTankBarrier == 0 )
			{
				Util.ChangeSpawn( TEAM.ALLIES, 5 );
			}
			else
			{
				Util.ChangeSpawn( TEAM.AXIS, 4 );
				Util.ChangeSpawn( TEAM.ALLIES, 1 );
			}

			SetAvailableMapGoals( TEAM.ALLIES, false, {
				"CHECKPOINT_.*",
				"MOUNTMG42_Road_MG",
				"REPAIRMG42_Road_MG",
				"REPAIRMG42_TowerMG42_mount",
				"BUILD_Road_MG",
				"BUILD_Generator",
				".*_Allied_Start_.*",
				".*_Axis_Start_.*",
				"CALLARTILLERY_Allied_Start_7",
				"ARTILLERY_S_Allied_Start_8",
				"ATTACK_Allied_NearBarrier_.*",
				"AIRSTRIKE_Allied_NearBarrier_.*",
			});

			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"CALLARTILLERY_Allied_PastBarrier_1",
				"ARTILLERY_S_Allied_PastBarrier_2",
				"ARTILLERY_S_Allied_PastBarrier_3",
				"DEFEND_Allied_PastBarrier_.*",
				"PLANT_Command_Post",
				"BUILD_Command_Post",
			});

			SetAvailableMapGoals( TEAM.AXIS, false, {
				"CALLARTILLERY_Axis_Start_1",
				"ARTILLERY_S_Axis_Start_2",
				"CALLARTILLERY_Axis_Start_3",
				"ARTILLERY_S_Axis_Start_4",
				"CALLARTILLERY_Axis_Start_5",
				"ARTILLERY_S_Axis_Start_6",
				"CHECKPOINT_.*",
				"PLANT_Road_MG",
				"BUILD_Command_Post",
				"PLANT_Generator",
				"BUILD_Tank_Barrier_1",
				".*_Axis_Start_.*",
				".*_Allied_Start_.*",
			});

			SetAvailableMapGoals( TEAM.AXIS, true, {
				"MOUNTMG42_TowerMG42_mount",
				"REPAIRMG42_TowerMG42_mount",
				"CALLARTILLERY_Axis_PastBarrier_1",
				"ARTILLERY_S_Axis_PastBarrier_2",
				"ARTILLERY_S_Axis_PastBarrier_3",
			});
			//SetAvailableMapGoals( TEAM.AXIS, true, "AIRSTRIKE_Axis_PastBarrier_7" );
			SetAvailableMapGoals( TEAM.AXIS, true, {
				"AIRSTRIKE_Axis_PastBarrier_15",
				"DEFEND_Axis_PastBarrier_.*",
				"PLANTMINE_Axis_PastBarrier_.*",
				"CALLARTILLERY_Axis_PastBarrier_16",
				"ARTILLERY_S_Axis_PastBarrier_17",
			});

			SetGoalPriority( "CALLARTILLERY_Axis_PastBarrier_16", 0.82, TEAM.AXIS, CLASS.FIELDOPS );
			SetGoalPriority( "ARTILLERY_S_Axis_PastBarrier_17", 0.82, TEAM.AXIS, CLASS.FIELDOPS );
			SetGoalPriority( "AIRSTRIKE_Axis_PastBarrier_15", 0.84, TEAM.AXIS, CLASS.FIELDOPS );

			Util.MapDebugPrint("Tank passed Barrier 1");
 		},
	},

	Axis_CP_Built = function()
	{
		Map.AxisCP = 1;

		SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Command_Post" );

		if ( Map.TankPastTankBarrier == 1 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Command_Post" );
		}
		else
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Command_Post" );
		}

		Util.MapDebugPrint( "^3Axis_CP_Built" );
	},

	Axis_CP_Destroyed = function()
	{
		Map.AxisCP = 0;

		if ( Map.TankPastTankBarrier == 0 )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Command_Post" );

			SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Command_Post" );
		}
		else
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Command_Post" );

			SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Command_Post" );
		}

		Util.MapDebugPrint( "^3Axis_CP_Destroyed" );
	},

	Command_Post_Planted = function()
	{
		Map.Command_Post_Dyno += 1;

		if ( Map.AxisCP == 1 )
		{
			if ( Map.TankPastTankBarrier == 0 )
			{
				SetAvailableMapGoals( TEAM.AXIS, true, "DEFUSE_Command_Post_.*" );
			}
			else
			{
				SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_Command_Post_.*" );
			}
		}
		else
		{
			if ( Map.TankPastTankBarrier == 0 )
			{
				SetAvailableMapGoals( TEAM.ALLIES, false, "DEFUSE_Command_Post_.*" );
			}
			else
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "DEFUSE_Command_Post_.*" );
			}
		}

		Util.MapDebugPrint( "^3Command_Post_Planted" );
	},

	Command_Post_Defused = function()
	{
		Map.Command_Post_Dyno -= 1;

		Util.MapDebugPrint( "^3Command_Post_Defused" );
	},

	Allied_CP_Built = function()
	{
		Map.AlliedCP = 1;

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

		if ( Map.TankPastTankBarrier == 0 )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Command_Post" );
		}
		else
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Command_Post" );
		}

		Util.MapDebugPrint( "^3Allied_CP_Built" );
	},

	Allied_CP_Destroyed = function()
	{
		Map.AlliedCP = 0;

		if ( Map.TankPastTankBarrier == 0 )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Command_Post" );

			SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Command_Post" );
		}
		else
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Command_Post" );

			SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Command_Post" );
		}

		Util.MapDebugPrint( "^3Allied_CP_Destroyed" );
	},

	TankInTunnel =
 	{
 		Name="TankInTunnel",
		TriggerOnEntity = GetGoal("MOVER_tank").GetEntity(),
 		OnEnter = function(ent)
 		{
			SetAvailableMapGoals( TEAM.AXIS, true, "AIRSTRIKE_Axis_PastBarrier_7" );

			Util.MapDebugPrint("Tank is in front of tunnel");
 		},
 		OnExit = function(ent)
 		{
			SetAvailableMapGoals( TEAM.AXIS, false, {
				"MOUNTMG42_TowerMG42_mount",
				"REPAIRMG42_TowerMG42_mount",
				"CALLARTILLERY_Axis_PastBarrier_1",
				"ARTILLERY_S_Axis_PastBarrier_2",
				"ARTILLERY_S_Axis_PastBarrier_3",
				"DEFEND_Axis_PastBarrier_.*",
				".*_Allied_PastBarrier_.*",
			});

			SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Axis_InTunnel_.*" );

			SetAvailableMapGoals( TEAM.ALLIES, false, {
				"CALLARTILLERY_Allied_PastBarrier_1",
				"ARTILLERY_S_Allied_PastBarrier_2",
				"ARTILLERY_S_Allied_PastBarrier_3",
				"DEFEND_Allied_PastBarrier_.*",
				".*_Axis_PastBarrier_.*",
			});

			SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_Allied_InTunnel_.*" );

			Util.MapDebugPrint("Tank is in tunnel");
 		},
	},

	TankPastTunnel =
 	{
 		Name="TankPastTunnel",
		TriggerOnEntity = GetGoal("MOVER_tank").GetEntity(),
 		OnEnter = function(ent)
 		{
			SetAvailableMapGoals( TEAM.AXIS, true, {
				"AIRSTRIKE_Axis_InTunnel_9",
				"AIRSTRIKE_Axis_InTunnel_10",
				"DEFEND_Axis_AtTransmitter_1",
				"DEFEND_Axis_AtTransmitter_5",
				"DEFEND_Axis_AtTransmitter_6",
			});

			SetGoalPriority( "AIRSTRIKE_Axis_InTunnel_9", 0.85, TEAM.AXIS, CLASS.FIELDOPS );
			SetGoalPriority( "AIRSTRIKE_Axis_InTunnel_10", 0.85, TEAM.AXIS, CLASS.FIELDOPS );
			SetGoalPriority( "DEFEND_Axis_AtTransmitter_1", 1.2, TEAM.AXIS, CLASS.COVERTOPS );
			SetGoalPriority( "DEFEND_Axis_AtTransmitter_1", 1.2, TEAM.AXIS, CLASS.SOLDIER );
			SetGoalPriority( "DEFEND_Axis_AtTransmitter_1", 1.2, TEAM.AXIS, CLASS.ENGINEER );
			SetGoalPriority( "DEFEND_Axis_AtTransmitter_5", 1.2, TEAM.AXIS, CLASS.ENGINEER );
			SetGoalPriority( "DEFEND_Axis_AtTransmitter_5", 1.2, TEAM.AXIS, CLASS.SOLDIER );
			SetGoalPriority( "DEFEND_Axis_AtTransmitter_5", 1.2, TEAM.AXIS, CLASS.COVERTOPS );
			SetGoalPriority( "DEFEND_Axis_AtTransmitter_6", 1.2, TEAM.AXIS, CLASS.SOLDIER );
			SetGoalPriority( "DEFEND_Axis_AtTransmitter_6", 1.2, TEAM.AXIS, CLASS.COVERTOPS );
			SetGoalPriority( "DEFEND_Axis_AtTransmitter_6", 1.2, TEAM.AXIS, CLASS.ENGINEER );

			Util.MapDebugPrint("Tank passed tunnel");
 		},
 		OnExit = function(ent)
 		{
			Util.MapDebugPrint("Tank is in front of Main Gate");
 		},
	},

	Main_Entrance_Destroyed = function()
	{
		Map.MainEntranceDestroyed = 1;

		if ( Map.MainEntranceDestroyed == 1 )
		{
			Util.ChangeSpawn( TEAM.AXIS, 2 );
			Util.ChangeSpawn( TEAM.ALLIES, 3 );
		}
		else if ( Map.MainEntranceDestroyed == 0 and Map.TankPastTankBarrier == 1 )
		{
			Util.ChangeSpawn( TEAM.AXIS, 3 );
			Util.ChangeSpawn( TEAM.ALLIES, 4 );
		}
		else if (Map.ForwardBunkerAllied == 1 and Map.MainEntranceDestroyed == 0 and Map.TankPastTankBarrier == 0 )
		{
			Util.ChangeSpawn( TEAM.ALLIES, 5 );
		}
		else
		{
			Util.ChangeSpawn( TEAM.AXIS, 4 );
			Util.ChangeSpawn( TEAM.ALLIES, 1 );
		}

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"BUILD_Command_Post",
			"BUILD_tank",
			"ESCORT_tank",
			"MOUNT_tank",
			".*_Axis_PastBarrier_.*",
			".*_Allied_PastBarrier_.*",
			".*_Axis_InTunnel_.*",
			".*_Allied_InTunnel_.*",
			"HEALTHCAB_south_healthcabinet",
			"AMMOCAB_south_ammocabinet",
		});

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"PLANT_Command_Post",
			"MOUNTMG42_TowerMG42_mount",
			"REPAIRMG42_TowerMG42_mount",
			"AIRSTRIKE_Axis_PastBarrier_7",
			".*_Axis_PastBarrier_.*",
			".*_Allied_PastBarrier_.*",
			".*_Axis_InTunnel_.*",
			".*_Allied_InTunnel_.*",
			"HEALTHCAB_south_healthcabinet",
			"AMMOCAB_south_ammocabinet",
		});

		SetAvailableMapGoals( TEAM.AXIS, true, {
			"AMMOCAB_hall_ammocabinet",
			"HEALTHCAB_hall_healthcabinet",
			"DEFEND_Axis_AtDocuments_.*",
			"ROUTE_LastAxisSpawn",
		});

		SetGoalPriority( "DEFEND_Axis_AtTransmitter_1", 1.1, TEAM.AXIS, 0 );
		SetGoalPriority( "DEFEND_Axis_AtTransmitter_5", 1.1, TEAM.AXIS, 0 );
		SetGoalPriority( "DEFEND_Axis_AtTransmitter_6", 1.1, TEAM.AXIS, 0 );

		sleep(5);

		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"AMMOCAB_hall_ammocabinet",
			"HEALTHCAB_hall_healthcabinet",
			"BUILD_transmitter",
			"FLAG_document",
			"ATTACK_Allied_AtDocuments_.*",
			"SMOKEBOMB_Allied_AtDocuments_8",
			"PLANT_Side_Entrance",
		});

		WeaponTable.SetWeaponAvailability(CLASS.SOLDIER, { WEAPON.MP40, WEAPON.THOMPSON }, true);

		Util.MapDebugPrint( "^3Main_Entrance_Destroyed" );
	},

	TankEndPath =
 	{
 		Name="TankEndPath",
		TriggerOnEntity = GetGoal("MOVER_tank").GetEntity(),
 		OnEnter = function(ent)
 		{
			Util.DisableGoal( "ESCORT_tank", true );
			Util.DisableGoal( "MOUNT_tank", true );
			Util.DisableGoal( "BUILD_tank", true );

			Util.MapDebugPrint( "^3Tank�s_path_ended" );
 		},
	},

	transmitter_Built = function()
	{
		Map.TransmitterBuild = 1;

		if ( Map.DocsTaken == 1 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "CAPPOINT_transmitter" );
		}

		SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_transmitter" );

		SetGoalPriority( "PLANT_transmitter", 1.6, TEAM.AXIS, CLASS.COVERTOPS );
		SetGoalPriority( "PLANT_transmitter", 1.3, TEAM.AXIS, CLASS.ENGINEER );

		Util.MapDebugPrint( "^3transmitter_Built" );
	},

	transmitter_Planted = function()
	{
		Map.transmitter_Dyno += 1;

		SetAvailableMapGoals( TEAM.ALLIES, true, "DEFUSE_transmitter_.*" );

		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Axis_AtTransmitter_8" );

		Util.MapDebugPrint( "^3transmitter_Planted" );
	},

	transmitter_Defused = function()
	{
		Map.transmitter_Dyno -= 1;

		Util.MapDebugPrint( "^3transmitter_Defused" );
	},

	transmitter_Destroyed = function()
	{
		Map.transmitter_Dyno = 0;
		Map.TransmitterBuild = 0;

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"CAPPOINT_transmitter",
			"DEFUSE_transmitter_.*",
		});

		SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_transmitter" );

		//SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Axis_AtTransmitter_1" );
		//SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Axis_AtTransmitter_6" );

		Util.MapDebugPrint( "^3transmitter_Destroyed" );
	},

	Side_Entrance_Destroyed = function()
	{
		Wp.SetWaypointFlag( "SideEntranceDoor", "axis", false);

		Util.MapDebugPrint( "^3Side_Entrance_Destroyed" );
	},

	document_Taken = function()
	{
		Map.DocsTaken = 1;

		SetAvailableMapGoals( TEAM.AXIS, true, {
			"FLAG_document_dropped",
			"FLAGRETURN_document_dropped",
		});

		SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_document_dropped" );

		if ( Map.MainEntranceDestroyed == 0 )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, {
				"DEFEND_Axis_AtTransmitter_1",
				"DEFEND_Axis_AtTransmitter_4",
				"DEFEND_Axis_AtTransmitter_5",
			});

			SetAvailableMapGoals( TEAM.ALLIES, true, ".*_Allied_AtTransmitter_.*" );
		}
		else
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, ".*_Allied_AtDocuments_.*" );

			SetAvailableMapGoals( TEAM.ALLIES, true, ".*_Allied_AtTransmitter_.*" );

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

			SetAvailableMapGoals( TEAM.AXIS, true, ".*_Axis_AtTransmitter_.*" );
		}

		if ( Map.TransmitterBuild == 1 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "CAPPOINT_transmitter" );
		}

		Util.MapDebugPrint( "^3document_Taken" );
	},

	document_Returned = function()
	{
		Map.DocsTaken = 0;

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

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

		if ( Map.MainEntranceDestroyed == 1 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, ".*_Allied_AtDocuments_.*" );

			SetAvailableMapGoals( TEAM.AXIS, true, {
				".*_Axis_AtDocuments_.*",
				"DEFEND_Axis_AtTransmitter_1",
				"DEFEND_Axis_AtTransmitter_6",
			});
		}

		Util.MapDebugPrint( "^3document_Returned" );
	},

	document_Secured = function()
	{
		Util.MapDebugPrint( "^3document_Secured" );
	},

	Grenade_plate_Exploded = function()
	{
		Map.plategate_exploded = true;

		Util.MapDebugPrint( "^3Grenade_plate_Exploded" );
	},

};

global OnMapLoad = function()
{
	// Register callback functions
	OnTrigger( "Allies have constructed the Generator!", Map.Generator_Built );
	OnTrigger( "Allied team has built the road mg!", Map.Road_MG_Built );
	OnTrigger( "The Tank has been repaired!", Map.Tank_Built );
	OnTrigger( "Tank Barrier #1 has been constructed.", Map.Tank_Barrier_1_Built );
	OnTrigger( "Allied team has built the transmitter!", Map.transmitter_Built );
	OnTrigger( "Planted at the Generator.", Map.Generator_Planted );
	OnTrigger( "Planted at the Road MG.", Map.Road_MG_Planted );
	OnTrigger( "Planted at Tank Barrier #1.", Map.Tank_Barrier_1_Planted );
	OnTrigger( "Planted at the Bunker Entrance.", Map.Side_Bunker_Entrance_Planted );
	OnTrigger( "Defused at the Bunker Entrance.", Map.Side_Bunker_Entrance_Defused );
	OnTrigger( "Planted at the transmitter.", Map.transmitter_Planted );
	OnTrigger( "Defused at the Command Post.", Map.Command_Post_Defused );
	OnTrigger( "Defused at the Generator.", Map.Generator_Defused );
	OnTrigger( "Defused at the Road MG.", Map.Road_MG_Defused );
	OnTrigger( "The Tank has been damaged!", Map.Tank_Destroyed );
	OnTrigger( "Defused at the Tank Barrier #1.", Map.Tank_Barrier_1_Defused );
	OnTrigger( "Defused at the transmitter.", Map.transmitter_Defused );
	OnTrigger( "Axis team has destroyed the Lift Controls Generator!", Map.Generator_Destroyed );
	OnTrigger( "Axis team has destroyed the road mg!", Map.Road_MG_Destroyed );
	OnTrigger( "Tank Barrier #1 has been destroyed.", Map.Tank_Barrier_1_Destroyed );
	OnTrigger( "Axis team has destroyed the transmitter!", Map.transmitter_Destroyed );
	OnTrigger( "Allied team has destroyed the main entrance!", Map.Main_Entrance_Destroyed );
	OnTrigger( "Allies have breached the Side Entrance!", Map.Side_Entrance_Destroyed );
	OnTrigger( "the allies have destroyed the Bunker side entrance", Map.Side_Bunker_Entrance_Destroyed );
	OnTrigger( "Allied team has stolen the documents!", Map.document_Taken );
	OnTrigger( "Axis team has returned the documents!", Map.document_Returned );
	OnTrigger( "Allied team has transmitted the documents", Map.document_Secured );
	OnTrigger( "Axis capture the Forward Bunker!!", Map.forward_bunkerflag_Axis_Captured );
	OnTrigger( "Allies capture the Forward Bunker!", Map.forward_bunkerflag_Allies_Captured );
	OnTrigger( "Allied Command Post constructed. Charge speed increased!", Map.Allied_CP_Built );
	OnTrigger( "Axis team has destroyed the Allied Command Post!", Map.Allied_CP_Destroyed );
	OnTrigger( "Axis Command Post constructed. Charge speed increased!", Map.Axis_CP_Built );
	OnTrigger( "Allied team has destroyed the Axis Command Post!", Map.Axis_CP_Destroyed );
	OnTrigger( "Planted at the Command Post.", Map.Command_Post_Planted );
	OnTrigger( "GRENADE_BlachGate Exploded.", Map.Grenade_plate_Exploded );

	Util.DisableGoal( ".*", true ); // all but routes
	SetAvailableMapGoals( TEAM.AXIS, false, {
		".*",
		"PLANT_Road_MG",
		"MOUNTMG42_TowerMG42_mount",
		".*_Allied_Start_.*",
		".*_Allied_.*",
	});

	SetAvailableMapGoals( TEAM.AXIS, true, {
		"CALLARTILLERY_Axis_Start_1",
		"ARTILLERY_S_Axis_Start_2",
		"BUILD_Command_Post",
		"BUILD_Tank_Barrier_1",
		"DEFEND_Axis_Start_.*",
		"ROUTE_.*",
	});
	//SetAvailableMapGoals( TEAM.AXIS, true, "HEALTHCAB_.*" );
	//SetAvailableMapGoals( TEAM.AXIS, true, "AMMOCAB_.*" );

	SetAvailableMapGoals( TEAM.ALLIES, false, {
		".*",
		"PLANT_Command_Post",
		"BUILD_Command_Post",
		"GRENADE_.*",
		"CAPPOINT_transmitter",
		"MOUNTMG42_TowerMG42_mount",
		".*_Axis_Start_.*",
		".*_Axis_.*",
	});

	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"MOUNT_tank",
		"ESCORT_tank",
		"BUILD_tank",
		"BUILD_Road_MG",
		"PLANT_Bunker_Entrance",
		"ATTACK_Allied_Start_.*",
		"CALLARTILLERY_Allied_Start_7",
		"ARTILLERY_S_Allied_Start_8",
	});

	SetGoalPriority( "PLANT_Bunker_Entrance", 0.82, TEAM.ALLIES, CLASS.ENGINEER );
	//SetGoalPriority( "CHECKPOINT_forward_bunkerflag", 0.8, TEAM.ALLIES, 0 );
	SetGoalPriority( "CHECKPOINT_forward_bunkerflag", 0.91, TEAM.ALLIES, 0 );
	SetGoalPriority( "CHECKPOINT_forward_bunkerflag", 0.78, TEAM.ALLIES, CLASS.FIELDOPS );
	SetGoalPriority( "PLANT_Command_Post", 0.3, 0, CLASS.ENGINEER );
	SetGoalPriority( "GRENADE_.*", 0.4, 0, 0 );
	SetGoalPriority( "REPAIRMG42_.*", 0.6, 0, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_Road_MG", 0.45, TEAM.AXIS, CLASS.ENGINEER );

	// Max users per goal
	Util.SetMaxUsers( 1, "DEFEND_.*" );
	Util.SetMaxUsers( 1, "GRENADE_.*" );
	Util.SetMaxUsers( 1, "MOUNTMG42_.*" );
	Util.SetMaxUsers( 1, "MOUNT_.*" );
	Util.SetMaxUsers( 2, "ESCORT_.*" );
	Util.SetMaxUsers( 3, "FLAG_.*" );

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

	//Util.AddUseWp( "PLANT_Tank_Barrier_1", "TankBarrier_1" );
	//Util.AddUseWp( "PLANT_Tank_Barrier_1", "TankBarrier_2" );
	Util.AddUseWp( "PLANT_Tank_Barrier_1", "TankBarrier_3" );
	Util.AddUseWp( "PLANT_Side_Entrance", "PlantSideEntranceDoor" );

	Wp.SetWaypointFlag( "SideEntranceDoor", "axis", true);

	triggertankstart = OnTriggerRegion(AABB(2742.393,-4762.761,292.808,2838.011,-4468.716,415.672), Map.TankPastStone);
	triggertankroadmg42 = OnTriggerRegion(AABB(1423.856,-4678.874,309.700,1512.647,-4331.223,694.650), Map.TankPastRoadMG42);
	triggerbarrier1 = OnTriggerRegion(AABB(-897.671,-4460.543,708.935,-840.854,-4273.875,849.718), Map.TankAtBarrier1);
	triggertankintunnel = OnTriggerRegion(AABB(-2635.492,-3493.776,777.733,-2256.716,-3024.935,858.717), Map.TankInTunnel);
	//triggertankpasttunnel = OnTriggerRegion(AABB(-2856.155,-678.136,1198.651,-2631.714,-397.471,1300.827), Map.TankPastTunnel);
	triggertankpasttunnel = OnTriggerRegion(AABB(-3161.727,-1048.670,1153.125,-2487.367,-468.014,1291.553), Map.TankPastTunnel);
	triggertankendpath = OnTriggerRegion(AABB(-2101.136,914.774,1356.113,-1887.271,1128.575,1474.908), Map.TankEndPath);

	WeaponTable.SetWeaponAvailability(CLASS.SOLDIER, WEAPON.FLAMETHROWER, false);

	MapRoutes =
	{
		PLANT_Road_MG =
		{
			ROUTE_SpawnCP =
			{
				ROUTE_PlantMG_1 =
				{
					ROUTE_PlantMG_2 =
					{
						ROUTE_PlantMG_3 =
						{
							ROUTE_PlantMG_4 =
							{
								ROUTE_PlantMG_5 =
								{

								},
							},
						},
					},
				},
			},
		},
		DEFEND_Axis_AtTransmitter_1 =
		{
			ROUTE_LastAxisSpawn =
			{
				ROUTE_BackDoor =
				{
					ROUTE_LeftWay_1 =
					{
						ROUTE_LeftWay_2 =
						{
							ROUTE_LeftWay_3 =
							{

							},
						},
						ROUTE_LeftWay_4 =
						{
							Weight = 3,
							ROUTE_LeftWay_5 =
							{
								ROUTE_LeftWay_6 =
								{
									ROUTE_LeftWay_7 =
									{

									},
								},
							},
						},
					},
					ROUTE_RightWay_1 =
					{
						Weight = 2,
						ROUTE_RightWay_2 =
						{
							ROUTE_OutsideWay_3 =
							{
								ROUTE_OutsideWay_4 =
								{
									ROUTE_LeftWay_7 =
									{

									},
								},
							},
						},
					},
				},
				ROUTE_OutsideWay_1 =
				{
					ROUTE_OutsideWay_2 =
					{
						ROUTE_OutsideWay_3 =
						{
							ROUTE_OutsideWay_4 =
							{
								ROUTE_LeftWay_7 =
								{

								},
							},
						},
					},
				},
			},
		},
	};

	MapRoutes.DEFEND_Axis_AtTransmitter_2 = MapRoutes.DEFEND_Axis_AtTransmitter_1;
	MapRoutes.DEFEND_Axis_AtTransmitter_3 = MapRoutes.DEFEND_Axis_AtTransmitter_1;
	MapRoutes.DEFEND_Axis_AtTransmitter_4 = MapRoutes.DEFEND_Axis_AtTransmitter_1;
	MapRoutes.DEFEND_Axis_AtTransmitter_5 = MapRoutes.DEFEND_Axis_AtTransmitter_1;
	MapRoutes.DEFEND_Axis_AtTransmitter_6 = MapRoutes.DEFEND_Axis_AtTransmitter_1;
	MapRoutes.DEFEND_Axis_AtTransmitter_7 = MapRoutes.DEFEND_Axis_AtTransmitter_1;
	MapRoutes.DEFEND_Axis_AtTransmitter_8 = MapRoutes.DEFEND_Axis_AtTransmitter_1;
	MapRoutes.DEFEND_Axis_AtTransmitter_9 = MapRoutes.DEFEND_Axis_AtTransmitter_1;
	MapRoutes.PLANT_transmitter = MapRoutes.DEFEND_Axis_AtTransmitter_1;
	MapRoutes.AIRSTRIKE_Axis_AtTransmitter_10 = MapRoutes.DEFEND_Axis_AtTransmitter_1;

	Util.Routes(MapRoutes);

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

global OnBotJoin = function( bot )
{
	if ( Map.MainEntranceDestroyed == 1 )
	{
		Util.ChangeSpawn( TEAM.AXIS, 2 );
		Util.ChangeSpawn( TEAM.ALLIES, 3 );
	}
	else if ( Map.MainEntranceDestroyed == 0 and Map.TankPastTankBarrier == 1 )
	{
		Util.ChangeSpawn( TEAM.AXIS, 3 );
		Util.ChangeSpawn( TEAM.ALLIES, 4 );
	}
	else if (Map.ForwardBunkerAllied == 1 and Map.MainEntranceDestroyed == 0 and Map.TankPastTankBarrier == 0 )
	{
		Util.ChangeSpawn( TEAM.ALLIES, 5 );
	}
	else
	{
		Util.ChangeSpawn( TEAM.AXIS, 4 );
		Util.ChangeSpawn( TEAM.ALLIES, 1 );
	}
	bot.TargetBreakableDist = 250.0;
	bot.MaxViewDistance = 4250;
};
