//==========================================================================================
//
//	tron_v1.gm
//
//	Who	When		What
//------------------------------------------------------------------------------------------
//	Martin	04 October 2010	Initial Script
//
//==========================================================================================
//

global Map =
{
	Debug = 1,

	barricade_Dyno = 0,
	master_control_program_Dyno = 0,

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

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

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

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

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

	barricade_Destroyed = function( trigger )
	{
		Map.barricade_Dyno = 0;

		Util.MapDebugPrint( "barricade_Destroyed" );
	},

	master_control_program_Destroyed = function( trigger )
	{
		Map.master_control_program_Dyno = 0;

		Util.MapDebugPrint( "master_control_program_Destroyed" );
	},

};

global OnMapLoad = function()
{
	// Register callback functions
	OnTrigger( "MISSING_STRING", Map.barricade_Built );
	OnTrigger( "Planted at the MISSING_STRING.", Map.barricade_Planted );
	OnTrigger( "Planted at the MISSING_STRING.", Map.master_control_program_Planted );
	OnTrigger( "Defused at the MISSING_STRING.", Map.barricade_Defused );
	OnTrigger( "Defused at the MISSING_STRING.", Map.master_control_program_Defused );
	OnTrigger( "MISSING_STRING", Map.barricade_Destroyed );
	OnTrigger( "MISSING_STRING", Map.master_control_program_Destroyed );

	//~Util.DisableGoal( ".*", true ); // all but routes
	//~SetAvailableMapGoals( TEAM.AXIS, true, "ATTACK_.*" );
	//~SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_.*" );

	SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_master_control_program" );
	SetGoalPriority( "DEFUSE_master_control_program.*", 0.0, 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} );

	if ( Map.Debug > 1 )
		{ Util.ShowActiveGoals(); }

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