//==========================================================================================
//
//	necrology_final.gm
//
//	Who  	When		What
//------------------------------------------------------------------------------------------
//	^4Tardis	24 October 2010	Initial Script
//
//==========================================================================================
//TODO: Mabie Add Attack / Defend Spots

global Map =
{
	Allies_Resurector_Dyno = 0,
	Axis_Resurector_Dyno = 0,
	Axis_Command_Post_Dyno = 0,
	Allied_Command_Post_Dyno = 0,
 	Talk = true, //set Talk to false if you don't want the bots to cheer after winning game:

	Allied_Command_Post_Built = function()
	{
		SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Command_Post" );
		Util.MapDebugPrint( "Allied_Command_Post_Built" );
	},

	Allied_Command_Post_Planted = function()
	{
		Map.Allied_Command_Post_Dyno += 1;
		Util.MapDebugPrint( "Allied_Command_Post_Planted" );
	},

	Allied_Command_Post_Defused = function()
	{
		Map.Allied_Command_Post_Dyno -= 1;
		Util.MapDebugPrint( "Allied_Command_Post_Defused" );
	},

	Allied_Command_Post_Destroyed = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Command_Post" );
		Util.MapDebugPrint( "Allied_Command_Post_Destroyed" );
	},

	Axis_Command_Post_Built = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Command_Post" );
		Util.MapDebugPrint( "Axis_Command_Post_Built" );
	},

	Axis_Command_Post_Planted = function()
	{
		Map.Axis_Command_Post_Dyno += 1;
		Util.MapDebugPrint( "Axis_Command_Post_Planted" );
	},

	Axis_Command_Post_Defused = function()
	{
		Map.Axis_Command_Post_Dyno -= 1;
		Util.MapDebugPrint( "Axis_Command_Post_Defused" );
	},

	Axis_Command_Post_Destroyed = function()
	{
		SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Command_Post" );
		Util.MapDebugPrint( "Axis_Command_Post_Destroyed" );
	},

	Allies_Resurector_Built = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_allies.*" );
		Util.MapDebugPrint( "Allies_Resurector_Built" );
	},

	Allies_Resurector_Planted = function()
	{
		Map.Allies_Resurector_Dyno += 1;
		Util.MapDebugPrint( "Allies_Resurector_Planted" );
	},

	Allies_Resurector_Defused = function()
	{
		Map.Allies_Resurector_Dyno -= 1;
		Util.MapDebugPrint( "Allies_Resurector_Defused" );
	},

	Allies_Resurector_Destroyed = function()
	{
		Map.Allies_Resurector_Dyno = 0;
		SetAvailableMapGoals( TEAM.ALLIES, false, "FLAG_allies.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Allies_Resurector" );
		Util.MapDebugPrint( "Allies_Resurector_Destroyed" );
	},

	Axis_Resurector_Built = function()
	{
		SetAvailableMapGoals( TEAM.AXIS, true, "FLAG_axis.*" );
		Util.MapDebugPrint( "Axis_Resurector_Built" );
	},

	Axis_Resurector_Planted = function()
	{
		Map.Axis_Resurector_Dyno += 1;
		Util.MapDebugPrint( "Axis_Resurector_Planted" );
	},

	Axis_Resurector_Defused = function()
	{
		Map.Axis_Resurector_Dyno -= 1;
		Util.MapDebugPrint( "Axis_Resurector_Defused" );
	},

	Axis_Resurector_Destroyed = function()
	{
		Map.Axis_Resurector_Dyno = 0;
		SetAvailableMapGoals( TEAM.AXIS, false, "FLAG_axis.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Axis_Resurector" );
		Util.MapDebugPrint( "Axis_Resurector_Destroyed" );
	},

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	The_Axis_win = function()
	{
		Util.DisableGoal( "CAPPOINT_Allied" );
		Util.DisableGoal( "FLAG_allies.*" );

		ETUtil.WinningChat( TEAM.AXIS );
		ETUtil.LosingChat( TEAM.ALLIES );
		Util.MapDebugPrint( "The Axis win!!" );
	},

	The_Allies_win = function()
	{
		Util.DisableGoal( "CAPPOINT_Axis" );
		Util.DisableGoal( "FLAG_axis.*" );

		ETUtil.WinningChat( TEAM.ALLIES );
		ETUtil.LosingChat( TEAM.AXIS );
		Util.MapDebugPrint( "The Allies win!!" );
	},
};

