//==========================================================================================
//
//	sod2_rev.gm
//
//	Who                    	When		What
//------------------------------------------------------------------------------------------
//	^1{WeB}^7*^4GA^1NG$^4TA^7*	11 November 2016	Initial Script
//
//==========================================================================================
//

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

	Neutral_Command_Post_Dyno = 0,
	Tank_Barrier_Dyno = 0,
	balcony_Dyno = 0,
	bank_wall_Dyno = 0,
	footbridge_Dyno = 0,

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

		Util.MapDebugPrint( "Neutral_Command_Post_Built" );
	},

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

		Util.MapDebugPrint( "Tank_Barrier_Built" );
	},
	
		Tank_Built = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "Tank_Built" );
	},

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

		Util.MapDebugPrint( "balcony_Built" );
	},

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

		Util.MapDebugPrint( "footbridge_Built" );
	},

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

		Map.Neutral_Command_Post_Dyno += 1;
		Util.MapDebugPrint( "Neutral_Command_Post_Planted" );
	},

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

		Map.Tank_Barrier_Dyno += 1;
		Util.MapDebugPrint( "Tank_Barrier_Planted" );
	},

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

		Map.balcony_Dyno += 1;
		Util.MapDebugPrint( "balcony_Planted" );
	},

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

		Map.bank_wall_Dyno += 1;
		Util.MapDebugPrint( "bank_wall_Planted" );
	},

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

		Map.footbridge_Dyno += 1;
		Util.MapDebugPrint( "footbridge_Planted" );
	},

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

		Map.Neutral_Command_Post_Dyno -= 1;
		Util.MapDebugPrint( "Neutral_Command_Post_Defused" );
	},

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

		Map.Tank_Barrier_Dyno -= 1;
		Util.MapDebugPrint( "Tank_Barrier_Defused" );
	},

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

		Map.balcony_Dyno -= 1;
		Util.MapDebugPrint( "balcony_Defused" );
	},

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

		Map.bank_wall_Dyno -= 1;
		Util.MapDebugPrint( "bank_wall_Defused" );
	},

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

		Map.footbridge_Dyno -= 1;
		Util.MapDebugPrint( "footbridge_Defused" );
	},

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

		Map.Neutral_Command_Post_Dyno = 0;

		Util.MapDebugPrint( "Neutral_Command_Post_Destroyed" );
	},

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

		Map.Tank_Barrier_Dyno = 0;

		Util.MapDebugPrint( "Tank_Barrier_Destroyed" );
	},

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

		Map.balcony_Dyno = 0;

		Util.MapDebugPrint( "balcony_Destroyed" );
	},
	
		Bank_Doors_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }

		SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Neutral_Command_Post" );
	      SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Neutral_Command_Post" );
		SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_tank" );
		SetAvailableMapGoals( TEAM.AXIS, false, "ESCORT_tank" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Neutral_Command_Post" );
	      SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Neutral_Command_Post" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "CHECKPOINT_forward_flag" );
		SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_bank_wall" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Bank_1" );
	      SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Bank_2" );
	      SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Bank_3" );
	      SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Bank_4" );
	      SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Bank_5" );

		Util.MapDebugPrint( "Bank_Doors_Destroyed" );
	},

	bank_wall_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_balcony" );
	      SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_footbridge" );	

		Map.bank_wall_Dyno = 0;

		Util.MapDebugPrint( "bank_wall_Destroyed" );
	},

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

		Map.footbridge_Dyno = 0;

		Util.MapDebugPrint( "footbridge_Destroyed" );
	},

	gold_crate1_Taken = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_balcony" );
		SetAvailableMapGoals( TEAM.AXIS, true, "CAPPOINT_safe" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Train_4" );
	      SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Train_5" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Train_1" );
	      SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Train_2" );
	      SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Train_3" );
	      SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Train_4" );
	      SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Train_5" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Bank_1" );
	      SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Bank_2" );
	      SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Bank_3" );
	      SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Bank_4" );
	      SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Bank_5" );

		Util.MapDebugPrint( "gold_crate1_Taken" );
	},

	gold_crate1_Returned = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_balcony" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Train_4" );
	      SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Train_5" );	
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Train_1" );
	      SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Train_2" );
	      SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Train_3" );
	      SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Train_4" );
	      SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Train_5" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Bank_1" );
	      SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Bank_2" );
	      SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Bank_3" );
	      SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Bank_4" );
	      SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Bank_5" );

		Util.MapDebugPrint( "gold_crate1_Returned" );
	},

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

		Util.MapDebugPrint( "gold_crate1_Secured" );
	},

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

		Util.MapDebugPrint( "forward_flag_Axis_Captured" );
	},

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

		Util.MapDebugPrint( "forward_flag_Allies_Captured" );
	},

};

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

	// Register callback functions
	OnTrigger( "^/The Tank Barrier has been constructed.", Map.Tank_Barrier_Built );
	OnTrigger( "^/The -=^1AN^/=- ^1TANK ^/has been repaired!^1!^/!", Map.Tank_Built );
	OnTrigger( "^/The ^1Axis ^/forces have rebuilt the balcony!", Map.balcony_Built );
	OnTrigger( "^/The ^1Axis ^/forces have rebuilt the footbridge!", Map.footbridge_Built );
	OnTrigger( "Planted at the MISSING_STRING.", Map.Tank_Barrier_Planted );
	OnTrigger( "^/The Tank Barrier has been destroyed.", Map.Tank_Barrier_Destroyed );
	OnTrigger( "^/The ^1Axis ^/forces have destroyed the Bank Doors!", Map.Bank_Doors_Destroyed );
	OnTrigger( "^/The ^4Allied ^/forces have destroyed the balcony!", Map.balcony_Destroyed );
	OnTrigger( "^/The ^1Axis ^/forces have destroyed the bank side wall!", Map.bank_wall_Destroyed );
	OnTrigger( "^/The ^4Allied ^/forces have destroyed the footbridge!", Map.footbridge_Destroyed );
	OnTrigger( "^/The ^1Axis ^/forces have stolen the Spear of Destiny!", Map.gold_crate1_Taken );
	OnTrigger( "^/The ^4Allied ^/forces have returned the Spear of Destiny!", Map.gold_crate1_Returned );
	OnTrigger( "The Axis forces have secured the Spear of Destiny!", Map.gold_crate1_Secured );
	OnTrigger( "^/The ^1Axis ^/forces have captured the Forward Flag!", Map.forward_flag_Axis_Captured );
	OnTrigger( "^/The ^4Allies ^/have captured the Forward Flag!", Map.forward_flag_Allies_Captured );

	SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_balcony" );
	SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_footbridge" );
	SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_bank_wall" );
	SetAvailableMapGoals( TEAM.AXIS, false, "CAPPOINT_safe" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Train_4" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Train_5" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Train_1" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Train_2" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Train_3" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Train_4" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Train_5" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Bank_1" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Bank_2" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Bank_3" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Bank_4" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Bank_5" );
	
	SetGoalPriority("CAPPOINT_Safe", 0.91);
	SetGoalPriority("BUILD_footbridge", 0.91);
	
	//~Util.DisableGoal( ".*", true ); // all but routes
	//~SetAvailableMapGoals( TEAM.AXIS, true, "ATTACK_.*" );
	//~SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_.*" );

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

global OnBotJoin = function( bot )
{
	bot.TargetBreakableDist = 90.0;
	// Only set MaxViewDistance on maps with limited sight (e.g. fog)
	//~bot.MaxViewDistance = 2400;
};

global InitializeRoutes = function()
{
	MapRoutes =
	{
		BUILD_footbridge =
		{
		},
		BUILD_Tank_Barrier =
		{
		},
		BUILD_Neutral_Command_Post =
		{
		},
		BUILD_balcony =
		{
		},
		PLANT_Neutral_Command_Post =
		{
		},
		PLANT_bank_wall =
		{
		},
		PLANT_footbridge =
		{
		},
		PLANT_Tank_Barrier =
		{
		},
		PLANT_balcony =
		{
		},
		FLAG_gold_crate1 =
		{
		},
		CHECKPOINT_forward_flag =
		{
		},
	};
	Util.Routes(MapRoutes);
};
