-- Weapons for Type 055 Destroyer by Currenthill

-- =============================== CJ-10 ship-launched cruise missile ==========================================

local Type055_CJ10_warhead = {
    mass                 = 500, 
    caliber              = 500,
    expl_mass            = 500, 
    piercing_mass        = 500, 
    other_factors        = { 1.0, 1.0, 1.0 },
    concrete_factors     = { 2.0, 1.0, 1.0 },
    concrete_obj_factor  = 2.0,
    obj_factors          = { 2.0, 1.0 },
    cumulative_factor    = 2.0,
    cumulative_thickness = 0.0,
}

local TYPE_055_CJ_10 = {
	category		= CAT_MISSILES,
	name			= "TYPE055_CJ10",
	user_name	 	= _("CJ-10 Cruise Missile"),
	mass			= 850,
	model			= 'Type055_CJ-10',
	wsTypeOfWeapon  = {wsType_Weapon,wsType_Missile,wsType_AS_Missile,WSTYPE_PLACEHOLDER},
	Escort 			= 0,
	Head_Type 		= 5,  
	sigma 			= {10, 10, 10},
	M 				= 850.0,   
	H_max 			= 15000.0,  
	H_min 			= -1,  
	Diam 			= 500.0,
	Cx_pil 			= 1,   
	D_max 			= 800000.0, 
	D_min 			= 2000.0,
	Head_Form 		= 1, 
	Life_Time 		= 3600.0,   
	Nr_max 			= 6,  
	v_min 			= 170.0,
	v_mid 			= 450.0,  
	Mach_max 		= 1.3,  
	t_b 			= 0.0,
	t_acc 			= 4.0, 
	t_marsh         = 1800.0,  
	Range_max 		= 800000.0, 
	H_min_t 		= 0.0,
	Fi_start 		= 3.14152,
    Fi_rak 			= 3.14152,
    Fi_excort 		= 3.14152,
    Fi_search 		= 99.9,
    OmViz_max 		= 99.9,	
	exhaust1 		= { 1, 1, 1, 1 },
	X_back 			= -7.2,  
	Y_back 			= 0.0, 
	Z_back 			= 0.0, 
	Reflection 		= 0.15, 
	KillDistance 	= 0.0, 
	add_attributes = {"Cruise missiles"},	

	warhead	= Type055_CJ10_warhead,
	warhead_air = Type055_CJ10_warhead,
	
	shape_table_data = 
	{
		{

			name	 = "TYPE055_CJ10";
			file  	 = "Type055_CJ-10";   		
			life  	 = 1;
			fire  	 = { 0, 1};
			username = _("CJ-10 Cruise Missile");
			index = WSTYPE_PLACEHOLDER;
		},
	},
	
    class_name      = "wAmmunitionCruise",
    scheme          = "cruise_missile_vert_start_booster_drop",

	boost = {
		Cx 								= 0.9,
		I 								= 100,
		L 								= 0.3,
		Ma 								= 0.5,
		Mw 								= 0.1,
		boost_factor 					= 0,
		boost_time 						= 0,
		caliber 						= 0.5,
		custom_smoke_dissipation_factor = 0.5,
		fuel_mass 						= 247.5,
		impulse 						= 160,
		impulse_sigma 					= 1,
		mass 							= 50,
		model_name					 	= "",
		moment_sigma 					= 1000000,
		nozzle_orientationXYZ 			= { { 0, 0, 0 } },
		nozzle_position 				= { { -8.2, 0, 0 } },
		smoke_color 					= { 1, 1, 1 },
		smoke_transparency 				= 0.5,
		start_impulse 					= 0,
		tail_width 						= 1.4,
		wind_sigma 						= 0,
		work_time 						= 7
	},
	
	booster_animation = {
		start_val = 1
	},
	
	control_block = {
		can_update_target_pos 			= 0,
		default_cruise_height 			= 50,
		obj_sensor 						= 1,
		seeker_activation_dist 			= 12000,
		turn_before_point_reach 		= 1,
		turn_hor_N 						= 0.8,
		turn_max_calc_angle_deg 		= 90,
		turn_point_trigger_dist 		= 100
	},
	
	controller = {
		boost_start = 0,
		march_start = 8
	},
	
	cruise_autopilot = {
		Kd_eng 							= 0,
		Kd_hor 							= 0,
		Kd_ver 							= 0.02,
		Kd_ver_st1 						= 0.015,
		Kd_ver_st2 						= 5e-05,
		Ki_eng 							= 0.005,
		Kii_ver 						= 0.3,
		Kp_eng 							= 200,
		Kp_hor_err 						= 240,
		Kp_hor_err_croll 				= 0.08,
		Kp_ver 							= 8,
		Kp_ver_st1 						= 0.009,
		Kp_ver_st2 						= 0.00018,
		alg_calc_time 					= 1.5,
		alg_div_k 						= 2,
		alg_max_sin_climb 				= 0.7,
		alg_points_num 					= 7,
		alg_section_temp_points 		= 3,
		alg_tmp_point_vel_k 			= 1.5,
		alg_vel_k 						= 6,
		auto_terrain_following 			= 1,
		auto_terrain_following_height 	= 50,
		delay 							= 1,
		eng_max_thrust 					= 3000,
		eng_min_thrust 					= -100,
		estimated_N_max 				= 12,
		finsLimit 						= 0.8,
		max_roll 						= 0.7,
		max_start_y_vel 				= 30,
		no_alg_vel_k 					= 10,
		stab_vel 						= 272,
	},
	
	final_autopilot = {
		J_Angle_K 				= 0.23,
		J_Angle_W 				= 0.4,
		J_Diff_K 				= 0.1,
		J_FinAngle_K 			= 0.38,
		J_Int_K 				= 0.001,
		J_Power_K 				= 1.2,
		K 						= 240,
		Kg 						= 6,
		Ki 						= 0.001,
		delay 					= 0,
		finsLimit 				= 0.4,
		hKd 					= 0.005,
		hKp_err 				= 100,
		hKp_err_croll 			= 0.04,
		max_roll 				= 0.7,
		useJumpByDefault 		= 1
	},
	
	fm = {
		A 				= 0.08,
		I 				= 3000,
		L 				= 5.56,
		Ma 				= 2,
		Ma_x			= 2,
		Mw 				= 4,
		Mw_x			= 3,
		Sw 				= 1.2,
		addDeplSw 		= 1,
		caliber 		= 0.52,
		cx_coeff 		= { 1, 0.3, 0.65, 0.018, 1.6 },
		dCydA 			= { 0.07, 0.036 },
		finsTau 		= 0.2,
		mass 			= 1440,
		maxAoa 			= 0.3,
		wind_sigma 		= 0,
		wind_time 		= 0,
		wingsDeplDelay 	= 20
	},
	
	march = {
		fuel_mass 		= 100,
		impulse 		= 5080,
		max_thrust 		= 1900,
		min_fuel_rate 	= 0.005,
		min_thrust 		= -100,
		thrust_Tau 		= 0.0017,
		work_time 		= 9999
	},
	
	play_booster_animation = {
		val = 0
	},

	seeker = {
		coalition 			= 2,
		coalition_rnd_coeff = 5
	},
	
	start_autopilot = {
		K 				= 6.4,
		Kd 				= 90,
		delay 			= 0.5,
		finsLimit 		= 60,
		opTime 			= 20,
		rK 				= 0.02,
		rKd	 			= 0.0001,
		rollCtrlDelay 	= 15
	},
}

