//==========================================================================================
//
//	the_town.gm
//
//	Who	When		What
//------------------------------------------------------------------------------------------
//	BubbaG1	14 July 2012	Initial Script
//
//==========================================================================================
//

global Map =
{
	Axis_Team_Door_Dyno = 0,
	Axis_Team_Door_1_Dyno = 0,
	Barrier_Defenses_Dyno = 0,
	Command_Post_Dyno = 0,
	First_Barrier_Defenses_Dyno = 0,
	Oasis_Water_Pump_Dyno = 0,
	Secret_Door_Dyno = 0,
	tunnel_barrier_Dyno = 0,

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

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

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

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

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

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

	Barrier_Defenses_Planted = function()
	{
		Map.Barrier_Defenses_Dyno += 1;
		Util.MapDebugPrint( "Barrier_Defenses_Planted" );
	},

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

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

	First_Barrier_Defenses_Planted = function()
	{
		Map.First_Barrier_Defenses_Dyno += 1;
		Util.MapDebugPrint( "First_Barrier_Defenses_Planted" );
	},

	Oasis_Water_Pump_Planted = function()
	{
		Map.Oasis_Water_Pump_Dyno += 1;
		Util.MapDebugPrint( "Oasis_Water_Pump_Planted" );
	},

	Secret_Door_Planted = function()
	{
		Map.Secret_Door_Dyno += 1;
		Util.MapDebugPrint( "Secret_Door_Planted" );
	},

	tunnel_barrier_Planted = function()
	{
		Map.tunnel_barrier_Dyno += 1;
		Util.MapDebugPrint( "tunnel_barrier_Planted" );
	},

	Barrier_Defenses_Defused = function()
	{
		Map.Barrier_Defenses_Dyno -= 1;
		Util.MapDebugPrint( "Barrier_Defenses_Defused" );
	},

	Command_Post_Defused = function()
	{
		Map.Command_Post_Dyno -= 1;
		Util.MapDebugPrint( "Command_Post_Defused" );
	},

	First_Barrier_Defenses_Defused = function()
	{
		Map.First_Barrier_Defenses_Dyno -= 1;
		Util.MapDebugPrint( "First_Barrier_Defenses_Defused" );
	},

	Oasis_Water_Pump_Defused = function()
	{
		Map.Oasis_Water_Pump_Dyno -= 1;
		Util.MapDebugPrint( "Oasis_Water_Pump_Defused" );
	},

	Secret_Door_Defused = function()
	{
		Map.Secret_Door_Dyno -= 1;
		Util.MapDebugPrint( "Secret_Door_Defused" );
	},

	tunnel_barrier_Defused = function()
	{
		Map.tunnel_barrier_Dyno -= 1;
		Util.MapDebugPrint( "tunnel_barrier_Defused" );
	},

	Axis_Team_Door_Destroyed = function()
	{
		Map.Axis_Team_Door_Dyno = 0;

		Util.MapDebugPrint( "Axis_Team_Door_Destroyed" );
	},

	Axis_Team_Door_1_Destroyed = function()
	{
		Map.Axis_Team_Door_1_Dyno = 0;

		Util.MapDebugPrint( "Axis_Team_Door_1_Destroyed" );
	},

	Barrier_Defenses_Destroyed = function()
	{
		Map.Barrier_Defenses_Dyno = 0;

		Util.MapDebugPrint( "Barrier_Defenses_Destroyed" );
	},

	Allied_Command_Post_Destroyed = function()
	{
		Map.Command_Post_Dyno = 0;

		Util.MapDebugPrint( "Allied_Command_Post_Destroyed" );
	},

	Axis_Command_Post_Destroyed = function()
	{
		Map.Command_Post_Dyno = 0;

		Util.MapDebugPrint( "Axis_Command_Post_Destroyed" );
	},

	First_Barrier_Defenses_Destroyed = function()
	{
		Map.First_Barrier_Defenses_Dyno = 0;

		Util.MapDebugPrint( "First_Barrier_Defenses_Destroyed" );
	},

	Oasis_Water_Pump_Destroyed = function()
	{
		Map.Oasis_Water_Pump_Dyno = 0;

		Util.MapDebugPrint( "Oasis_Water_Pump_Destroyed" );
	},

	Secret_Door_Destroyed = function()
	{
		Map.Secret_Door_Dyno = 0;

		Util.MapDebugPrint( "Secret_Door_Destroyed" );
	},

	tunnel_barrier_Destroyed = function()
	{
		Map.tunnel_barrier_Dyno = 0;

		Util.MapDebugPrint( "tunnel_barrier_Destroyed" );
	},

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

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

	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( "barrier_defenses", Map.Barrier_Defenses_Built );
	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( "barrier_defenses1", Map.First_Barrier_Defenses_Built );
	OnTrigger( "Allies have built the Oasis Water Pump!", Map.Oasis_Water_Pump_Built );
	OnTrigger( "Axis team has built the tunnel barrier!", Map.tunnel_barrier_Built );
	OnTrigger( "Planted at The Barrier Defenses.", Map.Barrier_Defenses_Planted );
	OnTrigger( "Planted at The First Barrier Defenses.", Map.First_Barrier_Defenses_Planted );
	OnTrigger( "Planted at the Oasis Water Pump.", Map.Oasis_Water_Pump_Planted );
	OnTrigger( "Planted at The Secret Door.", Map.Secret_Door_Planted );
	OnTrigger( "Planted at the tunnel barrier.", Map.tunnel_barrier_Planted );
	OnTrigger( "Defused at The First Barrier Defenses.", Map.First_Barrier_Defenses_Defused );
	OnTrigger( "Defused at the Oasis Water Pump.", Map.Oasis_Water_Pump_Defused );
	OnTrigger( "Defused at The Secret Door.", Map.Secret_Door_Defused );
	OnTrigger( "Defused at the tunnel barrier.", Map.tunnel_barrier_Defused );
	OnTrigger( "Allies have destroyed the Axis team door!!", Map.Axis_Team_Door_Destroyed );
	OnTrigger( "Allied team has destroyed the barrier defenses! Action: announce Entity: (298:1)", Map.Barrier_Defenses_Destroyed );
	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( "Allied team has destroyed the barrier defenses! Action: announce Entity: (311:1)", Map.First_Barrier_Defenses_Destroyed );
	OnTrigger( "Axis have damaged the Oasis Water Pump!", Map.Oasis_Water_Pump_Destroyed );
	OnTrigger( "the secret door has been destroyed", Map.Secret_Door_Destroyed );
	OnTrigger( "Allied team has destroyed the tunnel barrier!", Map.tunnel_barrier_Destroyed );
	OnTrigger( "Allies has stolen the Documents!", Map.axisdocuments_Taken );
	OnTrigger( "Axis have returned Axis Documents!", Map.axisdocuments_Returned );
	OnTrigger( "Allies lose the forward spawn!", Map.forward_spawn_Axis_Captured );
	OnTrigger( "Allies capture the forward spawn!", Map.forward_spawn_Allies_Captured );

	SetGoalPriority( "DEFUSE_First_Barrier_Defenses_.*", 1.20, TEAM.AXIS, CLASS.ENGINEER, true );
	SetGoalPriority( "DEFUSE_Barrier_Defenses_.*", 1.20, TEAM.AXIS, CLASS.ENGINEER, true );
	SetGoalPriority( "DEFUSE_Axis_Team_Door_.*", 1.20, TEAM.AXIS, CLASS.ENGINEER, true );
	SetGoalPriority( "DEFUSE_Secret_Door_.*", 1.20, TEAM.AXIS, CLASS.ENGINEER, true );

	// Max users per goal
	Util.SetMaxUsers( 1, "DEFEND_.*" );
	Util.SetMaxUsers( 1, "GRENADE_.*" );
	Util.SetMaxUsers( 1, "MOUNTMG42_.*" );

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


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


