diff --git a/Aircraft/Generic/radardist.nas b/Aircraft/Generic/radardist.nas deleted file mode 100644 index e5867ca14..000000000 --- a/Aircraft/Generic/radardist.nas +++ /dev/null @@ -1,199 +0,0 @@ -### Radar Visibility Calculator - -# Jettoo (glazmax) and xiii (Alexis) - -# my_maxrange(myaircraft): finds our own aircraft max radar range in a table. -# Returns my_radarcorr in kilometers, should be called from your own aircraft -# radar stuff. - -# radis(i, my_radarcorr): find multiplayer[i], its Radar Cross Section (RCS), -# applies factor upon our altitude, shorter radar detection distance (due to air -# turbulence), then factor upon its altitude above ground, and finaly computes if -# it is detectable given our radar range. -# Returns 1 if detectable, 0 if not. Should be called from your own aircraft -# radar stuff too. - - -var data_path = getprop("/sim/fg-root") ~ "/Aircraft/Generic/radardist.xml"; -var aircraftData = {}; -var radarData = []; - -mpnode_string = nil; -var cutname = nil; -var mpnode = nil; -var mpname_node_string = nil; -var mpname_node = nil; -var mpname = nil; -var splitname = nil; -var acname = nil; -var rcs_4r = nil; -var radartype = nil; -var alt_corr = nil; -var alt_ac = nil; -var agl_corr = nil; -var mp_lon = nil; -var mp_lat = nil; -var pos_elev = nil; -var mp_agl = nil; -var det_range = nil; -var act_range = nil; -var max_range = nil; -var radar_range = nil; -var radar_area = nil; -var have_radar = nil; - - -var FT2M = 0.3048; -var NM2KM = 1.852; - - - - -var my_maxrange = func(a) { - max_range = 0; - radar_range = 0; - radar_area = 0; - acname = aircraftData[a] or 0; - if ( acname ) { - have_radar = radarData[acname][4]; - if ( have_radar != "none" and have_radar != "unknown") { - radar_area = radarData[acname][7]; - radar_range = radarData[acname][5]; - if ( radar_area > 0 ) { max_range = radar_range / radar_area } - } - } - #var plane = radarData[acname][2]; - #print ("aircraft = " ~ plane); - #print ("range = " ~ radar_range); - #print ("aera = " ~ radar_area); - return( max_range ); -} - -var get_aircraft_name = func( t ) { - # Get the multiplayer aircraft name. - mpnode_string = t; - mpnode = props.globals.getNode(mpnode_string); - if ( find("tanker", mpnode_string) > 0 ) { - #print("tanker"); - cutname = "KC135"; - } else { - mpname_node_string = mpnode_string ~ "/sim/model/path"; - mpname_node = props.globals.getNode(mpname_node_string); - #print(mpname_node_string); - if (mpname_node == nil) { return(0) } - - var mpname = mpname_node.getValue(); - if (mpname == nil) { return(0) } - - splitname = split("/", mpname); - cutname = splitname[1]; - } - return( cutname ); -} - - -var radis = func(t, my_radarcorr) { - cutname = get_aircraft_name(t); - # Calculate the rcs detection range, - # if aircraft is not found in list, 0 (generic) will be used. - acname = aircraftData[cutname]; - if ( acname == nil ) { acname = 0 } - rcs_4r = radarData[acname][3]; - radartype = radarData[acname][1]; - - # Add a correction factor for altitude, as lower alt means - # shorter radar distance (due to air turbulence). - alt_corr = 1; - alt_ac = mpnode.getNode("position/altitude-ft").getValue(); - if (alt_ac <= 1000) { - alt_corr = 0.6; - } elsif ((alt_ac > 1000) and (alt_ac <= 5000)) { - alt_corr = 0.8; - } - - # Add a correction factor for altitude AGL. - agl_corr = 1; - mp_lon = mpnode.getNode("position/longitude-deg").getValue(); - mp_lat = mpnode.getNode("position/latitude-deg").getValue(); - pos_elev = geo.elevation(mp_lat, mp_lon); - if (pos_elev != nil) { - #print("pos_elev: " ~ pos_elev); - mp_agl = alt_ac - ( pos_elev / FT2M ); - if (mp_agl <= 20) { - agl_corr = 0.03; - } elsif ((mp_agl > 20) and (mp_agl <= 50)) { - agl_corr = 0.08; - } elsif ((mp_agl > 50) and (mp_agl <= 120)) { - agl_corr = 0.25; - } elsif ((mp_agl > 120) and (mp_agl <= 300)) { - agl_corr = 0.4; - } elsif ((mp_agl > 300) and (mp_agl <= 600)) { - agl_corr = 0.7; - } elsif ((mp_agl > 600) and (mp_agl <= 1000)) { - agl_corr = 0.85; - } - } - - # Calculate the detection distance for this multiplayer. - det_range = my_radarcorr * rcs_4r * alt_corr * agl_corr / NM2KM; - #print (radartype); - #print (rcs_4r); - - ### Compare if aircraft is in detection range and return. - act_range = mpnode.getNode("radar/range-nm").getValue() or 500; - #print (det_range ~ " " ~ act_range); - if (det_range >= act_range) { - #print("paint it"); - return(1); - } - return(0); -} - - -var load_data = func { - # a) converts aircraft model name to lookup (index) number in aircraftData{}. - # b) appends ordered list of data into radarData[], - # data is: - # - acname (the index number) - # - the first (if several) aircraft model name corresponding to this type, - # - RCS(m2), - # - 4th root of RCS, - # - radar type, - # - max. radar range(km), - # - max. radar range target seize(RCS)m2, - # - 4th root of radar RCS. - var data_node = props.globals.getNode("instrumentation/radar-performance/data"); - var aircraft_types = data_node.getChildren(); - foreach( var t; aircraft_types ) { - var index = t.getIndex(); - var aircraft_names = t.getChildren(); - foreach( var n; aircraft_names) { - if ( n.getName() == "name") { - aircraftData[n.getValue()] = index; - #print(n.getValue() ~ " : " ~ index); - } - } - var t_list = [ - index, - t.getNode("name[0]").getValue(), - t.getNode("rcs-sq-meter").getValue(), - t.getNode("rcs-4th-root").getValue(), - t.getNode("radar-type").getValue(), - t.getNode("max-radar-rng-km").getValue(), - t.getNode("max-target-sq-meter").getValue(), - t.getNode("max-target-4th-root").getValue() - ]; - append(radarData, t_list); - } -} - - -var init = func { - print("Initializing Radar Data"); - io.read_properties(data_path, props.globals); - load_data(); -} - - - - diff --git a/Aircraft/Generic/radardist.xml b/Aircraft/Generic/radardist.xml deleted file mode 100644 index ad84ceff0..000000000 --- a/Aircraft/Generic/radardist.xml +++ /dev/null @@ -1,541 +0,0 @@ - - - - - - - - - - - - - - generic - 5 - 1.49 - APG-63 - 150 - 100 - 3.16 - - - 707 - 80 - 2.34 - none - 0 - 0 - 0 - - - 737-300 - 50 - 2.11 - none - 0 - 0 - 0 - - - 747 - 100 - 2.34 - none - 0 - 0 - 0 - - - 787 - 777 - 35 - 1.86 - WXR-2100 - 160 - 100 - 3.16 - - - A24-Viking - 2 - 1.19 - none - 0 - 0 - 0 - - - A-10 - 25 - 2.23 - none - 0 - 0 - 0 - - - A300 - 80 - 2.23 - none - 0 - 0 - 0 - - - A320 - 50 - 1.96 - none - 0 - 0 - 0 - - - A380 - 100 - 2.11 - none - 0 - 0 - 0 - - - a4 - 10 - 1.77 - APG-53 - 15 - 5 - 1.49 - - - A-6E - 14 - 1.93 - APQ-112 - 150 - 100 - 3.16 - - - A6M2 - 15 - 1.96 - none - 0 - 0 - 0 - - - Albatross - 40 - 2.51 - none - 0 - 0 - 0 - - - Aerostar-700 - 10 - 1.86 - none - 0 - 0 - 0 - - - Alouette-II - 15 - 2.51 - none - 0 - 0 - 0 - - - Alouette-III - 20 - 2.11 - none - 0 - 0 - 0 - - - Alphajet - 5 - 1.49 - none - 0 - 0 - 0 - - - an-2 - 2 - 1.19 - none - 0 - 0 - 0 - - - AN-225 - 100 - 2.59 - unknown - 0 - 0 - 0 - - - apache - 30 - 2.34 - APG-78 - 8 - 1 - 1 - - - ASK21 - asw20 - bocian - 1 - 1 - none - 0 - 0 - 0 - - - b1900d - 20 - 2.11 - wx500 - 60 - 100 - 3.16 - - - B-1B - 4 - 1.41 - APQ-164 - 296 - 100 - 3.16 - - - B-2 - 0.0015 - 0.19 - APQ-181 - 333 - 100 - 3.16 - - - b29 - 100 - 3.16 - APQ-19 - 45 - 100 - 3.16 - - - B-52F - 100 - 3.16 - APQ-166 - 296 - 100 - 3.16 - - - BAC-TSR2 - 15 - 1.86 - Blue Parrot - 46 - 100 - 3.16 - - - beaufighter - 9 - 1.73 - none - 0 - 0 - 0 - - - bf109 - 15 - 1.96 - none - 0 - 0 - 0 - - - Buccaneer - 10 - 1.77 - Blue Parrot - 46 - 100 - 3.16 - - - c310 - c310u3a - 4 - 1.41 - none - 0 - 0 - 0 - - - c172 - c172p - c172r - c182 - c182rg - 2 - 1.19 - none - 0 - 0 - 0 - - - dhc6 - 5 - 1.49 - none - 0 - 0 - 0 - - - E3B - 100 - 2.23 - APY-1/2 - 650 - 100 - 3.16 - - - F-86 - 9 - 1.73 - APG-37 - 50 - 100 - 3.16 - - - f104 - 9 - 1.73 - ASG-14 - 60 - 100 - 3.16 - - - f-14b - 25 - 2.23 - AWG-9 - 333 - 100 - 3.16 - - - f-14d - 25 - 2.23 - APG-71 - 380 - 100 - 3.16 - - - f-15 - f15c - 30 - 2.34 - APG-70 - 235 - 100 - 3.16 - - - f16 - 1.5 - 1.11 - APG-68 - 296 - 100 - 3.16 - - - f18 - 1.0 - 1.00 - APG-73 - 326 - 100 - 3.16 - - - f22 - 0.0010 - 0.17 - APG-77 - 410 - 100 - 3.16 - - - f35 - 0.0025 - 0.22 - APG-81 - 350 - 100 - 3.16 - - - f117 - 0.015 - 0.35 - none - 0 - 0 - 0 - - - fokker50 - 40 - 1.96 - none - 0 - 0 - 0 - - - harrier - 15 - 1.96 - APG-65 - 296 - 100 - 3.16 - - - hunter - 8 - 2 - Akco - 10 - 100 - 3.16 - - - j22 - 9 - 1.79 - none - 0 - 0 - 0 - - - KC135 - 100 - 2.43 - APN-218 - 160 - 100 - 3.16 - - - Lightning - 5 - 1.49 - AI-23 - 111 - 100 - 3.16 - - - SR71-Blackbird - 0.015 - 0.35 - APQ-108 - 200 - 100 - 3.16 - - - MiG-21 - 4 - 1.41 - RP-21 - 18 - 100 - 3.16 - - - Mig-29 - 7 - 1.63 - Sapfir - 115 - 100 - 3.16 - - - mirage2000 - 2 - 1.19 - RDY - 220 - 100 - 3.16 - - - MPCarrier - 10000 - 10 - SPS-49 - 525 - 100 - 3.16 - - - Tornado - 7 - 1.63 - Foxhunter - 210 - 100 - 3.16 - - - - - - -