-- MEKO-HN

-- AI Ship MOD for DCS WORLD

GT = {};
GT_t.ws = 0;

set_recursive_metatable(GT, GT_t.generic_ship)

GT.visual = {}
GT.visual.shape = "MEKO_HN"
GT.visual.shape_dstr = "meko_hn_dstr"
GT.animation_arguments.alarm_state = -1;
GT.toggle_alarm_state_interval = 5.0;
GT.animation_arguments.radar1_rotation = 6;
GT.radar1_period = 3;
GT.animation_arguments.radar2_rotation = 10;
GT.radar2_period = 2;
GT.animation_arguments.radar3_rotation = 5;
GT.radar3_period = 1;

GT.animation_arguments.luna_lights = -1;
GT.animation_arguments.headlights = 1;

GT.animation_arguments.flag_animation = 11;
GT.animation_arguments.water_propeller = 30;
--GT.animation_arguments.flight_deck_fences = 150
GT.propeller_omega_max = 300.0;
GT.snd.move = "Ships/ShipMove";
GT.snd.engine = "Ships/ShipEngine";

GT.life = 1640
GT.mass = 9.59e+006;
GT.max_velocity = 15.4333
GT.race_velocity = 15.4333
GT.economy_velocity = 10.2889
GT.economy_distance = 1.1112e+007
GT.race_distance = 2.778e+006
GT.shipLength = 117.5
GT.Width = 14.8
GT.Height = 37.2
GT.Length = 117.5
GT.DeckLevel = 8
-----GT.X_nose = 75.7412
GT.X_nose = 63.0
GT.X_tail = -70
GT.Tail_Width = 15
GT.Gamma_max = 0.35
GT.Om = 0.05
GT.speedup = 0.229734
GT.R_min = 345.6
GT.distFindObstacles = 568.4

GT.numParking = 1
GT.Plane_Num_ = 0
GT.Helicopter_Num_ = 1

GT.airWeaponDist = 100000
GT.airFindDist = 150000

GT.exhaust = {
[1] = { size = 0.60 , pos = {-8.0, 17.0, 2.914 } },
[2] = { size = 0.60 , pos = {-8.0, 17.0, -3.158 } },
}

GT.Landing_Point = {-37.001, 5.489, -0.286}

GT.DM = {
	{ area_name = "HULL", 				area_arg = 82,	area_life = 70, area_fire = { pos = {9.152, 10.971, -0.0}, size = 0.4}},
	{ area_name = "COMMAND",  			area_arg = 80,	area_life = 80},
	{ area_name = "BOW",  				area_arg = 83,	area_life = 70, area_fire = { pos = {51.969, 5.120, -0.0}, size = 0.4}},
	{ area_name = "FLIGHT_DECK",  		area_arg = 82,	area_life = 70, area_fire = { pos = {-35.508, 5.120, -0.0}, size = 0.4}},
	{ area_name = "CANNON_TURRET", 		area_arg = 83,	area_life = 65},
	{ area_name = "RDR_TOWER", 			area_arg = 82,	area_life = 70},
	{ area_name = "CHIMINIES", 			area_arg = 82,	area_life = 70},
	{ area_name = "SILOS", 				area_arg = 82,	area_life = 65},
	{ area_name = "HARPOONS", 			area_arg = 77,	area_life = 65}, 
	{ area_name = "FCIWS", 				area_arg = 78,	area_life = 65}, 
	{ area_name = "BCIWS", 				area_arg = 79,	area_life = 65}, 
	{ area_name = "UPPERPARTS", 		area_arg = 80,	area_life = 80}, 
	{ area_name = "MAINRDR", 			area_arg = 82,	area_life = 70}, 
	}	

-- weapon systems
GT.WS = {}
local ws;
GT.WS.maxTargetDetectionRange = 250000;
GT.WS.radar_type = 102
GT.WS.searchRadarMaxElevation = math.rad(80);
GT.WS.searchRadarFrequencies = {{50.0e6, 54.0e6}, {2.0e9, 2.2e9}}


