/****************************************************
Pathing updated and script by **PCZ** >M@t3o$<
Correspondant WAY file size : 26,6 Ko (27 320 octets)
Last Update : 10 November 2009
Updated 2 20 10--Blindman
02 23 10 -more ally camp spots at start
moved some stuff around, new camp goals and a mg42
****************************************************/
//	^4Tardis	01 December 2010	fixed team chat
global Map =
{
	Debug = 0, // please set to zero before distributing your script

	Ammo_Cabinet_t63 = "AMMOCAB_t63",
	Ammo_Cabinet_t65 = "AMMOCAB_t65",
	Health_Cabinet_healaxis = "HEALTHCAB_healaxis",
	Health_Cabinet_t64 = "HEALTHCAB_t64",
	Checkpoint_towerflag = "CHECKPOINT_towerflag",
	Flag_docs = "FLAG_docs",
	Cappoint_Transmitter = "CAPPOINT_Transmitter",
	Build_Command_Post = "BUILD_Command_Post",
	Build_Vault_Door = "BUILD_Vault_Door",
	Build_construction_mg = "BUILD_construction_mg",
	Plant_Castle_Main_Door = "PLANT_Castle_Main_Door",
	Plant_Command_Post = "PLANT_Command_Post",
	Plant_Main_Wall = "PLANT_Main_Wall",
	Plant_Side_Wall = "PLANT_Side_Wall",
	Plant_Vault_Door = "PLANT_Vault_Door",
	Plant_construction_mg = "PLANT_construction_mg",
	Mount_HouseMG42 = "MOUNTMG42_HouseMG42",
	Mount_SpawnMG42 = "MOUNTMG42_SpawnMG42",
	Mount_construction_mg = "MOUNTMG42_construction_mg",
	Repair_HouseMG42 = "REPAIRMG42_HouseMG42",
	Repair_SpawnMG42 = "REPAIRMG42_SpawnMG42",
	Repair_construction_mg = "REPAIRMG42_construction_mg",

	disablecm =
	{
		Name = "disablecm",
		TriggerOnClass = CLASS.ANYPLAYER,
		OnEnter = function(ent)
		{
			b = Util.IsBot(ent);
			if (b)
			{
				b.DisableBotPush(true);
				b.DisableCombatMovement = true;


				Util.MapDebugPrint( "" );
			}
		},
		OnExit = function(ent)
		{
			b = Util.IsBot(ent);
			if (b)
			{
				b.DisableBotPush(false);
				b.DisableCombatMovement = false;

			}
		},
	},

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

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

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

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

	Castle_Main_Door_Destroyed = function( trigger )
	{


		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Charlie.*" );

		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_Allied.*" );

		Util.MapDebugPrint( "Castle_Main_Door_Destroyed" );
	},

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

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

	Main_Wall_Destroyed = function( trigger )
	{

		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_Bravo.*",
			Map.Build_Command_Post,
			Map.Plant_Command_Post,
		});
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Alpha.*" );

		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"ATTACK_Allies.*",
			Map.Build_Command_Post,
			Map.Plant_Command_Post,
			Map.Plant_Vault_Door,
			Map.Build_construction_mg,
			Map.Mount_construction_mg,
			"CAPPOINT_Transmitter",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"MOUNTMG42_CastleMG42",
			"REPAIRMG42_CastleMG42",
		});
		Util.DisableGroup( "1", TEAM.ALLIES);
		Util.EnableGroup( "2", TEAM.ALLIES);

		Util.MapDebugPrint( "Main_Wall_Destroyed" );
	},

	Side_Wall_Destroyed = function( trigger )
	{


		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Charlie.*" );

		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_Allied.*" );

		Util.MapDebugPrint( "Side_Wall_Destroyed" );
	},

	Vault_Door_Destroyed = function( trigger )
	{



		SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_docs" );

		Util.MapDebugPrint( "Vault_Door_Destroyed" );
	},

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

	Docs_Taken = function( trigger )
	{

		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Alpha.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_Bravo.*",
			"DEFEND_Charlie.*",
		});

		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_Delta.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"ATTACK_Allied.*",
			Map.Mount_construction_mg,
		});
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"MOUNTMG42_CastleMG42",
			"REPAIRMG42_CastleMG42",
		});

		Util.MapDebugPrint( "Docs_Taken" );
	},

	Docs_Returned = function( trigger )
	{

		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_Bravo.*",
			"DEFEND_Charlie.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Alpha.*" );


		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_Allied.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_Delta.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, Map.Mount_construction_mg );
		SetAvailableMapGoals( TEAM.AXIS, true, "MOUNTMG42_CastleMG42" );

		Util.MapDebugPrint( "Docs_Returned" );
	},

	Docs_Captured = function( trigger )
	{

		ETUtil.WinningChat( TEAM.ALLIES );
		ETUtil.LosingChat( TEAM.AXIS );

		Util.MapDebugPrint( "Docs_Captured" );
	},

	towerflag_Axis_Captured = function( trigger )
	{

		SetAvailableMapGoals( TEAM.ALLIES, true, Map.Checkpoint_towerflag );
		Util.EnableGroup( "1", TEAM.ALLIES);
		Util.DisableGroup( "2", TEAM.ALLIES);


		Util.MapDebugPrint( "towerflag_Axis_Captured" );
	},

	towerflag_Allies_Captured = function( trigger )
	{

		SetAvailableMapGoals( TEAM.AXIS, true, Map.Checkpoint_towerflag );

		Util.DisableGroup( "1", TEAM.ALLIES);
		Util.EnableGroup( "2", TEAM.ALLIES);

		Util.MapDebugPrint( "towerflag_Allies_Captured" );
	},

};

