Advertisement
sumguytwitches

0zin vtol

Aug 26th, 2020
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. set steeringmanager:rollcontrolanglerange to 180.
  2. set steeringmanager:rollpid:kp to 0.4.
  3. set servos to ship:modulesnamed("ModuleRoboticRotationServo").
  4. for s in servos s:setfield("traverse rate", 10).
  5. set st to lookdirup(up:vector, facing:topvector).
  6. lock steering to st.
  7. set hdg to 90. set sl to 0.
  8.  
  9.  
  10. function tilt { parameter tlt is 0. for s in servos s:setfield("target angle", tlt). }
  11. list engines in engs.
  12. function vertThrust {
  13. set vth to 0.
  14. for e in engs if e:ignition set vth to vth + vdot(up:vector, e:facing:vector * (choose -1 if e:tag = "reverse" else 1)) * e:availablethrust.
  15. return max(1,vth).
  16. }
  17. on round(time:seconds * 5) { set twr to vertThrust()/ship:mass/body:mu*body:position:sqrmagnitude. return true. }
  18.  
  19.  
  20. set twr to 1.
  21. lock terAlt to max(0,max(ship:geoposition:terrainheight, body:geopositionof(velocity:surface * 6):terrainheight)).
  22. lock talt to 20 + terAlt.
  23. lock vs to max(-30,min(100,((talt^0.8) - (max(0.1,altitude)^0.8)) / 2)).
  24. set tpid to pidloop(5,0.5, 9, -0.75, 4).
  25. lock mul to 1 + tpid:update(time:seconds,verticalspeed - vs).
  26. lock throttle to mul/twr.
  27.  
  28.  
  29.  
  30. lock tv to heading(hdg,0):vector * sl.
  31. set tltpid to pidloop(20, 2, 25, -35, 55).
  32. on round(time:seconds * 12) {
  33. set relVelVec to vxcl(up:vector, tv - velocity:surface) / 4.
  34. set relVelVec:mag to min(5,relVelVec:mag).
  35. tilt(tltpid:update(time:seconds, vdot(facing:topvector, relVelVec))).
  36. set st to lookdirup(velocity:surface / -500 + up:vector * 10 + vxcl(vxcl(up:vector,facing:topvector),relVelVec),(choose tv * -1 if tv:mag > 2 else facing:topvector)).
  37. return not(abort).
  38. }
  39.  
  40.  
  41. set aftE to ship:partstagged("aft")[0].
  42. when true then {
  43. set aftE:thrustlimit to choose 0 if tv:mag < 10 else vdot(aftE:facing:vector, tv-velocity:surface) * 30.
  44. return true.
  45. }
  46. stage.
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement