//==========================================================================================
//
//	afd_beta5.gm
//	African Fuel Dump
//
//	Who	When		What
//------------------------------------------------------------------------------------------
//	d00d	26 January 2013	Initial Script
//
//==========================================================================================
//

global Map =
{
	Talk = true,
	DefendingTeam = TEAM.AXIS,
	iw = 0,
	iw2 = 0,

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

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

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

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

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

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

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

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

	Fortress_Doors_Destroyed = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"GRENADE_mg_636",
			"GRENADE_mg_848",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"MOUNTMG42_848",
			"REPAIRMG42_848",
			"MOUNTMG42_663",
			"REPAIRMG42_663",
			"MOUNTMG42_815",
			"REPAIRMG42_815",
			"DEFEND_fueldump.*",
		});
		Map.iw = OnTriggerRegion( AABB(-253,1491,0, 162,2064,130), RegionTrigger.IntrusionWarning );
		sleep(0.5);
		if ( Map.Talk && MAP_TALK )
		{
			foreach ( gameId and bot in BotTable )
			{
				if ( bot.GetTeam() == TEAM.AXIS && RandInt(0,1) < 1 )
				{
					bot.SayVoice(VOICE.REINFORCE_DEF);
					break;
				}
				else if ( bot.GetTeam() == TEAM.AXIS && RandInt(0,1) < 1 )
				{
					bot.SayVoice(VOICE.DEFEND_OBJECTIVE);
					break;
				}
				else if ( bot.GetTeam() == TEAM.ALLIES && RandInt(0,1) < 1 )
				{
					bot.SayVoice(VOICE.REINFORCE_OFF);
					break;
				}
			}
		}
		Util.MapDebugPrint( "Fortress_Doors_Destroyed" );
	},

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

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

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

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

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

};

global OnMapLoad = function()
{
	// Register callback functions
	OnTrigger( "Axis Team have built the Old Mine Team Door", Map.Axis_Team_Door_Construction_Hut_Built );
	OnTrigger( "Axis Have built the Bunker Blockade", Map.Bunker_Blockade_Built );
	OnTrigger( "Axis Command Post constructed. Charge speed increased!", Map.Command_Post_Built );
	OnTrigger( "Allied Command Post constructed. Charge speed increased!", Map.Command_Post_Built );
	OnTrigger( "Axis Have Built the Fuel Dump Defences", Map.Fuel_Dump_Defences_Built );
	OnTrigger( "Allies have built the Water Pump! Old mines Clearing.", Map.Water_Pump_Built );
	OnTrigger( "Allies have destroyed the Axis Old Mine Team Door!!", Map.Axis_Team_Door_Construction_Hut_Destroyed );
	OnTrigger( "Allies have Destroyed the Bunker Blockade", Map.Bunker_Blockade_Destroyed );
	OnTrigger( "Axis team has destroyed the Allied Command Post!", Map.Command_Post_Destroyed );
	OnTrigger( "Allied team has destroyed the Axis Command Post!", Map.Command_Post_Destroyed );
	OnTrigger( "The Allies have breached the Fortress Doors!", Map.Fortress_Doors_Destroyed );
	OnTrigger( "Allied team has destroyed Fuel Dump Defences #1!", Map.Fuel_Dump_Defences_Destroyed );
	OnTrigger( "The Allies have destroyed the Fuel Dump", Map.Fuel_Dump_Destroyed );
	OnTrigger( "Axis have damaged the Water Pump! Old mines flooding.", Map.Water_Pump_Destroyed );
	OnTrigger( "Axis capture the forward spawn!", Map.forward_spawn_Axis_Captured );
	OnTrigger( "Allies capture the forward spawn!", Map.forward_spawn_Allies_Captured );

	// Initial goal availability
	SetAvailableMapGoals( TEAM.ALLIES, false, {
		"DEFEND_.*",
		"MOUNTMG42_.*",
		"REPAIRMG42_.*",
	});
	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"MOUNTMG42_724",
		"REPAIRMG42_724",
	});
	SetAvailableMapGoals( TEAM.ALLIES, false, {
		"GRENADE_mg_724",
		"PLANTMINE_.*",
	});

	SetAvailableMapGoals( TEAM.AXIS, false, {
		"DEFEND_.*",
		"SMOKEBOMB_.*",
		"GRENADE_mg.*",
	});
	SetAvailableMapGoals( TEAM.AXIS, true, "GRENADE_mg_724" );
	SetAvailableMapGoals( TEAM.AXIS, false, {
		"MOUNTMG42_.*",
		"REPAIRMG42_.*",
	});
	SetAvailableMapGoals( TEAM.AXIS, true, {
		"MOUNTMG42_848",
		"MOUNTMG42_724",
	});

	// Priority
	SetGoalPriority( "BUILD_Command_Post", 0.8 );
	SetGoalPriority( "PLANT_Command_Post", 0.8 );
	SetGoalPriority( "BUILD_Fuel_Dump_Defences", 0.91 );

	// Max users per goal
	Util.SetMaxUsers( 1, "DEFEND_.*" );
	Util.SetMaxUsers( 1, "GRENADE_.*" );
	Util.SetMaxUsers( 1, "BUILD_.*" );
	Util.SetMaxUsers( 1, "PLANT_.*" );
	Util.SetMaxUsers( 1, "MOUNTMG42_.*" );
	Util.SetMaxUsers( 2, "DEFUSE_.*" );
	Util.SetMaxUsers( 2, "CHECKPOINT_forward_spawn" );

	// Camp times
	SetMapGoalProperties( "MOUNTMG42_.*", {MinCampTime=15, MaxCampTime=150} );
	SetMapGoalProperties( "MOBILEMG42_.*", {MinCampTime=10, MaxCampTime=60} );

	// Use points
	Util.AddUsePoint( "PLANT_Axis_Team_Door_Construction_Hut", {Vec3(-605,1849,-360),Vec3(-679,1834,-360)} );
	Util.AddUsePoint( "PLANT_Fortress_Doors", Vec3(-27,1243,0) );
	Util.AddUsePoint( "PLANT_Fuel_Dump_Defences", {Vec3(1152,2422,0),Vec3(749,2648,0),Vec3(781,2413,0),Vec3(1189,2603,0)} );
	Util.AddUsePoint( "PLANT_Water_Pump", {Vec3(352,-2061,10),Vec3(249,-2194,10),Vec3(395,-2281,10)} );

	Map.iw2 = OnTriggerRegion( AABB(714,1812,0, 1348,2896,180), RegionTrigger.IntrusionWarningEngObj );

	Util.MapDebugPrint( "Omni-bot map script for African Fuel Dump executed." );
};

global OnBotJoin = function( bot )
{
	bot.MaxViewDistance = 3000;
};

global InitializeRoutes = function()
{
	MapRoutes =
	{
		BUILD_Command_Post =
		{
			ROUTE_allied_spawn =
			{
				ROUTE_wall_south =
				{
					ROUTE_center = {},
					ROUTE_south = {},
				},
				ROUTE_wall_north =
				{
					ROUTE_ruin = {},
					ROUTE_center = {},
				},
				ROUTE_gate =
				{
					ROUTE_south = {},
					ROUTE_ruin = {},
					ROUTE_center = {},
				},
			},
		},
		BUILD_Water_Pump =
		{
			ROUTE_allied_spawn =
			{
				ROUTE_wall_south = {},
				ROUTE_wall_north = {},
				ROUTE_gate = {},
			},
		},
		MOUNTMG42_724 =
		{
			ROUTE_allied_spawn =
			{
				ROUTE_wall_south =
				{
					ROUTE_center = {},
					ROUTE_south = {},
				},
				ROUTE_wall_north =
				{
					ROUTE_ruin = {},
					ROUTE_center = {},
				},
				ROUTE_gate =
				{
					ROUTE_south = {},
					ROUTE_ruin = {},
					ROUTE_center = {},
				},
			},
		},
		PLANT_Command_Post =
		{
			ROUTE_allied_spawn =
			{
				ROUTE_wall_south =
				{
					ROUTE_center = {},
					ROUTE_south = {},
				},
				ROUTE_wall_north =
				{
					ROUTE_ruin = {},
					ROUTE_center = {},
				},
				ROUTE_gate =
				{
					ROUTE_south = {},
					ROUTE_ruin = {},
					ROUTE_center = {},
				},
			},
		},
		PLANT_Fuel_Dump_Defences =
		{
			ROUTE_allied_spawn =
			{
				ROUTE_wall_south =
				{
					ROUTE_center = {},
					ROUTE_south = {},
				},
				ROUTE_east = {},
				ROUTE_wall_north = {},
				ROUTE_gate =
				{
					ROUTE_west = {},
					ROUTE_east = {},
					ROUTE_south = {},
					ROUTE_ruin = {},
					ROUTE_center = {},
				},
			},
		},
		PLANT_Fortress_Doors =
		{
			ROUTE_allied_spawn =
			{
				ROUTE_wall_south =
				{
					ROUTE_center = {},
					ROUTE_south = {},
				},
				ROUTE_east = {},
				ROUTE_wall_north = {},
				ROUTE_gate =
				{
					ROUTE_west = {},
					ROUTE_east = {},
					ROUTE_south = {},
					ROUTE_ruin = {},
					ROUTE_center = {},
				},
			},
		},
		PLANT_Fule_Dump =
		{
			ROUTE_allied_spawn =
			{
				ROUTE_wall_south =
				{
					ROUTE_center = {},
					ROUTE_south = {},
				},
				ROUTE_east = {},
				ROUTE_wall_north = {},
				ROUTE_gate =
				{
					ROUTE_west = {},
					ROUTE_east = {},
					ROUTE_south = {},
					ROUTE_ruin = {},
					ROUTE_center = {},
				},
			},
		},
		CHECKPOINT_forward_spawn =
		{
			ROUTE_allied_spawn =
			{
				ROUTE_wall_south = {},
				ROUTE_wall_north = {},
				ROUTE_gate = {},
			},
		},
	};
	Util.Routes(MapRoutes);
};
