//==========================================================================================
//
//	bloody_hill.gm
//
//	Who     	When		What
//------------------------------------------------------------------------------------------
//	.MaNgO		26 October 2010	Initial Script
//
//==========================================================================================
//
// Basic Script 

global Map =
{
	Debug = 0,
	ShowMovers = false,

	Allied_cp_Dyno = 0,
	Axis_Command_Post_Dyno = 0,
	safe_door_Dyno = 0,
	
		
	Allied_cp_Built = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "Allied_cp_Built" );
	},

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

		Util.MapDebugPrint( "Axis_Command_Post_Built" );
	},

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

		Map.Allied_cp_Dyno += 1;
		Util.MapDebugPrint( "Allied_cp_Planted" );
	},

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

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

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

		Map.safe_door_Dyno += 1;
		Util.MapDebugPrint( "safe_door_Planted" );
	},

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

		Map.Allied_cp_Dyno -= 1;
		Util.MapDebugPrint( "Allied_cp_Defused" );
	},

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

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

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

		Map.safe_door_Dyno -= 1;
		Util.MapDebugPrint( "safe_door_Defused" );
	},

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

		Map.Allied_cp_Dyno = 0;

		Util.MapDebugPrint( "Allied_cp_Destroyed" );
	},

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

		Map.Axis_Command_Post_Dyno = 0;

		Util.MapDebugPrint( "Axis_Command_Post_Destroyed" );
	},

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

		Map.safe_door_Dyno = 0;

		Util.MapDebugPrint( "safe_door_Destroyed" );
	},

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

		Util.MapDebugPrint( "secret_papers_Taken" );
	},

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

		Util.MapDebugPrint( "secret_papers_Returned" );
	},

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

		Util.MapDebugPrint( "secret_papers_Secured" );
	},

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

		Util.MapDebugPrint( "spawnflagforwardspwn_Axis_Captured" );
	},

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

		Util.MapDebugPrint( "spawnflagforwardspwn_Allies_Captured" );
	},

};

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

	// Register callback functions
	OnTrigger( "Allied Command Post constructed. Charge speed increased!", Map.Allied_cp_Built );
	OnTrigger( "Axis Command Post constructed. Charge speed increased!", Map.Axis_Command_Post_Built );
	OnTrigger( "Planted at Allied cp.", Map.Allied_cp_Planted );
	OnTrigger( "Planted at the Axis Command Post.", Map.Axis_Command_Post_Planted );
	OnTrigger( "Planted at safe_door.", Map.safe_door_Planted );
	OnTrigger( "Defused at Allied cp.", Map.Allied_cp_Defused );
	OnTrigger( "Defused at the Axis Command Post.", Map.Axis_Command_Post_Defused );
	OnTrigger( "Defused at safe_door.", Map.safe_door_Defused );
	OnTrigger( "Axis team has destroyed the Allied Command Post!", Map.Allied_cp_Destroyed );
	OnTrigger( "Allied team has destroyed the Axis Command Post!", Map.Axis_Command_Post_Destroyed );
	OnTrigger( "allied have blown the safedoor", Map.safe_door_Destroyed );
	OnTrigger( "Allies have stolen secret papers!", Map.secret_papers_Taken );
	OnTrigger( "Flag returned secret_papers!", Map.secret_papers_Returned );
	OnTrigger( "allied transmitted the secret docs!!", Map.secret_papers_Secured );
	OnTrigger( "CHECKPOINT_spawnflagforwardspwn to team 1", Map.spawnflagforwardspwn_Axis_Captured );
	OnTrigger( "CHECKPOINT_spawnflagforwardspwn to team 2", Map.spawnflagforwardspwn_Allies_Captured );
		
	
	//~Util.DisableGoal( ".*", true ); // all but routes
	//~SetAvailableMapGoals( TEAM.AXIS, true, "ATTACK_.*" );
	//~SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, true, GRENADE_.*" );
	
	// 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} );

	if ( Map.Debug > 1 )
		{ Util.ShowActiveGoals(); }

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

global OnBotJoin = function( bot )
{
	// Uncomment for shootable breakables
	bot.TargetBreakableDist = 240.0; // not tested for the breakable Transmitterdoor
	// Only set MaxViewDistance on maps with limited sight (e.g. fog)
	//~bot.MaxViewDistance = 2400;
};
