//==========================================================================================
//
//	radiochatterii2.gm
//
//	Who                    	When		What
//------------------------------------------------------------------------------------------
//	^1{WeB}^7*^4GA^1NG$^4TA^7*	27 June 2017	Initial Script
//
//==========================================================================================
//

global Map =
{
	Debug = 0, // please set to zero before distributing your script

	Bridge_Dyno = 0,
	Command_Post_Dyno = 0,
	Front_Door_Dyno = 0,
	Gate_Dyno = 0,
	Side_Wall_Dyno = 0,

	Bridge_Built = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"PLANT_Front_Door",
			"FLAG_docs",
			"DEFEND_Door_Plant_1",
			"DEFEND_Door_Plant_2",
			"DEFEND_Door_Plant_3",
			"DEFEND_Door_Plant_4",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Bridge" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "CAPPOINT_radio" );
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_docs_1",
			"DEFEND_docs_2",
			"DEFEND_docs_3",
			"DEFEND_docs_4",
			"DEFEND_docs_5",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"DEFEND_Bridge_1",
			"DEFEND_Bridge_2",
			"DEFEND_Bridge_3",
			"DEFEND_Bridge_4",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_Gate_Attack_1",
			"DEFEND_Gate_Attack_2",
		});

		Util.MapDebugPrint( "Bridge_Built" );
	},

	Command_Post_Built = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"DEFEND_Door_Plant_1",
			"DEFEND_Door_Plant_2",
			"DEFEND_Door_Plant_3",
			"DEFEND_Door_Plant_4",
		});

		Util.MapDebugPrint( "Command_Post_Built" );
	},

	Bridge_Planted = function( trigger )
	{
		Map.Bridge_Dyno += 1;
		Util.MapDebugPrint( "Bridge_Planted" );
	},

	Command_Post_Planted = function( trigger )
	{
		Map.Command_Post_Dyno += 1;
		Util.MapDebugPrint( "Command_Post_Planted" );
	},

	Front_Door_Planted = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"BUILD_Command_Post",
			"PLANT_Command_Post",
		});

		Map.Front_Door_Dyno += 1;
		Util.MapDebugPrint( "Front_Door_Planted" );
	},

	Gate_Planted = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "SWITCH_Open_Gate_Protection" );
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"SWITCH_Close_Gate_Protection",
			"DEFEND_Controls_1",
			"DEFEND_Controls_2",
			"DEFEND_Controls_3",
			"DEFEND_Controls_4",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"DEFEND_Controls_1",
			"DEFEND_Controls_4",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"DEFEND_Bridge_1",
			"DEFEND_Bridge_2",
			"DEFEND_Bridge_3",
			"DEFEND_Bridge_4",
			"BUILD_Bridge",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"BUILD_Command_Post",
			"DEFEND_Gate_Attack_1",
			"DEFEND_Gate_Attack_2",
		});

		Map.Gate_Dyno += 1;
		Util.MapDebugPrint( "Gate_Planted" );
	},

	Side_Wall_Planted = function( trigger )
	{
		Map.Side_Wall_Dyno += 1;
		Util.MapDebugPrint( "Side_Wall_Planted" );
	},

	Bridge_Defused = function( trigger )
	{
		Map.Bridge_Dyno -= 1;
		Util.MapDebugPrint( "Bridge_Defused" );
	},

	Command_Post_Defused = function( trigger )
	{
		Map.Command_Post_Dyno -= 1;
		Util.MapDebugPrint( "Command_Post_Defused" );
	},

	Front_Door_Defused = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"DEFEND_Door_Plant_1",
			"DEFEND_Door_Plant_2",
			"DEFEND_Door_Plant_3",
			"DEFEND_Door_Plant_4",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"BUILD_Command_Post",
			"PLANT_Command_Post",
		});

		Map.Front_Door_Dyno -= 1;
		Util.MapDebugPrint( "Front_Door_Defused" );
	},

	Gate_Defused = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "SWITCH_Open_Gate_Protection" );
	      SetAvailableMapGoals( TEAM.AXIS, true, {
	      	"SWITCH_Close_Gate_Protection",
	      	"DEFEND_Controls_1",
	      	"DEFEND_Controls_2",
	      	"DEFEND_Controls_3",
	      	"DEFEND_Controls_4",
	      });
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"DEFEND_Bridge_1",
			"DEFEND_Bridge_2",
			"DEFEND_Bridge_3",
			"DEFEND_Bridge_4",
		});

		Map.Gate_Dyno -= 1;
		Util.MapDebugPrint( "Gate_Defused" );
	},

	Side_Wall_Defused = function( trigger )
	{
		Map.Side_Wall_Dyno -= 1;
		Util.MapDebugPrint( "Side_Wall_Defused" );
	},

	Bridge_Destroyed = function( trigger )
	{
		Map.Bridge_Dyno = 0;

		Util.MapDebugPrint( "Bridge_Destroyed" );
	},

	Command_Post_Destroyed = function( trigger )
	{
		Map.Command_Post_Dyno = 0;

		Util.MapDebugPrint( "Command_Post_Destroyed" );
	},

	Front_Door_Destroyed = function( trigger )
	{
		Map.Front_Door_Dyno = 0;

		Util.MapDebugPrint( "Front_Door_Destroyed" );
	},

	Gate_Destroyed = function( trigger )
	{
		Map.Gate_Dyno = 0;

		Util.MapDebugPrint( "Gate_Destroyed" );
	},

	Side_Wall_Destroyed = function( trigger )
	{
		Map.Side_Wall_Dyno = 0;

		Util.MapDebugPrint( "Side_Wall_Destroyed" );
	},

	docs_Taken = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_radio_1",
			"DEFEND_radio_2",
			"DEFEND_radio_3",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_docs_1",
			"DEFEND_docs_2",
			"DEFEND_docs_3",
			"DEFEND_docs_4",
			"DEFEND_docs_5",
		});

		Util.MapDebugPrint( "docs_Taken" );
	},

	docs_Returned = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_radio_1",
			"DEFEND_radio_2",
			"DEFEND_radio_3",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_docs_1",
			"DEFEND_docs_2",
			"DEFEND_docs_3",
			"DEFEND_docs_4",
			"DEFEND_docs_5",
		});

		Util.MapDebugPrint( "docs_Returned" );
	},

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

};

