//==========================================================================================
//
//	nightcrawlers.gm
//
//	Who	When		What
//------------------------------------------------------------------------------------------
//	MickyP	28 October 2010	Initial Script
//
//==========================================================================================
//

global Map =
{
	antenna_Built = function()
	{
		Util.MapDebugPrint( "antenna_Built" );
	},

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

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

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

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

	antenna_Destroyed = function()
	{
		Map.antenna_Dyno = 0;

		Util.MapDebugPrint( "antenna_Destroyed" );
	},

	bridge_Destroyed = function()
	{
		Map.bridge_Dyno = 0;

		Util.MapDebugPrint( "bridge_Destroyed" );
	},

	command_post_Destroyed = function()
	{
		Map.command_post_Dyno = 0;

		Util.MapDebugPrint( "command_post_Destroyed" );
	},

	main_door_Destroyed = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "GRENADE_Wood" );
		Map.main_door_Dyno = 0;

		Util.MapDebugPrint( "main_door_Destroyed" );
	},

	protection_doors_Destroyed = function()
	{
		Map.protection_doors_Dyno = 0;

		Util.MapDebugPrint( "protection_doors_Destroyed" );
	},

	side_platform_Destroyed = function()
	{
		Map.side_platform_Dyno = 0;

		Util.MapDebugPrint( "side_platform_Destroyed" );
	},

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

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

	briefcase_Secured = function()
	{
		SetGoalPriority( "BUILD_antenna", 0.91 );
		SetAvailableMapGoals( TEAM.ALLIES, true, "SWITCH_Send" );
		Util.MapDebugPrint( "briefcase_Secured" );
	},

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

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

};

global OnMapLoad = function()
{
	// Register callback functions
	OnTrigger( "The antenna has been constructed", Map.antenna_Built );
	OnTrigger( "The bridge has been constructed", Map.bridge_Built );
	OnTrigger( "Allied Command Post constructed. Charge speed increased!", Map.command_post_Built );
	OnTrigger( "Axis Command Post constructed. Charge speed increased!", Map.command_post_Built );
	OnTrigger( "Protection doors have been constructed", Map.protection_doors_Built );
	OnTrigger( "The platform has been constructed", Map.side_platform_Built );
	OnTrigger( "The antenna has been destroyed", Map.antenna_Destroyed );
	OnTrigger( "The bridge has been destroyed", Map.bridge_Destroyed );
	OnTrigger( "Axis team has destroyed the Allied Command Post!", Map.command_post_Destroyed );
	OnTrigger( "Allied team has destroyed the Axis Command Post!", Map.command_post_Destroyed );
	OnTrigger( "Allies have breached the Main Entrance!", Map.main_door_Destroyed );
	OnTrigger( "The platform has been destroyed", Map.protection_doors_Destroyed );
	OnTrigger( "The platform has been destroyed", Map.side_platform_Destroyed );
	OnTrigger( "Allies have stolen Briefcase!", Map.briefcase_Taken );
	OnTrigger( "Flag returned briefcase!", Map.briefcase_Returned );
	OnTrigger( "Allies have secured the briefcase!", Map.briefcase_Secured );
	OnTrigger( "Axis reclaimed the Barrack!", Map.barracks_flag_Axis_Captured );
	OnTrigger( "Allies captured the Barrack!", Map.barracks_flag_Allies_Captured );

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

	Util.DisableGoal( "SWITCH_Send" );
	Util.DisableGoal( "GRENADE_Wood" );

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

	SetGoalPriority( "PLANT_main_door", 0.91 );
	SetGoalPriority( "GRENADE_Wood", 0.81 );

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

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

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