global Map =
{
	Quiet = true,
	FocusPrimary = false,
	Debug = false,
	DispenseAmmoTime = 10,
	TowerMg = false,

	Checkpoint_flag_respawn_obj = "CHECKPOINT_ForwardSpawn_flag",
	Plant_Communications_Tower = "PLANT_Communications_Tower",
	Plant_Warehouse_Entrance = "PLANT_Warehouse_Entrance",
	Plant_Gate_Hatch = "PLANT_Gate_Hatch",
	Explode_obj_block01 = "EXPLODE_obj_block01",
	Mount_tarmac_nest_1 = "MOUNTMG42_tarmac_nest_1",
	Mount_tarmac_nest_2 = "MOUNTMG42_tarmac_nest_2",
	Mount_tarmac_truck = "MOUNTMG42_tarmac_truck",
	Mount_tower_mg = "MOUNTMG42_tower_mg",
	Repair_tarmac_nest_1 = "REPAIRMG42_tarmac_nest_1",
	Repair_tarmac_nest_2 = "REPAIRMG42_tarmac_nest_2",
	Repair_tarmac_truck = "REPAIRMG42_tarmac_truck",
	Repair_tower_mg = "REPAIRMG42_tower_mg",
	Build_Allied_Command_Post = "BUILD_Allied_Command_Post",
	Build_Axis_Command_Post = "BUILD_Axis_Command_Post",
	Plant_Allied_Command_Post = "PLANT_Allied_Command_Post",
	Plant_Axis_Command_Post = "PLANT_Axis_Command_Post",
	Ammo_Cabinet_allied_ammocabinet = "AMMOCAB_allied_ammocabinet",
	Ammo_Cabinet_axis_ammocabinet = "AMMOCAB_axis_ammocabinet",
	Health_Cabinet_allied_healthcabinet = "HEALTHCAB_allied_healthcabinet",
	Health_Cabinet_axis_healthcabinet = "HEALTHCAB_axis_healthcabinet",

	GateStatus = false, //closed
	HangarDoorStatus = false, //closed
	BarrierStatus = false, //intact
	AxisAtTower = false,
	WarehouseStatus = false,
	TowerDyno = 0,
	AlliesPushedForward = false,
	GateHatchStatus = false,
	FirstTimeCheck = true,
	FriendlyFire,

	bPanzers = 0,
	rPanzers = 0,

	//scripted defend spots for dual objective support
	Defend =
	{
                MaxBots = 2,
		AxisSpawnPt = 0, // axis defenders will choose this spawn point
		AlliesSpawnPt = 0, // allied defenders will choose this spawn point
		AxisDefenders = 0, // a variable to keep a count of defenders
		AlliesDefenders = 0,

		// initialize some tables for adding waypoints for them to use
		Axis = {},
		Allies = {},
	},

	Airstrike =
	{
		stepsas =
		{
			Enabled = false,
			Team = (1<<TEAM.AXIS),
			Waypoint = "rstepsas_1",
		},
	},

	Navigation =
	{
		midladder =
		{
			navigate = function(_this)
			{
				_this.Bot.HoldButton(BTN.FORWARD, 1);
				sleep(1);
			},
		},
	},

	ViewDistance = 5300,
	LadderTrigger =
	{
		Name = "LadderTrigger",
		TriggerOnClass = CLASS.ANYPLAYER,
		OnEnter = function(ent)
		{
			b = Util.IsBot(ent);
			if (b)
			{
				b.MaxViewDistance = 100;
			}
		},
		OnExit = function(ent)
		{
			b = Util.IsBot(ent);
			if (b)
			{
				b.MaxViewDistance = Map.ViewDistance;
			}
		},
	},

	Switches =
	{
		Gate1 =
		{
			Enabled = true,
			Priority = 0.65,
			WaypointName = "gate1",
			LimitTeam = 0, //wait for gate hatch
			LimitBots = 1,
			LimitClass = Util.AllClasses,
			AimPosition = Vector3(-1220.125, -116.430, 64.783),
		},
		Gate2 =
		{
			//Enabled = false,	// Martin - Removed
			Enabled = true,
			Priority = 0.9,
			WaypointName = "gate2",
			LimitTeam = (1<<TEAM.ALLIES),
			LimitBots = 1,
			LimitClass = Util.AllClasses,
			AimPosition = Vector3(-1083.875, -95.821, 454.913),
		},
		HangarDoor1 =
		{
			Enabled = false,
			Priority = 0.65,
			WaypointName = "hangardoor1",
			LimitTeam = 0, //wait for gate hatch
			LimitBots = 1,
			LimitClass = Util.AllClasses,
			AimPosition = Vector3(2427.501, 2888.125, 67.328),
		},
	},

	TowerTrigger =
	{
		Name = "TowerTrigger",
		TriggerOnClass = CLASS.ANYPLAYER,
		OnEnter = function(ent)
		{
			if( GetEntTeam(ent) == TEAM.AXIS )
			{
				Map.AxisAtTower = true;

				//TODO: implement a method for them to eventually rotate
				//back to less conservative defense
				SetAvailableMapGoals( TEAM.ALLIES, false, {
					"DEFEND_.*",
					"CHECKPOINT.*",
					"CAMP_bPanz.*",
				});
				SetAvailableMapGoals( TEAM.ALLIES, true, {
					"CAMP_bPanzTower.*",
					"DEFEND_bTower.*",
				});
                                SetAvailableMapGoals( TEAM.ALLIES, false, {
                                	"CAMP_bBox.*",
                                	"CAMP_bWh.*",
                                });
			}
		},
	},

	Communications_Tower_Destroyed = function( trigger )
	{
		Map.TowerDyno = 0;

	},

	Warehouse_Entrance_Destroyed = function( trigger )
	{
		Map.WarehouseStatus = true;
		Map.AlliesPushedForward = false;

		SetAvailableMapGoals( TEAM.AXIS, true, {
			Map.Plant_Communications_Tower,
			"ATTACK_rTower.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, {
			Map.Plant_Warehouse_Entrance,
			"ATTACK_rDoor.*",
		});

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

		if (Map.FriendlyFire == 0)
		{
			Map.Airstrike.stepsas.Enabled = true;
		}

		SetAvailableMapGoals( TEAM.ALLIES, false, "CHECKPOINT.*" );
		Util.SetMaxUsersInProgress( 3, "CHECKPOINT.*" );
	},

	Gate_Hatch_Destroyed = function( trigger )
	{
		Map.AlliesPushedForward = false;
		Map.GateHatchStatus = true;

		Util.EnableGoal("ROUTE_mwh.*");
		if (!Map.GateStatus)
			{ Map.Switches.Gate1.LimitTeam = (1<<TEAM.AXIS); }

		SetAvailableMapGoals( TEAM.AXIS, false, Map.Plant_Gate_Hatch );
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_bGate.*" );
		// Support fire time
		SetAvailableMapGoals( TEAM.AXIS, true, "ARTILLERY_S_rArty.*" );


		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"CALLARTILLERY_spot_allied_spawn_1",
			"CALLARTILLERY_spot_allied_spawn_2",
			"CALLARTILLERY_spot_allied_tower",
			"CALLARTILLERY_spot_ladder",
			"SNIPE_allies.*",
			"ARTILLERY_S_target_gate_1",
			"ARTILLERY_S_target_gate_2",
			"ARTILLERY_S_tarmac",
		});
		//SetAvailableMapGoals( TEAM.ALLIES, true, "ARTILLERY_D_warehouse_ladder" );
		//SetAvailableMapGoals( TEAM.ALLIES, false, "CALLARTILLERY_bArty" );	// First spawn location
		SetAvailableMapGoals( TEAM.ALLIES, false, "ARTILLERY_S_bTruck" );	// First spawn location
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"ARTILLERY_S_aTower",
			"DEFEND_bFlag.*",
			"DEFEND_bGate.*",
		});

		if ( Map.TowerMg ) {
			SetAvailableMapGoals( TEAM.ALLIES, true, "MOUNTMG42_tower_mg" );
		}

		SetAvailableMapGoals( TEAM.ALLIES, false, "CAMP_bPanz.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "CAMP_rPanzSpawnkill.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "CAMP_bPanzDoor.*" );

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

		Util.SetMaxUsersInProgress( 1, "CHECKPOINT.*" );
		Util.EnableGoal("CHECKPOINT.*");

		Util.LimitToClass( "CHECKPOINT.*", TEAM.ALLIES, CLASS.SOLDIER, CLASS.FIELDOPS );

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

		if ( !Map.FocusPrimary )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, Map.Plant_Warehouse_Entrance );
			SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_bDoor.*" );
                        SetAvailableMapGoals( TEAM.ALLIES, false, "CAMP_bBox.*" );
                        SetAvailableMapGoals( TEAM.ALLIES, true, "CAMP_bWh.*" );

                        SetAvailableMapGoals( TEAM.AXIS, true, {
                        	"SNIPE_rDoor.*",
                        	"ATTACK_rDoor.*",
                        });
                        SetAvailableMapGoals( TEAM.AXIS, false, {
                        	"SNIPE_rGate.*",
                        	"ATTACK_rGate.*",
                        });
		}
	},

	flag_respawn_obj_Axis_Captured = function( trigger )
	{
		Util.SetMaxUsersInProgress( 1, "CHECKPOINT.*" );
	},

	flag_respawn_obj_Allies_Captured = function( trigger )
	{
		Util.SetMaxUsersInProgress( 3, "CHECKPOINT.*" );
	},

	gate_planted = function( trigger )
	{
		//don't bother trying to defuse this.
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFUSE_Gate_Hatch.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "ARTILLERY_S_bTruck" );	// only arty tower

		SetAvailableMapGoals( TEAM.AXIS, false, "MOUNTMG42.*" );
	},

	gate_defused = function( trigger )
	{
	},

	door_planted = function( trigger )
	{

		//don't bother trying to defuse this.
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFUSE_Warehous_Entrance.*" );

		//shift allies early
		if ( !Map.AxisAtTower )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"DEFEND_bGarage.*",
				"CAMP_bBox.*",
			});
                        SetAvailableMapGoals( TEAM.ALLIES, false, "CAMP_bWh.*" );
		}

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"DEFEND_bDoor.*",
			"CHECKPOINT.*",
			"CAMP_bPanz.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, "CAMP_bPanzTarmac.*" );
	},

	door_defused = function( trigger )
	{
	},

	tower_planted = function( trigger )
	{
		Map.TowerDyno += 1;
		SetAvailableMapGoals( TEAM.ALLIES, false, "CHECKPOINT_ForwardSpawn_flag" );
	},

	tower_defused = function( trigger )
	{
		Map.TowerDyno -= 1;
	},

	gate_lever = function( trigger )
	{
		Map.Switches.Gate1.LimitTeam = 0;
		Map.Switches.Gate2.Enabled = false;
	},

	gate_trigger = function( trigger )
	{
		vel = ToVector(trigger.Action);

		if ( vel.y < 0 )
		{
			Wp.SetWaypointFlag( "gatehack", "closed", true );
			Map.GateStatus = false;
			Map.Switches.Gate1.LimitTeam = (1<<TEAM.AXIS);
			Map.Switches.Gate2.Enabled = true;
		}
		else if ( vel.y > 0 )
		{
			Map.Switches.Gate1.LimitTeam = 0;

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

			//open up the node so they can pathfind through gate
			Wp.SetWaypointFlag( "gatehack", "closed", false );

			Map.GateStatus = true;
		}
	},

	hangardoor_lever = function( trigger )
	{
		Map.Switches.HangarDoor1.LimitTeam = 0;
	},

	hangardoor_trigger = function( trigger )
	{
		vel = ToVector(trigger.Action);

		if ( vel.y < 0 )
		{
			Map.HangarDoorStatus = false;
			Map.Switches.HangarDoor1.LimitTeam = (1<<TEAM.AXIS);
		}
		else if ( vel.y > 0 )
		{
			Map.Switches.HangarDoor1.LimitTeam = (1<<TEAM.ALLIES);

			Map.HangarDoorStatus = true;
		}
	},

	barrier_gone = function( trigger )
	{
		Map.BarrierStatus = true;

		//close the barbed wire nodes now that the barrier is gone
		Wp.SetWaypointFlag( "barb1", "closed", true );
		Wp.SetWaypointFlag( "barb2", "closed", true );
	},

	two_minute = function( trigger )
	{

		//time is low, so start focusing on main obj
		Map.FocusPrimary = true;

		WeaponTable.SetWeaponTeamAvailability(TEAM.AXIS, CLASS.SOLDIER, WEAPON.FLAMETHROWER, false);

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"ATTACK_rGate.*",
			"ATTACK_rDoor.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, {
			Map.Plant_Communications_Tower,
			"ATTACK_rTower.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"DEFEND_bDoor.*",
			"DEFEND_bGate.*",
			"CHECKPOINT_ForwardSpawn_flag",
		});

		if ( !Map.AxisAtTower )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"DEFEND_bGarage.*",
				"CAMP_bBox.*",
			});
                        SetAvailableMapGoals( TEAM.ALLIES, false, "CAMP_bWh.*" );
		}
	},

	thirty_second = function( trigger )
	{

		if ( Map.TowerDyno > 1 ) { return; }

		foreach ( id and bot in BotTable )
		{
			if (RandInt(0,10) < 2)
			{
				bot.SayVoice(VOICE.G_GOODGAME);
			}
			sleep(0.5);
		}
	},
	Allied_Command_Post_Built = function( trigger )
	{
		//SetAvailableMapGoals( TEAM.ALLIES, true, Map.Health_Cabinet_allied_healthcabinet );
		//SetAvailableMapGoals( TEAM.ALLIES, true, Map.Ammo_Cabinet_allied_ammocabinet );
	},

	Axis_Command_Post_Built = function( trigger )
	{
		//SetAvailableMapGoals( TEAM.AXIS, true, Map.Health_Cabinet_axis_healthcabinet );
		//SetAvailableMapGoals( TEAM.AXIS, true, Map.Ammo_Cabinet_axis_ammocabinet );
	},

	Allied_Command_Post_Destroyed = function( trigger )
	{
		//SetAvailableMapGoals( TEAM.ALLIES, false, Map.Health_Cabinet_allied_healthcabinet );
		//SetAvailableMapGoals( TEAM.ALLIES, false, Map.Ammo_Cabinet_allied_ammocabinet );
	},

	Axis_Command_Post_Destroyed = function( trigger )
	{
		//SetAvailableMapGoals( TEAM.AXIS, false, Map.Health_Cabinet_axis_healthcabinet );
		//SetAvailableMapGoals( TEAM.AXIS, false, Map.Ammo_Cabinet_axis_ammocabinet );
	},

	FlagSpawnkill = function()
	{
		Util.MapDebugPrint( "FlagSpawnkill" );
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"DEFEND_.*",
			"SNIPE_.*",
			"ARTILLERY.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"DEFEND_bFlag.*",
			"CHECKPOINT.*",
			"AIRSTRIKE_bFlag.*",
		});
	},

	check_flagPush = function()
	{
		while (1)
		{
			if (Map.FirstTimeCheck == true)
			{
				Map.FirstTimeCheck = false;
				sleep(3);
			}
			if (ETUtil.IsTeamClassDead(TEAM.AXIS, CLASS.ENGINEER))
			{
				if (Map.GateStatus == true)
				{
					if (Map.AxisAtTower == false && Map.WarehouseStatus == false && Map.GateHatchStatus == false && !Map.AlliesPushedForward)
					{
						Map.AlliesPushedForward = true;
						Util.OneBotSayTeam(TEAM.ALLIES, "Rush the flag!");
						Map.FlagSpawnkill();
						Util.OneBotVSayTeam(TEAM.ALLIES, VOICE.NEED_BACKUP);
					}
				}
			}
			sleep(1);
		}
	},
	Tower =
	{
		Name = "Tower",
		TriggerOnClass = CLASS.ENGINEER,
		OnEnter = function(ent)
		{


			if( GetEntTeam(ent) == TEAM.AXIS )
			{
				foreach ( id and bot in BotTable )
				{
					if ( bot.GetTeam() == TEAM.ALLIES )
					{
						bot.SayTeam("Axis are planting at Tower!");
						break;
					}
				}
			}
		},

	},

};

