dofile("Scripts/Database/wsTypes.lua")
PlaneIndex = {iSu_27 = 1, iSu_33 = 2, iSu_25 = 3, iSu_39 = 4, iMiG_29 = 5, iMiG_29K = 6, iA_10 = 7, iF_15 = 8, iKA_50 = 9,iMI_24W = 10,iKA_52 = 11,iMI_28N = 12,iAH_64A = 13,iAH_64D = 14,iAH_1W = 15,iOH_58D = 16,iSea_Lynx = 17,iMI_8MT = 18,iMI_26 = 20,iKA_27 = 21,iCH_47D = 22,iCH_53E = 23,iSH_60B = 24,iUH_60A = 25,iSH_3H = 26,iAB_212 = 27,}

PlaneIndexByType =
{[MiG_29]  = PlaneIndex.iMiG_29,[Su_27]   = PlaneIndex.iSu_27,[Su_33]   = PlaneIndex.iSu_33,[F_15]    = PlaneIndex.iF_15,[Su_25]   = PlaneIndex.iSu_25,[A_10]    = PlaneIndex.iA_10,[MIG_29K] = PlaneIndex.iMiG_29K,
[Su_39]   = PlaneIndex.iSu_39,[MiG_29G] = PlaneIndex.iMiG_29,[MiG_29C] = PlaneIndex.iMiG_29,[Su_25T]  = PlaneIndex.iSu_39,[KA_50]   = PlaneIndex.iKA_50,[MI_24W]   = PlaneIndex.iMI_24W,[KA_52]   = PlaneIndex.iKA_52,[MI_28N]   = PlaneIndex.iMI_28N,[AH_64A]   = PlaneIndex.iAH_64A,[AH_64D]   = PlaneIndex.iAH_64D,[AH_1W]   = PlaneIndex.iAH_1W,[OH_58D]   = PlaneIndex.iOH_58D,[Sea_Lynx]   = PlaneIndex.iSea_Lynx,[MI_8MT]   = PlaneIndex.iMI_8MT,[MI_26]   = PlaneIndex.iMI_26,[KA_27]   = PlaneIndex.iKA_27,[CH_47D]   = PlaneIndex.iCH_47D,[CH_53E]   = PlaneIndex.iCH_53E,[SH_60B]   = PlaneIndex.iSH_60B,[UH_60A]   = PlaneIndex.iUH_60A,[SH_3H]   = PlaneIndex.iSH_3H,[AB_212]   = PlaneIndex.iAB_212,}

function validate(tbl,itype)
	return tbl[itype] or tbl[Su_27]
end

DisableCombatViews = false -- F5 & Ctrl-F5
ExternalObjectsLockDistance = 10000.0
ShowTargetInfo = false
CameraTerrainRestriction = true

CockpitLocalPoint = {}
------------------------ Zamena Ka-50 na dr verty s kabinoy KA-50 -------------------------

--CockpitLocalPoint[PlaneIndex.iKA_50] = {3.188, 0.39, 0.0} ------- ka-50
--CockpitLocalPoint[PlaneIndex.iKA_50] = {3.188, 0.39, 0.0} ------- ka-52
--CockpitLocalPoint[PlaneIndex.iKA_50] = {6.5, 0.10, 0.0} ------- Ch47d-chinook
--CockpitLocalPoint[PlaneIndex.iKA_50] = {4.5, 0.39, 0.0} ------- ka27--uh60--mi8
--CockpitLocalPoint[PlaneIndex.iKA_50] = {5.188, 0.39, 0.0} ----- mi-24
--CockpitLocalPoint[PlaneIndex.iKA_50] = {6.5, 0.10, 0.0} ------- ah-1w

----------------------- Zamena Ka-50 na dr verty so svoej kabinoy --------------------------

