//==========================================================================================
//
//	villagun_b1.gm
//
//	Who	When		What
//------------------------------------------------------------------------------------------
//	Maker	05 October 2017	Initial Script
//
//==========================================================================================
//

global Map =
{
	Debug = 0, // please set to zero before distributing your script
	ShowMovers = false,

	Anti_Aircraft_Roof_Gun_Dyno = 0,
	Command_Post_Dyno = 0,
	Garden_Anti_Aircraft_Gun_Dyno = 0,
	Side_Warehouse_Entrance_Dyno = 0,
	Villa_Gate_Dyno = 0,
	Villa_Ladder_Dyno = 0,

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

		Util.MapDebugPrint( "Command_Post_Built" );
	},

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

		Util.MapDebugPrint( "Villa_Gate_Built" );
	},

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

		Util.MapDebugPrint( "Villa_Ladder_Built" );
	},

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

		Map.Anti_Aircraft_Roof_Gun_Dyno += 1;
		Util.MapDebugPrint( "Anti_Aircraft_Roof_Gun_Planted" );
	},

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

		Map.Command_Post_Dyno += 1;
		Util.MapDebugPrint( "Command_Post_Planted" );
	},

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

		Map.Garden_Anti_Aircraft_Gun_Dyno += 1;
		Util.MapDebugPrint( "Garden_Anti_Aircraft_Gun_Planted" );
	},

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

		Map.Side_Warehouse_Entrance_Dyno += 1;
		Util.MapDebugPrint( "Side_Warehouse_Entrance_Planted" );
	},

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

		Map.Villa_Gate_Dyno += 1;
		Util.MapDebugPrint( "Villa_Gate_Planted" );
	},

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

		Map.Villa_Ladder_Dyno += 1;
		Util.MapDebugPrint( "Villa_Ladder_Planted" );
	},

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

		Map.Anti_Aircraft_Roof_Gun_Dyno -= 1;
		Util.MapDebugPrint( "Anti_Aircraft_Roof_Gun_Defused" );
	},

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

		Map.Command_Post_Dyno -= 1;
		Util.MapDebugPrint( "Command_Post_Defused" );
	},

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

		Map.Garden_Anti_Aircraft_Gun_Dyno -= 1;
		Util.MapDebugPrint( "Garden_Anti_Aircraft_Gun_Defused" );
	},

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

		Map.Side_Warehouse_Entrance_Dyno -= 1;
		Util.MapDebugPrint( "Side_Warehouse_Entrance_Defused" );
	},

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

		Map.Villa_Gate_Dyno -= 1;
		Util.MapDebugPrint( "Villa_Gate_Defused" );
	},

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

		Map.Villa_Ladder_Dyno -= 1;
		Util.MapDebugPrint( "Villa_Ladder_Defused" );
	},

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

		Map.Anti_Aircraft_Roof_Gun_Dyno = 0;

		Util.MapDebugPrint( "Anti_Aircraft_Roof_Gun_Destroyed" );
	},

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

		Map.Command_Post_Dyno = 0;

		Util.MapDebugPrint( "Command_Post_Destroyed" );
	},

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

		Map.Garden_Anti_Aircraft_Gun_Dyno = 0;

		Util.MapDebugPrint( "Garden_Anti_Aircraft_Gun_Destroyed" );
	},

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

		Map.Side_Warehouse_Entrance_Dyno = 0;

		Util.MapDebugPrint( "Side_Warehouse_Entrance_Destroyed" );
	},

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

		Map.Villa_Gate_Dyno = 0;

		Util.MapDebugPrint( "Villa_Gate_Destroyed" );
	},

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

		Map.Villa_Ladder_Dyno = 0;

		Util.MapDebugPrint( "Villa_Ladder_Destroyed" );
	},

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

		Util.MapDebugPrint( "desertspawn_Axis_Captured" );
	},

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

		Util.MapDebugPrint( "desertspawn_Allies_Captured" );
	},

};

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

	// Register callback functions
	OnTrigger( "MISSING_STRING", Map.Command_Post_Built );
	OnTrigger( "MISSING_STRING", Map.Villa_Gate_Built );
	OnTrigger( "MISSING_STRING", Map.Villa_Ladder_Built );
	OnTrigger( "Planted at the MISSING_STRING.", Map.Anti_Aircraft_Roof_Gun_Planted );
	OnTrigger( "Planted at the MISSING_STRING.", Map.Command_Post_Planted );
	OnTrigger( "Planted at the MISSING_STRING.", Map.Garden_Anti_Aircraft_Gun_Planted );
	OnTrigger( "Planted at the MISSING_STRING.", Map.Side_Warehouse_Entrance_Planted );
	OnTrigger( "Planted at the MISSING_STRING.", Map.Villa_Gate_Planted );
	OnTrigger( "Planted at the MISSING_STRING.", Map.Villa_Ladder_Planted );
	OnTrigger( "Defused at the MISSING_STRING.", Map.Anti_Aircraft_Roof_Gun_Defused );
	OnTrigger( "Defused at the MISSING_STRING.", Map.Command_Post_Defused );
	OnTrigger( "Defused at the MISSING_STRING.", Map.Garden_Anti_Aircraft_Gun_Defused );
	OnTrigger( "Defused at the MISSING_STRING.", Map.Side_Warehouse_Entrance_Defused );
	OnTrigger( "Defused at the MISSING_STRING.", Map.Villa_Gate_Defused );
	OnTrigger( "Defused at the MISSING_STRING.", Map.Villa_Ladder_Defused );
	OnTrigger( "MISSING_STRING", Map.Anti_Aircraft_Roof_Gun_Destroyed );
	OnTrigger( "MISSING_STRING", Map.Command_Post_Destroyed );
	OnTrigger( "MISSING_STRING", Map.Garden_Anti_Aircraft_Gun_Destroyed );
	OnTrigger( "MISSING_STRING", Map.Side_Warehouse_Entrance_Destroyed );
	OnTrigger( "MISSING_STRING", Map.Villa_Gate_Destroyed );
	OnTrigger( "MISSING_STRING", Map.Villa_Ladder_Destroyed );
	OnTrigger( "MISSING_STRING", Map.desertspawn_Axis_Captured );
	OnTrigger( "MISSING_STRING", Map.desertspawn_Allies_Captured );

	//~Util.DisableGoal( ".*", true ); // all but routes
	//~SetAvailableMapGoals( TEAM.AXIS, true, "ATTACK_.*" );
	//~SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_.*" );

	// Max users per goal
	Util.SetMaxUsers( 1, "ATTACK_.*" );
	Util.SetMaxUsers( 1, "DEFEND_.*" );
	Util.SetMaxUsers( 1, "GRENADE_.*" );
	Util.SetMaxUsers( 1, "SNIPE_.*" );
	Util.SetMaxUsers( 1, "MOUNTMG42_.*" );
	Util.SetMaxUsers( 1, "MOBILEMG42_.*" );
	Util.SetMaxUsers( 1, "MOBILEMORTAR_.*" );
	Util.SetMaxUsers( 1, "AIRSTRIKE_.*" );
	Util.SetMaxUsers( 1, "CALLARTILLERY_.*" );

	// 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 )
{
	// Uncomment for shootable breakables
	bot.TargetBreakableDist = 90.0;
	// Only set MaxViewDistance on maps with limited sight (e.g. fog)
	//~bot.MaxViewDistance = 2400;
};

global InitializeRoutes = function()
{
	MapRoutes =
	{
		BUILD_Villa_Gate =
		{
		},
		PLANT_Villa_Gate =
		{
		},
		PLANT_Garden_Anti_Aircraft_Gun =
		{
		},
		PLANT_Side_Warehouse_Entrance =
		{
		},
		BUILD_Command_Post =
		{
		},
		PLANT_Command_Post =
		{
		},
		CHECKPOINT_desertspawn =
		{
		},
		BUILD_Villa_Ladder =
		{
		},
		PLANT_Villa_Ladder =
		{
		},
		PLANT_Anti_Aircraft_Roof_Gun =
		{
		},
	};
	Util.Routes(MapRoutes);
};
