//==========================================================================================
//
//	industry_swe.gm
//
//	Who      	When		  What
//------------------------------------------------------------------------------------------
//	BMW	16 November 2012	  Initial Script
//
//==========================================================================================
//

global Map =
{
	Debug = 1, // please set to zero before distributing your script

	Allied_MG_Dyno = 0,
	Command_Post_Dyno = 0,
	Field_Radio_Dyno = 0,
	Safe_Dyno = 0,
	Tank_Barrier_1_Dyno = 0,
	Tank_Barrier_2_Dyno = 0,
	SafeOpen = 0,
	FieldRadioBuilt = 0,
	DoorDestroyed = 0,

	Allied_MG_Built = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "MOUNTMG42_Allied_MG" );
		SetAvailableMapGoals( TEAM.AXIS, true, "MOUNTMG42_Allied_MG" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Allied_MG" );
		Util.MapDebugPrint( "Allied_MG_Built" );
	},

	Allied_Command_Post_Built = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Command_Post" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Command_Post" );
		SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Command_Post" );
		Util.MapDebugPrint( "Allied_Command_Post_Built" );
	},

	Field_Radio_Built = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Field_Radio" );
		SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Field_Radio" );
		Map.FieldRadioBuilt = 1;
		if( Map.SafeOpen == 1 )
		{
			SetAvailableMapGoals(TEAM.AXIS, true, "FLAG_Das_Kochrezept" );
			SetGoalPriority( "FLAG_Das_Kochrezept", 0.93, TEAM.AXIS );
		}
		Util.MapDebugPrint( "Field_Radio_Built" );
	},

	Tank_Built = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, true, "ESCORT_tank" );
		SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Tank" );

		Util.MapDebugPrint( "Tank_Built" );
	},

	Tank_Barrier_1_Built = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Tank_Barrier_1" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Tank_Barrier_1" );
		Util.MapDebugPrint( "Tank_Barrier_1_Built" );
	},

	Tank_Barrier_2_Built = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Tank_Barrier_2" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Tank_Barrier_2" );
		Util.MapDebugPrint( "Tank_Barrier_2_Built" );
	},

	Allied_MG_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Allied_MG" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "MOUNTMG42_Allied_MG" );
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"MOUNTMG42_Allied_MG",
			"PLANT_Allied_MG",
		});
		Map.Allied_MG_Dyno = 0;

		Util.MapDebugPrint( "Allied_MG_Destroyed" );
	},

	Allied_Command_Post_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Command_Post" );
		SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Command_Post" );
		SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Command_Post" );
		Map.Command_Post_Dyno = 0;

		Util.MapDebugPrint( "Command_Post_Destroyed" );
	},

	Field_Radio_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Field_Radio" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Field_Radio" );
		SetAvailableMapGoals( TEAM.AXIS, false, "FLAG_Das_Kochrezept" );
		Map.FieldRadioBuilt = 0;
		Map.Field_Radio_Dyno = 0;

		Util.MapDebugPrint( "Field_Radio_Destroyed" );
	},

	Safe_Destroyed = function( trigger )
	{

		Map.Safe_Dyno = 0;
		Map.SafeOpen = 1;
		if( Map.FieldRadioBuilt == 1 )
		{
			SetAvailableMapGoals(TEAM.AXIS, true, "FLAG_Das_Kochrezept" );
			SetGoalPriority( "FLAG_Das_Kochrezept", 0.93, TEAM.AXIS );
		}
		SetGoalPriority( "BUILD_Field_Radio", 0.95, TEAM.AXIS, CLASS.ENGINEER );
		SetGoalPriority( "PLANT_Field_Radio", 0.95, TEAM.ALLIES, CLASS.COVERTOPS );
		SetGoalPriority( "PLANT_Field_Radio", 0.95, TEAM.ALLIES, CLASS.ENGINEER );
		Util.MapDebugPrint( "Safe_Destroyed" );
	},

	Tank_Barrier_1_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Tank_Barrier_1" );
		SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Tank_Barrier_1" );
		Map.Tank_Barrier_1_Dyno = 0;

		Util.MapDebugPrint( "Tank_Barrier_1_Destroyed" );
	},

	Tank_Barrier_2_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Tank_Barrier_2" );
		SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Tank_Barrier_2" );
		Map.Tank_Barrier_2_Dyno = 0;

		Util.MapDebugPrint( "Tank_Barrier_2_Destroyed" );
	},

	Das_Kochrezept_Taken = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, true, "CAPPOINT_70" );
		SetAvailableMapGoals( TEAM.AXIS, false, "FLAG_Das_Kochrezept" );
		Util.MapDebugPrint( "Das_Kochrezept_Taken" );
	},

	Das_Kochrezept_Returned = function( trigger )
	{
		if( Map.FieldRadioBuilt == 1 )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "FLAG_Das_Kochrezept" );
		}
		Util.MapDebugPrint( "Das_Kochrezept_Returned" );
	},

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

	Tank_Past_Barrier_1 = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Tank_Barrier_1" );
		SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Tank_Barrier_1" );
		Util.MapDebugPrint( "Tank_Past_Barrier_1" );
	},

	Tank_Past_Barrier_2 = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Tank_Barrier_2" );
		SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Tank_Barrier_2" );
		Util.MapDebugPrint( "Tank_Past_Barrier_2" );
	},


	Tank_Damaged = function( trigger )
	{
		if ( Map.DoorDestroyed == 0 )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Tank" );
			SetAvailableMapGoals( TEAM.AXIS, false, "ESCORT_tank" );
		}
		Util.MapDebugPrint( "Tank_Damaged" );
	},

	Axis_Command_Post_Built = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Command_Post" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Command_Post" );
		Util.MapDebugPrint( "Axis_Command_Post_Built" );
	},

	Axis_Command_Post_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Command_Post" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Command_Post" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Command_Post" );
		Util.MapDebugPrint( "Axis_Command_Post_Destroyed" );
	},

	Door_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Safe" );
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"BUILD_Tank",
			"ESCORT_tank",
		});
		SetGoalPriority( "PLANT_Safe", 0.90, TEAM.AXIS, CLASS.ENGINEER );
		SetGoalPriority( "BUILD_Field_Radio", 0.89, TEAM.AXIS, CLASS.ENGINEER );
		Map.DoorDestroyed = 1;
		Util.MapDebugPrint( "Door_Destroyed" );
	},

};

