//==========================================================================================
//
//	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_.*" );

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


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