//==========================================================================================
//
//	raw_te.gm
//
//	Who  	When		What
//------------------------------------------------------------------------------------------
//	^4Tardis	01 December 2010	Initial Script
//
//==========================================================================================
//Used bits from raw_final Thanks ....
/****************************************************
Pathing updated and script by **PCZ** >M@t3o$<
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
****************************************************/

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

	Castle_Main_Door_Dyno = 0,
	Main_Wall_Dyno = 0,
	Side_Wall_Dyno = 0,
	Vault_Door_Dyno = 0,
	Vault_Door_1_Dyno = 0,
	construction_mg_Dyno = 0,
	Allied_Command_Post_Dyno = 0,
	Axis_Command_Post_Dyno = 0,

	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" );
	},

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

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

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

	Axis_Command_Post_Built = function( trigger )
	{

		Util.MapDebugPrint( "Axis_Command_Post_Built" );
	},

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

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

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

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

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

	Castle_Main_Door_Planted = function( trigger )
	{
		Map.Castle_Main_Door_Dyno += 1;
		Util.MapDebugPrint( "Castle_Main_Door_Planted" );
	},

	Main_Wall_Planted = function( trigger )
	{
		Map.Main_Wall_Dyno += 1;
		Util.MapDebugPrint( "Main_Wall_Planted" );
	},

	Side_Wall_Planted = function( trigger )
	{
		Map.Side_Wall_Dyno += 1;
		Util.MapDebugPrint( "Side_Wall_Planted" );
	},

	Vault_Door_Planted = function( trigger )
	{
		Map.Vault_Door_Dyno += 1;
		Util.MapDebugPrint( "Vault_Door_Planted" );
	},

	construction_mg_Planted = function( trigger )
	{
		Map.construction_mg_Dyno += 1;
		Util.MapDebugPrint( "construction_mg_Planted" );
	},

	Castle_Main_Door_Defused = function( trigger )
	{
		Map.Castle_Main_Door_Dyno -= 1;
		Util.MapDebugPrint( "Castle_Main_Door_Defused" );
	},


	Main_Wall_Defused = function( trigger )
	{
		Map.Main_Wall_Dyno -= 1;
		Util.MapDebugPrint( "Main_Wall_Defused" );
	},

	Side_Wall_Defused = function( trigger )
	{
		Map.Side_Wall_Dyno -= 1;
		Util.MapDebugPrint( "Side_Wall_Defused" );
	},

	Vault_Door_Defused = function( trigger )
	{
		Map.Vault_Door_Dyno -= 1;
		Util.MapDebugPrint( "Vault_Door_Defused" );
	},

	construction_mg_Defused = function( trigger )
	{
		Map.construction_mg_Dyno -= 1;
		Util.MapDebugPrint( "construction_mg_Defused" );
	},

	Castle_Main_Door_Destroyed = function( trigger )
	{
		Map.Castle_Main_Door_Dyno = 0;

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

		Util.MapDebugPrint( "Castle_Main_Door_Destroyed" );
	},

	Main_Wall_Destroyed = function( trigger )
	{
		Map.Main_Wall_Dyno = 0;
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_Bravo.*",
			"BUILD_Command_Post",
			"PLANT_Command_Post",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Alpha.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"ATTACK_Allies.*",
			"BUILD_Command_Post",
			"PLANT_Command_Post",
			"PLANT_Vault_Door",
			"PLANT_Vault_Door_1",
			"BUILD_construction_mg",
			"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 )
	{
		Map.Side_Wall_Dyno = 0;
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Charlie.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_Allied.*" );
		Util.MapDebugPrint( "Side_Wall_Destroyed" );
	},

	Vault_Door_Destroyed = function( trigger )
	{
		Map.Vault_Door_Dyno = 0;
		SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_docs" );
		Util.MapDebugPrint( "Vault_Door_Destroyed" );
	},

	construction_mg_Destroyed = function( trigger )
	{
		Map.construction_mg_Dyno = 0;

		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.*",
			"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, "MOUNT_construction_mg" );
		SetAvailableMapGoals( TEAM.AXIS, true, "MOUNTMG42_CastleMG42" );

		Util.MapDebugPrint( "docs_Returned" );
	},

	docs_Secured = function( trigger )
	{

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

		Util.MapDebugPrint( "docs_Secured" );
	},

	towerflag_Axis_Captured = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "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, "CHECKPOINT_towerflag" );
		Util.DisableGroup( "1", TEAM.ALLIES);
		Util.EnableGroup( "2", TEAM.ALLIES);
		Util.MapDebugPrint( "towerflag_Allies_Captured" );
	},

};