CockpitLocalPoint[PlaneIndex.iKA_50] = {3.3, 0.65, 0.0} --------- mi-24 verh - luchse
--CockpitLocalPoint[PlaneIndex.iKA_50] = {4.7, -0.07, 0.0} -------- mi-24 niz
--CockpitLocalPoint[PlaneIndex.iKA_50] = {1.25, 1.0, 0.0} --------- mi-28 verh 
--CockpitLocalPoint[PlaneIndex.iKA_50] = {2.62, 0.5, 0.0} --------- mi-28 niz
--CockpitLocalPoint[PlaneIndex.iKA_50] = {3.09, 0.39, -0.38} ------ ka-27
--CockpitLocalPoint[PlaneIndex.iKA_50] = {2.6, 0.15, -0.3} -------- ka-52
--CockpitLocalPoint[PlaneIndex.iKA_50] = {5.7, 0.38, -0.65} ------- mi-8MT mod left
--CockpitLocalPoint[PlaneIndex.iKA_50] = {5.6, 0.38, 0.65} ------- mi-8MT mod right
--CockpitLocalPoint[PlaneIndex.iKA_50] = {4.2, 0.12, -0.55} ------- mi-8 - bez 3d modeli
--CockpitLocalPoint[PlaneIndex.iKA_50] = {9.7, -1.75, -0.4} ------- mi-26 - Net kabiny

--CockpitLocalPoint[PlaneIndex.iKA_50] = {2.96, 0.0, 0.0} ---------- ah-64a niz
--CockpitLocalPoint[PlaneIndex.iKA_50] = {1.4, 0.46, 0.0} ---------- ah-64a verh
--CockpitLocalPoint[PlaneIndex.iKA_50] = {2.96, 0.0, 0.0} ---------- ah-64d niz
--CockpitLocalPoint[PlaneIndex.iKA_50] = {1.35, 0.43, 0.0} ---------- ah-64d verh
--CockpitLocalPoint[PlaneIndex.iKA_50] = {2.15, 0.24, 0.0} ------------ ah-1w verh
--CockpitLocalPoint[PlaneIndex.iKA_50] = {3.3, 0.04, 0.0} ---------- ah-1w niz
--CockpitLocalPoint[PlaneIndex.iKA_50] = {3.38, -0.08, 0.0} ---------- AH-1G niz
--CockpitLocalPoint[PlaneIndex.iKA_50] = {0.75, 0.38, -0.25} -------- OH-58D
--CockpitLocalPoint[PlaneIndex.iKA_50] = {2.3, 0.45, -0.55} --------- uh-1h
--CockpitLocalPoint[PlaneIndex.iKA_50] = {6.2, 0.08, -0.6} ---------- ch-47d
--CockpitLocalPoint[PlaneIndex.iKA_50] = {2.43, 0.16, -0.68} -------- uh-60a
--CockpitLocalPoint[PlaneIndex.iKA_50] = {3.99, 0.95, -0.65} -------- sh-3h - Net kabiny
--CockpitLocalPoint[PlaneIndex.iKA_50] = {2.99, 0.55, -0.2} --------- sh-60b - Net kabiny

--CockpitLocalPoint[PlaneIndex.iKA_50] = {4.2, 1.0, 0.0} ------- harrier

----------------------- MOD verty neletaby svoya kabina --[[ --]] ---------------

