//==========================================================================================
//
//	decay_b7.gm
//
//	Who                           	When		What
//------------------------------------------------------------------------------------------
//	=F|A=BLACKWOLF*	22 July 2020	Initial Script
//	Based off original waypoints by Qiki and Native 12 for decay_b5
//	Script and goals re-done as new 
//
//==========================================================================================
//

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

	Fence_Dyno = 0,
	Generator_Dyno = 0,
	Neutral_Command_Post_Dyno = 0,
	side_gate_Dyno = 0,

	Fence_Built = function( trigger )
	{
		if ( TestMap )
			{ return; }
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Fence" );
		Util.MapDebugPrint( "Fence_Built" );
	},

	Neutral_Command_Post_Built = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "Neutral_Command_Post_Built" );
	},

	Fence_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Fence" );
		Map.Fence_Dyno += 1;
		Util.MapDebugPrint( "Fence_Planted" );
	},

	Generator_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Generator" );
		Map.Generator_Dyno += 1;
		Util.MapDebugPrint( "Generator_Planted" );
	},

	Neutral_Command_Post_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Neutral_Command_Post_Dyno += 1;
		Util.MapDebugPrint( "Neutral_Command_Post_Planted" );
	},

	side_gate_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_side_gate" );

		Map.side_gate_Dyno += 1;
		Util.MapDebugPrint( "side_gate_Planted" );
	},

	Fence_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Fence" );
		Map.Fence_Dyno -= 1;
		Util.MapDebugPrint( "Fence_Defused" );
	},

	Generator_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Generator" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_generator_.*" );
		Map.Generator_Dyno -= 1;
		Util.MapDebugPrint( "Generator_Defused" );
	},

	Neutral_Command_Post_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Neutral_Command_Post_Dyno -= 1;
		Util.MapDebugPrint( "Neutral_Command_Post_Defused" );
	},

	side_gate_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_side_gate" );
		Map.side_gate_Dyno -= 1;
		Util.MapDebugPrint( "side_gate_Defused" );
	},

	Fence_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Fence_Dyno = 0;
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Fence" );
		Util.MapDebugPrint( "Fence_Destroyed" );
	},

	Generator_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Generator" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_axis_gold1" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_axis_gold2" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_axis_third_.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_axis_second_.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_axis_fourth_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_generator_.*" );
		Map.Generator_Dyno = 0;

		Util.MapDebugPrint( "Generator_Destroyed" );
	},

	Neutral_Command_Post_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Neutral_Command_Post_Dyno = 0;

		Util.MapDebugPrint( "Neutral_Command_Post_Destroyed" );
	},

	side_gate_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.side_gate_Dyno = 0;
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Generator" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_generator_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Neutral_Command_Post" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Neutral_Command_Post" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Fence" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_axis_second_.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_axis_third_.*" );

		Util.MapDebugPrint( "side_gate_Destroyed" );
	},

	axis_gold1_Taken = function( trigger )
	{
		if ( TestMap )
			{ return; }

		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_axis_fourth_.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_axis_third_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_final_.*" );
		Util.MapDebugPrint( "axis_gold1_Taken" );
	},

	axis_gold2_Taken = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "axis_gold2_Taken" );
	},

	secretdocs_Taken = function( trigger )
	{
		if ( TestMap )
			{ return; }

		SetAvailableMapGoals( TEAM.ALLIES, true, "CAPPOINT_Radio" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_radio" );

		Util.MapDebugPrint( "secretdocs_Taken" );
	},

	axis_gold1_Returned = function( trigger )
	{
		if ( TestMap )
			{ return; }
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_axis_fourth_.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_axis_third_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_final_.*" );

		Util.MapDebugPrint( "axis_gold1_Returned" );
	},

	axis_gold2_Returned = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "axis_gold2_Returned" );
	},

	secretdocs_Returned = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "secretdocs_Returned" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "CAPPOINT_Radio" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_radio" );
	},

	axis_gold1_Secured = function( trigger )
	{
		if ( TestMap )
			{ return; }
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_final_.*" );
		Util.MapDebugPrint( "axis_gold1_Secured" );
	},

	axis_gold2_Secured = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "axis_gold2_Secured" );
	},

	secretdocs_Secured = function( trigger )
	{
		if ( TestMap )
			{ return; }
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_side_gate" );
		SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Fence" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "CAPPOINT_Radio" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Generator" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_generator_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Fence" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "CAPPOINT_truck1" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_AXIS_initial_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_allies_initial_.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "PLANTMINE_.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_axis_third_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Generator" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_generator_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Fence" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_axis_third_.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_radio" );
		SetAvailableMapGoals( TEAM.AXIS, false, "ARTILLERY_.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "CALLARTILLERY_.*" );

		Util.MapDebugPrint( "secretdocs_Secured" );
	},

	forward_flag_Axis_Captured = function( trigger )
	{
		if ( TestMap )
			{ return; }
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_axis_initial_.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "PLANTMINE_.*" );
		Util.MapDebugPrint( "forward_flag_Axis_Captured" );
		SetAvailableMapGoals( TEAM.AXIS, true, "ARTILLERY_.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "CALLARTILLERY_.*" );
	},

	forward_flag_Allies_Captured = function( trigger )
	{
		if ( TestMap )
			{ return; }
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_axis_initial_.*" );
		Util.MapDebugPrint( "forward_flag_Allies_Captured" );
		SetAvailableMapGoals( TEAM.AXIS, false, "PLANTMINE_.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "ARTILLERY_.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "CALLARTILLERY_.*" );
	},

};

