//==========================================================================================
//
//	citadel_obj.gm
//
//	Who			When		What
//------------------------------------------------------------------------------------------
//	MickyP		02Apr2010	1st Version
//
//==========================================================================================
//

global Map =
{
	Ammo_Cabinet_north_ammocabinet = "AMMOCAB_north_ammocabinet",
	Ammo_Cabinet_north_ammocabinet_1 = "AMMOCAB_north_ammocabinet_1",
	Flag_gold = "FLAG_gold",
	Cappoint_262 = "CAPPOINT_262",
	Build_Command_Post = "BUILD_Command_Post",
	Build_Gun_control_ladder = "BUILD_Gun_control_ladder",
	Build_citadel_entrance_barrier = "BUILD_citadel_entrance_barrier",
	Build_scaffolding = "BUILD_scaffolding",
	Plant_Ammo_crates = "PLANT_Ammo_crates",
	Plant_Command_Post = "PLANT_Command_Post",
	Plant_Gun_control_ladder = "PLANT_Gun_control_ladder",
	Plant_citadel_entrance_barrier = "PLANT_citadel_entrance_barrier",
	Plant_scaffolding = "PLANT_scaffolding",
	Mount_spawnmg_gun = "MOUNTMG42_spawnmg_gun",
	Repair_spawnmg_gun = "REPAIRMG42_spawnmg_gun",

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

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

	Gun_control_ladder_Built = function( trigger )
	{

		Wp.SetWaypointFlag( "ammo_ladder_1", "closed", false );
		Wp.SetWaypointFlag( "ammo_ladder_2", "closed", false );
		Util.EnableGoal("ROUTE_ammo_ladder.*" );

		Util.MapDebugPrint( "Gun_control_ladder_Built" );
	},

	citadel_entrance_barrier_Built = function( trigger )
	{
		Wp.SetWaypointFlag( "citadel_ladder_1", "closed", false );
		Wp.SetWaypointFlag( "citadel_ladder_2", "closed", false );
		Util.DisableGoal("ROUTE_citadel_door" );
		Util.EnableGoal("ROUTE_citadel_ladder.*" );
		Util.MapDebugPrint( "citadel_entrance_barrier_Built" );
	},

	scaffolding_Built = function( trigger )
	{

		Util.EnableGoal("ROUTE_scaffolding" );

		Util.MapDebugPrint( "scaffolding_Built" );
	},

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

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

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

	Gun_control_ladder_Destroyed = function( trigger )
	{
		Wp.SetWaypointFlag( "ammo_ladder_1", "closed", true );
		Wp.SetWaypointFlag( "ammo_ladder_2", "closed", true );
		Util.DisableGoal("ROUTE_ammo_ladder.*" );

		Util.MapDebugPrint( "Gun_control_ladder_Destroyed" );
	},

	citadel_entrance_barrier_Destroyed = function( trigger )
	{

		Wp.SetWaypointFlag( "citadel_ladder_1", "closed", true );
		Wp.SetWaypointFlag( "citadel_ladder_2", "closed", true );
		Util.DisableGoal("ROUTE_citadel_ladder.*" );
		Util.EnableGoal("ROUTE_citadel_door" );
		Util.MapDebugPrint( "citadel_entrance_barrier_Destroyed" );
	},

	scaffolding_Destroyed = function( trigger )
	{
		Util.DisableGoal("ROUTE_scaffolding" );

		Util.MapDebugPrint( "scaffolding_Destroyed" );
	},

	Ammo_Taken = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_ammo.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Cap_Sw.*" );
		Util.MapDebugPrint( "Ammo_Taken" );
	},

	Ammo_Returned = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_ammo.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Cap_Sw.*" );
		Util.MapDebugPrint( "Ammo_Returned" );
	},

	Ammo_Loaded = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "SWITCH_gun" );
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"MOUNTMG42_spawnmg_gun",
			"REPAIRMG42_spawnmg_gun",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"MOUNTMG42_spawnmg_gun",
			"REPAIRMG42_spawnmg_gun",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_scaffolding" );
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"PLANT_scaffolding",
			"DEFEND_ammo.*",
		});

		Util.MapDebugPrint( "Ammo_Loaded" );
	},

	Tower_Breached = function( trigger )
	{

		Util.MapDebugPrint( "Tower_Breached" );
	},

		Switch_Activated = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"PLANT_Ammo_crates",
			"PLANT_citadel_entrance_barrier",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"SWITCH_gun",
			"ATTACK_ammo.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_crates.*" );

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_Cap_Sw.*",
			"DEFEND_Ladder.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_crates.*" );

		Util.MapDebugPrint( "Switch_Activated" );
	},

};

