//==========================================================================================
//
//	bunker_sg1945_3.gm
//
//	Who             When			What
//------------------------------------------------------------------------------------------
//	MickyP		Jan 2011		Initial Script
//
//==========================================================================================
//

global Map =
{
	Naquada_on_truck = false,
	Escorting = false,


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

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

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

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

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

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

	Tank_Stolen = function()
	{

		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"BUILD_Command_Post",
			"PLANT_Command_Post",
			"PLANT_Tank_Barrier_1",
			"PLANT_South_base_MG",
		});

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"AMMOCAB_t3",
			"HEALTHCAB_t2",
		});

		SetAvailableMapGoals( TEAM.AXIS, true, {
			"MOUNTMG42_east",
			"REPAIRMG42_east",
			"MOUNTMG42_west",
			"REPAIRMG42_west",
		});


		SetAvailableMapGoals( TEAM.AXIS, false, {
			"BUILD_Command_Post",
			"BUILD_South_base_MG",
			"MOUNTMG42_South_base_MG",
			"REPAIRMG42_South_base_MG",
			"MOUNTMG42_t1",
			"REPAIRMG42_t1",
			"MOUNTMG42_t1_1",
			"REPAIRMG42_t1_1",
		});

		Util.MapDebugPrint( "Tank_Stolen" );
	},

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

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

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

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

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

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

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

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

	Elevator_Wall_Destroyed = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "MOUNT_tank" );
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"FLAG_Naquada",
			"CAPPOINT_Truck",
			"PLANT_Iris_Construction_Kit",
		});

		SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Truck_Barrier_1" );

		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"SWITCH_Right_Door",
			"SWITCH_Left_Door",
		});

		Util.MapDebugPrint( "Elevator_Wall_Destroyed" );
	},

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

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

	Objectives_Secured = function()
	{

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"SWITCH_Right_Door",
			"SWITCH_Left_Door",
		});
		Map.Naquada_on_truck = true;
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"ESCORT_Truck",
			"BUILD_Truck",
			"PLANT_Truck_Barrier_1",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"PLANT_Iris_Construction_Kit",
			"FLAG_The_Naquada",
			"CAPPOINT_Truck",
		});

		Util.MapDebugPrint( "Objectives_Secured" );
	},

	Left_Door_Open = function()
	{

		SetAvailableMapGoals( TEAM.ALLIES, false, "SWITCH_Left_Door" );

		Util.MapDebugPrint( "Left_Door_Open" );
	},

	Left_Door_Closed = function()
	{
		if ( Map.Naquada_on_truck == false ) {
			SetAvailableMapGoals( TEAM.ALLIES, true, "SWITCH_Left_Door" );
			Util.MapDebugPrint( "Left_Door_Closed" );
			return;
        }

		Util.MapDebugPrint( "Left_Door_Closed" );
	},

	Right_Door_Open = function()
	{

		SetAvailableMapGoals( TEAM.ALLIES, false, "SWITCH_Right_Door" );

		Util.MapDebugPrint( "Right_Door_Open" );
	},

	Right_Door_Closed = function()
	{
		if ( Map.Naquada_on_truck == false ) {
			SetAvailableMapGoals( TEAM.ALLIES, true, "SWITCH_Right_Door" );
			Util.MapDebugPrint( "Right_Door_Closed" );
			return;
        }

		Util.MapDebugPrint( "Right_Door_Closed" );
	},

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

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

	truck_past_barrier1 = function()
	{

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"MOUNTMG42_east",
			"REPAIRMG42_east",
			"MOUNTMG42_west",
			"REPAIRMG42_west",
			"BUILD_Truck_Barrier_1",
		});

		Util.MapDebugPrint( "truck_past_barrier1" );
	},

	tank_past_barrier1 = function()
	{

		SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Tank_Barrier_1" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Tank_Barrier_1" );

		Util.MapDebugPrint( "truck_past_barrier1" );
	},
};

global OnMapLoad = function()
{
	OnTrigger( "Axis team has destroyed the Allied Command Post!", Map.Allied_Compost_Destroyed );
	OnTrigger( "Allied Command Post constructed. Charge speed increased!", Map.Allied_Compost_Built );
	OnTrigger( "Axis Command Post constructed. Charge speed increased!", Map.Axis_Compost_Built );
	OnTrigger( "Allied team has destroyed the Axis Command Post!", Map.Axis_Compost_Destroyed );

	OnTrigger( "Allied team has built the the south base MG!", Map.South_base_MG_Built ); // More like AXIS have
	OnTrigger( "Axis team has destroyed the south base MG!", Map.South_base_MG_Destroyed ); // More like ALLIES have

	OnTrigger( "The Tank has been repaired!", Map.Tank_Built );
	OnTrigger( "Allied team has stolen the Tank!", Map.Tank_Stolen );
	OnTrigger( "The Tank has been damaged!", Map.Tank_Damaged );

	OnTrigger( "The Tank Barrier has been constructed.", Map.Tank_Barrier_1_Built );
	OnTrigger( "The Tank Barrier has been destroyed.", Map.Tank_Barrier_1_Destroyed );
	OnTrigger( "goldrush_allies_tank_barrier2", Map.tank_past_barrier1 );

	OnTrigger( "Allied team has destroyed the Elevator Wall!", Map.Elevator_Wall_Destroyed );

	OnTrigger( "The Iris has been mounted.", Map.Iris_Built );
	OnTrigger( "The Iris has been destroyed.", Map.Iris_Destroyed );

	OnTrigger( "The Truck has been repaired!", Map.Truck_Built );
	OnTrigger( "The Truck has been damaged!", Map.Truck_Damaged );

	OnTrigger( "Allies have stolen The Naquada!", Map.Naquada_Taken );
	OnTrigger( "Flag returned Naquada!", Map.Naquada_Returned );
	OnTrigger( "Allied team is escaping with the Naquada!", Map.Objectives_Secured );

	OnTrigger( "Truck Barrier #1 has been constructed.", Map.Truck_Barrier_1_Built );
	OnTrigger( "Truck Barrier #1 has been destroyed.", Map.Truck_Barrier_1_Destroyed );
	OnTrigger( "goldrush_allies_truck_barrier1", Map.truck_past_barrier1 );

	OnTrigger( "The left Securitydoor has been opended", Map.Left_Door_Open );
	OnTrigger( "The left Securitydoor has been closed", Map.Left_Door_Closed );
	OnTrigger( "The right Securitydoor has been opended", Map.Right_Door_Open );
	OnTrigger( "The right Securitydoor has been closed", Map.Right_Door_Closed );

	Util.DisableGoal( ".*", true );

	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"BUILD_Tank",
		"MOUNT_tank",
		"AMMOCAB_t3",
		"HEALTHCAB_t2",
	});

	SetAvailableMapGoals( TEAM.AXIS, true, {
		"BUILD_Command_Post",
		"BUILD_South_base_MG",
		"MOUNTMG42_South_base_MG",
		"REPAIRMG42_South_base_MG",
	});
	SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Tank_Barrier_1" ); //Tank Barrier
	SetAvailableMapGoals( TEAM.AXIS, true, {
		"MOUNTMG42_t1",
		"REPAIRMG42_t1",
		"MOUNTMG42_t1_1",
		"REPAIRMG42_t1_1",
	});

	Util.SetGoalOffset( 0, -50, 0, "PLANT_Truck_Barrier_1" );

	Util.MapDebugPrint( "OnMapLoad" );
};


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

};
