Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // !runscript Z9qzkF1G
- set cam to addons:camera:flightcamera.
- set camflag to true.
- set cam:mode to "orbital".
- set cx to 0.
- set cy to -25.
- set cz to 0.
- set cd to cam:distance.
- set turntime to 45.
- set maxapproach to ship:deltav:vacuum/2.1.
- set distmargin to ship:bounds:size:mag * 2.
- set relvel to ship:velocity:orbit - target:velocity:orbit.
- set tarVel to target:position:normalized.
- lock steering to tarVel - relvel.
- lock throttle to choose (steering:mag + 2) / 2 if steering:mag > 0.01 and vang(steering,ship:facing:vector) < 5 else 0.
- when true then {
- set relvel to ship:velocity:orbit - target:velocity:orbit.
- set turnmargin to max(0,abs(vang(ship:facing:vector,-relvel) / 180)*(relvel:mag*turntime)).
- set rawtarSpeed to min(
- maxapproach,
- sqrt(max(0,
- (
- target:distance - turnmargin - distmargin
- )*2*(ship:availablethrust/ship:mass)
- ))
- ).
- set tarSpeed to choose rawtarspeed if rawtarspeed - relvel:mag > 10 else min(rawtarSpeed, relvel:mag).
- set tarspeed to choose 0 if target:distance < 200 else tarSpeed.
- set tarVel to target:position:normalized * tarSpeed.
- if camflag { set cam:position to (-target:position:normalized*cd)*r(cx,cy,cz). }
- return true.
- }
- when target:loaded then set distmargin to (ship:bounds:size:mag + target:bounds:size:mag).
- set sgp to 0.
- set sggo to true.
- set sgf to 8.
- set sgpr to 4.
- function sgd {
- parameter l. parameter d.
- If l:length > sgpr set sgpr to l:length.
- print (l:padleft(sgpr) + ": " +round(d,2)):padright(terminal:width) at (0, sgp).
- set sgp to sgp + 1.
- }.
- set sggo to false. wait 1. set sggo to true.
- On round(kuniverse:realtime * sgf) {
- set sgp to 0.
- sgd("Relvel:mag",Relvel:mag).
- sgd("rawtarSpeed",rawtarSpeed).
- sgd("tarSpeed",tarSpeed).
- sgd("turnmargin",turnmargin).
- sgd("tarVel:mag",tarVel:mag).
- sgd("distmargin",distmargin).
- Print "":padright(terminal:width) at (0,sgp).
- return sggo.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement