Update damage

pull/4/head
Justin Nicholson 6 years ago
parent 3dc4ba8539
commit bbba81a080

@ -28,16 +28,6 @@ var warhead_lbs = {
"AGM-84": 488.00,
"AGM-88": 146.00,
"AGM65": 200.00,
"aim-120": 44.00,
"AIM-120": 44.00,
"AIM-54": 135.00,
"aim-7": 88.00,
"AIM-7": 88.00,
"aim-9": 20.80,
"AIM-9": 20.80,
"AIM120": 44.00,
"AIM132": 22.05,
"AIM9": 20.80,
"ALARM": 450.00,
"AM39-Exocet": 364.00,
"AS-37-Martel": 330.00,
@ -47,12 +37,13 @@ var warhead_lbs = {
"FAB-250": 202.85,
"FAB-500": 564.38,
"GBU-12": 190.00,
"GBU-24": 945.00,
"GBU-31": 945.00,
"GBU12": 190.00,
"GBU16": 450.00,
"HVAR": 7.50,#P51
"KAB-500": 564.38,
"KH-25MP": 197.53,
"Kh-25MP": 197.53,
"Kh-66": 244.71,
"KN-06": 315.00,
"LAU-68": 10.00,
@ -60,40 +51,14 @@ var warhead_lbs = {
"M71": 200.00,
"M71R": 200.00,
"M90": 500.00,
"Magic-2": 27.00,
"Matra MICA": 30.00,
"Matra R550 Magic 2": 27.00,
"MATRA-R530": 55.00,
"MatraMica": 30.00,
"MatraMicaIR": 30.00,
"MatraR550Magic2": 27.00,
"Meteor": 55.00,
"MICA-EM": 30.00,
"MICA-IR": 30.00,
"MK-82": 192.00,
"MK-83": 445.00,
"MK-84": 945.00,
"OFAB-100": 92.59,
"R-13M": 16.31,
"R-27R1": 85.98,
"R-27T1": 85.98,
"R-3R": 16.31,
"R-3S": 16.31,
"R-55": 20.06,
"R-60": 6.60,
"R-60M": 7.70,
"R-73E": 16.31,
"R-77": 49.60,
"R74": 16.00,
"RB-04E": 661.00,
"RB-05A": 353.00,
"RB-15F": 440.92,
"RB-24": 20.80,
"RB-24J": 20.80,
"RB-71": 88.00,
"RB-74": 20.80,
"RB-75": 126.00,
"RB-99": 44.00,
"RN-14T": 800.00, #fictional, thermobaeric replacement for the RN-24 nuclear bomb
"RN-18T": 1200.00, #fictional, thermobaeric replacement for the RN-28 nuclear bomb
"RS-2US": 28.66,

@ -1,245 +0,0 @@
################### GLOBALS
var false = 0;
var true = 1;
var radar_update_time = 2;
var launch_update_time = 0.3;
var missile_delay_time = 0;
var ciws_delay_time = 0;
var AIR = 0;
var MARINE = 1;
var SURFACE = 2;
var ORDNANCE = 3;
var ACTIVE_MISSILE = 0;
var NUM_MISSILES = 3; # total carried minus 1
var ROUNDS = 30;
var RELOAD_TIME = 600;
################### MISSILE INFO
var missile_name = "M317";
var missile_brevity = "Grizzly";
var missile_max_distance = 31; #max distance in nm
var missile_min_distance = 2; #minimum distance in nm
var lockon_time = 12; #time in seconds it takes to lock on to a target
var launch_in_progress = 0;
################### IFF
var target = {
new: func (callsign) {
var m = { parents: [target] };
m.callsign = callsign;
m.fired = false;
return m;
},
};
var targets = {
"pinto": target.new("pinto"),
"Leto": target.new("Leto"),
"YV-187": target.new("YV-187"),
"swamp": target.new("swamp"),
"S": target.new("S"),
"G-UNTER": target.new("G-UNTER"),
"J-Mav16": target.new("J-Mav16"),
"Raider1": target.new("Raider1"),
"AF-MA13": target.new("AF-MA13"),
"KOL24M": target.new("KOL24M"),
"SNOWY1": target.new("SNOWY1"),
"Evading-target": target.new("Evading-target"),# for testing with AI targets
"Slow-evading-target": target.new("Slow-evading-target"),
};
################### MAIN LOOP
var scan = func() {
if ( getprop("/carrier/sunk") == 1 ) {
return;
}
#### ITERATE THROUGH MP LIST ####
var my_pos = geo.aircraft_position();
foreach(var mp; props.globals.getNode("/ai/models").getChildren("multiplayer")){#change to "aircraft" to shoot at scenario AI planes.
#### DO WE HAVE FIRING SOLUTION... ####
# is plane in range, do we still have missiles, and is a missile already inbound, and has it been 4 seconds since the last missile launch?
var trigger = fire_control(mp, my_pos);
#print("dist to target = " ~ dist_to_target);
#### ... FOR THE MISSILE ####
if ( launch_in_progress == 0 and trigger == true and targets[mp.getNode("callsign").getValue()].fired == false and ACTIVE_MISSILE <= NUM_MISSILES and ( systime() - missile_delay_time > 7 ) ) { #
#print("callsign " ~ cs ~ " found at " ~ dist_to_target);
missile_delay_time = systime();
targets[mp.getNode("callsign").getValue()].fired = true;
mp.getNode("unique",1).setValue(rand());
armament.contact = radar_logic.Contact.new(mp, AIR);
missile_launch(mp, systime(), my_pos);
launch_in_progress = 1;
#### ... FOR THE CIWS
# disabled
}
}
settimer(scan,radar_update_time);
}
################## FIRE CONTROL
################## ALL AI LOGIC RELATED TO FIGURING OUT IF A TARGET SHOULD BE SHOT AT SHOULD GO HERE.
var fire_control = func(mp, my_pos) {
#gather some data about the target
var ufo_pos = geo.Coord.new().set_latlon(mp.getNode("position/latitude-deg").getValue(),mp.getNode("position/longitude-deg").getValue(),(mp.getNode("position/altitude-ft").getValue() * 0.3048));
var target_distance = my_pos.direct_distance_to(ufo_pos) * .000539957; #in nautical miles
var target_heading = mp.getNode("orientation/true-heading-deg").getValue();
var target_bearing = my_pos.course_to(ufo_pos);
var relative_bearing = math.abs(ufo_pos.course_to(my_pos) - target_heading);
var target_altitude = mp.getNode("position/altitude-ft").getValue();
var target_airspeed = mp.getNode("velocities/true-airspeed-kt").getValue();
# can the radar see it?
if ( mp.getNode("valid").getValue() == false ) { return false; }
if ( radar_logic.isNotBehindTerrain(mp) == false ) { return false; }
if ( target_airspeed < 40 ) { return false; }
if ( target_altitude - props.globals.getNode("/position/altitude-ft").getValue() < 150 ) { return false; }
if ( target_altitude > 70000 ) { return false; }
if ( target_distance > missile_max_distance ) { return false; }
# is this plane a friend or foe?
if ( targets[mp.getNode("callsign").getValue()] == nil ) { return false; }
#should we shoot? using linear interpolation, with minimum probability of 0.01 to 0.10 and maximum probability of 1
var distance_probability = 1 + (0.01 - 1) * (( target_distance - missile_min_distance ) / ( missile_max_distance - missile_min_distance ));
var bearing_probability = 1 + (0.05 - 1) * (( relative_bearing ) / ( 180 ));
var altitude_probability = 1 + (0.05 - 1) * (( target_altitude - 150 ) / ( 70000 - 150 ));
var speed_probability = distance_probability / 2.5 + (1 - distance_probability / 2.5) * (( target_airspeed - 1000 ) / ( 40 - 1000 ));
var distance_weight = 0.4;
var bearing_weight = 0.3;
var altitude_weight = 0.2;
var speed_weight = 0.1;
var fire_probability = (distance_probability * distance_weight) + (bearing_probability * bearing_weight) + (altitude_probability * altitude_weight) + (speed_probability * speed_weight);
var the_dice = rand();
print("probability for " ~ mp.getNode("callsign").getValue() ~ ": "~fire_probability);
if ( fire_probability > 0.60 and fire_probability > the_dice ) {
return true;
} else {
return false;
}
}
################### MISSILE CONTROL
### missile reload
var reload = func() {
#figure out how many to add
for ( var i = 0; i <= NUM_MISSILES; i = i + 1 ) {
if (armament.AIM.new(i,missile_name,missile_brevity) != -1) {
#if statement just in case reload was called before all missiles were fired. Cause avoid calling search() on same missile twice.
armament.AIM.active[i].status = 0;
armament.AIM.active[i].search();
}
}
ACTIVE_MISSILE = 0;
print("SAM reloaded with "~(NUM_MISSILES+1)~" missiles.");
}
### missile launch
var missile_launch = func(mp, launchtime, my_pos) {
var ufo_pos = geo.Coord.new().set_latlon(mp.getNode("position/latitude-deg").getValue(),mp.getNode("position/longitude-deg").getValue(),(mp.getNode("position/altitude-ft").getValue() * 0.3048));
var target_bearing = my_pos.course_to(ufo_pos);
setprop("/orientation/heading-deg",target_bearing);
if ( armament.AIM.active[ACTIVE_MISSILE].status == 1 and systime() - launchtime > lockon_time and radar_logic.isNotBehindTerrain(mp) == true ) {
var brevity = armament.AIM.active[ACTIVE_MISSILE].brevity;
armament.AIM.active[ACTIVE_MISSILE].release();
defeatSpamFilter(brevity ~ " at: " ~ mp.getNode("callsign").getValue());
ACTIVE_MISSILE = ACTIVE_MISSILE + 1;
print("Fired "~missile_name~" #" ~ ACTIVE_MISSILE ~ " at: " ~ mp.getNode("callsign").getValue());
launch_in_progress = 0;
return;
} elsif ((systime() - launchtime) > (lockon_time*3) or radar_logic.isNotBehindTerrain(mp) == false) {
# launch cancelled so it dont forever goes in this loop and dont allow for other firings.
launch_in_progress = 0;
return;
}
settimer( func { missile_launch(mp, launchtime, my_pos); },launch_update_time);
}
### missile set launched to false for target
var incoming_listener = func {
var history = getprop("/sim/multiplay/chat-history");
var hist_vector = split("\n", history);
if (size(hist_vector) > 0) {
var last = hist_vector[size(hist_vector)-1];
var last_vector = split(":", last);
var author = last_vector[0];
var callsign = getprop("sim/multiplay/callsign");
if (size(last_vector) > 1 and author == callsign) {
var last1 = split(" ", last_vector[1]);
print(last1);
if(size(last1) > 2 and (last1[size(last1)-1] == "exploded" or last1[size(last1)-1] == "disarmed") ) {
print("missile hit");
if (size(last_vector) > 3) {
#print("that someone is me!");
var type = last1[1];
#callsign = target, type = missile
last_vector[3] = right(last_vector[3],size(last_vector[3]) - 1);
if ( targets[last_vector[3]] != nil and type == missile_name ) {
targets[last_vector[3]].fired = false;
}
}
} elsif(size(last1) > 2 and last1[size(last1)-2] == "missed" ) {
print("missile missed");
var target = last1[size(last1)-1];
var type = last1[1];
#callsign = target, type = missile
last_vector[3] = right(last_vector[3],size(last_vector[3]) - 1);
if (targets[target] != nil and type == missile_name) {
targets[target].fired = false;
}
}
}
}
}
################### MISC
var spams = 0;
var spamList = [];
var defeatSpamFilter = func (str) {
spams += 1;
if (spams == 15) {
spams = 1;
}
str = str~":";
for (var i = 1; i <= spams; i+=1) {
str = str~".";
}
var newList = [str];
for (var i = 0; i < size(spamList); i += 1) {
append(newList, spamList[i]);
}
spamList = newList;
}
var spamLoop = func {
var spam = pop(spamList);
if (spam != nil) {
setprop("/sim/multiplay/chat", spam);
}
settimer(spamLoop, 1.20);
}
spamLoop();
reload();
scan();
setlistener("/sim/multiplay/chat-history", incoming_listener, 0, 0);

File diff suppressed because it is too large Load Diff

@ -28,16 +28,6 @@ var warhead_lbs = {
"AGM-84": 488.00,
"AGM-88": 146.00,
"AGM65": 200.00,
"aim-120": 44.00,
"AIM-120": 44.00,
"AIM-54": 135.00,
"aim-7": 88.00,
"AIM-7": 88.00,
"aim-9": 20.80,
"AIM-9": 20.80,
"AIM120": 44.00,
"AIM132": 22.05,
"AIM9": 20.80,
"ALARM": 450.00,
"AM39-Exocet": 364.00,
"AS-37-Martel": 330.00,
@ -47,12 +37,13 @@ var warhead_lbs = {
"FAB-250": 202.85,
"FAB-500": 564.38,
"GBU-12": 190.00,
"GBU-24": 945.00,
"GBU-31": 945.00,
"GBU12": 190.00,
"GBU16": 450.00,
"HVAR": 7.50,#P51
"KAB-500": 564.38,
"KH-25MP": 197.53,
"Kh-25MP": 197.53,
"Kh-66": 244.71,
"KN-06": 315.00,
"LAU-68": 10.00,
@ -60,40 +51,14 @@ var warhead_lbs = {
"M71": 200.00,
"M71R": 200.00,
"M90": 500.00,
"Magic-2": 27.00,
"Matra MICA": 30.00,
"Matra R550 Magic 2": 27.00,
"MATRA-R530": 55.00,
"MatraMica": 30.00,
"MatraMicaIR": 30.00,
"MatraR550Magic2": 27.00,
"Meteor": 55.00,
"MICA-EM": 30.00,
"MICA-IR": 30.00,
"MK-82": 192.00,
"MK-83": 445.00,
"MK-84": 945.00,
"OFAB-100": 92.59,
"R-13M": 16.31,
"R-27R1": 85.98,
"R-27T1": 85.98,
"R-3R": 16.31,
"R-3S": 16.31,
"R-55": 20.06,
"R-60": 6.60,
"R-60M": 7.70,
"R-73E": 16.31,
"R-77": 49.60,
"R74": 16.00,
"RB-04E": 661.00,
"RB-05A": 353.00,
"RB-15F": 440.92,
"RB-24": 20.80,
"RB-24J": 20.80,
"RB-71": 88.00,
"RB-74": 20.80,
"RB-75": 126.00,
"RB-99": 44.00,
"RN-14T": 800.00, #fictional, thermobaeric replacement for the RN-24 nuclear bomb
"RN-18T": 1200.00, #fictional, thermobaeric replacement for the RN-28 nuclear bomb
"RS-2US": 28.66,

@ -1,209 +0,0 @@
################### GLOBALS
var false = 0;
var true = 1;
var radar_update_time = 2;
var launch_update_time = 0.3;
var missile_delay_time = 0;
var ciws_delay_time = 0;
var AIR = 0;
var MARINE = 1;
var SURFACE = 2;
var ORDNANCE = 3;
var ACTIVE_MISSILE = 0;
var NUM_MISSILES = 7;
var ROUNDS = 30;
var RELOAD_TIME = 600;
################### MISSILE INFO
var missile_name = "KN-06";
var missile_brevity = "Grumble";
var missile_max_distance = 85; #max distance in nm
var missile_min_distance = 2; #minimum distance in nm
var lockon_time = 6; #time in seconds it takes to lock on to a target
################### IFF
var target = {
new: func (callsign) {
var m = { parents: [target] };
m.callsign = callsign;
m.fired = false;
return m;
},
};
var targets = {
"pinto": target.new("pinto"),
"Leto": target.new("Leto"),
"YV-187": target.new("YV-187"),
"swamp": target.new("swamp"),
"Raider1": target.new("Raider1"),
"AF-MA13": target.new("AF-MA13"),
"KOL24M": target.new("KOL24M"),
"SNOWY1": target.new("SNOWY1"),
};
################### MAIN LOOP
var scan = func() {
if ( getprop("/carrier/sunk") == 1 ) {
return;
}
#### ITERATE THROUGH MP LIST ####
var my_pos = geo.aircraft_position();
foreach(var mp; props.globals.getNode("/ai/models").getChildren("multiplayer")){
#### DO WE HAVE FIRING SOLUTION... ####
# is plane in range, do we still have missiles, and is a missile already inbound, and has it been 4 seconds since the last missile launch?
var trigger = fire_control(mp, my_pos);
#print("dist to target = " ~ dist_to_target);
#### ... FOR THE MISSILE ####
if ( trigger == true and targets[mp.getNode("callsign").getValue()].fired == false and ACTIVE_MISSILE <= NUM_MISSILES and ( systime() - missile_delay_time > 7 ) ) { #
#print("callsign " ~ cs ~ " found at " ~ dist_to_target);
missile_delay_time = systime();
targets[mp.getNode("callsign").getValue()].fired = true;
mp.getNode("unique",1).setValue(rand());
armament.contact = radar_logic.Contact.new(mp, AIR);
missile_launch(mp, systime());
#### ... FOR THE CIWS ####
} elsif ( trigger == 2 and ROUNDS > 0 and ( systime() - ciws_delay_time > 1.0 ) ) {
hit_msg = defeatSpamFilter("Gun Splash On : " ~ mp.getNode("callsign").getValue());
print("CIWS fired | rounds remaining: " ~ ROUNDS ~ " | hit on: " ~ mp.getNode("callsign").getValue());
ciws_delay_time = systime();
ROUNDS = ROUNDS - 1;
setprop("/sim/multiplay/chat",hit_msg);
}
}
settimer(scan,radar_update_time);
}
################## FIRE CONTROL
################## ALL AI LOGIC RELATED TO FIGURING OUT IF A TARGET SHOULD BE SHOT AT SHOULD GO HERE.
var fire_control = func(mp, my_pos) {
#gather some data about the target
var ufo_pos = geo.Coord.new().set_latlon(mp.getNode("position/latitude-deg").getValue(),mp.getNode("position/longitude-deg").getValue(),(mp.getNode("position/altitude-ft").getValue() * 0.3048));
var target_distance = my_pos.direct_distance_to(ufo_pos) * .000539957; #in nautical miles
var target_heading = mp.getNode("orientation/true-heading-deg").getValue();
var target_bearing = my_pos.course_to(ufo_pos);
var relative_bearing = math.abs(ufo_pos.course_to(my_pos) - target_heading);
var target_altitude = mp.getNode("position/altitude-ft").getValue();
var target_airspeed = mp.getNode("velocities/true-airspeed-kt").getValue();
# can the radar see it?
if ( mp.getNode("valid").getValue() == false ) { return false; }
if ( radar_logic.isNotBehindTerrain(mp) == false ) { return false; }
if ( target_airspeed < 40 ) { return false; }
if ( target_altitude - props.globals.getNode("/position/altitude-ft").getValue() < 150 ) { return false; }
if ( target_altitude > 70000 ) { return false; }
if ( target_distance > missile_max_distance ) { return false; }
# is this plane a friend or foe?
if ( targets[mp.getNode("callsign").getValue()] == nil ) { return false; }
#special CIWS handling
if ( target_distance < 0.5 ) { return 2; }
#should we shoot? using linear interpolation, with minimum probability of 0.01 to 0.10 and maximum probability of 1
var distance_probability = 1 + (0.01 - 1) * (( target_distance - missile_min_distance ) / ( missile_max_distance - missile_min_distance ));
var bearing_probability = 1 + (0.05 - 1) * (( relative_bearing ) / ( 180 ));
var altitude_probability = 1 + (0.05 - 1) * (( target_altitude - 150 ) / ( 70000 - 150 ));
var speed_probability = distance_probability / 2.5 + (1 - distance_probability / 2.5) * (( target_airspeed - 1000 ) / ( 40 - 1000 ));
var distance_weight = 0.4;
var bearing_weight = 0.3;
var altitude_weight = 0.2;
var speed_weight = 0.1;
var fire_probability = (distance_probability * distance_weight) + (bearing_probability * bearing_weight) + (altitude_probability * altitude_weight) + (speed_probability * speed_weight);
var the_dice = rand();
print("probability for " ~ mp.getNode("callsign").getValue() ~ ": "~fire_probability);
if ( fire_probability > 0.60 and fire_probability > the_dice ) {
return true;
} else {
return false;
}
}
################### MISSILE CONTROL
### missile reload
var reload = func() {
#figure out how many to add
for ( var i = 0; i <= NUM_MISSILES; i = i + 1 ) {
armament.AIM.new(i,missile_name,missile_brevity);
armament.AIM.active[i].status = 0;
armament.AIM.active[i].search();
}
ACTIVE_MISSILE = 0;
}
### missile launch
var missile_launch = func(mp, launchtime) {
if ( armament.AIM.active[ACTIVE_MISSILE].status == 1 and systime() - launchtime > lockon_time and radar_logic.isNotBehindTerrain(mp) == true ) {
armament.AIM.active[ACTIVE_MISSILE].release();
setprop("/sim/multiplay/chat", defeatSpamFilter("KN-06 fired at: " ~ mp.getNode("callsign").getValue()));
ACTIVE_MISSILE = ACTIVE_MISSILE + 1;
print("Fired KN-06 #" ~ ACTIVE_MISSILE ~ " at: " ~ mp.getNode("callsign").getValue());
return;
}
settimer( func { missile_launch(mp, launchtime); },launch_update_time);
}
### missile set launched to false for target
var incoming_listener = func {
var history = getprop("/sim/multiplay/chat-history");
var hist_vector = split("\n", history);
if (size(hist_vector) > 0) {
var last = hist_vector[size(hist_vector)-1];
var last_vector = split(":", last);
var author = last_vector[0];
var callsign = getprop("sim/multiplay/callsign");
if (size(last_vector) > 1 and author == callsign) {
var last1 = split(" ", last_vector[1]);
if(size(last1) > 2 and last1[size(last1)-1] == "exploded" ) {
#print("missile hitting someone");
if (size(last_vector) > 3) {
#print("that someone is me!");
var type = last1[1];
#callsign = target, type = missile
last_vector[3] = right(last_vector[3],size(last_vector[3]) - 1);
if ( targets[last_vector[3]] != nil and type == "KN-06" ) {
targets[last_vector[3]].fired = false;
}
}
}
}
}
}
################### MISC
var spams = 1;
var defeatSpamFilter = func (str) {
spams += 1;
if (spams == 15) {
spams = 1;
}
str = str~":";
for (var i = 1; i <= spams; i+=1) {
str = str~".";
}
return str;
}
reload();
scan();
setlistener("/sim/multiplay/chat-history", incoming_listener, 0, 0);

File diff suppressed because it is too large Load Diff

@ -1,424 +0,0 @@
var clamp = func(v, min, max) { v < min ? min : v > max ? max : v }
var encode3bits = func(first, second, third) {
var integer = first;
integer = integer + 2 * second;
integer = integer + 4 * third;
return integer;
}
var AIR = 0;
var MARINE = 1;
var SURFACE = 2;
var ORDNANCE = 3;
var Contact = {
# For now only used in guided missiles, to make it compatible with Mirage 2000-5.
new: func(c, class) {
var obj = { parents : [Contact]};
#debug.benchmark("radar process1", func {
obj.rdrProp = c.getNode("radar");
obj.oriProp = c.getNode("orientation");
obj.velProp = c.getNode("velocities");
obj.posProp = c.getNode("position");
obj.heading = obj.oriProp.getNode("true-heading-deg");
#});
#debug.benchmark("radar process2", func {
obj.alt = obj.posProp.getNode("altitude-ft");
obj.lat = obj.posProp.getNode("latitude-deg");
obj.lon = obj.posProp.getNode("longitude-deg");
#});
#debug.benchmark("radar process3", func {
#As it is a geo.Coord object, we have to update lat/lon/alt ->and alt is in meters
obj.coord = geo.Coord.new();
obj.coord.set_latlon(obj.lat.getValue(), obj.lon.getValue(), obj.alt.getValue() * FT2M);
#});
#debug.benchmark("radar process4", func {
obj.pitch = obj.oriProp.getNode("pitch-deg");
obj.speed = obj.velProp.getNode("true-airspeed-kt");
obj.vSpeed = obj.velProp.getNode("vertical-speed-fps");
obj.callsign = c.getNode("callsign", 1);
obj.shorter = c.getNode("model-shorter");
obj.orig_callsign = obj.callsign.getValue();
obj.name = c.getNode("name");
obj.sign = c.getNode("sign",1);
obj.valid = c.getNode("valid");
obj.painted = c.getNode("painted");
obj.unique = c.getNode("unique");
obj.validTree = 0;
#});
#debug.benchmark("radar process5", func {
#obj.transponderID = c.getNode("instrumentation/transponder/transmitted-id");
#});
#debug.benchmark("radar process6", func {
obj.acType = c.getNode("sim/model/ac-type");
obj.type = c.getName();
obj.index = c.getIndex();
obj.string = "ai/models/" ~ obj.type ~ "[" ~ obj.index ~ "]";
obj.shortString = obj.type ~ "[" ~ obj.index ~ "]";
#});
#debug.benchmark("radar process7", func {
obj.range = obj.rdrProp.getNode("range-nm");
obj.bearing = obj.rdrProp.getNode("bearing-deg");
obj.elevation = obj.rdrProp.getNode("elevation-deg");
#});
obj.deviation = nil;
obj.node = c;
obj.class = class;
obj.polar = [0,0];
obj.cartesian = [0,0];
return obj;
},
isValid: func () {
var valid = me.valid.getValue();
if (valid == nil) {
valid = FALSE;
}
if (me.callsign.getValue() != me.orig_callsign) {
valid = FALSE;
}
return valid;
},
isPainted: func () {
if (me.painted == nil) {
me.painted = me.node.getNode("painted");
}
if (me.painted == nil) {
return nil;
}
var p = me.painted.getValue();
return p;
},
getUnique: func () {
if (me.unique == nil) {
me.unique = me.node.getNode("unique");
}
if (me.unique == nil) {
return nil;
}
var u = me.unique.getValue();
return u;
},
getElevation: func() {
var e = 0;
e = me.elevation.getValue();
if(e == nil or e == 0) {
# AI/MP has no radar properties
var self = geo.aircraft_position();
me.get_Coord();
var angleInv = clamp(self.distance_to(me.coord)/self.direct_distance_to(me.coord), -1, 1);
e = (self.alt()>me.coord.alt()?-1:1)*math.acos(angleInv)*R2D;
}
return e;
},
getNode: func () {
return me.node;
},
getFlareNode: func () {
return me.node.getNode("sim/multiplay/generic/string[10]");
},
setPolar: func(dist, angle) {
me.polar = [dist,angle];
},
setCartesian: func(x, y) {
me.cartesian = [x,y];
},
remove: func(){
if(me.validTree != 0){
me.validTree.setValue(0);
}
},
get_Coord: func(){
me.coord.set_latlon(me.lat.getValue(), me.lon.getValue(), me.alt.getValue() * FT2M);
var TgTCoord = geo.Coord.new(me.coord);
return TgTCoord;
},
get_Callsign: func(){
var n = me.callsign.getValue();
if(n != "" and n != nil) {
return n;
}
if (me.name == nil) {
me.name = me.getNode().getNode("name");
}
if (me.name == nil) {
n = "";
} else {
n = me.name.getValue();
}
if(n != "" and n != nil) {
return n;
}
n = me.sign.getValue();
if(n != "" and n != nil) {
return n;
}
return "UFO";
},
get_model: func(){
var n = "";
if (me.shorter == nil) {
me.shorter = me.node.getNode("model-shorter");
}
if (me.shorter != nil) {
n = me.shorter.getValue();
}
if(n != "" and n != nil) {
return n;
}
n = me.sign.getValue();
if(n != "" and n != nil) {
return n;
}
if (me.name == nil) {
me.name = me.getNode().getNode("name");
}
if (me.name == nil) {
n = "";
} else {
n = me.name.getValue();
}
if(n != "" and n != nil) {
return n;
}
return me.get_Callsign();
},
get_Speed: func(){
# return true airspeed
var n = me.speed.getValue();
return n;
},
get_Longitude: func(){
var n = me.lon.getValue();
return n;
},
get_Latitude: func(){
var n = me.lat.getValue();
return n;
},
get_Pitch: func(){
var n = me.pitch.getValue();
return n;
},
get_heading : func(){
var n = me.heading.getValue();
if(n == nil)
{
n = 0;
}
return n;
},
get_bearing: func(){
var n = 0;
n = me.bearing.getValue();
if(n == nil or n == 0) {
# AI/MP has no radar properties
n = me.get_bearing_from_Coord(geo.aircraft_position());
}
return n;
},
get_bearing_from_Coord: func(MyAircraftCoord){
me.get_Coord();
var myBearing = 0;
if(me.coord.is_defined()) {
myBearing = MyAircraftCoord.course_to(me.coord);
}
return myBearing;
},
get_reciprocal_bearing: func(){
return geo.normdeg(me.get_bearing() + 180);
},
get_deviation: func(true_heading_ref, coord){
me.deviation = - deviation_normdeg(true_heading_ref, me.get_bearing_from_Coord(coord));
return me.deviation;
},
get_altitude: func(){
#Return Alt in feet
return me.alt.getValue();
},
get_Elevation_from_Coord: func(MyAircraftCoord) {
me.get_Coord();
var value = (me.coord.alt() - MyAircraftCoord.alt()) / me.coord.direct_distance_to(MyAircraftCoord);
if (math.abs(value) > 1) {
# warning this else will fail if logged in as observer and see aircraft on other side of globe
return 0;
}
var myPitch = math.asin(value) * R2D;
return myPitch;
},
get_total_elevation_from_Coord: func(own_pitch, MyAircraftCoord){
var myTotalElevation = - deviation_normdeg(own_pitch, me.get_Elevation_from_Coord(MyAircraftCoord));
return myTotalElevation;
},
get_total_elevation: func(own_pitch) {
me.deviation = - deviation_normdeg(own_pitch, me.getElevation());
return me.deviation;
},
get_range: func() {
var r = 0;
if(me.range == nil or me.range.getValue() == nil or me.range.getValue() == 0) {
# AI/MP has no radar properties
me.get_Coord();
r = me.coord.direct_distance_to(geo.aircraft_position()) * M2NM;
} else {
r = me.range.getValue();
}
return r;
},
get_range_from_Coord: func(MyAircraftCoord) {
var myCoord = me.get_Coord();
var myDistance = 0;
if(myCoord.is_defined()) {
myDistance = MyAircraftCoord.direct_distance_to(myCoord) * M2NM;
}
return myDistance;
},
get_type: func () {
return me.class;
},
get_cartesian: func() {
return me.cartesian;
},
get_polar: func() {
return me.polar;
},
};
var isNotBehindTerrain = func( mp ) {
###########
var pos = mp.getNode("position");
var alt = pos.getNode("altitude-ft").getValue();
var lat = pos.getNode("latitude-deg").getValue();
var lon = pos.getNode("longitude-deg").getValue();
if(alt == nil or lat == nil or lon == nil) {
return isVisible = 0;
}
var aircraftPos = geo.Coord.new().set_latlon(lat, lon, alt*0.3048);
#################
var isVisible = 0;
var MyCoord = geo.aircraft_position();
# Because there is no terrain on earth that can be between these 2
if(MyCoord.alt() < 8900 and aircraftPos.alt() < 8900)
{
# Temporary variable
# A (our plane) coord in meters
var a = MyCoord.x();
var b = MyCoord.y();
var c = MyCoord.z();
# B (target) coord in meters
var d = aircraftPos.x();
var e = aircraftPos.y();
var f = aircraftPos.z();
var x = 0;
var y = 0;
var z = 0;
var RecalculatedL = 0;
var difa = d - a;
var difb = e - b;
var difc = f - c;
# direct Distance in meters
var myDistance = aircraftPos.direct_distance_to(MyCoord);
var Aprime = geo.Coord.new();
# Here is to limit FPS drop on very long distance
var L = 500;
if(myDistance > 50000)
{
L = myDistance / 15;
}
var step = L;
var maxLoops = int(myDistance / L);
isVisible = 1;
# This loop will make travel a point between us and the target and check if there is terrain
for(var i = 0 ; i < maxLoops ; i += 1)
{
L = i * step;
var K = (L * L) / (1 + (-1 / difa) * (-1 / difa) * (difb * difb + difc * difc));
var DELTA = (-2 * a) * (-2 * a) - 4 * (a * a - K);
if(DELTA >= 0)
{
# So 2 solutions or 0 (1 if DELTA = 0 but that 's just 2 solution in 1)
var x1 = (-(-2 * a) + math.sqrt(DELTA)) / 2;
var x2 = (-(-2 * a) - math.sqrt(DELTA)) / 2;
# So 2 y points here
var y1 = b + (x1 - a) * (difb) / (difa);
var y2 = b + (x2 - a) * (difb) / (difa);
# So 2 z points here
var z1 = c + (x1 - a) * (difc) / (difa);
var z2 = c + (x2 - a) * (difc) / (difa);
# Creation Of 2 points
var Aprime1 = geo.Coord.new();
Aprime1.set_xyz(x1, y1, z1);
var Aprime2 = geo.Coord.new();
Aprime2.set_xyz(x2, y2, z2);
# Here is where we choose the good
if(math.round((myDistance - L), 2) == math.round(Aprime1.direct_distance_to(aircraftPos), 2))
{
Aprime.set_xyz(x1, y1, z1);
}
else
{
Aprime.set_xyz(x2, y2, z2);
}
var AprimeLat = Aprime.lat();
var Aprimelon = Aprime.lon();
var AprimeTerrainAlt = geo.elevation(AprimeLat, Aprimelon);
if(AprimeTerrainAlt == nil)
{
AprimeTerrainAlt = 0;
}
if(AprimeTerrainAlt > Aprime.alt())
{
isVisible = 0;
}
}
}
}
else
{
isVisible = 1;
}
return isVisible;
}

@ -42,16 +42,6 @@ var warhead_lbs = {
"AGM-84": 488.00,
"AGM-88": 146.00,
"AGM65": 200.00,
"aim-120": 44.00,
"AIM-120": 44.00,
"AIM-54": 135.00,
"aim-7": 88.00,
"AIM-7": 88.00,
"aim-9": 20.80,
"AIM-9": 20.80,
"AIM120": 44.00,
"AIM132": 22.05,
"AIM9": 20.80,
"ALARM": 450.00,
"AM39-Exocet": 364.00,
"AS-37-Martel": 330.00,
@ -61,12 +51,13 @@ var warhead_lbs = {
"FAB-250": 202.85,
"FAB-500": 564.38,
"GBU-12": 190.00,
"GBU-24": 945.00,
"GBU-31": 945.00,
"GBU12": 190.00,
"GBU16": 450.00,
"HVAR": 7.50,#P51
"KAB-500": 564.38,
"KH-25MP": 197.53,
"Kh-25MP": 197.53,
"Kh-66": 244.71,
"KN-06": 315.00,
"LAU-68": 10.00,
@ -74,40 +65,14 @@ var warhead_lbs = {
"M71": 200.00,
"M71R": 200.00,
"M90": 500.00,
"Magic-2": 27.00,
"Matra MICA": 30.00,
"Matra R550 Magic 2": 27.00,
"MATRA-R530": 55.00,
"MatraMica": 30.00,
"MatraMicaIR": 30.00,
"MatraR550Magic2": 27.00,
"Meteor": 55.00,
"MICA-EM": 30.00,
"MICA-IR": 30.00,
"MK-82": 192.00,
"MK-83": 445.00,
"MK-84": 945.00,
"OFAB-100": 92.59,
"R-13M": 16.31,
"R-27R1": 85.98,
"R-27T1": 85.98,
"R-3R": 16.31,
"R-3S": 16.31,
"R-55": 20.06,
"R-60": 6.60,
"R-60M": 7.70,
"R-73E": 16.31,
"R-77": 49.60,
"R74": 16.00,
"RB-04E": 661.00,
"RB-05A": 353.00,
"RB-15F": 440.92,
"RB-24": 20.80,
"RB-24J": 20.80,
"RB-71": 88.00,
"RB-74": 20.80,
"RB-75": 126.00,
"RB-99": 44.00,
"RN-14T": 800.00, #fictional, thermobaeric replacement for the RN-24 nuclear bomb
"RN-18T": 1200.00, #fictional, thermobaeric replacement for the RN-28 nuclear bomb
"RS-2US": 28.66,

@ -28,16 +28,6 @@ var warhead_lbs = {
"AGM-84": 488.00,
"AGM-88": 146.00,
"AGM65": 200.00,
"aim-120": 44.00,
"AIM-120": 44.00,
"AIM-54": 135.00,
"aim-7": 88.00,
"AIM-7": 88.00,
"aim-9": 20.80,
"AIM-9": 20.80,
"AIM120": 44.00,
"AIM132": 22.05,
"AIM9": 20.80,
"ALARM": 450.00,
"AM39-Exocet": 364.00,
"AS-37-Martel": 330.00,
@ -47,12 +37,13 @@ var warhead_lbs = {
"FAB-250": 202.85,
"FAB-500": 564.38,
"GBU-12": 190.00,
"GBU-24": 945.00,
"GBU-31": 945.00,
"GBU12": 190.00,
"GBU16": 450.00,
"HVAR": 7.50,#P51
"KAB-500": 564.38,
"KH-25MP": 197.53,
"Kh-25MP": 197.53,
"Kh-66": 244.71,
"KN-06": 315.00,
"LAU-68": 10.00,
@ -60,40 +51,14 @@ var warhead_lbs = {
"M71": 200.00,
"M71R": 200.00,
"M90": 500.00,
"Magic-2": 27.00,
"Matra MICA": 30.00,
"Matra R550 Magic 2": 27.00,
"MATRA-R530": 55.00,
"MatraMica": 30.00,
"MatraMicaIR": 30.00,
"MatraR550Magic2": 27.00,
"Meteor": 55.00,
"MICA-EM": 30.00,
"MICA-IR": 30.00,
"MK-82": 192.00,
"MK-83": 445.00,
"MK-84": 945.00,
"OFAB-100": 92.59,
"R-13M": 16.31,
"R-27R1": 85.98,
"R-27T1": 85.98,
"R-3R": 16.31,
"R-3S": 16.31,
"R-55": 20.06,
"R-60": 6.60,
"R-60M": 7.70,
"R-73E": 16.31,
"R-77": 49.60,
"R74": 16.00,
"RB-04E": 661.00,
"RB-05A": 353.00,
"RB-15F": 440.92,
"RB-24": 20.80,
"RB-24J": 20.80,
"RB-71": 88.00,
"RB-74": 20.80,
"RB-75": 126.00,
"RB-99": 44.00,
"RN-14T": 800.00, #fictional, thermobaeric replacement for the RN-24 nuclear bomb
"RN-18T": 1200.00, #fictional, thermobaeric replacement for the RN-28 nuclear bomb
"RS-2US": 28.66,

@ -28,16 +28,6 @@ var warhead_lbs = {
"AGM-84": 488.00,
"AGM-88": 146.00,
"AGM65": 200.00,
"aim-120": 44.00,
"AIM-120": 44.00,
"AIM-54": 135.00,
"aim-7": 88.00,
"AIM-7": 88.00,
"aim-9": 20.80,
"AIM-9": 20.80,
"AIM120": 44.00,
"AIM132": 22.05,
"AIM9": 20.80,
"ALARM": 450.00,
"AM39-Exocet": 364.00,
"AS-37-Martel": 330.00,
@ -47,12 +37,13 @@ var warhead_lbs = {
"FAB-250": 202.85,
"FAB-500": 564.38,
"GBU-12": 190.00,
"GBU-24": 945.00,
"GBU-31": 945.00,
"GBU12": 190.00,
"GBU16": 450.00,
"HVAR": 7.50,#P51
"KAB-500": 564.38,
"KH-25MP": 197.53,
"Kh-25MP": 197.53,
"Kh-66": 244.71,
"KN-06": 315.00,
"LAU-68": 10.00,
@ -60,40 +51,14 @@ var warhead_lbs = {
"M71": 200.00,
"M71R": 200.00,
"M90": 500.00,
"Magic-2": 27.00,
"Matra MICA": 30.00,
"Matra R550 Magic 2": 27.00,
"MATRA-R530": 55.00,
"MatraMica": 30.00,
"MatraMicaIR": 30.00,
"MatraR550Magic2": 27.00,
"Meteor": 55.00,
"MICA-EM": 30.00,
"MICA-IR": 30.00,
"MK-82": 192.00,
"MK-83": 445.00,
"MK-84": 945.00,
"OFAB-100": 92.59,
"R-13M": 16.31,
"R-27R1": 85.98,
"R-27T1": 85.98,
"R-3R": 16.31,
"R-3S": 16.31,
"R-55": 20.06,
"R-60": 6.60,
"R-60M": 7.70,
"R-73E": 16.31,
"R-77": 49.60,
"R74": 16.00,
"RB-04E": 661.00,
"RB-05A": 353.00,
"RB-15F": 440.92,
"RB-24": 20.80,
"RB-24J": 20.80,
"RB-71": 88.00,
"RB-74": 20.80,
"RB-75": 126.00,
"RB-99": 44.00,
"RN-14T": 800.00, #fictional, thermobaeric replacement for the RN-24 nuclear bomb
"RN-18T": 1200.00, #fictional, thermobaeric replacement for the RN-28 nuclear bomb
"RS-2US": 28.66,

Loading…
Cancel
Save