global OnMapLoad = function()
{
	// *** TRIGGERS ***
	OnTrigger( "Allied Command Post constructed. Charge speed increased!", Map.Allied_Command_Post_Built );
	OnTrigger( "Axis Command Post constructed. Charge speed increased!", Map.Axis_Command_Post_Built );
	OnTrigger( "Axis team has destroyed the Allied Command Post!", Map.Allied_Command_Post_Destroyed );
	OnTrigger( "Allied team has destroyed the Axis Command Post!", Map.Axis_Command_Post_Destroyed );
	OnTrigger( "Axis team has ^3constructed ^7the ^3Safe Door^7!", Map.Vault_Door_Built );
	OnTrigger( "Allied team has ^3built ^7the ^3mg42^7!", Map.construction_mg_Built );
	OnTrigger( "The allied team has ^3destroyed ^7the ^3Main Entrance^7!!", Map.Castle_Main_Door_Destroyed );
	OnTrigger( "Allies have ^3breached ^7the ^3Main Wall^7!", Map.Main_Wall_Destroyed );
	OnTrigger( "Allies have ^3breached ^7the ^3Side Wall^7!", Map.Side_Wall_Destroyed );
	OnTrigger( "Allied team has ^3destroyed ^7the ^3Safe Door^7!", Map.Vault_Door_Destroyed );
	OnTrigger( "Axis team has ^3destroyed ^7the ^3mg42^7!", Map.construction_mg_Destroyed );
	OnTrigger( "Allies have stolen the Secert Documents!", Map.Docs_Taken );
	OnTrigger( "Flag returned docs!", Map.Docs_Returned );
	OnTrigger( "Allied team has ^1transmitted ^7the ^1Documents!", Map.Docs_Captured );
	OnTrigger( "Axis ^3reclaim ^7the ^3Tower Spawn^7!", Map.towerflag_Axis_Captured );
	OnTrigger( "Allies ^3capture ^7the ^3Tower Spawn^7!", Map.towerflag_Allies_Captured );

	dead = OnTriggerRegion(AABB(-457.6,830.975,34.534,336.317,1380.261,274.371), Map.disablecm);


	// *** CLEAR ALL GOALS FOR BOTH TEAMS ***
	Util.DisableGoal(".*", true); // all but routes
	Util.SetGroup( "MOBILEMG42_.*", "1");
	Util.SetGroup( "CAMP_start.*", "1");
	Util.SetGroup( "HEALTHCAB_t64", "1");
	Util.SetGroup( "AMMOCAB_t65", "1");
	Util.SetGroup( "PLANT_Castle_Main_Door", "2");
	Util.SetGroup( "PLANT_Side_Wall", "2");
	Util.SetGroup( "AMMOCAB_t63", "2");
	Util.SetGroup( "HEALTHCAB_healaxis", "2");



	// *** AXIS GOALS ***
	SetAvailableMapGoals( TEAM.AXIS, true, {
		"DEFEND_Alpha.*",
		"AMMOCAB_t63",
		"HEALTHCAB_healaxis",
		"BUILD_Vault_Door",
	});
//~	SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Vault_Door_1" );
//~	SetAvailableMapGoals( TEAM.AXIS, true, "MOUNTMG42_CastleMG42" );

	// *** ALLIED GOALS ***
	SetAvailableMapGoals( TEAM.ALLIES, true, {
		Map.Plant_Main_Wall,
		Map.Checkpoint_towerflag,
	});

	Util.EnableGroup( "1", TEAM.ALLIES);


	// *** PRIORITIES ***
/*
//~	SetGoalPriority( "ATTACK_.*", 0.4 );
//~	SetGoalPriority( "DEFEND_.*", 0.4 );
	SetGoalPriority( "CAMP_.*", 0.7 );
	SetGoalPriority( "ATTACK_Allied.*", 0.5 );
	SetGoalPriority( "ATTACK_Delta.*", 0.5 );
	SetGoalPriority( "DEFEND_Charlie.*", 0.5 );
	SetGoalPriority( Map.Build_construction_mg, 0.7 );
	SetGoalPriority( Map.Checkpoint_towerflag, 0.7 );
	SetGoalPriority( Map.Plant_Command_Post, 0.7 );
	SetGoalPriority( Map.Plant_Main_Wall, 0.8 );
	SetGoalPriority( Map.Plant_Side_Wall, 0.9 );
	SetGoalPriority( Map.Plant_Castle_Main_Door, 0.9 );
	SetGoalPriority( Map.Build_Command_Post, 0.95 );
	SetGoalPriority( Map.Plant_Vault_Door, 1.0 );
*/
	SetGoalPriority( Map.Plant_Command_Post, 0.0, 0, CLASS.ENGINEER );

	SetMapGoalProperties( "MOUNTMG42_CastleMG42", {MinCampTime=60, MaxCampTime=120});

	// *** GOALS PROPERTIES ***
	Util.SetMaxUsers( 1, "PLANT_.*" );
	Util.SetMaxUsers( 2, "PLANT_Main_Wall" );
	Util.SetMaxUsers( 1, "CAMP_.*" );
	Util.SetMaxUsers( 1, "BUILD_.*" );
	Util.SetMaxUsers( 2, "BUILD_Vault_Door" );

	Util.SetMaxUsers( 1, "DEFEND_.*" );
	Util.SetMaxUsers( 1, "REPAIR_.*" );
	Util.SetMaxUsers( 1, "MOUNTMG42_.*" );
	Util.SetMaxUsers( 3, "CHECKPOINT_.*" );


	// *** MOVING FEW PLANT GOALS ***
	Util.SetGoalPosition( -1358, 1642, 28.234, "PLANT_Side_Wall" );
	Util.SetGoalPosition( -748.4, 1260, 24.125, "PLANT_Castle_Main_Door" );
	Util.SetGoalPosition( 617, 162, 311.35, "PLANT_Main_Wall" );
	Util.SetGoalPosition( -1337.684, 1337.453, 216.125, "BUILD_Vault_Door" );

	// *** ROUTES ***
	MapRoutes =
	{
		CHECKPOINT_towerflag =
		{
			ROUTE_AlliedSpawn1 =
			{
				ROUTE_Flag1 =
				{
					ROUTE_Flag2 =
					{
						ROUTE_Flag3 =
						{
							ROUTE_Flag3_1 = { ROUTE_Flag3_3 = {}, },
							ROUTE_Flag3_2 = { ROUTE_Flag3_3 = {}, },
						},
					},
				},
			},

			ROUTE_AlliedSpawn2 =
			{
				ROUTE_Flag1 =
				{
					ROUTE_Flag2 =
					{
						ROUTE_Flag3 =
						{
							ROUTE_Flag3_1 = { ROUTE_Flag3_3 = {}, },
							ROUTE_Flag3_2 = { ROUTE_Flag3_3 = {}, },
						}
					},
				},
			},
		},

		CAPPOINT_Transmitter =
		{
			ROUTE_Docs =
			{
				ROUTE_Escape1 =
				{
					ROUTE_Escape2 =
					{
						ROUTE_Escape3 =
						{
							ROUTE_Escape4 =
							{
								ROUTE_Escape5 = {},
							}
						},
					},
				},
			},
		},
	};

	Util.Routes(MapRoutes);


	Util.MapDebugPrint( "Omni-bot map script for Raw Castle Final by **PCZ** >M@t3o$<." );
};

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