//==========================================================================================
//
//	weisbaden_final.gm
//
//	Who          	When		What
//------------------------------------------------------------------------------------------
//	^1[UJE]^3Captain	24 May 2015	Initial Script
//
//==========================================================================================
//

global Map =
{
	Debug = 1, // please set to zero before distributing your script
	ShowMovers = false,

	Main_Generator_Dyno = 0,
	Neutral_Command_Post_Dyno = 0,
	Silo_Controls_Dyno = 0,
    Talk = true,
	start_of_map = true,
	Receiving_Bay_Gate = true,
	Allied_Command_Post_Built = true,
	
	Allied_Command_Post_Built = function( trigger )
	{
		if ( Map.start_of_map )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_Hall_Gate_.*" );
			SetAvailableMapGoals( TEAM.ALLIES, true, "SMOKEBOMB_Hall_.*" );
			Map.start_of_map = false;
		}
		
		SetAvailableMapGoals( TEAM.ALLIES, false, "MOUNTMG42_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_Rail_Yard_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Receiving_Bay_Gate" );
	    SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Neutral_Command_Post" );
	    SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Neutral_Command_Post" );	
		      
			  if ( Map.Receiving_Bay_Gate == false )
		{
	   SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Neutral_Command_Post" );
		}

	   SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Neutral_Command_Post" );
	   
	   SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Neutral_Command_Post" );
	   SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Neutral_Command_Post" );
	   Map.Allied_Command_Post_Built = true;
		Util.MapDebugPrint( "Allied_Command_Post_Built" );
		
	},
	
	Allied_Command_Post_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

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

	Allied_Command_Post_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

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

	Allied_Command_Post_Destroyed = function( trigger )
	{

     if ( Map.Receiving_Bay_Gate == false )
		{
	   SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Neutral_Command_Post" );
		}
	SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Neutral_Command_Post" );
	
	SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Neutral_Command_Post" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Neutral_Command_Post" );	
	
		Util.MapDebugPrint( "Allied_Command_Post_Destroyed" );
	},
	
	Axis_Command_Post_Built = function( trigger )
	{
		if ( TestMap )
			{ return; }
	SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Neutral_Command_Post" );
	SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Neutral_Command_Post" );	
	
	SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Neutral_Command_Post" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Neutral_Command_Post" );
	
		Util.MapDebugPrint( "Axis_Command_Post_Built" );
	},

	Axis_Command_Post_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

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

	Axis_Command_Post_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

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

	Axis_Command_Post_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
	SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Neutral_Command_Post" );
	SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Neutral_Command_Post" );
	
	SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Neutral_Command_Post" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Neutral_Command_Post" );	
	
		Util.MapDebugPrint( "Axis_Command_Post_Destroyed" );
		
	},

	Receiving_Bay_Gate_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

        Map.Receiving_Bay_gate_Dyno += 1;
		Util.MapDebugPrint( "Receiving_Bay_gate_Planted" );
	},
	
	Receiving_Bay_Gate_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Receiving_Bay_gate_Dyno -= 1;
		Util.MapDebugPrint( "Receiving_Bay_gate_Defused" );
	},
	
	Receiving_Bay_Gate_Destroyed = function( trigger )
	{
      if ( Map.Allied_Command_Post_Built == true )
		{
	   SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Neutral_Command_Post" );
		}
	 SetAvailableMapGoals( TEAM.AXIS, false, "MOBILEMG42_Hall_Gate" );
	 SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Hall_Gate_.*" );
	 SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Main_Generator_.*" );
	 SetAvailableMapGoals( TEAM.AXIS, true, "MOBILEMG42_Main_Generator" );
	 
			
	 SetAvailableMapGoals( TEAM.ALLIES, false, "SMOKEBOMB_Hall_.*" );
	 SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_Hall_Gate_.*" );
	 SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_Main_Generator_.*" );
	 SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Main_Generator" );
	 
		Map.Main_Generator_Dyno -= 1;
		Map.Receiving_Bay_Gate = false;
		Util.MapDebugPrint( "Receiving_Bay_gate_Destroyed" );
	},
	
   Main_Generator_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Main_Generator_Dyno += 1;
		Util.MapDebugPrint( "Main_Generator_Planted" );
	},

	Silo_Controls_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Silo_Controls_Dyno += 1;
		Util.MapDebugPrint( "Silo_Controls_Planted" );
	},

	Main_Generator_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Main_Generator_Dyno -= 1;
		Util.MapDebugPrint( "Main_Generator_Defused" );
	},

	Silo_Controls_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Silo_Controls_Dyno -= 1;
		Util.MapDebugPrint( "Silo_Controls_Defused" );
	},

	Main_Generator_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }
	 SetAvailableMapGoals( TEAM.AXIS, false, "MOBILEMG42_Main_Generator" );
	 SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Main_Generator_.*" );
	 SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Silo_Controls_.*" );
	 SetAvailableMapGoals( TEAM.AXIS, true, "MOBILEMG_Silo_Controls_.*" );


	 
	 SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_Main_Generator_.*" );
	 SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Main_Generator" );
	 SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_Main_Generator_.*" );
	 SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Silo_Controls" );
	 SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_Silo_Controls_.*" );
	 
		Map.Main_Generator_Dyno = 0;

		Util.MapDebugPrint( "Main_Generator_Destroyed" );
	},


	Silo_Controls_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }
		
	 
		Map.Silo_Controls_Dyno = 0;

		Util.MapDebugPrint( "Silo_Controls_Destroyed" );
	},

};

