//==========================================================================================
//
//	transmitter_spring.gm
//
//	Who  	When		What
//------------------------------------------------------------------------------------------
//	^4Tardis	20 October 2014	Script Copy from Transmitter - Just updated for new goals
//
//==========================================================================================
//
global Map =
{
	Debug = 0,
	ShowMovers = false,

	Axis_Castle_MG_Dyno = 0,
	Backgate_Dyno = 0,
	Bridge_Dyno = 0,
	Bridge_MG_Dyno = 0,
	Command_Post_Dyno = 0,
	Grate_Door_Dyno = 0,
	Serpentine_Barricade_Dyno = 0,
	allied_Castle_MG_Dyno = 0,
	Tunnel_Wall_Dyno = 0,
	Bunker_Wall_Dyno = 0,
	Cave_Ladder_Dyno = 0,
	
	Backgate_Status = null,
	Antenna_Status = 1,
	Transmitter_Status = 1,

	Phase = 1,

	Ammo_Cabinet_ammo1 = "AMMOCAB_ammo1",
	Ammo_Cabinet_ammo1_1 = "AMMOCAB_ammo1_1",
	Ammo_Cabinet_forestcab_ammo = "AMMOCAB_forestcab_ammo",
	Health_Cabinet_forestcab_health = "HEALTHCAB_forestcab_health",
	Health_Cabinet_health1 = "HEALTHCAB_health1",
	Health_Cabinet_health1_1 = "HEALTHCAB_health1_1",
	Call_Artillery_bridge6 = "CALLARTILLERY_bridge6",
	Call_Artillery_castle1 = "CALLARTILLERY_castle1",
	Artillery_D_4 = "ARTILLERY_D_4",
	Artillery_D_80 = "ARTILLERY_D_80",
	Artillery_D_90 = "ARTILLERY_D_90",
	Artillery_D_before_bridge4 = "ARTILLERY_D_before_bridge4",
	Artillery_D_before_bridge5 = "ARTILLERY_D_before_bridge5",
	Checkpoint_forwardflag = "CHECKPOINT_forwardflag",
	Flag_radioparts = "FLAG_radioparts",
	Cappoint_339 = "CAPPOINT_339",
	Build_Axis_Castle_MG = "BUILD_Axis_Castle_MG",
	Build_Bridge = "BUILD_Bridge",
	Build_Bridge_MG = "BUILD_Bridge_MG",
	Build_Command_Post = "BUILD_Command_Post",
	Build_Grate_Door = "BUILD_Grate_Door",
	Build_allied_Castle_MG = "BUILD_allied_Castle_MG",
	Build_Cave_Ladder = "BUILD_Cave_Ladder",
	Plant_Axis_Castle_MG = "PLANT_Axis_Castle_MG",
	Plant_Backgate = "PLANT_Backgate",
	Plant_Bridge = "PLANT_Bridge",
	Plant_Bridge_MG = "PLANT_Bridge_MG",
	Plant_Cave_Ladder = "PLANT_Cave_Ladder",
	Plant_Command_Post = "PLANT_Command_Post",
	Plant_Grate_Door = "PLANT_Grate_Door",
	Plant_Bunker_Wall = "PLANT_Bunker_Wall",
	Plant_Serpentine_Barricade = "PLANT_Serpentine_Barricade",
	Plant_allied_Castle_MG = "PLANT_allied_Castle_MG",
	Mount_336 = "MOUNTMG42_336",
	Mount_353 = "MOUNTMG42_353",
	Mount_355 = "MOUNTMG42_355",
	Mount_Axis_Castle_MG = "MOUNTMG42_Axis_Castle_MG",
	Mount_Bridge_MG = "MOUNTMG42_Bridge_MG",
	Mount_allied_Castle_MG = "MOUNTMG42_allied_Castle_MG",
	Mount_barricade_mg = "MOUNTMG42_barricade_mg",
	Mount_forward_spawn = "MOUNTMG42_forward_spawn",
	Repair_336 = "REPAIRMG42_336",
	Repair_353 = "REPAIRMG42_353",
	Repair_355 = "REPAIRMG42_355",
	Repair_Axis_Castle_MG = "REPAIRMG42_Axis_Castle_MG",
	Repair_Bridge_MG = "REPAIRMG42_Bridge_MG",
	Repair_allied_Castle_MG = "REPAIRMG42_allied_Castle_MG",
	Repair_barricade_mg = "REPAIRMG42_barricade_mg",
	Repair_forward_spawn = "REPAIRMG42_forward_spawn",
	Mobile_MG42_bridge2 = "MOBILEMG42_bridge2",
	Mobile_MG42_maindoor = "MOBILEMG42_maindoor",
	Plant_Mine_allied_mg = "PLANTMINE_allied_mg",
	Plant_Mine_allied_snipe1 = "PLANTMINE_allied_snipe1",
	Plant_Mine_backdoor1 = "PLANTMINE_backdoor1",
	Plant_Mine_backdoor2 = "PLANTMINE_backdoor2",
	Plant_Mine_barricade = "PLANTMINE_barricade",
	Plant_Mine_forest_hut = "PLANTMINE_forest_hut",
	Plant_Mine_forest_hut2 = "PLANTMINE_forest_hut2",
	Plant_Mine_forest_hut3 = "PLANTMINE_forest_hut3",
	Plant_Mine_frontgate = "PLANTMINE_frontgate",
	Plant_Mine_sniper_hut = "PLANTMINE_sniper_hut",

	Roles =
	{
		AXIS =
		{
			DEFENDER =
			{
				numbots = 2,
			},
		},
	},

	// increase TargetBreakableDist in this trigger region
	increasebreakabledist =
	{
		Name = "increasebreakabledist",
		TriggerOnClass = CLASS.ANYPLAYER,
		OnEnter = function(ent)
		{
			b = Util.IsBot(ent);
			if (b)
			{
				b.TargetBreakableDist = 570.0;
			}
			Util.MapDebugPrint( GetEntName(ent) + " entering." );
		},
		OnExit = function(ent)
		{
			b = Util.IsBot(ent);
			if (b)
			{
				b.TargetBreakableDist = 90.0;
			}
			Util.MapDebugPrint( GetEntName(ent) + " exiting." );
		},
	},

	Bridge_Built = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Bridge_Dyno = 0;

		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_before_bridge.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "MOUNTMG42_355" );
		if ( Map.Phase < 3 )
		{
			Map.Phase = 2;
			SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_barricade.*" );
			SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_forward_spawn.*" );
			SetAvailableMapGoals( TEAM.AXIS, true, "MOBILEMG42_forward_spawn.*" );
			SetAvailableMapGoals( TEAM.AXIS, false, "MOBILEMORTAR_bridge.*" );
			SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_bridge[789]" );
		}

		Util.MapDebugPrint( "Bridge_Built" );
	},

	Bridge_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Bridge_Dyno += 1;
		SetAvailableMapGoals( TEAM.AXIS, false, Map.Plant_Bridge );

		Util.MapDebugPrint( "Bridge_Planted" );
	},

	Bridge_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Bridge_Dyno -= 1;
		if ( Map.Bridge_Dyno < 1 && Map.Phase < 3 )
			{ SetAvailableMapGoals( TEAM.AXIS, true, Map.Plant_Bridge ); }

		Util.MapDebugPrint( "Bridge_Defused" );
	},

	Bridge_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }

		if ( Map.Phase < 3 )
		{
			Map.Phase = 1;
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_barricade.*" );
			SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_before_bridge.*" );
			SetAvailableMapGoals( TEAM.AXIS, false, "MOBILEMG42_forward_spawn.*" );
			SetAvailableMapGoals( TEAM.AXIS, true, "MOBILEMORTAR_bridge.*" );
		}

		Map.Bridge_Dyno = 0;

		Util.MapDebugPrint( "Bridge_Destroyed" );
	},

	Bridge_MG_Built = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "Bridge_MG_Built" );
	},

	Grate_Door_Built = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Grate_Door_Dyno = 0;

		if ( Map.Backgate_Status != "destroyed" )
			{ SetAvailableMapGoals( TEAM.ALLIES, false, "FLAG_radioparts" ); }

		Util.MapDebugPrint( "Grate_Door_Built" );
	},

	Grate_Door_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Grate_Door_Dyno += 1;
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Plant_Grate_Door );

		Util.MapDebugPrint( "Grate_Door_Planted" );
	},

	Grate_Door_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Grate_Door_Dyno -= 1;
		if ( Map.Grate_Door_Dyno < 1 )
			{ SetAvailableMapGoals( TEAM.ALLIES, true, Map.Plant_Grate_Door ); }

		Util.MapDebugPrint( "Grate_Door_Defused" );
	},

	Grate_Door_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Grate_Door_Dyno = 0;
		SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_radioparts" );

		Util.MapDebugPrint( "Grate_Door_Destroyed" );
	},
	
	
	Bunker_Wall_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Bunker_Wall_Dyno -= 1;
		Util.MapDebugPrint( "Bunker_Wall_Defused" );
	},
	
	
	Bunker_Wall_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Bunker_Wall_Dyno += 1;
		Util.MapDebugPrint( "Bunker_Wall_Planted" );
	},
	
	Bunker_Wall_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }
		
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Tunnel_Wall" );
		
		Util.MapDebugPrint( "Bunker_Wall_Destroyed" );
	},

	
	Cave_Ladder_Built = function( trigger )
	{
		if ( TestMap )
			{ return; }
		Wp.SetWaypointFlag( "ladder_low", "closed", false );
		Util.MapDebugPrint( "Cave_Ladder_Built" );
	},
	
	Cave_Ladder_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Cave_Ladder_Dyno += 1;
		Util.MapDebugPrint( "Cave_Ladder_Planted" );
	},
	
	Cave_Ladder_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Cave_Ladder_Dyno -= 1;
		Util.MapDebugPrint( "Cave_Ladder_Defused" );
	},

	Cave_Ladder_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }
		Wp.SetWaypointFlag( "ladder_low", "closed", true );
		Util.MapDebugPrint( "Cave_Ladder_Destroyed" );
	},
	
	
	Tunnel_Wall_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Tunnel_Wall_Dyno += 1;
		Util.MapDebugPrint( "Tunnel_Wall_Planted" );
	},
	
	
	Tunnel_Wall_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Tunnel_Wall_Dyno -= 1;
		Util.MapDebugPrint( "Tunnel_Wall_Defused" );
	},
	
	
	Tunnel_Wall_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "Tunnel_Wall_Destroyed" );
	},

	
	Backgate_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Backgate_Dyno += 1;
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Plant_Backgate );

		Util.MapDebugPrint( "Backgate_Planted" );
	},

	Backgate_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Backgate_Dyno -= 1;
		if ( Map.Backgate_Dyno < 1 )
			{ SetAvailableMapGoals( TEAM.ALLIES, true, Map.Plant_Backgate ); }

		Util.MapDebugPrint( "Backgate_Defused" );
	},

	Backgate_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Backgate_Dyno = 0;
		Map.Backgate_Status = "destroyed";
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_kurbel" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_radioparts" );

		Util.MapDebugPrint( "Backgate_Destroyed" );
	},

	Command_Post_Built = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Command_Post_Dyno = 0;

		Util.MapDebugPrint( "Command_Post_Built" );
	},

	Command_Post_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Command_Post_Dyno += 1;

		SetAvailableMapGoals( TEAM.AXIS, false, Map.Plant_Command_Post );
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Plant_Command_Post );

		Util.MapDebugPrint( "Command_Post_Planted" );
	},

	Command_Post_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Command_Post_Dyno -= 1;

		if ( Map.Command_Post_Dyno < 1 )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, Map.Plant_Command_Post );
			SetAvailableMapGoals( TEAM.ALLIES, true, Map.Plant_Command_Post );
		}

		Util.MapDebugPrint( "Command_Post_Defused" );
	},

	Command_Post_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Command_Post_Dyno = 0;

		Util.MapDebugPrint( "Command_Post_Destroyed" );
	},

	Serpentine_Barricade_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Serpentine_Barricade_Dyno += 1;
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Plant_Serpentine_Barricade );

		Util.MapDebugPrint( "Serpentine_Barricade_Planted" );
	},

	Serpentine_Barricade_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Serpentine_Barricade_Dyno -= 1;
		if ( Map.Serpentine_Barricade_Dyno < 1 )
			{ SetAvailableMapGoals( TEAM.ALLIES, true, Map.Plant_Serpentine_Barricade ); }

		Util.MapDebugPrint( "Serpentine_Barricade_Defused" );
	},

	Serpentine_Barricade_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }

		if ( Map.Phase < 3 )
		{
			Map.Phase = 3;
			SetAvailableMapGoals( TEAM.ALLIES, true, "GRENADE_castle.*" );
			SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_castle.*" );
			SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_kurbel" );
			SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Command_Post" );
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Command_Post" );
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Bunker_Wall" );

			SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_forest_hut.*" );
			SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_castle.*" );
			SetAvailableMapGoals( TEAM.AXIS, true, "SNIPE_castle.*" );
		}

		Wp.SetWaypointFlag( "serpentine2", "closed", false );
		Map.Serpentine_Barricade_Dyno = 0;
		Util.SetMaxUsersInProgress( 3, "FLAG_.*" );
		SetGoalPriority( "FLAG_radioparts", 0.7, TEAM.ALLIES );
		SetGoalPriority( "BUILD_Command_Post", 0.7, TEAM.ALLIES );

		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_forward_spawn.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "GRENADE_spawn_mg" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "GRENADE_serpentine.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "AIRSTRIKE_serpentine.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_bridge.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Bridge_MG" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "REPAIRMG42_Bridge_MG" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "MOUNTMG42_Bridge_MG" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Bridge" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "MOUNTMG42_355" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "REPAIRMG42_355" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "MOUNTMG42_forward_spawn" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "REPAIRMG42_forward_spawn" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "SWITCH_ladder_switch" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_allied_Castle_MG" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "MOUNTMG42_allied_Castle_MG" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "REPAIRMG42_allied_Castle_MG" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Grate_Door" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Backgate" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Command_Post" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Command_Post" );

		SetAvailableMapGoals( TEAM.AXIS, false, "TRIPMINE_axis_serpentine" );
		SetAvailableMapGoals( TEAM.AXIS, false, "TRIPMINE_axis_foward_hut" );
		SetAvailableMapGoals( TEAM.AXIS, false, "MOBILEMG42_forward_spawn.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_forward_spawn.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "SWITCH_ladder_switch" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_bridge.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_barricade.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Bridge" );
		SetAvailableMapGoals( TEAM.AXIS, false, "PLANTMINE_barricade" );
		SetAvailableMapGoals( TEAM.AXIS, false, "MOUNTMG42_barricade_mg" );
		SetAvailableMapGoals( TEAM.AXIS, false, "REPAIRMG42_barricade_mg" );
		SetAvailableMapGoals( TEAM.AXIS, false, "MOUNTMG42_forward_spawn" );
		SetAvailableMapGoals( TEAM.AXIS, false, "REPAIRMG42_forward_spawn" );
		SetAvailableMapGoals( TEAM.AXIS, false, "CALLARTILLERY_bridge.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "SNIPE_bridge.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "MOBILEMORTAR_bridge.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "PLANTMINE_frontgate" );
		SetAvailableMapGoals( TEAM.AXIS, true, "PLANTMINE_allied_mg" );
		SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Axis_Castle_MG" );
		SetAvailableMapGoals( TEAM.AXIS, true, "REPAIRMG42_Axis_Castle_MG" );
		SetAvailableMapGoals( TEAM.AXIS, true, "MOUNTMG42_Axis_Castle_MG" );
		SetAvailableMapGoals( TEAM.AXIS, true, "REPAIRMG42_336" );
		SetAvailableMapGoals( TEAM.AXIS, true, "MOUNTMG42_336" );
		SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_allied_Castle_MG" );
		SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Grate_Door" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_antenna4" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_antenna7" );
		SetAvailableMapGoals( TEAM.AXIS, true, "TRIPMINE_axis_main_door" );
		SetAvailableMapGoals( TEAM.AXIS, true, "TRIPMINE_axis_rear_gate" );

		Util.MapDebugPrint( "Serpentine_Barricade_Destroyed" );
	},

	radioparts_Taken = function( trigger )
	{
		if ( TestMap )
			{ return; }

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

		if ( Map.Phase >= 3 )
		{
			SetGoalPriority( "DEFEND_forest_hut.*", 0.51, TEAM.AXIS );
			SetGoalPriority( "ATTACK_transmitter.*", 0.6, TEAM.ALLIES );
		}
		SetGoalPriority( "DEFEND_transmitter.*", 0.6, TEAM.AXIS );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_forest_hut.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_transmitter.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "MOUNTMG42_Axis_Castle_MG" );
		SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Axis_Castle_MG" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_transmitter.*" );

		Util.MapDebugPrint( "radioparts_Taken" );
	},

	radioparts_Returned = function( trigger )
	{
		if ( TestMap )
			{ return; }

		SetAvailableMapGoals( TEAM.ALLIES, false, "SWITCH_antenna_switch" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_transmitter.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_transmitter.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_forest_hut.*" );

		Util.MapDebugPrint( "radioparts_Returned" );
	},

	radioparts_Secured = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.DisableGoal( ".*", true );
		Map.Phase = 4;
		Map.Transmitter_Status = 2;

		SetGoalPriority( "SWITCH_antenna_switch", 1.0 );
		SetGoalPriority( "DEFEND_antenna.*", 0.61 );
		SetGoalPriority( "DEFEND_antenna2", 0.75 );
		Util.SetMaxUsersInProgress( 3, "SWITCH_antenna_switch" );
		Util.SetMaxUsersInProgress( 1, "DEFEND_antenna.*" );
		Util.SetMaxUsersInProgress( 3, "ATTACK_antenna.*" );

		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_castle.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "SNIPE_castle.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "TRIPMINE_axis_antenna.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_antenna.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "MOUNTMG42_336" );
		SetAvailableMapGoals( TEAM.AXIS, true, "MOUNTMG42_Axis_Castle_MG" );
		SetAvailableMapGoals( TEAM.AXIS, true, "REPAIRMG42_Axis_Castle_MG" );
		SetAvailableMapGoals( TEAM.AXIS, true, "REPAIRMG42_336" );
		SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_allied_Castle_MG" );
		SetAvailableMapGoals( TEAM.AXIS, true, "HEALTHCAB_.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "AMMOCAB_.*" );

		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_antenna.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "REPAIRMG42_allied_Castle_MG" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_allied_Castle_MG" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "MOUNTMG42_allied_Castle_MG" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "HEALTHCAB_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "AMMOCAB_.*" );

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

		Util.MapDebugPrint( "radioparts_Secured" );
	},

	Antenna_Changed = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Antenna_Status = 2;
		SetAvailableMapGoals( TEAM.ALLIES, false, "SWITCH_antenna_switch" );
		SetAvailableMapGoals( TEAM.AXIS, true, "SWITCH_antenna_switch" );

		Util.MapDebugPrint( "Antenna_Changed" );
	},

	Antenna_Rearranged = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Antenna_Status = 1;
		if ( Map.Phase >= 3 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "SWITCH_antenna_switch" );
		}
		SetAvailableMapGoals( TEAM.AXIS, false, "SWITCH_antenna_switch" );

		Util.MapDebugPrint( "Antenna_Rearranged" );
	},

	Allies_Win = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "Allies_Win" );
	},

	forwardflag_Axis_Captured = function( trigger )
	{
		if ( TestMap )
			{ return; }

		SetAvailableMapGoals( TEAM.ALLIES, true, "GRENADE_spawn_mg" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "REPAIRMG42_forward_spawn" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "MOUNTMG42_forward_spawn" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "CHECKPOINT_forwardflag" );

		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_forward_spawn.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "CHECKPOINT_forwardflag" );
		SetAvailableMapGoals( TEAM.AXIS, true, "REPAIRMG42_forward_spawn" );
		SetAvailableMapGoals( TEAM.AXIS, true, "MOUNTMG42_forward_spawn" );

		Util.MapDebugPrint( "forwardflag_Axis_Captured" );
	},

	forwardflag_Allies_Captured = function( trigger )
	{
		if ( TestMap )
			{ return; }

		SetAvailableMapGoals( TEAM.ALLIES, false, "GRENADE_spawn_mg" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "REPAIRMG42_forward_spawn" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "MOUNTMG42_forward_spawn" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "CHECKPOINT_forwardflag" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_forward_spawn.*" );

		SetAvailableMapGoals( TEAM.AXIS, false, "MOBILEMG42_forward_spawn.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_forward_spawn.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "CHECKPOINT_forwardflag" );
		SetAvailableMapGoals( TEAM.AXIS, false, "REPAIRMG42_forward_spawn" );
		SetAvailableMapGoals( TEAM.AXIS, false, "MOUNTMG42_forward_spawn" );

		Util.MapDebugPrint( "forwardflag_Allies_Captured" );
	},

};

global OnMapLoad = function()
{
	if ( TestMapOn )
		{ Util.AutoTestMap(); }

	OnTrigger( "^1Allied team has built the Bridge!", Map.Bridge_Built );
	OnTrigger( "Planted at the Bridge.", Map.Bridge_Planted );
	OnTrigger( "Defused at the Bridge.", Map.Bridge_Defused );
	OnTrigger( "^1Axis team has destroyed the Bridge!", Map.Bridge_Destroyed );
	OnTrigger( "^1Allied team has built the Bridge MG!", Map.Bridge_MG_Built );

	OnTrigger( "^1Allied Command Post constructed. Charge speed increased! Forest Spawn", Map.Command_Post_Built );
	OnTrigger( "^1Axis Command Post constructed. Charge speed increased!", Map.Command_Post_Built );
	OnTrigger( "Planted at the Command Post.", Map.Command_Post_Planted );
	OnTrigger( "Defused at the Command Post.", Map.Command_Post_Defused );
	OnTrigger( "^1Axis team has damaged the Allied Command Post!", Map.Command_Post_Destroyed );
	OnTrigger( "^1Allied team has damaged the Axis Command Post!", Map.Command_Post_Destroyed );
	
	OnTrigger( "^1Allied Team Have Built The Cave Ladder!", Map.Cave_Ladder_Built );
	OnTrigger( "Planted at the Cave Ladder", Map.Cave_Ladder_Planted );
	OnTrigger( "Defused at the Cave Ladder", Map.Cave_Ladder_Defused );
	OnTrigger( "^1Axis Team Have Destroyed The Cave Ladder!", Map.Cave_Ladder_Destroyed );
	OnTrigger( "Planted at the Tunnel Wall", Map.Tunnel_Wall_Planted );
	OnTrigger( "Defused at the Tunnel Wall", Map.Tunnel_Wall_Defused );
	OnTrigger( "^1The Allies have breached the Tunnel Wall!", Map.Tunnel_Wall_Destroyed );
	OnTrigger( "Planted at the Bunker Wall", Map.Bunker_Wall_Planted );
	OnTrigger( "Defused at the Bunker Wall", Map.Bunker_Wall_Defused );
	OnTrigger( "^1The Allies have breached the Bunker Wall!", Map.Bunker_Wall_Destroyed );

	OnTrigger( "^1Axis team has rebuilt the Grate Door!", Map.Grate_Door_Built );
	OnTrigger( "Planted at the Grate Door.", Map.Grate_Door_Planted );
	OnTrigger( "Defused at the Grate Door.", Map.Grate_Door_Defused );
	OnTrigger( "^1Allied team has breached the Grate Door!", Map.Grate_Door_Destroyed );

	OnTrigger( "Planted at the Serpentine Barricade.", Map.Serpentine_Barricade_Planted );
	OnTrigger( "Defused at the Serpentine Barricade.", Map.Serpentine_Barricade_Defused );
	OnTrigger( "^1Allies have breached the Serpentine Barricade and secured the Forward", Map.Serpentine_Barricade_Destroyed );

	OnTrigger( "Planted at the Backgate.", Map.Backgate_Planted );
	OnTrigger( "Defused at the Backgate.", Map.Backgate_Defused );
	OnTrigger( "^1Backgate destroyed!", Map.Backgate_Destroyed );

	OnTrigger( "axis_modification_kit_taken", Map.radioparts_Taken );
	OnTrigger( "axis_modification_kit_returned", Map.radioparts_Returned );
	OnTrigger( "axis_they_modified_transmitter", Map.radioparts_Secured );

	OnTrigger( "^1Allies have changed the Antenna orientation!", Map.Antenna_Changed );
	OnTrigger( "^1Axis have rearranged the Antenna!", Map.Antenna_Rearranged );
	OnTrigger( "^1Allies are sending their pirate signal!", Map.Allies_Win );

	OnTrigger( "^1Axis reclaim the Forward Hut!", Map.forwardflag_Axis_Captured );
	OnTrigger( "^1Allies capture the Forward Hut!", Map.forwardflag_Allies_Captured );

	//OnTrigger( "^1Cave Ladder lowered!^7", Map.Ladder_Lowered );
	//OnTrigger( "^1Cave Ladder raised!^7", Map.Ladder_Raised );

	OnTriggerRegion( AABB(860,-5170,-920, 1450,-4790,-640), Map.increasebreakabledist );

	/*** GOALS ***/
	Util.DisableGoal( ".*", true ); // disable all but routes

	SetAvailableMapGoals( TEAM.ALLIES, true, "SWITCH_ladder_switch" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "GRENADE_serpentine.*" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "GRENADE_spawn_mg" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "GRENADE_barrier" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "AIRSTRIKE_serpentine.*" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "MOUNTMG42_355" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "REPAIRMG42_355" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "REPAIRMG42_Bridge_MG" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "MOUNTMG42_Bridge_MG" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_forward_spawn.*" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_bridge.*" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_before_bridge.*" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Bridge_MG" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Bridge" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Serpentine_Barricade" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "CHECKPOINT_forwardflag" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "CAPPOINT_339" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "HEALTHCAB_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "AMMOCAB_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Cave_Ladder" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "GRENADE_dunny" );

	SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Cave_Ladder" );
	SetAvailableMapGoals( TEAM.AXIS, true, "CHECKPOINT_forwardflag" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_bridge.*" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_bridge[789]" ); //disable these three
	SetAvailableMapGoals( TEAM.AXIS, true, "CALLARTILLERY_bridge.*" );
	SetAvailableMapGoals( TEAM.AXIS, true, "SNIPE_bridge.*" );
	SetAvailableMapGoals( TEAM.AXIS, true, "MOBILEMORTAR_bridge.*" );
	SetAvailableMapGoals( TEAM.AXIS, true, "PLANTMINE_forest_hut.*" );
	SetAvailableMapGoals( TEAM.AXIS, true, "PLANTMINE_backdoor[123]" );
	SetAvailableMapGoals( TEAM.AXIS, true, "PLANTMINE_barricade" );
	SetAvailableMapGoals( TEAM.AXIS, true, "PLANTMINE_tunnel.*" );
	SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Bridge" );
	SetAvailableMapGoals( TEAM.AXIS, true, "MOUNTMG42_barricade_mg" );
	SetAvailableMapGoals( TEAM.AXIS, true, "REPAIRMG42_barricade_mg" );
	SetAvailableMapGoals( TEAM.AXIS, true, "MOUNTMG42_forward_spawn" );
	SetAvailableMapGoals( TEAM.AXIS, true, "REPAIRMG42_forward_spawn" );
	SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Grate_Door" );
	SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Command_Post" );
	SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Command_Post" );
	SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Bridge_MG" );
	SetAvailableMapGoals( TEAM.AXIS, true, "HEALTHCAB_.*" );
	SetAvailableMapGoals( TEAM.AXIS, true, "AMMOCAB_.*" );
	SetAvailableMapGoals( TEAM.AXIS, true, "ARTILLERY_.*" );
	SetAvailableMapGoals( TEAM.AXIS, true, "GRENADE_tunnelentrance" ); // roled defenders have better cover inside
	SetAvailableMapGoals( TEAM.AXIS, true, "TRIPMINE_axis_serpentine" );
	SetAvailableMapGoals( TEAM.AXIS, true, "TRIPMINE_axis_foward_hut" );

	SetGoalPriority( "MOUNTMG42_Bridge_MG", 0.71, TEAM.ALLIES );
	SetGoalPriority( "MOUNTMG42_.*", 0.6, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_Axis_Castle_MG", 0.5, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_Bridge_MG", 0.5, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_allied_Castle_MG", 0.5, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( "BUILD_allied_Castle_MG", 0.7, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "FLAG_radioparts", 0.61, TEAM.ALLIES );
	SetGoalPriority( "ATTACK_kurbel", 0.6, TEAM.ALLIES );
	SetGoalPriority( "CHECKPOINT_forwardflag", 0.71 );
	SetGoalPriority( "GRENADE_.*", 0.65, TEAM.ALLIES );
	SetGoalPriority( "BUILD_Command_Post", 0.8, TEAM.AXIS );
	SetGoalPriority( "PLANTMINE_tunnel.*", 0.8, TEAM.AXIS );
	SetGoalPriority( "PLANTMINE_barricade", 0.8, TEAM.AXIS );
	SetGoalPriority( "SWITCH_antenna_switch", 0.8, TEAM.AXIS );
	SetGoalPriority( "DEFEND_bridge[789]", 0.71, TEAM.AXIS ); // roled goals

	//Util.SetRoleForGoals( "SWITCH_ladder_switch", ROLE.DEFENDER );

	// Goal positions
	Util.SetGoalPosition( -500, -6090, -935, "PLANT_Bridge" );
	Util.SetGoalOffset( 0, -40, -20, "BUILD_Bridge" );
	Util.SetGoalOffset( 10, -20, 0, "BUILD_allied_Castle_MG" );
	Util.SetGoalOffset( 40, 0, -20, "BUILD_Bridge_MG" );
	Util.AddUseWp( "PLANT_Grate_Door", "gratedoor1" );
	Util.AddUseWp( "PLANT_Grate_Door", "gratedoor2" );
	Util.AddUseWp( "PLANT_Bunker_Wall", "bunkerwall" );
	Util.AddUseWp( "PLANT_Tunnel_Wall", "tunnelwall" );

	// Flag some waypoints as closed
	Wp.SetWaypointFlag( "ladder_low", "closed", true );
	Wp.SetWaypointFlag( "serpentine2", "closed", true );

	// Set max. users
	Util.SetMaxUsers( 1, "DEFEND_.*" );
	Util.SetMaxUsers( 1, "MOUNTMG42.*" );
	Util.SetMaxUsers( 1, "REPAIRMG42_.*" );
	Util.SetMaxUsers( 1, "GRENADE_.*" );
	Util.SetMaxUsers( 1, "SWITCH_.*" );
	Util.SetMaxUsers( 1, "BUILD_.*" );
	Util.SetMaxUsers( 1, "PLANT_.*" );
	Util.SetMaxUsers( 1, "FLAG_.*" );
	Util.SetMaxUsers( 3, "CHECKPOINT_.*" );

	// Set Map Goal Properties
	SetMapGoalProperties( "MOUNTMG42_.*", {MinCampTime=10, MaxCampTime=90} );
	SetMapGoalProperties( "MOBILEMG42_.*", {MinCampTime=10, MaxCampTime=90} );
	SetMapGoalProperties( "DEFEND_.*", {MinCampTime=5, MaxCampTime=25} );
	SetMapGoalProperties( "ATTACK_.*", {MinCampTime=2, MaxCampTime=15} );
	SetMapGoalProperties( "ATTACK_kurbel", {MinCampTime=15, MaxCampTime=25} );
	SetMapGoalProperties( "BUILD_Bridge", {Stance="prone"} );

	/*** ROUTES ***/
	MapRoutes =
	{
		CAPPOINT_339 =
		{
			ROUTE_objective =
			{
				ROUTE_gate = {},
				ROUTE_arch = {}
			}
		},
		CHECKPOINT_forwardflag =
		{
			ROUTE_allied_spawn =
			{
				ROUTE_bridge3 = {},
				ROUTE_right = {},
				ROUTE_tree = {}
			}
		},
		GRENADE_spawn_mg =
		{
			ROUTE_allied_spawn =
			{
				ROUTE_bridge3 = {},
				ROUTE_right = { ROUTE_tree = {} }
			}
		},
		SWITCH_antenna_switch =
		{
			ROUTE_castle_spawn =
			{
				ROUTE_bridge = {},
				ROUTE_cellar = {},
				ROUTE_ladder = {},
				ROUTE_stairs = {},
			},
			ROUTE_forward_spawn =
			{
				ROUTE_gate =
				{
					ROUTE_bridge = {},
					ROUTE_cellar = {},
					ROUTE_ladder = {},
					ROUTE_stairs = {},
				},
				ROUTE_arch =
				{
					ROUTE_bridge = {},
					ROUTE_cellar = {},
					ROUTE_ladder = {},
					ROUTE_stairs = {},
				}
			}
		}
	};
	Util.Routes(MapRoutes);

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

global OnBotJoin = function( bot )
{
	bot.TargetBreakableDist = 90.0;
	// default all bots to spawning at the default location.
	bot.ChangeSpawnPoint(0);
	Util.ChangeBotSpawn( bot, TEAM.AXIS, 2, 2 );
};