global OnMapLoad = function()
{
	if ( TestMapOn )
		{ Util.AutoTestMap(); }

	// Register callback functions
	OnTrigger( "Axis Team have built the Fence!", Map.Fence_Built );
	OnTrigger( "MISSING_STRING", Map.Neutral_Command_Post_Built );
	OnTrigger( "Planted at The Fence.", Map.Fence_Planted );
	OnTrigger( "Planted at The Generator.", Map.Generator_Planted );
	OnTrigger( "Planted at the MISSING_STRING.", Map.Neutral_Command_Post_Planted );
	OnTrigger( "Planted at the side gate.", Map.side_gate_Planted );
	OnTrigger( "Defused at The Fence.", Map.Fence_Defused );
	OnTrigger( "Defused at The Generator.", Map.Generator_Defused );
	OnTrigger( "Defused at the MISSING_STRING.", Map.Neutral_Command_Post_Defused );
	OnTrigger( "Defused at the side gate.", Map.side_gate_Defused );
	OnTrigger( "Allied have destroyed the Fence!", Map.Fence_Destroyed );
	OnTrigger( "The Allies have destroyed the generator, the vault doors are opening!", Map.Generator_Destroyed );
	OnTrigger( "MISSING_STRING", Map.Neutral_Command_Post_Destroyed );
	OnTrigger( "The Allies have destroyed the side entrance!", Map.side_gate_Destroyed );
	OnTrigger( "Allies have stolen the Gold!", Map.axis_gold1_Taken );
	OnTrigger( "MISSING_STRING", Map.axis_gold2_Taken );
	OnTrigger( "Allies have stolen The Access Codes!", Map.secretdocs_Taken );
	OnTrigger( "Axis have returned the Gold!", Map.axis_gold1_Returned );
	OnTrigger( "MISSING_STRING", Map.axis_gold2_Returned );
	OnTrigger( "Axis have returned The Access Codes!", Map.secretdocs_Returned );
	OnTrigger( "The Allies have secured a gold crate!", Map.axis_gold1_Secured );
	OnTrigger( "MISSING_STRING", Map.axis_gold2_Secured );
	OnTrigger( "The Allies have transmitted the Access codes. The main gate is opening!", Map.secretdocs_Secured );
	OnTrigger( "Axis have captured the Forward Flag!", Map.forward_flag_Axis_Captured );
	OnTrigger( "Allies have captured the Forward Flag!", Map.forward_flag_Allies_Captured );

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

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

	SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_secretdocs" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_side_gate" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Generator" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Neutral_Command_Post" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Neutral_Command_Post" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Fence" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "FLAG_axis_gold1" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "FLAG_axis_gold2" );
	SetAvailableMapGoals( TEAM.AXIS, false, "CAPPOINT_Radio" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "CAPPOINT_Radio" );
	SetAvailableMapGoals( TEAM.AXIS, false, "CAPPOINT_truck1" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "CAPPOINT_truck1" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Fence" );
	SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Fence" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "MOUNTMG42_.*" );
	SetAvailableMapGoals( TEAM.AXIS, false, "MOUNTMG42_.*" );
	SetAvailableMapGoals( TEAM.AXIS, false, "REPAIRMG42_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "REPAIRMG42_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "PLANTMINE_.*" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_.*" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_axis_initial_.*" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_axis_second_.*" );
	SetAvailableMapGoals( TEAM.AXIS, false, "ATTACK_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_allies_initial_.*" );
	SetAvailableMapGoals( TEAM.AXIS, true, "ARTILLERY_.*" );
	SetAvailableMapGoals( TEAM.AXIS, true, "CALLARTILLERY_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "ARTILLERY_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "CALLARTILLERY_.*" );

	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 =
	{
		CHECKPOINT_forward_flag = 
		{
			ROUTE_allies_spawn  = 
			{
				ROUTE_allies_south  = 
				{
					ROUTE_south_ruins  = 
					{
						ROUTE_south_ruins_lower  = 
						{
						},
						ROUTE_south_ruins_upper  = 
						{
						},
					},
					ROUTE_south_tank  = 
					{
					},
				},
				ROUTE_allies_north  = 
				{
					ROUTE_roof1  = 
					{
					},
					ROUTE_lower1  = 
					{
					},
					ROUTE_lower2  = 
					{
					},
				},
				ROUTE_allies_central  = 
				{
				},
			},
			ROUTE_docs  = 
			{
				ROUTE_allies_north  = 
				{
					ROUTE_roof1  = 
					{
					},
					ROUTE_lower1  = 
					{
					},
					ROUTE_lower2  = 
					{
					},
				},
				ROUTE_allies_central  = 
				{
				},
				ROUTE_allies_south  = 
				{
					ROUTE_south_ruins  = 
					{
						ROUTE_south_ruins_lower  = 
						{
						},
						ROUTE_south_ruins_upper  = 
						{
						},
					},
					ROUTE_south_tank  = 
					{
					},
				},
			},
		},
		CAPPOINT_Radio = 
		{
			ROUTE_docs  = 
			{
				ROUTE_allies_north  = 
				{
					ROUTE_roof1  = 
					{
					},
					ROUTE_lower2  = 
					{
					},
					ROUTE_lower1  = 
					{
					},
				},
				ROUTE_allies_central  = 
				{
				},
				ROUTE_allies_south  = 
				{
					ROUTE_south_ruins  = 
					{
						ROUTE_south_ruins_lower  = 
						{
						},
						ROUTE_south_ruins_upper  = 
						{
						},
					},
					ROUTE_south_tank  = 
					{
					},
				},
			},
		},
		PLANT_Neutral_Command_Post = 
		{
			ROUTE_flag  = 
			{
				ROUTE_flag_door1  = 
				{
				},
			},
		},
		PLANT_side_gate = 
		{
			ROUTE_allies_spawn  = 
			{
				ROUTE_allies_central  = 
				{
					ROUTE_south_ruins  = 
					{
						ROUTE_south_ruins_lower  = 
						{
							ROUTE_south_ruins_upper  = 
							{
								ROUTE_sideplant  = 
								{
								},
							},
						},
					},
				},
				ROUTE_allies_south  = 
				{
					ROUTE_south_ruins  = 
					{
						ROUTE_south_ruins_lower  = 
						{
							ROUTE_south_ruins_upper  = 
							{
								ROUTE_sideplant  = 
								{
								},
							},
						},
					},
				},
			},
		},
		PLANT_Generator = 
		{
			ROUTE_flag  = 
			{
				ROUTE_flag_door1  = 
				{
					ROUTE_entrance1  = 
					{
					},
					ROUTE_entrance2  = 
					{
					},
				},
				ROUTE_main_entrance  = 
				{
				},
			},
		},
		FLAG_axis_gold2 = 
		{
			ROUTE_flag  = 
			{
				ROUTE_flag_door1  = 
				{
					ROUTE_entrance1  = 
					{
					},
					ROUTE_entrance2  = 
					{
					},
				},
				ROUTE_main_entrance  = 
				{
				},
			},
			ROUTE_allies_final_1  = 
			{
				ROUTE_gold1  = 
				{
				},
				ROUTE_gold2  = 
				{
				},
			},
			ROUTE_allies_final_2  = 
			{
				ROUTE_gold1  = 
				{
				},
				ROUTE_gold2  = 
				{
				},
			},
		},
		PLANT_Fence = 
		{
			ROUTE_flag  = 
			{
				ROUTE_flag_door1  = 
				{
					ROUTE_entrance1  = 
					{
					},
					ROUTE_entrance2  = 
					{
					},
				},
				ROUTE_main_entrance  = 
				{
				},
			},
		},
		CAPPOINT_truck1 = 
		{
			ROUTE_gold  = 
			{
				ROUTE_truck1  = 
				{
					ROUTE_gold1  = 
					{
					},
					ROUTE_truck3  = 
					{
					},
				},
				ROUTE_truck2  = 
				{
				},
			},
		},
		ATTACK_generator_1 = 
		{
			ROUTE_flag  = 
			{
				ROUTE_flag_door1  = 
				{
					ROUTE_entrance1  = 
					{
					},
					ROUTE_entrance2  = 
					{
					},
				},
				ROUTE_main_entrance  = 
				{
				},
			},
		},
		ATTACK_generator_2 = 
		{
			ROUTE_flag  = 
			{
				ROUTE_flag_door1  = 
				{
					ROUTE_entrance1  = 
					{
					},
					ROUTE_entrance2  = 
					{
					},
				},
				ROUTE_main_entrance  = 
				{
				},
			},
		},
		ATTACK_final_1 = 
		{
			ROUTE_gold  = 
			{
				ROUTE_truck1  = 
				{
					ROUTE_gold1  = 
					{
					},
					ROUTE_truck3  = 
					{
					},
				},
				ROUTE_truck2  = 
				{
				},
			},
			ROUTE_allies_final_1  = 
			{
				ROUTE_gold1  = 
				{
				},
				ROUTE_truck3  = 
				{
				},
			},
			ROUTE_allies_final_2  = 
			{
				ROUTE_gold1  = 
				{
				},
				ROUTE_truck3  = 
				{
				},
			},
		},
		ATTACK_final_2 = 
		{
			ROUTE_gold  = 
			{
				ROUTE_truck1  = 
				{
					ROUTE_gold1  = 
					{
					},
					ROUTE_truck3  = 
					{
					},
				},
				ROUTE_truck2  = 
				{
				},
			},
			ROUTE_allies_final_1  = 
			{
				ROUTE_gold1  = 
				{
				},
				ROUTE_truck3  = 
				{
				},
			},
			ROUTE_allies_final_2  = 
			{
				ROUTE_gold1  = 
				{
				},
				ROUTE_truck3  = 
				{
				},
			},
		},
		ATTACK_final_3 = 
		{
			ROUTE_gold  = 
			{
				ROUTE_truck1  = 
				{
					ROUTE_gold1  = 
					{
					},
					ROUTE_truck3  = 
					{
					},
				},
				ROUTE_truck2  = 
				{
				},
			},
			ROUTE_allies_final_1  = 
			{
				ROUTE_gold1  = 
				{
				},
				ROUTE_truck3  = 
				{
				},
			},
			ROUTE_allies_final_2  = 
			{
				ROUTE_gold1  = 
				{
				},
				ROUTE_truck3  = 
				{
				},
			},
		},

	};
	Util.Routes(MapRoutes);
};
