-- 1) IrisT

--/N/ jan 2015

-- Headtypes
-- // тип головки самонаведения ГСН:
-- const int InfraredSeeker = 1;    // Thermal IR (infrared seeker)
-- const int ActiveRadar        = 2;    //  (active radar (AR) (+ИНС)) 
-- const int AntiRadar          = 3;    // (Passive radar +INS)
-- const int LaserHoming        = 4;    // Laser illumination (+INS)
-- const int Autopilot          = 5;    // Autonmous (INS+ Card, GPS,TV,IIR...)
-- const int SemiActiveRadar    = 6;    // semi-active radar (SAR) 
-- const int SemiAutoAT	    = 7;	// semi-automatic control with a platform for anti-tank systems , fly to woPoint, coordinates woPoint change platform.

-- Highest possible number seems to be ~25772



local wsType_IrisT = 11062


local function calcPiercingMass(warhead)
	warhead.piercing_mass = warhead.mass;
	if (warhead.expl_mass/warhead.mass > 0.1) then
		warhead.piercing_mass = warhead.mass/5.0;
	end
end

local explosivePercent = 1--0.8

function enhanced_a2a_warhead(power, caliber)
 local res = {};

	res.expl_mass = 1.7*power;
	res.mass = res.expl_mass;
	res.other_factors = {1, 1, 1};
	res.obj_factors = {1, 1};
	res.concrete_factors = {1, 1, 1};
	res.cumulative_factor = 0;
	res.concrete_obj_factor = 0.0;
	res.cumulative_thickness = 0.0;
	res.caliber = caliber;

	calcPiercingMass(res)
 return res;
end


warhead = {}
--AA MISSILES
warhead["IrisT"] =  enhanced_a2a_warhead(9.4, 127); 


-- ROCKETS
-- MISSILES