global OnMapLoad = function()
{
// Register callback functions
	OnTrigger( "^4Allies activated the command post !", Map.Allied_Command_Post_Built );
	OnTrigger( "^1Axis activated the command post !!", Map.Axis_Command_Post_Built );
	OnTrigger( "^4Allies activated the Resurector, Allied crypt door is open !", Map.Allies_Resurector_Built );
	OnTrigger( "^1Axis activated the Resurector, Axis crypt door is open !", Map.Axis_Resurector_Built );
	OnTrigger( "^4Planted at the Allies Resurector", Map.Allies_Resurector_Planted );
	OnTrigger( "^1Planted at the Axis Resurector", Map.Axis_Resurector_Planted );
	OnTrigger( "^4Planted at the Allied Command Post!", Map.Allied_Command_Post_Planted );
	OnTrigger( "^1Planted at the Axis Command Post!", Map.Axis_Command_Post_Planted );
	OnTrigger( "^4Defused at the Allies Resurector", Map.Allies_Resurector_Defused );
	OnTrigger( "^1Defused at the Axis Resurector", Map.Axis_Resurector_Defused );
	OnTrigger( "^4Defused at the Allied Command Post!", Map.Allied_Command_Post_Defused );
	OnTrigger( "^1Defused at the Axis Command Post!", Map.Axis_Command_Post_Defused );
	OnTrigger( "^1Axis desactived the Resurector, Allied crypt door is closed !", Map.Allies_Resurector_Destroyed );
	OnTrigger( "^4Allies desactived the Resurector, Axis crypt door is closed !", Map.Axis_Resurector_Destroyed );
	OnTrigger( "^1Axis desactived the command post !", Map.Allied_Command_Post_Destroyed );
	OnTrigger( "^4Allies desactived the command post !", Map.Axis_Command_Post_Destroyed );
	OnTrigger( "Axis have returned the Alllied Bones!", Map.allies_gold_crate_Returned  );
	OnTrigger( "Allies have returned the Axis Bones!", Map.axis_gold_crate_Returned  );
	OnTrigger( "^4Allied has secured the first Bones!", Map.allies_gold_crate_Secured );
	OnTrigger( "^4Allied has secured the second Bones!", Map.allies_gold_crate_1_Secured );
	OnTrigger( "^4Allied has secured the third Bones!", Map.allies_gold_crate_2_Secured );
	OnTrigger( "^4Allied has secured the forth Bones!", Map.allies_gold_crate_3_Secured );
	OnTrigger( "^4Allied has secured the fifth Bones!", Map.allies_gold_crate_4_Secured );
	OnTrigger( "^4Allied has secured the sixth Bones!", Map.allies_gold_crate_5_Secured );
	OnTrigger( "^4Allied has secured the seventh Bones!", Map.allies_gold_crate_6_Secured );
	OnTrigger( "^4Allied has secured the last Bones!", Map.allies_gold_crate_7_Secured );
	OnTrigger( "^1Axis has secured the first Bones!", Map.axis_gold_crate_Secured );
	OnTrigger( "^1Axis has secured the second Bones!", Map.axis_gold_crate_1_Secured );
	OnTrigger( "^1Axis has secured the third Bones!", Map.axis_gold_crate_2_Secured );
	OnTrigger( "^1Axis has secured the forth Bones!", Map.axis_gold_crate_3_Secured );
	OnTrigger( "^1Axis has secured the fifth Bones!", Map.axis_gold_crate_4_Secured );
	OnTrigger( "^1Axis has secured the sixth Bones!", Map.axis_gold_crate_5_Secured );
	OnTrigger( "^1Axis has secured the seventh Bones!", Map.axis_gold_crate_6_Secured );
	OnTrigger( "^1Axis has secured the last Bones!", Map.axis_gold_crate_7_Secured );
	OnTrigger( "Allies have stolen the Allied Bones!", Map.allies_gold_crate_Taken );
	OnTrigger( "Axis have stolen the Axis Bones!", Map.axis_gold_crate_Taken );
	OnTrigger( "^1The Axis win!!", Map.The_Axis_win );
	OnTrigger( "^4The Allies win!!", Map.The_Allies_win );

	Util.SetGoalOffset( -50, -20, -30, "BUILD_Allies_Resurector" );
	Util.SetGoalOffset( 0, 50, 0, "PLANT_Allies_Resurector" );
	Util.SetGoalOffset( 0, 50, -30, "BUILD_Axis_Resurector" );
	Util.SetGoalOffset( -50, -20, 0, "PLANT_Axis_Resurector" );
	Util.SetGoalOffset( 50, 0, -30, "BUILD_Command_Post" );
	Util.SetGoalOffset( -50, -20, 0, "PLANT_Command_Post" );

	SetGoalPriority( "BUILD_Allies_Resurector", 0.91, TEAM.ALLIES, CLASS.ENGINEER, true );
	SetGoalPriority( "BUILD_Axis_Resurector", 0.91, TEAM.AXIS, CLASS.ENGINEER, true );

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

	Util.EnableGoal ("AMMOCAB.*");
	Util.EnableGoal	("HEALTHCAB.*");
	SetAvailableMapGoals( TEAM.AXIS, true, "FLAG_allies.*");
	SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_axis.*");
	SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Axis_Resurector" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Allies_Resurector" );
	SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Allies_Resurector" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Axis_Resurector" ):
	SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Command_Post" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Command_Post" );
	SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Command_Post" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Command_Post" ):
	SetAvailableMapGoals( TEAM.AXIS, true, "CAPPOINT_Axis" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "CAPPOINT_Allied" );
