--RM-70 GRAD

--ADD_ROCKETS
local JROF122 = {
	category  		= CAT_ROCKETS,
	name      		= "122JROF",
	model     		= "122JROF",
	user_name 		= _("122JROF"),
	wsTypeOfWeapon 	= {wsType_Weapon, wsType_NURS, wsType_Rocket, WSTYPE_PLACEHOLDER},
	scheme			= "nurs-standard",
	fm = 
	{
		mass        = 46.25 + 20.1, 
		caliber     = 0.122,    
		cx_coeff    = {1,0.66,0.49,0.2,1.53},
		L           = 2.881,
		I           = 39.00209,
		Ma          = 0.50851,
		Mw          = 3.28844,  
		wind_time   = 1.1,-- dispersion coefficient
		wind_sigma  = 7,
		shapeName   = "122JROF",
	},
	engine = 
	{
		fuel_mass   = 20.5,
		impulse     = 200,
		boost_time  = 0,
		work_time   = 1.0,
		boost_factor= 1,
		nozzle_position =  { {-1.598, 0, 0} },
		nozzle_orientationXYZ =  {{0, 0, 0}},
		tail_width  = 0.52,
		boost_tail  = 0,
		work_tail   = 1,
    smoke_color = {0.9, 0.9, 0.9},
    smoke_transparency = 0.5,
	},
	warhead = 
	{
		mass					= 0.52,
		expl_mass        		= 0.52,
 		other_factors 			= {1.0, 1.0, 1.0};
		concrete_factors	 	= {1.0, 1.0, 1.0};
		obj_factors      		= { 0.25, 1.0 },
		cumulative_factor 		= 1;
		concrete_obj_factor 	= 1.0;
		cumulative_thickness 	= 0.3;
		piercing_mass  			= 0.52/5.0;
		caliber     			= 55;
    cumulative_thickness = 0.0,
    },
	shape_table_data = 
	{
		{
			name     = "122JROF",
			file     = "122JROF",
			life     = 1,
			fire     = {0, 1},
			username = "122JROF",
			index    = WSTYPE_PLACEHOLDER,
		},
	},
	properties = 
	{
		dist_min = 1200,   -- min range, meters
		dist_max = 4000,  -- max range, meters
	}
}
declare_weapon(JROF122)
--------------------------------------------------------------------------------
--launcher

GT = {};
GT_t.ws = 0;
set_recursive_metatable(GT, GT_t.generic_wheel_vehicle);
set_recursive_metatable(GT.chassis, GT_t.CH_t.URAL375);

GT.visual.shape = "RM-70";
GT.visual.shape_dstr = "RM-70_DM";

--chassis
GT.swing_on_run = false;

GT.sensor = {};
set_recursive_metatable(GT.sensor, GT_t.SN_visual);
GT.sensor.height = 2.85;

--Burning after hit
GT.visual.fire_size = 0.7; --relative burning size
GT.visual.fire_pos[1] = 1; -- center of burn at long axis shift(meters)
GT.visual.fire_pos[2] = 0;-- center of burn shift at vertical shift(meters)
GT.visual.fire_pos[3] = 0; -- center of burn at transverse axis shift(meters)
GT.visual.fire_time = 900; --burning time (seconds)
GT.animation_arguments.crew_presence = 50;

GT.driverViewConnectorName = "DRIVER_POINT"

-- weapon systems

GT.WS = {};
GT.WS.fire_on_march = false;
GT.WS.maxTargetDetectionRange = 5000;

--machinegun_7_62

local ws = GT_t.inc_ws();
GT.WS[ws] = {};
GT.WS[ws].center = 'CENTER_MGUN';
GT.WS[ws].angles = {  {math.rad(150), math.rad(-165), math.rad(-8), math.rad(25)},     };                   
GT.WS[ws].drawArgument1 = 25;
GT.WS[ws].drawArgument2 = 26;
GT.WS[ws].pidY = {p=100, i=0.1, d=10, inn=10};
GT.WS[ws].pidZ = {p=100, i=0.1, d=10, inn=10};
GT.WS[ws].omegaY = math.rad(120);
GT.WS[ws].omegaZ = math.rad(120);
GT.WS[ws].cockpit = { "IronSight/IronSight", {-1.1, 0.18, 0 }, };
--GT.WS[1].LN[2]
__LN = add_launcher(GT.WS[ws], GT_t.LN_t.machinegun_7_62);
__LN.PL[1].ammo_capacity = 300;
__LN.switch_on_delay = 12;
__LN.BR[1].connector_name = 'POINT_MGUN';
__LN.fireAnimationArgument = 44;
__LN.sightMasterMode = 1

local ws = GT_t.inc_ws();
GT.WS[ws] = {};
GT.WS[ws].center = 'CENTER_TOWER';
GT.WS[ws].angles_mech = {
                    {math.rad(102), math.rad(-70), math.rad(0), math.rad(55)},
                    };