global OnMapLoad = function()
{
	//Set the waypoint as a position for the bots to plant hatch
	Util.AddUseWp("PLANT_Gate_Hatch", "hatch");

	tOne = OnTriggerRegion(AABB(2595.000,3267.000,767.000,3068.000,3740.000,841.000), Map.Tower);

	//some triggers to help bots know when to aggressively defend tower
	tTwo = OnTriggerRegion(AABB(1855.000,2943.000,283.000,1978.000,3200.000,357.000), Map.TowerTrigger);	//Garage Steps
	tThree = OnTriggerRegion(AABB(3462.000,3327.000,391.000,3586.000,3456.000,465.000), Map.TowerTrigger);	//Garage ladder
	tFour = OnTriggerRegion(Vector3(3540,3398,112), 200, Map.TowerTrigger);	// Spawn Ladder

	//tThree = OnTriggerRegion(Vector3(3704,1662,444), 200, Map.TowerTrigger);
	//tFour = OnTriggerRegion(Vector3(2235,3082,264), 200, Map.TowerTrigger);

	//focus bots on getting up the allied spawn ladder
	ladder = OnTriggerRegion(AABB(3694,1474,31,3732,1539,492), Map.LadderTrigger);

        Wp.SetWaypointFlag( "boxjump", "closed", true );

	OnTrigger( "Axis team destroyed the Communications Tower!", Map.Communications_Tower_Destroyed );
	OnTrigger( "Planted at The Communications Tower.", Map.tower_planted );
	OnTrigger( "Defused at The Communications Tower.", Map.tower_defused );
	OnTrigger( "Axis team breached the Warehouse Door!", Map.Warehouse_Entrance_Destroyed );
	OnTrigger( "Planted at the Warehouse Entrance.", Map.door_planted );
	OnTrigger( "Defused at the Warehouse Entrance.", Map.door_defused );
	OnTrigger( "Axis team breached the Gate Hatch!", Map.Gate_Hatch_Destroyed );
	OnTrigger( "Planted at the Gate Hatch.", Map.gate_planted );
	OnTrigger( "Defused at the Gate Hatch.", Map.gate_defused );
	OnTrigger( "Axis captures the Gate Area!", Map.flag_respawn_obj_Axis_Captured );
	OnTrigger( "Allies reclaim the Gate Area!", Map.flag_respawn_obj_Allies_Captured );
	OnTrigger( "big_lever1_goto", Map.gate_lever );
	OnTrigger( "big_gate1_goto", Map.gate_trigger );
	OnTrigger( "hangar_lever1_goto", Map.hangardoor_lever );
	OnTrigger( "allied_hangardoor1_goto", Map.hangardoor_trigger );
	OnTrigger( "Explode_obj_block01 Exploded.", Map.barrier_gone );
	OnTrigger( "two minute warning.", Map.two_minute );
	OnTrigger( "thirty second warning.", Map.thirty_second );
	OnTrigger( "Allied Command Post constructed. Charge speed increased!", Map.Allied_Command_Post_Built );
	OnTrigger( "Axis Command Post constructed. Charge speed increased!", Map.Axis_Command_Post_Built );
	OnTrigger( "Axis team has destroyed the Allied Command Post!", Map.Allied_Command_Post_Destroyed );
	OnTrigger( "Allied team has destroyed the Axis Command Post!", Map.Axis_Command_Post_Destroyed );

	SetMapGoalProperties( "SNIPE_.*", {MinCampTime=30, MaxCampTime=60});
	SetMapGoalProperties( "ATTACK_.*", {MinCampTime=15, MaxCampTime=30});
	SetMapGoalProperties( "DEFEND_.*", {MinCampTime=15, MaxCampTime=30});
	SetMapGoalProperties( "CAMP_.*", {MinCampTime=60, MaxCampTime=90});
	ETUtil.SetPrimaryGoals(1.0);
	SetGoalPriority( "SNIPE.*", 1.1);
	SetGoalPriority( "CALL.*", 0.7 );
	SetGoalPriority( "ARTILLLERY.*", 1.0 );
	SetGoalPriority( "MOUNT.*", 0.71 );
	SetGoalPriority( "DEFEND_bGarage_[23]", 0.55 );
        SetGoalPriority( "CAMP_bBox.*", 0.8 );
        SetGoalPriority( "CAMP_bWh.*", 0.8 );
	SetGoalPriority( "PLANT_Gate_Hatch", 1.1, TEAM.AXIS, CLASS.ENGINEER );

	thread(Map.check_flagPush);
	//open up some airstrike goals if ff is off
	Map.FriendlyFire = GetCvar("g_friendlyfire");

	Util.LimitToClass( "CHECKPOINT.*", TEAM.AXIS, CLASS.MEDIC, CLASS.SOLDIER, CLASS.FIELDOPS );

	Util.SetMaxUsers( 1, "ATTACK.*" );
	Util.SetMaxUsers( 1, "DEFEND.*" );
	Util.SetMaxUsers( 1, "BUILD.*" );
	Util.SetMaxUsers( 1, "MOUNTMG42.*" );
        Util.SetMaxUsers( 1, "CAMP.*" );
	Util.SetMaxUsers( 1, "GRENADE.*" );

	Util.LimitToClass( "MOUNTMG42.*", TEAM.ALLIES, CLASS.SOLDIER, CLASS.FIELDOPS );
	Util.LimitToClass( "MOUNTMG42.*", TEAM.AXIS, CLASS.SOLDIER );

	Util.DisableGoal(".*", true); //all but the routes
	Util.DisableGoal("ROUTE_mwh.*");

        SetAvailableMapGoals( TEAM.AXIS, true, {
        	"SNIPE_rGate.*",
        	"ATTACK_rGate.*",
        	Map.Checkpoint_flag_respawn_obj,
        	Map.Plant_Gate_Hatch,
        	Map.Build_Axis_Command_Post,
        	"MOUNTMG42_tarmac_nest_2",
        });

	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"SNIPE_allies.*",
		"DEFEND_bGate.*",
		Map.Build_Allied_Command_Post,
	});

	// Artillery
	//SetAvailableMapGoals( TEAM.ALLIES, true, "CALLARTILLERY_bArty" );	// First spawn location
	SetAvailableMapGoals( TEAM.ALLIES, true, "ARTILLERY_S_bTruck" );	// First spawn location
	SetAvailableMapGoals( TEAM.ALLIES, true, "ARTILLERY_S_aTower" );	// First spawn location
	// end artillery

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

	//used to get bots to pathfind through gate rather than waiting for blockable status
	Wp.SetWaypointFlag( "gatehack", "closed", true );

	//until barrier is destroyed, bots will go through barbed wire
	Wp.SetWaypointFlag( "barb1", "closed", false );
	Wp.SetWaypointFlag( "barb2", "closed", false );

	//allies should throw airstrikes over gate
	SetAvailableMapGoals( TEAM.ALLIES, true, "AIRSTRIKE_bGate.*" );
	SetAvailableMapGoals( TEAM.AXIS, true, "AIRSTRIKE_rGate.*" );

	bDefends = { "CAMP_bBox1", "CAMP_bBox2", "CAMP_bWh1", "CAMP_bWh2", };
        SetGoalRole(bDefends, ROLE.DEFENDER);

	MapRoutes =
	{
		CHECKPOINT_ForwardSpawn_flag =
		{
			ROUTE_rSpawn_1 =
			{
				ROUTE_rBase_w1 = { ROUTE_rBase_w2 = {}, },
				ROUTE_rBase_e1 = { ROUTE_rBase_e2 = {}, },
				ROUTE_rBase_m1 = { ROUTE_rBase_m2 = {}, },
			},
			ROUTE_rSpawn_2 =
			{
				ROUTE_rBase_w1 = { ROUTE_rBase_w2 = {}, },
				ROUTE_rBase_e1 = { ROUTE_rBase_e2 = {}, },
				ROUTE_rBase_m1 = { ROUTE_rBase_m2 = {}, },
			},
			ROUTE_bSpawn =
			{
				ROUTE_wall = {Weight = 3,},
				ROUTE_wTmac_1 = {},
			},
		},

		SNIPE_rGate_s1 =
		{
			ROUTE_rSpawn_1 =
			{
				ROUTE_rSnipe = {},
			},
			ROUTE_rSpawn_2 =
			{
				ROUTE_rSnipe = {},
			},
		},
		PLANT_Warehouse_Entrance =
		{
			//always go lower
			ROUTE_flagspawn =
			{
				ROUTE_mwh_1 = { ROUTE_mwh_2 = {}, },
			},
			ROUTE_rSpawn_1 =
			{
				ROUTE_mwh_1 = { ROUTE_mwh_2 = {}, },
			},
			ROUTE_rSpawn_2 =
			{
				ROUTE_mwh_1 = { ROUTE_mwh_2 = {}, },
			},
		},
		PLANT_Communications_Tower =
		{
			ROUTE_flagspawn =
			{
				ROUTE_mwh_1 =
				{
					ROUTE_mwh_2 =
					{
						ROUTE_bwh_1 =
						{
							ROUTE_bwh_2 = {},
							ROUTE_bwh_3 = {},
						},
					},
				},
				ROUTE_eTmac_1 =
				{
					ROUTE_wTmac_2 =
					{
						ROUTE_bwh_1 =
						{
							Weight = 2,
							ROUTE_bwh_2 = {},
							ROUTE_bwh_3 = {},
						},
						ROUTE_wTmac_3 =
						{
							ROUTE_wTmac_4 =
							{
								ROUTE_bwh_2 = {},
								ROUTE_bwh_3 = {},
							},
						},
					},
				},
			},
			ROUTE_rSpawn_1 =
			{
				ROUTE_mwh_1 =
				{
					ROUTE_mwh_2 =
					{
						ROUTE_bwh_1 =
						{
							ROUTE_bwh_2 = {},
							ROUTE_bwh_3 = {},
						},
					},
				},
				ROUTE_eTmac_1 =
				{
					ROUTE_wTmac_2 =
					{
						ROUTE_bwh_1 =
						{
							Weight = 2,
							ROUTE_bwh_2 = {},
							ROUTE_bwh_3 = {},
						},
						ROUTE_wTmac_3 =
						{
							ROUTE_wTmac_4 =
							{
								ROUTE_bwh_2 = {},
								ROUTE_bwh_3 = {},
							},
						},
					},
				},
			},
			ROUTE_rSpawn_2 =
			{
				ROUTE_mwh_1 =
				{
					ROUTE_mwh_2 =
					{
						ROUTE_bwh_1 =
						{
							ROUTE_bwh_2 = {},
							ROUTE_bwh_3 = {},
						},
					},
				},
				ROUTE_eTmac_1 =
				{
					ROUTE_wTmac_2 =
					{
						ROUTE_bwh_1 =
						{
							Weight = 2,
							ROUTE_bwh_2 = {},
							ROUTE_bwh_3 = {},
						},
						ROUTE_wTmac_3 =
						{
							ROUTE_wTmac_4 =
							{
								ROUTE_bwh_2 = {},
								ROUTE_bwh_3 = {},
							},
						},
					},
				},
			},
		},
		ATTACK_rTower_1 =
		{
			ROUTE_flagspawn =
			{
				ROUTE_mwh_1 =
				{
					ROUTE_mwh_2 =
					{
						ROUTE_bwh_1 =
						{
							ROUTE_bwh_2 = {},
							ROUTE_bwh_3 = {},
						},
					},
				},
				ROUTE_wTmac_1 =
				{
					ROUTE_wTmac_2 =
					{
						ROUTE_wTmac_3 =
						{
							ROUTE_wTmac_4 = { ROUTE_tLadder = {}, },
						},
					},
				},
				ROUTE_eTmac_1 =
				{
					ROUTE_wTmac_2 =
					{
						ROUTE_bwh_1 =
						{
							ROUTE_bwh_2 = {},
							ROUTE_bwh_3 = {},
						},
						ROUTE_wTmac_3 =
						{
							ROUTE_wTmac_4 =
							{
								ROUTE_bwh_2 = {},
								ROUTE_bwh_3 = {},
							},
						},
					},
				},
			},
		},
		DEFEND_bTower_1 =
		{
			ROUTE_bSpawn =
			{
				ROUTE_whdoor =
				{
					ROUTE_bwh_2 = {},
					ROUTE_bwh_3 = {},
				},
				ROUTE_tLadder = {},
			},
		},
		DEFEND_bGate_1 =
		{
			ROUTE_bSpawn =
			{
				ROUTE_eTmac_3 = {},
				ROUTE_wTmac_3 = {},
				ROUTE_mTmac = {},
			},
		},
		DEFEND_bFlag_1 =
		{
			ROUTE_bSpawn =
			{
				ROUTE_eTmac_3 = {},
				ROUTE_wTmac_3 = {},
				ROUTE_mTmac = {},
				ROUTE_wall = {},
			},
		},
	};

	MapRoutes.PLANT_Gate_Hatch = MapRoutes.CHECKPOINT_ForwardSpawn_flag;
	MapRoutes.ATTACK_rGate_1 = MapRoutes.CHECKPOINT_ForwardSpawn_flag;
	MapRoutes.ATTACK_rGate_2 = MapRoutes.CHECKPOINT_ForwardSpawn_flag;
	MapRoutes.ATTACK_rGate_3 = MapRoutes.CHECKPOINT_ForwardSpawn_flag;
	MapRoutes.ATTACK_rGate_4 = MapRoutes.CHECKPOINT_ForwardSpawn_flag;
	MapRoutes.ATTACK_rGate_5 = MapRoutes.CHECKPOINT_ForwardSpawn_flag;
	MapRoutes.ATTACK_rGate_6 = MapRoutes.CHECKPOINT_ForwardSpawn_flag;
	MapRoutes.ATTACK_rDoor_1 = MapRoutes.PLANT_Warehouse_Entrance;
	MapRoutes.ATTACK_rDoor_2 = MapRoutes.PLANT_Warehouse_Entrance;
	MapRoutes.ATTACK_rDoor_3 = MapRoutes.PLANT_Warehouse_Entrance;
	MapRoutes.ATTACK_rTower_2 = MapRoutes.ATTACK_rTower_1;
	MapRoutes.ATTACK_rTower_3 = MapRoutes.ATTACK_rTower_1;
	MapRoutes.ATTACK_rTower_4 = MapRoutes.ATTACK_rTower_1;
	MapRoutes.ATTACK_rTower_5 = MapRoutes.ATTACK_rTower_1;
	MapRoutes.ATTACK_rTower_6 = MapRoutes.ATTACK_rTower_1;
	MapRoutes.DEFEND_bTower_2 = MapRoutes.DEFEND_bTower_1;
	MapRoutes.DEFEND_bTower_3 = MapRoutes.DEFEND_bTower_1;
	MapRoutes.DEFEND_bTower_4 = MapRoutes.DEFEND_bTower_1;
	MapRoutes.DEFEND_bTower_5 = MapRoutes.DEFEND_bTower_1;
	MapRoutes.DEFEND_bTower_6 = MapRoutes.DEFEND_bTower_1;
	MapRoutes.DEFEND_bGate_2 = MapRoutes.DEFEND_bGate_1;
	MapRoutes.DEFEND_bGate_3 = MapRoutes.DEFEND_bGate_1;
	MapRoutes.DEFEND_bGate_4 = MapRoutes.DEFEND_bGate_1;
	MapRoutes.DEFEND_bGate_5 = MapRoutes.DEFEND_bGate_1;
	MapRoutes.DEFEND_bGate_6 = MapRoutes.DEFEND_bGate_1;
	MapRoutes.DEFEND_bDoor_4 = MapRoutes.DEFEND_bGate_1;
	MapRoutes.DEFEND_bDoor_5 = MapRoutes.DEFEND_bGate_1;
	MapRoutes.DEFEND_bDoor_6 = MapRoutes.DEFEND_bGate_1;
	MapRoutes.DEFEND_bDoor_7 = MapRoutes.DEFEND_bGate_1;
	MapRoutes.DEFEND_bFlag_2 = MapRoutes.DEFEND_bFlag_1;
	MapRoutes.DEFEND_bFlag_3 = MapRoutes.DEFEND_bFlag_1;
	MapRoutes.DEFEND_bFlag_4 = MapRoutes.DEFEND_bFlag_1;
	MapRoutes.DEFEND_bFlag_5 = MapRoutes.DEFEND_bFlag_1;
	MapRoutes.DEFEND_bFlag_6 = MapRoutes.DEFEND_bFlag_1;
	MapRoutes.SNIPE_rGate_s2 = MapRoutes.SNIPE_rGate_s1;

	Util.Routes(MapRoutes);
	Util.UpdateSwitchData();

	Util.MapDebugPrint( "OnMapLoad" );
};

global OnBotJoin = function( bot )
{
	bot.TargetBreakableDist = 100.0;
	bot.MaxViewDistance = Map.ViewDistance;

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

	//select spawn point and change class if necessary
	ETUtil.SetDualObjective(bot);

	// ignore the radios
	bot.IgnoreTarget( 548, 9999 );
	bot.IgnoreTarget( 550, 9999 );
};