global OnMapLoad = function()
{
	OnTrigger( "Allied Command Post constructed. Charge speed increased!", Map.Allies_Command_Post_Built );
	OnTrigger( "Axis Command Post constructed. Charge speed increased!", Map.Axis_Command_Post_Built );
	OnTrigger( "The ladder has been built.", Map.Gun_control_ladder_Built );
	OnTrigger( "The citadel entrance wooden barrier has been contructed.", Map.citadel_entrance_barrier_Built );
	OnTrigger( "The scaffolding has been built.", Map.scaffolding_Built );
	OnTrigger( "^6Allies have blown the Axis ammo crates!!!", Map.Ammo_crates_Destroyed );
	OnTrigger( "Axis team has destroyed the Allied Command Post!", Map.Allies_Command_Post_Destroyed );
	OnTrigger( "Allied team has destroyed the Axis Command Post!", Map.Axis_Command_Post_Destroyed );
	OnTrigger( "The ladder has been destroyed.", Map.Gun_control_ladder_Destroyed );
	OnTrigger( "The citadel entrance wooden barrier has been destroyed.", Map.citadel_entrance_barrier_Destroyed );
	OnTrigger( "The scaffolding has been destroyed.", Map.scaffolding_Destroyed );
	OnTrigger( "^6Allies have stolen the ammo!!!", Map.Ammo_Taken );
	OnTrigger( "^6The ammo has been returned!!!", Map.Ammo_Returned );
	OnTrigger( "^6The ammo has been loaded onto the cannon!!!", Map.Ammo_Loaded );
	OnTrigger( "^6The Citadel Tower has been breached!!!", Map.Tower_Breached );
	OnTrigger( "base_lever2_goto", Map.Switch_Activated );

	Util.DisableGoal(".*");
	Util.EnableGoal("ROUTE_.*" );
	Util.DisableGoal("ROUTE_scaffolding" );
	Util.DisableGoal("ROUTE_ammo_ladder.*" );
	Util.DisableGoal("ROUTE_citadel_ladder.*" );

	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"GRENADE_gate.*",
		"AMMOCAB_north_ammocabinet",
		"FLAG_gold",
		"CAPPOINT_262",
		"BUILD_Command_Post",
		"BUILD_Gun_control_ladder",
		"BUILD_scaffolding",
		"ATTACK_ammo.*",
	});

	SetAvailableMapGoals( TEAM.AXIS, true, {
		"AMMOCAB_north_ammocabinet_1",
		"BUILD_citadel_entrance_barrier",
		"MOUNTMG42_spawnmg_gun",
		"REPAIRMG42_spawnmg_gun",
		"DEFEND_Ladder.*",
		"DEFEND_ammo.*",
	});

	Wp.SetWaypointFlag( "ammo_ladder_1", "closed", true );
	Wp.SetWaypointFlag( "ammo_ladder_2", "closed", true );
	Wp.SetWaypointFlag( "citadel_ladder_1", "closed", true );
	Wp.SetWaypointFlag( "citadel_ladder_2", "closed", true );

	Util.SetMaxUsersInProgress( 1, "MOUNTMG42.*" );

	Util.SetGoalOffset( 0, 50, 0, "PLANT_citadel_entrance_barrier" );

	SetGoalPriority( "BUILD_Command_Post", 0.75 );
	SetGoalPriority( "PLANT_Command_Post", 0.75 );
	SetGoalPriority( "BUILD_Gun_control_ladder", 0.95 );
	SetGoalPriority( "SWITCH_gun", 0.95 );

	MapRoutes =
	{
		FLAG_gold =
		{
			ROUTE_AlliesS2  =
			{
				ROUTE_left_passage  =
				{
					ROUTE_ammo_door  =
					{
					},
					ROUTE_scaffolding  =
					{
					},
				},
				ROUTE_left_tower  =
				{
					ROUTE_comm_post_door  =
					{
						ROUTE_ammo_door  =
						{
						},
						ROUTE_scaffolding  =
						{
						},
					},
					ROUTE_secondry_ladder  =
					{
						ROUTE_ammo_door  =
						{
						},
						ROUTE_scaffolding  =
						{
						},
					},
				},
				ROUTE_old_flag  =
				{
					ROUTE_comm_post_door  =
					{
						ROUTE_ammo_door  =
						{
						},
						ROUTE_scaffolding  =
						{
						},
					},
				},
			},
			ROUTE_AlliesS4  =
			{
				ROUTE_blowable_gate  =
				{
					ROUTE_ammo_door  =
					{
					},
					ROUTE_scaffolding  =
					{
					},
				},
				ROUTE_far_left_wall  =
				{
					ROUTE_ammo_door  =
					{
					},
					ROUTE_scaffolding  =
					{
					},
				},
			},
		},
		BUILD_scaffolding =
		{
			ROUTE_AlliesS2  =
			{
				ROUTE_left_passage  = 	{},
				ROUTE_left_tower  =
				{
					ROUTE_comm_post_door  = {},
					ROUTE_secondry_ladder  = {},
				},
				ROUTE_old_flag  =
				{
					ROUTE_comm_post_door  ={},
				},
			},
			ROUTE_AlliesS4  =
			{
				ROUTE_blowable_gate  = {},
				ROUTE_far_left_wall  = {},
			},
		},
		CAPPOINT_262 =
		{
			ROUTE_ammo  =
			{
				ROUTE_ammo_door  =
				{
					ROUTE_ammo_ladder_1  =
					{
					},
					ROUTE_ammo_ladder_2  =
					{
					},
					ROUTE_secondry_ladder  =
					{
						ROUTE_ammo_wall  =
						{
						},
					},
				},
				ROUTE_ammo_side  =
				{
					ROUTE_ammo_ladder_1  =
					{
					},
					ROUTE_ammo_ladder_2  =
					{
					},
					ROUTE_secondry_ladder  =
					{
					},
				},
			},
		},
		DEFEND_Ladder_1 =
		{
			ROUTE_AxisS6  =
			{
				ROUTE_s6door  =
				{
					ROUTE_citadel_ladder_1  =
					{
					},
					ROUTE_citadel_ladder_2  =
					{
					},
					ROUTE_citadel_door  =
					{
					},
					ROUTE_comm_post_exit  =
					{
						ROUTE_comm_post_passage  =
						{
						},
					},
				},
				ROUTE_s6left  =
				{
					ROUTE_citadel_ladder_1  =
					{
					},
					ROUTE_citadel_ladder_2  =
					{
					},
					ROUTE_citadel_door  =
					{
					},
					ROUTE_comm_post_exit  =
					{
						ROUTE_comm_post_passage  =
						{
						},
					},
				},
				ROUTE_s6right  =
				{
					ROUTE_citadel_ladder_2  =
					{
					},
					ROUTE_citadel_ladder_1  =
					{
					},
					ROUTE_citadel_door  =
					{
					},
					ROUTE_comm_post_exit  =
					{
						ROUTE_comm_post_passage  =
						{
						},
					},
				},
			},
		},
		ATTACK_crates_1 =
		{
			ROUTE_AlliesS2  =
			{
				ROUTE_left_passage  =
				{
					ROUTE_citadel_door  =
					{
						ROUTE_citadel_wall  =
						{
							ROUTE_citadel_ladder_1  =
							{
								ROUTE_citadel_ladder_2  =
								{
								},
							},
						},
					},
				},
				ROUTE_comm_post_door  =
				{
					ROUTE_comm_post_exit  =
					{
					},
				},
				ROUTE_comm_post_passage  =
				{
					ROUTE_comm_post_exit  =
					{
					},
				},
			},
		},

	};

	MapRoutes.ATTACK_ammo_1 = MapRoutes.BUILD_scaffolding;
	MapRoutes.ATTACK_ammo_2 = MapRoutes.BUILD_scaffolding;
	MapRoutes.ATTACK_ammo_3 = MapRoutes.BUILD_scaffolding;
	MapRoutes.ATTACK_ammo_4 = MapRoutes.BUILD_scaffolding;
	MapRoutes.ATTACK_ammo_5 = MapRoutes.BUILD_scaffolding;
	MapRoutes.ATTACK_ammo_6 = MapRoutes.BUILD_scaffolding;
	MapRoutes.ATTACK_ammo_7 = MapRoutes.BUILD_scaffolding;
	MapRoutes.ATTACK_ammo_8 = MapRoutes.BUILD_scaffolding;
	MapRoutes.BUILD_Gun_control_ladder = MapRoutes.BUILD_scaffolding;
	MapRoutes.DEFEND_ladder_2 = MapRoutes.DEFEND_Ladder_1;
	MapRoutes.DEFEND_ladder_3 = MapRoutes.DEFEND_Ladder_1;
	MapRoutes.DEFEND_ladder_4 = MapRoutes.DEFEND_Ladder_1;
	MapRoutes.DEFEND_ladder_5 = MapRoutes.DEFEND_Ladder_1;
	MapRoutes.DEFEND_ladder_7 = MapRoutes.DEFEND_Ladder_1;
	MapRoutes.DEFEND_ladder_8 = MapRoutes.DEFEND_Ladder_1;
	MapRoutes.DEFEND_ammo_1 = MapRoutes.DEFEND_Ladder_1;
	MapRoutes.DEFEND_ammo_2 = MapRoutes.DEFEND_Ladder_1;
	MapRoutes.DEFEND_Cap_Sw_1 = MapRoutes.DEFEND_Ladder_1;
	MapRoutes.DEFEND_Cap_Sw_2 = MapRoutes.DEFEND_Ladder_1;
	MapRoutes.DEFEND_crates_3 = MapRoutes.DEFEND_crates_2;
	MapRoutes.DEFEND_crates_4 = MapRoutes.DEFEND_crates_2;
	MapRoutes.DEFEND_crates_5 = MapRoutes.DEFEND_crates_2;
	MapRoutes.DEFEND_crates_6 = MapRoutes.DEFEND_crates_2;
	MapRoutes.DEFEND_crates_7 = MapRoutes.DEFEND_crates_2;
	MapRoutes.DEFEND_crates_8 = MapRoutes.DEFEND_crates_2;
	MapRoutes.ATTACK_crates_2 = MapRoutes.ATTACK_crates_1;
	MapRoutes.ATTACK_crates_3 = MapRoutes.ATTACK_crates_1;
	MapRoutes.ATTACK_crates_4 = MapRoutes.ATTACK_crates_1;
	MapRoutes.ATTACK_crates_5 = MapRoutes.ATTACK_crates_1;
	MapRoutes.ATTACK_crates_6 = MapRoutes.ATTACK_crates_1;
	MapRoutes.ATTACK_crates_7 = MapRoutes.ATTACK_crates_1;
	MapRoutes.PLANT_Ammo_crates = MapRoutes.ATTACK_crates_1;

	Util.Routes(MapRoutes);

	Util.MapDebugPrint( "OnMapLoad" );
};
global OnBotJoin = function( bot )
{

};
