*This forum post will no longer be updated, go to the new post for newer codes
Target Data
Distance from target without vertical component [m]
TargetDistance*cos(TargetElevation)
Target Altitude [m]
Altitude+(TargetDistance*sin(TargetElevation))
Target Longitude [m]
Longitude+((TargetDistance*cos(TargetElevation))*sin(TargetHeading))
Target Latitude [m]
Latitude+((TargetDistance*cos(TargetElevation))*cos(TargetHeading))
Target Speed [m/s]
sqrt(pow(rate(Altitude+(TargetDistance*sin(TargetElevation))),2)+pow(rate(Longitude+((TargetDistance*cos(TargetElevation))*sin(TargetHeading))),2)+pow(rate(Latitude+((TargetDistance*cos(TargetElevation))*cos(TargetHeading))),2))
(AI)
sqrt(pow(rate(TargetDistance * cos(TargetElevation) * sin(TargetHeading) + Longitude), 2) + pow(rate(TargetDistance * cos(TargetElevation) * cos(TargetHeading) + Latitude), 2))
Target Velocity Heading [Degrees]
(rate(Longitude+(TargetDistance*sin(TargetHeading)))>0?atan(rate(Latitude+((TargetDistance*cos(TargetElevation))*cos(TargetHeading)))/rate(Longitude+((TargetDistance*cos(TargetElevation))*sin(TargetHeading))))-90:atan(rate(Latitude+((TargetDistance*cos(TargetElevation))*cos(TargetHeading)))/rate(Longitude+((TargetDistance*cos(TargetElevation))*sin(TargetHeading))))+90)/-1
More Flight Data
Forward/Reverse Differentiation [Boolean]
clamp(AngleOfAttack,-90,90)=clamp(AngleOfAttack,-180,180)
This nifty bit of code gives a Boolean output depending on whether the craft is moving forward or not, meaning you get a +1 output when going forward and a -1 when going backwards.
Glide angle [Degrees]
atan2(rate(Altitude),sqrt(pow(rate(Longitude),2)+pow(rate(Latitude),2)))
Generates an angle defining the combination of the vertical and horizontal velocity of your aircraft.
Turn Radius [m]
abs(pow(GS,2)/((GForce-1)*9.81))
Ammo
Absolute ammo depletion [Boolean]
Thanks to @DarDragon for helping tremendously with this code!
clamp01(sum((Activate1?clamp01(ammo("AAA")=0):0)))
This code gives a permanent output of 1 when a certain ammo type is depleted. Ignores inaccurate count adjustments caused by deactivation of a given weapon's AG group
Fuel consumption
Metric
Liters per kilometer
(smooth(rate(-Fuel*FUEL CAPACITY IN LITRES),0.05))/(GS/1000)
Kilometers per liter
1/((smooth(rate(-Fuel*FUEL CAPACITY IN LITERS),0.05))/(GS/1000))
Distance until fuel depletion. (Kilometers)
(1/((smooth(rate(-Fuel*FUEL CAP),0.05))/(GS/1000)))*(Fuel*FUEL CAP)
Imperial
Gallons per mile
(smooth(rate(-Fuel*FUEL CAPACITY IN GALLONS),0.05))/(GS/1609.34)
Miles per gallon.
1/((smooth(rate(-Fuel*FUEL CAPACITY IN GALLONS),0.05))/(GS/1609.34))
Distance until fuel depletion. (Miles)
(1/((smooth(rate(-Fuel*FUEL CAP),0.05))/(GS/1609.34)))*(Fuel*FUEL CAP)
Misc
Seconds until fuel exhaustion
(Fuelcap/(rate(-Fuel)*Fuelcap))*Fuel
- Use liters
Fuel Consumption Rate
Per second
rate(-Fuel)*Fuelcap
Per minute
(rate(-Fuel)*Fuelcap)*60
Per hour
((rate(-Fuel)*Fuelcap)*60)*60
- It doesn't matter what unit you put in
NOTE. This list will be updated from time to time for new/optimized codes so make sure to check back every now and then. Also lmk if you want to be tagged whenever the list updates.
(pow(TAS,2)/(VerticalG*9.806))*3.281
turn radius in ft(pow(TAS,2)/(VerticalG*9.806))
m(provided its in a 90* bank)
@bjac0 am would like apu code for two engine plane
Any idea on how to get a missile to drop but not fire until at a certain Altitude?
Thanks for the post, really needed target data for something I wanted to build!
Una pregunta puedes hacer un código ft con el que pueda controlar naves Que allá spawneado en el juego con acceso a la cámara esque lo ví en un vídeo y también me podrías ayudar dónde se pone XD
Thank you!
So where can I put that code ??????
@Chancey21
((rate(-Fuel)*Fuelcap)*60)*60
@Chancey21 i'll have to do that tomorrow shouldn't be too tricky
@edensk good call
GPH? (Gallons per hour for planes?)
might wanna put the first one in bold instead of `` to fix the problem with comparison characters
He uses Gallons Per Mile like we fr gonna be building a Dodge Demon anytime soon
Nice!
@DarDragon @Ash007