local IrisT = { 

	category		= CAT_AIR_TO_AIR,
	name			= "IrisT",
	user_name		= _("IrisT"),
	--/N/ wrong -> wsTypeOfWeapon = {4, 4, 11, WSTYPE_PLACEHOLDER},
	wsTypeOfWeapon = {wsType_Weapon,wsType_Missile,wsType_AA_Missile},
	NatoName		=	"(IrisT)",
	

	shape_table_data =
	{
		{
			name	 = "IrisT";
			file  = "Iris-T"; -- <--/N/ replace this file name with proper one
			life  = 1;
			fire  = { 0, 1};
			username = "IrisT";
			index = wsType_IrisT,
		},
	},

        Escort = 0,
        Head_Type = 1,
		sigma = {2, 2, 2},
        M = 87.4,
        H_max = 20000.0,
        H_min = -1,
        Diam = 127.0,
        Cx_pil = 1.5,
        D_max = 25000.0,
        D_min = 200.0,
        Head_Form = 0,
        Life_Time = 100.0,
        Nr_max = 140,
        v_min = 140.0,
        v_mid = 400.0,
        Mach_max = 3,
        t_b = 0.0,
        t_acc = 4.5,
        t_marsh = 0.0,
        Range_max = 35000.0,
        H_min_t = 1.0,
        Fi_start = 3.14152,
        Fi_rak = 3.14152,
        Fi_excort = 1.57,
        Fi_search = 3.14152/2,
        OmViz_max = 1.1,
        warhead = warhead["IrisT"],
		exhaust = { 0.7, 0.7, 0.7, 0.08 };
        X_back = -1.455,
        Y_back = 0.0,
        Z_back = 0.0,
        Reflection = 0.03,
        KillDistance = 7.0,
		--seeker sensivity params
		SeekerSensivityDistance = 25000, -- The range of target with IR value = 1. In meters. In forward hemisphere.
		ccm_k0 = 0.12,  -- Counter Countermeasures Probability Factor. Value = 0 - missile has absolutely resistance to countermeasures. Default = 1 (medium probability)
		SeekerCooled			= true, -- True is cooled seeker and false is not cooled seeker.				
		PN_coeffs = {
			3,
			3000,
			1,
			5000,
			0.5,
			10000,
			0.2
		},
		ModelData = {   58 ,  -- model params count
						0.35 ,   -- characteristic square (õàðàêòåðèñòè÷åñêàÿ ïëîùàäü)
						
						-- ïàðàìåòðû çàâèñèìîñòè Ñx
						0.035 , -- Cx_k0 ïëàíêà Ñx0 íà äîçâóêå ( M << 1)
						0.08 , -- Cx_k1 âûñîòà ïèêà âîëíîâîãî êðèçèñà
						0.02 , -- Cx_k2 êðóòèçíà ôðîíòà íà ïîäõîäå ê âîëíîâîìó êðèçèñó
						0.05, -- Cx_k3 ïëàíêà Cx0 íà ñâåðõçâóêå ( M >> 1)
						1.2 , -- Cx_k4 êðóòèçíà ñïàäà çà âîëíîâûì êðèçèñîì 
						1.0 , -- êîýôôèöèåíò îòâàëà ïîëÿðû (ïðîïîðöèîíàëüíî sqrt (M^2-1))
						
						-- ïàðàìåòðû çàâèñèìîñòè Cy
						0.9 , -- Cy_k0 ïëàíêà Ñy0 íà äîçâóêå ( M << 1)
						0.8	 , -- Cy_k1 ïëàíêà Cy0 íà ñâåðõçâóêå ( M >> 1)
						1.2  , -- Cy_k2 êðóòèçíà ñïàäà(ôðîíòà) çà âîëíîâûì êðèçèñîì  
						
						0.7 , -- 7 Alfa_max  ìàêñèìàëüíûé áàëàíñèðîâà÷íûé óãîë, ðàäèàíû
						10.0, --óãëîâàÿ ñêîðîñòü ñîçäàâàéìàÿ ìîìåíòîì ãàçîâûõ ðóëåé
						
					-- Engine data. Time, fuel flow, thrust.	
					--	t_statr		t_b		t_accel		t_march		t_inertial		t_break		t_end			-- Stage
						-1.0,		-1.0,	5,  		0.0,		0.0,			0.0,		1000000000,         -- time of stage, sec
						 0.0,		0.0,	5.44,		0.0,		0.0,			0.0,		0.0,           -- fuel flow rate in second, kg/sec(ñåêóíäíûé ðàñõîä ìàññû òîïëèâà êã/ñåê)
						 0.0,		0.0,	12802.0,	0.0,	0.0,			0.0,		0.0,           -- thrust, newtons
					
						1.0e9, -- temporizador de autodestrucción, seg
						60.0, -- tiempo de funcionamiento del sistema de potencia, seg.
						0, -- абсолютная высота самоликвидации, м altura absoluta de autoliquidación, m
						0.3, -- tiempo de retardo de activación del control (maniobra de salida, seguridad), seg
						1.0e9, -- alcance al objetivo en el momento del lanzamiento, cuando se excede el cual el misil realiza una maniobra de "deslizamiento", m
						1.0e9, -- rango hasta el objetivo en el que se completa la maniobra de "deslizamiento" y el misil cambia a navegación proporcional pura (debe ser mayor o igual que el parámetro anterior), m
						0.0,  -- синус угла возвышения траектории набора горки 	seno del ángulo de elevación de la trayectoria de la montaña rusa
						30.0, -- продольное ускорения взведения взрывателя aceleración longitudinal del armado del fusible
						0.0, -- модуль скорости сообщаймый катапультным устройством, вышибным зарядом и тд módulo de velocidad comunicado por dispositivo de expulsión, expulsión de carga, etc.
						1.19, -- характристика системы САУ-РАКЕТА,  коэф фильтра второго порядка K0 característica del sistema SAU-Raketa, coeficiente de filtro de segundo orden K0
						1.0, -- характристика системы САУ-РАКЕТА,  коэф фильтра второго порядка K1 característica del sistema SAU-Raketa, coeficiente de filtro de segundo orden K1
						2.0, -- характристика системы САУ-РАКЕТА,  полоса пропускания контура управления característica del sistema SAU-RAKETA, ancho de banda del lazo de control

						-- DLZ. Данные для рассчета дальностей пуска (индикация на прицеле) Datos para calcular los rangos de lanzamiento (indicación en la mira)
						14.0, 
						-15.0, 
						-2.5, 
						15200, 
						5200, 
						25000,
						9800, 
						10300, 
						3000, 
						1500, 
						0.5, 
						-0.015, 
						0.5,
					},
		
		
	
}

declare_weapon(IrisT)

declare_loadout(
	{		
		category			= CAT_AIR_TO_AIR,
		CLSID				= "{Iris-T}",
		attribute			= {wsType_Weapon, wsType_Missile, wsType_AA_Missile, wsType_IrisT},
		wsTypeOfWeapon		= IrisT.wsTypeOfWeapon,
		Count				= 1,
		Picture				= "IrisT.png",
		displayName			= IrisT.user_name.._(""), --<-- /N/  put the launcher name here if any
		Weight				= 87.4, --<--/N/ missile + launcher weight (if any), this is important since the launcher stays on  aircraft! So this weight should be higher than a missile itself!
		Cx_pil				= 0.001, --<--/N/ this is too low, you might have difficulties later to set up the human and AI FM (ignore the 21 code when it comes to weapons Cx, it is a special case) -- edited Jedi
		Elements			={
			[1]	=
			{
				Position	=	{0.0,	0.0,	0}, 
				ShapeName	=	"Iris-T", --<-- /N/  put the missile shape name here
			},
		},
	}
)

       