//=============================================================================
//
//  Transmitter - transmitter.gm
//
//  Who         When                What
//-----------------------------------------------------------------------------
//	Mateos		6th December 2016	Avoid Axis Engi/Covi trying to destroy the
//									Allied MG at the first Allied spawn after
//									the Serpentine Barricade destruction;
//									Tiny cleanup
//	d00d		2011 - 2014			Several updates and improvements
//	crapshoot	2nd July 2010		0.8 ET
//
//=============================================================================

global Map =
{
	Debug = 0,	// Please set to zero before distributing your script

	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,

	t_breakable_dist_low = 0,		// Default distance for targetting breakable objects
	t_breakable_dist_high = 570,	// Target breakable distance inside trigger regions

	Backgate_Status = "closed",
	Antenna_Status = 1,
	Transmitter_Status = 1,

	Phase = 1,

	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 = Map.t_breakable_dist_high;
			}
			Util.MapDebugPrint( GetEntName(ent) + " entering." );
		},
		OnExit = function(ent)
		{
			b = Util.IsBot(ent);
			if (b)
			{
				b.TargetBreakableDist = Map.t_breakable_dist_low;
			}
			Util.MapDebugPrint( GetEntName(ent) + " exiting." );
		},
	},

	Bridge_Built = function( trigger )
	{
		Map.Bridge_Dyno = 0;

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

		Util.MapDebugPrint( "Bridge_Built" );
	},

	Bridge_Planted = function( trigger )
	{
		Map.Bridge_Dyno += 1;
		SetAvailableMapGoals( TEAM.AXIS, false, Map.Plant_Bridge );

		Util.MapDebugPrint( "Bridge_Planted" );
	},

	Bridge_Defused = function( trigger )
	{
		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 ( 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 )
	{
		Util.MapDebugPrint( "Bridge_MG_Built" );
	},

	Grate_Door_Built = function( trigger )
	{
		Map.Grate_Door_Dyno = 0;
		Util.MapDebugPrint( "Grate_Door_Built" );
	},

	Grate_Door_Planted = function( trigger )
	{
		Map.Grate_Door_Dyno += 1;
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Plant_Grate_Door );

		Util.MapDebugPrint( "Grate_Door_Planted" );
	},

	Grate_Door_Defused = function( trigger )
	{
		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 )
	{
		Map.Grate_Door_Dyno = 0;
		Util.MapDebugPrint( "Grate_Door_Destroyed" );
	},

	castle_main_gate_moving = function( trigger )
	{
		z = ToVector(trigger.Action).z;
		if ( z < 0 )
		{
			Util.MapDebugPrint( "Gate closing.", true );
			Map.Backgate_Status = "closed";
		}
		else
		{
			Util.MapDebugPrint( "Gate opening.", true );
			Map.Backgate_Status = "open";
		}
	},

	Backgate_Planted = function( trigger )
	{
		Map.Backgate_Dyno += 1;
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Plant_Backgate );

		Util.MapDebugPrint( "Backgate_Planted" );
	},

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

		Util.MapDebugPrint( "Backgate_Defused" );
	},

	Backgate_Destroyed = function( trigger )
	{
		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 )
	{
		Map.Command_Post_Dyno = 0;

		Util.MapDebugPrint( "Command_Post_Built" );
	},

	Command_Post_Planted = function( trigger )
	{
		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 )
	{
		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 )
	{
		Map.Command_Post_Dyno = 0;

		Util.MapDebugPrint( "Command_Post_Destroyed" );
	},

	Serpentine_Barricade_Planted = function( trigger )
	{
		Map.Serpentine_Barricade_Dyno += 1;
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Plant_Serpentine_Barricade );

		Util.MapDebugPrint( "Serpentine_Barricade_Planted" );
	},

	Serpentine_Barricade_Defused = function( trigger )
	{
		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 ( Map.Phase < 3 )
		{
			Map.Phase = 3;
			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"GRENADE_castle.*",
				"ATTACK_castle.*",
				"ATTACK_kurbel",
				"BUILD_Command_Post",
				"PLANT_Command_Post",
			});

			SetAvailableMapGoals( TEAM.AXIS, true, {
				"DEFEND_forest_hut.*",
				"DEFEND_castle.*",
				"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.*",
			"GRENADE_spawn_mg",
			"GRENADE_serpentine.*",
			"AIRSTRIKE_serpentine.*",
			"ATTACK_bridge.*",
			"BUILD_Bridge_MG",
			"REPAIRMG42_Bridge_MG",
			"MOUNTMG42_Bridge_MG",
			"BUILD_Bridge",
			"MOUNTMG42_623",
			"REPAIRMG42_623",
			"MOUNTMG42_forward_spawn",
			"REPAIRMG42_forward_spawn",
			"SWITCH_ladder_switch",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"BUILD_allied_Castle_MG",
			"MOUNTMG42_allied_Castle_MG",
			"REPAIRMG42_allied_Castle_MG",
			"PLANT_Grate_Door",
			"PLANT_Backgate",
			"BUILD_Command_Post",
			"PLANT_Command_Post",
			"FLAG_radioparts",
		});

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

		Util.MapDebugPrint( "Serpentine_Barricade_Destroyed" );
	},

	radioparts_Taken = function( trigger )
	{
		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.*",
			"MOUNTMG42_Axis_Castle_MG",
			"BUILD_Axis_Castle_MG",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_transmitter.*" );

		Util.MapDebugPrint( "radioparts_Taken" );
	},

	radioparts_Returned = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"SWITCH_antenna_switch",
			"ATTACK_transmitter.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_transmitter.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_forest_hut.*" );

		Util.MapDebugPrint( "radioparts_Returned" );
	},

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

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

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

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

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

		Util.MapDebugPrint( "radioparts_Secured" );
	},

	Antenna_Changed = function( trigger )
	{
		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 )
	{
		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 )
	{
		Util.MapDebugPrint( "Allies_Win" );
	},

	forwardflag_Axis_Captured = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "GRENADE_spawn_mg" );
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"REPAIRMG42_forward_spawn",
			"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",
			"MOUNTMG42_forward_spawn",
		});

		Util.MapDebugPrint( "forwardflag_Axis_Captured" );
	},

	forwardflag_Allies_Captured = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "GRENADE_spawn_mg" );
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"REPAIRMG42_forward_spawn",
			"MOUNTMG42_forward_spawn",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, "CHECKPOINT_forwardflag" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_forward_spawn.*" );

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

		Util.MapDebugPrint( "forwardflag_Allies_Captured" );
	},

	Ladder_Raised = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, false, "SWITCH_ladder_switch" );
		Wp.SetWaypointFlag( "ladder_low", "closed", true );
		if ( Map.Phase < 3 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "SWITCH_ladder_switch" );
		}

		Util.MapDebugPrint( "Ladder_Raised" );
	},

	Ladder_Lowered = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "SWITCH_ladder_switch" );
		Wp.SetWaypointFlag( "ladder_low", "closed", false );
		if ( Map.Phase < 3 )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "SWITCH_ladder_switch" );
		}

		Util.MapDebugPrint( "Ladder_Lowered" );
	},
};