global OnMapLoad = function()
{
	OnTrigger( "Allied team has built the Bridge!", Map.Bridge_Built );
	OnTrigger( "Allied Command Post constructed. Charge speed increased!", Map.Command_Post_Built );
	OnTrigger( "Planted at the Front Door.", Map.Front_Door_Planted );
	OnTrigger( "Planted at the Gate.", Map.Gate_Planted );
	OnTrigger( "Defused at the Front Door.", Map.Front_Door_Defused );
	OnTrigger( "Defused at the Gate.", Map.Gate_Defused );
	OnTrigger( "Axis team has destroyed the Bridge!", Map.Bridge_Destroyed );
	OnTrigger( "Allies have destroyed the Front Door!", Map.Front_Door_Destroyed );
	OnTrigger( "Allies have destroyed the Guard House Gate!", Map.Gate_Destroyed );
	OnTrigger( "Allies have destroyed the Side Wall!", Map.Side_Wall_Destroyed );
	OnTrigger( "Allies have stolen the documents!", Map.docs_Taken );
	OnTrigger( "^The docments have been returned!", Map.docs_Returned );

	SetAvailableMapGoals( TEAM.ALLIES, true, "SWITCH_Open_Gate_Protection" );
	SetAvailableMapGoals( TEAM.AXIS, true, "SWITCH_Close_Gate_Protection" );
	SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Command_Post" );
	SetAvailableMapGoals( TEAM.ALLIES, false, {
		"BUILD_Command_Post",
		"BUILD_Bridge",
		"PLANT_Command_Post",
		"PLANT_Front_Door",
		"PLANT_Side_Wall",
		"FLAG_docs",
		"CAPPOINT_radio",
		"DEFEND_Bridge_1",
		"DEFEND_Bridge_2",
		"DEFEND_Bridge_3",
		"DEFEND_Bridge_4",
		"DEFEND_Door_Plant_1",
		"DEFEND_Door_Plant_2",
		"DEFEND_Door_Plant_3",
		"DEFEND_Door_Plant_4",
	});
	SetAvailableMapGoals( TEAM.AXIS, false, {
		"DEFEND_docs_1",
		"DEFEND_docs_2",
		"DEFEND_docs_3",
		"DEFEND_docs_4",
		"DEFEND_docs_5",
		"DEFEND_Gate_Attack_1",
		"DEFEND_Gate_Attack_2",
		"DEFEND_radio_1",
		"DEFEND_radio_2",
		"DEFEND_radio_3",
	});

	SetGoalPriority("PLANT_Gate", 0.91);
	SetGoalPriority("PLANT_Front_Door", 0.91);
	SetGoalPriority("BUILD_Command_Post", 0.91);

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

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