#include maps\mp\_utility;
#include common_scripts\utility;

main()
{
	maps\mp\mp_comeback_precache::main();
	maps\createart\mp_comeback_art::main();
	maps\mp\mp_comeback_fx::main();
	
	maps\mp\_load::main();
	maps\mp\mp_comeback_lighting::main();
	maps\mp\mp_comeback_aud::main();
	
	level.aerial_pathnode_offset = 600;
	level.aerial_pathnode_group_connect_dist = 275;
	
	maps\mp\_compass::setupMiniMap( "compass_map_mp_comeback" );
	
	game["attackers"] = "allies";
	game["defenders"] = "axis";
	
	level.mapCustomKillstreakFunc = ::comebackCustomKillstreakFunc;
	
	// OSP overrides
	level.orbitalSupportOverrideFunc = ::comebackCustomOSPFunc;
	
	
	level thread init_ceiling_fans();
	level thread init_traffic();

	//Setting killstreak overrrides	
	level.ospvisionset = "mp_comeback_osp";
	level.osplightset = "mp_comeback_osp";
	level.droneVisionSet = "mp_comeback_drone";
	level.droneLightSet = "mp_comeback_drone";
	level.warbirdVisionSet = "mp_comeback_warbird";
	level.warbirdLightSet = "mp_comeback_warbird";
	
	level.goliath_bad_landing_volumes = GetEntArray( "goliath_bad_landing_volume", "targetname" );
}

comebackCustomKillstreakFunc()
{
	level thread maps\mp\killstreaks\streak_mp_comeback::init();
}

comebackCustomOSPFunc()
{
	if(level.currentgen)
	{
		level.orbitalsupportoverrides.spawnAngleMin 	= 30;	// Default Random(360)
		level.orbitalsupportoverrides.spawnAngleMax 	= 90;	// Default Random(360)
		level.orbitalsupportoverrides.spawnHeight 		= 9541;
	
		level.orbitalsupportoverrides.leftArc		= 15;	//leftArc	= 25;
		level.orbitalsupportoverrides.rightArc		= 15;	//rightArc	= 25;
		level.orbitalsupportoverrides.topArc		= -40;	//topArc	= -25;
		level.orbitalsupportoverrides.bottomArc		= 60;	//bottomArc	= 60;

	}
}

init_ceiling_fans()
{
	ceiling_fans = GetEntArray("ceiling_fan","targetname");
	array_thread(ceiling_fans, ::ceiling_fan);
}

ceiling_fan()
{
	spin_time = 30*60; //30 minutes should be long enough so it only has to be called once per match
	degrees_per_second = RandomFloatRange(700,750);
	while(1)
	{
		self RotateVelocity( (0,degrees_per_second,0), spin_time);
		wait spin_time;
	}
}

init_traffic()
{
	anims = [];
	for(i=1; i<=7; i++)
	{
		trafficAnim  = "mp_comeback_vista_cars_0" + i;
		PrecacheMpAnim(trafficAnim);
		anims[anims.size] = trafficAnim;
	}
	
	cars = GetEntArray("traffic","targetname");
	for(i=0; i<cars.size && anims.size; i++)
	{
		cars[i] thread run_traffic( anims[i] );
	}
}

run_traffic( trafficAnim )
{
	self ScriptModelPlayAnimDeltaMotionFromPos( trafficAnim, (0,0,0), (0,0,0) );
}

