//==========================================================================================
//
//	the_gauntlet_b1.gm
//
//	Who                  	When		What
//------------------------------------------------------------------------------------------
//	maker@bigsighstudios.com	14 February 2018	Initial Script
//
//==========================================================================================
//

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


	// Primary Obj's

	AXIS_RADIO_Planted = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, 0, "PLANT_AXIS_RADIO" );
		Util.MapDebugPrint( "AXIS_RADIO_Planted" );
	},
	AXIS_RADIO_Defused = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, 1, "PLANT_AXIS_RADIO" );
		Util.MapDebugPrint( "AXIS_RADIO_Defused" );
	},
	AXIS_RADIO_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, 0, "PLANT_AXIS_RADIO" );
		Util.MapDebugPrint( "AXIS_RADIO_Destroyed" );
	},

	NORTH_FLAK_88_GUN_Planted = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, 0, "PLANT__NORTH_FLAK_88_GUN" );
		Util.MapDebugPrint( "NORTH_FLAK_88_GUN_Planted" );
	},
	NORTH_FLAK_88_GUN_Defused = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, 1, "PLANT__NORTH_FLAK_88_GUN" );
		Util.MapDebugPrint( "NORTH_FLAK_88_GUN_Defused" );
	},
	NORTH_FLAK_88_GUN_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, 0, "PLANT__NORTH_FLAK_88_GUN" );
		Util.MapDebugPrint( "NORTH_FLAK_88_GUN_Destroyed" );
	},

	SOUTH_FLAK_88_GUN_Planted = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, 0, "PLANT_SOUTH_FLAK_88_GUN" );
		Util.MapDebugPrint( "SOUTH_FLAK_88_GUN_Planted" );
	},
	SOUTH_FLAK_88_GUN_Defused = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, 1, "PLANT_SOUTH_FLAK_88_GUN" );
		Util.MapDebugPrint( "SOUTH_FLAK_88_GUN_Defused" );
	},
	SOUTH_FLAK_88_GUN_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, 0, "PLANT_SOUTH_FLAK_88_GUN" );
		Util.MapDebugPrint( "SOUTH_FLAK_88_GUN_Destroyed" );
	},

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

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


	// Secondary Obj's

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

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

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

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

	// Neutral Command Post
	CP_Owner = 0,
	CP_Dyno = 0,

	Set_CP = function(_p) // p = TEAM.ALLIES or TEAM.AXIS or 0 (unbuilt)
	{
		switch(_p)
		{
			case 0:
			{
				Map.CP_Owner = 0;
				SetAvailableMapGoals( TEAM.ALLIES, 1, "BUILD_Command_Post" );
				SetAvailableMapGoals( TEAM.ALLIES, 0, "PLANT_Command_Post" );
				SetAvailableMapGoals( TEAM.AXIS,   1, "BUILD_Command_Post" );
				SetAvailableMapGoals( TEAM.AXIS,   0, "PLANT_Command_Post" );
			}
			case TEAM.ALLIES:
			{
				Map.CP_Owner = TEAM.ALLIES;
				SetAvailableMapGoals( TEAM.ALLIES, 0, "BUILD_Command_Post" );
				SetAvailableMapGoals( TEAM.ALLIES, 0, "PLANT_Command_Post" );
				SetAvailableMapGoals( TEAM.AXIS,   1, "PLANT_Command_Post" );
				SetAvailableMapGoals( TEAM.AXIS,   0, "BUILD_Command_Post" );
			}
			case TEAM.AXIS:
			{
				Map.CP_Owner = TEAM.AXIS;
				SetAvailableMapGoals( TEAM.ALLIES, 0, "BUILD_Command_Post" );
				SetAvailableMapGoals( TEAM.ALLIES, 1, "PLANT_Command_Post" );
				SetAvailableMapGoals( TEAM.AXIS,   0, "PLANT_Command_Post" );
				SetAvailableMapGoals( TEAM.AXIS,   0, "BUILD_Command_Post" );
			}
		}
		//Util.MapDebugPrint("CP Owner: " + Map.CP_Owner );
	},
	Allied_CP_Built = function( trigger )
	{
		Map.Set_CP(TEAM.ALLIES);
		Util.MapDebugPrint( "Allied_CP_Built" );
	},
	Allied_CP_Destroyed = function( trigger )
	{
		Map.CP_Dyno = 0;
		Map.Set_CP(0);
		Util.MapDebugPrint( "Allied_CP_Destroyed" );
	},
	Axis_CP_Built = function( trigger )
	{
		Map.Set_CP(TEAM.AXIS);
		Util.MapDebugPrint( "Axis_CP_Built" );
	},
	Axis_CP_Destroyed = function( trigger )
	{
		Map.CP_Dyno = 0;
		Map.Set_CP(0);
		Util.MapDebugPrint( "Axis_CP_Destroyed" );
	},
	CP_Planted = function( trigger )
	{
		Map.CP_Dyno += 1;
		Util.MapDebugPrint( "CP_Planted" );
	},
	CP_Defused = function( trigger )
	{
		Map.CP_Dyno -= 1;
		Util.MapDebugPrint( "CP_Defused" );
	},

