SHOW:
|
|
- or go back to the newest paste.
1 | if not (defined launch_margin) declare global launch_margin is 60. | |
2 | if not (defined orbital_speed_multiplier) declare global orbital_speed_multiplier is 0.6. | |
3 | set t0 to time:seconds. | |
4 | set r0 to ship:position-body:position. | |
5 | set rh to vxcl(v(0,1,0),r0). | |
6 | set rv to vxcl(rh,r0). | |
7 | set ph to vcrs(rh,v(0,1,0)). | |
8 | lock t to time:seconds. | |
9 | function pos {parameter x. return positionat(x,t)-x:body:position.} | |
10 | function vel {parameter x. return velocityat(x,t):obt.} | |
11 | function nrm {parameter x. return vcrs(vel(x),pos(x)):normalized.} | |
12 | lock rs to pos(ship). lock vs to vel(ship). lock ns to nrm(ship). | |
13 | lock rt to pos(target). lock vt to vel(target). lock nt to nrm(target). | |
14 | set a to vdot(rh,nt). | |
15 | set b to vdot(ph,nt). | |
16 | set arg to -vdot(rv,nt)/sqrt(a^2+b^2). | |
17 | if(abs(arg) > 1) log_error("no solution"). | |
18 | set theta1 to arccos(arg). | |
19 | set theta2 to 360-theta1. | |
20 | set q1 to mod(360+theta1+arctan2(b,a),360). | |
21 | set q2 to mod(360+theta2+arctan2(b,a),360). | |
22 | set first to min(q1,q2). | |
23 | set tlaunch to t0 + (first/360)*body:rotationperiod - launch_margin. | |
24 | ||
25 | - | print "Warping to launch window...". |
25 | + | |
26 | - | if time:seconds < tlaunch-300 {warpto(tlaunch-300). wait 0.} |
26 | + | |
27 | - | wait until warp=0 and kuniverse:timewarp:issettled and velocity:surface:mag < 0.1 and time:seconds > tlaunch-300. |
27 | + | |
28 | - | if time:seconds < tlaunch-10 {set warp to 1. wait 1. warpto(tlaunch-10). wait 0.} |
28 | + |