//waypoint & scripting by C3R14L.K1L4
//version of 20:01 21-11-2008
//OB 0.71
global Map =
{
	//GOALS
	ammo_supply = "AMMOCAB_supplycabinet",
	attack_bunker_entrance = "ATTACK_BUNKER_ENTRANCE.*",
	attack_protect_docs_position = "ATTACK_PROTECT_DOCS_POSITION.*",
	attack_radio = "ATTACK_RADIO.*",
	attack_stairs = "ATTACK_STAIRS.*",
	health_supply = "HEALTHCAB_healthcabinet",
	plant_airshaftgrid = "PLANT_airshaftgrid",
	plant_coderoom = "PLANT_CODEROOM",
	plant_radiostation = "PLANT_RADIOSTATION",
	plant_secretentrance = "PLANT_secret_entrance",
	plant_steeldoor = "PLANT_STEEL_DOOR",
	steal_docs = "FLAG_SECRET_BEER_FORMULA",
	transmit_docs = "CAPPOINT_RADIO",

	//GOALS STATUS
	// bunker entrances (existence)
	steeldoor = true,
	airshaft = true,
	secretentrance = true,
	// objectives dinamitables (existence)
	coderoom = true,
	radiostation = true,

	//documents stolen
	documents_stolen = false,

	//TRIGGERS
	CheckBunkerEntrances = function (trigger)
	{
		SetAvailableMapGoals( TEAM.AXIS, false, {
			Map.attack_bunker_entrance,
			Map.attack_bunker_entrance,
			Map.attack_bunker_entrance,
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.attack_bunker_entrance );
		//some entrance got destroyed, if the code room exists, defend it!
		if(Map.coderoom) {
			SetAvailableMapGoals( TEAM.AXIS, true, Map.attack_stairs );
			SetAvailableMapGoals( TEAM.ALLIES, true, Map.attack_stairs );
			SetAvailableMapGoals( TEAM.AXIS, true, Map.attack_protect_docs_position );
			SetAvailableMapGoals( TEAM.ALLIES, true, Map.attack_protect_docs_position );
		}
		Util.MapDebugPrint("CheckBunkerEntrances");
	},

	Steeldoor_Destroyed = function( trigger )
	{

		Map.steeldoor=false;
		Map.CheckBunkerEntrances();
		Util.MapDebugPrint("Steeldoor_Destroyed");
	},

	Airshaft_Destroyed = function( trigger )
	{

		Map.airshaft=false;
		Map.CheckBunkerEntrances();
		Util.MapDebugPrint("Airshaft_Destroyed");
	},

	Secretentrance_Destroyed = function( trigger )
	{

		Map.secretentrance=false;
		Map.CheckBunkerEntrances();
		Util.MapDebugPrint("Secretentrance_Destroyed");
	},

	Radiostation_Destroyed = function( trigger )
	{

		SetAvailableMapGoals( TEAM.ALLIES, true, Map.steal_docs );
		Map.radiostation=false;
		Util.MapDebugPrint("Radiostation_Destroyed");
	},

	Coderoom_Destroyed = function( trigger )
	{

		Map.coderoom=false;
		Util.MapDebugPrint("Coderoom_Destroyed");
	},

	Objective_Returned = function (trigger)
	{
		Map.documents_stolen = true;
		SetAvailableMapGoals( TEAM.AXIS, false, Map.attack_bunker_entrance );
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.attack_bunker_entrance );
		SetAvailableMapGoals( TEAM.AXIS, true, Map.attack_stairs );
		SetAvailableMapGoals( TEAM.ALLIES, true, Map.attack_stairs );
		SetAvailableMapGoals( TEAM.AXIS, true, Map.attack_protect_docs_position );
		SetAvailableMapGoals( TEAM.ALLIES, true, Map.attack_protect_docs_position );

		SetAvailableMapGoals( TEAM.AXIS, false, Map.attack_radio );
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.attack_radio );
		Util.MapDebugPrint("Objective_Returned");
	},

	// docs returned -> defend docs point
	Objective_Taken = function (trigger)
	{
		Map.documents_stolen = false;
		SetAvailableMapGoals( TEAM.AXIS, false, Map.attack_bunker_entrance );
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.attack_bunker_entrance );
		SetAvailableMapGoals( TEAM.AXIS, false, Map.attack_stairs );
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.attack_stairs );
		SetAvailableMapGoals( TEAM.AXIS, false, Map.attack_protect_docs_position );
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.attack_protect_docs_position );

		SetAvailableMapGoals( TEAM.AXIS, true, Map.attack_radio );
		SetAvailableMapGoals( TEAM.ALLIES, true, Map.attack_radio );
		Util.MapDebugPrint("Objective_Taken");
	},
};

