//==========================================================================================
//
//	pier16_v3.gm
//
//	Who			When		What
//------------------------------------------------------------------------------------------
// Blindman     		12/2/09	 	draft
// MickyP			01/11/09	Removed Secret areas waypoints/script
//
//==========================================================================================
//


global Map =
{
	Navigation =
	{
		ladder =
		{
			navigate = function(_this)
			{
				_this.Bot.HoldButton(BTN.FORWARD, 2);
				sleep(2);
			},
		},
		ladder2 =
		{
			navigate = function(_this)
			{
				_this.Bot.HoldButton(BTN.FORWARD, 3);
				sleep(3);
			},
		},

		l2 =
		{
			navigate = function(_this)
			{
				_this.Bot.HoldButton(BTN.FORWARD, 3);
				sleep(3);
			},
		},

		l1 =
		{
			navigate = function(_this)
			{
				_this.Bot.HoldButton(BTN.FORWARD, 3);
				sleep(3);
			},
		},

		ladder3 =
		{
			navigate = function(_this)
			{
				_this.Bot.HoldButton(BTN.FORWARD, 3);
				sleep(3);
			},
		},

		strafe_l_point =
		{
			navigate = function(_this)
			{
				_this.Bot.HoldButton(BTN.STRAFE_L, 2);
				sleep(2);
			},
		},

		strafe_r_point =
		{
			navigate = function(_this)
			{
				_this.Bot.HoldButton(BTN.STRAFE_L, 2);
				sleep(2);
			},
		},
	},

	Switches =
	{
		door2 =
		{
			WaypointName = "door2",
			Priority = 0,
			Enabled = true,
			LimitBots = 1,
			LimitTeam = (1<<TEAM.AXIS), //only axis can use it
			AimPosition = Vector3(-1335.771,2448.125,-6.912),
		},
	},



	DontDispenseAmmo = true,
	DontDispenseHealth = true,
	DoorStatus = 0,
	Door2Status = 0,
	MainDoor = 1,
	Pillar = 1,

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

	East_Assault_Ramp_Built = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"PLANT_East_Hull",
			"PLANT_West_Hull",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_DYNAEAST.*",
			"DEFEND_DYNAWEST.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_def.*" );

		Util.MapDebugPrint("East_Assault_Ramp_Built");
	},

	West_Assault_Ramp_Built = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_def.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_DYNAEAST.*",
			"DEFEND_DYNAWEST.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"PLANT_East_Hull",
			"PLANT_West_Hull",
		});

		Util.MapDebugPrint("West_Assault_Ramp_Built");
	},

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

	Cracked_Wall_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Cracked_Wall" );

		Util.MapDebugPrint("Cracked_Wall_Destroyed");
	},

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

	East_Hull_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_DYNAEAST.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_DYNAEAST.*" );

		Util.MapDebugPrint("East_Hull_Destroyed");
	},

	Main_Warehouse_Entrance_Destroyed = function( trigger )
	{

		Map.MainDoor = 0;

		if ( Map.Pillar == 1 )
			{
			SetAvailableMapGoals( TEAM.AXIS, true, {
				"DEFEND_pillar.*",
				"DEFEND_stairs",
			});
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_ddoor.*" );

			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Tunnel_Support_Pillar" );
			SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_MAINDOOR_.*" );
			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"ATTACK_dyno.*",
				"SWITCH_door1",
			});
			Util.EnableGoal("ATTACK_DYNAPILAR1"); //enables for both teams
			}
		else
			{ return; }

		Util.MapDebugPrint("Main_Warehouse_Entrance_Destroyed");
	},

	Tunnel_Support_Pillar_Destroyed = function( trigger )
	{

		Map.Pillar = 0;
		if ( Map.MainDoor == 0 )

			{
			SetAvailableMapGoals( TEAM.AXIS, false, {
				"DEFEND_pillar.*",
				"DEFEND_stairs",
			});
			SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_dyno.*" );

			}

		else
			{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_ddoor.*" );
			SetAvailableMapGoals( TEAM.ALLIES, false, {
				"ATTACK_MAINDOOR_.*",
				"ATTACK_MAINDOOR_.*",
			});
			}

		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_def.*",
			"PLANT_East_Assault_Ramp",
			"PLANT_West_Assault_Ramp",
			"DEFEND_def1",
			"DEFEND_def2",
		});

		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"BUILD_East_Assault_Ramp",
			"BUILD_West_Assault_Ramp",
			"FLAG_generator_battery",
			"CAPPOINT_337",
			"ATTACK_DYNAEAST.*",
			"ATTACK_DYNAWEST.*",
		});
		Util.RemoveGoal( "SWITCH_door1" );
		Util.KillTeam (2);
		Util.KillTeam (1);
		Util.DisableGoal("ATTACK_DYNAPILAR1"); //disables for both teams

		Util.MapDebugPrint("Tunnel_Support_Pillar_Destroyed");
	},

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

	West_Hull_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_DYNAWEST.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_DYNAWEST.*" );

		Util.MapDebugPrint("West_Hull_Destroyed");
	},

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

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

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

	door_open = function(trigger)
	{
		if ( Map.Pillar == 0 )
			{ return; }

		vel = ToVector(trigger.Action);

		if ( vel.z < 0 )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "SWITCH_door1" );
			SetAvailableMapGoals( TEAM.ALLIES, false, "SWITCH_door1" );

			Map.DoorStatus = 1;
			Util.MapDebugPrint("Open", true);
		}
		else if ( vel.z > 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "SWITCH_door1" );
			SetAvailableMapGoals( TEAM.AXIS, false, "SWITCH_door1" );
			Map.DoorStatus = 0;
			Util.MapDebugPrint("^1Closed", true);
		}
	},

	side_open = function(trigger)
	{
		vel = ToVector(trigger.Action);

		if ( vel.y > 0 )
		{
			Map.Switches.door2.Enabled = false;
			Map.Door2Status = 1;
			Util.MapDebugPrint( "side_Open", true );
		}
		else if ( vel.y < 0 )
		{
			Map.Switches.door2.Enabled = true;
			Map.Door2Status = 0;
			Util.MapDebugPrint("^8side_Closed",true);
		}
	},
};