CockpitLocalPoint[PlaneIndex.iKA_50] = {3.6, 0.39, 0.0}
CockpitLocalPoint[PlaneIndex.iMI_24W] = {3.3, 0.65, 0.0} --------- mi-24 verh - luchse
CockpitLocalPoint[PlaneIndex.iMI_24W] = {4.7, -0.07, 0.0} -------- mi-24 niz
CockpitLocalPoint[PlaneIndex.iKA_52] = {2.6, 0.15, -0.3}
--CockpitLocalPoint[PlaneIndex.iMI_28N] = {1.25, 1.0, 0.0} ------- mi-28 verh 
CockpitLocalPoint[PlaneIndex.iMI_28N] = {2.8, 0.47, 0.0} --------- mi-28 niz
--CockpitLocalPoint[PlaneIndex.iAH_64A] = {1.35, 0.43, 0.0} ------- ah-64a verh
CockpitLocalPoint[PlaneIndex.iAH_64A] = {2.93, -0.1, 0.0} --------- ah-64a niz - luchse
--CockpitLocalPoint[PlaneIndex.iAH_64D] = {1.35, 0.43, 0.0} ------- ah-64d verh
CockpitLocalPoint[PlaneIndex.iAH_64D] = {2.93, -0.1, 0.0} --------- ah-64a niz - luchse
CockpitLocalPoint[PlaneIndex.iAH_1W] = {3.5, -0.07, 0.0}
CockpitLocalPoint[PlaneIndex.iOH_58D] = {0.75, 0.38, -0.25}
CockpitLocalPoint[PlaneIndex.iSea_Lynx] = {3.188, 0.39, 0.0}
CockpitLocalPoint[PlaneIndex.iMI_8MT] = {5.6, 0.38, -0.65} ----------- mi-8-mod
--CockpitLocalPoint[PlaneIndex.iMI_8MT] = {7.5, 0.2, 0.0}
CockpitLocalPoint[PlaneIndex.iMI_26] = {9.8, -1.85, -0.4}
CockpitLocalPoint[PlaneIndex.iKA_27] = {3.03, 0.29, -0.38}
CockpitLocalPoint[PlaneIndex.iCH_47D] = {6.2, 0.08, -0.6}
CockpitLocalPoint[PlaneIndex.iCH_53E] = {4.5, 0.3, -0.5}
CockpitLocalPoint[PlaneIndex.iSH_60B] = {2.9, 0.3, -0.5}
CockpitLocalPoint[PlaneIndex.iUH_60A] = {2.43, 0.16, -0.68}
CockpitLocalPoint[PlaneIndex.iSH_3H] = {3.188, 0.39, 0.0}
CockpitLocalPoint[PlaneIndex.iAB_212] = {2.3, 0.45, -0.55} ------------ uh-1h

----------------------- MOD verty neletaby kabina KA-50 --[[ --]] ---------------

--[[
--CockpitLocalPoint[PlaneIndex.iKA_50] = {3.188, 0.39, 0.0}
CockpitLocalPoint[PlaneIndex.iMI_24W] = {5.188, 0.39, 0.0}
CockpitLocalPoint[PlaneIndex.iKA_52] = {3.188, 0.39, 0.0}
CockpitLocalPoint[PlaneIndex.iMI_28N] = {3.188, 0.39, 0.0}
CockpitLocalPoint[PlaneIndex.iAH_64A] = {3.188, 0.39, 0.0}
CockpitLocalPoint[PlaneIndex.iAH_64D] = {3.188, 0.39, 0.0}
CockpitLocalPoint[PlaneIndex.iAH_1W] = {3.188, 0.39, 0.0}
CockpitLocalPoint[PlaneIndex.iOH_58D] = {3.188, 0.39, 0.0}
CockpitLocalPoint[PlaneIndex.iSea_Lynx] = {3.188, 0.39, 0.0}
CockpitLocalPoint[PlaneIndex.iMI_8MT] = {7.5, 0.2, 0.0}
CockpitLocalPoint[PlaneIndex.iMI_26] = {6.0, 0.39, 0.0}
CockpitLocalPoint[PlaneIndex.iKA_27] = {4.5, 0.39, 0.0}
CockpitLocalPoint[PlaneIndex.iCH_47D] = {6.5, 0.10, 0.0}
CockpitLocalPoint[PlaneIndex.iCH_53E] = {5.4, 0.39, 0.0}
CockpitLocalPoint[PlaneIndex.iSH_60B] = {3.188, 0.39, 0.0}
CockpitLocalPoint[PlaneIndex.iUH_60A] = {3.188, 0.39, 0.0}
CockpitLocalPoint[PlaneIndex.iSH_3H] = {3.188, 0.39, 0.0}
CockpitLocalPoint[PlaneIndex.iAB_212] = {3.188, 0.39, 0.0} --]]