--VLS Launcher
ws = GT_t.inc_ws();
GT.WS[ws] = {}
set_recursive_metatable(GT.WS[ws], GT_t.WS_t.ship_MK41_SM2 )
GT.WS[ws].area = 'SILOS' 
GT.WS[ws].center = 'CENTER_SILOS'
GT.WS[ws].drawArgument2 = 48
GT.animation_arguments.alarm_state = 48;
GT.WS[ws].LN[1].depends_on_unit = AIGES_TRACKERS
GT.WS[ws].LN[1].PL[1].ammo_capacity = 32;
GT.WS[ws].LN[1].show_external_missile = false
GT.WS[ws].LN[1].BR = {
						{connector_name = 'POINT_ROCKET_1_1', recoilArgument = 193, recoilT0 = -2, recoilT1 = -1, recoilT2 = 1.0, recoilTime = 2},
						{connector_name = 'POINT_ROCKET_1_2', recoilArgument = 194, recoilT0 = -2, recoilT1 = -1, recoilT2 = 1.0, recoilTime = 2},	
						{connector_name = 'POINT_ROCKET_1_3', recoilArgument = 195, recoilT0 = -2, recoilT1 = -1, recoilT2 = 1.0, recoilTime = 2},
						{connector_name = 'POINT_ROCKET_1_4', recoilArgument = 196, recoilT0 = -2, recoilT1 = -1, recoilT2 = 1.0, recoilTime = 2},
						{connector_name = 'POINT_ROCKET_2_1', recoilArgument = 197, recoilT0 = -2, recoilT1 = -1, recoilT2 = 1.0, recoilTime = 2},
						{connector_name = 'POINT_ROCKET_2_2', recoilArgument = 198, recoilT0 = -2, recoilT1 = -1, recoilT2 = 1.0, recoilTime = 2},
						{connector_name = 'POINT_ROCKET_2_3', recoilArgument = 199, recoilT0 = -2, recoilT1 = -1, recoilT2 = 1.0, recoilTime = 2},
						{connector_name = 'POINT_ROCKET_2_4', recoilArgument = 200, recoilT0 = -2, recoilT1 = -1, recoilT2 = 1.0, recoilTime = 2},	
						{connector_name = 'POINT_ROCKET_3_1', recoilArgument = 201, recoilT0 = -2, recoilT1 = -1, recoilT2 = 1.0, recoilTime = 2},
						{connector_name = 'POINT_ROCKET_3_2', recoilArgument = 202, recoilT0 = -2, recoilT1 = -1, recoilT2 = 1.0, recoilTime = 2},	
						{connector_name = 'POINT_ROCKET_3_3', recoilArgument = 203, recoilT0 = -2, recoilT1 = -1, recoilT2 = 1.0, recoilTime = 2},
						{connector_name = 'POINT_ROCKET_3_4', recoilArgument = 204, recoilT0 = -2, recoilT1 = -1, recoilT2 = 1.0, recoilTime = 2},
						{connector_name = 'POINT_ROCKET_4_1', recoilArgument = 201, recoilT0 = -2, recoilT1 = -1, recoilT2 = 1.0, recoilTime = 2},
						{connector_name = 'POINT_ROCKET_4_2', recoilArgument = 202, recoilT0 = -2, recoilT1 = -1, recoilT2 = 1.0, recoilTime = 2},	
						{connector_name = 'POINT_ROCKET_4_3', recoilArgument = 203, recoilT0 = -2, recoilT1 = -1, recoilT2 = 1.0, recoilTime = 2},
						{connector_name = 'POINT_ROCKET_4_4', recoilArgument = 204, recoilT0 = -2, recoilT1 = -1, recoilT2 = 1.0, recoilTime = 2},
					};
					
-- ======================================================================================

-- Mark 32 Surface Vessel Torpedo Tubes

ws = GT_t.inc_ws();
GT.WS[ws] = {};
set_recursive_metatable(GT.WS[ws], GT_t.WS_t.ship_Torpedo84 );
--set_recursive_metatable(GT.WS[ws], GT_t.WS_t.ship_mk46 );
GT.WS[ws].center = 'CENTER_TOWER_MK_32_01';
GT.WS[ws].drawArgument1 = 25;
GT.WS[ws].angles = {{math.rad (180), math.rad (0), math.rad(0), math.rad(0)},}
GT.WS[ws].reference_angle_Y = math.rad(0);
GT.WS[ws].LN[1].show_external_missile = false
GT.WS[ws].LN[1].BR = {
	{connector_name = 'POINT_MK_32_01', recoilArgument = 209, recoilT0 = -1, recoilT1 = -0.5, recoilT2 = 0.5, recoilTime = 1.0 },  
	{connector_name = 'POINT_MK_32_02', recoilArgument = 209, recoilT0 = -1, recoilT1 = -0.5, recoilT2 = 0.5, recoilTime = 1.0 },  
	{connector_name = 'POINT_MK_32_03', recoilArgument = 209, recoilT0 = -1, recoilT1 = -0.5, recoilT2 = 0.5, recoilTime = 1.0 },  
}
GT.WS[ws].LN[1].customViewPoint = { "genericMissile", {-2.0, 0.75, 0.0}, }; 

