//==========================================================================================
//
//	rushers11.gm
//
//	Who		When		What
//------------------------------------------------------------------------------------------
//	BubbaG1		21 July 2012	Initial Script
//
//==========================================================================================
//

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

	Allied_Command_Post_Dyno = 0,
	Axis_Command_Post_Dyno = 0,
	Generator_Dyno = 0,
	Road_MG_Dyno = 0,
	West_Axis_Base_Fortification_Dyno = 0,

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

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

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

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

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

	Allied_Command_Post_Planted = function( trigger )
	{
		Map.Allied_Command_Post_Dyno += 1;
		Util.MapDebugPrint( "Allied_Command_Post_Planted" );
	},

	Axis_Command_Post_Planted = function( trigger )
	{
		Map.Axis_Command_Post_Dyno += 1;
		Util.MapDebugPrint( "Axis_Command_Post_Planted" );
	},

	Generator_Planted = function( trigger )
	{
		Map.Generator_Dyno += 1;
		Util.MapDebugPrint( "Generator_Planted" );
	},

	Road_MG_Planted = function( trigger )
	{
		Map.Road_MG_Dyno += 1;
		Util.MapDebugPrint( "Road_MG_Planted" );
	},

	West_Axis_Base_Fortification_Planted = function( trigger )
	{
		Map.West_Axis_Base_Fortification_Dyno += 1;
		Util.MapDebugPrint( "West_Axis_Base_Fortification_Planted" );
	},

	Allied_Command_Post_Defused = function( trigger )
	{
		Map.Allied_Command_Post_Dyno -= 1;
		Util.MapDebugPrint( "Allied_Command_Post_Defused" );
	},

	Axis_Command_Post_Defused = function( trigger )
	{
		Map.Axis_Command_Post_Dyno -= 1;
		Util.MapDebugPrint( "Axis_Command_Post_Defused" );
	},

	Generator_Defused = function( trigger )
	{
		Map.Generator_Dyno -= 1;
		Util.MapDebugPrint( "Generator_Defused" );
	},

	Road_MG_Defused = function( trigger )
	{
		Map.Road_MG_Dyno -= 1;
		Util.MapDebugPrint( "Road_MG_Defused" );
	},

	West_Axis_Base_Fortification_Defused = function( trigger )
	{
		Map.West_Axis_Base_Fortification_Dyno -= 1;
		Util.MapDebugPrint( "West_Axis_Base_Fortification_Defused" );
	},

	Old_City_Gate_Destroyed = function( trigger )
	{

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

		Util.MapDebugPrint( "Old_City_Gate_Destroyed" );
	},

	Bridg_Doors_Destroyed = function( trigger )
	{

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"MOUNTMG42_513",
			"PLANT_Allied_Command_Post",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"BUILD_West_Axis_Base_Fortification",
			"PLANTMINE_generator_.*",
		});

		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Axis_Command_Post" );

		Util.MapDebugPrint( "Bridg_Doors_Destroyed" );
	},

	Generator_Gates_Destroyed = function( trigger )
	{

		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"PLANT_West_Axis_Base_Fortification",
			"PLANT_Generator",
		});

		Util.MapDebugPrint( "Generator_Gates_Destroyed" );
	},

	Generator_Side_Wall_Destroyed = function( trigger )
	{

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"BUILD_Tank",
			"MOVER_tank",
			"MOUNT_tank",
			"ESCORT_tank",
		});

		Util.MapDebugPrint( "Generator_Side_Wall_Destroyed" );
	},

	Allied_Command_Post_Destroyed = function( trigger )
	{
		Map.Allied_Command_Post_Dyno = 0;

		Util.MapDebugPrint( "Allied_Command_Post_Destroyed" );
	},

	Axis_Command_Post_Destroyed = function( trigger )
	{
		Map.Axis_Command_Post_Dyno = 0;

		Util.MapDebugPrint( "Axis_Command_Post_Destroyed" );
	},

	Generator_Destroyed = function( trigger )
	{
		Map.Generator_Dyno = 0;

		Util.MapDebugPrint( "Generator_Destroyed" );
	},

	Road_MG_Destroyed = function( trigger )
	{
		Map.Road_MG_Dyno = 0;

		Util.MapDebugPrint( "Road_MG_Destroyed" );
	},

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

	West_Axis_Base_Fortification_Destroyed = function( trigger )
	{
		Map.West_Axis_Base_Fortification_Dyno = 0;

		Util.MapDebugPrint( "West_Axis_Base_Fortification_Destroyed" );
	},

};