----------------------------------------------------------------------
CockpitLocalPoint[PlaneIndex.iSu_27] = {8.15, 1.38, 0.0}
CockpitLocalPoint[PlaneIndex.iSu_33] = {8.35, 1.35, 0.0}
CockpitLocalPoint[PlaneIndex.iSu_25] = {3.5 , 0.4 , 0.0}
CockpitLocalPoint[PlaneIndex.iSu_39] = {3.406, 0.466, 0.0}
CockpitLocalPoint[PlaneIndex.iMiG_29] = {4.92, 1.35, 0.0}
CockpitLocalPoint[PlaneIndex.iMiG_29K] = {4.9, 1.254, 0.0}
CockpitLocalPoint[PlaneIndex.iA_10] = {3.991, 1.55, 0.0}
CockpitLocalPoint[PlaneIndex.iF_15] = {6.5, 1.238, 0.0}

EyePoint = {}
EyePoint[PlaneIndex.iSu_27] = {0,0,0}
EyePoint[PlaneIndex.iSu_33] = {0,0,0}
EyePoint[PlaneIndex.iSu_25] = {0,0,0}
EyePoint[PlaneIndex.iSu_39] = {0,0,0}
EyePoint[PlaneIndex.iMiG_29] = {0,0,0}
EyePoint[PlaneIndex.iMiG_29K] = {0,0,0}
EyePoint[PlaneIndex.iA_10] = {0,0,0}
EyePoint[PlaneIndex.iF_15] = {0,0,0}
EyePoint[PlaneIndex.iKA_50] = {0.09, 0, 0}

--local old_aircrafts_6DOF  = {x = {-2,2},y = {-2,2},z = {-2,2},roll = 90.0} -- {x = {0,0},y = {0,0},z = {0,0},roll = 0}
local old_aircrafts_6DOF  = {x = {-0.02,0.05},y = {-0.03,0.03},z = {-0.03,0.03},roll = 90.0}

limits_6DOF = {}
limits_6DOF[PlaneIndex.iSu_27]   = old_aircrafts_6DOF
limits_6DOF[PlaneIndex.iSu_33]   = old_aircrafts_6DOF
limits_6DOF[PlaneIndex.iSu_25]   = old_aircrafts_6DOF
limits_6DOF[PlaneIndex.iSu_39]   = old_aircrafts_6DOF
limits_6DOF[PlaneIndex.iMiG_29]  = old_aircrafts_6DOF
limits_6DOF[PlaneIndex.iMiG_29K] = old_aircrafts_6DOF
limits_6DOF[PlaneIndex.iA_10]    = old_aircrafts_6DOF
limits_6DOF[PlaneIndex.iF_15]    = old_aircrafts_6DOF
limits_6DOF[PlaneIndex.iKA_50]   = {x = {-0.02,0.35},y = {-0.15,0.21},z = {-0.26,0.26},roll = 90.0}

function GetCockpitLocalPoint(iType)
	local p = CockpitLocalPoint[iType]
	return p[1], p[2], p[3]
end

function GetEyePoint(iType)
	local p = EyePoint[iType]
	return p[1], p[2], p[3]
end

function Get_6DOF_limits(iType)
	local p = limits_6DOF[iType]
	return p.x[1],
		   p.x[2],
		   p.y[1],
		   p.y[2],
		   p.z[1],
		   p.z[2],
		   p.roll
end

function SetCockpitLocalPoint(iType, x, y, z)
	local p = CockpitLocalPoint[iType]
	p[1] = x
	p[2] = y
	p[3] = z
end

-- Camera angle limits {horizontal angle max, vertical angle min, vertical angle max}
CameraAngleLimits = {}
CameraAngleLimits[PlaneIndex.iSu_27] = {140.0, -75.0, 90.0}
CameraAngleLimits[PlaneIndex.iSu_33] = {140.0, -75.0, 90.0}
CameraAngleLimits[PlaneIndex.iSu_25] = {95.0, -65.0, 90.0}
CameraAngleLimits[PlaneIndex.iSu_39] = {110.0, -80.0, 90.0}
CameraAngleLimits[PlaneIndex.iMiG_29] = {140.0, -75.0, 90.0}
CameraAngleLimits[PlaneIndex.iMiG_29K] = {140.0, -65.0, 90.0}
CameraAngleLimits[PlaneIndex.iA_10] = {140.0, -65.0, 90.0}
CameraAngleLimits[PlaneIndex.iF_15] = {140.0, -80.0, 90.0}
CameraAngleLimits[PlaneIndex.iKA_50] ={140.0, -65.0, 90.0}