-- ======================================================================================

-- Mark 32 Surface Vessel Torpedo Tubes

ws = GT_t.inc_ws();
GT.WS[ws] = {};
set_recursive_metatable(GT.WS[ws], GT_t.WS_t.ship_Torpedo84 );
--set_recursive_metatable(GT.WS[ws], GT_t.WS_t.ship_mk46 );
GT.WS[ws].center = 'CENTER_TOWER_MK_32_02';
GT.WS[ws].drawArgument1 = 28;
GT.WS[ws].angles = {{math.rad (-180), math.rad (0), math.rad(0), math.rad(0)},}
GT.WS[ws].reference_angle_Y = math.rad(0);
GT.WS[ws].LN[1].show_external_missile = false
GT.WS[ws].LN[1].BR = {
	{connector_name = 'POINT_MK_32_04', recoilArgument = 210, recoilT0 = -1, recoilT1 = -0.5, recoilT2 = 0.5, recoilTime = 1.0 }, 
	{connector_name = 'POINT_MK_32_05', recoilArgument = 210, recoilT0 = -1, recoilT1 = -0.5, recoilT2 = 0.5, recoilTime = 1.0 }, 
	{connector_name = 'POINT_MK_32_06', recoilArgument = 210, recoilT0 = -1, recoilT1 = -0.5, recoilT2 = 0.5, recoilTime = 1.0 }, 
}
GT.WS[ws].LN[1].customViewPoint = { "genericMissile", {-2.0, 0.75, 0.0}, }; 

-- ======================================================================================
					

-- CIWS 
--------------   CIWS Front -----------------------------------------------------------------------------
ws = GT_t.inc_ws();
GT.WS[ws] = {}
set_recursive_metatable(GT.WS[ws], GT_t.WS_t.phalanx )
GT.WS[ws].area = 'FCIWS'
GT.WS[ws].center = 'CENTER_TOWER_PHALANX_01'
GT.WS[ws].drawArgument1 = 17
GT.WS[ws].drawArgument2 = 18
GT.WS[ws].LN[1].ammo_capacity = 4500

GT.WS[ws].angles[1][1] = math.rad(120);
GT.WS[ws].angles[1][2] = math.rad(-120);

GT.WS[ws].LN[1].fireAnimationArgument = 119;
GT.WS[ws].LN[1].createMuzzleFlashEffect = true;

GT.WS[ws].LN[1].BR[1].connector_name =  'POINT_PHALANX_01'

--------------   CIWS Back -----------------------------------------------------------------------------
ws = GT_t.inc_ws();
GT.WS[ws] = {}
set_recursive_metatable(GT.WS[ws], GT_t.WS_t.phalanx )
GT.WS[ws].area = 'BCIWS'
GT.WS[ws].center = 'CENTER_TOWER_PHALANX_02'
GT.WS[ws].drawArgument1 = 19
GT.WS[ws].drawArgument2 = 20
GT.WS[ws].LN[1].ammo_capacity = 4500

GT.WS[ws].angles[1][1] = math.rad(-20);
GT.WS[ws].angles[1][2] = math.rad(20);
GT.WS[ws].reference_angle_Y = math.rad(-180);

GT.WS[ws].LN[1].fireAnimationArgument = 120;
GT.WS[ws].LN[1].createMuzzleFlashEffect = true;

GT.WS[ws].LN[1].BR[1].connector_name =  'POINT_PHALANX_02'

---------------------------------------------------------------------------------------------------------------------------------------------------------

-- Artillery Gun
ws = GT_t.inc_ws();
GT.WS[ws] = {}
set_recursive_metatable(GT.WS[ws], GT_t.WS_t.ship_FMC5 )
GT.WS[ws].area = 'CANNON_TURRET'
--GT.WS[ws].center = 'CENTER_TOWER_MK_45_01'
GT.WS[ws].center = 'Turret_Center_Point'
GT.WS[ws].drawArgument1 = 0
GT.WS[ws].drawArgument2 = 1

GT.WS[ws].angles = {{math.rad(170), math.rad(-170), math.rad(0), math.rad(70)},};

GT.WS[ws].LN[1].BR[1].connector_name = 'POINT_MK_45_01'
GT.WS[ws].LN[1].BR[1].recoilArgument = 33;
GT.WS[ws].LN[1].BR[1].recoilTime = 0.2;