// Command Post END

};

global OnMapLoad = function()
{
	// Register callback functions

	OnTrigger( "^3ALLIED EAST MACHINE GUN CONSTRUCTED!!!", Map.Allied_MG_Built );
	OnTrigger( "^3AXIS HAVE DESTROYED THE ALLIED EAST MACHINE GUN!!!", Map.Allied_MG_Destroyed );

	OnTrigger( "^3ALLIED WEST MACHINE GUN CONSTRUCTED!!!", Map.Allied_MG_1_Built );
	OnTrigger( "^3AXIS HAVE DESTROYED THE ALLIED WEST MACHINE GUN!!!", Map.Allied_MG_1_Destroyed );

	OnTrigger( "^3AXIS NORTH MACHINE GUN CONSTRUCTED!!!", Map.Axis_MG_Built );
	OnTrigger( "^3ALLIES HAVE DESTROYED THE AXIS NORTH MACHINE GUN!!!", Map.Axis_MG_Destroyed );

	OnTrigger( "^3AXIS SOUTH MACHINE GUN CONSTRUCTED!!!", Map.Axis_MG_1_Built );
	OnTrigger( "^3ALLIES HAVE DESTROYED THE AXIS SOUTH MACHINE GUN!!!", Map.Axis_MG_1_Destroyed );

	OnTrigger( "Planted at THE AXIS RADIO.", Map.AXIS_RADIO_Planted );
	OnTrigger( "Defused at THE AXIS RADIO.", Map.AXIS_RADIO_Defused );
	OnTrigger( "^3ALLIES HAVE DESTROYED THE AXIS RADIO!!!", Map.AXIS_RADIO_Destroyed );

	OnTrigger( "Planted at THE  NORTH FLAK 88 GUN.", Map.NORTH_FLAK_88_GUN_Planted );
	OnTrigger( "Defused at THE  NORTH FLAK 88 GUN.", Map.NORTH_FLAK_88_GUN_Defused );
	OnTrigger( "^3ALLIES HAVE DESTROYED THE NORTH FLAK 88 GUN!!!", Map.NORTH_FLAK_88_GUN_Destroyed );

	OnTrigger( "Planted at THE  SOUTH FLAK 88 GUN.", Map.SOUTH_FLAK_88_GUN_Planted );
	OnTrigger( "Defused at THE  SOUTH FLAK 88 GUN.", Map.SOUTH_FLAK_88_GUN_Defused );
	OnTrigger( "^3ALLIES HAVE DESTROYED THE SOUTH FLAK 88 GUN!!!", Map.SOUTH_FLAK_88_GUN_Destroyed );

	OnTrigger( "^3AXIS HAVE CAPTURED THE FORWARD SPAWN!!!", Map.forwardspawn1_flag_Axis_Captured );
	OnTrigger( "^3ALLIES HAVE CAPTURED THE FORWARD SPAWN!!!", Map.forwardspawn1_flag_Allies_Captured );

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

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

	//Allies
	SetAvailableMapGoals( TEAM.ALLIES, 1, {
		"ATTACK_.*",
		"CHECKPOINT_forwardspawn1_flag",
		"BUILD_Command_Post",
		"BUILD_Allied_MG",
		"BUILD_Allied_MG_1",
		"PLANT_AXIS_RADIO",
		"PLANT__NORTH_FLAK_88_GUN",
		"PLANT__SOUTH_FLAK_88_GUN",

	});

	//Axis
	SetAvailableMapGoals( TEAM.AXIS, 1, {
		"DEFEND_.*",
		"CHECKPOINT_forwardspawn1_flag",
		"BUILD_Command_Post",
		"BUILD_Axis_MG",
		"BUILD_Axis_MG_1",

	});

	Util.LimitToClass( "PLANT_Allied_MG_.*", 1, 5 );
	Util.LimitToClass( "PLANT_Axis_MG_.*", 2, 5 );
	Util.LimitToClass( "PLANT_Command_Post", 0, 5 );

	SetGoalPriority( "BUILD_Axis_.*", 0.8 );
	SetGoalPriority( "BUILD_Allied_.*", 0.8 );

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

	// 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_Command_Post =
		{
		},
		PLANT_Command_Post =
		{
		},
		PLANT_AXIS_RADIO =
		{
		},
		PLANT__NORTH_FLAK_88_GUN =
		{
		},
		PLANT__SOUTH_FLAK_88_GUN =
		{
		},
		CHECKPOINT_forwardspawn1_flag =
		{
		},
		BUILD_Axis_MG =
		{
		},
		PLANT_Axis_MG =
		{
		},
		BUILD_Allied_MG =
		{
		},
		PLANT_Allied_MG =
		{
		},
		BUILD_Axis_MG_1 =
		{
		},
		PLANT_Axis_MG_1 =
		{
		},
		BUILD_Allied_MG_1 =
		{
		},
		PLANT_Allied_MG_1 =
		{
		},
	};
	Util.Routes(MapRoutes);
};
