// Omni-bot script for "Wacht Am Rhein beta 1" (bulge_beta1) by d00d.
// Version 4.2 for Omni-bot 0.81.
// Set Map.Talk below to false if you don't want the bots to use voice chats.
global Map =
{
	// Set Talk to false if you don't want the bots to talk.
	Talk = true,
	DefendingTeam = TEAM.ALLIES,
	Debug = 0,

	// Status for conditionals
	SideDoorOpen = false,
	Barrier1IsBuilt = false,
	TankIsAtBarrier = false,
	TankIsPastBarrier1 = false,
	TankIsAtBridge = false,
	grenade_bunker_mg_active = false,

	/*** TRIGGER REGIONS ***/
	bunker_mg_trigger =
	{
		Name = "bunker_mg_trigger",
		TriggerOnClass = CLASS.ANYPLAYER,
		OnEnter = function(ent)
		{
			if( GetEntTeam(ent) == TEAM.AXIS )
			{
				SetAvailableMapGoals( TEAM.AXIS, false, "GRENADE_rear_bunker_mg" );
			}
			Util.MapDebugPrint( "bunker mg manned", true );
		},
		OnExit = function(ent)
		{
			if( GetEntTeam(ent) == TEAM.AXIS && Map.grenade_bunker_mg_active )
			{
				SetAvailableMapGoals( TEAM.AXIS, true, "GRENADE_rear_bunker_mg" );
			}
			Util.MapDebugPrint( "bunker mg unmanned", true );
		},
	},

	BridgeBuilt = function()
	{
		if (!Map.TankIsAtBarrier && !Map.TankIsPastBarrier1)
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "MOBILEMG42_bridge_mg_axis1" );
		}
		SetAvailableMapGoals( TEAM.AXIS, false, "SMOKEBOMB_axis_bridge_build.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"PLANTMINE_bridge_mine1",
			"PLANTMINE_bridge_mine2",
		});
		// Flag bridge waypoints unblocked:
		Wp.SetWaypointFlag("bridge_mg_axis1","closed",false);
		Wp.SetWaypointFlag("bridge1","closed",false);
		Wp.SetWaypointFlag("bridge2","closed",false);
		//Wp.SetWaypointFlag("ice","closed",true);

		Util.MapDebugPrint("BridgeBuilt");
	},

	BridgeDestroyed = function()
	{
		if (!Map.TankIsAtBarrier && !Map.TankIsPastBarrier1)
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"PLANTMINE_bridge_mine1",
				"PLANTMINE_bridge_mine2",
			});
		}
		SetAvailableMapGoals( TEAM.AXIS, false, "MOBILEMG42_bridge_mg_axis1" );

		// Flag bridge waypoints blocked:
		Wp.SetWaypointFlag("bridge_mg_axis1","closed",true);
		Wp.SetWaypointFlag("bridge1","closed",true);
		Wp.SetWaypointFlag("bridge2","closed",true);
		Wp.SetWaypointFlag("ice","closed",false);

		Util.MapDebugPrint("BridgeDestroyed");
	},

	TankAtBridge = function()
	{
		SetGoalPriority( "PLANT_Fallen_Tree", 0.9 );
		Map.TankIsAtBridge = true;
		Util.MapDebugPrint( "TankAtBridge" );
	},

	TankOverBridge = function()
	{
		Map.TankIsAtBridge = false;
		SetGoalPriority( "PLANT_Fallen_Tree", 0.9 );
		SetGoalPriority( "PLANT_Damaged_Tree", 0.9 );
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"CALLARTILLERY_bridge_allies.*",
			"MOBILEMORTAR_mortar_bridge_allies.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"CALLARTILLERY_barrier2_allies.*",
			"DEFEND_barrier2_allies.*",
			"MOUNT_tank_allies",
			"SNIPE_barrier2_allies.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"MOBILEMORTAR_mortar_bridge_axis.*",
			"SMOKEBOMB_axis_bridge_build.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"ATTACK_barrier1.*",
			"MOBILEMORTAR_mortar_bridge_axis4",
			"SNIPE_barrier1_axis.*",
		});
		Util.SetMaxUsersInProgress( 1, "DEFEND_barrier2_allies.*" );
		Util.MapDebugPrint( "TankOverBridge" );
	},

	TankPastBunker = function()
	{
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"GRENADE_axis_bunker_mg.*",
			"SMOKEBOMB_axis_bunker_mg.*",
			"MOBILEMG42_bridge_mg_axis.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, "MOBILEMG42_bridge_mg_allies.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "MOBILEMG42_1stbarrier_mg_allies.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"BUILD_Command_Post",
			"SMOKEBOMB_axis_hotel.*",
			"PLANT_Command_Post",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"ATTACK_bridge_axis.*",
			"SNIPE_bridge_.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"PLANT_Bridge",
			"DEFEND_axis_spawn",
			"PLANTMINE_bridge_mine1",
			"PLANTMINE_bridge_mine2",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"PLANTMINE_barrier1_mine1",
			"AIRSTRIKE_treebarrier.*",
		});
		SetGoalPriority( "DEFEND_barrier2_allies.*", 0.7 );
		SetGoalPriority( "DEFEND_barrier2_allies7", 0.75 );
		SetGoalPriority( "DEFEND_barrier2_allies8", 0.77 );
		SetGoalPriority( "DEFEND_barrier2_allies9", 0.77 );
		SetGoalPriority( "BUILD_Bridge", 0.7 );

		if ( GetGameTimeLeft() < 300 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, {
				"BUILD_Command_Post",
				"PLANT_Command_Post",
			});
			SetAvailableMapGoals( TEAM.AXIS, false, {
				"BUILD_Command_Post",
				"PLANT_Command_Post",
				"PLANT_Window_Defenses",
			});
		}
		Util.MapDebugPrint( "TankPastBunker" );
	},

	TankAtBarrier = function()
	{
		Map.TankIsAtBarrier = true;
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"BUILD_Tank_Barrier",
			"MOUNT_tank_allies",
			"TRIPMINE_allies_barrier2.*",
		});

		//Disable health and ammo stand
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"HEALTHCAB.*",
			"AMMOCAB.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"HEALTHCAB.*",
			"AMMOCAB.*",
		});

		if ( Map.Talk && MAP_TALK )
		{
			foreach ( gameId and bot in BotTable )
			{
				if (bot.GetTeam() == TEAM.AXIS)
				{
					if (GetEntFlags(bot.GetGameEntity(), ENTFLAG.MOUNTED) && Map.Barrier1IsBuilt)
					{
						if ( bot.GetNearestAlly(CAT.PLAYER,CLASS.ENGINEER) || bot.GetNearestAlly(CAT.PLAYER,CLASS.COVERTOPS) )
						{
							bot.SayVoice(VOICE.CLEAR_PATH);
						}
						else if ( RandInt(1,2) == 1 && bot.GetClass() != CLASS.COVERTOPS )
						{
							bot.SayVoice(VOICE.NEED_OPS);
						}
						else
						{
							bot.SayVoice(VOICE.NEED_ENGINEER);
						}
					}
				}
			}
		}
		Util.MapDebugPrint( "TankAtBarrier" );
	},

	Barrier1Built = function()
	{
		Map.Barrier1IsBuilt = true;
		SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Fallen_Tree" );
		Util.SetGoalOffset( 240, -10, 0, "PLANT_Fallen_Tree" );
		Util.RemoveGoal( "PLANT_Damaged_Tree" );
		Util.MapDebugPrint("Barrier1Built");
	},

	Barrier1Destroyed = function()
	{
		Map.Barrier1IsBuilt = false;
		if ( GetGoal("PLANT_Fallen_Tree") )
		{
			Util.RemoveGoal( "PLANT_Fallen_Tree" );
		}
		if ( Map.Talk && MAP_TALK )
		{
			foreach ( id and bot in BotTable )
			{
				if ( bot.GetTeam() == TEAM.AXIS && bot.GetClass() == CLASS.ENGINEER )
				{
					if( RandRange(0,10) < 3 )
					{
						bot.SayVoice(VOICE.PATH_CLEARED);
					}
				}
				else if( bot.GetTeam() == TEAM.AXIS && GetGameTimeLeft()<1100 && GetGameTimeLeft()>600 )
				{
					bot.SayVoice(VOICE.G_CHEER);
					break;
				}
			}
		}
		Util.MapDebugPrint( "Barrier1Destroyed" );
	},

	TankPastBarrier1 = function()
	{
		Map.grenade_bunker_mg_active = true;
		Map.TankIsAtBarrier = false;
		Map.TankIsPastBarrier1 = true;
		if ( GetGoal("PLANT_Damaged_Tree") )
		{
			Util.RemoveGoal( "PLANT_Damaged_Tree" );
		}
		if ( GetGoal("PLANT_Fallen_Tree") )
		{
			Util.RemoveGoal( "PLANT_Fallen_Tree" );
		}
		SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Tank_Barrier" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Tank_Barrier" );
		SetGoalPriority( "BUILD_Tank_Barrier", 0.9 );

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"SNIPE_spawnrape.*",
			"CALLARTILLERY_barrier2_allies.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, "CALLARTILLERY_after_barrier2_allies.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"PLANTMINE_bridge_mine.*",
			"PLANTMINE_barrier1_mine.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"DEFEND_after_barrier2_allies.*",
			"SNIPE_after_barrier2_allies.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"SNIPE_bridge_allies.*",
			"SNIPE_barrier2_allies.*",
			"DEFEND_bridge_allies.*",
			"MOUNTMG42_591",
			"REPAIRMG42_591",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"MOUNTMG42_565",
			"REPAIRMG42_565",
			"DEFEND_bunker.*",
			"SNIPE_bunker.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, "MOBILEMG42_1stbarrier_mg_allies.*" );

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"SMOKEBOMB_axis_hotel.*",
			"MOBILEMORTAR_mortar_bridge_.*",
			"BUILD_Bridge",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"REPAIRMG42_565",
			"MOUNTMG42_565",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"ATTACK_barrier1.*",
			"SNIPE_barrier1_axis.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"ATTACK_after_barrier2_allies.*",
			"SNIPE_after_barrier2_allies.*",
		});
		SetGoalPriority( "DEFEND_barrier2_allies.*", 0.7 );
		SetGoalPriority( "DEFEND_after_barrier2_allies.*", 0.75 );
		SetGoalPriority( "ATTACK_after_barrier2_allies.*", 0.75 );
		Util.SetMaxUsersInProgress( 1, "DEFEND_after_barrier2_allies.*" );
		Util.SetMaxUsersInProgress( 1, "ATTACK_after_barrier2_allies.*" );

		// Disable some goals if time is an issue:
		if ( GetGameTimeLeft() < 300 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, {
				"BUILD_Command_Post",
				"PLANT_Command_Post",
			});
			SetAvailableMapGoals( TEAM.AXIS, false, {
				"BUILD_Command_Post",
				"PLANT_Command_Post",
			});
		}
		if ( GetGameTimeLeft() < 180 )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Window_Defenses" );
		}

		Util.MapDebugPrint( "TankPastBarrier1" );
	},

	TankPastCorner1 = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"MOBILEMG42_bunker_mg_allies.*",
			"MOBILEMORTAR_bunker_allies.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"DEFEND_barrier2_allies.*",
			"MOUNT_tank_allies",
			"DEFEND_after_barrier2_allies.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, "ATTACK_after_barrier2_allies.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"ATTACK_second_barrier.*",
			"GRENADE_rear_bunker_mg.*",
			"ATTACK_tank_path.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, "SNIPE_after_barrier2_allies.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"SNIPE_after_barrier2_allies.*",
			"CALLARTILLERY_after_barrier2_allies.*",
			"AIRSTRIKE_treebarrier.*",
		});
		SetGoalPriority( "PLANT_Tank_Barrier", 0.9 );

		if ( Map.Talk && MAP_TALK )
		{
			foreach ( gameId and bot in BotTable )
			{
				rand = ETUtil.CountTeam(TEAM.ALLIES) * 2;
				if( RandInt(1,rand)<2 && bot.GetTeam() == TEAM.ALLIES)
				{
					sleep(1.0);
					bot.ExecCommand("vsay_team FTFallBack");
					break;
				}
			}
		}
		Util.MapDebugPrint( "TankPastCorner1" );
	},

	TankPastCorner2 = function()
	{
		Map.grenade_bunker_mg_active = false;
		SetAvailableMapGoals( TEAM.ALLIES, false, "MOBILEMORTAR_bunker_allies.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Window_Defenses" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "CALLARTILLERY_after_barrier2_allies.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "CALLARTILLERY_second_barrier.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"ATTACK_second_barrier.*",
			"SMOKEBOMB_barrier2.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"ATTACK_tank_path.*",
			"GRENADE_rear_bunker_mg.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"SNIPE_bunker.*",
			"DEFEND_bunker.*",
			"MOBILEMG42_bunker_mg_allies.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"MOBILEMG42_2ndbarrier_mg_allies.*",
			"DEFEND_second_barrier.*",
			"SNIPE_second_barrier.*",
		});
		Util.SetMaxUsersInProgress( 1, "DEFEND_second_barrier4" );

		if (ETUtil.CountTeam(TEAM.ALLIES) < 5)
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, {
				"MOUNTMG42_565",
				"REPAIRMG42_565",
			});
		}
		Util.SetMaxUsersInProgress( 1, "MOUNTMG42.*" );

		SetAvailableMapGoals( TEAM.ALLIES, true, "MOBILEMORTAR_mortar_barrier2_allies.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"REPAIRMG42_565",
			"MOUNTMG42_565",
		});

		// Disable some goals if time is an issue:
		if ( GetGameTimeLeft() < 240 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, {
				"BUILD_Command_Post",
				"PLANT_Command_Post",
			});
			SetAvailableMapGoals( TEAM.AXIS, false, {
				"BUILD_Command_Post",
				"PLANT_Command_Post",
			});
		}
		if ( GetGameTimeLeft() < 180 )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Window_Defenses" );
		}
		Util.MapDebugPrint( "TankPastCorner2" );
	},

	Barrier2Built = function()
	{
		Util.MapDebugPrint( "Barrier2Built" );
	},

	Barrier2Destroyed = function()
	{
		if ( GetGameTimeLeft() < 150 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, {
				"BUILD_Command_Post",
				"PLANT_Command_Post",
				"BUILD_Window_Defenses",
			});
			SetAvailableMapGoals( TEAM.AXIS, false, {
				"BUILD_Command_Post",
				"PLANT_Command_Post",
				"PLANT_Window_Defenses",
			});
		}
		if ( Map.Talk && MAP_TALK )
		{
			foreach ( id and bot in BotTable )
			{
				if ( bot.GetTeam() == TEAM.AXIS && bot.GetClass() == CLASS.ENGINEER )
				{
					if( RandRange(0,10) < 3 )
					{
						bot.SayVoice(VOICE.PATH_CLEARED);
					}
				}
			}
		}

		Util.MapDebugPrint("Barrier2Destroyed");
	},

	WindowDefenseBuilt = function()
	{
		SetAvailableMapGoals( TEAM.AXIS, false, "ROUTE_window1" );
		if ( GetGameTimeLeft()>90 && GetGameTimeLeft()<900 && Map.TankIsPastBarrier1)
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANTMINE_window_mine1" );
		}
		Util.MapDebugPrint("WindowDefenseBuilt");
	},

	WindowDefenseDestroyed = function()
	{
		SetAvailableMapGoals( TEAM.AXIS, true, "ROUTE_window1" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANTMINE_window_mine1" );
		Util.MapDebugPrint("WindowDefenseDestroyed");
	},

	TankPastBarrier2 = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"CALLARTILLERY_barrier2_allies.*",
			"MOBILEMORTAR_bunker_allies.*",
			"MOBILEMORTAR_mortar_barrier2_allies.*",
			"MOBILEMG42_2ndbarrier_mg_allies.*",
			"TRIPMINE_allies_barrier2.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"MOBILEMG42_church_mg_allies.*",
			"DEFEND_church_allies.*",
			"TRIPMINE_allies_church.*",
			"SNIPE_church_allies.*",
		});
		//Redisable 3 sniper spots that are only important after the main door is open:
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"SNIPE_church_allies1",
			"SNIPE_church_allies2",
			"SNIPE_church_allies3",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"ATTACK_church_axis.*",
			"SNIPE_church_axis.*",
			"PLANT_Window_Defenses",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"ATTACK_second_barrier9",
			"SMOKEBOMB_barrier2.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"MOUNTMG42_565",
			"REPAIRMG42_565",
			"DEFEND_second_barrier1",
			"DEFEND_second_barrier2",
		});
		SetGoalPriority( "PLANT_Command_Post", 0.8 );
		SetGoalPriority( "BUILD_Command_Post", 0.8 );
		SetGoalPriority( "ATTACK_second_barrier.*", 0.6 );
		SetGoalPriority( "DEFEND_second_barrier.*", 0.6 );
		SetGoalPriority( "DEFEND_second_barrier4", 0.6 );
		Util.SetMaxUsersInProgress( 1, "DEFEND_church_allies.*" );
		Util.SetMaxUsersInProgress( 1, "DEFEND_second_barrier.*" );
		Util.SetMaxUsersInProgress( 1, "ATTACK_second_barrier.*" );
		Wp.SetWaypointFlag("church_mg_allies1","closed",false);
		Wp.SetWaypointFlag("church_mg_allies2","closed",false);

		if ( GetGameTimeLeft() < 120 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, {
				"BUILD_Command_Post",
				"PLANT_Command_Post",
				"BUILD_Window_Defenses",
			});
			SetAvailableMapGoals( TEAM.AXIS, false, {
				"BUILD_Command_Post",
				"PLANT_Command_Post",
				"PLANT_Window_Defenses",
			});
		}

		if ( Map.Talk && MAP_TALK )
		{
			foreach ( gameId and bot in BotTable )
			{
				rand = ETUtil.CountTeam(TEAM.ALLIES) * 2;
				if( RandInt(1,rand)<2 && bot.GetTeam() == TEAM.ALLIES)
				{
					sleep(1.0);
					bot.ExecCommand("vsay_team FTFallBack");
					break;
				}
			}
		}
		Util.MapDebugPrint( "TankPastBarrier2" );
	},

	TankAtChurch = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"CALLARTILLERY_second_barrier.*",
			"SNIPE_second_barrier.*",
			"DEFEND_second_barrier.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_second_barrier4" );
		SetAvailableMapGoals( TEAM.AXIS, false, "ATTACK_second_barrier.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"SNIPE_church_allies.*",
			"MOUNT_tank_allies",
		});
		SetGoalPriority( "DEFEND_church_allies13", 0.7 );
		Util.SetMaxUsersInProgress( 1, "DEFEND_church_allies13" );
		if ( GetGameTimeLeft() < 90 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, {
				"BUILD_Command_Post",
				"PLANT_Command_Post",
				"BUILD_Window_Defenses",
			});
			SetAvailableMapGoals( TEAM.AXIS, false, {
				"BUILD_Command_Post",
				"PLANT_Command_Post",
				"PLANT_Window_Defenses",
			});
		}
		Util.MapDebugPrint( "TankAtChurch" );
	},

	TankPastChurch = function( trigger )
	{
		Util.MapDebugPrint( "TankPastChurch" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "MOUNT_tank_allies" );
		Util.MapDebugPrint( "TankPastChurch" );
	},

	MainDoorDestroyed = function()
	{
		ac2 = OnTriggerRegion( AABB(-3101.128,-1246.338,137.056,-2984.251,-1048.710,327.378), RegionTrigger.AllClear );
		frontdoor = OnTriggerRegion( AABB(-2913,-1478,133, -2714,-1238,302), RegionTrigger.IntrusionWarning );
		radio = OnTriggerRegion( AABB(-3086,-698,124, -2965,-545,271), RegionTrigger.IntrusionWarning );
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"SMOKEBOMB_church.*",
			"PLANT_Allied_Command_and_Control",
			"PLANT_Allied_Command_and_Control",
			"MOBILEMG42_church_axis.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, "ATTACK_second_barrier.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"SNIPE_second_barrier.*",
			"DEFEND_second_barrier.*",
			"BUILD_Command_Post",
			"PLANT_Command_Post",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"SNIPE_inside_church_allies.*",
			"DEFEND_inside_church_allies.*",
			"MOBILEMG42_inside_church_mg_allies.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_inside_church_allies8" );
		SetGoalPriority( "PLANT_Allied_Command_and_Control", 0.9 );
		SetGoalPriority( "ATTACK_church_axis.*", 0.7 );
		SetGoalPriority( "ATTACK_church_axis1", 0.75 );
		SetGoalPriority( "ATTACK_church_axis6", 0.75 );
		SetGoalPriority( "ATTACK_church_axis2", 0.75 );
		SetGoalPriority( "ATTACK_church_axis4", 0.7 );
		SetGoalPriority( "DEFEND_church_allies13", 0.7 );
		SetGoalPriority( "DEFEND_church_allies14", 0.7 );
		SetGoalPriority( "DEFEND_church_allies17", 0.7 );
		SetGoalPriority( "DEFEND_inside_church_allies.*", 0.7 );
		SetGoalPriority( "SNIPE_inside_church_allies.*", 0.7 );
		SetGoalPriority( "SNIPE_church_allies1", 0.9 );
		SetGoalPriority( "SNIPE_church_allies2", 0.9 );
		SetGoalPriority( "SNIPE_church_allies4", 0.9 );
		SetGoalPriority( "SNIPE_church_allies5", 0.9 );
		Util.SetMaxUsersInProgress( 1, "DEFEND_inside_church_allies.*" );

		if ( GetGameTimeLeft() < 240 )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, {
				"BUILD_Command_Post",
				"PLANT_Window_Defenses",
				"PLANT_Command_Post",
			});
		}
		if ( GetGameTimeLeft() < 150 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Window_Defenses" );
			SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Tank" );
			SetGoalPriority( "SNIPE_inside_church_allies.*", 0.9 );
			SetGoalPriority( "ATTACK_church_axis1", 0.75 );
			SetGoalPriority( "DEFEND_inside_church_allies.*", 0.75 );
		}
		if ( GetGameTimeLeft() < 60 )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "MOUNT_tank" );
		}

		if ( Map.Talk && MAP_TALK )
		{
			rand = ETUtil.CountTeam(TEAM.ALLIES) * 2;
			rand2 = ETUtil.CountTeam(TEAM.AXIS) * 2;

			gametime = GetGameTimeLeft();
			foreach ( gameId and bot in BotTable )
			{
				if (bot.GetTeam() == TEAM.ALLIES && RandInt(0,rand) < 2 && gametime>35)
				{
					sleep(RandRange(1,2.5));
					bot.SayVoice(VOICE.DEFEND_OBJECTIVE);
					bot.HasSpoken = true;
				}
				else if (bot.GetTeam() == TEAM.ALLIES && RandInt(0,rand) < 2 && gametime>35)
				{
					sleep(RandRange(1,2.0));
					bot.ExecCommand("vsay_team FTFallBack");
					bot.HasSpoken = true;
				}
				if (bot.GetTeam() == TEAM.AXIS && RandInt(0,rand2) < 2 && gametime>40)
				{
					sleep(RandRange(1,2.8));
					bot.SayVoice(VOICE.REINFORCE_OFF);
					bot.HasSpoken = true;
				}
				else if (bot.GetTeam() == TEAM.AXIS && RandInt(1,rand2) < 2 && gametime>120)
				{
					sleep(1.5);
					bot.SayVoice(VOICE.G_CHEER);
					bot.HasSpoken = true;
				}
				else if (bot.GetTeam() == TEAM.AXIS && RandInt(1,rand2) < 2 && gametime>120)
				{
					sleep(1.5);
					bot.ExecCommand("vsay_team FTAttack");
					bot.HasSpoken = true;
				}
			}
		}

		Util.MapDebugPrint("MainDoorDestroyed");
	},

	SideDoorDestroyed = function()
	{
		Map.SideDoorOpen = true;
		ac3 = OnTriggerRegion( AABB(-2593.310,-686.479,119.511,-2452.219,-583.733,263.823), RegionTrigger.AllClear );
		ac1 = OnTriggerRegion( AABB(-2606.604,-1159.880,129.006,-2502.231,-1053.702,317.038), RegionTrigger.AllClear );
		backdoor = OnTriggerRegion( AABB(-2675.663,-1187.701,132.593,-2442.384,-784.781,277.449), RegionTrigger.IntrusionWarning );
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"ROUTE_church_axis4",
			"ROUTE_church_axis7",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"DEFEND_inside_church_allies8",
			"PLANTMINE_sidedoor_mine.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, "MOUNT_tank" );
		if ( GetGoal("BUILD_Tank") )
		{
			Util.RemoveGoal("BUILD_Tank");
		}
		SetGoalPriority( "DEFEND_church_allies14", 0.7 );
		SetGoalPriority( "DEFEND_inside_church_allies.*", 0.7 );
		SetGoalPriority( "SNIPE_inside_church_allies.*", 0.9 );
		SetGoalPriority( "PLANT_Allied_Command_and_Control", 0.9 );
		if ( GetGameTimeLeft() < 150 )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, {
				"BUILD_Command_Post",
				"PLANT_Command_Post",
				"PLANT_Window_Defenses",
			});
			SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Window_Defenses" );
		}

		if (Map.Talk && MAP_TALK && GetGameTimeLeft()>90)
		{
			rand = ETUtil.CountTeam(TEAM.ALLIES) * 2;
			rand2 = ETUtil.CountTeam(TEAM.AXIS) * 2;

			gametime = GetGameTimeLeft();
			foreach ( gameId and bot in BotTable )
			{
				if (!bot.HasSpoken && bot.GetTeam() == TEAM.ALLIES && RandInt(1,rand) < 2)
				{
					sleep(1.0);
					bot.SayVoice(VOICE.REINFORCE_DEF);
				}
				else if (!bot.HasSpoken && bot.GetTeam() == TEAM.ALLIES && RandInt(0,rand) < 2)
				{
					sleep(1.5);
					bot.SayVoice(VOICE.DEFEND_OBJECTIVE);
				}
				if (!bot.HasSpoken && bot.GetTeam() == TEAM.AXIS && RandInt(0,rand2) < 2 && gametime>40 && bot.GetClass() != CLASS.ENGINEER)
				{
					sleep(1.0);
					bot.SayVoice(VOICE.DESTROY_PRIMARY);
				}
				else if (!bot.HasSpoken && bot.GetTeam() == TEAM.AXIS && RandInt(1,rand2) < 2 && gametime>60)
				{
					sleep(2.0);
					bot.SayVoice(VOICE.LETS_GO);
				}
				else if (!bot.HasSpoken && bot.GetTeam() == TEAM.AXIS && RandInt(0,rand2) < 2 && gametime>120)
				{
					sleep(1.5);
					bot.SayVoice(VOICE.G_ENEMY_WEAK);
				}
				else if (!bot.HasSpoken && bot.GetTeam() == TEAM.AXIS && RandInt(0,rand2) < 2 && gametime>120)
				{
					sleep(0.8);
					bot.ExecCommand("vsay_team FTAttack");
				}
				else if (!bot.HasSpoken && bot.GetTeam() == TEAM.AXIS && RandInt(1,rand2) < 2 && gametime>180)
				{
					sleep(1.8);
					bot.SayVoice(VOICE.G_CHEER);
				}
			}
		}

		Util.MapDebugPrint("SideDoorDestroyed");
	},

	TankDamaged = function()
	{
		if(Map.SideDoorOpen) {return;}

		//center it every time it is damaged
		Util.SetPositionGoal( "BUILD_Tank", "MOVER_tank" );

		if (Map.Talk && MAP_TALK && !Map.SideDoorOpen)
		{
			rand = ETUtil.CountTeam(TEAM.AXIS) * 2;
			foreach ( gameId and bot in BotTable )
			{
				if (bot.GetTeam() == TEAM.AXIS && bot.GetClass() != CLASS.ENGINEER && RandInt(1,rand) < 2)
				{
					sleep(1.0);
					bot.SayVoice(VOICE.REPAIR_VEHICLE);
					break;
				}
				else if (bot.GetTeam() == TEAM.AXIS && bot.GetClass() != CLASS.ENGINEER && RandInt(1,rand) < 4)
				{
					sleep(1.5);
					bot.SayTeam("Panzer instand setzen!"); //"Repair the tank" in German
					break;
				}
			}
		}

		Util.MapDebugPrint("TankDamaged", true);
	},

	TankRepaired = function()
	{
		if (Map.Talk && !Map.SideDoorOpen)
		{
			foreach ( gameId and bot in BotTable )
			{
				if (bot.GetTeam() == TEAM.AXIS && bot.GetClass() == CLASS.ENGINEER && RandInt(1,10) < 2)
				{
					sleep(1.0);
					bot.SayVoice(VOICE.ESCORT_VEHICLE);
					break;
				}
			}
		}

		Util.MapDebugPrint("TankRepaired", true);
	},

	OnDynoRadio = function()
	{
		if ( Map.Talk && MAP_TALK )
		{
			wppos = Util.GetWpNamePosition( "inside_church_allies6" );
			foreach ( id and bot in BotTable )
			{
				if ( bot.GetTeam() == TEAM.ALLIES && bot.GetClass() != CLASS.ENGINEER && GetGameTimeLeft()>35 )
				{
					ran = RandRange(0,10);
					if( ran<3 && bot.DistanceTo(wppos)<800 && !bot.GetNearestAlly(CAT.PLAYER,CLASS.ENGINEER) )
					{
						sleep(ran);
						bot.SayVoice(VOICE.NEED_ENGINEER);
					}
					else if( ran>9 && GetGameTimeLeft()>30 )
					{
						sleep(ran-8);
						bot.SayVoice(VOICE.DISARM_DYNAMITE);
					}
				}
			}
		}

		Util.MapDebugPrint("OnDynoRadio");
	},

	OnDefusedRadio = function()
	{
		if ( GetGameTimeLeft() < 150 )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, {
				"BUILD_Command_Post",
				"PLANT_Command_Post",
				"PLANT_Window_Defenses",
			});
		}
		if ( Map.Talk && MAP_TALK )
		{
			foreach ( id and bot in BotTable )
			{
				if ( bot.GetTeam() == TEAM.ALLIES && GetGameTimeLeft()>29 && GetGameTimeLeft()<500 )
				{
					if( RandInt(1,10)<2 )
					{
						bot.SayVoice(VOICE.G_CHEER);
						break;
					}
				}
			}
		}

		Util.MapDebugPrint("OnDefuseRadio");
	},

	AxisWon = function()
	{
		ETUtil.WinningChat( TEAM.AXIS );
		ETUtil.LosingChat( TEAM.ALLIES );
		Util.MapDebugPrint("AxisWon");
	},

	tank_at_location = function( trigger )
	{
		switch( Map.VehicleLocation )
		{
			case 1:
			{
				Map.TankAtBridge();
			}
			case 2:
			{
				Map.TankPastBunker();
			}
			case 3:
			{
				Map.TankAtBarrier();
			}
			case 4:
			{
				Map.TankPastCorner1();
			}
			case 5:
			{
				Map.TankPastCorner2();
			}
			case 6:
			{
				Map.TankAtChurch();
			}
			case 7:
			{
				Map.TankPastChurch();
			}
		}
		Util.MapDebugPrint( "tank at location " + Map.VehicleLocation, true );
	},

};