global OnMapLoad = function()
{
	if ( TestMapOn )
		{ Util.AutoTestMap(); }

	// Register callback functions
	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( "Allied team has destroyed the Axis Command Post!", Map.Axis_Command_Post_Destroyed );
	OnTrigger( "Axis team has destroyed the Allied Command Post!", Map.Allied_Command_Post_Destroyed );
	OnTrigger( "Planted at the Receiving Bay Gate.", Map.Receiving_Bay_Gate_Planted );
	OnTrigger( "Defused at the Receiving Bay Gate.", Map.Receiving_Bay_Gate_Defused );
	OnTrigger( "The Allies have breached the receiving bay door!", Map.Receiving_Bay_Gate_Destroyed );
	OnTrigger( "Planted at the Main Generator.", Map.Main_Generator_Planted );
	OnTrigger( "Planted at the Silo Controls.", Map.Silo_Controls_Planted );
	OnTrigger( "Defused at the Main Generator.", Map.Main_Generator_Defused );
	OnTrigger( "Defused at the Silo Controls.", Map.Silo_Controls_Defused );
	OnTrigger( "The Allies have destroyed the Main Generator - security doors and fuel pumps off-line!", Map.Main_Generator_Destroyed );
	OnTrigger( "Auxiliary generators engaged - fuel pumps re-activated!", Map.Main_Generator_Destroyed );
	OnTrigger( "The Allies have destroyed the Silo Controls!", Map.Silo_Controls_Destroyed );

	Util.DisableGoal( ".*", true ); // all but routes
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Hall_Gate_.*" );
	SetAvailableMapGoals( TEAM.AXIS, true, "MOBILEMG42_Hall_Gate" );
	SetAvailableMapGoals( TEAM.AXIS, true, "AMMOCAB_.*" );
	SetAvailableMapGoals( TEAM.AXIS, true, "HEALTHCAB_.*" );
	SetAvailableMapGoals( TEAM.AXIS, false, "ATTACK_.*" );
	SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_.*" );
	SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_.*" );


	
	
	SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_.*" );
    SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "SMOKEBOMB_Hall_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "MOUNTMG42_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_Rail_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "AMMOCAB_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "HEALTHCAB_.*" );

	// Max users per goal
	Util.SetMaxUsers( 1, "ATTACK_.*" );
	Util.SetMaxUsers( 1, "DEFEND_.*" );
	Util.SetMaxUsers( 1, "MOUNTMG42_.*" );
	Util.SetMaxUsers( 1, "BUILD_.*" );
	
	// *** PRIORITY ***
	SetGoalPriority( "PLANT_Silo_Controls", 0.91, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_Main_Generator", 0.91, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_Receiving_Bay_Gate", 0.80, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_Command_.*", 0.84, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "BUILD_Command_.*", 0.84, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "BUILD_Command_.*", 0.81, TEAM.AXIS, CLASS.ENGINEER );

	// Camp times
	SetMapGoalProperties( "MOUNTMG42_.*", {MinCampTime=45, MaxCampTime=90} );

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

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

global InitializeRoutes = function()
{
	MapRoutes =
	{
	};
	Util.Routes(MapRoutes);
};
