Profile image

some codes I made

347 tomlin5412  4.5 years ago

I don't like building planes but I like writing funky trees codes to make some planes flies well
here are some codes I've made:
Fighter
Pitch & Auto Trim Control(5deg/s max)-0 pitch input to make it auto trim:
clamp(((smooth(Pitch,1)+clamp(PID(Trim/20*clamp01(Pitch=0),PitchRate/100*clamp01(Pitch=0),1,15,0),-1,1))/clamp((((IAS-100)/100)*clamp01(IAS>100)+1),-100,100)),-1,1)

New version(Gforce control)
clamp(((smooth(smooth(Pitch,1)-smooth(clamp01((abs((PitchRate*(pi/180)*TAS)/9.80665)+abs(rate((PitchRate*(pi/180)*TAS)/9.80665)/20))>9),1/clamp(TAS/50,1,20)+
clamp01(abs(PitchRate*(pi/180)*TAS/9.80665)-9))*abs(smooth(Pitch,1))*sign(PitchRate),1)+clamp(PID(Trim/20*clamp01(Pitch=0),PitchRate/100*clamp01(Pitch=0),1,15,0),-1,1))
/clamp((((IAS-100)/100)*clamp01(IAS>100)+1),-100,100)),-1,1)

Roll 360deg/s:
clamp(PID(Roll,-RollRate/360,1,0,0),-1,1)

VTOL(AG1,Throttle&Brake to control,5m/s max)
clamp01(PID(smooth((Throttle-Brake)*clamp01(Activate1),0.25),rate(Altitude)/5*clamp01(Activate1),1,1,0)*clamp01(Activate1)+Throttle*clamp01(-Activate1))

Bomber / Transport Autopilot(height/pitchangle)-must be use on rotators and use with auto level together
Climb Rate 30m/s max/Pitch Angle 30deg max(AG1 to switch):
clamp(PID(clamp(PID(smooth((Trim*2+Pitch)*clamp01(Activate1),0.2),-rate(Altitude)/10*clamp01(Activate1),0.5,1,0),-2,2),-PitchAngle/15,0.5,0,0)*clamp01(Activate1)
+PID(smooth((Pitch+Trim/2)*clamp01(-Activate1),1),-PitchAngle/20,1,0,0)*clamp01(-Activate1),-1,1)-PitchRate/20

Auto Wing Level(60deg max):
clamp(PID(smooth(Roll,0.2),-RollAngle/60,2.5,1,0),-1,1)

Helicopter Auto/Manual Hover(AG1,10m/s max)-use this on collective pitch:
clamp(PID(smooth(VTOL*clamp01(Activate1),0.25),rate(Altitude)/10*clamp01(Activate1),1,1,0)*clamp01(Activate1)+(VTOL+1)/2*clamp01(Activate1=0),-1,1)

Pitch Axis(LG activate,brake to hover):
PID(clamp(smooth(Pitch,0.5)-smooth(Brake*clamp01(GS)*cos(AngleOfSlip)*abs(cos(AngleOfAttack)),0.5)/4,-1,1)*clamp01(LandingGear),-PitchAngle/30*clamp01(LandingGear),1,1,0)

Roll Axis(LG activate,brake to hover):
PID(clamp(smooth(Roll,0.5)-smooth(Brake*clamp01(GS)*sin(AngleOfSlip)*abs(cos(AngleOfAttack)),0.5)/4,-1,1)*clamp01(LandingGear),-RollAngle/30*clamp01(LandingGear),1,1,0)

Turret:
Range adjustment(max 10km,90deg range of hinge,1500m/s muzzle velocity)-use cockpit to aim or this code will not work correctly
(asin(((10000*cos(PitchAngle)+((10000*sin(PitchAngle))/(10000*cos(PitchAngle))))*Throttle*9.80665)/(pow(1500,2)))/2)/90

Horizontal(no limited (yes the shortest one)):
sum(Roll/2)

Horizontal(no limited+5x slower turning(AG1 to slow down)):
sum(Roll/(2+8*clamp01(Activate1)))

Horizontal(limited):
smooth(clamp(sign(Roll),-1,1)*clamp01(Roll!=0),0.5*abs(Roll))

Horizontal(limited+5x slower turning(AG1 to slow down)):
smooth(clamp(sign(Roll),-1,1)*clamp01(Roll!=0),(0.5-0.4*clamp01(Activate1))*abs(Roll))

Vertical(limited):
smooth(clamp(sign(Pitch),-1,1)*clamp01(Pitch!=0),0.5*abs(Pitch))

Vertical(limited+5x slower elevating(AG1 to slow down)):
smooth(clamp(sign(Pitch),-1,1)*clamp01(Pitch!=0),(0.5-0.4*clamp01(Activate1))*abs(Pitch))

