//==========================================================================================
//
//	tankrace_b1.gm
//
//	Who                    	When		What
//------------------------------------------------------------------------------------------
//	MickyP			19 May 2011	Initial Script
//
//==========================================================================================
//

global Map =
{

	Allied_Tank_At_Barrier = 0,
	Axis_Tank_At_Barrier = 0,
	Next_Allied_Barrier = 1,
	Next_Axis_Barrier = 1,

	Movers =
	{
		"MOVER_tank",
		"MOVER_tank2",
	},


	Allied_Tank_Built = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "ESCORT_Allied_Tank" );

		Util.MapDebugPrint( "Allied_Tank_Built" );
	},

	Allied_Tank_Damaged = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "ESCORT_Allied_Tank" );

		Util.MapDebugPrint( "Allied_Tank_Damaged" );
	},

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

	Allies_Tank_at_Barrier = function( trigger )
	{
		//		print(trigger.Entity);
		//		print(GetGameIdFromEntity(trigger.Entity));
		//		print( "Allies_Tank_at_Barrier" );

		if ( GetGameIdFromEntity(trigger.Entity) == 177 )
		{
			if (Map.Next_Axis_Barrier == 1 )
			{
				Util.MapDebugPrint( "Allies_Tank_at_Barrier_1" );
			}
			else
			{
				Util.MapDebugPrint( "Allies_Tank_at_Barrier_2" );
			}
		}
	},

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

	Allies_Tank_Past_Barrier_1 = function( trigger )
	{
		Map.Next_Allied_Barrier = 2;
		Util.MapDebugPrint( "Allies_Tank_Past_Barrier_1" );
	},

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

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

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

	Axis_Tank_Built = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, true, "ESCORT_Axis_Tank" );

		Util.MapDebugPrint( "Axis_Tank_Built" );
	},

	Axis_Tank_Damaged = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, false, "ESCORT_Axis_Tank" );

		Util.MapDebugPrint( "Axis_Tank_Damaged" );
	},

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

	Axis_Tank_at_Barrier = function( trigger )
	{
		//		print(trigger.Entity);
		//		print(GetGameIdFromEntity(trigger.Entity));

		if ( GetGameIdFromEntity(trigger.Entity) == 189 )
		{
			if (Map.Next_Allied_Barrier == 1 )
			{
				Util.MapDebugPrint( "Axis_Tank_at_Barrier_1" );
			}
			else
			{
				Util.MapDebugPrint( "Axis_Tank_at_Barrier_2" );
			}
		}
	},

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

	Axis_Tank_Past_Barrier_1 = function( trigger )
	{
		Map.Next_Axis_Barrier = 2;
		Util.MapDebugPrint( "Axis_Tank_Past_Barrier_1" );
	},

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

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



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

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

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

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

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

global OnMapLoad = function()
{
	// Register callback functions
	OnTrigger( "The Tank has been repaired!", Map.Allied_Tank_Built );
	OnTrigger( "The Allied Tank has been damaged!", Map.Allied_Tank_Damaged );

	OnTrigger( "Allied Tank Barrier #1 has been constructed.", Map.Allies_Tank_Barrier_1_Built );
	OnTrigger( "allies_destroy_barrier", Map.Allies_Tank_at_Barrier );
	OnTrigger( "Allied Tank Barrier #1 has been destroyed.", Map.Allies_Tank_Barrier_1_Destroyed );
	OnTrigger( "allies_tank_past_first", Map.Allies_Tank_Past_Barrier_1 );
	OnTrigger( "Allied Tank Barrier #2 has been constructed.", Map.Allies_Tank_Barrier_2_Built );
	OnTrigger( "Allied Tank Barrier #2 has been destroyed.", Map.Allies_Tank_Barrier_2_Destroyed );
	OnTrigger( "allies_tank_past_sec", Map.Allies_Tank_Past_Barrier_2 );

	OnTrigger( "The Axis Tank has been repaired!", Map.Axis_Tank_Built );
	OnTrigger( "The Axis Tank has been damaged!", Map.Axis_Tank_Damaged );

	OnTrigger( "Axis Tank Barrier #1 has been constructed.", Map.Axis_Tank_Barrier_1_Built );
	OnTrigger( "axis_destroy_barrier", Map.Axis_Tank_at_Barrier );
	OnTrigger( "Axis Tank Barrier #1 has been destroyed.", Map.Axis_Tank_Barrier_1_Destroyed );
	OnTrigger( "axis_tank_past_first", Map.Axis_Tank_Past_Barrier_1 );
	OnTrigger( "Axis Tank Barrier #2 has been constructed.", Map.Axis_Tank_Barrier_2_Built );
	OnTrigger( "Axis Tank Barrier #2 has been destroyed.", Map.Axis_Tank_Barrier_2_Destroyed );
	OnTrigger( "axis_tank_past_sec", Map.Axis_Tank_Past_Barrier_2 );

	OnTrigger( "Allied Command Post constructed. Charge speed increased!", Map.Neutral_Command_Post_Built );
	OnTrigger( "Axis team has destroyed the Allied Command Post!", Map.Neutral_Command_Post_Destroyed );
	OnTrigger( "Axis Command Post constructed. Charge speed increased!", Map.Neutral_Command_Post_Built );
	OnTrigger( "Allied team has destroyed the Axis Command Post!", Map.Neutral_Command_Post_Destroyed );

	OnTrigger( "The Allies have breached the Sewer Wall!", Map.Allied_Sewer_Wall_Destroyed );
	OnTrigger( "The Axis have breached the Sewer Wall!", Map.Axis_Sewer_Wall_Destroyed );

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

	SetAvailableMapGoals( TEAM.AXIS, true, {
		"BUILD_Axis_Tank",
		"BUILD_Allies_Tank_Barrier_1",
		"BUILD_Allies_Tank_Barrier_2",
		"BUILD_Neutral_Command_Post",
		"PLANT_Axis_Sewer_Wall",
		"PLANT_Axis_Tank_Barrier_1",
		"PLANT_Axis_Tank_Barrier_2",
		"PLANT_Neutral_Command_Post",
		"AMMOCAB_south_ammocabinet_1",
		"HEALTHCAB_south_healthcabinet_1",
	});

	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"BUILD_Allied_Tank",
		"BUILD_Axis_Tank_Barrier_1",
		"BUILD_Axis_Tank_Barrier_2",
		"BUILD_Neutral_Command_Post",
		"PLANT_Allied_Sewer_Wall",
		"PLANT_Allies_Tank_Barrier_1",
		"PLANT_Allies_Tank_Barrier_2",
		"PLANT_Neutral_Command_Post",
		"AMMOCAB_south_ammocabinet",
		"HEALTHCAB_south_healthcabinet",
	});

	Util.SetGoalOffset( -50, 0, 0, "PLANT_Axis_Sewer_Wall" );
	Util.SetGoalOffset( 50, 0, 0, "PLANT_Allied_Sewer_Wall" );

	// 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 )
{
};
