-- 2A18M 122mm 'D-30A'

-- Cannon
GT_t.LN_t.howitzer_2A18M = {}
GT_t.LN_t.howitzer_2A18M.type = 6
GT_t.LN_t.howitzer_2A18M.xc = 0.716
GT_t.LN_t.howitzer_2A18M.distanceMin = 30
GT_t.LN_t.howitzer_2A18M.distanceMax = 15400
GT_t.LN_t.howitzer_2A18M.max_trg_alt = 5000
GT_t.LN_t.howitzer_2A18M.reactionTimeLOFAC = 3;		-- removing the aiming delay
GT_t.LN_t.howitzer_2A18M.reactionTime = 100
GT_t.LN_t.howitzer_2A18M.maxShootingSpeed = 0
GT_t.LN_t.howitzer_2A18M.sensor = {}
set_recursive_metatable(GT_t.LN_t.howitzer_2A18M.sensor, GT_t.WSN_t[8])
GT_t.LN_t.howitzer_2A18M.PL = {}
GT_t.LN_t.howitzer_2A18M.PL[1] = {}
GT_t.LN_t.howitzer_2A18M.PL[1].ammo_capacity = 50
GT_t.LN_t.howitzer_2A18M.PL[1].shell_name = {"2A18M_3OF56_HE"};
GT_t.LN_t.howitzer_2A18M.PL[1].shot_delay = 10
GT_t.LN_t.howitzer_2A18M.PL[1].reload_time = 10*25;
GT_t.LN_t.howitzer_2A18M.PL[1].automaticLoader = false;
GT_t.LN_t.howitzer_2A18M.PL[2] = {}
GT_t.LN_t.howitzer_2A18M.PL[2].ammo_capacity = 20
GT_t.LN_t.howitzer_2A18M.PL[2].shell_name = {"2A18M_3BK6_HEAT"};
GT_t.LN_t.howitzer_2A18M.PL[2].shot_delay = 10
GT_t.LN_t.howitzer_2A18M.PL[2].reload_time = 10*25;
GT_t.LN_t.howitzer_2A18M.PL[2].automaticLoader = false
GT_t.LN_t.howitzer_2A18M.BR = { {pos = {5, 0, 0} } }

GT = {};
GT_t.ws = 0;

set_recursive_metatable(GT, GT_t.generic_stationary);
GT.armour_scheme = unarmed_armour_scheme;

set_recursive_metatable(GT.chassis, GT_t.CH_t.STATIC);
GT.chassis.life = 3.0;

GT.visual.shape = "2a18m"
GT.visual.shape_dstr = "2a18m_p_1"

-- Crew
GT.crew_locale = "RUS";
GT.crew_members = {"gunner"};

--Chassis
GT.sensor = {}
set_recursive_metatable(GT.sensor, GT_t.SN_visual)
GT.sensor.height = 1.74

--Burning after hit
GT.visual.fire_size = 0.8		-- relative burning size
GT.visual.fire_pos[1] = 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)

-- Weapon systems
GT.driverViewConnectorName = {"DRIVER_POINT", offset = {0.05, 0.03, 0.0}}
GT.driverCockpit = "DriverCockpit/DriverCockpitWithIR"

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

local ws = GT_t.inc_ws();
GT.WS[ws] = {};
GT.WS[ws].center = 'CENTER_TOWER';
GT.WS[ws].angles = {
					{math.rad(180), math.rad(-180), math.rad(-7), math.rad(70),},
					};
GT.WS[ws].drawArgument1 = 0;
GT.WS[ws].drawArgument2 = 1;
GT.WS[ws].mount_before_move = true;
GT.WS[ws].omegaY = math.rad(18);
GT.WS[ws].omegaZ = math.rad(14);
GT.WS[ws].pidY = {p=30, i=0.0, d=8, inn=2};
GT.WS[ws].pidZ = {p=30, i=0.0, d=8, inn=2};
GT.WS[ws].isoviewOffset = {0.0, 3.0, 0.0};
GT.WS[ws].pointer = 'POINT_SIGHT_01'
GT.WS[ws].cockpit = {"genericHowitzer", {0.1, 0.0, 0.0}}

--GT.WS[1].LN[1]
__LN = add_launcher(GT.WS[ws], GT_t.LN_t.howitzer_2A18M);
__LN.fireAnimationArgument = 25;
__LN.PL[1].feedSlot = 1;
__LN.PL[2].feedSlot = 2;
__LN.BR[1] = {connector_name = 'POINT_GUN',
			recoilArgument = 23,
			recoilTime = 0.3}
__LN.sightMasterMode = 1;
__LN.sightIndicationMode = 1;

__LN = nil;

GT.Name = "2A18M"
GT.DisplayName = _("Howitzer 2A18M D-30")
GT.Rate = 15

GT.Sensors = {
				OPTIC = {"TKN-3B day", "TKN-3B night",}
			}

GT.DetectionRange = 0;
GT.ThreatRangeMin = GT.WS[1].LN[1].distanceMin;
GT.ThreatRange = 15000;
GT.mapclasskey = "P0091000006";
GT.attribute = {wsType_Ground,wsType_Tank,wsType_Gun,wsType_GenericSAU,
				"Artillery",
				};
GT.category = "Artillery";
GT.Countries = { "Russia","USSR","Ukraine","Kazakhstan","Belarus","Abkhazia","South Ossetia","Georgia","Greece","India","Iran","Iraq","Oman","Pakistan","Serbia","Slovakia","Syria","Vietnam","Algeria","Aggressors"};

add_surface_unit(GT)