GT.WS[ws].angles = {
                    {math.rad(102), math.rad(45), math.rad(0), math.rad(55)},
                    {math.rad(45), math.rad(-45), math.rad(15), math.rad(55)},
                    {math.rad(-45), math.rad(-70), math.rad(0), math.rad(55)},
                    };
GT.WS[ws].drawArgument1 = 0;
GT.WS[ws].drawArgument2 = 1;
GT.WS[ws].omegaY = math.rad(7);
GT.WS[ws].omegaZ = math.rad(5);
GT.WS[ws].pidY = {p = 10, i = 0.0, d = 7, inn = 1};
GT.WS[ws].pidZ = {p = 10, i = 0.0, d = 7, inn = 1};
--GT.WS[ws].mount_before_move = true;

GT.WS[ws].LN = {};
GT.WS[ws].LN[1] = {};
GT.WS[ws].LN[1].type = 34;
GT.WS[ws].LN[1].maxShootingSpeed = 0;
GT.WS[ws].LN[1].out_velocity = 450;
GT.WS[ws].LN[1].distanceMin = 5000;
GT.WS[ws].LN[1].distanceMax = 19000;
GT.WS[ws].LN[1].reactionTimeLOFAC = 3;
GT.WS[ws].LN[1].reactionTime = 100;
GT.WS[ws].LN[1].launch_delay = 0.5;
GT.WS[ws].LN[1].show_external_missile = true
GT.WS[ws].LN[1].sensor = {};
set_recursive_metatable(GT.WS[ws].LN[1].sensor, GT_t.WSN_t[8]);
GT.WS[ws].LN[1].depends_on_unit = {{{"Grad_FDDM", 1}}, {{"none"}}}

GT.WS[ws].LN[1].PL = {};
GT.WS[ws].LN[1].PL[1] = {};
GT.WS[ws].LN[1].PL[1].ammo_capacity = 40;
GT.WS[ws].LN[1].PL[1].type_ammunition = JROF122.wsTypeOfWeapon
GT.WS[ws].LN[1].PL[1].name_ammunition = JROF122.shape_table_data.username
GT.WS[ws].LN[1].PL[1].reload_time = 420;
GT.WS[ws].LN[1].PL[1].shot_delay = 0.01;


GT.WS[ws].LN[1].BR = { 
{ connector_name = "ROCKET_01"},
{ connector_name = "ROCKET_006"},
{ connector_name = "ROCKET_010"},
{ connector_name = "ROCKET_005"},
{ connector_name = "ROCKET_011"},
{ connector_name = "ROCKET_016"},
{ connector_name = "ROCKET_020"},
{ connector_name = "ROCKET_015"},
{ connector_name = "ROCKET_002"}, 
{ connector_name = "ROCKET_007"},
{ connector_name = "ROCKET_009"},
{ connector_name = "ROCKET_004"},
{ connector_name = "ROCKET_012"},
{ connector_name = "ROCKET_017"},
{ connector_name = "ROCKET_019"},
{ connector_name = "ROCKET_014"},
{ connector_name = "ROCKET_003"},
{ connector_name = "ROCKET_008"},
{ connector_name = "ROCKET_013"},
{ connector_name = "ROCKET_018"},
{ connector_name = "ROCKET_021"},
{ connector_name = "ROCKET_026"},
{ connector_name = "ROCKET_030"},
{ connector_name = "ROCKET_025"},
{ connector_name = "ROCKET_031"},
{ connector_name = "ROCKET_036"},
{ connector_name = "ROCKET_040"},
{ connector_name = "ROCKET_035"},
{ connector_name = "ROCKET_022"},
{ connector_name = "ROCKET_027"},
{ connector_name = "ROCKET_029"},
{ connector_name = "ROCKET_024"},
{ connector_name = "ROCKET_032"},
{ connector_name = "ROCKET_037"},
{ connector_name = "ROCKET_039"},
{ connector_name = "ROCKET_034"},
{ connector_name = "ROCKET_023"},
{ connector_name = "ROCKET_028"},
{ connector_name = "ROCKET_033"},
{ connector_name = "ROCKET_038"},
};


GT.WS[ws].LN[1].customViewPoint = { "genericMLRS", {-3.0, 0.3, -0.8 }, };

GT.Name = "RM-70 GRAD";
GT.Aliases = {"RM-70 GRAD"}
GT.DisplayName = _("RM-70 GRAD");
GT.Rate = 10;

GT.DetectionRange  = 0;
GT.ThreatRangeMin = GT.WS[1].LN[1].distanceMin;
GT.ThreatRange = 19000;
GT.mapclasskey = "P0091000208";      --"P0091000209";
GT.attribute = {wsType_Ground,wsType_Tank,wsType_MissGun,wsType_GenericMLRS,
                "MLRS",
                };
GT.category = "Artillery";


        
GT.Countries = { "Czech Republic","Slovakia","Poland","Germany","Finland","Greece","Georgia", };        
--------------------------------------------------------------------------------

        
add_surface_unit(GT)
