//==========================================================================================
//
//	beach_bbq_a1.gm
//
//	Who	   When		          What
//------------------------------------------------------------------------------------------
//	BMW	   04 December 2012	  Initial Script
//
//==========================================================================================
//

global Map =
{
	Debug = 1, // please set to zero before distributing your script
	Beer = 0, //0=returned or captured 1=stolen
	Sausages = 0,

	Barbeque_Built = function( trigger )
	{

		SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Barbeque" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Barbeque" );

		Util.MapDebugPrint( "Barbeque_Built" );
	},

	Deck_Extension_Built = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Deck_Extension" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Deck_Extension" );

		Util.MapDebugPrint( "Deck_Extension_Built" );
	},

	MG42_Built = function( trigger )
	{

		SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_MG42" );
		SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_MG42" );

		Util.MapDebugPrint( "MG42_Built" );
	},

	Barbeque_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Barbeque" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Barbeque" );

		Util.MapDebugPrint( "Barbeque_Destroyed" );
	},

	MG42_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_MG42" );
		SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_MG42" );

		Util.MapDebugPrint( "MG42_Destroyed" );
	},

	Side_Wall_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_SideWallRoom" );
		SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Side_Wall" );
		SetAvailableMapGoals( TEAM.AXIS, true, "FLAG_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Fridge" );
		SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Ladder" );


		Util.MapDebugPrint( "Side_Wall_Destroyed" );
	},

	beer_Taken = function( trigger )
	{

		SetAvailableMapGoals( TEAM.AXIS, true, "CAPPOINT_bbq" );
		Beer = 1;

		Util.MapDebugPrint( "beer_Taken" );
	},

	sausages_Taken = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, true, "CAPPOINT_bbq" );
		Sausages = 1;

		Util.MapDebugPrint( "sausages_Taken" );
	},

	beer_Returned = function( trigger )
	{

		if ( Sausages == 0 )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "CAPPOINT_bbq" );
		}
		Beer = 0;

		Util.MapDebugPrint( "beer_Returned" );
	},

	sausages_Returned = function( trigger )
	{

		if ( Beer == 0 )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "CAPPOINT_bbq" );
		}
		Sausages = 0;

		Util.MapDebugPrint( "sausages_Returned" );
	},

	beer_Secured = function( trigger )
	{

		if ( Sausages == 0 )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "CAPPOINT_bbq" );
		}
		Beer = 0;

		Util.MapDebugPrint( "beer_Secured" );
	},

	sausages_Secured = function( trigger )
	{
		if ( Beer == 0 )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "CAPPOINT_bbq" );
		}
		Sausages = 0;
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_bbq" );

		Util.MapDebugPrint( "sausages_Secured" );
	},

	Ladder_Built = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Ladder" );
		SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Ladder" );

		Util.MapDebugPrint( "Ladder_Built" );
	},

	Ladder_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Ladder" );
		SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Ladder" );

		Util.MapDebugPrint( "Ladder_Destroyed" );
	},

};

global OnMapLoad = function()
{
	// Register callback functions
	OnTrigger( "The Axis have built the Barbeque!", Map.Barbeque_Built );
	OnTrigger( "The Axis have built the Deck Extension!", Map.Deck_Extension_Built );
	OnTrigger( "The Allies have built the MG42!", Map.MG42_Built );
	OnTrigger( "The Allies have destroyed the Barbeque!", Map.Barbeque_Destroyed );
	OnTrigger( "The Axis have destroyed the MG42!", Map.MG42_Destroyed );
	OnTrigger( "The Axis have destroyed the Side Wall!", Map.Side_Wall_Destroyed );
	OnTrigger( "Axis have stolen the Beer!", Map.beer_Taken );
	OnTrigger( "Axis have stolen the Sausages!", Map.sausages_Taken );
	OnTrigger( "Allies have returned the Beer!", Map.beer_Returned );
	OnTrigger( "Allies have returned the Sausages!", Map.sausages_Returned );
	OnTrigger( "The Axis have secured the Beer!", Map.beer_Secured );
	OnTrigger( "The Axis have secured the Sausages!", Map.sausages_Secured );
	OnTrigger( "The Axis have built the Ladder!", Map.Ladder_Built );
	OnTrigger( "The Allies have destroyed the Ladder!", Map.Ladder_Destroyed );

	Util.DisableGoal( ".*", true ); // all but routes
	SetAvailableMapGoals( TEAM.AXIS, true, {
		"PLANT_Side_Wall",
		"BUILD_Barbeque",
		"BUILD_Deck_Extension",
		"ATTACK_.*",
	});
	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"ATTACK_.*",
		"SNIPE_.*",
		"MOUNTMG42_.*",
		"AMMOCAB_.*",
		"HEALTHCAB_.*",
	});
	SetAvailableMapGoals( TEAM.AXIS, true, {
		"AMMOCAB_.*",
		"HEALTHCAB_.*",
	});
	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"BUILD_MG42",
		"REPAIRMG42_.*",
	});
	SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Ladder" );

	SetGoalPriority( "PLANT_Side_Wall", 0.90, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( "BUILD_bbq", 0.91, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( "BUILD_Deck_Extension", 0.84, TEAM.AXIS, CLASS.ENGINEER );

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

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


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


global InitializeRoutes = function()
{
	MapRoutes =
	{
		BUILD_Barbeque =
		{
			ROUTE_AxisSpawn = {},
		},
		BUILD_Deck_Extension =
		{
			ROUTE_AxisSpawn = {},
		},
		PLANT_Side_Wall =
		{
			ROUTE_AxisSpawn =
			{
				ROUTE_FarRight = { Weight = 2, },
				ROUTE_Mid = {},
			},
		},
		FLAG_beer =
		{
			ROUTE_AxisSpawn =
			{
				ROUTE_FarRight = { Weight = 2, },
				ROUTE_Mid = {},
			},
		},
		FLAG_sausages =
		{
			ROUTE_AxisSpawn =
			{
				ROUTE_FarRight = { Weight = 2, },
				ROUTE_Mid = {},
			},
		},
		CAPPOINT_bbq =
		{
			ROUTE_Fridge =
			{
				ROUTE_LeftFromHouse = { Weight = 2, },
				ROUTE_RightFromHouse = {},
			},
		},
	};
	Util.Routes(MapRoutes);
};
