mirror of
https://github.com/l0k1/oprf_assets.git
synced 2024-11-01 07:41:15 +08:00
Update damage, missile-code and fire-control in shooting SAMs.
This commit is contained in:
parent
a1dde8d694
commit
68746eb0c0
@ -27,8 +27,6 @@ var mlw_max=getprop("payload/d-config/mlw_max"); #
|
||||
var auto_flare_caller = getprop("payload/d-config/auto_flare_caller"); # If damage.nas should detect flare releases, or if function is called from somewhere in aircraft
|
||||
############################################################################################################################
|
||||
|
||||
var TRUE = 1;
|
||||
var FALSE = 0;
|
||||
|
||||
var hp = hp_max;
|
||||
setprop("sam/damage", math.max(0,100*hp/hp_max));#used in HUD
|
||||
@ -164,7 +162,9 @@ var warheads = {
|
||||
"pilot": [93, 0.00,1,0],# ejected pilot
|
||||
"BETAB-500ShP": [94, 1160.00,1,0],
|
||||
"Flare": [95, 0.00,0,0],
|
||||
"3M9": [96, 125.00,0,0],# 3M9 Missile used with 2K12/SA-6
|
||||
"3M9": [96, 125.00,0,0],# 3M9M3 Missile used with 2K12/SA-6
|
||||
"5V28V": [97, 478.00,0,0],# Missile used with S-200D/SA-5
|
||||
"AIM-9X": [98, 20.80,0,0],
|
||||
};
|
||||
|
||||
var AIR_RADAR = "air";
|
||||
@ -189,7 +189,8 @@ var radar_signatures = {
|
||||
"E-8R": AIR_RADAR,
|
||||
"EC-137D": AIR_RADAR,
|
||||
"Mig-28": AIR_RADAR,
|
||||
"SA-6": AIR_RADAR,#Air radar tone chosen so that there is at least some lock tone until asset-specific is created
|
||||
"SA-6": "gnd-06",#Air radar tone chosen so that there is at least some lock tone until asset-specific is created
|
||||
"s-200": "gnd-05",
|
||||
"ZSU-23-4M": "gnd-23",
|
||||
"S-75": "gnd-02",
|
||||
"buk-m2": "gnd-11",
|
||||
@ -203,7 +204,7 @@ var radar_signatures = {
|
||||
var id2warhead = [];
|
||||
var launched = {};# callsign: elapsed-sec
|
||||
var approached = {};# callsign: uniqueID
|
||||
var heavy_smoke = [61,62,63,65,92,96];
|
||||
var heavy_smoke = [61,62,63,65,92,96,97];
|
||||
|
||||
var k = keys(warheads);
|
||||
|
||||
@ -241,6 +242,10 @@ for(var myid = 0;myid<size(k);myid+=1) {
|
||||
}
|
||||
}
|
||||
|
||||
var crater_model0 = getprop("payload/armament/models") ~ "crater_small.xml";
|
||||
var crater_model1 = getprop("payload/armament/models") ~ "crater_big.xml";
|
||||
var crater_model2 = getprop("payload/armament/models") ~ "bomb_hit_smoke.xml";
|
||||
|
||||
#==================================================================
|
||||
# Notification processing
|
||||
#==================================================================
|
||||
@ -281,6 +286,7 @@ var DamageRecipient =
|
||||
# " Flags=",notification.Flags,
|
||||
# " Radar=",bits.test(notification.Flags, 0),
|
||||
# " Thrust=",bits.test(notification.Flags, 1));
|
||||
# " CWI=",bits.test(notification.Flags, 2));
|
||||
#
|
||||
# todo:
|
||||
# animate missiles
|
||||
@ -301,6 +307,7 @@ var DamageRecipient =
|
||||
var bearing = ownPos.course_to(notification.Position);
|
||||
var radarOn = bits.test(notification.Flags, 0);
|
||||
var thrustOn = bits.test(notification.Flags, 1);
|
||||
var CWIOn = bits.test(notification.Flags, 2);
|
||||
var index = notification.SecondaryKind-21;
|
||||
var typ = id2warhead[index];
|
||||
|
||||
@ -334,7 +341,7 @@ var DamageRecipient =
|
||||
dynamics["noti_"~notification.Callsign~"_"~notification.UniqueIdentity] = [systime()-(time_before_delete-1.6), notification.Position.lat(), notification.Position.lon(), notification.Position.alt(), notification.u_fps, notification.Heading, notification.Pitch,-1]
|
||||
}
|
||||
|
||||
if (tacview_supported and getprop("sim/multiplay/txhost") != "mpserver.opredflag.com") {
|
||||
if (tacview_supported and (getprop("sim/multiplay/txhost") != "mpserver.opredflag.com" or m28_auto)) {
|
||||
if (tacview.starttime) {
|
||||
var tacID = left(md5(notification.Callsign~notification.UniqueIdentity),6);
|
||||
if (notification.Kind == DESTROY) {
|
||||
@ -348,7 +355,7 @@ var DamageRecipient =
|
||||
var extra2 = typ[2]==0?",Type=Weapon+Missile":",Type=Weapon+Bomb";
|
||||
extra2 = typ[4]=="Flare"?",Type=Flare":extra2;
|
||||
extra2 = typp=="Parachutist"?"":extra2;
|
||||
var color = radarOn?",Color=Red":",Color=Yellow";
|
||||
var color = radarOn or CWIOn?",Color=Red":",Color=Yellow";
|
||||
thread.lock(tacview.mutexWrite);
|
||||
tacview.write("#" ~ (systime() - tacview.starttime)~"\n");
|
||||
tacview.write(tacID~",T="~notification.Position.lon()~"|"~notification.Position.lat()~"|"~notification.Position.alt()~extra~",Name="~typp~color~extra2~"\n");
|
||||
@ -376,9 +383,10 @@ var DamageRecipient =
|
||||
setprop("payload/armament/MLW-launcher", notification.Callsign);
|
||||
setprop("payload/armament/MLW-count", getprop("payload/armament/MLW-count")+1);
|
||||
var out = sprintf("Missile Launch Warning from %03d degrees.", bearing);
|
||||
if (rwr_to_screen) screen.log.write(out, 1,1,0);# temporary till someone models a RWR in RIO seat
|
||||
if (rwr_to_screen) screen.log.write(out, 1,0.5,0);# temporary till someone models a RWR in RIO seat
|
||||
print(out);
|
||||
damageLog.push(sprintf("Missile Launch Warning from %03d degrees from %s.", bearing, notification.Callsign));
|
||||
if (m28_auto) mig28.missileLaunch();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -386,19 +394,29 @@ var DamageRecipient =
|
||||
# Missile approach warning:
|
||||
var callsign = processCallsign(getprop("sim/multiplay/callsign"));
|
||||
if (notification.RemoteCallsign != callsign) return emesary.Transmitter.ReceiptStatus_OK;
|
||||
if (!radarOn) return emesary.Transmitter.ReceiptStatus_OK;# this should be little more complex later
|
||||
var heading = getprop("orientation/heading-deg");
|
||||
var clock = geo.normdeg(bearing - heading);
|
||||
setprop("payload/armament/MAW-bearing", bearing);
|
||||
setprop("payload/armament/MAW-active", 1);# resets every 1 seconds
|
||||
if (!radarOn and !CWIOn) return emesary.Transmitter.ReceiptStatus_OK;# this should be little more complex later
|
||||
#var heading = getprop("orientation/heading-deg");
|
||||
#var clock = geo.normdeg(bearing - heading);
|
||||
if (radarOn) {
|
||||
setprop("payload/armament/MAW-bearing", bearing);
|
||||
setprop("payload/armament/MAW-active", 1);# resets every 1 seconds
|
||||
} elsif (CWIOn) {
|
||||
setprop("payload/armament/MAW-semiactive", 1);# resets every 1 seconds
|
||||
}
|
||||
MAW_elapsed = elapsed;
|
||||
var appr = approached[notification.Callsign~notification.UniqueIdentity];
|
||||
if (appr == nil or elapsed - appr > 450) {
|
||||
printf("Missile Approach Warning from %03d degrees.", bearing);
|
||||
damageLog.push(sprintf("Missile Approach Warning from %03d degrees from %s.", bearing, notification.Callsign));
|
||||
if (rwr_to_screen) screen.log.write(sprintf("Missile Approach Warning from %03d degrees.", bearing), 1,1,0);# temporary till someone models a RWR in RIO seat
|
||||
if (radarOn) {
|
||||
#printf("Missile Approach Warning from %03d degrees.", bearing);
|
||||
damageLog.push(sprintf("Missile Approach Warning from %03d degrees from %s.", bearing, notification.Callsign));
|
||||
if (rwr_to_screen) screen.log.write(sprintf("Missile Approach Warning from %03d degrees.", bearing), 1,0.5,0);# temporary till someone models a RWR in RIO seat
|
||||
} else {
|
||||
#printf("Missile Approach Warning");
|
||||
damageLog.push(sprintf("Missile Approach Warning from %s.", notification.Callsign));
|
||||
if (rwr_to_screen) screen.log.write(sprintf("Missile Approach Warning (semi-active)."), 1,0.5,0);# temporary till someone models a RWR in RIO seat
|
||||
}
|
||||
approached[notification.Callsign~notification.UniqueIdentity] = elapsed;
|
||||
if (m28_auto) mig28.engagedBy(notification.Callsign);
|
||||
if (m28_auto) mig28.engagedBy(notification.Callsign, 1);
|
||||
}
|
||||
return emesary.Transmitter.ReceiptStatus_OK;
|
||||
}
|
||||
@ -415,7 +433,7 @@ var DamageRecipient =
|
||||
# debug.dump(notification);
|
||||
#
|
||||
#
|
||||
if (tacview_supported and tacview.starttime and getprop("sim/multiplay/txhost") != "mpserver.opredflag.com") {
|
||||
if (tacview_supported and tacview.starttime and (getprop("sim/multiplay/txhost") != "mpserver.opredflag.com" or m28_auto)) {
|
||||
var node = getCallsign(notification.RemoteCallsign);
|
||||
if (node != nil and notification.SecondaryKind > 20) {
|
||||
# its a warhead
|
||||
@ -439,9 +457,10 @@ var DamageRecipient =
|
||||
var callsign = processCallsign(getprop("sim/multiplay/callsign"));
|
||||
if (notification.RemoteCallsign == callsign and getprop("payload/armament/msg") == 1) {
|
||||
#damage enabled and were getting hit
|
||||
if (m28_auto) mig28.engagedBy(notification.Callsign);
|
||||
|
||||
if (notification.SecondaryKind < 0 and hitable_by_cannon) {
|
||||
# cannon hit
|
||||
if (m28_auto) mig28.engagedBy(notification.Callsign, 0);
|
||||
var probability = id2shell[-1*notification.SecondaryKind-1][1];
|
||||
var typ = id2shell[-1*notification.SecondaryKind-1][2];
|
||||
var hit_count = notification.Distance;
|
||||
@ -457,6 +476,7 @@ var DamageRecipient =
|
||||
}
|
||||
} elsif (notification.SecondaryKind > 20) {
|
||||
# its a warhead
|
||||
if (m28_auto) mig28.engagedBy(notification.Callsign, 1);
|
||||
var dist = notification.Distance;
|
||||
var wh = id2warhead[notification.SecondaryKind - 21];
|
||||
var type = wh[4];#test code
|
||||
@ -549,21 +569,18 @@ var DamageRecipient =
|
||||
}
|
||||
if (notification.Kind == CREATE and getprop("payload/armament/enable-craters") == 1 and statics["obj_"~notification.UniqueIdentity] == nil) {
|
||||
if (notification.SecondaryKind == 0) {# TODO: make a hash with all the models
|
||||
var crater_model = getprop("payload/armament/models") ~ "crater_small.xml";
|
||||
var static = geo.put_model(crater_model, notification.Position.lat(), notification.Position.lon(), notification.Position.alt(), notification.Heading);
|
||||
var static = geo.put_model(crater_model0, notification.Position.lat(), notification.Position.lon(), notification.Position.alt(), notification.Heading);
|
||||
if (static != nil) {
|
||||
statics["obj_"~notification.UniqueIdentity] = [static, notification.Position.lat(), notification.Position.lon(), notification.Position.alt(), notification.Heading, notification.SecondaryKind];
|
||||
#static is a PropertyNode inside /models
|
||||
}
|
||||
} elsif (notification.SecondaryKind == 1) {
|
||||
var crater_model = getprop("payload/armament/models") ~ "crater_big.xml";
|
||||
var static = geo.put_model(crater_model, notification.Position.lat(), notification.Position.lon(), notification.Position.alt(), notification.Heading);
|
||||
var static = geo.put_model(crater_model1, notification.Position.lat(), notification.Position.lon(), notification.Position.alt(), notification.Heading);
|
||||
if (static != nil) {
|
||||
statics["obj_"~notification.UniqueIdentity] = [static, notification.Position.lat(), notification.Position.lon(), notification.Position.alt(), notification.Heading, notification.SecondaryKind];
|
||||
}
|
||||
} elsif (notification.SecondaryKind == 2) {
|
||||
var crater_model = getprop("payload/armament/models") ~ "bomb_hit_smoke.xml";
|
||||
var static = geo.put_model(crater_model, notification.Position.lat(), notification.Position.lon(), notification.Position.alt(), notification.Heading);
|
||||
var static = geo.put_model(crater_model2, notification.Position.lat(), notification.Position.lon(), notification.Position.alt(), notification.Heading);
|
||||
if (static != nil) {
|
||||
statics["obj_"~notification.UniqueIdentity] = [static, notification.Position.lat(), notification.Position.lon(), notification.Position.alt(), notification.Heading, notification.SecondaryKind];
|
||||
}
|
||||
@ -863,6 +880,7 @@ var flare_update_time = 0.4;
|
||||
var flare_duration = 8;
|
||||
var flare_terminal_speed = 50;#m/s
|
||||
var flares_max_process_per_loop = 4;
|
||||
var flare_sequencer = -120;
|
||||
|
||||
var flare_sorter = func(a, b) {
|
||||
if(a[0] < b[0]){
|
||||
@ -945,7 +963,9 @@ var flare_released = func {
|
||||
getprop("orientation/heading-deg"),
|
||||
FT2M*getprop("velocities/speed-down-fps"),
|
||||
FT2M*math.sqrt(getprop("velocities/speed-north-fps")*getprop("velocities/speed-north-fps")+getprop("velocities/speed-east-fps")*getprop("velocities/speed-east-fps")),
|
||||
int(rand()*240)-120];
|
||||
flare_sequencer];
|
||||
flare_sequencer += 1;
|
||||
if (flare_sequencer > 120) flare_sequencer = -120;
|
||||
append(flare_list, flare);
|
||||
var msg = notifications.ObjectInFlightNotification.new("ffly", flare[6], MOVE, 21+95);
|
||||
msg.Flags = 0;
|
||||
@ -1233,7 +1253,7 @@ var processCallsigns = func () {
|
||||
var painted = 0;
|
||||
var paint_list = [];
|
||||
foreach (var player; players) {
|
||||
if(player.getChild("valid") != nil and player.getChild("valid").getValue() == TRUE and player.getChild("callsign") != nil and player.getChild("callsign").getValue() != "" and player.getChild("callsign").getValue() != nil) {
|
||||
if(player.getChild("valid") != nil and player.getChild("valid").getValue() == 1 and player.getChild("callsign") != nil and player.getChild("callsign").getValue() != "" and player.getChild("callsign").getValue() != nil) {
|
||||
var callsign = player.getChild("callsign").getValue();
|
||||
callsign_struct[callsign] = player;
|
||||
var str6 = player.getNode("sim/multiplay/generic/string[6]");
|
||||
@ -1247,6 +1267,7 @@ var processCallsigns = func () {
|
||||
}
|
||||
if (getprop("sim/time/elapsed-sec")-MAW_elapsed > 1.1) {
|
||||
setprop("payload/armament/MAW-active", 0);# resets every 1.1 seconds without warning
|
||||
setprop("payload/armament/MAW-semiactive", 0);
|
||||
}
|
||||
|
||||
# spike handling:
|
||||
@ -1293,16 +1314,16 @@ processCallsignsTimer.start();
|
||||
var code_ct = func () {
|
||||
#ANTIC
|
||||
if (getprop("payload/armament/msg")) {
|
||||
setprop("sim/rendering/redout/enabled", TRUE);
|
||||
setprop("sim/rendering/redout/enabled", 1);
|
||||
#call(func{fgcommand('dialog-close', multiplayer.dialog.dialog.prop())},nil,var err= []);# props.Node.new({"dialog-name": "location-in-air"}));
|
||||
call(func{multiplayer.dialog.del();},nil,var err= []);
|
||||
if (!m28_auto) call(func{multiplayer.dialog.del();},nil,var err= []);
|
||||
if (!getprop("gear/gear[0]/wow")) {
|
||||
call(func{fgcommand('dialog-close', props.Node.new({"dialog-name": "WeightAndFuel"}))},nil,var err2 = []);
|
||||
call(func{fgcommand('dialog-close', props.Node.new({"dialog-name": "system-failures"}))},nil,var err2 = []);
|
||||
call(func{fgcommand('dialog-close', props.Node.new({"dialog-name": "instrument-failures"}))},nil,var err2 = []);
|
||||
}
|
||||
setprop("sim/freeze/fuel",0);
|
||||
setprop("/sim/speed-up", 1);
|
||||
if (!m28_auto) setprop("/sim/speed-up", 1);
|
||||
setprop("/gui/map/draw-traffic", 0);
|
||||
setprop("/sim/marker-pins/traffic", 0);
|
||||
setprop("/sim/gui/dialogs/map-canvas/draw-TFC", 0);
|
||||
@ -1317,7 +1338,7 @@ code_ctTimer.simulatedTime = 1;
|
||||
|
||||
|
||||
|
||||
setprop("/sim/failure-manager/display-on-screen", FALSE);
|
||||
setprop("/sim/failure-manager/display-on-screen", 0);
|
||||
|
||||
code_ctTimer.start();
|
||||
|
||||
@ -1337,6 +1358,22 @@ var re_init = func (node) {
|
||||
}
|
||||
stopLaunch();
|
||||
damageLog.push("Aircraft was repaired due to re-init.");
|
||||
|
||||
# Remove all 3D craters and re-place them. Due to re-init can remove some of them.
|
||||
|
||||
foreach (var thekey ; keys(statics)) {
|
||||
var sta = statics[thekey];
|
||||
if (sta[0] != nil) {
|
||||
sta[0].remove();
|
||||
if (sta[5] == 0) {# TODO: make a hash with all the models
|
||||
sta[0] = geo.put_model(crater_model0, sta[1], sta[2], sta[3], sta[4]);
|
||||
} elsif (sta[5] == 1) {
|
||||
sta[0] = geo.put_model(crater_model1, sta[1], sta[2], sta[3], sta[4]);
|
||||
} elsif (sta[5] == 2) {
|
||||
sta[0] = geo.put_model(crater_model2, sta[1], sta[2], sta[3], sta[4]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#==================================================================
|
||||
@ -1405,6 +1442,7 @@ setlistener("sim/signals/exit", writeDamageLog, 0, 0);
|
||||
|
||||
#screen.property_display.add("payload/armament/MAW-bearing");
|
||||
#screen.property_display.add("payload/armament/MAW-active");
|
||||
#screen.property_display.add("payload/armament/MAW-semiactive");
|
||||
#screen.property_display.add("payload/armament/MLW-bearing");
|
||||
#screen.property_display.add("payload/armament/MLW-count");
|
||||
#screen.property_display.add("payload/armament/MLW-launcher");
|
||||
@ -1412,6 +1450,8 @@ setlistener("sim/signals/exit", writeDamageLog, 0, 0);
|
||||
#screen.property_display.add("payload/armament/spike-air");
|
||||
#screen.property_display.add("payload/armament/spike-gnd-20");
|
||||
#screen.property_display.add("payload/armament/spike-gnd-02");
|
||||
#screen.property_display.add("payload/armament/spike-gnd-05");
|
||||
#screen.property_display.add("payload/armament/spike-gnd-06");
|
||||
#screen.property_display.add("payload/armament/spike-gnd-11");
|
||||
#screen.property_display.add("payload/armament/spike-gnd-23");
|
||||
#screen.property_display.add("payload/armament/spike-gnd-p2");
|
||||
|
@ -34,9 +34,9 @@ var ROUNDS = ROUNDS_init;#CIWS bursts remaining
|
||||
|
||||
var NUM_MISSILES = 3; # total carried minus 1
|
||||
var missile_name = "GEM";
|
||||
var missile_brevity = "GEM/T";
|
||||
var missile_max_distance = 43; #max distance of target in nm when it will fire
|
||||
var missile_min_distance = 0.5; #minimum distance in nm when it will fire
|
||||
var missile_brevity = damage.id2warhead[getprop("payload/armament/"~string.lc(missile_name)~"/type-id")][4];
|
||||
var missile_max_distance = getprop("payload/armament/"~string.lc(missile_name)~"/max-fire-range-nm"); #max distance of target in nm when it will fire
|
||||
var missile_min_distance = getprop("payload/armament/"~string.lc(missile_name)~"/min-fire-range-nm"); #minimum distance in nm when it will fire
|
||||
var lockon_time = 12; #time in seconds it takes to lock on and get a firing solution on a target
|
||||
var fire_minimum_interval = 7;# time since last track was initiated till a new can be initiated
|
||||
var same_target_max_missiles = 1;# max number of missiles in air against same target
|
||||
|
@ -1,8 +1,5 @@
|
||||
################### GLOBALS
|
||||
|
||||
var false = 0;
|
||||
var true = 1;
|
||||
|
||||
var AIR = 0;
|
||||
var MARINE = 1;
|
||||
var SURFACE = 2;
|
||||
@ -189,7 +186,7 @@ var scan = func() {
|
||||
#print("dist to target = " ~ dist_to_target);
|
||||
|
||||
var lu = lookup(mp[0].getNode("callsign").getValue());
|
||||
if ( launch_in_progress == 0 and trigger == true and lu != nil and lu.in_air < same_target_max_missiles and !lu.tracking and ACTIVE_MISSILE <= NUM_MISSILES and ( systime() - missile_delay_time > fire_minimum_interval ) ) { #
|
||||
if ( launch_in_progress == 0 and trigger == 1 and lu != nil and lu.in_air < same_target_max_missiles and !lu.tracking and ACTIVE_MISSILE <= NUM_MISSILES and ( systime() - missile_delay_time > fire_minimum_interval ) ) { #
|
||||
#### ... FOR THE MISSILE ####
|
||||
#print("callsign " ~ cs ~ " found at " ~ dist_to_target);
|
||||
missile_delay_time = systime();
|
||||
@ -329,7 +326,7 @@ var clearSingleLock = func () {
|
||||
var fire_control = func(mp, my_pos) {
|
||||
# gather some data about the target
|
||||
|
||||
if ( mp.getNode("valid").getValue() == false ) { return [mp,false,0,0]; }
|
||||
if ( mp.getNode("valid").getValue() == 0 ) { return [mp,0,0,0]; }
|
||||
|
||||
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() * FT2M));
|
||||
var target_distance = my_pos.direct_distance_to(ufo_pos);
|
||||
@ -337,7 +334,7 @@ var fire_control = func(mp, my_pos) {
|
||||
|
||||
# is this plane a friend or foe?
|
||||
var lu = lookup(mp.getNode("callsign").getValue());
|
||||
if ( lu == nil ) { return [mp,false,0,0]; }
|
||||
if ( lu == nil ) { return [mp,0,0,0]; }
|
||||
|
||||
var target_airspeed = mp.getNode("velocities/true-airspeed-kt").getValue();
|
||||
var target_ground_distance = my_pos.distance_to(ufo_pos);
|
||||
@ -350,7 +347,7 @@ var fire_control = func(mp, my_pos) {
|
||||
|
||||
|
||||
# can the radar see it?
|
||||
var data_link_match = false;
|
||||
var data_link_match = 0;
|
||||
# foreach(var cx; gci.data_receive_callsigns) {
|
||||
# if (cx[0] == callsign) {
|
||||
# data_link_match = true;
|
||||
@ -364,8 +361,8 @@ var fire_control = func(mp, my_pos) {
|
||||
if (ciws_installed and ROUNDS > 0 and target_distance*M2NM < ciws_domain_nm) {
|
||||
#CIWS
|
||||
var radarSeeTarget = 1;
|
||||
if ( data_link_match == false ) {
|
||||
if ( visible[0] == false ) {radarSeeTarget = 0 }
|
||||
if ( data_link_match == 0 ) {
|
||||
if ( visible[0] == 0 ) {radarSeeTarget = 0 }
|
||||
if ( target_relative_pitch < radar_lowest_pitch ) { radarSeeTarget = 0 } #
|
||||
if ( target_distance*M2NM > 1.0 and visible[1] and math.abs(target_radial_airspeed) < 20 ) {radarSeeTarget = 0 } # i.e. notching with terrain behind
|
||||
}
|
||||
@ -392,15 +389,15 @@ var fire_control = func(mp, my_pos) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( data_link_match == false ) {
|
||||
if (target_airspeed < 60) {return [mp,false,0,0];}
|
||||
if ( visible[0] == false ) { return [mp,false,0,0]; }
|
||||
if ( target_relative_pitch < radar_lowest_pitch ) { return [mp,false,0,0]; } #
|
||||
if ( visible[1] and math.abs(target_radial_airspeed) < 20 ) { return [mp,false,0,0]; } # i.e. notching, landed aircraft
|
||||
if ( data_link_match == 0 ) {
|
||||
if (target_airspeed < 60) {return [mp,0,0,0];}
|
||||
if ( visible[0] == 0 ) { return [mp,0,0,0]; }
|
||||
if ( target_relative_pitch < radar_lowest_pitch ) { return [mp,0,0,0]; } #
|
||||
if ( visible[1] and math.abs(target_radial_airspeed) < 20 ) { return [mp,0,0,0]; } # i.e. notching, landed aircraft
|
||||
}
|
||||
|
||||
if ( target_distance * M2NM > missile_max_distance ) { return [mp,false,0,0]; }
|
||||
if ( target_distance * M2NM < missile_min_distance ) { return [mp,false,0,0]; }
|
||||
if ( target_distance * M2NM > missile_max_distance ) { return [mp,0,0,0]; }
|
||||
if ( target_distance * M2NM < missile_min_distance ) { return [mp,0,0,0]; }
|
||||
|
||||
|
||||
|
||||
@ -410,7 +407,7 @@ var fire_control = func(mp, my_pos) {
|
||||
# larger offset means it wont fire until the plane is closer.
|
||||
# for visualization: https://www.desmos.com/calculator/gw570fa9km
|
||||
|
||||
if (!isInEngagementEnvelope(target_radial_airspeed, target_ground_distance, target_relative_altitude) ) { return [mp,false,0,0]; }
|
||||
if (!isInEngagementEnvelope(target_radial_airspeed, target_ground_distance, target_relative_altitude) ) { return [mp,0,0,0]; }
|
||||
|
||||
|
||||
|
||||
@ -434,9 +431,9 @@ var fire_control = func(mp, my_pos) {
|
||||
} elsif (priority==PRIO_FAR) {
|
||||
score = target_distance;
|
||||
}
|
||||
return [mp,true,score,1];
|
||||
return [mp,1,score,1];
|
||||
} else {
|
||||
return [mp,false,0,1];
|
||||
return [mp,0,0,1];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,9 +15,6 @@ if ((major == 2017 and minor == 2 and pica >= 1) or (major == 2017 and minor > 2
|
||||
pickingMethod = 1;
|
||||
}
|
||||
|
||||
var FALSE = 0;
|
||||
var TRUE = 1;
|
||||
|
||||
var AIR = 0;
|
||||
var MARINE = 1;
|
||||
var SURFACE = 2;
|
||||
@ -124,10 +121,10 @@ var Contact = {
|
||||
isValid: func () {
|
||||
var valid = me.valid.getValue();
|
||||
if (valid == nil) {
|
||||
valid = FALSE;
|
||||
valid = 0;
|
||||
}
|
||||
if (me.callsign.getValue() != me.orig_callsign) {
|
||||
valid = FALSE;
|
||||
valid = 0;
|
||||
}
|
||||
return valid;
|
||||
},
|
||||
|
@ -27,8 +27,6 @@ var mlw_max=getprop("payload/d-config/mlw_max"); #
|
||||
var auto_flare_caller = getprop("payload/d-config/auto_flare_caller"); # If damage.nas should detect flare releases, or if function is called from somewhere in aircraft
|
||||
############################################################################################################################
|
||||
|
||||
var TRUE = 1;
|
||||
var FALSE = 0;
|
||||
|
||||
var hp = hp_max;
|
||||
setprop("sam/damage", math.max(0,100*hp/hp_max));#used in HUD
|
||||
@ -164,7 +162,9 @@ var warheads = {
|
||||
"pilot": [93, 0.00,1,0],# ejected pilot
|
||||
"BETAB-500ShP": [94, 1160.00,1,0],
|
||||
"Flare": [95, 0.00,0,0],
|
||||
"3M9": [96, 125.00,0,0],# 3M9 Missile used with 2K12/SA-6
|
||||
"3M9": [96, 125.00,0,0],# 3M9M3 Missile used with 2K12/SA-6
|
||||
"5V28V": [97, 478.00,0,0],# Missile used with S-200D/SA-5
|
||||
"AIM-9X": [98, 20.80,0,0],
|
||||
};
|
||||
|
||||
var AIR_RADAR = "air";
|
||||
@ -189,7 +189,8 @@ var radar_signatures = {
|
||||
"E-8R": AIR_RADAR,
|
||||
"EC-137D": AIR_RADAR,
|
||||
"Mig-28": AIR_RADAR,
|
||||
"SA-6": AIR_RADAR,#Air radar tone chosen so that there is at least some lock tone until asset-specific is created
|
||||
"SA-6": "gnd-06",#Air radar tone chosen so that there is at least some lock tone until asset-specific is created
|
||||
"s-200": "gnd-05",
|
||||
"ZSU-23-4M": "gnd-23",
|
||||
"S-75": "gnd-02",
|
||||
"buk-m2": "gnd-11",
|
||||
@ -203,7 +204,7 @@ var radar_signatures = {
|
||||
var id2warhead = [];
|
||||
var launched = {};# callsign: elapsed-sec
|
||||
var approached = {};# callsign: uniqueID
|
||||
var heavy_smoke = [61,62,63,65,92,96];
|
||||
var heavy_smoke = [61,62,63,65,92,96,97];
|
||||
|
||||
var k = keys(warheads);
|
||||
|
||||
@ -241,6 +242,10 @@ for(var myid = 0;myid<size(k);myid+=1) {
|
||||
}
|
||||
}
|
||||
|
||||
var crater_model0 = getprop("payload/armament/models") ~ "crater_small.xml";
|
||||
var crater_model1 = getprop("payload/armament/models") ~ "crater_big.xml";
|
||||
var crater_model2 = getprop("payload/armament/models") ~ "bomb_hit_smoke.xml";
|
||||
|
||||
#==================================================================
|
||||
# Notification processing
|
||||
#==================================================================
|
||||
@ -281,6 +286,7 @@ var DamageRecipient =
|
||||
# " Flags=",notification.Flags,
|
||||
# " Radar=",bits.test(notification.Flags, 0),
|
||||
# " Thrust=",bits.test(notification.Flags, 1));
|
||||
# " CWI=",bits.test(notification.Flags, 2));
|
||||
#
|
||||
# todo:
|
||||
# animate missiles
|
||||
@ -301,6 +307,7 @@ var DamageRecipient =
|
||||
var bearing = ownPos.course_to(notification.Position);
|
||||
var radarOn = bits.test(notification.Flags, 0);
|
||||
var thrustOn = bits.test(notification.Flags, 1);
|
||||
var CWIOn = bits.test(notification.Flags, 2);
|
||||
var index = notification.SecondaryKind-21;
|
||||
var typ = id2warhead[index];
|
||||
|
||||
@ -334,7 +341,7 @@ var DamageRecipient =
|
||||
dynamics["noti_"~notification.Callsign~"_"~notification.UniqueIdentity] = [systime()-(time_before_delete-1.6), notification.Position.lat(), notification.Position.lon(), notification.Position.alt(), notification.u_fps, notification.Heading, notification.Pitch,-1]
|
||||
}
|
||||
|
||||
if (tacview_supported and getprop("sim/multiplay/txhost") != "mpserver.opredflag.com") {
|
||||
if (tacview_supported and (getprop("sim/multiplay/txhost") != "mpserver.opredflag.com" or m28_auto)) {
|
||||
if (tacview.starttime) {
|
||||
var tacID = left(md5(notification.Callsign~notification.UniqueIdentity),6);
|
||||
if (notification.Kind == DESTROY) {
|
||||
@ -348,7 +355,7 @@ var DamageRecipient =
|
||||
var extra2 = typ[2]==0?",Type=Weapon+Missile":",Type=Weapon+Bomb";
|
||||
extra2 = typ[4]=="Flare"?",Type=Flare":extra2;
|
||||
extra2 = typp=="Parachutist"?"":extra2;
|
||||
var color = radarOn?",Color=Red":",Color=Yellow";
|
||||
var color = radarOn or CWIOn?",Color=Red":",Color=Yellow";
|
||||
thread.lock(tacview.mutexWrite);
|
||||
tacview.write("#" ~ (systime() - tacview.starttime)~"\n");
|
||||
tacview.write(tacID~",T="~notification.Position.lon()~"|"~notification.Position.lat()~"|"~notification.Position.alt()~extra~",Name="~typp~color~extra2~"\n");
|
||||
@ -376,9 +383,10 @@ var DamageRecipient =
|
||||
setprop("payload/armament/MLW-launcher", notification.Callsign);
|
||||
setprop("payload/armament/MLW-count", getprop("payload/armament/MLW-count")+1);
|
||||
var out = sprintf("Missile Launch Warning from %03d degrees.", bearing);
|
||||
if (rwr_to_screen) screen.log.write(out, 1,1,0);# temporary till someone models a RWR in RIO seat
|
||||
if (rwr_to_screen) screen.log.write(out, 1,0.5,0);# temporary till someone models a RWR in RIO seat
|
||||
print(out);
|
||||
damageLog.push(sprintf("Missile Launch Warning from %03d degrees from %s.", bearing, notification.Callsign));
|
||||
if (m28_auto) mig28.missileLaunch();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -386,19 +394,29 @@ var DamageRecipient =
|
||||
# Missile approach warning:
|
||||
var callsign = processCallsign(getprop("sim/multiplay/callsign"));
|
||||
if (notification.RemoteCallsign != callsign) return emesary.Transmitter.ReceiptStatus_OK;
|
||||
if (!radarOn) return emesary.Transmitter.ReceiptStatus_OK;# this should be little more complex later
|
||||
var heading = getprop("orientation/heading-deg");
|
||||
var clock = geo.normdeg(bearing - heading);
|
||||
setprop("payload/armament/MAW-bearing", bearing);
|
||||
setprop("payload/armament/MAW-active", 1);# resets every 1 seconds
|
||||
if (!radarOn and !CWIOn) return emesary.Transmitter.ReceiptStatus_OK;# this should be little more complex later
|
||||
#var heading = getprop("orientation/heading-deg");
|
||||
#var clock = geo.normdeg(bearing - heading);
|
||||
if (radarOn) {
|
||||
setprop("payload/armament/MAW-bearing", bearing);
|
||||
setprop("payload/armament/MAW-active", 1);# resets every 1 seconds
|
||||
} elsif (CWIOn) {
|
||||
setprop("payload/armament/MAW-semiactive", 1);# resets every 1 seconds
|
||||
}
|
||||
MAW_elapsed = elapsed;
|
||||
var appr = approached[notification.Callsign~notification.UniqueIdentity];
|
||||
if (appr == nil or elapsed - appr > 450) {
|
||||
printf("Missile Approach Warning from %03d degrees.", bearing);
|
||||
damageLog.push(sprintf("Missile Approach Warning from %03d degrees from %s.", bearing, notification.Callsign));
|
||||
if (rwr_to_screen) screen.log.write(sprintf("Missile Approach Warning from %03d degrees.", bearing), 1,1,0);# temporary till someone models a RWR in RIO seat
|
||||
if (radarOn) {
|
||||
#printf("Missile Approach Warning from %03d degrees.", bearing);
|
||||
damageLog.push(sprintf("Missile Approach Warning from %03d degrees from %s.", bearing, notification.Callsign));
|
||||
if (rwr_to_screen) screen.log.write(sprintf("Missile Approach Warning from %03d degrees.", bearing), 1,0.5,0);# temporary till someone models a RWR in RIO seat
|
||||
} else {
|
||||
#printf("Missile Approach Warning");
|
||||
damageLog.push(sprintf("Missile Approach Warning from %s.", notification.Callsign));
|
||||
if (rwr_to_screen) screen.log.write(sprintf("Missile Approach Warning (semi-active)."), 1,0.5,0);# temporary till someone models a RWR in RIO seat
|
||||
}
|
||||
approached[notification.Callsign~notification.UniqueIdentity] = elapsed;
|
||||
if (m28_auto) mig28.engagedBy(notification.Callsign);
|
||||
if (m28_auto) mig28.engagedBy(notification.Callsign, 1);
|
||||
}
|
||||
return emesary.Transmitter.ReceiptStatus_OK;
|
||||
}
|
||||
@ -415,7 +433,7 @@ var DamageRecipient =
|
||||
# debug.dump(notification);
|
||||
#
|
||||
#
|
||||
if (tacview_supported and tacview.starttime and getprop("sim/multiplay/txhost") != "mpserver.opredflag.com") {
|
||||
if (tacview_supported and tacview.starttime and (getprop("sim/multiplay/txhost") != "mpserver.opredflag.com" or m28_auto)) {
|
||||
var node = getCallsign(notification.RemoteCallsign);
|
||||
if (node != nil and notification.SecondaryKind > 20) {
|
||||
# its a warhead
|
||||
@ -439,9 +457,10 @@ var DamageRecipient =
|
||||
var callsign = processCallsign(getprop("sim/multiplay/callsign"));
|
||||
if (notification.RemoteCallsign == callsign and getprop("payload/armament/msg") == 1) {
|
||||
#damage enabled and were getting hit
|
||||
if (m28_auto) mig28.engagedBy(notification.Callsign);
|
||||
|
||||
if (notification.SecondaryKind < 0 and hitable_by_cannon) {
|
||||
# cannon hit
|
||||
if (m28_auto) mig28.engagedBy(notification.Callsign, 0);
|
||||
var probability = id2shell[-1*notification.SecondaryKind-1][1];
|
||||
var typ = id2shell[-1*notification.SecondaryKind-1][2];
|
||||
var hit_count = notification.Distance;
|
||||
@ -457,6 +476,7 @@ var DamageRecipient =
|
||||
}
|
||||
} elsif (notification.SecondaryKind > 20) {
|
||||
# its a warhead
|
||||
if (m28_auto) mig28.engagedBy(notification.Callsign, 1);
|
||||
var dist = notification.Distance;
|
||||
var wh = id2warhead[notification.SecondaryKind - 21];
|
||||
var type = wh[4];#test code
|
||||
@ -549,21 +569,18 @@ var DamageRecipient =
|
||||
}
|
||||
if (notification.Kind == CREATE and getprop("payload/armament/enable-craters") == 1 and statics["obj_"~notification.UniqueIdentity] == nil) {
|
||||
if (notification.SecondaryKind == 0) {# TODO: make a hash with all the models
|
||||
var crater_model = getprop("payload/armament/models") ~ "crater_small.xml";
|
||||
var static = geo.put_model(crater_model, notification.Position.lat(), notification.Position.lon(), notification.Position.alt(), notification.Heading);
|
||||
var static = geo.put_model(crater_model0, notification.Position.lat(), notification.Position.lon(), notification.Position.alt(), notification.Heading);
|
||||
if (static != nil) {
|
||||
statics["obj_"~notification.UniqueIdentity] = [static, notification.Position.lat(), notification.Position.lon(), notification.Position.alt(), notification.Heading, notification.SecondaryKind];
|
||||
#static is a PropertyNode inside /models
|
||||
}
|
||||
} elsif (notification.SecondaryKind == 1) {
|
||||
var crater_model = getprop("payload/armament/models") ~ "crater_big.xml";
|
||||
var static = geo.put_model(crater_model, notification.Position.lat(), notification.Position.lon(), notification.Position.alt(), notification.Heading);
|
||||
var static = geo.put_model(crater_model1, notification.Position.lat(), notification.Position.lon(), notification.Position.alt(), notification.Heading);
|
||||
if (static != nil) {
|
||||
statics["obj_"~notification.UniqueIdentity] = [static, notification.Position.lat(), notification.Position.lon(), notification.Position.alt(), notification.Heading, notification.SecondaryKind];
|
||||
}
|
||||
} elsif (notification.SecondaryKind == 2) {
|
||||
var crater_model = getprop("payload/armament/models") ~ "bomb_hit_smoke.xml";
|
||||
var static = geo.put_model(crater_model, notification.Position.lat(), notification.Position.lon(), notification.Position.alt(), notification.Heading);
|
||||
var static = geo.put_model(crater_model2, notification.Position.lat(), notification.Position.lon(), notification.Position.alt(), notification.Heading);
|
||||
if (static != nil) {
|
||||
statics["obj_"~notification.UniqueIdentity] = [static, notification.Position.lat(), notification.Position.lon(), notification.Position.alt(), notification.Heading, notification.SecondaryKind];
|
||||
}
|
||||
@ -863,6 +880,7 @@ var flare_update_time = 0.4;
|
||||
var flare_duration = 8;
|
||||
var flare_terminal_speed = 50;#m/s
|
||||
var flares_max_process_per_loop = 4;
|
||||
var flare_sequencer = -120;
|
||||
|
||||
var flare_sorter = func(a, b) {
|
||||
if(a[0] < b[0]){
|
||||
@ -945,7 +963,9 @@ var flare_released = func {
|
||||
getprop("orientation/heading-deg"),
|
||||
FT2M*getprop("velocities/speed-down-fps"),
|
||||
FT2M*math.sqrt(getprop("velocities/speed-north-fps")*getprop("velocities/speed-north-fps")+getprop("velocities/speed-east-fps")*getprop("velocities/speed-east-fps")),
|
||||
int(rand()*240)-120];
|
||||
flare_sequencer];
|
||||
flare_sequencer += 1;
|
||||
if (flare_sequencer > 120) flare_sequencer = -120;
|
||||
append(flare_list, flare);
|
||||
var msg = notifications.ObjectInFlightNotification.new("ffly", flare[6], MOVE, 21+95);
|
||||
msg.Flags = 0;
|
||||
@ -1233,7 +1253,7 @@ var processCallsigns = func () {
|
||||
var painted = 0;
|
||||
var paint_list = [];
|
||||
foreach (var player; players) {
|
||||
if(player.getChild("valid") != nil and player.getChild("valid").getValue() == TRUE and player.getChild("callsign") != nil and player.getChild("callsign").getValue() != "" and player.getChild("callsign").getValue() != nil) {
|
||||
if(player.getChild("valid") != nil and player.getChild("valid").getValue() == 1 and player.getChild("callsign") != nil and player.getChild("callsign").getValue() != "" and player.getChild("callsign").getValue() != nil) {
|
||||
var callsign = player.getChild("callsign").getValue();
|
||||
callsign_struct[callsign] = player;
|
||||
var str6 = player.getNode("sim/multiplay/generic/string[6]");
|
||||
@ -1247,6 +1267,7 @@ var processCallsigns = func () {
|
||||
}
|
||||
if (getprop("sim/time/elapsed-sec")-MAW_elapsed > 1.1) {
|
||||
setprop("payload/armament/MAW-active", 0);# resets every 1.1 seconds without warning
|
||||
setprop("payload/armament/MAW-semiactive", 0);
|
||||
}
|
||||
|
||||
# spike handling:
|
||||
@ -1293,16 +1314,16 @@ processCallsignsTimer.start();
|
||||
var code_ct = func () {
|
||||
#ANTIC
|
||||
if (getprop("payload/armament/msg")) {
|
||||
setprop("sim/rendering/redout/enabled", TRUE);
|
||||
setprop("sim/rendering/redout/enabled", 1);
|
||||
#call(func{fgcommand('dialog-close', multiplayer.dialog.dialog.prop())},nil,var err= []);# props.Node.new({"dialog-name": "location-in-air"}));
|
||||
call(func{multiplayer.dialog.del();},nil,var err= []);
|
||||
if (!m28_auto) call(func{multiplayer.dialog.del();},nil,var err= []);
|
||||
if (!getprop("gear/gear[0]/wow")) {
|
||||
call(func{fgcommand('dialog-close', props.Node.new({"dialog-name": "WeightAndFuel"}))},nil,var err2 = []);
|
||||
call(func{fgcommand('dialog-close', props.Node.new({"dialog-name": "system-failures"}))},nil,var err2 = []);
|
||||
call(func{fgcommand('dialog-close', props.Node.new({"dialog-name": "instrument-failures"}))},nil,var err2 = []);
|
||||
}
|
||||
setprop("sim/freeze/fuel",0);
|
||||
setprop("/sim/speed-up", 1);
|
||||
if (!m28_auto) setprop("/sim/speed-up", 1);
|
||||
setprop("/gui/map/draw-traffic", 0);
|
||||
setprop("/sim/marker-pins/traffic", 0);
|
||||
setprop("/sim/gui/dialogs/map-canvas/draw-TFC", 0);
|
||||
@ -1317,7 +1338,7 @@ code_ctTimer.simulatedTime = 1;
|
||||
|
||||
|
||||
|
||||
setprop("/sim/failure-manager/display-on-screen", FALSE);
|
||||
setprop("/sim/failure-manager/display-on-screen", 0);
|
||||
|
||||
code_ctTimer.start();
|
||||
|
||||
@ -1337,6 +1358,22 @@ var re_init = func (node) {
|
||||
}
|
||||
stopLaunch();
|
||||
damageLog.push("Aircraft was repaired due to re-init.");
|
||||
|
||||
# Remove all 3D craters and re-place them. Due to re-init can remove some of them.
|
||||
|
||||
foreach (var thekey ; keys(statics)) {
|
||||
var sta = statics[thekey];
|
||||
if (sta[0] != nil) {
|
||||
sta[0].remove();
|
||||
if (sta[5] == 0) {# TODO: make a hash with all the models
|
||||
sta[0] = geo.put_model(crater_model0, sta[1], sta[2], sta[3], sta[4]);
|
||||
} elsif (sta[5] == 1) {
|
||||
sta[0] = geo.put_model(crater_model1, sta[1], sta[2], sta[3], sta[4]);
|
||||
} elsif (sta[5] == 2) {
|
||||
sta[0] = geo.put_model(crater_model2, sta[1], sta[2], sta[3], sta[4]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#==================================================================
|
||||
@ -1405,6 +1442,7 @@ setlistener("sim/signals/exit", writeDamageLog, 0, 0);
|
||||
|
||||
#screen.property_display.add("payload/armament/MAW-bearing");
|
||||
#screen.property_display.add("payload/armament/MAW-active");
|
||||
#screen.property_display.add("payload/armament/MAW-semiactive");
|
||||
#screen.property_display.add("payload/armament/MLW-bearing");
|
||||
#screen.property_display.add("payload/armament/MLW-count");
|
||||
#screen.property_display.add("payload/armament/MLW-launcher");
|
||||
@ -1412,6 +1450,8 @@ setlistener("sim/signals/exit", writeDamageLog, 0, 0);
|
||||
#screen.property_display.add("payload/armament/spike-air");
|
||||
#screen.property_display.add("payload/armament/spike-gnd-20");
|
||||
#screen.property_display.add("payload/armament/spike-gnd-02");
|
||||
#screen.property_display.add("payload/armament/spike-gnd-05");
|
||||
#screen.property_display.add("payload/armament/spike-gnd-06");
|
||||
#screen.property_display.add("payload/armament/spike-gnd-11");
|
||||
#screen.property_display.add("payload/armament/spike-gnd-23");
|
||||
#screen.property_display.add("payload/armament/spike-gnd-p2");
|
||||
|
@ -34,9 +34,9 @@ var ROUNDS = ROUNDS_init;#CIWS bursts remaining
|
||||
|
||||
var NUM_MISSILES = 5; # total carried minus 1
|
||||
var missile_name = "Volga-M";
|
||||
var missile_brevity = "5Ya23";
|
||||
var missile_max_distance = 36; #max distance of target in nm when it will fire
|
||||
var missile_min_distance = 3.5; #minimum distance in nm when it will fire
|
||||
var missile_brevity = damage.id2warhead[getprop("payload/armament/"~string.lc(missile_name)~"/type-id")][4];
|
||||
var missile_max_distance = getprop("payload/armament/"~string.lc(missile_name)~"/max-fire-range-nm"); #max distance of target in nm when it will fire
|
||||
var missile_min_distance = getprop("payload/armament/"~string.lc(missile_name)~"/min-fire-range-nm"); #minimum distance in nm when it will fire
|
||||
var lockon_time = 12; #time in seconds it takes to lock on and get a firing solution on a target
|
||||
var fire_minimum_interval = 7;# time since last track was initiated till a new can be initiated
|
||||
var same_target_max_missiles = 2;# max number of missiles in air against same target
|
||||
|
@ -1,8 +1,5 @@
|
||||
################### GLOBALS
|
||||
|
||||
var false = 0;
|
||||
var true = 1;
|
||||
|
||||
var AIR = 0;
|
||||
var MARINE = 1;
|
||||
var SURFACE = 2;
|
||||
@ -189,7 +186,7 @@ var scan = func() {
|
||||
#print("dist to target = " ~ dist_to_target);
|
||||
|
||||
var lu = lookup(mp[0].getNode("callsign").getValue());
|
||||
if ( launch_in_progress == 0 and trigger == true and lu != nil and lu.in_air < same_target_max_missiles and !lu.tracking and ACTIVE_MISSILE <= NUM_MISSILES and ( systime() - missile_delay_time > fire_minimum_interval ) ) { #
|
||||
if ( launch_in_progress == 0 and trigger == 1 and lu != nil and lu.in_air < same_target_max_missiles and !lu.tracking and ACTIVE_MISSILE <= NUM_MISSILES and ( systime() - missile_delay_time > fire_minimum_interval ) ) { #
|
||||
#### ... FOR THE MISSILE ####
|
||||
#print("callsign " ~ cs ~ " found at " ~ dist_to_target);
|
||||
missile_delay_time = systime();
|
||||
@ -329,7 +326,7 @@ var clearSingleLock = func () {
|
||||
var fire_control = func(mp, my_pos) {
|
||||
# gather some data about the target
|
||||
|
||||
if ( mp.getNode("valid").getValue() == false ) { return [mp,false,0,0]; }
|
||||
if ( mp.getNode("valid").getValue() == 0 ) { return [mp,0,0,0]; }
|
||||
|
||||
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() * FT2M));
|
||||
var target_distance = my_pos.direct_distance_to(ufo_pos);
|
||||
@ -337,7 +334,7 @@ var fire_control = func(mp, my_pos) {
|
||||
|
||||
# is this plane a friend or foe?
|
||||
var lu = lookup(mp.getNode("callsign").getValue());
|
||||
if ( lu == nil ) { return [mp,false,0,0]; }
|
||||
if ( lu == nil ) { return [mp,0,0,0]; }
|
||||
|
||||
var target_airspeed = mp.getNode("velocities/true-airspeed-kt").getValue();
|
||||
var target_ground_distance = my_pos.distance_to(ufo_pos);
|
||||
@ -350,7 +347,7 @@ var fire_control = func(mp, my_pos) {
|
||||
|
||||
|
||||
# can the radar see it?
|
||||
var data_link_match = false;
|
||||
var data_link_match = 0;
|
||||
# foreach(var cx; gci.data_receive_callsigns) {
|
||||
# if (cx[0] == callsign) {
|
||||
# data_link_match = true;
|
||||
@ -364,8 +361,8 @@ var fire_control = func(mp, my_pos) {
|
||||
if (ciws_installed and ROUNDS > 0 and target_distance*M2NM < ciws_domain_nm) {
|
||||
#CIWS
|
||||
var radarSeeTarget = 1;
|
||||
if ( data_link_match == false ) {
|
||||
if ( visible[0] == false ) {radarSeeTarget = 0 }
|
||||
if ( data_link_match == 0 ) {
|
||||
if ( visible[0] == 0 ) {radarSeeTarget = 0 }
|
||||
if ( target_relative_pitch < radar_lowest_pitch ) { radarSeeTarget = 0 } #
|
||||
if ( target_distance*M2NM > 1.0 and visible[1] and math.abs(target_radial_airspeed) < 20 ) {radarSeeTarget = 0 } # i.e. notching with terrain behind
|
||||
}
|
||||
@ -392,15 +389,15 @@ var fire_control = func(mp, my_pos) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( data_link_match == false ) {
|
||||
if (target_airspeed < 60) {return [mp,false,0,0];}
|
||||
if ( visible[0] == false ) { return [mp,false,0,0]; }
|
||||
if ( target_relative_pitch < radar_lowest_pitch ) { return [mp,false,0,0]; } #
|
||||
if ( visible[1] and math.abs(target_radial_airspeed) < 20 ) { return [mp,false,0,0]; } # i.e. notching, landed aircraft
|
||||
if ( data_link_match == 0 ) {
|
||||
if (target_airspeed < 60) {return [mp,0,0,0];}
|
||||
if ( visible[0] == 0 ) { return [mp,0,0,0]; }
|
||||
if ( target_relative_pitch < radar_lowest_pitch ) { return [mp,0,0,0]; } #
|
||||
if ( visible[1] and math.abs(target_radial_airspeed) < 20 ) { return [mp,0,0,0]; } # i.e. notching, landed aircraft
|
||||
}
|
||||
|
||||
if ( target_distance * M2NM > missile_max_distance ) { return [mp,false,0,0]; }
|
||||
if ( target_distance * M2NM < missile_min_distance ) { return [mp,false,0,0]; }
|
||||
if ( target_distance * M2NM > missile_max_distance ) { return [mp,0,0,0]; }
|
||||
if ( target_distance * M2NM < missile_min_distance ) { return [mp,0,0,0]; }
|
||||
|
||||
|
||||
|
||||
@ -410,7 +407,7 @@ var fire_control = func(mp, my_pos) {
|
||||
# larger offset means it wont fire until the plane is closer.
|
||||
# for visualization: https://www.desmos.com/calculator/gw570fa9km
|
||||
|
||||
if (!isInEngagementEnvelope(target_radial_airspeed, target_ground_distance, target_relative_altitude) ) { return [mp,false,0,0]; }
|
||||
if (!isInEngagementEnvelope(target_radial_airspeed, target_ground_distance, target_relative_altitude) ) { return [mp,0,0,0]; }
|
||||
|
||||
|
||||
|
||||
@ -434,9 +431,9 @@ var fire_control = func(mp, my_pos) {
|
||||
} elsif (priority==PRIO_FAR) {
|
||||
score = target_distance;
|
||||
}
|
||||
return [mp,true,score,1];
|
||||
return [mp,1,score,1];
|
||||
} else {
|
||||
return [mp,false,0,1];
|
||||
return [mp,0,0,1];
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -15,9 +15,6 @@ if ((major == 2017 and minor == 2 and pica >= 1) or (major == 2017 and minor > 2
|
||||
pickingMethod = 1;
|
||||
}
|
||||
|
||||
var FALSE = 0;
|
||||
var TRUE = 1;
|
||||
|
||||
var AIR = 0;
|
||||
var MARINE = 1;
|
||||
var SURFACE = 2;
|
||||
@ -124,10 +121,10 @@ var Contact = {
|
||||
isValid: func () {
|
||||
var valid = me.valid.getValue();
|
||||
if (valid == nil) {
|
||||
valid = FALSE;
|
||||
valid = 0;
|
||||
}
|
||||
if (me.callsign.getValue() != me.orig_callsign) {
|
||||
valid = FALSE;
|
||||
valid = 0;
|
||||
}
|
||||
return valid;
|
||||
},
|
||||
|
@ -27,8 +27,6 @@ var mlw_max=getprop("payload/d-config/mlw_max"); #
|
||||
var auto_flare_caller = getprop("payload/d-config/auto_flare_caller"); # If damage.nas should detect flare releases, or if function is called from somewhere in aircraft
|
||||
############################################################################################################################
|
||||
|
||||
var TRUE = 1;
|
||||
var FALSE = 0;
|
||||
|
||||
var hp = hp_max;
|
||||
setprop("sam/damage", math.max(0,100*hp/hp_max));#used in HUD
|
||||
@ -164,7 +162,9 @@ var warheads = {
|
||||
"pilot": [93, 0.00,1,0],# ejected pilot
|
||||
"BETAB-500ShP": [94, 1160.00,1,0],
|
||||
"Flare": [95, 0.00,0,0],
|
||||
"3M9": [96, 125.00,0,0],# 3M9 Missile used with 2K12/SA-6
|
||||
"3M9": [96, 125.00,0,0],# 3M9M3 Missile used with 2K12/SA-6
|
||||
"5V28V": [97, 478.00,0,0],# Missile used with S-200D/SA-5
|
||||
"AIM-9X": [98, 20.80,0,0],
|
||||
};
|
||||
|
||||
var AIR_RADAR = "air";
|
||||
@ -189,7 +189,8 @@ var radar_signatures = {
|
||||
"E-8R": AIR_RADAR,
|
||||
"EC-137D": AIR_RADAR,
|
||||
"Mig-28": AIR_RADAR,
|
||||
"SA-6": AIR_RADAR,#Air radar tone chosen so that there is at least some lock tone until asset-specific is created
|
||||
"SA-6": "gnd-06",#Air radar tone chosen so that there is at least some lock tone until asset-specific is created
|
||||
"s-200": "gnd-05",
|
||||
"ZSU-23-4M": "gnd-23",
|
||||
"S-75": "gnd-02",
|
||||
"buk-m2": "gnd-11",
|
||||
@ -203,7 +204,7 @@ var radar_signatures = {
|
||||
var id2warhead = [];
|
||||
var launched = {};# callsign: elapsed-sec
|
||||
var approached = {};# callsign: uniqueID
|
||||
var heavy_smoke = [61,62,63,65,92,96];
|
||||
var heavy_smoke = [61,62,63,65,92,96,97];
|
||||
|
||||
var k = keys(warheads);
|
||||
|
||||
@ -241,6 +242,10 @@ for(var myid = 0;myid<size(k);myid+=1) {
|
||||
}
|
||||
}
|
||||
|
||||
var crater_model0 = getprop("payload/armament/models") ~ "crater_small.xml";
|
||||
var crater_model1 = getprop("payload/armament/models") ~ "crater_big.xml";
|
||||
var crater_model2 = getprop("payload/armament/models") ~ "bomb_hit_smoke.xml";
|
||||
|
||||
#==================================================================
|
||||
# Notification processing
|
||||
#==================================================================
|
||||
@ -281,6 +286,7 @@ var DamageRecipient =
|
||||
# " Flags=",notification.Flags,
|
||||
# " Radar=",bits.test(notification.Flags, 0),
|
||||
# " Thrust=",bits.test(notification.Flags, 1));
|
||||
# " CWI=",bits.test(notification.Flags, 2));
|
||||
#
|
||||
# todo:
|
||||
# animate missiles
|
||||
@ -301,6 +307,7 @@ var DamageRecipient =
|
||||
var bearing = ownPos.course_to(notification.Position);
|
||||
var radarOn = bits.test(notification.Flags, 0);
|
||||
var thrustOn = bits.test(notification.Flags, 1);
|
||||
var CWIOn = bits.test(notification.Flags, 2);
|
||||
var index = notification.SecondaryKind-21;
|
||||
var typ = id2warhead[index];
|
||||
|
||||
@ -334,7 +341,7 @@ var DamageRecipient =
|
||||
dynamics["noti_"~notification.Callsign~"_"~notification.UniqueIdentity] = [systime()-(time_before_delete-1.6), notification.Position.lat(), notification.Position.lon(), notification.Position.alt(), notification.u_fps, notification.Heading, notification.Pitch,-1]
|
||||
}
|
||||
|
||||
if (tacview_supported and getprop("sim/multiplay/txhost") != "mpserver.opredflag.com") {
|
||||
if (tacview_supported and (getprop("sim/multiplay/txhost") != "mpserver.opredflag.com" or m28_auto)) {
|
||||
if (tacview.starttime) {
|
||||
var tacID = left(md5(notification.Callsign~notification.UniqueIdentity),6);
|
||||
if (notification.Kind == DESTROY) {
|
||||
@ -348,7 +355,7 @@ var DamageRecipient =
|
||||
var extra2 = typ[2]==0?",Type=Weapon+Missile":",Type=Weapon+Bomb";
|
||||
extra2 = typ[4]=="Flare"?",Type=Flare":extra2;
|
||||
extra2 = typp=="Parachutist"?"":extra2;
|
||||
var color = radarOn?",Color=Red":",Color=Yellow";
|
||||
var color = radarOn or CWIOn?",Color=Red":",Color=Yellow";
|
||||
thread.lock(tacview.mutexWrite);
|
||||
tacview.write("#" ~ (systime() - tacview.starttime)~"\n");
|
||||
tacview.write(tacID~",T="~notification.Position.lon()~"|"~notification.Position.lat()~"|"~notification.Position.alt()~extra~",Name="~typp~color~extra2~"\n");
|
||||
@ -376,9 +383,10 @@ var DamageRecipient =
|
||||
setprop("payload/armament/MLW-launcher", notification.Callsign);
|
||||
setprop("payload/armament/MLW-count", getprop("payload/armament/MLW-count")+1);
|
||||
var out = sprintf("Missile Launch Warning from %03d degrees.", bearing);
|
||||
if (rwr_to_screen) screen.log.write(out, 1,1,0);# temporary till someone models a RWR in RIO seat
|
||||
if (rwr_to_screen) screen.log.write(out, 1,0.5,0);# temporary till someone models a RWR in RIO seat
|
||||
print(out);
|
||||
damageLog.push(sprintf("Missile Launch Warning from %03d degrees from %s.", bearing, notification.Callsign));
|
||||
if (m28_auto) mig28.missileLaunch();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -386,19 +394,29 @@ var DamageRecipient =
|
||||
# Missile approach warning:
|
||||
var callsign = processCallsign(getprop("sim/multiplay/callsign"));
|
||||
if (notification.RemoteCallsign != callsign) return emesary.Transmitter.ReceiptStatus_OK;
|
||||
if (!radarOn) return emesary.Transmitter.ReceiptStatus_OK;# this should be little more complex later
|
||||
var heading = getprop("orientation/heading-deg");
|
||||
var clock = geo.normdeg(bearing - heading);
|
||||
setprop("payload/armament/MAW-bearing", bearing);
|
||||
setprop("payload/armament/MAW-active", 1);# resets every 1 seconds
|
||||
if (!radarOn and !CWIOn) return emesary.Transmitter.ReceiptStatus_OK;# this should be little more complex later
|
||||
#var heading = getprop("orientation/heading-deg");
|
||||
#var clock = geo.normdeg(bearing - heading);
|
||||
if (radarOn) {
|
||||
setprop("payload/armament/MAW-bearing", bearing);
|
||||
setprop("payload/armament/MAW-active", 1);# resets every 1 seconds
|
||||
} elsif (CWIOn) {
|
||||
setprop("payload/armament/MAW-semiactive", 1);# resets every 1 seconds
|
||||
}
|
||||
MAW_elapsed = elapsed;
|
||||
var appr = approached[notification.Callsign~notification.UniqueIdentity];
|
||||
if (appr == nil or elapsed - appr > 450) {
|
||||
printf("Missile Approach Warning from %03d degrees.", bearing);
|
||||
damageLog.push(sprintf("Missile Approach Warning from %03d degrees from %s.", bearing, notification.Callsign));
|
||||
if (rwr_to_screen) screen.log.write(sprintf("Missile Approach Warning from %03d degrees.", bearing), 1,1,0);# temporary till someone models a RWR in RIO seat
|
||||
if (radarOn) {
|
||||
#printf("Missile Approach Warning from %03d degrees.", bearing);
|
||||
damageLog.push(sprintf("Missile Approach Warning from %03d degrees from %s.", bearing, notification.Callsign));
|
||||
if (rwr_to_screen) screen.log.write(sprintf("Missile Approach Warning from %03d degrees.", bearing), 1,0.5,0);# temporary till someone models a RWR in RIO seat
|
||||
} else {
|
||||
#printf("Missile Approach Warning");
|
||||
damageLog.push(sprintf("Missile Approach Warning from %s.", notification.Callsign));
|
||||
if (rwr_to_screen) screen.log.write(sprintf("Missile Approach Warning (semi-active)."), 1,0.5,0);# temporary till someone models a RWR in RIO seat
|
||||
}
|
||||
approached[notification.Callsign~notification.UniqueIdentity] = elapsed;
|
||||
if (m28_auto) mig28.engagedBy(notification.Callsign);
|
||||
if (m28_auto) mig28.engagedBy(notification.Callsign, 1);
|
||||
}
|
||||
return emesary.Transmitter.ReceiptStatus_OK;
|
||||
}
|
||||
@ -415,7 +433,7 @@ var DamageRecipient =
|
||||
# debug.dump(notification);
|
||||
#
|
||||
#
|
||||
if (tacview_supported and tacview.starttime and getprop("sim/multiplay/txhost") != "mpserver.opredflag.com") {
|
||||
if (tacview_supported and tacview.starttime and (getprop("sim/multiplay/txhost") != "mpserver.opredflag.com" or m28_auto)) {
|
||||
var node = getCallsign(notification.RemoteCallsign);
|
||||
if (node != nil and notification.SecondaryKind > 20) {
|
||||
# its a warhead
|
||||
@ -439,9 +457,10 @@ var DamageRecipient =
|
||||
var callsign = processCallsign(getprop("sim/multiplay/callsign"));
|
||||
if (notification.RemoteCallsign == callsign and getprop("payload/armament/msg") == 1) {
|
||||
#damage enabled and were getting hit
|
||||
if (m28_auto) mig28.engagedBy(notification.Callsign);
|
||||
|
||||
if (notification.SecondaryKind < 0 and hitable_by_cannon) {
|
||||
# cannon hit
|
||||
if (m28_auto) mig28.engagedBy(notification.Callsign, 0);
|
||||
var probability = id2shell[-1*notification.SecondaryKind-1][1];
|
||||
var typ = id2shell[-1*notification.SecondaryKind-1][2];
|
||||
var hit_count = notification.Distance;
|
||||
@ -457,6 +476,7 @@ var DamageRecipient =
|
||||
}
|
||||
} elsif (notification.SecondaryKind > 20) {
|
||||
# its a warhead
|
||||
if (m28_auto) mig28.engagedBy(notification.Callsign, 1);
|
||||
var dist = notification.Distance;
|
||||
var wh = id2warhead[notification.SecondaryKind - 21];
|
||||
var type = wh[4];#test code
|
||||
@ -549,21 +569,18 @@ var DamageRecipient =
|
||||
}
|
||||
if (notification.Kind == CREATE and getprop("payload/armament/enable-craters") == 1 and statics["obj_"~notification.UniqueIdentity] == nil) {
|
||||
if (notification.SecondaryKind == 0) {# TODO: make a hash with all the models
|
||||
var crater_model = getprop("payload/armament/models") ~ "crater_small.xml";
|
||||
var static = geo.put_model(crater_model, notification.Position.lat(), notification.Position.lon(), notification.Position.alt(), notification.Heading);
|
||||
var static = geo.put_model(crater_model0, notification.Position.lat(), notification.Position.lon(), notification.Position.alt(), notification.Heading);
|
||||
if (static != nil) {
|
||||
statics["obj_"~notification.UniqueIdentity] = [static, notification.Position.lat(), notification.Position.lon(), notification.Position.alt(), notification.Heading, notification.SecondaryKind];
|
||||
#static is a PropertyNode inside /models
|
||||
}
|
||||
} elsif (notification.SecondaryKind == 1) {
|
||||
var crater_model = getprop("payload/armament/models") ~ "crater_big.xml";
|
||||
var static = geo.put_model(crater_model, notification.Position.lat(), notification.Position.lon(), notification.Position.alt(), notification.Heading);
|
||||
var static = geo.put_model(crater_model1, notification.Position.lat(), notification.Position.lon(), notification.Position.alt(), notification.Heading);
|
||||
if (static != nil) {
|
||||
statics["obj_"~notification.UniqueIdentity] = [static, notification.Position.lat(), notification.Position.lon(), notification.Position.alt(), notification.Heading, notification.SecondaryKind];
|
||||
}
|
||||
} elsif (notification.SecondaryKind == 2) {
|
||||
var crater_model = getprop("payload/armament/models") ~ "bomb_hit_smoke.xml";
|
||||
var static = geo.put_model(crater_model, notification.Position.lat(), notification.Position.lon(), notification.Position.alt(), notification.Heading);
|
||||
var static = geo.put_model(crater_model2, notification.Position.lat(), notification.Position.lon(), notification.Position.alt(), notification.Heading);
|
||||
if (static != nil) {
|
||||
statics["obj_"~notification.UniqueIdentity] = [static, notification.Position.lat(), notification.Position.lon(), notification.Position.alt(), notification.Heading, notification.SecondaryKind];
|
||||
}
|
||||
@ -863,6 +880,7 @@ var flare_update_time = 0.4;
|
||||
var flare_duration = 8;
|
||||
var flare_terminal_speed = 50;#m/s
|
||||
var flares_max_process_per_loop = 4;
|
||||
var flare_sequencer = -120;
|
||||
|
||||
var flare_sorter = func(a, b) {
|
||||
if(a[0] < b[0]){
|
||||
@ -945,7 +963,9 @@ var flare_released = func {
|
||||
getprop("orientation/heading-deg"),
|
||||
FT2M*getprop("velocities/speed-down-fps"),
|
||||
FT2M*math.sqrt(getprop("velocities/speed-north-fps")*getprop("velocities/speed-north-fps")+getprop("velocities/speed-east-fps")*getprop("velocities/speed-east-fps")),
|
||||
int(rand()*240)-120];
|
||||
flare_sequencer];
|
||||
flare_sequencer += 1;
|
||||
if (flare_sequencer > 120) flare_sequencer = -120;
|
||||
append(flare_list, flare);
|
||||
var msg = notifications.ObjectInFlightNotification.new("ffly", flare[6], MOVE, 21+95);
|
||||
msg.Flags = 0;
|
||||
@ -1233,7 +1253,7 @@ var processCallsigns = func () {
|
||||
var painted = 0;
|
||||
var paint_list = [];
|
||||
foreach (var player; players) {
|
||||
if(player.getChild("valid") != nil and player.getChild("valid").getValue() == TRUE and player.getChild("callsign") != nil and player.getChild("callsign").getValue() != "" and player.getChild("callsign").getValue() != nil) {
|
||||
if(player.getChild("valid") != nil and player.getChild("valid").getValue() == 1 and player.getChild("callsign") != nil and player.getChild("callsign").getValue() != "" and player.getChild("callsign").getValue() != nil) {
|
||||
var callsign = player.getChild("callsign").getValue();
|
||||
callsign_struct[callsign] = player;
|
||||
var str6 = player.getNode("sim/multiplay/generic/string[6]");
|
||||
@ -1247,6 +1267,7 @@ var processCallsigns = func () {
|
||||
}
|
||||
if (getprop("sim/time/elapsed-sec")-MAW_elapsed > 1.1) {
|
||||
setprop("payload/armament/MAW-active", 0);# resets every 1.1 seconds without warning
|
||||
setprop("payload/armament/MAW-semiactive", 0);
|
||||
}
|
||||
|
||||
# spike handling:
|
||||
@ -1293,16 +1314,16 @@ processCallsignsTimer.start();
|
||||
var code_ct = func () {
|
||||
#ANTIC
|
||||
if (getprop("payload/armament/msg")) {
|
||||
setprop("sim/rendering/redout/enabled", TRUE);
|
||||
setprop("sim/rendering/redout/enabled", 1);
|
||||
#call(func{fgcommand('dialog-close', multiplayer.dialog.dialog.prop())},nil,var err= []);# props.Node.new({"dialog-name": "location-in-air"}));
|
||||
call(func{multiplayer.dialog.del();},nil,var err= []);
|
||||
if (!m28_auto) call(func{multiplayer.dialog.del();},nil,var err= []);
|
||||
if (!getprop("gear/gear[0]/wow")) {
|
||||
call(func{fgcommand('dialog-close', props.Node.new({"dialog-name": "WeightAndFuel"}))},nil,var err2 = []);
|
||||
call(func{fgcommand('dialog-close', props.Node.new({"dialog-name": "system-failures"}))},nil,var err2 = []);
|
||||
call(func{fgcommand('dialog-close', props.Node.new({"dialog-name": "instrument-failures"}))},nil,var err2 = []);
|
||||
}
|
||||
setprop("sim/freeze/fuel",0);
|
||||
setprop("/sim/speed-up", 1);
|
||||
if (!m28_auto) setprop("/sim/speed-up", 1);
|
||||
setprop("/gui/map/draw-traffic", 0);
|
||||
setprop("/sim/marker-pins/traffic", 0);
|
||||
setprop("/sim/gui/dialogs/map-canvas/draw-TFC", 0);
|
||||
@ -1317,7 +1338,7 @@ code_ctTimer.simulatedTime = 1;
|
||||
|
||||
|
||||
|
||||
setprop("/sim/failure-manager/display-on-screen", FALSE);
|
||||
setprop("/sim/failure-manager/display-on-screen", 0);
|
||||
|
||||
code_ctTimer.start();
|
||||
|
||||
@ -1337,6 +1358,22 @@ var re_init = func (node) {
|
||||
}
|
||||
stopLaunch();
|
||||
damageLog.push("Aircraft was repaired due to re-init.");
|
||||
|
||||
# Remove all 3D craters and re-place them. Due to re-init can remove some of them.
|
||||
|
||||
foreach (var thekey ; keys(statics)) {
|
||||
var sta = statics[thekey];
|
||||
if (sta[0] != nil) {
|
||||
sta[0].remove();
|
||||
if (sta[5] == 0) {# TODO: make a hash with all the models
|
||||
sta[0] = geo.put_model(crater_model0, sta[1], sta[2], sta[3], sta[4]);
|
||||
} elsif (sta[5] == 1) {
|
||||
sta[0] = geo.put_model(crater_model1, sta[1], sta[2], sta[3], sta[4]);
|
||||
} elsif (sta[5] == 2) {
|
||||
sta[0] = geo.put_model(crater_model2, sta[1], sta[2], sta[3], sta[4]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#==================================================================
|
||||
@ -1405,6 +1442,7 @@ setlistener("sim/signals/exit", writeDamageLog, 0, 0);
|
||||
|
||||
#screen.property_display.add("payload/armament/MAW-bearing");
|
||||
#screen.property_display.add("payload/armament/MAW-active");
|
||||
#screen.property_display.add("payload/armament/MAW-semiactive");
|
||||
#screen.property_display.add("payload/armament/MLW-bearing");
|
||||
#screen.property_display.add("payload/armament/MLW-count");
|
||||
#screen.property_display.add("payload/armament/MLW-launcher");
|
||||
@ -1412,6 +1450,8 @@ setlistener("sim/signals/exit", writeDamageLog, 0, 0);
|
||||
#screen.property_display.add("payload/armament/spike-air");
|
||||
#screen.property_display.add("payload/armament/spike-gnd-20");
|
||||
#screen.property_display.add("payload/armament/spike-gnd-02");
|
||||
#screen.property_display.add("payload/armament/spike-gnd-05");
|
||||
#screen.property_display.add("payload/armament/spike-gnd-06");
|
||||
#screen.property_display.add("payload/armament/spike-gnd-11");
|
||||
#screen.property_display.add("payload/armament/spike-gnd-23");
|
||||
#screen.property_display.add("payload/armament/spike-gnd-p2");
|
||||
|
@ -35,9 +35,9 @@ var ROUNDS = ROUNDS_init;#CIWS bursts remaining
|
||||
|
||||
var NUM_MISSILES = 2; # total carried minus 1
|
||||
var missile_name = "m3m9";
|
||||
var missile_brevity = "3M9";
|
||||
var missile_max_distance = 18; #max distance of target in nm when it will fire
|
||||
var missile_min_distance = 0.5; #minimum distance in nm when it will fire
|
||||
var missile_brevity = damage.id2warhead[getprop("payload/armament/"~string.lc(missile_name)~"/type-id")][4];
|
||||
var missile_max_distance = getprop("payload/armament/"~string.lc(missile_name)~"/max-fire-range-nm"); #max distance of target in nm when it will fire
|
||||
var missile_min_distance = getprop("payload/armament/"~string.lc(missile_name)~"/min-fire-range-nm"); #minimum distance in nm when it will fire
|
||||
var lockon_time = 24; #time in seconds it takes to lock on and get a firing solution on a target
|
||||
var fire_minimum_interval = 7;# time since last track was initiated till a new can be initiated
|
||||
var same_target_max_missiles = 2;# max number of missiles in air against same target
|
||||
|
@ -1,8 +1,5 @@
|
||||
################### GLOBALS
|
||||
|
||||
var false = 0;
|
||||
var true = 1;
|
||||
|
||||
var AIR = 0;
|
||||
var MARINE = 1;
|
||||
var SURFACE = 2;
|
||||
@ -189,7 +186,7 @@ var scan = func() {
|
||||
#print("dist to target = " ~ dist_to_target);
|
||||
|
||||
var lu = lookup(mp[0].getNode("callsign").getValue());
|
||||
if ( launch_in_progress == 0 and trigger == true and lu != nil and lu.in_air < same_target_max_missiles and !lu.tracking and ACTIVE_MISSILE <= NUM_MISSILES and ( systime() - missile_delay_time > fire_minimum_interval ) ) { #
|
||||
if ( launch_in_progress == 0 and trigger == 1 and lu != nil and lu.in_air < same_target_max_missiles and !lu.tracking and ACTIVE_MISSILE <= NUM_MISSILES and ( systime() - missile_delay_time > fire_minimum_interval ) ) { #
|
||||
#### ... FOR THE MISSILE ####
|
||||
#print("callsign " ~ cs ~ " found at " ~ dist_to_target);
|
||||
missile_delay_time = systime();
|
||||
@ -329,7 +326,7 @@ var clearSingleLock = func () {
|
||||
var fire_control = func(mp, my_pos) {
|
||||
# gather some data about the target
|
||||
|
||||
if ( mp.getNode("valid").getValue() == false ) { return [mp,false,0,0]; }
|
||||
if ( mp.getNode("valid").getValue() == 0 ) { return [mp,0,0,0]; }
|
||||
|
||||
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() * FT2M));
|
||||
var target_distance = my_pos.direct_distance_to(ufo_pos);
|
||||
@ -337,7 +334,7 @@ var fire_control = func(mp, my_pos) {
|
||||
|
||||
# is this plane a friend or foe?
|
||||
var lu = lookup(mp.getNode("callsign").getValue());
|
||||
if ( lu == nil ) { return [mp,false,0,0]; }
|
||||
if ( lu == nil ) { return [mp,0,0,0]; }
|
||||
|
||||
var target_airspeed = mp.getNode("velocities/true-airspeed-kt").getValue();
|
||||
var target_ground_distance = my_pos.distance_to(ufo_pos);
|
||||
@ -350,7 +347,7 @@ var fire_control = func(mp, my_pos) {
|
||||
|
||||
|
||||
# can the radar see it?
|
||||
var data_link_match = false;
|
||||
var data_link_match = 0;
|
||||
# foreach(var cx; gci.data_receive_callsigns) {
|
||||
# if (cx[0] == callsign) {
|
||||
# data_link_match = true;
|
||||
@ -364,8 +361,8 @@ var fire_control = func(mp, my_pos) {
|
||||
if (ciws_installed and ROUNDS > 0 and target_distance*M2NM < ciws_domain_nm) {
|
||||
#CIWS
|
||||
var radarSeeTarget = 1;
|
||||
if ( data_link_match == false ) {
|
||||
if ( visible[0] == false ) {radarSeeTarget = 0 }
|
||||
if ( data_link_match == 0 ) {
|
||||
if ( visible[0] == 0 ) {radarSeeTarget = 0 }
|
||||
if ( target_relative_pitch < radar_lowest_pitch ) { radarSeeTarget = 0 } #
|
||||
if ( target_distance*M2NM > 1.0 and visible[1] and math.abs(target_radial_airspeed) < 20 ) {radarSeeTarget = 0 } # i.e. notching with terrain behind
|
||||
}
|
||||
@ -392,15 +389,15 @@ var fire_control = func(mp, my_pos) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( data_link_match == false ) {
|
||||
if (target_airspeed < 60) {return [mp,false,0,0];}
|
||||
if ( visible[0] == false ) { return [mp,false,0,0]; }
|
||||
if ( target_relative_pitch < radar_lowest_pitch ) { return [mp,false,0,0]; } #
|
||||
if ( visible[1] and math.abs(target_radial_airspeed) < 20 ) { return [mp,false,0,0]; } # i.e. notching, landed aircraft
|
||||
if ( data_link_match == 0 ) {
|
||||
if (target_airspeed < 60) {return [mp,0,0,0];}
|
||||
if ( visible[0] == 0 ) { return [mp,0,0,0]; }
|
||||
if ( target_relative_pitch < radar_lowest_pitch ) { return [mp,0,0,0]; } #
|
||||
if ( visible[1] and math.abs(target_radial_airspeed) < 20 ) { return [mp,0,0,0]; } # i.e. notching, landed aircraft
|
||||
}
|
||||
|
||||
if ( target_distance * M2NM > missile_max_distance ) { return [mp,false,0,0]; }
|
||||
if ( target_distance * M2NM < missile_min_distance ) { return [mp,false,0,0]; }
|
||||
if ( target_distance * M2NM > missile_max_distance ) { return [mp,0,0,0]; }
|
||||
if ( target_distance * M2NM < missile_min_distance ) { return [mp,0,0,0]; }
|
||||
|
||||
|
||||
|
||||
@ -410,7 +407,7 @@ var fire_control = func(mp, my_pos) {
|
||||
# larger offset means it wont fire until the plane is closer.
|
||||
# for visualization: https://www.desmos.com/calculator/gw570fa9km
|
||||
|
||||
if (!isInEngagementEnvelope(target_radial_airspeed, target_ground_distance, target_relative_altitude) ) { return [mp,false,0,0]; }
|
||||
if (!isInEngagementEnvelope(target_radial_airspeed, target_ground_distance, target_relative_altitude) ) { return [mp,0,0,0]; }
|
||||
|
||||
|
||||
|
||||
@ -434,9 +431,9 @@ var fire_control = func(mp, my_pos) {
|
||||
} elsif (priority==PRIO_FAR) {
|
||||
score = target_distance;
|
||||
}
|
||||
return [mp,true,score,1];
|
||||
return [mp,1,score,1];
|
||||
} else {
|
||||
return [mp,false,0,1];
|
||||
return [mp,0,0,1];
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -15,9 +15,6 @@ if ((major == 2017 and minor == 2 and pica >= 1) or (major == 2017 and minor > 2
|
||||
pickingMethod = 1;
|
||||
}
|
||||
|
||||
var FALSE = 0;
|
||||
var TRUE = 1;
|
||||
|
||||
var AIR = 0;
|
||||
var MARINE = 1;
|
||||
var SURFACE = 2;
|
||||
@ -124,10 +121,10 @@ var Contact = {
|
||||
isValid: func () {
|
||||
var valid = me.valid.getValue();
|
||||
if (valid == nil) {
|
||||
valid = FALSE;
|
||||
valid = 0;
|
||||
}
|
||||
if (me.callsign.getValue() != me.orig_callsign) {
|
||||
valid = FALSE;
|
||||
valid = 0;
|
||||
}
|
||||
return valid;
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user