global OnMapLoad = function()
{
	// Register callback functions
	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( "Allied team has constructed the Road MG Nest!", Map.Road_MG_Built );
	OnTrigger( "The Tank has been repaired", Map.Tank_Built );
	OnTrigger( "Axis team has constructed the West Axis Base Fortification!", Map.West_Axis_Base_Fortification_Built );
	OnTrigger( "Planted at the Allied Command Post.", Map.Allied_Command_Post_Planted );
	OnTrigger( "Planted at the Axis Command Post.", Map.Axis_Command_Post_Planted );
	OnTrigger( "Planted at the Generator.", Map.Generator_Planted );
	OnTrigger( "Planted at the Road MG.", Map.Road_MG_Planted );
	OnTrigger( "Planted at the West Axis Base Fortification.", Map.West_Axis_Base_Fortification_Planted );
	OnTrigger( "Defused at the Allied Command Post.", Map.Allied_Command_Post_Defused );
	OnTrigger( "Defused at the Axis Command Post.", Map.Axis_Command_Post_Defused );
	OnTrigger( "Defused at the Generator.", Map.Generator_Defused );
	OnTrigger( "Defused at the Road MG.", Map.Road_MG_Defused );
	OnTrigger( "Defused at the West Axis Base Fortification.", Map.West_Axis_Base_Fortification_Defused );
	OnTrigger( "Allied team has breached the Old city Gate!", Map.Old_City_Gate_Destroyed );
	OnTrigger( "Allied team has breached the Bridg Doors!", Map.Bridg_Doors_Destroyed );
	OnTrigger( "Allied team has breached the Generator Gates!", Map.Generator_Gates_Destroyed );
	OnTrigger( "Allied team has breached the Generator Side Wall!", Map.Generator_Side_Wall_Destroyed );
	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 );
	OnTrigger( "Allied team has destroyed the Axis Generator!", Map.Generator_Destroyed );
	OnTrigger( "Axis team has destroyed the Road MG Nest!", Map.Road_MG_Destroyed );
	OnTrigger( "The Tank has been damaged", Map.Tank_Destroyed );
	OnTrigger( "Allied team has destroyed the West Axis Base Fortification!", Map.West_Axis_Base_Fortification_Destroyed );

	Util.AddUsePoint( "BUILD_West_Axis_Base_Fortification", { Vec3(2136, 861, -444), Vec3(2088, 912, -444) } );
	Util.AddUsePoint( "PLANT_Axis_Command_Post", { Vec3(-2750, 2060, 184), Vec3(-2698, 2097, 184) } );

	SetAvailableMapGoals( TEAM.AXIS, false, ".*" );
	SetAvailableMapGoals( TEAM.AXIS, true, {
		"AMMOCAB_.*",
		"BUILD_Axis_Command_Post",
		"HEALTHCAB_.*",
		"MOUNTMG42_513",
		"PLANT_Allied_Command_Post",
	});

	SetAvailableMapGoals( TEAM.ALLIES, false, ".*" );
	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"AMMOCAB_.*",
		"BUILD_Allied_Command_Post",
		"BUILD_Tank",
		"ESCORT_tank",
		"HEALTHCAB_.*",
		"MOVER_tank",
		"MOUNT_tank",
	});

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

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


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

global OnBotJoin = function( bot )
{
};

global InitializeRoutes = function()
{
	MapRoutes =
	{
		BUILD_West_Axis_Base_Fortification =
		{
		},
		BUILD_Axis_Command_Post =
		{
		},
		BUILD_Allied_Command_Post =
		{
		},
		BUILD_Road_MG =
		{
		},
		BUILD_Tank =
		{
		},
		PLANT_Generator =
		{
		},
		PLANT_Road_MG =
		{
		},
		PLANT_West_Axis_Base_Fortification =
		{
		},
		PLANT_Allied_Command_Post =
		{
		},
		PLANT_Axis_Command_Post =
		{
		},
	};
	Util.Routes(MapRoutes);
};
