//==========================================================================================
//
//	wolken5_fp.gm
//
//	Who                  	When		What
//------------------------------------------------------------------------------------------
//	maker@bigsighstudios.com	15 October 2017	Initial Script
//
//==========================================================================================
//

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

	Airships_Engine_Dyno = 0,
	Command_Post_Dyno = 0,
	Main_Entrance_Dyno = 0,
	Top_Entrance_Dyno = 0,

	Command_Post_Built = function( trigger )
	{
		if ( TestMap ) { return; }
		Util.EnableGoal( "AMMOCAB_tankbay_ammocabinet", true );
		Util.EnableGoal( "AMMOCAB_tankbay_healthcabinet", true );

		Util.MapDebugPrint( "Command_Post_Built" );
	},

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

		Map.Airships_Engine_Dyno += 1;
		Util.MapDebugPrint( "Airships_Engine_Planted" );
	},

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

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

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

		Map.Main_Entrance_Dyno += 1;
		Util.MapDebugPrint( "Main_Entrance_Planted" );
	},

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

		Map.Top_Entrance_Dyno += 1;
		Util.MapDebugPrint( "Top_Entrance_Planted" );
	},

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

		Map.Airships_Engine_Dyno -= 1;
		Util.MapDebugPrint( "Airships_Engine_Defused" );
	},

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

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

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

		Map.Main_Entrance_Dyno -= 1;
		Util.MapDebugPrint( "Main_Entrance_Defused" );
	},

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

		Map.Top_Entrance_Dyno -= 1;
		Util.MapDebugPrint( "Top_Entrance_Defused" );
	},

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

		Map.Airships_Engine_Dyno = 0;

		Util.MapDebugPrint( "Airships_Engine_Destroyed" );
	},

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

		Map.Command_Post_Dyno = 0;

		Util.MapDebugPrint( "Command_Post_Destroyed" );
	},

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

		Map.Main_Entrance_Dyno = 0;

		Util.MapDebugPrint( "Main_Entrance_Destroyed" );
	},

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

		Map.Top_Entrance_Dyno = 0;

		Util.MapDebugPrint( "Top_Entrance_Destroyed" );
	},

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

		Util.MapDebugPrint( "forwardspawn1_flag_Axis_Captured" );
	},

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

		Util.MapDebugPrint( "forwardspawn1_flag_Allies_Captured" );
	},

};

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

	// Register callback functions
	OnTrigger( "Allied Command Post constructed. Charge speed increased!", Map.Command_Post_Built );// > if ALLIED, AMMOCAB_tankbay_ammocabinet
	OnTrigger( "Planted at the Command Post.", Map.Command_Post_Planted ); //both teams
	OnTrigger( "Defused at the Command Post.", Map.Command_Post_Defused );
	OnTrigger( "Axis Team has destroyed the Allied Command Post!", Map.Command_Post_Destroyed );
	
	OnTrigger( "Planted at the Airships Engine.", Map.Airships_Engine_Planted );
	OnTrigger( "Defused at the Airships Engine.", Map.Airships_Engine_Defused );
	OnTrigger( "The Airships Engine has been destroyed!", Map.Airships_Engine_Destroyed );

	OnTrigger( "Planted at the Main Entrance.", Map.Main_Entrance_Planted );
	OnTrigger( "Defused at the Main Entrance.", Map.Main_Entrance_Defused );
	OnTrigger( "Defused at the Main Entrance", Map.Main_Entrance_Destroyed );

	OnTrigger( "Planted at the Top Entrance.", Map.Top_Entrance_Planted );
	OnTrigger( "Defused at the Top Entrance.", Map.Top_Entrance_Defused );
	OnTrigger( "Top Entrance destroyed!", Map.Top_Entrance_Destroyed );

	OnTrigger( "MISSING_STRING", Map.forwardspawn1_flag_Axis_Captured );
	OnTrigger( "MISSING_STRING", Map.forwardspawn1_flag_Allies_Captured );

	//~Util.DisableGoal( ".*", true ); // all but routes
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_.*" );
	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} );

	//enable only after ALLIED CP built
	Util.DisableGoal( "AMMOCAB_tankbay_ammocabinet", true );
	Util.DisableGoal( "AMMOCAB_tankbay_healthcabinet", true );

	Util.AddUsePoint( "PLANT_Airships_Engine", Vec3( 1036, 521, 588 ) );

	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 =
	{
		PLANT_Top_Entrance =
		{
		},
		PLANT_Main_Entrance =
		{
		},
		PLANT_Airships_Engine =
		{
		},
		CHECKPOINT_forwardspawn1_flag =
		{
		},
		BUILD_Command_Post =
		{
		},
		PLANT_Command_Post =
		{
		},
	};
	Util.Routes(MapRoutes);
};