global OnMapLoad = function()
{
	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( "^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 );
	OnTrigger( "backdoor_goto", Map.castle_main_gate_moving );

	OnTriggerRegion( AABB(860,-5170,-920, 1450,-4790,-640), Map.increasebreakabledist );
	OnTriggerRegion( AABB(703,-7324,-870, 821,-7112,-745), Map.increasebreakabledist );

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

	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"SWITCH_ladder_switch",
		"GRENADE_serpentine.*",
		"GRENADE_spawn_mg",
		"GRENADE_barrier",
		"AIRSTRIKE_serpentine.*",
		"MOUNTMG42_623",
		"REPAIRMG42_623",
		"REPAIRMG42_Bridge_MG",
		"MOUNTMG42_Bridge_MG",
		"ATTACK_forward_spawn.*",
		"ATTACK_bridge.*",
		"ATTACK_before_bridge.*",
		"BUILD_Bridge_MG",
		"BUILD_Bridge",
		"PLANT_Serpentine_Barricade",
		"CHECKPOINT_forwardflag",
		"CAPPOINT_339",
		"HEALTHCAB_.*",
		"AMMOCAB_.*",
	});

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

	// 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=70} );

	/*** 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_radio_parts =
			{
				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 executed." );
};

global OnBotJoin = function( bot )
{
	bot.TargetBreakableDist = Map.t_breakable_dist_low;
	Util.ChangeBotSpawn( bot, TEAM.AXIS, 2, 2 );
};