global OnMapLoad = function()
{
	// Register callback functions
	OnTrigger( "Axis team has ^3constructed ^7the ^3Safe Door^7!", Map.Vault_Door_Built );
	//OnTrigger( "Axis team has ^3constructed ^7the ^3Safe Door^7!", Map.Vault_Door_1_Built );
	OnTrigger( "Allied team has ^3built ^7the ^3mg42^7!", Map.construction_mg_Built );
	OnTrigger( "Planted at the Castle Main Door.", Map.Castle_Main_Door_Planted );
	OnTrigger( "Planted at the Main Wall.", Map.Main_Wall_Planted );
	OnTrigger( "Planted at the Side Wall.", Map.Side_Wall_Planted );
	OnTrigger( "Planted at the Vault Door.", Map.Vault_Door_Planted );
	OnTrigger( "Planted at the construction mg.", Map.construction_mg_Planted );
	OnTrigger( "Defused at the Castle Main Door.", Map.Castle_Main_Door_Defused );
	OnTrigger( "Defused at the Main Wall.", Map.Main_Wall_Defused );
	OnTrigger( "Defused at the Side Wall.", Map.Side_Wall_Defused );
	OnTrigger( "Defused at the Vault Door.", Map.Vault_Door_Defused );
	OnTrigger( "Defused at the construction mg.", Map.construction_mg_Defused );
	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 Secret Documents!", Map.docs_Taken );
	OnTrigger( "Axis have returned the objective!", Map.docs_Returned );
	OnTrigger( "Allied team has ^1transmitted ^7the ^1Documents!", Map.docs_Secured );
	OnTrigger( "Axis ^3reclaim ^7the ^3Tower Spawn^7!", Map.towerflag_Axis_Captured );
	OnTrigger( "Allies ^3capture ^7the ^3Tower Spawn^7!", Map.towerflag_Allies_Captured );
	OnTrigger( "Allied Command Post constructed. Charge speed increased!", Map.Allied_Command_Post_Built );
	OnTrigger( "Defused at the Allied Command Post.", Map.Allied_Command_Post_Defused );
	OnTrigger( "Defused at the Axis Command Post.", Map.Axis_Command_Post_Defused );
	OnTrigger( "Axis Command Post constructed. Charge speed increased!", Map.Axis_Command_Post_Built );
	OnTrigger( "Planted at the Allied Command Post.", Map.Allied_Command_Post_Planted );
	OnTrigger( "Planted at the Axis Command Post.", Map.Axis_Command_Post_Planted );
	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 );

	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.RemoveGoal( "BUILD_Vault_Door_1" );
	Util.RemoveGoal( "PLANT_Vault_Door_1" );
	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",
	});
	// *** ALLIES GOALS ***
	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"PLANT_Main_Wall",
		"CHECKPOINT_towerflag",
	});
	Util.EnableGroup( "1", TEAM.ALLIES);
	// Camp times
	SetMapGoalProperties( "MOUNTMG42_.*", {MinCampTime=15, MaxCampTime=90} );
	SetMapGoalProperties( "MOBILEMG42_.*", {MinCampTime=60, MaxCampTime=120} );
	// Max users per goal
	Util.SetMaxUsers( 1, "DEFEND_.*" );
	Util.SetMaxUsers( 1, "GRENADE_.*" );
	Util.SetMaxUsers( 1, "MOUNTMG42_.*" );
	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( -1994.809, 1674.073, 50.430, "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( -1343.794, 1357.127, 440.125, "PLANT_Vault_Door" );
	Util.SetGoalPosition( -1343.794, 1357.127, 440.125, "PLANT_Vault_Door_1" );

// *** 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 " + GetMapName() + " executed." );
};

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