CameraAngleRestriction = {}
CameraAngleRestriction[PlaneIndex.iSu_27] =  {1,60,0.4}
CameraAngleRestriction[PlaneIndex.iSu_33] =  {1,60,0.4}
CameraAngleRestriction[PlaneIndex.iSu_25] =  {1,60,0.4}
CameraAngleRestriction[PlaneIndex.iSu_39] =  {1,60,0.4}
CameraAngleRestriction[PlaneIndex.iMiG_29] = {1,60,0.4}
CameraAngleRestriction[PlaneIndex.iMiG_29K] ={1,60,0.4}
CameraAngleRestriction[PlaneIndex.iA_10]  =  {1,90,0.5}
CameraAngleRestriction[PlaneIndex.iF_15]  =  {1,60,0.4}
CameraAngleRestriction[PlaneIndex.iKA_50] =  {0,60,0.4}

function GetCameraAngleLimits(iType)
	local p = CameraAngleLimits[iType]
	return p[1], p[2], p[3]
end




function GetCameraAngleRestriction(iType)
	local p = CameraAngleRestriction[iType]
	return  p[1], p[2], p[3]
end 



function SetCameraAngleLimits(iType, hAngMax, vAngMin, vAngMax)
	local p = CameraAngleLimits[iType]
	p[1] = hAngMax
	p[2] = vAngMin
	p[3] = vAngMax
end

-- Following values will not be saved in tracks in the current version!
hAngleRearDefault =  180
vAngleRearDefault = -8.0
vAngleRearMin     = -90 -- -8.0
vAngleRearMax     = 90.0



RearCameraPos = {}
RearCameraAnglesDefault = {}

for i = PlaneIndex.iSu_27,PlaneIndex.iKA_50 do
    local cockpit_point = CockpitLocalPoint[i]
    RearCameraAnglesDefault[i] =  {180,-8.0} 
    RearCameraPos[i]           =  {cockpit_point[1] - 3.7 ,cockpit_point[2] + 2.4, cockpit_point[3]}
end

ArcadeCameraPos = {}
ArcadeCameraAnglesDefault = {}

for i = PlaneIndex.iSu_27,PlaneIndex.iKA_50 do  
    local cockpit_point = CockpitLocalPoint[i]
    ArcadeCameraAnglesDefault[i] =  {0  ,-8.0}
    ArcadeCameraPos[i]           =  {cockpit_point[1] - 20  ,cockpit_point[2] + 5  , cockpit_point[3] + 0}  
end


function GetRearCameraPosition(iType)
	local  p = RearCameraPos[iType]
	return p[1], p[2], p[3]
end

function GetRearCameraAnglesDefault(iType)
    local p = RearCameraAnglesDefault[iType]
    if p == nil then    return hAngleRearDefault , vAngleRearDefault
    else                return p[1], p[2]    end
end


function GetArcadeCameraPosition(iType)
	local  p = ArcadeCameraPos[iType]
	return p[1], p[2], p[3]
end

function GetArcadeCameraAnglesDefault(iType)
    local p = ArcadeCameraAnglesDefault[iType]
    if p == nil then    return hAngleRearDefault , vAngleRearDefault
    else                return p[1], p[2]    end
end

-- LSO local position on the carrier: {x, y, z, rot_Y, rot_Z)
-- Note: tracks can't save modified LSO local positions in the current version!
LSOPosition = {}
LSOPosition["Vinson"] = {88.0, 28.0, 31.0, 0.0, 0.0} 
LSOPosition["Kouznetsov"] = {81.236, 24.0, 28.497, 10.0, 0.0} 

function GetLSOPosition(iType)
	local p = LSOPosition[iType]
	return p[1], p[2], p[3], p[4], p[5]
end




dbg_shell    = "weapons.shells.GSH23_23"
dbg_shell_v0 = -1