declare_weapon(TYPE_055_CJ_10)

GT_t.WS_t.Type055_CJ10 = {} 
GT_t.WS_t.Type055_CJ10.angles = {
					{math.rad(180), math.rad(-180), math.rad(-90), math.rad(90)},
					};
GT_t.WS_t.Type055_CJ10.moveable = false
GT_t.WS_t.Type055_CJ10.LN = {}
GT_t.WS_t.Type055_CJ10.LN[1] = {}
GT_t.WS_t.Type055_CJ10.LN[1].type = 8
GT_t.WS_t.Type055_CJ10.LN[1].distanceMin = 4500
GT_t.WS_t.Type055_CJ10.LN[1].distanceMax = 800000
GT_t.WS_t.Type055_CJ10.LN[1].reactionTime = 1;
GT_t.WS_t.Type055_CJ10.LN[1].launch_delay = 1;
GT_t.WS_t.Type055_CJ10.LN[1].max_number_of_missiles_channels = 4
GT_t.WS_t.Type055_CJ10.LN[1].sensor = {}
set_recursive_metatable(GT_t.WS_t.Type055_CJ10.LN[1].sensor, GT_t.WSN_t[0])
GT_t.WS_t.Type055_CJ10.LN[1].external_tracking_awacs = true
GT_t.WS_t.Type055_CJ10.LN[1].show_external_missile = true
GT_t.WS_t.Type055_CJ10.LN[1].PL = {}
GT_t.WS_t.Type055_CJ10.LN[1].PL[1] = {}
GT_t.WS_t.Type055_CJ10.LN[1].PL[1].ammo_capacity = 16
GT_t.WS_t.Type055_CJ10.LN[1].PL[1].type_ammunition = TYPE_055_CJ_10.wsTypeOfWeapon
GT_t.WS_t.Type055_CJ10.LN[1].PL[1].reload_time = 1000000; 
GT_t.WS_t.Type055_CJ10.LN[1].PL[1].shot_delay = 0.1;
GT_t.WS_t.Type055_CJ10.LN[1].BR = { {pos = {0, 0, 0} } }