global OnMapLoad = function()
{

	/*** REGION TRIGGERS ***/
	bmg = OnTriggerRegion( AABB(960,-1555,130, 1130,-1250,250), Map.bunker_mg_trigger );
	// these region triggers disable bot pushing and combat movement in some places
	house1 = OnTriggerRegion( AABB(-2490,-3815,100, -2880,-3610,300), RegionTrigger.DisableBotPush );
	house2 = OnTriggerRegion( AABB(-2470,-3140,100, -2020,-2760,300), RegionTrigger.DisableBotPush );
	wall = OnTriggerRegion( AABB(-2660,-2035,100, -2540,-1760,200), RegionTrigger.DisableBotPush );
	// vehicle locations
	location1 = OnTriggerRegion( AABB(1549.421,-4547.822,217.012, 1943.938,-4328.008,308.280), RegionTrigger.VehicleTrigger );
	location2 = OnTriggerRegion( AABB(1775.430,-2745.835,217.300, 2111.522,-2478.304,305.038), RegionTrigger.VehicleTrigger );
	location3 = OnTriggerRegion( AABB(4051.828,-1777.384,217.125, 4361.241,-1521.905,318.503), RegionTrigger.VehicleTrigger );
	location4 = OnTriggerRegion( AABB(2452.436,-801.326,244.693, 2830.719,-490.467,393.125), RegionTrigger.VehicleTrigger );
	location5 = OnTriggerRegion( AABB(178.646,-1211.715,81.125, 499.843,-689.152,194.137), RegionTrigger.VehicleTrigger );
	location6 = OnTriggerRegion( AABB(-2902.575,-3228.470,78.687, -2636.793,-2965.396,155.125), RegionTrigger.VehicleTrigger );
	location7 = OnTriggerRegion( AABB(-2484.187,-2125.717,79.368, -2183.409,-1955.981,277.809), RegionTrigger.VehicleTrigger );

	// Triggers
	OnTrigger( "Axis team has contructed the Bridge!", Map.BridgeBuilt );
	OnTrigger( "Allied team has destroyed the Bridge!", Map.BridgeDestroyed );
	OnTrigger( "bulge_axis_tank_across_bridge", Map.TankOverBridge );
	OnTrigger( "Tank Barrier #1 has been placed.", Map.Barrier1Built );
	OnTrigger( "Tank Barrier #1 has been destroyed.", Map.Barrier1Destroyed );
	OnTrigger( "bulge_axis_past_tankbar1", Map.TankPastBarrier1 );
	OnTrigger( "Tank Barrier #2 has been constructed.", Map.Barrier2Built );
	OnTrigger( "Tank Barrier #2 has been destroyed.", Map.Barrier2Destroyed );
	OnTrigger( "bulge_axis_past_tankbar2", Map.TankPastBarrier2 );
	OnTrigger( "Window Defenses have been constructed.", Map.WindowDefenseBuilt );
	OnTrigger( "Window Defenses have been destroyed.", Map.WindowDefenseDestroyed );
	OnTrigger( "Axis team has destroyed the Church Doors!", Map.MainDoorDestroyed );
	OnTrigger( "Axis team has destroyed the Church side Door!", Map.SideDoorDestroyed );
	//OnTrigger( "The plane has damaged the tank", Map.TankDamaged ); //not needed ATM
	OnTrigger( "The Tank has been damaged", Map.TankDamaged );
	OnTrigger( "The Tank has been repaired", Map.TankRepaired );
	OnTrigger( "Planted at The Allied Command and Control.", Map.OnDynoRadio );
	OnTrigger( "Defused at The Allied Command and Control.", Map.OnDefusedRadio );
	OnTrigger( "Axis team has destroyed the Allied command and control!", Map.AxisWon );
	OnTrigger( "tank at location", Map.tank_at_location );

	// Clear bogus goals
	Util.RemoveGoal( "BUILD_Damaged_Tree" );
	Util.RemoveGoal( "BUILD_Fallen_Tree" );

	// Set Map Goal Properties
	SetMapGoalProperties( "ATTACK_.*", {MinCampTime=2, MaxCampTime=15} );
	SetMapGoalProperties( "DEFEND_.*", {MinCampTime=3, MaxCampTime=35} );
	SetMapGoalProperties( "SNIPE_.*", {MinCampTime=10, MaxCampTime=60} );
	SetMapGoalProperties( "MOBILEMG42_.*", {MinCampTime=10, MaxCampTime=70} );
	SetMapGoalProperties( "MOUNTMG42_.*", {MinCampTime=10, MaxCampTime=120} );

	// Flag bridge waypoints blocked
	Wp.SetWaypointFlag( "bridge_mg_axis1", "closed", true );
	Wp.SetWaypointFlag( "church_mg_allies1", "closed", true );
	Wp.SetWaypointFlag( "church_mg_allies2", "closed", true );
	Wp.SetWaypointFlag( "bridge1", "closed", true );
	Wp.SetWaypointFlag( "bridge2", "closed", true );
	Wp.SetWaypointFlag( "ice", "closed", false );

	// Reposition some goals so they're easier to reach
	//Util.SetGoalOffset( 0, -40, 0, "BUILD_Bridge" );
	//Util.SetGoalOffset( 25, 0, 0, "BUILD_Window_Defenses" );
	//Util.SetGoalOffset( 20, 0, -20, "PLANT_Window_Defenses" );
	Util.SetGoalOffset( 0, 0, 220, "PLANT_Bridge" );
	Util.SetGoalOffset( 15, 0, -40, "PLANT_Damaged_Tree" );
	Util.AddUsePoint( "PLANT_Window_Defenses", {Vector3(-723,-2059,130), Vector3(-802,-2059,140)} );

	//Set max users for some goals
	Util.SetMaxUsersInProgress( 1, "PLANT_Command_Post" );
	Util.SetMaxUsersInProgress( 2, "MOBILEMG42.*" );
	Util.SetMaxUsersInProgress( 2, "DEFUSE_.*" );
	Util.SetMaxUsersInProgress( 4, "DEFUSE_Allied_Command_and_Control_.*" );
	Util.SetMaxUsersInUse( 1, "DEFUSE_.*" );
	Util.SetMaxUsersInProgress( 3, "MOUNT_.*" );
	Util.SetMaxUsersInProgress( 2, "MOBILEMORTAR.*" );
	Util.SetMaxUsersInProgress( 1, "DEFEND_barrier2_allies.*" );
	Util.SetMaxUsersInProgress( 1, "DEFEND_inside_church_allies.*" );
	Util.SetMaxUsers( 1, "GRENADE_.*" );
	Util.SetMaxUsers( 1, "SMOKEBOMB_.*" );

	// Engineer stuff to disable
	SetAvailableMapGoals( TEAM.ALLIES, false, {
		"BUILD_Tank_Barrier",
		"BUILD_Window_Defenses",
	});
	SetAvailableMapGoals( TEAM.AXIS, false, {
		"PLANT_Window_Defenses",
		"PLANT_Tank_Barrier",
		"BUILD_Command_Post",
		"PLANT_Command_Post",
		"PLANT_Fallen_Tree",
		"PLANT_Allied_Command_and_Control",
	});

	// Priorities
	SetGoalPriority( "DEFUSE_Damaged_Tree.*", 0.0, TEAM.AXIS, CLASS.ENGINEER, true );
	SetGoalPriority( "DEFUSE_Allied_Command_and_Control_.*", 1.5, TEAM.ALLIES, CLASS.ENGINEER, true );
	SetGoalPriority( "PLANT_Fallen_Tree", 0.6, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_Fallen_Tree", 0.8, TEAM.AXIS, CLASS.COVERTOPS );
	SetGoalPriority( "SMOKEBOMB_church.*", 0.75 );
	SetGoalPriority( "BUILD_Bridge", 0.9 );
	SetGoalPriority( "BUILD_Tank", 0.8 );
	SetGoalPriority( "MOUNTMG42_.*", 0.8 );

	// Tank mount
	SetAvailableMapGoals( TEAM.AXIS, true, "MOUNT_tank" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "MOUNT_tank_allies" );

	// Mines
	SetAvailableMapGoals( TEAM.AXIS, false, "PLANTMINE_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "PLANTMINE_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "PLANTMINE_bridge_mine.*" );

	// MGs to disable
	SetAvailableMapGoals( TEAM.AXIS, false, {
		"MOUNTMG42_591",
		"REPAIRMG42_591",
		"MOUNTMG42_565",
		"REPAIRMG42_565",
	});
	SetAvailableMapGoals( TEAM.ALLIES, false, {
		"REPAIRMG42_565",
		"MOUNTMG42_565",
	});

	// Mobile MG/Mortar spots
	SetAvailableMapGoals( TEAM.AXIS, false, {
		"MOBILEMG42_.*",
		"MOBILEMORTAR_.*",
	});
	SetAvailableMapGoals( TEAM.ALLIES, false, {
		"MOBILEMORTAR_.*",
		"MOBILEMG42_.*",
	});
	SetAvailableMapGoals( TEAM.ALLIES, true, "MOBILEMORTAR_mortar_bridge_allies.*" );
	SetAvailableMapGoals( TEAM.AXIS, true, {
		"MOBILEMORTAR_mortar_bridge_axis.*",
		"MOBILEMG42_bridge_mg_axis.*",
	});
	SetAvailableMapGoals( TEAM.AXIS, false, "MOBILEMG42_bridge_mg_axis1" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "MOBILEMG42_bridge_mg_allies.*" );

	// First disable all attack/defend/snipe goals
	SetAvailableMapGoals( TEAM.ALLIES, false, {
		"GRENADE_.*",
		"ATTACK_.*",
		"DEFEND_.*",
		"SNIPE_.*",
		"SMOKEBOMB_.*",
		"CALLARTILLERY_.*",
		"AIRSTRIKE_.*",
	});
	SetAvailableMapGoals( TEAM.AXIS, false, {
		"GRENADE_.*",
		"ATTACK_.*",
		"DEFEND_.*",
		"SNIPE_.*",
		"SMOKEBOMB_.*",
		"CALLARTILLERY_.*",
		"AIRSTRIKE_.*",
	});

	// Enable bridge attack/defend/snipe goals
	SetAvailableMapGoals( TEAM.AXIS, true, {
		"GRENADE_axis_bunker_mg.*",
		"SMOKEBOMB_axis_bridge_build.*",
		"SMOKEBOMB_axis_bunker_mg.*",
		"ATTACK_bridge_axis.*",
		"SNIPE_bridge_axis.*",
	});
	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"SNIPE_bridge_allies.*",
		"SNIPE_spawnrape1",
		"SNIPE_spawnrape2",
		"SNIPE_spawnrape3",
		"SNIPE_spawnrape4",
		"DEFEND_bridge_allies.*",
		"CALLARTILLERY_bridge_allies.*",
	});
	if (ETUtil.CountTeam(TEAM.ALLIES) > 8)
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_axis_spawn" );
	}

	// *** Routing ***
	MapRoutes =
	{

		SNIPE_spawnrape1 =
		{
			ROUTE_hotelspawn =
			{
				ROUTE_forest = { ROUTE_forest2 = {} }
			}
		},
		BUILD_Bridge =
		{
			ROUTE_tank =
			{
				ROUTE_axis_health = {},
				ROUTE_hill0 =
				{
					ROUTE_hill2 = {},
					ROUTE_hill3 = {}
				},
				ROUTE_hill2 = {}
			},
			ROUTE_axis_spawn =
			{
				ROUTE_axis_health = {},
				ROUTE_hill0 =
				{
					ROUTE_hill2 = {},
					ROUTE_hill3 = {}
				},
				ROUTE_hill2 = {}
			},
			ROUTE_axis_spawn2 =
			{
				ROUTE_stairs1 =
				{
					ROUTE_stairs2 =
					{
						ROUTE_hill0 =
						{
							ROUTE_hill2 = {},
							ROUTE_hill3 = {}
						},
						ROUTE_axis_health = {},
					},
				},
				ROUTE_axis_health = {},
				ROUTE_hill0 =
				{
					ROUTE_hill2 = {},
					ROUTE_hill3 = {}
				},
				ROUTE_hill2 = {}
			},
		},

		ATTACK_bridge_axis4 =
		{
			ROUTE_axis_spawn =
			{
				ROUTE_axis_health = {},
				ROUTE_hill1 =
				{
					ROUTE_hill2 = {},
				},
				ROUTE_forest = {}
			},
			ROUTE_axis_spawn2 =
			{
				ROUTE_stairs1 =
				{
					ROUTE_stairs2 =
					{
						ROUTE_axis_health = {},
					},
				},
				ROUTE_axis_health = {},
				ROUTE_hill1 =
				{
					ROUTE_hill2 = {},
				},
			},
		},

		ATTACK_bridge_axis12 =
		{
			ROUTE_axis_spawn =
			{
				ROUTE_axis_health = {},
				ROUTE_hill1 =
				{
					ROUTE_hill2 =
					{
						ROUTE_hill3 = {},
					},
				},
				ROUTE_hill0 =
				{
					ROUTE_hill3 = {},
				},
			},
			ROUTE_axis_spawn2 =
			{
				ROUTE_hill0 =
				{
					ROUTE_hill3 = {},
				},
				ROUTE_stairs1 =
				{
					ROUTE_stairs2 =
					{
						ROUTE_hill0 =
						{
							ROUTE_hill3 = {},
						},
					},
				},
			},
		},

		ATTACK_barrier1_1 =
		{
			ROUTE_axis_spawn =
			{
				ROUTE_axis_health =
				{
					ROUTE_bridge = {},
					ROUTE_roadside1 =
					{
						ROUTE_roadside2 =
						{
							ROUTE_roadside3 = {},
						},
					},
				},

				ROUTE_stairs1 =
				{
					ROUTE_stairs2 =
					{
						ROUTE_axis_health =
						{
							ROUTE_bridge = {},
						},
					},
				},

				ROUTE_roadside1 =
				{
					//Weight = 2,
					ROUTE_roadside2 =
					{
						ROUTE_roadside3 = {},
					},
				},
			},
			ROUTE_axis_spawn2 =
			{
				ROUTE_roadside1 =
				{
					ROUTE_roadside2 =
					{
						ROUTE_roadside3 = {},
					},
				},

				ROUTE_axis_health =
				{
					ROUTE_bridge = {},
				},

				ROUTE_stairs1 =
				{
					ROUTE_stairs2 =
					{
						ROUTE_axis_health =
						{
							ROUTE_bridge = {},
						},
					}
				},
			},
		},

		ATTACK_barrier1_3 =
		{
			ROUTE_axis_spawn =
			{
				ROUTE_roadsideright1 =
				{
					ROUTE_roadsideright2 =
					{
						ROUTE_roadsideright3 =
						{
							ROUTE_roadsideright4 = {},
						},
					},
				},
			},
			ROUTE_axis_spawn2 =
			{
				ROUTE_roadsideright1 =
				{
					ROUTE_roadsideright2 =
					{
						ROUTE_roadsideright3 =
						{
							ROUTE_roadsideright4 = {},
						},
					},
				},
			},
		},

		ATTACK_barrier1_4 =
		{

			ROUTE_healthstand =
			{
				ROUTE_axis_health =
				{
					Weight = 2,
					ROUTE_bridge = {},
				},

				ROUTE_bridge =
				{
					ROUTE_bunker_MG =
					{
						ROUTE_bunker_tunnel =
						{
							ROUTE_bunker_tunnel2 =
							{
								ROUTE_bunker_door = {},
							},
						},
					},
				},
			},

			ROUTE_axis_spawn =
			{
				ROUTE_axis_health =
				{
					ROUTE_bridge = {},
				},

				ROUTE_bunker_MG =
				{
					ROUTE_bunker_tunnel =
					{
						ROUTE_bunker_tunnel2 =
						{
							ROUTE_bunker_door = {},
						},
					},
				},

				ROUTE_roadsideright1 =
				{
					ROUTE_roadsideright2 =
					{
						ROUTE_roadsideright3 =
						{
							ROUTE_roadsideright4 =
							{
								ROUTE_roadsideright5 = {},
							},
						},
					},
				},
			},
			ROUTE_axis_spawn2 =
			{
				ROUTE_bunker_MG =
				{
					ROUTE_bunker_tunnel =
					{
						ROUTE_bunker_tunnel2 =
						{
							ROUTE_bunker_door = {},
						},
					},
				},

				ROUTE_roadsideright1 =
				{
					ROUTE_roadsideright2 =
					{
						ROUTE_roadsideright3 =
						{
							ROUTE_roadsideright4 = {},
						},
					},
				},
			},
		},

		ATTACK_barrier1_2 =
		{
			ROUTE_axis_spawn =
			{
				ROUTE_roadsideright1 =
				{
					ROUTE_roadsideright2 =
					{
						ROUTE_roadsideright3 =
						{
							ROUTE_roadsideright4 = {},
						},
					},
				},

				ROUTE_axis_health =
				{
					ROUTE_bridge = {},
				},

				ROUTE_stairs1 =
				{
					ROUTE_stairs2 =
					{
						ROUTE_axis_health =
						{
							ROUTE_bridge = {},
						},
					}
				},
			},

			ROUTE_axis_spawn2 =
			{
				ROUTE_roadsideright1 =
				{
					ROUTE_roadsideright2 =
					{
						ROUTE_roadsideright3 =
						{
							ROUTE_roadsideright4 = {},
						},
					},
				},

				ROUTE_axis_health =
				{
					ROUTE_bridge = {},
				},

				ROUTE_stairs1 =
				{
					ROUTE_stairs2 =
					{
						ROUTE_axis_health =
						{
							ROUTE_bridge = {},
						},
					}
				},
			},
		},

		ATTACK_church_axis1 =
		{

			ROUTE_hotelspawn2 =
			{
				ROUTE_right_house1 =
				{
					ROUTE_right_house2 =
					{
						ROUTE_trench1 =
						{
							ROUTE_grey_house1 =
							{
								ROUTE_alley3 = {},
								ROUTE_grey_house2 =
								{
									ROUTE_grey_house3 = {},
								},
							},
						},
					},
				},

				ROUTE_window1 =
				{
					ROUTE_window2 =
					{
						ROUTE_backyard =
						{
							ROUTE_alley =
							{
								ROUTE_backdoor = {},
							},
						},
					},
				},
			},

			ROUTE_church_axis4 =
			{
				ROUTE_alley =
				{
					ROUTE_backdoor = {},
				},
			},

			ROUTE_church_axis7 =
			{
				ROUTE_alley =
				{
					ROUTE_backdoor = {},
				},
			},

		},

		DEFEND_inside_church_allies8 =
		{
			ROUTE_allied_spawn =
			{
				ROUTE_alley3 = {},
				ROUTE_high_window =
				{
					ROUTE_alley2 = {},
					ROUTE_churchside = {},
				},
			},
			ROUTE_allied_spawn2 =
			{
				ROUTE_alley3 = {},
				ROUTE_high_window =
				{
					ROUTE_alley2 = {},
					ROUTE_churchside = {},
				},
			},
			ROUTE_allied_spawn3 =
			{
				ROUTE_alley3 = {},
				ROUTE_high_window =
				{
					ROUTE_alley2 = {},
					ROUTE_churchside = {},
				},
			},
		},

	};

	// copy some routes
	MapRoutes.SNIPE_spawnrape2 = MapRoutes.SNIPE_spawnrape1;
	MapRoutes.SNIPE_spawnrape3 = MapRoutes.SNIPE_spawnrape1;
	MapRoutes.SNIPE_spawnrape4 = MapRoutes.SNIPE_spawnrape1;
	MapRoutes.SNIPE_spawnrape5 = MapRoutes.SNIPE_spawnrape1;
	MapRoutes.SNIPE_spawnrape6 = MapRoutes.SNIPE_spawnrape1;
	MapRoutes.SNIPE_spawnrape7 = MapRoutes.SNIPE_spawnrape1;
	MapRoutes.MOBILEMG42_bridge_mg_axis1 = MapRoutes.BUILD_Bridge;
	MapRoutes.ATTACK_barrier1_6 = MapRoutes.ATTACK_barrier1_4;
	MapRoutes.ATTACK_barrier1_9 = MapRoutes.ATTACK_barrier1_4;
	MapRoutes.ATTACK_church_axis1.ROUTE_hotelspawn = MapRoutes.ATTACK_church_axis1.ROUTE_hotelspawn2;
	MapRoutes.ATTACK_church_axis1.ROUTE_hotelspawn3 = MapRoutes.ATTACK_church_axis1.ROUTE_hotelspawn2;
	MapRoutes.ATTACK_church_axis1.ROUTE_hotelspawn4 = MapRoutes.ATTACK_church_axis1.ROUTE_hotelspawn2;
	MapRoutes.ATTACK_church_axis1.ROUTE_hotelspawn5 = MapRoutes.ATTACK_church_axis1.ROUTE_hotelspawn2;
	MapRoutes.ATTACK_church_axis2 = MapRoutes.ATTACK_church_axis1;
	MapRoutes.PLANT_Allied_Command_and_Control = MapRoutes.ATTACK_church_axis1;
	MapRoutes.DEFEND_inside_church_allies11 = MapRoutes.DEFEND_inside_church_allies8;
	MapRoutes.DEFEND_inside_church_allies6 = MapRoutes.DEFEND_inside_church_allies8;
	MapRoutes.PLANT_Fallen_Tree = MapRoutes.ATTACK_barrier1_4;

	Util.Routes(MapRoutes);

	// Disable side door routes initially
	SetAvailableMapGoals( TEAM.AXIS, false, {
		"ROUTE_church_axis4",
		"ROUTE_church_axis7",
	});

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

global OnBotJoin = function(bot)
{

	bot.MaxViewDistance = 2400;
	if( bot.CanSnipe() )
	{
		bot.MaxViewDistance = 2560;
	}

	if ( Map.Talk && MAP_TALK && bot.GetTeam()==TEAM.ALLIES && RandInt(1,20)<2 )
	{
		sleep(2.0);
		bot.ExecCommand("vsay_team FTDeployLandmines");
	}
	if ( Map.Talk && MAP_TALK && bot.GetTeam()==TEAM.AXIS && RandInt(1,20)<2 && !Map.SideDoorOpen )
	{
		sleep(2.0);
		bot.ExecCommand("vsay_team FTMortar");
	}
};
