Advertisement
Ozin

Simple suicide burn

Sep 9th, 2020 (edited)
3,660
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 3.95 KB | None | 0 0
  1. //Simple suicide burn !runscript https://pastebin.com/QQ9HaJf4
  2. HUDTEXT("Running script: Simple landing script",20,2,22,white,false).
  3. HUDTEXT("White values in GUI are adjustable",18,2,18,yellow,false).
  4.  
  5.  
  6. //Below values are tweakable and most are also shown in the GUI:
  7. if not(defined heightMargin) set heightMargin to 15. //extra margin in meters, will come to a stop this high above the ground before lowering slowly the rest of the way.
  8. if not(defined timeMargin) set timeMargin to 0.1. //in seconds, extra margin where verticalspeed * timeMargin is subtracted from the distance used in the suiocide burn calculations
  9. if not(defined accModifier) set accModifier to 0.9. //multiplier on how much acceleration the script thinks it has available
  10. if not(defined altCutoff) set altCutoff to 999999. //will not burn when alt:radar is higher than this number, no matter what. Could be useful in high atmo bodies where engines start burning way too early.
  11. if not(defined steeringExtraHorizontalMult) set steeringExtraHorizontalMult to 0. //set this to something > 0 to increase burning horizontally
  12. if not(defined minSpeed) set minSpeed to 1. // m/s, increase this if you want the final descent to be faster than 1m/s
  13.  
  14. //STEERING - for larger crafts that have trouble turning quick enough at the end of a landing try increasing the last number below.
  15. lock steering to lookdirup(-velocity:surface + vxcl(up:vector, -velocity:surface) * steeringExtraHorizontalMult  + up:vector * 10,facing:topvector).
  16.  
  17.  
  18. if ship:name:contains("CliffJumper") toggle ag2.
  19. set bnds to ship:bounds.
  20. set th to 0. lock throttle to th.
  21.  
  22. when true then {
  23.  
  24.     set altR to max(0,bnds:bottomaltradar).
  25.     if groundspeed > 10 set altR to max(0,min(altR, vdot(up:vector, bnds:furthestcorner(-up:vector)) + altitude - max(body:geopositionof(velocity:surface * 4):terrainheight,body:geopositionof(velocity:surface * 8):terrainheight))).
  26.     set grav to body:mu/(body:radius^2).
  27.     set acc to max(1,(max(0.05,vdot(up:vector,facing:vector)) * ship:availablethrust * accModifier) / mass - grav).
  28.  
  29.  
  30.  
  31.     set throttleNeutral to grav/(vdot(up:vector, facing:vector) *ship:availablethrust/mass).
  32.     set targetSpeed to sqrt(2 * acc * max(altR - heightMargin + verticalspeed * timeMargin,0.0001)).
  33.     set th to throttleNeutral  + 4*((-verticalspeed) - max(targetSpeed, max(minSpeed,min(bnds:bottomaltradar / 1 ,10)))) / ((ship:availablethrust/mass) / grav).
  34.     if alt:radar > altCutoff set th to 0.
  35.     return not(ship:status = "landed" or ship:status = "splashed").
  36. }
  37.  
  38.  
  39. when ship:status = "landed" or ship:status = "splashed" then lock throttle to 0.
  40.  
  41. wait 0.
  42.  
  43. set menu to gui(200, 30). Set menu:x to -10. set menu:y to 400. menu:show.
  44. menu:addlabel("<b><color=yellow>Simple Landing Script</color></b>").
  45. set m1 to menu:addlabel("heightMargin:").
  46. set m2 to menu:addlabel("timeMargin:").
  47. set m3 to menu:addlabel("accModifier :").
  48. set m8 to menu:addlabel("altCutoff :").
  49. set m9 to menu:addlabel("altCutoff :").
  50. set m4 to menu:addlabel("Est. Height:").
  51. set m5 to menu:addlabel("Verticalspeed:").
  52. set m6 to menu:addlabel("TargetSpeed:").
  53. set m7 to menu:addlabel("TWR:").
  54. menu:addlabel("<i>'menu:hide'</i> to close").
  55. for txt in menu:widgets { set txt:style:fontsize to 14. set txt:style:padding:v to 1. }
  56.  
  57. on time:second {
  58.     set m1:text to "heightMargin: <color=white>" + heightMargin + "m</color>".
  59.     set m2:text to "timeMargin: <color=white>" + timeMargin + "s</color>".
  60.     set m3:text to "accModifier: <color=white>" + accModifier + "</color>".
  61.     set m8:text to "altCutoff: <color=white>" + altCutoff + "m</color> (radar)".
  62.     set m9:text to "steeringExtraHorizontalMult: <color=white>" + steeringExtraHorizontalMult + "x</color>".
  63.     set m7:text to "TWR: " + round((ship:availablethrust/mass) / grav,2).
  64.     return menu:visible.
  65. }
  66. when true then {
  67.     set m4:text to "Est. Height: " + round(altR) + "m".
  68.     set m5:text to "Verticalspeed: " + round(verticalspeed) + "m/s".
  69.     set m6:text to "TargetSpeed:" + round(-targetSpeed) + "m/s".
  70.     return menu:visible.
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement