diff --git a/MIM-104D/MIM-104D-set.xml b/MIM-104D/MIM-104D-set.xml
index 042ec5a..7763baf 100644
--- a/MIM-104D/MIM-104D-set.xml
+++ b/MIM-104D/MIM-104D-set.xml
@@ -303,7 +303,7 @@
0.00
0.15
0.1
- radar
+ tvm
APN3003
true
@@ -333,7 +333,7 @@
false
45
0
- 0.96
+ 0.93
3
A
Bird away
diff --git a/MIM-104D/Nasal/fire-control.nas b/MIM-104D/Nasal/fire-control.nas
index 65598ff..82248f4 100644
--- a/MIM-104D/Nasal/fire-control.nas
+++ b/MIM-104D/Nasal/fire-control.nas
@@ -232,7 +232,14 @@ var scan = func() {
radarOn = 1;
}
}
-
+ if (getprop("payload/armament/"~string.lc(missile_name)~"/guidance") == "tvm" and !radarOn) {
+ foreach(var tgt ; targetsV2.vector) {
+ if (tgt.in_air > 0) {
+ radarOn = 1;
+ break;
+ }
+ }
+ }
setprop("/sim/multiplay/generic/int[2]",!radarOn);
if (launcher_align_to_target and ACTIVE_MISSILE > NUM_MISSILES and systime()-missile_release_time > 2) {
@@ -542,7 +549,7 @@ var missile_launch = func(mp, launchtime, my_pos) {
setprop("sam/info", info);
if (mp.getNode("callsign") != nil and mp.getNode("callsign").getValue() != nil and mp.getNode("callsign").getValue() != "") {
- setprop("sim/multiplay/generic/string[6]", left(md5(mp.getNode("callsign").getValue()), 4));
+ if (getprop("payload/armament/"~string.lc(missile_name)~"/guidance") != "tvm") setprop("sim/multiplay/generic/string[6]", left(md5(mp.getNode("callsign").getValue()), 4));
datalink.send_data({"contacts":[{"callsign":mp.getNode("callsign").getValue(),"iff":0}]});
} else {
clearSingleLock();
diff --git a/MIM-104D/Nasal/guided-missiles.nas b/MIM-104D/Nasal/guided-missiles.nas
index 03a7ab5..98f3b94 100644
--- a/MIM-104D/Nasal/guided-missiles.nas
+++ b/MIM-104D/Nasal/guided-missiles.nas
@@ -111,13 +111,10 @@ var fox2_unique_id = -100; # each missile needs to have a unique numeric ID
var SIM_TIME = 0;
var REAL_TIME = 1;
-var TRUE = 1;
-var FALSE = 0;
-
# enables the AIM-9 aiming reticle (F-14) - doesn't require the radar to be in TWS
var use_fg_default_hud = getprop("payload/armament/use-fg-default-hud");
if (use_fg_default_hud == nil) {
- use_fg_default_hud = FALSE;
+ use_fg_default_hud = 0;
}
var MISSILE_STANDBY = -1;
@@ -153,7 +150,7 @@ var SLUGS2LBM = 32.1740485564;
var LBM2SLUGS = 1/SLUGS2LBM;
var slugs_to_lbm = SLUGS2LBM;# since various aircraft use this from outside missile, leaving it for backwards compat.
-var first_in_air = FALSE;# first missile is in the air, other missiles should not write to MP.
+var first_in_air = 0;# first missile is in the air, other missiles should not write to MP.
var first_in_air_max_sec = 30;
var versionString = getprop("sim/version/flightgear");
@@ -161,13 +158,13 @@ var version = split(".", versionString);
var major = num(version[0]);
var minor = num(version[1]);
var pica = num(version[2]);
-var pickingMethod = FALSE;
+var pickingMethod = 0;
if ((major == 2017 and minor == 2 and pica >= 1) or (major == 2017 and minor > 2) or major > 2017) {
- pickingMethod = TRUE;
+ pickingMethod = 1;
}
-var offsetMethod = FALSE;
+var offsetMethod = 0;
if ((major == 2017 and minor == 2 and pica >= 1) or (major == 2017 and minor > 2) or major > 2017) {
- offsetMethod = TRUE;
+ offsetMethod = 1;
}
var wingedGuideFactor = 0.1;
@@ -238,7 +235,7 @@ var AIM = {
m.type_lc = string.lc(type);
m.type = type;
- m.deleted = FALSE;
+ m.deleted = 0;
m.status = MISSILE_STANDBY; # -1 = stand-by, 0 = searching, 1 = locked, 2 = fired.
m.free = 0; # 0 = status fired with lock, 1 = status fired but having lost lock.
@@ -255,7 +252,7 @@ var AIM = {
if (m.SwSoundVol.getValue() == nil) {
m.SwSoundVol.setDoubleValue(0);
}
- m.tacview_support = getprop("payload/armament/tacview");# set to false, unless using an aircraft that has tacview
+ m.tacview_support = getprop("payload/d-config/tacview_supported");# set to false, unless using an aircraft that has tacview
m.gnd_launch = getprop("payload/armament/gnd-launch");#true to be a SAM or ship
if (m.gnd_launch == nil) {
m.gnd_launch = 0;
@@ -317,7 +314,7 @@ var AIM = {
m.asc = getprop(m.nodeString~"attack-steering-cue-enabled");# Bool. ASC enabled.
# navigation, guiding and seekerhead
m.max_seeker_dev = getprop(m.nodeString~"seeker-field-deg") / 2; # missiles own seekers total FOV diameter.
- m.guidance = getprop(m.nodeString~"guidance"); # heat/radar/semi-radar/laser/gps/vision/unguided/level/gyro-pitch/radiation/inertial/remote/remote-stable/command/sample
+ m.guidance = getprop(m.nodeString~"guidance"); # heat/radar/semi-radar/tvm/laser/gps/gps-laser/vision/unguided/level/gyro-pitch/radiation/inertial/remote/remote-stable/command/sample
m.guidanceLaw = getprop(m.nodeString~"navigation"); # guidance-law: direct/direct-alt/OPN/PN/APN/PNxxyy/APNxxyy/LOS (use direct for pure pursuit, use PN for A/A missiles, use APN for modern SAM missiles PN for older, use PNxxyy/APNxxyy for surface to air where xx is degrees to aim above target, yy is seconds it will do that). GPN is APN for winged glidebombs.
m.guidanceLawHorizInit = getprop(m.nodeString~"navigation-init-pure-15"); # Bool. Guide in horizontal plane using pure pursuit until target with 15 deg of nose, before switching to
m.pro_constant = getprop(m.nodeString~"proportionality-constant"); # Constant for how sensitive proportional navigation is to target speed/acc. Normally between 3-6. [optional]
@@ -415,7 +412,7 @@ var AIM = {
m.eject_speed = 0;
}
- if (m.rail_forward == TRUE) {
+ if (m.rail_forward == 1) {
m.rail_pitch_deg = 0;
m.rail_head_deg = 0;
}
@@ -472,10 +469,10 @@ var AIM = {
m.ready_time = 0;
}
if (m.coolable == nil) {
- m.coolable = FALSE;
+ m.coolable = 0;
}
if (m.intoBore == nil) {
- m.intoBore = FALSE;
+ m.intoBore = 0;
}
if (m.lateralSpeed == nil) {
@@ -487,7 +484,7 @@ var AIM = {
}
if(m.loal == nil) {
- m.loal = FALSE;
+ m.loal = 0;
}
if(m.Cd_delta == nil) {
@@ -499,7 +496,7 @@ var AIM = {
}
if(m.canSwitch == nil) {
- m.canSwitch = FALSE;
+ m.canSwitch = 0;
}
if(m.terminal_alt_factor == nil) {
@@ -518,7 +515,7 @@ var AIM = {
m.weight_fuel_lbm = 0;
}
if (m.data == nil) {
- m.data = FALSE;
+ m.data = 0;
}
if (m.stage_1_jet == nil) {
m.stage_1_jet = 0;
@@ -533,7 +530,7 @@ var AIM = {
m.jet_effectiveness = 0.75;
}
if (m.vector_thrust == nil) {
- m.vector_thrust = FALSE;
+ m.vector_thrust = 0;
}
if (m.flareResistance == nil or !m.gnd_launch) {
m.flareResistance = 0.85;
@@ -572,16 +569,16 @@ var AIM = {
m.stage_3_duration = 0;
}
if (m.destruct_when_free == nil) {
- m.destruct_when_free = FALSE;
+ m.destruct_when_free = 0;
}
if (m.reaquire == nil) {
- if (m.guidance == "semi-radar" or m.guidance == "laser" or m.guidance == "heat" or m.guidance == "vision") {
- m.reaquire = TRUE;
+ if (m.guidance == "semi-radar" or m.guidance == "laser" or m.guidance == "heat" or m.guidance == "vision" or m.guidance == "tvm") {
+ m.reaquire = 1;
} else {
- m.reaquire = FALSE;
+ m.reaquire = 0;
}
}
- if (m.rail == TRUE) {
+ if (m.rail == 1) {
# drop distance in time
m.drop_time = 0;
} elsif (m.drop_time == nil) {
@@ -603,16 +600,16 @@ var AIM = {
m.switchTime = m.beam_width_deg*m.max_seeker_dev*0.05;
}
if(m.multiHit == nil) {
- m.multiHit = FALSE;
+ m.multiHit = 0;
}
if(m.inert == nil) {
- m.inert = FALSE;
+ m.inert = 0;
}
if(m.engineEnabled == nil) {
- m.engineEnabled = TRUE;
+ m.engineEnabled = 1;
}
if(m.guidanceEnabled == nil) {
- m.guidanceEnabled = TRUE;
+ m.guidanceEnabled = 1;
}
if (m.no_pitch == nil) {
m.no_pitch = 0;
@@ -621,14 +618,14 @@ var AIM = {
m.simple_drag = 1;
}
if(m.noCommonTarget == nil) {
- m.noCommonTarget = FALSE;
+ m.noCommonTarget = 0;
}
m.useModelCase = getprop("payload/armament/modelsUseCase");
m.useModelUpperCase = getprop("payload/armament/modelsUpperCase");
m.weapon_model_type = type;
- if (m.useModelCase == TRUE) {
- if (m.useModelUpperCase == TRUE) {
+ if (m.useModelCase == 1) {
+ if (m.useModelUpperCase == 1) {
m.weapon_model_type = string.uc(type);
} else {
m.weapon_model_type = m.type_lc;
@@ -656,7 +653,7 @@ var AIM = {
}
}
m.ai = n.getChild(m.type_lc, i, 1);
- if(m.data == TRUE) {
+ if(m.data == 1) {
m.ai.getNode("ETA", 1).setIntValue(-1);
m.ai.getNode("hit", 1).setIntValue(-1);
}
@@ -686,23 +683,23 @@ var AIM = {
m.mpLon = getprop("payload/armament/MP-lon");
m.mpAlt = getprop("payload/armament/MP-alt");
m.mpAltft = getprop("payload/armament/MP-alt-ft");#used for anim of S-300 camera view: Follow
- m.mpShow = FALSE;
+ m.mpShow = 0;
if (m.mpLat != nil and m.mpLon != nil and m.mpAlt != nil and m.mpAltft != nil) {
- m.mpLat = props.globals.getNode(m.mpLat, FALSE);
- m.mpLon = props.globals.getNode(m.mpLon, FALSE);
- m.mpAlt = props.globals.getNode(m.mpAlt, FALSE);
- m.mpAltft = props.globals.getNode(m.mpAltft, FALSE);
+ m.mpLat = props.globals.getNode(m.mpLat, 0);
+ m.mpLon = props.globals.getNode(m.mpLon, 0);
+ m.mpAlt = props.globals.getNode(m.mpAlt, 0);
+ m.mpAltft = props.globals.getNode(m.mpAltft, 0);
if (m.mpLat != nil and m.mpLon != nil and m.mpAlt != nil and m.mpAltft != nil) {
- m.mpShow = TRUE;
+ m.mpShow = 1;
}
}
- m.target_air = find("A", m.class)==-1?FALSE:TRUE;
- m.target_sea = find("M", m.class)==-1?FALSE:TRUE;#use M for marine, since S can be confused with surface.
- m.target_gnd = find("G", m.class)==-1?FALSE:TRUE;
- m.target_pnt = find("P", m.class)==-1?FALSE:TRUE;
+ m.target_air = find("A", m.class)==-1?0:1;
+ m.target_sea = find("M", m.class)==-1?0:1;#use M for marine, since S can be confused with surface.
+ m.target_gnd = find("G", m.class)==-1?0:1;
+ m.target_pnt = find("P", m.class)==-1?0:1;
m.ac = nil;
@@ -714,8 +711,8 @@ var AIM = {
#
# Seekerhead
#
- m.caged = TRUE;# if gyro is caged
- m.uncage_auto = TRUE;# will uncage when lock achieved (if SEAM supported)
+ m.caged = 1;# if gyro is caged
+ m.uncage_auto = 1;# will uncage when lock achieved (if SEAM supported)
m.command_dir_heading = 0;# where seeker is commanded in slave mode to look
m.command_dir_pitch = 0;
m.uncage_idle_heading = rand()*(2*m.max_seeker_dev)-m.max_seeker_dev;
@@ -723,7 +720,7 @@ var AIM = {
m.contacts = [];# contacts that should be considered to lock onto. In slave it will only lock to the first.
m.warm = 1;# normalized warm/cold
m.ready_standby_time = 0;# time when started from standby
- m.cooling = FALSE;
+ m.cooling = 0;
m.slave_to_radar = m.seam_support?1:0;
m.seeker_last_time = 0;
m.seeker_elev = 0;
@@ -746,8 +743,8 @@ var AIM = {
m.old_speed_horz_fps = nil;
m.old_speed_fps = 0;
m.g = 0;
- m.limitGs = FALSE;
- m.limitHalfGs = FALSE;
+ m.limitGs = 0;
+ m.limitHalfGs = 0;
m.speed_down_fps = nil;
m.speed_east_fps = nil;
m.speed_north_fps = nil;
@@ -782,7 +779,7 @@ var AIM = {
#
m.last_track_e = 0;
m.last_track_h = 0;
- m.guiding = TRUE;
+ m.guiding = 1;
m.t_alt = 0;
m.dist_curr = 0;
m.dist_curr_direct = -1;
@@ -795,13 +792,13 @@ var AIM = {
m.dist_direct_last = nil;
m.last_t_course = nil;
m.last_t_elev_deg = nil;
- m.last_cruise_or_loft = FALSE;
+ m.last_cruise_or_loft = 0;
m.last_t_norm_speed = nil;
m.last_t_elev_norm_speed = nil;
- m.dive_token = FALSE;
+ m.dive_token = 0;
m.raw_steer_signal_elev = 0;
m.raw_steer_signal_head = 0;
- m.cruise_or_loft = FALSE;
+ m.cruise_or_loft = 0;
m.curr_deviation_e = 0;
m.curr_deviation_h = 0;
m.track_signal_e = 0;
@@ -834,7 +831,7 @@ var AIM = {
#
# Rail
#
- m.rail_passed = FALSE;
+ m.rail_passed = 0;
m.x = 0;
m.y = 0;
m.z = 0;
@@ -859,48 +856,48 @@ var AIM = {
#
m.flareLast = 0;
m.flareTime = 0;
- m.flareLock = FALSE;
+ m.flareLock = 0;
m.chaffLast = 0;
m.chaffTime = 0;
- m.chaffLock = FALSE;
+ m.chaffLock = 0;
m.chaffLockTime = -1000;
m.flarespeed_fps = nil;
#
# Telemetry
#
- m.first = FALSE;
+ m.first = 0;
#
# these are used for limiting debugging spam
#
- m.heatLostLock = FALSE;
- m.semiLostLock = FALSE;
- m.radLostLock = FALSE;
- m.tooLowSpeed = FALSE;
- m.tooLowSpeedPass = FALSE;
+ m.heatLostLock = 0;
+ m.semiLostLock = 0;
+ m.radLostLock = 0;
+ m.tooLowSpeed = 0;
+ m.tooLowSpeedPass = 0;
m.tooLowSpeedTime = -1;
- m.lostLOS = FALSE;
+ m.lostLOS = 0;
#
# LOAL
#
- m.newTargetAssigned = FALSE;
+ m.newTargetAssigned = 0;
m.switchIndex = 0;
- m.hasGuided = FALSE;
- m.fovLost = FALSE;
- m.maddog = FALSE;
+ m.hasGuided = 0;
+ m.fovLost = 0;
+ m.maddog = 0;
m.nextFovCheck = m.switchTime;
m.observing = m.guidance;
#
# Sound
#
- m.SwSoundOnOff.setBoolValue(FALSE);
+ m.SwSoundOnOff.setBoolValue(0);
m.SwSoundVol.setDoubleValue(m.vol_search);
m.pendingLaunchSound = -1;
- m.explodeSound = TRUE;
+ m.explodeSound = 1;
@@ -926,9 +923,9 @@ var AIM = {
me.frameLoop.stop();
me.frameLoop = nil;
}
- me.deleted = TRUE;
+ me.deleted = 1;
thread.semup(me.frameToggle);
- if (me.first == TRUE) {
+ if (me.first) {
me.resetFirst();
}
me.model.remove();
@@ -1219,7 +1216,7 @@ var AIM = {
getDLZ: func (ignoreLock = 0) {
# call this only before release/eject
- if (me.dlz_enabled != TRUE) {
+ if (me.dlz_enabled != 1) {
return nil;
} elsif (contact == nil or (me.status != MISSILE_LOCK and !ignoreLock)) {
return [];
@@ -1363,7 +1360,7 @@ var AIM = {
if (vector.Math.angleBetweenVectors(vector.Math.eulerToCartesian2(-heading_deg, pitch_deg), [1,0,0]) <= me.fcs_fov) {
me.command_dir_heading = heading_deg;
me.command_dir_pitch = pitch_deg;
- me.slave_to_radar = FALSE;
+ me.slave_to_radar = 0;
}
me.printCode("Bore/dir command: heading %0.1f pitch %0.1f", heading_deg, pitch_deg);
},
@@ -1375,7 +1372,7 @@ var AIM = {
me.command_dir_heading = idle_heading;
me.command_dir_pitch = idle_elevation;
}
- me.slave_to_radar = TRUE;
+ me.slave_to_radar = 1;
me.printCode("Slave radar command. Idle: heading %0.1f pitch %0.1f", idle_heading, idle_elevation);
},
@@ -1468,10 +1465,10 @@ var AIM = {
me.force_lbf_3 = 0;
me.stage_gap_duration = 0;
me.drop_time = 10000;
- me.inert = TRUE;
- me.engineEnabled = FALSE;
- me.guidanceEnabled = FALSE;
- me.rail = FALSE;
+ me.inert = 1;
+ me.engineEnabled = 0;
+ me.guidanceEnabled = 0;
+ me.rail = 0;
me.releaseAtNothing();
},
@@ -1496,7 +1493,7 @@ var AIM = {
} else {
me.contacts = [];
}
- me.launchSoundProp.setBoolValue(FALSE);
+ me.launchSoundProp.setBoolValue(0);
if (me.engineEnabled and me.stage_1_duration > 0 and me.force_lbf_1 > 0 and me.drop_time < 1.75) {
me.pendingLaunchSound = me.drop_time;
@@ -1519,8 +1516,8 @@ var AIM = {
me.msl_hdg = ac_hdg;
me.msl_pitch = ac_pitch;
- if (me.rail == TRUE) {
- if (me.rail_forward == FALSE) {
+ if (me.rail) {
+ if (!me.rail_forward) {
me.position_on_rail = 0;
#if (me.rail_pitch_deg == 90 and me.Tgt != nil) {
# This only really works for surface launchers which is not rolled
@@ -1546,13 +1543,13 @@ var AIM = {
me.z = me.nasalPosition[2];
}
var init_coord = nil;
- if (me.rail == TRUE) {
- if (me.rail_forward == FALSE) {
+ if (me.rail) {
+ if (!me.rail_forward) {
me.railBegin = [-me.x, -me.y, me.z];
me.railEnd = vector.Math.plus(me.railBegin, vector.Math.product(me.rail_dist_m, me.railvec));
}
}
- if (offsetMethod == TRUE and (me.rail == FALSE or me.rail_forward == TRUE)) {
+ if (offsetMethod and (!me.rail or me.rail_forward)) {
var pos = aircraftToCart({x:-me.x, y:me.y, z: -me.z});
init_coord = geo.Coord.new();
init_coord.set_xyz(pos.x, pos.y, pos.z);
@@ -1573,10 +1570,10 @@ var AIM = {
me.usingTGPPoint = 1;
}
me.t_coord = me.Tgt.get_Coord();
- me.maddog = FALSE;
- me.newTargetAssigned = TRUE;
+ me.maddog = 0;
+ me.newTargetAssigned = 1;
} else {
- me.maddog = TRUE;
+ me.maddog = 1;
}
me.model.getNode("latitude-deg-prop", 1).setValue(me.latN.getPath());
@@ -1593,8 +1590,8 @@ var AIM = {
me.speed_east_fps = getprop("velocities/speed-east-fps");
me.speed_north_fps = getprop("velocities/speed-north-fps");
me.speed_horizontal_fps = math.sqrt(me.speed_east_fps*me.speed_east_fps + me.speed_north_fps*me.speed_north_fps);
- if (me.rail == TRUE) {
- if (me.rail_forward == FALSE) {
+ if (me.rail) {
+ if (!me.rail_forward) {
# TODO: add side wind here too since rail can now have heading offset too.
me.u = noseAir.getValue();
me.w = -belowAir.getValue();
@@ -1604,7 +1601,7 @@ var AIM = {
me.rail_speed_into_wind = noseAir.getValue();
#printf("Rail: ac_fps=%d uBody_fps=%d", math.sqrt(me.speed_down_fps*me.speed_down_fps+math.pow(math.sqrt(me.speed_east_fps*me.speed_east_fps+me.speed_north_fps*me.speed_north_fps),2)), me.rail_speed_into_wind);
}
- } elsif (me.intoBore == FALSE and me.eject_speed == 0) {
+ } elsif (!me.intoBore and me.eject_speed == 0) {
# to prevent the missile to appear falling up, we need to sometimes pitch it into wind:
#var t_spd = math.sqrt(me.speed_down_fps*me.speed_down_fps + h_spd*h_spd);
var wind_pitch = math.atan2(-me.speed_down_fps, me.speed_horizontal_fps) * R2D;
@@ -1708,16 +1705,16 @@ var AIM = {
var sun_y = getprop("ephemeris/sun/local/y");# unit vector pointing to sun in geocentric coords
var sun_z = getprop("ephemeris/sun/local/z");
if (sun_x != nil) {
- me.sun_enabled = TRUE;
+ me.sun_enabled = 1;
me.sun = geo.Coord.new();
me.sun.set_xyz(me.ac_init.x()+sun_x*2000000, me.ac_init.y()+sun_y*2000000, me.ac_init.z()+sun_z*2000000);#heat seeking missiles don't fly far, so setting it 2000Km away is fine.
me.sun.alt();# TODO: once fixed in FG this line is no longer needed.
} else {
# old FG versions does not supply location of sun. So this feature gets disabled.
- me.sun_enabled = FALSE;
+ me.sun_enabled = 0;
}
- me.lock_on_sun = FALSE;
+ me.lock_on_sun = 0;
loadNode.remove();
@@ -1891,6 +1888,8 @@ var AIM = {
me.printStats("After propulsion ends, it will max steer up to %d degree pitch.",me.maxPitch);
if(me.Tgt == nil) {
me.printStats("Note: Ordnance was released with no lock or destination target.");
+ } elsif (me.Tgt["getVirtualType"] != nil) {
+ me.printStats("Note: Ordnance was released locked on this target type: %s", me.Tgt.getVirtualType());
}
me.printStats("Seekerheads ability to filter out background noise is %.2f, where 0 is perfect and 3 is not so good.", me.seeker_filter);
me.printStats("Exhaust plume will reduce drag by %d percent.", (1-me.Cd_plume)*100);
@@ -2005,9 +2004,9 @@ var AIM = {
if (!me.rail and me.eject_speed != 0) {
me.printStats("Weapon will be ejected at %.1f feet/sec.",me.eject_speed);
}
- if (me.guidance == "heat" or me.guidance == "radar" or me.guidance == "semi-radar") {
+ if (me.guidance == "heat" or me.guidance == "radar" or me.guidance == "semi-radar" or me.guidance == "tvm") {
me.printStats("COUNTER-MEASURES:");
- if (me.guidance == "radar" or me.guidance == "semi-radar") {
+ if (me.guidance == "radar" or me.guidance == "semi-radar" or me.guidance == "tvm") {
me.printStats("Resistance to chaff is %d%%.",me.chaffResistance*100);
} elsif (me.guidance == "heat") {
me.printStats("Resistance to flares is %d%%.",me.flareResistance*100);
@@ -2045,24 +2044,24 @@ var AIM = {
me.Tgt = tagt;
me.callsign = tagt==nil?"Unknown":damage.processCallsign(me.Tgt.get_Callsign());
me.printStatsDetails("Target set to %s", me.callsign);
- me.newTargetAssigned = tagt==nil?FALSE:TRUE;
+ me.newTargetAssigned = tagt==nil?0:1;
me.t_coord = tagt==nil?nil:me.Tgt.get_Coord();
- me.fovLost = FALSE;
- me.lostLOS = tagt==nil?TRUE:FALSE;# to do prowl flight something needs to be lost.
- me.radLostLock = FALSE;
- me.semiLostLock = FALSE;
- me.heatLostLock = FALSE;
- me.hasGuided = FALSE;
+ me.fovLost = 0;
+ me.lostLOS = tagt==nil?1:0;# to do prowl flight something needs to be lost.
+ me.radLostLock = 0;
+ me.semiLostLock = 0;
+ me.heatLostLock = 0;
+ me.hasGuided = 0;
},
flight: func {
while(1==1) {
- if(me.deleted == TRUE) {
+ if(me.deleted) {
return;
}
thread.semdown(me.frameToggle);
- if(me.deleted == TRUE) {
+ if(me.deleted) {
return;
}
#############################################################################################################
@@ -2098,14 +2097,14 @@ var AIM = {
me.handleMidFlightFunc();
if (me.hasGuided and me.maddog) {
- me.maddog = FALSE;
+ me.maddog = 0;
me.printStats("Maddog stage over, guided at "~me.callsign);
}
- if (me.guidanceEnabled and me.free == FALSE and !me.newTargetAssigned and (me.canSwitch or (me.loal and me.maddog)) and size(me.contacts) > 0 and (me.dist_curr_direct==-1 or me.dist_curr_direct>me.reportDist)) {
+ if (me.guidanceEnabled and !me.free and !me.newTargetAssigned and (me.canSwitch or (me.loal and me.maddog)) and size(me.contacts) > 0 and (me.dist_curr_direct==-1 or me.dist_curr_direct>me.reportDist)) {
# me.reaquire must also be enabled for me.canSwitch to work
- if (me.Tgt==nil or me.hasGuided == FALSE or (me.canSwitch and (me.fovLost or me.lostLOS or me.radLostLock or me.semiLostLock or me.heatLostLock)) and me.life_time > me.nextFovCheck) {
+ if (me.Tgt==nil or !me.hasGuided or (me.canSwitch and (me.fovLost or me.lostLOS or me.radLostLock or me.semiLostLock or me.heatLostLock)) and me.life_time > me.nextFovCheck) {
# test next contact
me.numberContacts = size(me.contacts);
me.switchIndex += 1;
@@ -2117,7 +2116,7 @@ var AIM = {
if (!me.newLock(me.newTgt)) {
me.Tgt = nil;
me.callsign = "Unknown";
- me.newTargetAssigned = FALSE;
+ me.newTargetAssigned = 0;
} else {
me.setNewTargetInFlight(me.newTgt);
}
@@ -2127,7 +2126,7 @@ var AIM = {
if (me.prevGuidance != me.guidance) {
me.keepPitch = me.pitch;
}
- if (me.Tgt != nil and me.Tgt.isValid() == FALSE) {#TODO: verify that the following threaded code can handle invalid contact. As its read from property-tree, not mutex protected.
+ if (me.Tgt != nil and !me.Tgt.isValid()) {#TODO: verify that the following threaded code can handle invalid contact. As its read from property-tree, not mutex protected.
if (!(me.canSwitch and me.reaquire)) {
me.printStats(me.type~": Target went away, deleting missile.");
#me.sendMessage(me.type~" missed "~me.callsign~": Target logged off.");
@@ -2140,7 +2139,7 @@ var AIM = {
} else {
me.Tgt = nil;
me.callsign = "Unknown";
- me.newTargetAssigned = FALSE;
+ me.newTargetAssigned = 0;
}
} elsif (me.Tgt != nil and me.Tgt.get_type() == POINT and me.guidance == "laser" and me.usingTGPPoint and contactPoint == nil) {
# if laser illuminated lock is lost on a targetpod target:
@@ -2151,7 +2150,7 @@ var AIM = {
} else {
me.Tgt = nil;
me.callsign = "Unknown";
- me.newTargetAssigned = FALSE;
+ me.newTargetAssigned = 0;
}
} elsif (me.Tgt == nil and me.guidance == "laser" and me.usingTGPPoint and contactPoint != nil) {
# see if we can regain lock on new laser spot:
@@ -2163,9 +2162,9 @@ var AIM = {
}
}
- if (me.rail == FALSE) {
+ if (!me.rail) {
me.deploy = me.clamp(me.extrapolate(me.life_time, me.drop_time, me.drop_time+me.deploy_time,0,1),0,1);
- } elsif (me.rail_passed_time == nil and me.rail_passed == TRUE) {
+ } elsif (me.rail_passed_time == nil and me.rail_passed) {
me.rail_passed_time = me.life_time;
me.deploy = 0;
} elsif (me.rail_passed_time != nil) {
@@ -2235,12 +2234,12 @@ var AIM = {
# No guidance at low speed.
# Still go through the guidance loop for sensor logic (need to check flares, LOS, etc.
# to detect loss of lock), but the steering commands will be ignored.
- if (me.tooLowSpeed == FALSE) {
+ if (!me.tooLowSpeed) {
me.printStats(me.type~": Not guiding (too low speed)");
}
- me.tooLowSpeed = TRUE;
+ me.tooLowSpeed = 1;
} else {
- me.tooLowSpeed = FALSE;
+ me.tooLowSpeed = 0;
}
if (me.guidance == "remote" or me.guidance == "remote-stable") {
@@ -2252,8 +2251,8 @@ var AIM = {
}
AIM.setETA(nil);
me.prevETA = nil;
- } elsif (me.Tgt != nil and me.t_coord !=nil and me.free == FALSE and me.guidance != "unguided"
- and (me.rail == FALSE or me.rail_passed == TRUE) and me.guidanceEnabled) {
+ } elsif (me.Tgt != nil and me.t_coord !=nil and !me.free and me.guidance != "unguided"
+ and (!me.rail or me.rail_passed) and me.guidanceEnabled) {
#
# Here we figure out how to guide, navigate and steer.
#
@@ -2273,7 +2272,7 @@ var AIM = {
}
}
me.observing = me.guidance;
- } elsif (me.guidance != "unguided" and (me.rail == FALSE or me.rail_passed == TRUE) and me.guidanceEnabled and me.free == FALSE and me.t_coord == nil
+ } elsif (me.guidance != "unguided" and (!me.rail or me.rail_passed) and me.guidanceEnabled and !me.free and me.t_coord == nil
and (me.newTargetAssigned or (me.canSwitch and (me.fovLost or me.lostLOS or me.radLostLock or me.semiLostLock or me.heatLostLock) or (me.loal and me.maddog)))) {
# check for too low speed not performed on purpuse, difference between flying straight on A/P and making manouvres.
if (me.observing != me.standbyFlight) {
@@ -2300,7 +2299,7 @@ var AIM = {
me.track_signal_e = 0;
me.track_signal_h = 0;
me.printGuide("Unguided");
- #me.printGuideDetails(sprintf("not guiding %d %d %d %d %d",me.Tgt != nil,me.free == FALSE,me.guidance != "unguided",me.rail == FALSE,me.rail_passed == TRUE));
+ #me.printGuideDetails(sprintf("not guiding %d %d %d %d %d",me.Tgt != nil,me.free == 0,me.guidance != "unguided",me.rail == 0,me.rail_passed));
AIM.setETA(nil);
me.prevETA = nil;
}
@@ -2341,7 +2340,7 @@ var AIM = {
me.speed_east_fps = math.sin(me.hdg * D2R) * me.speed_horizontal_fps;
me.speed_down_fps += g_fps * me.dt;
- if (me.rail == TRUE and me.rail_passed == FALSE) {
+ if (me.rail and !me.rail_passed) {
# missile still on rail, lets calculate its speed relative to the wind coming in from the aircraft nose.
me.rail_speed_into_wind = me.rail_speed_into_wind + me.speed_change_fps;
} else {
@@ -2350,13 +2349,13 @@ var AIM = {
}
- if (me.rail == TRUE and me.rail_passed == FALSE) {
+ if (me.rail and !me.rail_passed) {
me.u = noseAir.getValue();# airstream from nose
#var v = getprop("velocities/vBody-fps");# airstream from side
me.w = -belowAir.getValue();# airstream from below
me.opposing_wind = me.u*math.cos(me.rail_pitch_deg*D2R)+me.w*math.sin(me.rail_pitch_deg*D2R);
- if (me.rail_forward == TRUE) {
+ if (me.rail_forward) {
me.pitch = OurPitch.getValue();
me.hdg = OurHdg.getValue();
} else {
@@ -2373,7 +2372,7 @@ var AIM = {
me.movement_on_rail = me.speed_on_rail * me.dt;
me.rail_pos = me.rail_pos + me.movement_on_rail;
- if (me.rail_forward == TRUE) {
+ if (me.rail_forward) {
me.x = me.x - (me.movement_on_rail * FT2M);# negative cause positive is rear in body coordinates
} else {
me.position_on_rail += math.max(0, me.movement_on_rail * FT2M);# only can move forward on rail.
@@ -2381,7 +2380,7 @@ var AIM = {
}
}
- if (me.rail == FALSE or me.rail_passed == TRUE) {
+ if (!me.rail or me.rail_passed) {
# missile not on rail, lets move it to next waypoint
if (me.observing != "level" or me.speed_m < me.min_speed_for_guiding) {
me.alt_ft = me.alt_ft - (me.speed_down_fps * me.dt);
@@ -2393,9 +2392,9 @@ var AIM = {
#me.coord.set_alt(me.alt_ft * FT2M);
} else {
# missile on rail, lets move it on the rail
- if (me.rail_forward == TRUE) {
+ if (me.rail_forward) {
var init_coord = nil;
- if (offsetMethod == TRUE) {
+ if (offsetMethod) {
me.geodPos = aircraftToCart({x:-me.x, y:me.y, z: -me.z});
me.coord.set_xyz(me.geodPos.x, me.geodPos.y, me.geodPos.z);
} else {
@@ -2417,16 +2416,20 @@ var AIM = {
}
# Get target position.
if (me.Tgt != nil and me.t_coord != nil) {
- if (me.flareLock == FALSE and me.chaffLock == FALSE) {
- me.t_coord = geo.Coord.new(me.Tgt.get_Coord());#in case multiple missiles use same Tgt we cannot rely on coords being different, so we extra create new.
+ if (!me.flareLock and !me.chaffLock) {
+ if (me.guidance != "gps" and (me.guidance != "gps-laser" or me.is_laser_painted(me.Tgt))) {# gps never updated inflight, gps-laser only when laser is online
+ me.t_coord = geo.Coord.new(me.Tgt.get_Coord());#in case multiple missiles use same Tgt we cannot rely on coords being different, so we extra create new.
+ }
if (me.t_coord == nil or !me.t_coord.is_defined()) {
# just to protect the multithreaded code for invalid pos.
print("Missile target has undefined coord!");
me.Tgt = nil;
+ } else {
+ me.t_coord.alt();# TODO: once fixed in FG this line is no longer needed.
}
} else {
# we are chasing a flare, lets update the flares position.
- if (me.flareLock == TRUE) {
+ if (me.flareLock) {
me.flarespeed_fps = me.flarespeed_fps - (25 * me.dt);#flare deacc. 15 kt per second.
} else {
me.flarespeed_fps = me.flarespeed_fps - (50 * me.dt);#chaff deacc. 30 kt per second.
@@ -2461,7 +2464,7 @@ var AIM = {
me.latN.setDoubleValue(me.coord.lat());
me.lonN.setDoubleValue(me.coord.lon());
me.altN.setDoubleValue(me.alt_ft);
- if (!me.no_pitch or (me.rail == TRUE and me.rail_passed == FALSE)) {
+ if (!me.no_pitch or (me.rail and !me.rail_passed)) {
me.pitchN.setDoubleValue(me.pitch);
} else {
# for ejection seat
@@ -2505,8 +2508,8 @@ var AIM = {
##############################
#### Proximity detection.#####
##############################
- if (me.rail == FALSE or me.rail_passed == TRUE) {
- if ( me.free == FALSE ) {
+ if (!me.rail or me.rail_passed) {
+ if ( !me.free ) {
me.g = me.steering_speed_G(me.hdg, me.pitch, me.track_signal_e, me.track_signal_h, me.old_speed_fps, me.dt);
} else {
me.g = 0;
@@ -2520,7 +2523,7 @@ var AIM = {
me.printFlight("Mach %04.2f , time %05.1f s , thrust %05.1f lbf , G-force %05.2f", me.speed_m, me.life_time, me.thrust_lbf, me.g);
me.printFlight("Alt %07.1f ft , direct distance to target %04.1f NM", me.alt_ft, (me.Tgt!=nil and me.direct_dist_m!=nil)?me.direct_dist_m*M2NM:-1);
- if (me.exploded == TRUE) {
+ if (me.exploded) {
me.printStats("%s max absolute %.2f Mach. Max relative %.2f Mach. Max alt %6d ft. Terminal %.2f mach.", me.type, me.maxMach, me.maxMach-me.startMach, me.maxAlt, me.speed_m);
me.printStats("%s max relative %d ft/s.", me.type, me.maxFPS-me.startFPS);
me.printStats(" Absolute %.2f Mach in stage 1.", me.maxMach1);
@@ -2533,7 +2536,7 @@ var AIM = {
me.sndSpeed = me.sound_fps;
me.sndDistance = 0;
me.elapsed_last_snd = systime();
- if (me.explodeSound == TRUE) {
+ if (me.explodeSound) {
thread.lock(mutexTimer);
append(AIM.timerQueue, [me,me.sndPropagate,[],0]);
thread.unlock(mutexTimer);
@@ -2547,7 +2550,7 @@ var AIM = {
}
}
- if (me.Tgt == nil and me.rail == TRUE and me.rail_pitch_deg==90 and me.rail_passed == FALSE) {
+ if (me.Tgt == nil and me.rail and me.rail_pitch_deg==90 and !me.rail_passed) {
#for ejection seat to be oriented correct, wont be ran for missiles with target such as the frigate.
# model of seat is loaded such that face is pointing in -Z FG coords.
@@ -2595,8 +2598,8 @@ var AIM = {
#print("looking2 "~me.myMath.cartesianToEuler(me.myMath.product(-1,me.myMath.eulerToCartesian3Z(-me.hdg, me.pitch, turnFace)))[0]);
#printf("seat now at P:%d H:%d R:%d",me.pitch, me.hdg, turnFace);
}
- if (me.rail_passed == FALSE and (me.rail == FALSE or me.rail_pos > me.rail_dist_m * M2FT)) {
- me.rail_passed = TRUE;
+ if (!me.rail_passed and (!me.rail or me.rail_pos > me.rail_dist_m * M2FT)) {
+ me.rail_passed = 1;
me.printFlight("rail passed");
}
@@ -2660,6 +2663,7 @@ var AIM = {
speed_fps: me.old_speed_fps,
weapon_position: me.coord,
guidance: me.guidance,
+ guidanceLaw: me.guidanceLaw,
seeker_detect_range: me.detect_range_curr_nm,
seeker_fov: me.max_seeker_dev,
weapon_pitch: me.pitch,
@@ -2689,10 +2693,10 @@ var AIM = {
}
if (me.settings["class"] != nil) {
me.class = me.settings.class;
- me.target_air = find("A", me.class)==-1?FALSE:TRUE;
- me.target_sea = find("M", me.class)==-1?FALSE:TRUE;
- me.target_gnd = find("G", me.class)==-1?FALSE:TRUE;
- me.target_pnt = find("P", me.class)==-1?FALSE:TRUE;
+ me.target_air = find("A", me.class)==-1?0:1;
+ me.target_sea = find("M", me.class)==-1?0:1;
+ me.target_gnd = find("G", me.class)==-1?0:1;
+ me.target_pnt = find("P", me.class)==-1?0:1;
me.printStats("Class switched to %s", me.class);
}
if (me.settings["target"] != nil) {
@@ -2726,9 +2730,9 @@ var AIM = {
},
sendTelemetry: func {
- if (me.data == TRUE) {
+ if (me.data) {
- me.eta = me.free == TRUE or me.vert_closing_rate_fps == -1?-1:(me["t_go"]!=nil?me.t_go:(me.dist_curr*M2FT)/me.vert_closing_rate_fps);
+ me.eta = me.free or me.vert_closing_rate_fps == -1?-1:(me["t_go"]!=nil?me.t_go:(me.dist_curr*M2FT)/me.vert_closing_rate_fps);
if (me.eta < 0) me.eta = -1;
me.hit = 50;# in percent
if (me.life_time > me.drop_time+me.stage_1_duration + me.gnd_launch?(me.stage_2_duration + me.stage_gap_duration):0) {
@@ -2753,11 +2757,11 @@ var AIM = {
# penalty for target being off-bore
me.hit -= math.abs(me.curr_deviation_h)/2.5;
}
- if (me.guiding == TRUE and me.t_speed_fps != nil and me.old_speed_fps > me.t_speed_fps and me.t_speed_fps != 0) {
+ if (me.guiding and me.t_speed_fps != nil and me.old_speed_fps > me.t_speed_fps and me.t_speed_fps != 0) {
# bonus for traveling faster than target
me.hit += me.clamp((me.old_speed_fps / me.t_speed_fps)*15,-25,50);
}
- if (me.free == TRUE or (me.gnd_launch and (me.chaffLock or me.flareLock))) {
+ if (me.free or (me.gnd_launch and (me.chaffLock or me.flareLock))) {
# penalty for not longer guiding
me.hit -= 75;
}
@@ -3025,28 +3029,28 @@ var AIM = {
},
setFirst: func() {
- if (me.smoke_prop.getValue() == TRUE and me.life_time < first_in_air_max_sec) {
- if (me.first == TRUE or first_in_air == FALSE) {
+ if (me.smoke_prop.getValue() == 1 and me.life_time < first_in_air_max_sec) {
+ if (me.first or !first_in_air) {
# report position over MP for MP animation of smoke trail.
- me.first = TRUE;
- first_in_air = TRUE;
- if (me.mpShow == TRUE) {
+ me.first = 1;
+ first_in_air = 1;
+ if (me.mpShow) {
me.mpLat.setDoubleValue(me.coord.lat());
me.mpLon.setDoubleValue(me.coord.lon());
me.mpAlt.setDoubleValue(me.coord.alt());
me.mpAltft.setDoubleValue(me.coord.alt()*M2FT);
}
}
- } elsif (me.first == TRUE and (me.life_time >= first_in_air_max_sec or me.life_time > me.drop_time + me.stage_1_duration + me.stage_gap_duration + me.stage_2_duration)) {
+ } elsif (me.first and (me.life_time >= first_in_air_max_sec or me.life_time > me.drop_time + me.stage_1_duration + me.stage_gap_duration + me.stage_2_duration)) {
# this weapon was reporting its position over MP, but now its fuel has used up. So allow for another to do that.
me.resetFirst();
}
},
resetFirst: func() {
- first_in_air = FALSE;
- me.first = FALSE;
- if (me.mpShow == TRUE) {
+ first_in_air = 0;
+ me.first = 0;
+ if (me.mpShow) {
me.mpLat.setDoubleValue(0.0);
me.mpLon.setDoubleValue(0.0);
me.mpAlt.setDoubleValue(0.0);
@@ -3071,12 +3075,12 @@ var AIM = {
me.myGnew = me.steering_speed_G(me.hdg, me.pitch, me.track_signal_e, me.track_signal_h, me.old_speed_fps, me.dt);
#me.printFlight(sprintf("G2 %.2f", myG)~sprintf(" - Coeff %.2f", MyCoef));
- if (me.limitGs == FALSE) {
+ if (!me.limitGs) {
me.printFlight("%s: Missile pulling approx max G: %06.3f/%06.3f (%06.3f)", me.type, me.myGnew, me.max_g_current, me.myG);
}
me.myG = me.myGnew;
}
- if (me.limitGs == TRUE and me.myG > me.max_g_current/2) {
+ if (me.limitGs and me.myG > me.max_g_current/2) {
# Save the horiz high performance maneuvering for later
me.track_signal_e = me.track_signal_e /2;
}
@@ -3141,11 +3145,14 @@ var AIM = {
me.raw_steer_signal_elev = 0;
me.raw_steer_signal_head = 0;
- me.guiding = TRUE;
+ me.guiding = 1;
if (me.guidance == "sample") {
me.blep = me.Tgt.getLastGroundTrackBlep();
- if (me.blep == nil) {
+ if (me.blep == nil and me.newTargetAssigned) {
+ # TODO: Do not remember what this is for
+ me.t_coord_sampled = me.t_coord;
+ } elsif (me.blep == nil) {
me.free = 1;
me.guiding = 0;
} elsif (me.blep.getID() != me["blepID"]) {
@@ -3172,6 +3179,10 @@ var AIM = {
} else {
me.t_coord_sampled = me.t_coord;
}
+ if (me["t_coord_sampled"] == nil) {
+ # Without this, t_coord_sampled can possibly be undefined in maddog mode.
+ me.t_coord_sampled = me.t_coord;
+ }
# Calculate current target elevation and azimut deviation.
me.t_alt = me.t_coord_sampled.alt()*M2FT;
@@ -3234,16 +3245,16 @@ var AIM = {
if (!(me.fovLost or me.lostLOS or me.radLostLock or me.semiLostLock or me.heatLostLock)) {
# me.tooLowSpeed not included in check on purpose
- me.hasGuided = TRUE;
+ me.hasGuided = 1;
}
- me.newTargetAssigned=FALSE;
+ me.newTargetAssigned=0;
},
checkForFlare: func () {
#
# Check for being fooled by flare.
#
- if (me.Tgt != nil and me.fovLost != TRUE and me.guidance == "heat" and me.flareLock == FALSE and (me.life_time-me.flareTime) > 1) {
+ if (me.Tgt != nil and me.fovLost != 1 and me.guidance == "heat" and !me.flareLock and (me.life_time-me.flareTime) > 1) {
# the fov check is for loal missiles that should not lock onto flares from aircraft not in view.
#
# TODO: Use Richards Emissary for this.
@@ -3258,7 +3269,7 @@ var AIM = {
me.flareLast = me.flareNumber;
me.aspectDeg = me.aspectToExhaust(me.coord, me.Tgt) / 180;
me.flareLock = rand() < (1-me.flareResistance + ((1-me.flareResistance) * 0.5 * me.aspectDeg));# 50% extra chance to be fooled if front aspect
- if (me.flareLock == TRUE) {
+ if (me.flareLock) {
# fooled by the flare
me.printStats(me.type~": Missile locked on flare from "~me.callsign);
me.flarespeed_fps = me.Tgt.get_Speed()*KT2FPS;
@@ -3277,7 +3288,7 @@ var AIM = {
#
# Check for being fooled by chaff.
#
- if (me.Tgt != nil and me.fovLost != TRUE and (me.guidance == "radar" or me.guidance == "semi-radar" or me.guidance == "command") and me.chaffLock == FALSE and (me.life_time-me.chaffTime) > 1) {
+ if (me.Tgt != nil and me.fovLost != 1 and (me.guidance == "radar" or me.guidance == "semi-radar" or me.guidance == "command" or me.guidance == "tvm") and !me.chaffLock and (me.life_time-me.chaffTime) > 1) {
#
# TODO: Use Richards Emissary for this.
#
@@ -3290,11 +3301,11 @@ var AIM = {
me.chaffLast = me.chaffNumber;
me.chaffTime = me.life_time;
me.aspectDeg = me.aspectToExhaust(me.coord, me.Tgt) / 180;# 0 = viewing engine, 1 = front
- me.redux = me.guidance == "semi-radar" or me.guidance == "command"?(me.gnd_launch?0.5:0.75):1;
+ me.redux = me.guidance == "semi-radar" or me.guidance == "command" or me.guidance == "tvm"?(me.gnd_launch?0.5:0.75):1;
me.chaffChance = (1-me.chaffResistance)*me.redux;
me.chaffLock = rand() < (me.chaffChance - (me.chaffChance * 0.5 * me.aspectDeg));# 50% less chance to be fooled if front aspect
- if (me.chaffLock == TRUE) {
+ if (me.chaffLock) {
me.printStats(me.type~": Missile locked on chaff from "~me.callsign);
me.flarespeed_fps = me.Tgt.get_Speed()*KT2FPS;
me.flare_hdg = me.Tgt.get_heading();
@@ -3310,7 +3321,7 @@ var AIM = {
},
checkForSun: func () {
- if (me.fovLost != TRUE and me.guidance == "heat" and me.sun_enabled == TRUE and getprop("/rendering/scene/diffuse/red") > 0.6) {
+ if (me.fovLost != 1 and me.guidance == "heat" and me.sun_enabled and getprop("/rendering/scene/diffuse/red") > 0.6) {
# test for heat seeker locked on to sun
me.sun_dev_e = me.getPitch(me.coord, me.sun) - me.pitch;
me.sun_dev_h = me.coord.course_to(me.sun) - me.hdg;
@@ -3319,21 +3330,21 @@ var AIM = {
me.sun_dev = math.sqrt((me.sun_dev_e-me.curr_deviation_e)*(me.sun_dev_e-me.curr_deviation_e)+(me.sun_dev_h-me.curr_deviation_h)*(me.sun_dev_h-me.curr_deviation_h));
if (me.sun_dev < me.sun_lock) {
me.printStats(me.type~": Locked onto sun, lost target. ");
- me.lock_on_sun = TRUE;
- me.free = TRUE;
+ me.lock_on_sun = 1;
+ me.free = 1;
}
}
},
checkForLOS: func () {
- if (pickingMethod == TRUE and me.guidance != "gps" and me.guidance != "unguided" and me.guidance != "inertial" and me.guidance != "sample") {
+ if (pickingMethod and me.guidance != "gps" and me.guidance != "gps-laser" and me.guidance != "unguided" and me.guidance != "inertial" and me.guidance != "sample") {
me.xyz = {"x":me.coord.x(), "y":me.coord.y(), "z":me.coord.z()};
me.directionLOS = {"x":me.t_coord.x()-me.coord.x(), "y":me.t_coord.y()-me.coord.y(), "z":me.t_coord.z()-me.coord.z()};
# Check for terrain between own weapon and target:
me.terrainGeod = get_cart_ground_intersection(me.xyz, me.directionLOS);
if (me.terrainGeod == nil) {
- me.lostLOS = FALSE;
+ me.lostLOS = 0;
return;
} else {
me.terrain = geo.Coord.new();
@@ -3341,118 +3352,118 @@ var AIM = {
me.maxDist = me.coord.direct_distance_to(me.t_coord)-1;#-1 is to avoid z-fighting distance
me.terrainDist = me.coord.direct_distance_to(me.terrain);
if (me.terrainDist >= me.maxDist) {
- me.lostLOS = FALSE;
+ me.lostLOS = 0;
return;
}
}
- if (me.reaquire == TRUE) {
- if (me.lostLOS == FALSE) {
+ if (me.reaquire) {
+ if (!me.lostLOS) {
me.printStats(me.type~": Not guiding (lost line of sight, trying to reaquire)");
}
- me.lostLOS = TRUE;
- me.guiding = FALSE;
+ me.lostLOS = 1;
+ me.guiding = 0;
return;
} else {
- if (me.lostLOS == FALSE) {
+ if (!me.lostLOS) {
me.printStats(me.type~": Gave up (lost line of sight)");
}
- me.lostLOS = TRUE;
- me.free = TRUE;
+ me.lostLOS = 1;
+ me.free = 1;
return;
}
}
- me.lostLOS = FALSE;
+ me.lostLOS = 0;
},
checkForGuidance: func () {
if(me.tooLowSpeed) {
- me.guiding = FALSE;
- } elsif ((me.guidance == "semi-radar" and me.is_painted(me.Tgt) == FALSE) or (me.guidance =="laser" and me.is_laser_painted(me.Tgt) == FALSE) ) {
+ me.guiding = 0;
+ } elsif ((me.guidance == "semi-radar" and !me.is_painted(me.Tgt)) or (me.guidance =="laser" and !me.is_laser_painted(me.Tgt)) ) {
# if its semi-radar guided and the target is no longer painted
- me.guiding = FALSE;
- if (me.reaquire == TRUE) {
- if (me.semiLostLock == FALSE) {
+ me.guiding = 0;
+ if (me.reaquire) {
+ if (!me.semiLostLock) {
me.printStats(me.type~": Not guiding (lost radar reflection, trying to reaquire)");
}
- me.semiLostLock = TRUE;
+ me.semiLostLock = 1;
} else {
me.printStats(me.type~": Not guiding (lost radar reflection, gave up)");
- me.free = TRUE;
+ me.free = 1;
}
- } elsif (me.guidance == "command" and (me.Tgt == nil or !me.Tgt.isCommandActive())) {
- # if its command guided and the control no longer sends commands
- me.guiding = FALSE;
+ } elsif ((me.guidance == "command" or me.guidance == "tvm") and (me.Tgt == nil or !me.Tgt.isCommandActive())) {
+ # if its command or TVM guided and the control no longer sends commands
+ me.guiding = 0;
me.printStats(me.type~": Not guiding (no commands from controller)");
- } elsif (me.guidance == "radiation" and me.is_radiating_me(me.Tgt) == FALSE) {
+ } elsif (me.guidance == "radiation" and !me.is_radiating_me(me.Tgt)) {
# if its radiation guided and the target is not illuminating us with radiation
- me.guiding = FALSE;
- if (me.reaquire == TRUE) {
- if (me.radLostLock == FALSE) {
+ me.guiding = 0;
+ if (me.reaquire) {
+ if (!me.radLostLock) {
me.printStats(me.type~": Not guiding (lost radiation, trying to reaquire)");
}
- me.radLostLock = TRUE;
+ me.radLostLock = 1;
} else {
me.printStats(me.type~": Not guiding (lost radiation, gave up)");
- me.free = TRUE;
+ me.free = 1;
}
- } elsif (me.guidance != "gps" and me.guidance != "inertial" and me.guidance != "sample" and (me.dist_curr_direct*M2NM > me.detect_range_curr_nm or !me.FOV_check(me.hdg, me.pitch, me.curr_deviation_h, me.curr_deviation_e, me.max_seeker_dev, me.myMath))) {
+ } elsif (me.guidance != "gps" and me.guidance != "gps-laser" and me.guidance != "inertial" and me.guidance != "sample" and (me.dist_curr_direct*M2NM > me.detect_range_curr_nm or !me.FOV_check(me.hdg, me.pitch, me.curr_deviation_h, me.curr_deviation_e, me.max_seeker_dev, me.myMath))) {
# target is not in missile seeker view anymore
- if (me.fovLost == FALSE and me.detect_range_curr_nm != 0) {
+ if (!me.fovLost and me.detect_range_curr_nm != 0) {
me.normFOV = me.FOV_check_norm(me.hdg, me.pitch, me.curr_deviation_h, me.curr_deviation_e, me.max_seeker_dev, me.myMath);
me.printStats(me.type~": "~me.callsign~" is not in seeker view. (%d%% in view, %d%% in range)", me.normFOV*100, 100*me.dist_curr_direct*M2NM / me.detect_range_curr_nm);#~me.viewLost);
- } elsif (me.fovLost == FALSE) {
+ } elsif (!me.fovLost) {
me.normFOV = me.FOV_check_norm(me.hdg, me.pitch, me.curr_deviation_h, me.curr_deviation_e, me.max_seeker_dev, me.myMath);
me.printStats(me.type~": "~me.callsign~" is not in seeker view. (%d%% in view)", me.normFOV*100);#~me.viewLost);
}
- if (me.reaquire == FALSE) {
- me.free = TRUE;
+ if (!me.reaquire) {
+ me.free = 1;
} else {
- me.fovLost = TRUE;
- me.guiding = FALSE;
+ me.fovLost = 1;
+ me.guiding = 0;
}
- } elsif (me.all_aspect == FALSE and me.rear_aspect(me.coord, me.Tgt) == FALSE) {
- me.guiding = FALSE;
- if (me.heatLostLock == FALSE) {
+ } elsif (!me.all_aspect and !me.rear_aspect(me.coord, me.Tgt)) {
+ me.guiding = 0;
+ if (!me.heatLostLock) {
me.printStats(me.type~": Missile lost heat lock, attempting to reaquire..");
}
- me.heatLostLock = TRUE;
+ me.heatLostLock = 1;
} elsif (me.life_time < me.drop_time and !me.guideWhileDrop) {
- me.guiding = FALSE;
- } elsif (me.semiLostLock == TRUE) {
+ me.guiding = 0;
+ } elsif (me.semiLostLock) {
me.printStats(me.type~": Reaquired reflection.");
- me.semiLostLock = FALSE;
- } elsif (me.radLostLock == TRUE) {
+ me.semiLostLock = 0;
+ } elsif (me.radLostLock) {
me.printStats(me.type~": Reaquired radiation.");
- me.radLostLock = FALSE;
- } elsif (me.heatLostLock == TRUE) {
+ me.radLostLock = 0;
+ } elsif (me.heatLostLock) {
me.printStats(me.type~": Regained heat lock.");
- me.heatLostLock = FALSE;
- } elsif (me.tooLowSpeed == TRUE) {
+ me.heatLostLock = 0;
+ } elsif (me.tooLowSpeed) {
me.printStats(me.type~": Gained speed and started guiding.");
- me.tooLowSpeed = FALSE;
- } elsif (me.fovLost == TRUE) {
+ me.tooLowSpeed = 0;
+ } elsif (me.fovLost) {
me.printStats(me.type~": Regained view of target.");
- me.fovLost = FALSE;
+ me.fovLost = 0;
} elsif (me.loal and me.maddog) {
me.printStats(me.type~": "~me.callsign~" is potential target. ("~me.Tgt.get_type()~","~me.class~")");
}
if (me.speed_m >= me.min_speed_for_guiding) {
- me.tooLowSpeedPass = TRUE;
+ me.tooLowSpeedPass = 1;
if (me.tooLowSpeedTime == -1) {
me.tooLowSpeedTime = me.life_time;
me.normFOV = me.FOV_check_norm(me.hdg, me.pitch, me.curr_deviation_h, me.curr_deviation_e, me.max_seeker_dev, me.myMath);
me.printStats(me.type~": Passed minimum speed for guiding after %.1f seconds. Target %d%% inside view.", me.life_time, me.normFOV*100);
}
}
- if (me.chaffLock and (me.guidance == "command" or me.guidance == "semi-radar") and (me.life_time - me.chaffLockTime) > (me.gnd_launch?4:6)) {
+ if (me.chaffLock and (me.guidance == "command" or me.guidance == "semi-radar" or me.guidance == "tvm") and (me.life_time - me.chaffLockTime) > (me.gnd_launch?4:6)) {
me.chaffLock = 0;
me.printStats(me.type~": Chaff dissipated, regained track.");
}
},
adjustToKeepLock: func {
- if (me.guidance != "gps" and me.guidance != "inertial" and me.guidance != "sample") {
+ if (me.guidance != "gps" and me.guidance != "gps-laser" and me.guidance != "inertial" and me.guidance != "sample") {
if (!me.FOV_check(me.hdg, me.pitch, me.curr_deviation_h+me.raw_steer_signal_head, me.curr_deviation_e+me.raw_steer_signal_elev, me.max_seeker_dev, me.myMath) and me.fov_radial != 0) {
# the commanded steer order will make the missile lose its lock, to prevent that we reduce the steering just enough so lock wont be lost.
me.factorKeep = me.max_seeker_dev/me.fov_radial;
@@ -3485,7 +3496,7 @@ var AIM = {
} else {
# lost lock due to angular speed limit could not keep target in beam
me.printStats("%s: %4.1f deg/s too fast angular change for seeker head to keep target in beam. %5.2fnm to target.", me.type, me.deviation_per_sec, me.dist_curr_direct*M2NM);
- me.free = TRUE;
+ me.free = 1;
}
} else {
me.localVectorSeeker = me.localVectorTarget;
@@ -3502,13 +3513,13 @@ var AIM = {
#
# cruise, loft, cruise-missile
#
- if (me.guiding == FALSE) {
+ if (!me.guiding) {
return;
}
me.loft_angle = 15;# notice Shinobi used 26.5651 degs, but Raider1 found a source saying 10-20 degs.
- me.cruise_or_loft = FALSE;# If true then this method handles the vertical component of guiding.
+ me.cruise_or_loft = 0;# If true then this method handles the vertical component of guiding.
me.time_before_snap_up = me.drop_time * 3;
- me.limitGs = FALSE;
+ me.limitGs = 0;
me.limitHalfGs = 0;
if (me.loft_alt != 0 and me.guidanceLaw == "direct-alt") {
@@ -3531,7 +3542,7 @@ var AIM = {
}
me.cruise_or_loft = 1;
me.limitHalfGs = 1;
- } elsif(me.loft_alt != 0 and me.snapUp == FALSE) {
+ } elsif(me.loft_alt != 0 and !me.snapUp) {
# this is for Air to ground/sea cruise-missile (SCALP, Sea-Eagle, Taurus, Tomahawk, RB-15...)
var code = 1;# 0 = old, 1 = new, 2 = angle
@@ -3648,9 +3659,9 @@ var AIM = {
me.slope = me.clamp(me.t_alt_delta_ft / 300, -7.5, 0);# the lower the desired alt is, the steeper the slope, but not steeper than 7.5
me.raw_steer_signal_elev = -me.pitch + me.clamp(math.atan2(me.t_alt_delta_ft, me.old_speed_fps * me.dt * 5) * R2D, me.slope, 0);
}
- me.cruise_or_loft = TRUE;
+ me.cruise_or_loft = 1;
}
- if (me.cruise_or_loft == TRUE) {
+ if (me.cruise_or_loft) {
me.printGuideDetails(" pitch "~me.pitch~" + me.raw_steer_signal_elev "~me.raw_steer_signal_elev);
}
} else {#Older code
@@ -3686,7 +3697,7 @@ var AIM = {
}
me.Daground = 0;# zero for sealevel in case target is ship. Don't shoot A/S missiles over terrain. :)
- if(me.Tgt.get_type() == SURFACE or me.follow == TRUE) {
+ if(me.Tgt.get_type() == SURFACE or me.follow) {
me.Daground = me.nextGroundElevation * M2FT;
}
me.loft_alt_curr = me.loft_alt;
@@ -3710,42 +3721,42 @@ var AIM = {
me.slope = me.clamp(me.t_alt_delta_ft / 300, -7.5, 0);# the lower the desired alt is, the steeper the slope.
me.raw_steer_signal_elev = -me.pitch + me.clamp(math.atan2(me.t_alt_delta_ft, me.old_speed_fps * me.dt * 5) * R2D, me.slope, 0);
}
- me.cruise_or_loft = TRUE;
+ me.cruise_or_loft = 1;
}
- if (me.cruise_or_loft == TRUE) {
+ if (me.cruise_or_loft) {
me.printGuideDetails(" pitch "~me.pitch~" + me.raw_steer_signal_elev "~me.raw_steer_signal_elev);
}
}
- #} elsif (me.rail == TRUE and me.rail_forward == FALSE and me.rotate_token == FALSE) {
+ #} elsif (me.rail == 1 and me.rail_forward == 0 and me.rotate_token == 0) {
# tube launched missile turns towards target
# me.raw_steer_signal_elev = me.curr_deviation_e;
# me.printGuideDetails("Turning, desire "~me.t_elev_deg~" degs pitch.");
- # me.cruise_or_loft = TRUE;
- # me.limitGs = TRUE;
+ # me.cruise_or_loft = 1;
+ # me.limitGs = 1;
# if (math.abs(me.curr_deviation_e) < 20) {
- # me.rotate_token = TRUE;
+ # me.rotate_token = 1;
# me.printGuide("Is last turn, snap-up/PN takes it from here..")
# }
- } elsif (me.snapUp == TRUE and me.t_elev_deg > me.clamp(-50/me.speed_m,-30,-5) and me.dist_curr * M2NM > me.speed_m * 6
+ } elsif (me.snapUp and me.t_elev_deg > me.clamp(-50/me.speed_m,-30,-5) and me.dist_curr * M2NM > me.speed_m * 6
and me.t_elev_deg < me.loft_angle #and me.t_elev_deg > -7.5
- and me.dive_token == FALSE) {
+ and !me.dive_token) {
# lofting: due to target is more than 10 miles out and we havent reached
# our desired cruising alt, and the elevation to target is less than lofting angle.
# The -7.5 limit, is so the seeker don't lose track of target when lofting.
if (me.life_time < me.time_before_snap_up and me.coord.alt() * M2FT < me.loft_alt) {
me.printGuide("preparing for lofting");
- me.cruise_or_loft = TRUE;
+ me.cruise_or_loft = 1;
} elsif (me.coord.alt() * M2FT < me.loft_alt) {
me.raw_steer_signal_elev = -me.pitch + me.loft_angle;
- me.limitGs = TRUE;
+ me.limitGs = 1;
me.printGuide("Lofting %04.1f degs, dev is %04.1f", me.loft_angle, me.raw_steer_signal_elev);
} else {
- me.dive_token = TRUE;
+ me.dive_token = 1;
me.printGuide("Stopped lofting");
}
- me.cruise_or_loft = TRUE;
- } elsif (me.snapUp == TRUE and me.coord.alt() > me.t_coord.alt() and me.last_cruise_or_loft == TRUE
+ me.cruise_or_loft = 1;
+ } elsif (me.snapUp and me.coord.alt() > me.t_coord.alt() and me.last_cruise_or_loft
and me.t_elev_deg > me.clamp(-50/me.speed_m,-30,-5) and me.dist_curr * M2NM > me.speed_m * 5.5) {
# cruising: keeping altitude since target is below and more than -45 degs down
@@ -3758,15 +3769,15 @@ var AIM = {
me.raw_steer_signal_elev = -me.pitch + me.attitude;
me.printGuideDetails("Cruising, desire "~me.attitude~" degs pitch.");
- me.cruise_or_loft = TRUE;
- me.limitGs = TRUE;
- me.dive_token = TRUE;
- } elsif (me.last_cruise_or_loft == TRUE and math.abs(me.curr_deviation_e) > 25 and me.life_time > me.time_before_snap_up) {
+ me.cruise_or_loft = 1;
+ me.limitGs = 1;
+ me.dive_token = 1;
+ } elsif (me.last_cruise_or_loft and math.abs(me.curr_deviation_e) > 25 and me.life_time > me.time_before_snap_up) {
# after cruising, point the missile in the general direction of the target, before PN starts guiding.
me.printGuide("Rotating toward target");
me.raw_steer_signal_elev = me.curr_deviation_e;
- me.cruise_or_loft = TRUE;
- #me.limitGs = TRUE;
+ me.cruise_or_loft = 1;
+ #me.limitGs = 1;
# TODO: this needs to be worked on.
}
@@ -3819,14 +3830,14 @@ var AIM = {
#
# guidance laws
#
- if (me.guiding == TRUE and me.free == FALSE and me.dist_last != nil and me.last_dt != 0 and me.newTargetAssigned==FALSE) {
+ if (me.guiding and !me.free and me.dist_last != nil and me.last_dt != 0 and me.newTargetAssigned==0) {
# augmented proportional navigation for heading #
#################################################
if (me.guidanceLaw == "direct" or (me.guidanceLaw == "LOS" and me.life_time < 4)) {
# pure pursuit
me.raw_steer_signal_head = me.curr_deviation_h;
- if (me.cruise_or_loft == FALSE) {
+ if (!me.cruise_or_loft) {
me.raw_steer_signal_elev = me.curr_deviation_e;
me.attitudePN = (math.atan2(-(me.speed_down_fps+g_fps * me.dt), me.speed_horizontal_fps ) - math.atan2(-me.speed_down_fps, me.speed_horizontal_fps )) * R2D;
me.gravComp = - me.attitudePN;
@@ -3856,7 +3867,7 @@ var AIM = {
}
if (me.life_time > 6) {
me.noise = 1;
- } elsif (me.seeker_filter > 0 and me.guidance != "gps" and me.life_time-me.last > me.next) {
+ } elsif (me.seeker_filter > 0 and me.guidance != "gps" and me.guidance != "gps-laser" and me.life_time-me.last > me.next) {
# PN noise.
me.sign = me.seed>0.85?(rand()>0.75?-1:1):1;
me.opnNoiseReduct = me.apn == -1?0.5:1;
@@ -3883,7 +3894,7 @@ var AIM = {
me.t_velocity = me.myMath.getCartesianVelocity(-me.Tgt.get_heading(), me.Tgt.get_Pitch(), me.Tgt.get_Roll(), me.Tgt.get_uBody(), me.Tgt.get_vBody(), me.Tgt.get_wBody());
- if ((me.flareLock == FALSE and me.chaffLock == FALSE) or me.t_heading == nil) {
+ if ((!me.flareLock and !me.chaffLock) or me.t_heading == nil) {
me.euler = me.myMath.cartesianToEuler(me.t_velocity);
if (me.euler[0] != nil) {
me.t_heading = me.euler[0];
@@ -3993,7 +4004,7 @@ var AIM = {
#me.print(sprintf("commanded-perpendicular-acceleration=%.1f ft/s^2", acc_lateral_fps2));
#printf("horz leading by %.1f deg, commanding %.1f deg", me.curr_deviation_h, me.raw_steer_signal_head);
- if (me.cruise_or_loft == FALSE) {
+ if (!me.cruise_or_loft) {
me.fixed_aim = nil;
me.fixed_aim_time = nil;
if (find("PN",me.guidanceLaw) != -1 and size(me.guidanceLaw) > 3) {
@@ -4148,7 +4159,7 @@ var AIM = {
if ((me.Tgt != nil and me.direct_dist_m != nil) or me.Tgt == nil) {
me.terrainImpact = 1;
#me.explode("Hit terrain.", me.coord, me.direct_dist_m, me.event);
- #return TRUE;
+ #return 1;
}
}
@@ -4167,9 +4178,9 @@ var AIM = {
if (me.terrainImpact) {
me.coord.set_alt(me.ground);
me.explode("Hit terrain.", me.coord, me.direct_dist_m, me.event);
- return TRUE;
+ return 1;
}
- return FALSE; # Wait for the buffer to fill at least once.
+ return 0; # Wait for the buffer to fill at least once.
}
if (me.life_time > me.arming_time) {
@@ -4179,25 +4190,25 @@ var AIM = {
me.subframeClosestRangeCoord(); # Provides `me.crc_closestRange` and `me.crc_missileCoord`.
me.explode("Passed target.", me.crc_missileCoord, me.crc_closestRange);
- return TRUE;
+ return 1;
}
- if (me.life_time > me.selfdestruct_time or (me.destruct_when_free == TRUE and me.free == TRUE)) {
+ if (me.life_time > me.selfdestruct_time or (me.destruct_when_free and me.free)) {
me.explode("Selfdestructed.", me.coord);
- return TRUE;
+ return 1;
}
}
me.direct_dist_m = me.crc_range[0];
} elsif (me.life_time > me.selfdestruct_time) {
me.Tgt = nil; # make sure we dont in inertial mode with target go in and start checking distances.
me.explode("Selfdestructed.", me.coord);
- return TRUE;
+ return 1;
}
if (me.terrainImpact) {
me.coord.set_alt(me.ground);
me.explode("Hit terrain.", me.coord, me.direct_dist_m, me.event);
- return TRUE;
+ return 1;
}
- return FALSE;
+ return 0;
},
#! brief: Recursive function to compute the closest range in the past mfd frames.
@@ -4361,9 +4372,9 @@ var AIM = {
var hitPrimaryTarget = 0;
if (me.Tgt != nil and !me.Tgt.isVirtual()) {
var tgtLabel = me.callsign;
- if(me.flareLock == TRUE)
+ if(me.flareLock)
tgtLabel ~= "'s flare";
- elsif (me.chaffLock == TRUE)
+ elsif (me.chaffLock)
tgtLabel ~= "'s chaff";
if (range != nil and range < me.reportDist) {
phrase = sprintf(me.type ~ " " ~ event ~ ": %.1f meters from: " ~ tgtLabel, range);
@@ -4403,10 +4414,10 @@ var AIM = {
thread.unlock(mutexTimer);
if (event == "exploded" and !me.inert and wh_mass > 0) {
me.animate_explosion(hitGround);
- me.explodeSound = TRUE;
+ me.explodeSound = 1;
} else {
me.animate_dud();
- me.explodeSound = FALSE;
+ me.explodeSound = 0;
}
me.Tgt = nil;
},
@@ -4430,7 +4441,11 @@ var AIM = {
thread.lock(mutexTimer);
append(AIM.timerQueue, [AIM, AIM.notifyHit, [explode_coord.alt() - cc.alt(),min_distance,cs,explode_coord.course_to(cc),"mhit1",me.typeID, me.typeLong,0], -1]);
thread.unlock(mutexTimer);
- }
+ } elsif (wh_mass > 0) {
+ thread.lock(mutexTimer);
+ append(AIM.timerQueue, [AIM, AIM.log, [phrase], 0]);
+ thread.unlock(mutexTimer);
+ }
me.sendout = 1;
}
@@ -4507,9 +4522,9 @@ var AIM = {
settimer(func me.standby(), 0.5);
}
if(me.seam_support and me.uncage_auto) {
- me.caged = TRUE;
+ me.caged = 1;
}
- if (me.deleted == TRUE or me.status == MISSILE_FLYING) return;
+ if (me.deleted or me.status == MISSILE_FLYING) return;
if (me.status == MISSILE_STARTING) {
me.printCode("Starting up missile");
me.startup();
@@ -4529,7 +4544,7 @@ var AIM = {
settimer(func me.startup(), 0.5);
}
if(me.seam_support and me.uncage_auto) {
- me.caged = TRUE;
+ me.caged = 1;
}
if (me.status != MISSILE_STARTING) {
me.standby();
@@ -4547,20 +4562,20 @@ var AIM = {
},
coolingSyst: func {
- if (me.coolable == TRUE and me.status != MISSILE_FLYING) {
+ if (me.coolable and me.status != MISSILE_FLYING) {
me.cool_elapsed = getprop("sim/time/elapsed-sec");
if (me.cooling_last_time != 0) {
me.cool_delta_time = me.cool_elapsed - me.cooling_last_time;
- if (me.cooling == TRUE) {
+ if (me.cooling) {
me.cool_total_time += me.cool_delta_time;
if (me.cool_total_time > me.cool_duration) {
- me.cooling = FALSE;
+ me.cooling = 0;
} else {
me.cool_curr_time = me.cool_delta_time+me.extrapolate(me.warm, 1, 0, 0, me.cool_time);
me.warm = me.clamp(me.extrapolate(me.cool_curr_time, 0, me.cool_time, 1, 0),0,1);
}
}
- if (me.cooling == FALSE) {
+ if (!me.cooling) {
me.cool_curr_time = me.cool_delta_time+me.extrapolate(me.warm, 0, 1, 0, me.cool_time*3);#takes longer to warm than to cool down
me.warm = me.clamp(me.extrapolate(me.cool_curr_time, 0, me.cool_time*3, 0, 1),0,1);
}
@@ -4575,29 +4590,29 @@ var AIM = {
checkForLock: func {
# call this only before firing
- if (!(me.tagt.get_type() == AIR and me.tagt.get_Speed()<15) and ((me.guidance != "semi-radar" or me.is_painted(me.tagt) == TRUE) and (me.guidance !="laser" or me.is_laser_painted(me.tagt) == TRUE))
- and (me.guidance != "radiation" or me.is_radiating_aircraft(me.tagt) == TRUE)
+ if (!(me.tagt.get_type() == AIR and me.tagt.get_Speed()<15) and ((me.guidance != "semi-radar" or me.is_painted(me.tagt)) and (me.guidance !="laser" or me.is_laser_painted(me.tagt)))
+ and (me.guidance != "radiation" or me.is_radiating_aircraft(me.tagt))
and me.rng < me.max_fire_range_nm and me.rng > me.getCurrentMinFireRange(me.tagt) and me.FOV_check(OurHdg.getValue(),OurPitch.getValue(),me.total_horiz, me.total_elev, me.slave_to_radar or contactPoint==me.tagt?(me.guidance == "heat" or me.guidance == "vision"?math.min(me.max_seeker_dev, me.fcs_fov):me.fcs_fov):me.max_seeker_dev, vector.Math)
- and (me.rng < me.detect_range_curr_nm or (me.guidance != "radar" and me.guidance != "semi-radar" and me.guidance != "sample" and me.guidance != "heat" and me.guidance != "vision" and me.guidance != "radiation"))
- and (me.guidance != "heat" or (me.all_aspect == TRUE or me.rear_aspect(geo.aircraft_position(), me.tagt) == TRUE))
+ and (me.rng < me.detect_range_curr_nm or (me.guidance != "radar" and me.guidance != "semi-radar" and me.guidance != "tvm" and me.guidance != "sample" and me.guidance != "heat" and me.guidance != "vision" and me.guidance != "radiation"))
+ and (me.guidance != "heat" or (me.all_aspect or me.rear_aspect(geo.aircraft_position(), me.tagt)))
and me.checkForView()) {
- return TRUE;
+ return 1;
}
#me.printSearch("Lock did fail %d %d %d %d %d %d %d %d %d",
# !(me.tagt.get_type() == AIR and me.tagt.get_Speed()<15),
- # ((me.guidance != "semi-radar" or me.is_painted(me.tagt) == TRUE) and (me.guidance !="laser" or me.is_laser_painted(me.tagt) == TRUE)),
- # (me.guidance != "radiation" or me.is_radiating_aircraft(me.tagt) == TRUE),
+ # ((me.guidance != "semi-radar" or me.is_painted(me.tagt) == 1) and (me.guidance !="laser" or me.is_laser_painted(me.tagt) == 1)),
+ # (me.guidance != "radiation" or me.is_radiating_aircraft(me.tagt) == 1),
# me.rng < me.max_fire_range_nm,
# me.rng > me.min_fire_range_nm,
# me.FOV_check(OurHdg.getValue(),OurPitch.getValue(),me.total_horiz, me.total_elev, me.slave_to_radar?math.min(me.max_seeker_dev, me.fcs_fov):me.max_seeker_dev, vector.Math),
# (me.rng < me.detect_range_curr_nm or (me.guidance != "radar" and me.guidance != "semi-radar" and me.guidance != "heat" and me.guidance != "vision" and me.guidance != "heat" and me.guidance != "radiation")),
- # (me.guidance != "heat" or (me.all_aspect == TRUE or me.rear_aspect(geo.aircraft_position(), me.tagt) == TRUE)),
+ # (me.guidance != "heat" or (me.all_aspect == 1 or me.rear_aspect(geo.aircraft_position(), me.tagt) == 1)),
# me.checkForView());
- return FALSE;
+ return 0;
},
checkForView: func {
- if (me.guidance != "gps" and me.guidance != "inertial" and me.guidance != "sample") {
+ if (me.guidance != "gps-laser" and me.guidance != "gps" and me.guidance != "inertial" and me.guidance != "sample") {
me.launchCoord = geo.aircraft_position();
if (!me.radarOrigin) {
me.geodPos = aircraftToCart({x:-me.radarX, y:me.radarY, z: -me.radarZ});
@@ -4611,23 +4626,23 @@ var AIM = {
# Check for terrain between own weapon and target:
me.terrainGeod = get_cart_ground_intersection(me.xyz, me.directionLOS);
if (me.terrainGeod == nil) {
- return TRUE;
+ return 1;
} else {
me.terrain = geo.Coord.new();
me.terrain.set_latlon(me.terrainGeod.lat, me.terrainGeod.lon, me.terrainGeod.elevation);
me.maxDist = me.launchCoord.direct_distance_to(me.potentialCoord)-1;#-1 is to avoid z-fighting distance
me.terrainDist = me.launchCoord.direct_distance_to(me.terrain);
if (me.terrainDist >= me.maxDist) {
- return TRUE;
+ return 1;
}
}
- return FALSE;
+ return 0;
}
- return TRUE;
+ return 1;
},
checkForViewInFlight: func (tagt) {
- if (me.guidance != "gps" and me.guidance != "inertial" and me.guidance != "sample") {
+ if (me.guidance != "gps-laser" and me.guidance != "gps" and me.guidance != "inertial" and me.guidance != "sample") {
me.launchCoord = me.coord;
me.potentialCoord = tagt.get_Coord();
me.xyz = {"x":me.launchCoord.x(), "y":me.launchCoord.y(), "z":me.launchCoord.z()};
@@ -4636,45 +4651,45 @@ var AIM = {
# Check for terrain between own weapon and target:
me.terrainGeod = get_cart_ground_intersection(me.xyz, me.directionLOS);
if (me.terrainGeod == nil) {
- return TRUE;
+ return 1;
} else {
me.terrain = geo.Coord.new();
me.terrain.set_latlon(me.terrainGeod.lat, me.terrainGeod.lon, me.terrainGeod.elevation);
me.maxDist = me.launchCoord.direct_distance_to(me.potentialCoord)-1;#-1 is to avoid z-fighting distance
me.terrainDist = me.launchCoord.direct_distance_to(me.terrain);
if (me.terrainDist >= me.maxDist) {
- return TRUE;
+ return 1;
}
}
- return FALSE;
+ return 0;
}
- return TRUE;
+ return 1;
},
checkForClassInFlight: func (newtgt) {
# call this only after firing
- if(newtgt != nil and newtgt.isValid() == TRUE and
- ( (newtgt.get_type() == SURFACE and me.target_gnd == TRUE)
- or (newtgt.get_type() == AIR and me.target_air == TRUE)
- or (newtgt.get_type() == POINT and me.target_pnt == TRUE)
- or (newtgt.get_type() == MARINE and me.target_sea == TRUE))) {
- return TRUE;
+ if(newtgt != nil and newtgt.isValid() and
+ ( (newtgt.get_type() == SURFACE and me.target_gnd)
+ or (newtgt.get_type() == AIR and me.target_air)
+ or (newtgt.get_type() == POINT and me.target_pnt)
+ or (newtgt.get_type() == MARINE and me.target_sea))) {
+ return 1;
}
- #if(me.slaveContact != nil) printf("class failed %d %d %d",me.slaveContact.isValid() == TRUE,me.slaveContact.get_type() == AIR,me.target_air == TRUE);
- return FALSE;
+ #if(me.slaveContact != nil) printf("class failed %d %d %d",me.slaveContact.isValid() == 1,me.slaveContact.get_type() == AIR,me.target_air == 1);
+ return 0;
},
checkForClass: func {
# call this only before firing
- if(me.slaveContact != nil and me.slaveContact.isValid() == TRUE and
- ( (me.slaveContact.get_type() == SURFACE and me.target_gnd == TRUE)
- or (me.slaveContact.get_type() == AIR and me.target_air == TRUE)
- or (me.slaveContact.get_type() == POINT and me.target_pnt == TRUE)
- or (me.slaveContact.get_type() == MARINE and me.target_sea == TRUE))) {
- return TRUE;
+ if(me.slaveContact != nil and me.slaveContact.isValid() and
+ ( (me.slaveContact.get_type() == SURFACE and me.target_gnd)
+ or (me.slaveContact.get_type() == AIR and me.target_air)
+ or (me.slaveContact.get_type() == POINT and me.target_pnt)
+ or (me.slaveContact.get_type() == MARINE and me.target_sea))) {
+ return 1;
}
- #if(me.slaveContact != nil) printf("class failed %d %d %d",me.slaveContact.isValid() == TRUE,me.slaveContact.get_type() == AIR,me.target_air == TRUE);
- return FALSE;
+ #if(me.slaveContact != nil) printf("class failed %d %d %d",me.slaveContact.isValid() == 1,me.slaveContact.get_type() == AIR,me.target_air == 1);
+ return 0;
},
newLock: func (tagt) {
@@ -4703,10 +4718,10 @@ var AIM = {
me.newlockgained = me.is_radiating_me(tagt);
if (!me.newlockgained) {me.printStatsDetails("Test: not radiating me. Rejected.");return 0;}
} elsif (me.guidance == "heat") {
- me.newlockgained = me.all_aspect == TRUE or me.rear_aspect(me.coord, tagt);
+ me.newlockgained = me.all_aspect or me.rear_aspect(me.coord, tagt);
if (!me.newlockgained) {me.printStatsDetails("Test: no view of heat source. Rejected.");return 0;}
}
- if (me.guidance != "gps" and me.guidance != "inertial" and me.guidance != "sample") {
+ if (me.guidance != "gps-laser" and me.guidance != "gps" and me.guidance != "inertial" and me.guidance != "sample") {
me.new_elev_deg = me.getPitch(me.coord, me.newCoord);
me.new_course = me.coord.course_to(me.newCoord);
me.new_deviation_e = me.new_elev_deg - me.pitch;
@@ -4722,14 +4737,14 @@ var AIM = {
checkForClassInFlight: func (tact) {
# call this only after firing
- if(tact != nil and tact.isValid() == TRUE and
- ( (tact.get_type() == SURFACE and me.target_gnd == TRUE)
- or (tact.get_type() == AIR and me.target_air == TRUE)
- or (tact.get_type() == POINT and me.target_pnt == TRUE)
- or (tact.get_type() == MARINE and me.target_sea == TRUE))) {
- return TRUE;
+ if(tact != nil and tact.isValid() and
+ ( (tact.get_type() == SURFACE and me.target_gnd)
+ or (tact.get_type() == AIR and me.target_air)
+ or (tact.get_type() == POINT and me.target_pnt)
+ or (tact.get_type() == MARINE and me.target_sea))) {
+ return 1;
}
- return FALSE;
+ return 0;
},
search: func {
@@ -4737,16 +4752,16 @@ var AIM = {
if (deltaSec.getValue()==0) {
settimer(func me.search(), 0.5);
}
- if (me.deleted == TRUE) {
+ if (me.deleted) {
return;
} elsif ( me.status == MISSILE_FLYING ) {
me.SwSoundVol.setDoubleValue(0);
- me.SwSoundOnOff.setBoolValue(FALSE);
+ me.SwSoundOnOff.setBoolValue(0);
return;
} elsif ( me.status == MISSILE_STANDBY or me.status == MISSILE_STARTING) {
# Stand by.
me.SwSoundVol.setDoubleValue(0);
- me.SwSoundOnOff.setBoolValue(FALSE);
+ me.SwSoundOnOff.setBoolValue(0);
#me.trackWeak = 1;
me.standby();
return;
@@ -4762,7 +4777,7 @@ var AIM = {
me.printSearch("searching");
# search.
if(me.seam_support and me.uncage_auto) {
- me.caged = TRUE;
+ me.caged = 1;
}
me.coolingSyst();
if (!me.caged) {
@@ -4793,7 +4808,7 @@ var AIM = {
me.convertGlobalToSeekerViewDirection(me.tagt.get_bearing(), me.tagt.getElevation(), OurHdg.getValue(), OurPitch.getValue(), OurRoll.getValue());
me.testSeeker();
if (me.inBeam) {
- me.printSearch("uncaged-search found a lock");
+ me.printSearch("uncaged-search found a lock (%s %s)", me.tagt["getVirtualType"] != nil?me.tagt.getVirtualType():"orig", contactPoint!=nil);
me.goToLock();
return;
}
@@ -4802,10 +4817,10 @@ var AIM = {
}
me.Tgt = nil;
me.SwSoundVol.setDoubleValue(me.vol_search);
- me.SwSoundOnOff.setBoolValue(TRUE);
+ me.SwSoundOnOff.setBoolValue(1);
settimer(func me.search(), 0.05);# this mode needs to be a bit faster.
return;
- } elsif (me.slave_to_radar == TRUE) {
+ } elsif (me.slave_to_radar) {
me.slaveContact = nil;
if (size(me.contacts) == 0) {
me.slaveContact = me.getContact();
@@ -4829,7 +4844,7 @@ var AIM = {
}
me.testSeeker();
if (me.inBeam) {
- me.printSearch("rdr-slave-search found a lock");
+ me.printSearch("rdr-slave-search found a lock (%s %s)", me.tagt["getVirtualType"] != nil?me.tagt.getVirtualType():"orig", contactPoint!=nil);
me.goToLock();
return;
}
@@ -4851,7 +4866,7 @@ var AIM = {
# Line of sight
me.printSearch("Lock failed %d %d %d %d %d %d %d",
!(me.tagt.get_type() == AIR and me.tagt.get_Speed()<15),
- (me.guidance != "semi-radar" or me.is_painted(me.tagt) == TRUE),
+ (me.guidance != "semi-radar" or me.is_painted(me.tagt)),
me.rng < me.max_fire_range_nm,
me.rng > me.getCurrentMinFireRange(me.tagt),
me.FOV_check(OurHdg.getValue(),OurPitch.getValue(),me.total_horiz, me.total_elev, me.fcs_fov, vector.Math),
@@ -4901,7 +4916,7 @@ var AIM = {
me.convertGlobalToSeekerViewDirection(me.tagt.get_bearing(), me.tagt.getElevation(), OurHdg.getValue(), OurPitch.getValue(), OurRoll.getValue());
me.testSeeker();
if (me.inBeam) {
- me.printSearch("dir-search found a lock");
+ me.printSearch("dir-search found a lock (%s %s)",me.tagt["getVirtualType"] != nil?me.tagt.getVirtualType():"orig", contactPoint!=nil);
me.goToLock();
return;
}
@@ -4911,13 +4926,13 @@ var AIM = {
}
me.Tgt = nil;
me.SwSoundVol.setDoubleValue(me.vol_search);
- me.SwSoundOnOff.setBoolValue(TRUE);
+ me.SwSoundOnOff.setBoolValue(1);
settimer(func me.search(), 0.05);
},
goToLock: func {
me.status = MISSILE_LOCK;
- me.SwSoundOnOff.setBoolValue(TRUE);
+ me.SwSoundOnOff.setBoolValue(1);
me.SwSoundVol.setDoubleValue(me.vol_track);
me.Tgt = me.tagt;
@@ -5047,7 +5062,7 @@ var AIM = {
},
testSeeker: func {
- me.inBeam = FALSE;
+ me.inBeam = 0;
# Build unit vector components for seeker and target location in aircraft frame:
me.target_x = math.cos(me.seeker_head_target*D2R)*math.cos(me.seeker_elev_target*D2R);
@@ -5063,14 +5078,14 @@ var AIM = {
me.target_deviation = vector.Math.angleBetweenVectors([me.target_x,me.target_y,me.target_z],[me.seeker_x,me.seeker_y,me.seeker_z]);
if (me.target_deviation < me.beam_width_deg) {
- me.inBeam = TRUE;
+ me.inBeam = 1;
#me.printSearch("in beam");
}
},
computeSeekerPos: func {
# Compute HUD diamond position.
- if ( use_fg_default_hud == TRUE) {
+ if ( use_fg_default_hud) {
var h_rad = (90 - me.seeker_head) * D2R;
var e_rad = (90 - me.seeker_elev) * D2R;
var devs = develev_to_devroll(h_rad, e_rad);
@@ -5110,7 +5125,7 @@ var AIM = {
} elsif ( me.status == MISSILE_STANDBY or me.status == MISSILE_STARTING) {
# Status = stand-by.
me.reset_seeker();
- me.SwSoundOnOff.setBoolValue(FALSE);
+ me.SwSoundOnOff.setBoolValue(0);
me.SwSoundVol.setDoubleValue(0);
#me.trackWeak = 1;
me.standby();
@@ -5121,14 +5136,14 @@ var AIM = {
me.printSearch("invalid");
me.return_to_search();
return;
- } elsif (me.deleted == TRUE) {
+ } elsif (me.deleted) {
return;
} elsif (me.slave_to_radar and me.caged and me.getContact() != me.Tgt and !me.noCommonTarget) {
- me.printSearch("target switch");
+ me.printSearch("target switch (%s to %s)", me.Tgt["getVirtualType"] != nil?me.Tgt.getVirtualType():"orig", me.getContact()==nil?"nil":(me.getContact()["getVirtualType"] != nil?me.getContact().getVirtualType():"orig"));
me.return_to_search();
return;
}
- me.printSearch("lock");
+ me.printSearch("lock (caged:%d slave:%d point:%s same:%d noCommon:%d)",me.caged,me.slave_to_radar,contactPoint!=nil,me.getContact() == me.Tgt,me.noCommonTarget);
# Time interval since lock time or last track loop.
#if (me.status == MISSILE_LOCK) {
# Status = locked. Get target position relative to our aircraft.
@@ -5138,14 +5153,14 @@ var AIM = {
#me.time = props.globals.getNode("/sim/time/elapsed-sec", 1).getValue();
if(me.seam_support and me.uncage_auto) {
- me.caged = FALSE;
+ me.caged = 0;
}
me.coolingSyst();
me.computeSeekerPos();
if (me.status != MISSILE_STANDBY ) {#TODO: should this also check for starting up?
me.in_view = me.check_t_in_fov();
- if (me.in_view == FALSE) {
+ if (!me.in_view) {
me.printSearch("out of view");
me.return_to_search();
return;
@@ -5173,7 +5188,7 @@ var AIM = {
me.printSearch("out of beam or no beam for fox 1");
me.status = MISSILE_SEARCH;
me.Tgt = nil;
- me.SwSoundOnOff.setBoolValue(TRUE);
+ me.SwSoundOnOff.setBoolValue(1);
me.SwSoundVol.setDoubleValue(me.vol_search);
settimer(func me.search(), 0.1);
return;
@@ -5181,19 +5196,21 @@ var AIM = {
me.dist = geo.aircraft_position().direct_distance_to(me.Tgt.get_Coord());
- me.SwSoundOnOff.setBoolValue(TRUE);
+ me.SwSoundOnOff.setBoolValue(1);
me.SwSoundVol.setDoubleValue(me.vol_track);
- me.slaveContact = nil;
- if (size(me.contacts) == 0) {
- me.slaveContact = me.getContact();
- } else {
- me.slaveContact = me.contacts[0];
- }
- if (me.slave_to_radar and (me.slaveContact == nil or (me.slaveContact.getUnique() != nil and me.Tgt.getUnique() != nil and me.slaveContact.getUnique() != me.Tgt.getUnique()))) {
- me.printSearch("oops ");
- me.return_to_search();
- return;
+ if (!me.noCommonTarget and me.slave_to_radar) {
+ me.slaveContact = nil;
+ if (size(me.contacts) == 0) {
+ me.slaveContact = me.getContact();
+ } else {
+ me.slaveContact = me.contacts[0];
+ }
+ if (me.slaveContact == nil or me.slaveContact != me.Tgt or (me.slaveContact.getUnique() != nil and me.Tgt.getUnique() != nil and me.slaveContact.getUnique() != me.Tgt.getUnique())) {
+ me.printSearch("Radar/TGP system lock updated, dropping this lock..");
+ me.return_to_search();
+ return;
+ }
}
settimer(func me.update_lock(), deltaSec.getValue()==0?0.5:0.1);
@@ -5206,7 +5223,7 @@ var AIM = {
return_to_search: func {
me.status = MISSILE_SEARCH;
me.Tgt = nil;
- me.SwSoundOnOff.setBoolValue(TRUE);
+ me.SwSoundOnOff.setBoolValue(1);
me.SwSoundVol.setDoubleValue(me.vol_search);
#me.trackWeak = 1;
me.reset_seeker();
@@ -5224,11 +5241,11 @@ var AIM = {
me.fov_radial = vect.angleBetweenVectors(me.meVector, me.itVector);
#me.fov_radial = math.sqrt(math.pow(deviation_hori,2)+math.pow(deviation_elev,2));
if (me.fov_radial <= fov_radius) {
- return TRUE;
+ return 1;
}
# out of FOV
#if (me.status==MISSILE_FLYING) printf("1: %.1f out of %.1f, deviation %.1f, %.1f", me.fov_radial, fov_radius, deviation_hori, deviation_elev);
- return FALSE;
+ return 0;
},
FOV_check_norm: func (meHeading, mePitch, deviation_hori, deviation_elev, fov_radius,vect) {
@@ -5248,51 +5265,51 @@ var AIM = {
me.total_horiz = deviation_normdeg(OurHdg.getValue(), me.Tgt.get_bearing()); # deg.
# Check if in range and in the seeker FOV.
if (me.FOV_check(OurHdg.getValue(),OurPitch.getValue(),me.total_horiz, me.total_elev, me.slave_to_radar?(me.guidance == "heat" or me.guidance == "vision"?math.min(me.max_seeker_dev, me.fcs_fov):me.fcs_fov):me.max_seeker_dev, vector.Math) and me.Tgt.get_range() < me.max_fire_range_nm and me.Tgt.get_range() > me.getCurrentMinFireRange(me.Tgt)
- and (me.Tgt.get_range() < me.detect_range_curr_nm or (me.guidance != "radar" and me.guidance != "semi-radar" and me.guidance != "sample" and me.guidance != "heat" and me.guidance != "vision" and me.guidance != "heat" and me.guidance != "radiation"))) {
- return TRUE;
+ and (me.Tgt.get_range() < me.detect_range_curr_nm or (me.guidance != "radar" and me.guidance != "semi-radar" and me.guidance != "tvm" and me.guidance != "sample" and me.guidance != "heat" and me.guidance != "vision" and me.guidance != "heat" and me.guidance != "radiation"))) {
+ return 1;
}
# Target out of FOV or range while still not launched, return to search loop.
- return FALSE;
+ return 0;
},
is_painted: func (target) {
if(target != nil) {
me.hasPaint = target.isPainted();
- if(me.hasPaint != nil and me.hasPaint == TRUE) {
- return TRUE;
+ if(me.hasPaint != nil and me.hasPaint) {
+ return 1;
}
}
- return FALSE;
+ return 0;
},
is_laser_painted: func (target) {
if(target != nil) {
me.hasPaint = target.isLaserPainted();
- if(me.hasPaint != nil and me.hasPaint == TRUE) {
- return TRUE;
+ if(me.hasPaint != nil and me.hasPaint) {
+ return 1;
}
}
- return FALSE;
+ return 0;
},
is_radiating_me: func (target) {
if(target != nil) {
me.seeMe = target.isRadiating(me.coord);
- if (me.seeMe != nil and me.seeMe == TRUE) {
- return TRUE;
+ if (me.seeMe != nil and me.seeMe) {
+ return 1;
}
}
- return FALSE;
+ return 0;
},
is_radiating_aircraft: func (target) {
if(target != nil) {
me.seeMe = target.isRadiating(geo.aircraft_position());
- if (me.seeMe != nil and me.seeMe == TRUE) {
- return TRUE;
+ if (me.seeMe != nil and me.seeMe) {
+ return 1;
}
}
- return FALSE;
+ return 0;
},
reset_seeker: func {
@@ -5318,32 +5335,32 @@ var AIM = {
var path_base = "payload/armament/"~me.type_lc~"/flags/";
var msl_path = path_base~"msl-id-" ~ me.ID;
- me.msl_prop = props.globals.initNode( msl_path, TRUE, "BOOL", TRUE);
- me.msl_prop.setBoolValue(TRUE);# this is cause it might already exist, and so need to force value
+ me.msl_prop = props.globals.initNode( msl_path, 1, "BOOL", 1);
+ me.msl_prop.setBoolValue(1);# this is cause it might already exist, and so need to force value
var smoke_path = path_base~"smoke-id-" ~ me.ID;
- me.smoke_prop = props.globals.initNode( smoke_path, FALSE, "BOOL", TRUE);
+ me.smoke_prop = props.globals.initNode( smoke_path, 0, "BOOL", 1);
var explode_path = path_base~"explode-id-" ~ me.ID;
- me.explode_prop = props.globals.initNode( explode_path, FALSE, "BOOL", TRUE);
+ me.explode_prop = props.globals.initNode( explode_path, 0, "BOOL", 1);
var explode_smoke_path = path_base~"explode-smoke-id-" ~ me.ID;
- me.explode_smoke_prop = props.globals.initNode( explode_smoke_path, FALSE, "BOOL", TRUE);
+ me.explode_smoke_prop = props.globals.initNode( explode_smoke_path, 0, "BOOL", 1);
var explode_water_path = path_base~"explode-water-id-" ~ me.ID;
- me.explode_water_prop = props.globals.initNode( explode_water_path, FALSE, "BOOL", TRUE);
+ me.explode_water_prop = props.globals.initNode( explode_water_path, 0, "BOOL", 1);
var explode_angle_path = path_base~"explode-angle";
- me.explode_angle_prop = props.globals.initNode( explode_angle_path, 0.0, "DOUBLE", TRUE);
+ me.explode_angle_prop = props.globals.initNode( explode_angle_path, 0.0, "DOUBLE", 1);
var explode_sound_path = "payload/armament/flags/explode-sound-on-" ~ me.ID;;
- me.explode_sound_prop = props.globals.initNode( explode_sound_path, FALSE, "BOOL", TRUE);
+ me.explode_sound_prop = props.globals.initNode( explode_sound_path, 0, "BOOL", 1);
var explode_sound_vol_path = "payload/armament/flags/explode-sound-vol-" ~ me.ID;;
- me.explode_sound_vol_prop = props.globals.initNode( explode_sound_vol_path, 0, "DOUBLE", TRUE);
+ me.explode_sound_vol_prop = props.globals.initNode( explode_sound_vol_path, 0, "DOUBLE", 1);
var deploy_path = path_base~"deploy-id-" ~ me.ID;
- me.deploy_prop = props.globals.initNode(deploy_path, 0, "DOUBLE", TRUE);
+ me.deploy_prop = props.globals.initNode(deploy_path, 0, "DOUBLE", 1);
},
animate_explosion: func (hitGround) {
@@ -5355,32 +5372,32 @@ var AIM = {
me.altN.setDoubleValue(me.coord.alt()*M2FT);
me.pitchN.setDoubleValue(0);# this will make explosions from cluster bombs (like M90) align to ground 'sorta'.
me.rollN.setDoubleValue(0);# this will make explosions from cluster bombs (like M90) align to ground 'sorta'.
- me.msl_prop.setBoolValue(FALSE);
- me.smoke_prop.setBoolValue(FALSE);
+ me.msl_prop.setBoolValue(0);
+ me.smoke_prop.setBoolValue(0);
var info = geodinfo(me.coord.lat(), me.coord.lon());
if (hitGround) {
if (info == nil) {
- me.explode_water_prop.setBoolValue(FALSE);
+ me.explode_water_prop.setBoolValue(0);
} elsif (info[1] == nil) {
#print ("Building hit!");
- } elsif (info[1].solid == 0) {
- me.explode_water_prop.setBoolValue(TRUE);
+ } elsif (!info[1].solid) {
+ me.explode_water_prop.setBoolValue(1);
} else {
- me.explode_water_prop.setBoolValue(FALSE);
+ me.explode_water_prop.setBoolValue(0);
}
} else {
- me.explode_water_prop.setBoolValue(FALSE);
+ me.explode_water_prop.setBoolValue(0);
}
#print (me.typeShort);
- me.explode_prop.setBoolValue(TRUE);
+ me.explode_prop.setBoolValue(1);
me.explode_angle_prop.setDoubleValue((rand() - 0.5) * 50);
thread.lock(mutexTimer);
- append(AIM.timerQueue, [me, func me.explode_prop.setBoolValue(FALSE), [], 0.5]);
- append(AIM.timerQueue, [me, func me.explode_smoke_prop.setBoolValue(TRUE), [], 0.5]);
- append(AIM.timerQueue, [me, func {me.explode_smoke_prop.setBoolValue(FALSE);if (me.first == TRUE and size(keys(AIM.flying))>1) {me.resetFirst();}}, [], 3]);
+ append(AIM.timerQueue, [me, func me.explode_prop.setBoolValue(0), [], 0.5]);
+ append(AIM.timerQueue, [me, func me.explode_smoke_prop.setBoolValue(1), [], 0.5]);
+ append(AIM.timerQueue, [me, func {me.explode_smoke_prop.setBoolValue(0);if (me.first and size(keys(AIM.flying))>1) {me.resetFirst();}}, [], 3]);
thread.unlock(mutexTimer);
if (info == nil or !hitGround or getprop("payload/armament/enable-craters") == nil or !getprop("payload/armament/enable-craters")) {return;};
thread.lock(mutexTimer);
@@ -5393,7 +5410,7 @@ var AIM = {
append(AIM.timerQueue, [AIM, AIM.notifyCrater, [me.coord.lat(), me.coord.lon(), info[0], 2, 0, static], 0]);
thread.unlock(mutexTimer);
}
- } else if ((info[1] != nil) and (info[1].solid == 1)) {
+ } else if ((info[1] != nil) and info[1].solid) {
var crater_model = "";
var siz = -1;
if (me.weight_whead_lbm < 850 and (me.target_sea or me.target_gnd)) {
@@ -5428,7 +5445,7 @@ var AIM = {
me.lonN.setDoubleValue(me.coord.lon());
me.altN.setDoubleValue(me.coord.alt()*M2FT);
#me.pitchN.setDoubleValue(0); uncomment this to let it lie flat on ground, instead of sticking its nose in it.
- me.smoke_prop.setBoolValue(FALSE);
+ me.smoke_prop.setBoolValue(0);
},
sndPropagate: func {