-- Soldier with TOW Closed

GT_t.LN_t.BGM71 = {}
GT_t.LN_t.BGM71.type = 33
GT_t.LN_t.BGM71.distanceMin = 65
GT_t.LN_t.BGM71.distanceMax = 3750
GT_t.LN_t.BGM71.max_trg_alt = 3000
GT_t.LN_t.BGM71.reactionTime = 10;
GT_t.LN_t.BGM71.launch_delay = 3;
GT_t.LN_t.BGM71.beamWidth = math.rad(1);
GT_t.LN_t.BGM71.radialDisperse = 2.0;
GT_t.LN_t.BGM71.dispertionReductionFactor = 0.986;
GT_t.LN_t.BGM71.missileControlInterval = 0.1;
GT_t.LN_t.BGM71.maxShootingSpeed = 0;
GT_t.LN_t.BGM71.sensor = {}
set_recursive_metatable(GT_t.LN_t.BGM71.sensor, GT_t.WSN_t[0])
GT_t.LN_t.BGM71.PL = {}
GT_t.LN_t.BGM71.PL[1] = {}
GT_t.LN_t.BGM71.PL[1].type_ammunition={4,4,11,160};
GT_t.LN_t.BGM71.PL[1].name_ammunition="TOW-2A";
GT_t.LN_t.BGM71.PL[1].automaticLoader = false;
GT_t.LN_t.BGM71.PL[1].shot_delay = 10;
GT_t.LN_t.BGM71.PL[1].ammo_capacity = 8;
GT_t.LN_t.BGM71.PL[1].reload_time = 8*20;
GT_t.LN_t.BGM71.inclination_correction_upper_limit = math.rad(45);
GT_t.LN_t.BGM71.inclination_correction_bias = math.rad(1.8);

GT = {};
GT_t.ws = 0;
set_recursive_metatable(GT, GT_t.generic_stationary);
set_recursive_metatable(GT.chassis, GT_t.CH_t.STATIC);
GT.chassis.life = 2; -- shielded

GT.visual.shape = "soldier_bgm-71_closed";
GT.visual.shape_dstr = "soldier_bgm-71_closed_dead";

GT.humanPlayable = true;

GT.sensor = {};
set_recursive_metatable(GT.sensor, GT_t.SN_visual);
GT.sensor.height = 1.207;
GT.sensor.max_range_finding_target = 4000;

--Burning after hit
GT.visual.fire_size = 0.4; --relative burning size
GT.visual.fire_pos[1] = 0;-- 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 = 500; --burning time (seconds)

GT.WS = {};
GT.WS.maxTargetDetectionRange = 4000;

-- weapon systems
local ws = GT_t.inc_ws();
GT.WS[ws] = {};
GT.WS[ws].new_rotation = false;
GT.WS[ws].pos = {0,1,0};
GT.WS[ws].angles = {
					{math.rad(180), math.rad(-180), math.rad(-20), math.rad(30)},
					};
GT.WS[ws].drawArgument1 = 0;
GT.WS[ws].drawArgument2 = 1;
GT.WS[ws].new_rotation = false;
GT.WS[ws].laser = true;
GT.WS[ws].omegaY = math.rad(60)
GT.WS[ws].omegaZ = math.rad(30)
GT.WS[ws].pidY = {p=100, i=0.5, d=8, inn = 5};
GT.WS[ws].pidZ = {p=100, i=0.5, d=8, inn = 5};
GT.WS[ws].pointer = 'POINT_SIGHT_1';

__LN = add_launcher(GT.WS[ws], GT_t.LN_t.BGM71)
__LN.BR = { {connector_name = 'POINT_ROCKET', drawArgument = 4}, }
__LN.customViewPoint = { "genericMissileAT", {-0.9, 0.15, -0.275 }, };
__LN.sightMasterMode = 1;
__LN.sightIndicationMode = 1;

GT.Name = "Infantry BGM-71 Soldier Closed";
GT.DisplayName = _("Infantry BGM-71 TOW Soldier Closed");
GT.Rate = 5;

GT.Sensors = { OPTIC = {"TAS4 TOW day", "TAS4 TOW night",
						},
			};

GT.DetectionRange = 0;
GT.ThreatRange = GT.WS[1].LN[1].distanceMax;
GT.mapclasskey = "P0091000201";
GT.attribute = {wsType_Ground,wsType_Tank,wsType_Gun,wsType_GenericFort,
				"Fortifications",
				"CustomAimPoint",
				"ATGM",
				"Datalink"
				};
GT.category = "Fortification";
GT.Countries = { "USA","UK","Denmark","Egypt","Finland","Hungary","GERMANY","GREECE","IRAN","Israel","Italy","Japan","THE_NETHERLANDS","NORWAY","PAKISTAN","Saudi Arabia","South Korea","SPAIN","SWEDEN","Switzerland","TURKEY","Aggressors"};

add_surface_unit(GT)