global OnMapLoad = function()
{

	//Util.SetGoalPosition( -479, 36, 457, Map.plant_steeldoor );

	SetMapGoalProperties( "ATTACK_.*", {MinCampTime=3, MaxCampTime=10});
	SetMapGoalProperties( "DEFEND_.*", {MinCampTime=20, MaxCampTime=30});

	SetGoalPriority("DEFUSE_CODEROOM.*", 1.1, TEAM.AXIS, 0, true);
	SetGoalPriority("DEFUSE_RADIOSTATION.*", 1.1, TEAM.AXIS, 0, true);
	SetGoalPriority("DEFUSE_STEEL_DOOR.*", 0.1, TEAM.AXIS, 0, true); //ie, leave it
	SetGoalPriority("DEFUSE_secret_entrance.*", 0.1, TEAM.AXIS, 0, true); //ie, leave it
	SetGoalPriority("DEFUSE_airshaftgrid.*", 0.1, TEAM.AXIS, 0, true); //ie, leave it

	SetGoalPriority(Map.plant_airshaftgrid, 0.85, TEAM.ALLIES, 0, true);
	SetGoalPriority(Map.plant_secretentrance, 0.83, TEAM.ALLIES, 0, true);
	SetGoalPriority(Map.plant_steeldoor, 0.86, TEAM.ALLIES, 0, true);
	SetGoalPriority(Map.attack_protect_docs_position, 0.55, TEAM.AXIS, 0, true);
	SetGoalPriority(Map.attack_protect_docs_position, 0.55, TEAM.ALLIES, 0, true);
	SetGoalPriority(Map.attack_stairs, 0.55, TEAM.AXIS, 0, true);
	SetGoalPriority(Map.attack_stairs, 0.55, TEAM.ALLIES, 0, true);

	SetAvailableMapGoals( TEAM.ALLIES, true, Map.transmit_docs );
	SetAvailableMapGoals( TEAM.ALLIES, false, Map.steal_docs );
	SetAvailableMapGoals( TEAM.ALLIES, true, {
		Map.plant_coderoom,
		Map.plant_radiostation,
	});

	SetAvailableMapGoals( TEAM.AXIS, true, Map.attack_bunker_entrance );
	SetAvailableMapGoals( TEAM.ALLIES, true, Map.attack_bunker_entrance );
	SetAvailableMapGoals( TEAM.AXIS, false, Map.attack_stairs );
	SetAvailableMapGoals( TEAM.ALLIES, false, Map.attack_stairs );
	SetAvailableMapGoals( TEAM.AXIS, false, Map.attack_protect_docs_position );
	SetAvailableMapGoals( TEAM.ALLIES, false, Map.attack_protect_docs_position );
	SetAvailableMapGoals( TEAM.AXIS, false, Map.attack_radio );
	SetAvailableMapGoals( TEAM.ALLIES, false, Map.attack_radio );

	OnTrigger( "THEY BROKEN INTO THE CODEROOM",Map.Coderoom_Destroyed);
	OnTrigger( "THEY BROKEN INTO THE RADIOROOM1",Map.Radiostation_Destroyed);
	OnTrigger( "THE AIRSHAFTGRID HAS BEEN DESTROYED",Map.Airshaft_Destroyed);
	OnTrigger( "THE DOOR HAS BEEN DESTROYED",Map.Steeldoor_Destroyed);
	OnTrigger( "THE SECRET DOOR HAS BEEN DESTROYED",Map.Secretentrance_Destroyed);
	OnTrigger( "Allies have stolen SECRET BEER FORMULA!",Map.Objective_Taken);
	OnTrigger( "Axis have returned SECRET BEER FORMULA!",Map.Objective_Returned);
	OnTrigger( "Flag returned SECRET BEER FORMULA!",Map.Objective_Returned);

	Util.SetMaxUsersInProgress( 1, Map.steal_docs );
	Util.SetMaxUsersInProgress( 1, Map.transmit_docs );
	Util.SetMaxUsersInProgress( 1, Map.plant_coderoom );
	Util.SetMaxUsersInProgress( 1, Map.plant_radiostation );
	Util.SetMaxUsersInProgress( 1, Map.plant_steeldoor );
	Util.SetMaxUsersInProgress( 1, Map.plant_airshaftgrid );
	Util.SetMaxUsersInProgress( 1, Map.plant_secretentrance );

	MapRoutes =
	{
		PLANT_RADIOSTATION = {
			ROUTE_ALLIES_SPAWN =
			{
				ROUTE_AIRSHAFT = {},
				ROUTE_DOCUMENTS_SHAFT = {},
				ROUTE_SECRET_ENTRANCE = {},
				ROUTE_STEEL_DOOR = {},
				ROUTE_SUPPLIES_SHAFT = {},
			},
			ROUTE_ALLIES_FSPAWN1 =
			{
				ROUTE_AIRSHAFT = {},
				ROUTE_DOCUMENTS_SHAFT = {},
				ROUTE_SECRET_ENTRANCE = {},
				ROUTE_STEEL_DOOR = {},
				ROUTE_SUPPLIES_SHAFT = {},
			},
			ROUTE_ALLIES_FSPAWN2 =
			{
				ROUTE_AIRSHAFT = {},
				ROUTE_DOCUMENTS_SHAFT = {},
				ROUTE_SECRET_ENTRANCE = {},
				ROUTE_STEEL_DOOR = {},
				ROUTE_SUPPLIES_SHAFT = {},
			},
		},
		CAPPOINT_RADIO = {
			ROUTE_DOCS_CAPTURE_STAIRS = {},
		},
	};

	MapRoutes.PLANT_CODEROOM = MapRoutes.PLANT_RADIOSTATION;
	MapRoutes.FLAG_SECRET_BEER_FORMULA = MapRoutes.PLANT_RADIOSTATION;
	MapRoutes.ATTACK_RADIO = MapRoutes.PLANT_RADIOSTATION;
	MapRoutes.ATTACK_RADIO_1 = MapRoutes.PLANT_RADIOSTATION;
	MapRoutes.ATTACK_RADIO_2 = MapRoutes.PLANT_RADIOSTATION;
	MapRoutes.ATTACK_RADIO_3 = MapRoutes.PLANT_RADIOSTATION;
	MapRoutes.ATTACK_PROTECT_DOCS_POSITION = MapRoutes.PLANT_RADIOSTATION;
	MapRoutes.ATTACK_PROTECT_DOCS_POSITION_1 = MapRoutes.PLANT_RADIOSTATION;
	MapRoutes.ATTACK_PROTECT_DOCS_POSITION_2 = MapRoutes.PLANT_RADIOSTATION;
	MapRoutes.ATTACK_PROTECT_DOCS_POSITION_3 = MapRoutes.PLANT_RADIOSTATION;
	MapRoutes.ATTACK_STAIRS = MapRoutes.PLANT_RADIOSTATION;
	MapRoutes.ATTACK_STAIRS_1 = MapRoutes.PLANT_RADIOSTATION;

	Util.Routes(MapRoutes);
	Util.MapDebugPrint("bunker: OnMapLoad()");
};

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