Auto turret(1.10 update):
horizontal:(rotor:150deg,muzzle velocity:1500m/s)
smooth(clamp(TargetSelected?(deltaangle(Heading,TargetHeading)+rate(TargetHeading)*(((1500*sin(asin((TargetDistance*9.81)/(pow(1500,2)))/2))/9.81)*2))/180:0,-1,1),0.3)

vertical:(rotor:10deg,muzzle velocity:1500m/s)
smooth(clamp(TargetSelected?(TargetElevation+rate(TargetElevation)*(((1500*sin(asin((TargetDistance*9.81)/(pow(1500,2)))/2))/9.81)*2))/10:0,-0.5,6.5),4)

just copy and paste on your craft and test. These codes should be work on almost all crafts

  • Log in to leave a comment
  • Profile image

    Please help me on what principle and how do I write code??????

    29 days ago
  • Profile image

    cool

    29 days ago
  • Profile image
    16.9k dekanii

    Damn, this is very very helpful, thanks for this!

    6 months ago
  • Profile image
    2,357 ACEVIPER9710

    @GuyFolk thanks!

    1.4 years ago
  • Profile image
    105k GuyFolk

    @ACEVIPER9710
    To put it simply, you can play around with number behind PitchRate.
    Like PitchRate/50, PitchRate/100, PitchRate/500 etc.

    +1 1.4 years ago
  • Profile image
    2,357 ACEVIPER9710

    @GuyFolk hey, im trying to work on my mig 29 and the first code for auto trim i used but i want more AoA to be used to effort to keeping its path. i saw on your f22 that it does that and i dont know how to change its auto trim limiter. some help would be great, thank you. and great work on the F-35!

    1.4 years ago
  • Profile image

    How to increase GForce on GForce control code?

    1.4 years ago
  • Profile image
    2,101 Khanhlam

    @GuyFolk
    It works, getting lazy and do nothing in a week or more...

    1.7 years ago
  • Profile image
    105k GuyFolk

    @Khanhlam
    Code broke, pain.
    Code work, euphoria for a week.

    +3 1.7 years ago
  • Profile image
    2,101 Khanhlam

    @GuyFolk
    "If you know how to code, this Funky Tree thing would be easy."

    Codes broke, Pain, code again, pain, code again, pain until you finally managed to fix it.
    Not really lol.

    +2 1.7 years ago
  • Profile image
    105k GuyFolk

    @ACEVIPER9710
    You might want to go and watch those videos in my bio, they are some basic code you can implement in the plane.
    If you know how to code, this Funky Tree thing would be easy.

    1.7 years ago
  • Profile image
    2,101 Khanhlam

    @GuyFolk
    You might wanna help @ACEVIPER9710 lol.

    1.7 years ago
  • Profile image
    2,357 ACEVIPER9710

    @Khanhlam I know most coding and I would just want to know how I can implement it into PitchRate or sm

    1.7 years ago
  • Profile image
    2,101 Khanhlam

    @ACEVIPER9710
    I can't describe it well but technically it's about controlling something using codes, in here it's our jet using advanced coding called Funky Trees.
    In order to use it you must know about coding, math and physics.

    +1 1.7 years ago
  • Profile image
    2,357 ACEVIPER9710

    @Khanhlam how does pid work and how can i use it??

    1.7 years ago
  • Profile image
    2,357 ACEVIPER9710

    how does even PID work??

    1.7 years ago
  • Profile image
    105k GuyFolk

    @Khanhlam
    Go ahead, who am I to say no.

    2.1 years ago
  • Profile image
    2,101 Khanhlam

    @GuyFolk Some people like simple, some love complicated.
    I respect that lol!
    I'll try to learn then Funky first then do complicated stuff lol, i love complicated things.

    +1 2.1 years ago
  • Profile image
    105k GuyFolk

    @Khanhlam
    I just want consistency and simplicity, all those button will have no function.

    +1 2.1 years ago
  • Profile image
    2,101 Khanhlam

    @GuyFolk Lol, btw your jet has a HUD button on the cockpit but why don't you code the function to get the HUD on when it's activated lol, it would make it more realistic:P

    2.1 years ago
  • Profile image
    105k GuyFolk

    @Khanhlam
    Do whatever work for you, I guess.

    2.1 years ago
  • Profile image
    2,101 Khanhlam

    @GuyFolk Long "paragraph" > short "paragraph" lol
    Jk
    I'll learn the basics first, then get more advanced.

    2.1 years ago
  • Profile image
    105k GuyFolk

    @Khanhlam
    I don't know, you answer that yourself lol.
    I guess you'd be going back and forth between this page and Snowflake's FT guide, I think there are many variables that you are not familiar with.
    But some code is short enough and I recommend you to just try it out in game.

    +1 2.1 years ago
  • Profile image
    2,101 Khanhlam

    @GuyFolk Should i start to learn with this???
    Knowing PID, Smooth,etc.

    2.1 years ago
  • Profile image

    @rexyX123456 overload mod

    2.1 years ago
  • Log in to see more comments