//==========================================================================================
//
//	base55.gm
//
//	Who                  	When		What
//------------------------------------------------------------------------------------------
//	maker@bigsighstudios.com	28 December 2017	Initial Script
//
//==========================================================================================
//

global Map =
{
	Debug = 1, // please set to zero before distributing your script
	DefendingTeam = TEAM.AXIS,

	Sidedoor_Planted = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, 0, "PLANT_Sidedoor" );
		Util.MapDebugPrint( "Sidedoor_Planted" );
	},
	Sidedoor_Defused = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, 1, "PLANT_Sidedoor" );
		Util.MapDebugPrint( "Sidedoor_Defused" );
	},
	Sidedoor_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, 0, "PLANT_Sidedoor" );
		SetAvailableMapGoals( TEAM.ALLIES, 0, "ATTACK_Plant_Side_.*" );

		SetAvailableMapGoals( TEAM.ALLIES, 1, "PLANT_Maingate" );
		SetAvailableMapGoals( TEAM.ALLIES, 1, "ATTACK_Plant_Main_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, 1, "CHECKPOINT_.*" );

		Util.MapDebugPrint( "Sidedoor_Destroyed" );
	},

	Maingate_Planted = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, 0, "PLANT_Maingate" );
		SetAvailableMapGoals( TEAM.ALLIES, 1, "ATTACK_Plant_Main_.*" );
		SetGoalPriority("ATTACK_Plant_Main_.*", 0.95);
		Util.MapDebugPrint( "Maingate_Planted" );
	},
	Maingate_Defused = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, 1, "PLANT_Maingate" );
		Util.MapDebugPrint( "Maingate_Defused" );
	},
	Maingate_Destroyed = function( trigger )
	{
		SetGoalPriority("ATTACK_Plant_Main_.*", 0.55);
		SetAvailableMapGoals( TEAM.ALLIES, 1, "CHECKPOINT_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, 0, "ATTACK_Plant_Main_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, 1, "PLANT_Depot_Defenses" );

		SetAvailableMapGoals( TEAM.AXIS, 0, "DEFEND_Plant_Main_.*" );
		SetAvailableMapGoals( TEAM.AXIS, 1, "DEFEND_Plant_Depot_.*" );

		Util.MapDebugPrint( "Maingate_Destroyed" );
	},

	Depot_Defenses_Built = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, 1, "PLANT_Depot_Defenses" );
		Util.MapDebugPrint( "Depot_Defenses_Built" );
	},
	Depot_Defenses_Planted = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, 0, "PLANT_Depot_Defenses" );
		Util.MapDebugPrint( "Depot_Defenses_Planted" );
	},
	Depot_Defenses_Defused = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, 1, "PLANT_Depot_Defenses" );
		Util.MapDebugPrint( "Depot_Defenses_Defused" );
	},
	Depot_Defenses_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, 1, "CHECKPOINT_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, 1, "PLANT_Controlpanel" );

		SetAvailableMapGoals( TEAM.ALLIES, 1, "ATTACK_Plant_Control_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, 0, "ATTACK_Plant_Depot_.*" );


		SetAvailableMapGoals( TEAM.AXIS, 0, "DEFEND_Depot_.*" );
		SetAvailableMapGoals( TEAM.AXIS, 1, "DEFEND_Plant_Control_.*" );

		Util.MapDebugPrint( "Depot_Defenses_Destroyed" );
	},

	Controlpanel_Planted = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, 0, "PLANT_Controlpanel" );
		Util.MapDebugPrint( "Controlpanel_Planted" );
	},
	Controlpanel_Defused = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, 1, "PLANT_Controlpanel" );
		Util.MapDebugPrint( "Controlpanel_Defused" );
	},
	Controlpanel_Destroyed = function( trigger )
	{
		Util.MapDebugPrint( "Controlpanel_Destroyed" );
	},

	secret_docs_Taken = function( trigger )
	{
		Util.MapDebugPrint( "secret_docs_Taken" );
	},
	secret_docs_Returned = function( trigger )
	{
		Util.MapDebugPrint( "secret_docs_Returned" );
	},
	secret_docs_Secured = function( trigger )
	{
		Util.MapDebugPrint( "secret_docs_Secured" );
	},

	forward_flag_Axis_Captured = function( trigger )
	{
		Util.MapDebugPrint( "forward_flag_Axis_Captured" );
	},
	forward_flag_Allies_Captured = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, 1, "PLANT_Depot_Defenses" );
		SetAvailableMapGoals( TEAM.ALLIES, 1, "ATTACK_Plant_Depot_.*" );
		Util.MapDebugPrint( "forward_flag_Allies_Captured" );
	},

	// Dual Command Post START

	Allied_CP_Built = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, 1, "PLANT_Allied_Command_Post" );
		Util.MapDebugPrint( "Allied_CP_Built" );
	},

	Allied_CP_Planted = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, 0, "PLANT_Allied_Command_Post" );
		Util.MapDebugPrint( "Allied_CP_Planted" );
	},

	Allied_CP_Defused = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, 1, "PLANT_Axis_Command_Post" );
		Util.MapDebugPrint( "Allied_CP_Defused" );
	},

	Allied_CP_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, 1, "BUILD_Allied_Command_Post" );
		Util.MapDebugPrint( "Allied_CP_Destroyed" );
	},

	Axis_CP_Built = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, 1, "PLANT_Allied_Command_Post" );
		Util.MapDebugPrint( "Axis_CP_Built" );
	},

	Axis_CP_Planted = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, 0, "PLANT_Axis_Command_Post" );
		Util.MapDebugPrint( "Axis_CP_Planted" );
	},

	Axis_CP_Defused = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, 1, "PLANT_Axis_Command_Post" );
		Util.MapDebugPrint( "Axis_CP_Defused" );
	},

	Axis_CP_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, 1, "BUILD_Axis_Command_Post" );
		Util.MapDebugPrint( "Axis_CP_Destroyed" );
	},


};