// Max users per goal
	Util.SetMaxUsers( 1, "DEFEND_.*" );
// Camp times
	SetMapGoalProperties( "MOBILEMG42_.*", {MinCampTime=10, MaxCampTime=60} );
//Routes
	MapRoutes =
	{
		FLAG_allies_gold_crate =
		{
			ROUTE_allied  =
			{
				ROUTE_alliedeast  =
				{
					ROUTE_alliedeastswitch  =
					{
						ROUTE_alliedeastcrypt  =
						{
							ROUTE_alliedcrypt  =
							{
							},
						},
					},
				},
				ROUTE_alliedwest  =
				{
					ROUTE_alliedwestswitch  =
					{
						ROUTE_alliedwestabby  =
						{
							ROUTE_alliedeastabby  =
							{
								ROUTE_alliedeastswitch  =
								{
									ROUTE_alliedeastcrypt  =
									{
										ROUTE_alliedcrypt  =
										{
										},
									},
								},
							},
						},
					},
				},
			},
		},
		FLAG_axis_gold_crate =
		{
			ROUTE_axis  =
			{
				ROUTE_axiseast  =
				{
					ROUTE_axiseastswitch  =
					{
						ROUTE_axiseastcrypt  =
						{
							ROUTE_axiscrypt  =
							{
							},
						},
					},
				},
				ROUTE_axiswest  =
				{
					ROUTE_axiswestswitch  =
					{
						ROUTE_axisabbywest  =
						{
							ROUTE_axisabbyeast  =
							{
								ROUTE_axiseastswitch  =
								{
									ROUTE_axiseastcrypt  =
									{
										ROUTE_axiscrypt  =
										{
										},
									},
								},
							},
						},
					},
				},
			},
		},
		CAPPOINT_Allied =
		{
			ROUTE_alliedcrypt  =
			{
				ROUTE_alliedeastcrypt  =
				{
					ROUTE_alliedeastswitch  =
					{
						ROUTE_alliedeastabby  =
						{
							ROUTE_alliedwestabby  =
							{
								ROUTE_alliedwestswitch  =
								{
									ROUTE_alliedsanc  =
									{
									},
								},
							},
						},
						ROUTE_alliedeast  =
						{
							ROUTE_alliedwest  =
							{
								ROUTE_alliedwestswitch  =
								{
									ROUTE_alliedsanc  =
									{
									},
								},
							},
						},
					},
				},
			},
		},
		CAPPOINT_Axis =
		{
			ROUTE_axiscrypt  =
			{
				ROUTE_axiseastcrypt  =
				{
					ROUTE_axiseastswitch  =
					{
						ROUTE_axisabbyeast  =
						{
							ROUTE_axisabbywest  =
							{
								ROUTE_axiswestswitch  =
								{
									ROUTE_axissanc  =
									{
									},
								},
							},
						},
						ROUTE_axiseast  =
						{
							ROUTE_axiswest  =
							{
								ROUTE_alliedwestswitch  =
								{
									ROUTE_axissanc  =
									{
									},
								},
							},
						},
					},
				},
			},
		},
	};
	MapRoutes.FLAG_allies_gold_crate_1 = MapRoutes.FLAG_allies_gold_crate;
	MapRoutes.FLAG_allies_gold_crate_2 = MapRoutes.FLAG_allies_gold_crate;
	MapRoutes.FLAG_allies_gold_crate_3 = MapRoutes.FLAG_allies_gold_crate;
	MapRoutes.FLAG_allies_gold_crate_4 = MapRoutes.FLAG_allies_gold_crate;
	MapRoutes.FLAG_allies_gold_crate_5 = MapRoutes.FLAG_allies_gold_crate;
	MapRoutes.FLAG_allies_gold_crate_6 = MapRoutes.FLAG_allies_gold_crate;
	MapRoutes.FLAG_allies_gold_crate_7 = MapRoutes.FLAG_allies_gold_crate;
	MapRoutes.FLAG_axis_gold_crate_1 = MapRoutes.FLAG_axis_gold_crate;
	MapRoutes.FLAG_axis_gold_crate_2 = MapRoutes.FLAG_axis_gold_crate;
	MapRoutes.FLAG_axis_gold_crate_3 = MapRoutes.FLAG_axis_gold_crate;
	MapRoutes.FLAG_axis_gold_crate_4 = MapRoutes.FLAG_axis_gold_crate;
	MapRoutes.FLAG_axis_gold_crate_5 = MapRoutes.FLAG_axis_gold_crate;
	MapRoutes.FLAG_axis_gold_crate_6 = MapRoutes.FLAG_axis_gold_crate;
	MapRoutes.FLAG_axis_gold_crate_7 = MapRoutes.FLAG_axis_gold_crate;

	Util.Routes(MapRoutes);

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

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