-- Harpoon
----------------  Classe Burke: 4 tubi di lancio dei missili Harpoon----------------------------------------------------------------------------
ws = GT_t.inc_ws();
GT.WS[ws] = {}
set_recursive_metatable(GT.WS[ws], GT_t.WS_t.ship_HARPOON )
GT.WS[ws].area = 'HARPOONS';
GT.WS[ws].center = 'Rocket_Point_125'
GT.WS[ws].pos = {14.459,-0.989,9.471}

GT.WS[ws].LN[1].PL[1].ammo_capacity = 4;
GT.WS[ws].LN[1].BR = {
		{connector_name = 'Rocket_Point_123', drawArgument = 153},
		{connector_name = 'Rocket_Point_124', drawArgument = 154},
		{connector_name = 'Rocket_Point_125', drawArgument = 155},
		{connector_name = 'Rocket_Point_126', drawArgument = 156},
}
ws = GT_t.inc_ws();
GT.WS[ws] = {}
set_recursive_metatable(GT.WS[ws], GT_t.WS_t.ship_HARPOON )
GT.WS[ws].area = 'HARPOONS';
GT.WS[ws].center = 'Rocket_Point_129'
GT.WS[ws].pos = {14.459,0.68,7.65}

GT.WS[ws].LN[1].PL[1].ammo_capacity = 4;
GT.WS[ws].LN[1].BR = {
		{connector_name = 'Rocket_Point_127', drawArgument = 157},
		{connector_name = 'Rocket_Point_128', drawArgument = 158},
		{connector_name = 'Rocket_Point_129', drawArgument = 159},
		{connector_name = 'Rocket_Point_130', drawArgument = 160},
}


-- 9 AIGES trackers
ws = GT_t.inc_ws();
local first_EGES_tracker_id = ws;
GT.WS[ws] = {
	omegaY = 2,
	omegaZ = 2,
	pidY = {p=100, i=0.05, d=12, inn = 50},
	pidZ = {p=100, i=0.05, d=12, inn = 50},
	area = 'RDR',
	pos = {0.0, 19.0, 0.0},
	angles = { {math.rad(180), math.rad(-180), math.rad(-90), math.rad(80)} },
	LN = {
		[1] = {
			type = 102,
			distanceMin = 1000,
			distanceMax = 150000,
			reactionTime = 2.0,
			reflection_limit = 0.1,
			ECM_K = 0.5,
			min_trg_alt = 5,
			max_trg_alt = 30000,
			max_number_of_missiles_channels = 2
		}
	}
};
local AIGES_TRACKERS = {{{'self', ws}}}

for i=2,9 do
	ws = GT_t.inc_ws();
	GT.WS[ws] = {};
	set_recursive_metatable(GT.WS[ws], GT.WS[first_EGES_tracker_id]);
	table.insert(AIGES_TRACKERS, {{'self', ws}})
end;

------------------------------------------------------------------------------------------------------
--      Parte Finale                                                                                --
------------------------------------------------------------------------------------------------------

GT.Name = "MEKO_HN"
GT.DisplayName = _("MEKO-200HN FFG Hydra class")
GT.Rate = 2500

GT.Sensors = {  OPTIC = {"long-range naval optics", "long-range naval LLTV", "long-range naval FLIR",},
                RADAR = {
                "Patriot str",
                "perry search radar",
				"seasparrow tr",
                }
            };


			
GT.DetectionRange  = GT.airFindDist;
GT.ThreatRange = GT.airWeaponDist;

GT.Singleton   ="yes";
GT.mapclasskey = "P0091000069";
GT.attribute = {wsType_Navy,wsType_Ship,wsType_ArmedShip,PERRY,

					"Frigates",
                    "RADAR_BAND1_FOR_ARM",
					--"RADAR_BAND2_FOR_ARM",
                    "DetectionByAWACS",
					"Datalink",
				};
				
GT.Categories = {
					{name = "Armed Ship"},
					{name = "HelicopterCarrier"}
						};
						
						
--GT.tags  =
--{
--	"Frigate",
--}

GT.Countries = {"Greece"}
						
add_surface_unit(GT)	
			
			
--add_structure({
--Name = "meko_hn_destruct", --ID name
--DisplayName = _("Meko-HN200 Wreck"), --Ingame display name
--ShapeName = "Meko_HN", --Main shape name (Lods selection will be automatic)
--ShapeNameDestr = "meko_hn_destruct", --Destroyed Shape
--Life = 0, --Life
--Rate = 0, --Score when destroyed
--category = 'Ship',
--SeaObject = true,
--isPutToWater = true,
--})