//==========================================================================================
//
//	antarctic_base.gm
//
//	Who	When		What
//------------------------------------------------------------------------------------------
//	palota	28 January 2019	Initial Script
//
//==========================================================================================
//

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

	Navigation =
	{
		elevator_top =
		{
			navigate = function( _this )
			{
				if (GetEntPosition(Map.elevatorEnt).z < 550)
				{
					_this.Goto(_this.Bot.GetPosition());
					dowhile(GetEntPosition(Map.elevatorEnt).z < 550) {
						yield();
					}
				}
			},
		},
		elevator_bottom =
		{
			navigate = function( _this )
			{
				_this.Goto(_this.Bot.GetPosition());
				_this.AddAimRequest(Priority.High, "facing", Vec3(-0.957, -0.268, 0.111));
				while(GetEntPosition(Map.elevatorEnt).z > 210)
				{
					_this.Bot.PressButton(BTN.USE);
					sleep(0.1);
				}
				_this.Goto(Vec3(3877.701, -6930.416, 355.445));
				sleep(2.3);
			},
		},
	},

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

};

global OnMapLoad = function()
{
	// Register callback functions
	OnTrigger( "Allied Command Post constructed. Charge speed increased!", Map.Allied_Command_Post_Built );
	OnTrigger( "Allied Team have built the ramp!", Map.Assault_Ramp_Built );
	OnTrigger( "Axis Command Post constructed. Charge speed increased!", Map.Axis_Command_Post_Built );
	OnTrigger( "The tank has been repaired!", Map.Tank_Built );
	OnTrigger( "The Tank Barrier has been constructed.", Map.Tank_Barrier_Built );
	OnTrigger( "Axis team has destroyed the Allied Command Post!", Map.Allied_Command_Post_Destroyed );
	OnTrigger( "Axis have destroyed the ramp!", Map.Assault_Ramp_Destroyed );
	OnTrigger( "Allied team has destroyed the Axis Command Post!", Map.Axis_Command_Post_Destroyed );
	OnTrigger( "The Allies blew up the ufo!", Map.Axis_Ufo_Destroyed );
	OnTrigger( "The Tank Barrier has been destroyed.", Map.Tank_Barrier_Destroyed );
	OnTrigger( "MISSING_STRING", Map.forward_flag1_Axis_Captured );
	OnTrigger( "Allies have captured the Forward Flag!", Map.forward_flag1_Allies_Captured );
	OnTrigger( "MISSING_STRING", Map.forward_flag2_Axis_Captured );
	OnTrigger( "MISSING_STRING", Map.forward_flag2_Allies_Captured );
	OnTrigger( "Axis have captured the Forward Flag!", Map.forward_flag3_Axis_Captured );
	OnTrigger( "MISSING_STRING", Map.forward_flag3_Allies_Captured );
	OnTrigger( "Allied team has destroyed the Main Gate!", Map.MainGate_Destroyed );

	tr = TraceLine( Vec3(4005, -6940, 396), Vec3(3817, -6929, 405), null, TRACE.SHOT, 0, false );
	Map.elevatorEnt = tr.entity;

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

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

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


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

global OnBotJoin = function( bot )
{
	// Uncomment for shootable breakables
	//~bot.TargetBreakableDist = 90.0;
};

global InitializeRoutes = function()
{
	MapRoutes =
	{
		BUILD_Tank =
		{
		},
		BUILD_Tank_Barrier =
		{
		},
		PLANT_Tank_Barrier =
		{
		},
		PLANT_Axis_Ufo =
		{
		},
		BUILD_Axis_Command_Post =
		{
		},
		PLANT_Axis_Command_Post =
		{
		},
		BUILD_Allied_Command_Post =
		{
		},
		PLANT_Allied_Command_Post =
		{
		},
		CHECKPOINT_forward_flag1 =
		{
		},
		CHECKPOINT_forward_flag2 =
		{
		},
		CHECKPOINT_forward_flag3 =
		{
		},
		BUILD_Assault_Ramp =
		{
		},
		PLANT_Assault_Ramp =
		{
		},
	};
	Util.Routes(MapRoutes);
};