global OnMapLoad = function()
{
	// Register callback functions
	OnTrigger( "Allied Command Post constructed. Charge speed increased!",  Map.Allied_CP_Built ); //"^3Allied CP Spawn active!"
	OnTrigger( "Planted at the Allied Command Post.",                       Map.Allied_CP_Planted );
	OnTrigger( "Defused at the Allied Command Post.",                       Map.Allied_CP_Defused );
	OnTrigger( "Axis team has destroyed the Allied Command Post!",          Map.Allied_CP_Destroyed );//"^1Allied CP Spawn inactive!"

	OnTrigger( "Axis Command Post constructed. Charge speed increased!",    Map.Axis_CP_Built );
	OnTrigger( "Planted at the Axis Command Post.",                         Map.Axis_CP_Planted );
	OnTrigger( "Defused at the Axis Command Post.",                         Map.Axis_CP_Defused );
	OnTrigger( "Allied team has destroyed the Axis Command Post!",          Map.Axis_CP_Destroyed );

	OnTrigger( "Depot Defences has been constructed!", Map.Depot_Defenses_Built );
	OnTrigger( "Planted at the Depot Defences.", Map.Depot_Defenses_Planted );
	OnTrigger( "Defused at the Depot Defences.", Map.Depot_Defenses_Defused );
	OnTrigger( "The Depot Defences has been destroyed!", Map.Depot_Defenses_Destroyed );

	OnTrigger( "Planted at the Controlpanel.", Map.Controlpanel_Planted );
	OnTrigger( "Defused at the Controlpanel.", Map.Controlpanel_Defused );
	OnTrigger( "The Controlpanel has been destroyed!", Map.Controlpanel_Destroyed );

	OnTrigger( "Planted at the Maingate.", Map.Maingate_Planted );
	OnTrigger( "Defused at the Maingate.", Map.Maingate_Defused );
	OnTrigger( "the Maingate destroyed", Map.Maingate_Destroyed );
	OnTrigger( "axis_entrance1_destroyed", Map.Maingate_Destroyed );

	OnTrigger( "Planted at the Sidedoor.", Map.Sidedoor_Planted );
	OnTrigger( "Defused at the Sidedoor.", Map.Sidedoor_Defused );
	OnTrigger( "Allies have breached the Side Entrance!", Map.Sidedoor_Destroyed );

	OnTrigger( "MISSING_STRING", Map.secret_docs_Taken );
	OnTrigger( "MISSING_STRING", Map.secret_docs_Returned );
	OnTrigger( "Allies successfully send the secret docs!", Map.secret_docs_Secured );

	OnTrigger( "Axis reclaim the Vehicle Depot!", Map.forward_flag_Axis_Captured );
	OnTrigger( "Allies captured the Vehicle Depot!", Map.forward_flag_Allies_Captured );

	Util.DisableGoal( ".*", 1 ); // all but routes

	SetAvailableMapGoals( TEAM.ALLIES, 1, {
		"PLANT_Sidedoor",
		"ATTACK_Plant_Side_.*",
		"BUILD_Allied_Command_Post",
	});
	SetGoalPriority("PLANT_Maingate",            0.86);
	SetGoalPriority("PLANT_Sidedoor",            0.84);
	SetGoalPriority("PLANT_Depot_Defenses",      0.82);
	SetGoalPriority("BUILD_Allied_Command_Post", 0.75);

	SetAvailableMapGoals( TEAM.AXIS, 1, {
		"DEFEND_Plant_Main_.*",
		"BUILD_Depot_Defenses",
		"BUILD_Axis_Command_Post",
		"CHECKPOINT_.*",
	});


	// Economy
	Util.LimitToClass("PLANT_Axis_Command_Post", TEAM.ALLIES, CLASS.COVERTOPS);
	Util.LimitToClass("PLANT_Allied_Command_Post", TEAM.AXIS, CLASS.COVERTOPS);

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

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


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

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

global InitializeRoutes = function()
{
	MapRoutes =
	{
		BUILD_Allied_Command_Post =
		{
		},
		PLANT_Allied_Command_Post =
		{
		},
		CHECKPOINT_forward_flag =
		{
		},
		PLANT_Sidedoor =
		{
		},
		FLAG_secret_docs =
		{
		},
		BUILD_Depot_Defenses =
		{
		},
		PLANT_Depot_Defenses =
		{
		},
		PLANT_Controlpanel =
		{
		},
		PLANT_Maingate =
		{
		},
		BUILD_Axis_Command_Post =
		{
		},
		PLANT_Axis_Command_Post =
		{
		},
	};
	Util.Routes(MapRoutes);
};
