//==========================================================================================
//
//	uje_hells_gate.gm
//
//	Who                  	When		What
//------------------------------------------------------------------------------------------
//	maker@bigsighstudios.com	13 October 2017	Initial Script
//
//  PLANT_ancient_castle_wall =
//	{
//		CreateOnLoad = 0,
//		ExplosiveType = 1,
//		GoalType = "PLANT",
//		Position = Vec3(-128.000, -3744.000, 16.000),
//		TagName = "ancient castle wall",
//		TeamAvailability = 2,
//	},
//
//==========================================================================================
//

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

	Hell_Dyno = 0,
	Tank_Barrier_Dyno = 0,
	Tank_Barrier_1_Dyno = 0,
	ancient_castle_wall_Dyno = 0,
	tank_thru_wall = 0,

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

	//first barrier
	Tank_Barrier_1_Built = function( trigger )
	{
		if ( TestMap ) { return; }
		Util.MapDebugPrint( "Tank_Barrier_1_Built" );
	},
	Tank_Barrier_1_Planted = function( trigger )
	{
		if ( TestMap ) { return; }
		Map.Tank_Barrier_1_Dyno += 1;
		Util.MapDebugPrint( "Tank_Barrier_1_Planted" );
	},
	Tank_Barrier_1_Defused = function( trigger )
	{
		if ( TestMap ) { return; }
		Map.Tank_Barrier_1_Dyno -= 1;
		Util.MapDebugPrint( "Tank_Barrier_1_Defused" );
	},
	Tank_Barrier_1_Destroyed = function( trigger )
	{
		if ( TestMap ) { return; }
		Map.Tank_Barrier_1_Dyno = 0;
		Util.MapDebugPrint( "Tank_Barrier_1_Destroyed" );
	},

	Tank_Goes_Thru_Wall = function( trigger )
	{
		if ( TestMap ) { return; }
		Map.tank_thru_wall = 1;
		Util.EnableGoal( "PLANT_ancient_castle_wall", true );
		Util.SetGoalPosition( -231, -3725, 286, "PLANT_ancient_castle_wall" );
		Util.MapDebugPrint( "Tank_Goes_Thru_Wall" );
	},

	//second barrier
	Tank_Barrier_Built = function( trigger )
	{
		if ( TestMap ) { return; }
		Util.MapDebugPrint( "Tank_Barrier_Built" );
	},
	Tank_Barrier_Planted = function( trigger )
	{
		if ( TestMap ) { return; }
		Map.Tank_Barrier_Dyno += 1;
		Util.MapDebugPrint( "Tank_Barrier_Planted" );
	},
	Tank_Barrier_Defused = function( trigger )
	{
		if ( TestMap ) { return; }
		Map.Tank_Barrier_Dyno -= 1;
		Util.MapDebugPrint( "Tank_Barrier_Defused" );
	},
	Tank_Barrier_Destroyed = function( trigger )
	{
		if ( TestMap ) { return; }
		Map.Tank_Barrier_Dyno = 0;
		Util.MapDebugPrint( "Tank_Barrier_Destroyed" );
	},

	Hell_Built = function( trigger )
	{
		if ( TestMap ) { return; }
		Util.MapDebugPrint( "Hell_Built" );
	},
	Hell_Planted = function( trigger )
	{
		if ( TestMap ) { return; }
		Map.Hell_Dyno += 1;
		Util.MapDebugPrint( "Hell_Planted" );
	},
	Hell_Defused = function( trigger )
	{
		if ( TestMap ) { return; }
		Map.Hell_Dyno -= 1;
		Util.MapDebugPrint( "Hell_Defused" );
	},
	Hell_Destroyed = function( trigger )
	{
		if ( TestMap ) { return; }
		Map.Hell_Dyno = 0;
		Util.MapDebugPrint( "Hell_Destroyed" );
	},

	ancient_castle_wall_Planted = function( trigger )
	{
		if ( TestMap ) { return; }
		Map.ancient_castle_wall_Dyno += 1;
		Util.MapDebugPrint( "ancient_castle_wall_Planted" );
	},
	ancient_castle_wall_Defused = function( trigger )
	{
		if ( TestMap ) { return; }
		Map.ancient_castle_wall_Dyno -= 1;
		Util.MapDebugPrint( "ancient_castle_wall_Defused" );
	},
	ancient_castle_wall_Destroyed = function( trigger )
	{
		if ( TestMap ) { return; }
		Map.ancient_castle_wall_Dyno = 0;
		Util.MapDebugPrint( "ancient_castle_wall_Destroyed" );
	},

};

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

	// Register callback functions
	OnTrigger( "The Tank has been Repaired!", Map.Tank_Built );

	//first barrier
	OnTrigger( "The first tank barrier has been constructed!", Map.Tank_Barrier_1_Built );
	OnTrigger( "Planted at the Tank Barrier.", Map.Tank_Barrier_1_Planted );
	OnTrigger( "Defused at the Tank Barrier.", Map.Tank_Barrier_1_Defused );
	OnTrigger( "The first tank barrier has been destroyed!", Map.Tank_Barrier_1_Destroyed );

	//tank_thru_wall
	OnTrigger( "The tank has passed the first barrier!", Map.Tank_Goes_Thru_Wall );
	OnTrigger( "The tank has reached the ancient castle!", Map.Tank_Goes_Thru_Wall );

	//second barrier - Tank_Barrier_Built
	OnTrigger( "The second tank barrier has been constructed!", Map.Tank_Barrier_Built );
	OnTrigger( "Planted at Tank Barrier.", Map.Tank_Barrier_Planted );
	OnTrigger( "Defused at Tank Barrier.", Map.Tank_Barrier_Defused );
	OnTrigger( "The second tank barrier has been destroyed", Map.Tank_Barrier_Destroyed );

	OnTrigger( "Hell Gate has been constructed!", Map.Hell_Built );
	OnTrigger( "Planted at Hell Gate.", Map.Hell_Planted );
	OnTrigger( "Defused at the Hell Gate.", Map.Hell_Defused );
	OnTrigger( "Hell Gate has been destroyed!", Map.Hell_Destroyed );

	OnTrigger( "Planted at the ancient castle wall.", Map.ancient_castle_wall_Planted );
	OnTrigger( "Defused at the ancient castle wall.", Map.ancient_castle_wall_Defused );
	OnTrigger( "The ancient castle wall has been destroyed!", Map.ancient_castle_wall_Destroyed );


	//~Util.DisableGoal( ".*", true ); // all but routes

	SetAvailableMapGoals( TEAM.AXIS, true, "ATTACK_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_.*" );

	// Max users per goal
	Util.SetMaxUsers( 1, "ATTACK_.*" );
	Util.SetMaxUsers( 1, "DEFEND_.*" );
	Util.SetMaxUsers( 1, "GRENADE_.*" );
	Util.SetMaxUsers( 1, "SNIPE_.*" );
	Util.SetMaxUsers( 1, "MOUNTMG42_.*" );
	Util.SetMaxUsers( 1, "MOBILEMG42_.*" );
	Util.SetMaxUsers( 1, "MOBILEMORTAR_.*" );
	Util.SetMaxUsers( 1, "AIRSTRIKE_.*" );
	Util.SetMaxUsers( 1, "CALLARTILLERY_.*" );

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

	Util.DisableGoal( "PLANT_ancient_castle_wall", true ); // all but routes

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

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

global InitializeRoutes = function()
{
	MapRoutes =
	{
		BUILD_Tank =
		{
		},
		BUILD_Tank_Barrier =
		{
		},
		PLANT_Tank_Barrier =
		{
		},
		BUILD_Tank_Barrier_1 =
		{
		},
		PLANT_Tank_Barrier_1 =
		{
		},
		PLANT_ancient_castle_wall =
		{
		},
		BUILD_Hell =
		{
		},
		PLANT_Hell =
		{
		},
	};
	Util.Routes(MapRoutes);
};
