// Map script by [UJE]Niek
// elevators by palota
global Map =
{
	SnipeMap = true,
	RideMovers = {},
	Movers = {},

	elevator_goto = function(trigger)
	{
		name = trigger.Name.Left(9);
		if(ToVector(trigger.Action).z > 0){
			Map[name] = 2;
			sleep(10.7);
			Map[name] = 3;
		}else{
			Map[name] = 4;
			sleep(10.8);
			if(Map[name] != 2){
				Map[name] = 1;
			}
		}
	},
};

global OnMapLoad = function()
{
	for(i=2; i<=5; i+=1)
	{
		name = "elevator" + i;
		Map[name] = 1;
		Util.AddToTable(Map.Movers, "MOVER_" + name);
		OnTrigger(name + "_goto", Map.elevator_goto);

		Map.RideMovers[name] = {
			elevatorName = name,
			movergoal = "MOVER_" + name,
			rideposition = Vec3(40.643,-2.533,28.125),
			startwp = name,
			exitwp = name + "_out",
			stance = BTN.CROUCH,
			board = function(_this)
			{
				return Map[this.elevatorName] == 1;
			},
			leave = function(_this)
			{
				return Map[this.elevatorName] == 3;
			},
		};
	}

	SetMapGoalProperties("SNIPE.*", { MinCampTime=30, MaxCamptime=50,});
	Util.LimitToTeam( TEAM.AXIS, "SNIPE_axis.*" );
	Util.LimitToTeam( TEAM.ALLIES, "SNIPE_allied.*" );
	Util.MapDebugPrint( "OnMapLoad", true );
};

global OnBotJoin = function( bot )
{
	Util.ChangeToSniperWeapons(bot);
};