global OnMapLoad = function()
{
	OnTrigger( "MISSING_STRING", Map.Command_Post_Built );
	OnTrigger( "Allies have built the East Assault Ramp!", Map.East_Assault_Ramp_Built );
	OnTrigger( "Allies have built the West Assault Ramp!" , Map.West_Assault_Ramp_Built );
	OnTrigger( "MISSING_STRING", Map.Command_Post_Destroyed );
	OnTrigger( "Allies have access to the Side Warehouse Door!", Map.Cracked_Wall_Destroyed );
	OnTrigger( "Axis have destroyed the East Assault Ramp!" , Map.East_Assault_Ramp_Destroyed );
	OnTrigger( "Allies have destroyed the East Hull!", Map.East_Hull_Destroyed );
	OnTrigger( "Allies have blown up the Main Warehouse Door!", Map.Main_Warehouse_Entrance_Destroyed );
	OnTrigger( "Time limit bonus: +5 minutes", Map.Tunnel_Support_Pillar_Destroyed );
	OnTrigger( "Axis have destroyed the West Assault Ramp!", Map.West_Assault_Ramp_Destroyed );
	OnTrigger( "Allies have destroyed the West Hull!", Map.West_Hull_Destroyed );
	OnTrigger( "Allies have taken the generator battery!", Map.generator_battery_Taken );
	OnTrigger( "Allies have successfully powered the generator! Fuel Depot accessible!", Map.CAPPOINT_337_Captured );
	OnTrigger( "Planted at the Tunnel Support Pillar.", Map.pillar_plant );
	OnTrigger( "auto_door_switch_goto", Map.door_open );
	OnTrigger( "axiswall_door_right_start", Map.side_open );


	SetAvailableMapGoals( TEAM.AXIS, false, ".*" );
	SetAvailableMapGoals( TEAM.ALLIES, false, ".*" );
//	Map.Switches.door1.Enabled = true;
//	Map.Switches.door2.Enabled = true;

	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"ATTACK_MAINDOOR_.*",
		"PLANT_Main_Warehouse_Entrance",
		"PLANT_Cracked_Wall",
	});

	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_ddoor.*" );
	//SetAvailableMapGoals( TEAM.AXIS, true, "CALLARTILLERY_maindoor.*" ); //no such goals?

	Util.SetMaxUsers( 1, "DEFEND_.*" );
	Util.SetMaxUsers( 1, "SWITCH_.*" );
	Util.SetMaxUsers( 1, "FLAG_generator_battery" );
	Util.SetGoalPosition( 3465.6, 4498.4, 59.202, "PLANT_West_Assault_Ramp" ) ;

	SetMapGoalProperties( "DEFEND_.*", {MinCampTime=30, MaxCampTime=90} );
	SetMapGoalProperties( "MOUNT_.*", {MinCampTime=30, MaxCampTime=90} );
	SetMapGoalProperties( "MOBILEMG42_.*", {MinCampTime=30, MaxCampTime=90} );
	SetMapGoalProperties( "MOUNTMG42_.*", {MinCampTime=30, MaxCampTime=90} );
	SetMapGoalProperties( "ATTACK_.*", {MinCampTime=30, MaxCampTime=90} );

	Util.EnableGoal("ROUTE_.*"); //enables for both teams

	SetGoalPriority( "PLANT_West_Assault_Ramp", 0.45 , TEAM.AXIS, CLASS.ENGINEER);

	Util.UpdateSwitchData();

	Util.MapDebugPrint("OnMapLoad");
};

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