global OnMapLoad = function()
{
	// Register callback functions
	OnTrigger( "^3Allied MG nest constructed!", Map.Allied_MG_Built );
	OnTrigger( "Allied Command Post constructed. Charge speed increased!^3 CP Spawn activated!", Map.Allied_Command_Post_Built );
	OnTrigger( "^3The Axis Field Radio has been constructed.", Map.Field_Radio_Built );
	OnTrigger( "^3The Tank has been repaired!", Map.Tank_Built );
	OnTrigger( "^3Tank Barrier #1 has been constructed.", Map.Tank_Barrier_1_Built );
	OnTrigger( "^3Tank Barrier #2 has been constructed.", Map.Tank_Barrier_2_Built );
	OnTrigger( "^3Axis team has destroyed the Allied MG nest!", Map.Allied_MG_Destroyed );
	OnTrigger( "Axis team has destroyed the Allied Command Post!", Map.Allied_Command_Post_Destroyed );
	OnTrigger( "^3Allies have destroyed the Axis Field Radio.", Map.Field_Radio_Destroyed );
	OnTrigger( "Axis have destroyed the ^3Safe Door^1 !", Map.Safe_Destroyed );
	OnTrigger( "^3Tank Barrier #1 has been destroyed.", Map.Tank_Barrier_1_Destroyed );
	OnTrigger( "^3Tank Barrier #2 has been destroyed.", Map.Tank_Barrier_2_Destroyed );
	OnTrigger( "Axis have stolen Das Kochrezept!", Map.Das_Kochrezept_Taken );
	OnTrigger( "Allies have returned Das Kochrezept!", Map.Das_Kochrezept_Returned );
	OnTrigger( "^3The Tank is past the first Barrier!", Map.Tank_Past_Barrier_1 );
	OnTrigger( "^3The Tank is past the second Barrier!", Map.Tank_Past_Barrier_2 );
	OnTrigger( "^3The Tank has been damaged!", Map.Tank_Damaged );
	OnTrigger( "Axis Command Post constructed. Charge speed increased!^3 CP Spawn activated!", Map.Axis_Command_Post_Built );
	OnTrigger( "^3 Axis have Destroyed the Bunker Door !", Map.Door_Destroyed );
	OnTrigger( "Allied team has destroyed the Axis Command Post!", Map.Axis_Command_Post_Destroyed );


	Util.DisableGoal( ".*", true ); // all but routes
	SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_.*" );
	SetAvailableMapGoals( TEAM.AXIS, true, "MOUNTMG42_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "MOUNTMG42_.*" );
	SetAvailableMapGoals( TEAM.AXIS, true, "REPAIRMG42_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "REPAIRMG42_.*" );
	SetAvailableMapGoals( TEAM.AXIS, false, "MOUNTMG42_Allied_MG" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "MOUNTMG42_Allied_MG" );
	SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Allied_MG" );
	SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Command_Post" );
	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"PLANT_Command_Post",
		"AMMOCAB_.*",
	});
	SetAvailableMapGoals( TEAM.AXIS, true, "AMMOCAB_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "HEALTHCAB_.*" );
	SetAvailableMapGoals( TEAM.AXIS, true, "HEALTHCAB_.*" );

	SetGoalPriority( "BUILD_Tank", 0.89, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_Tank_Barrier_1", 0.90, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_Tank_Barrier_2", 0.90, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( "BUILD_Command_Post", 0.88, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( "BUILD_Field_Radio", 0.6, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_Command_Post", 0.85, TEAM.AXIS, CLASS.COVERTOPS );

	SetGoalPriority( "BUILD_Tank_Barrier_1", 0.90, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "BUILD_Tank_Barrier_2", 0.90, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "BUILD_Command_Post", 0.88, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "BUILD_Allied_MG", 0.88, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_Command_Post", 0.85, TEAM.ALLIES, CLASS.COVERTOPS );
	SetGoalPriority( "PLANT_Field_Radio", 1.00, TEAM.ALLIES, CLASS.COVERTOPS );


	// Max users per goal
	Util.SetMaxUsers( 1, "DEFEND_.*" );
	Util.SetMaxUsers( 1, "GRENADE_.*" );
	Util.SetMaxUsers( 1, "MOUNTMG42_.*" );

	// Camp times
	SetMapGoalProperties( "MOUNTMG42_.*", {MinCampTime=15, MaxCampTime=60} );
	SetMapGoalProperties( "MOBILEMG42_.*", {MinCampTime=10, MaxCampTime=60} );


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

global OnBotJoin = function( bot )
{
	bot.TargetBreakableDist = 90.0;
};

global InitializeRoutes = function()
{
	MapRoutes =
	{
	};
	Util.Routes(MapRoutes);
};
