-
Notifications
You must be signed in to change notification settings - Fork 0
/
ret_mun.ks
161 lines (120 loc) · 3.34 KB
/
ret_mun.ks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// Return from Mun
run once libguido.
print "Mun Return v0.1".
sas off.
if ship:apoapsis < 20000 and body = Mun {
// Parked on the Mun, let's get into a 20k-30k orbit.
print "taking off.".
lock steering to heading(90,90).
lock throttle to 1.0.
wait 3.
print "raise ap to 25,000.".
gear off.
lock steering to heading(90,45).
wait until ship:apoapsis > 25000.
lock throttle to 0.
print "ap: "+round(ship:apoapsis,1)+" eta "+round(eta:apoapsis,1).
set warpmode to "rails".
until eta:apoapsis < 30 { set warp to 3. }
rwait(eta:apoapsis-10).
print "turning.".
wait_turn(heading(90,0)).
print "circualrizing.".
lock throttle to 1.0.
wait until ship:periapsis > 20000.
lock throttle to 0.0.
}
if ship:apoapsis > 20000 and body = Mun {
print "waiting for ejection point.".
set dst_ang to -22.
set ang to 99.
until ang < 1 {
set ang to MAX(MOD(-longitude+dst_ang+720,360),0.0001).
// Estimate how long we need to wait
set dt to MAX(ABS(ship:orbit:period/360*ang),1).
print "eta: "+floor(dt)+" s ( "+floor(ang)+" )".
if dt > 60 {
set warpmode to "rails". wait 0.1.
warpto(time:seconds+dt-30).
wait dt-30+1.
pstop().
} else if dt > 10 {
lock steering to ship:prograde.
set warpmode to "physics".
wait 0.1.
warpto(time:seconds+dt/2).
wait dt/2+1.
pstop().
} else {
lock steering to ship:prograde.
wait dt/3.
}
}
print "ejection burn.".
wait_turn(prograde).
set throttle to 1.0.
wait until ship:apoapsis < 0.
wait 0.1.
set throttle to 0.
until body = Kerbin {
set warpmode to "rails".
set warp to 5.
}
}
if ship:periapsis < 48000 {
print "already in capture orbit.".
} else {
// Multiple times... rounding errors
print "warp for AP. 95%".
rwait(eta:apoapsis*0.95).
print "warp for AP. 100%".
rwait(eta:apoapsis).
until ship:periapsis < 48000 AND ship:periapsis > 43000 {
// Lower PE
print "turning retrograde.".
wait_turn(retrograde).
print "PE: "+ship:periapsis.
until ship:periapsis < 48000 {
if ship:periapsis > 200000 { lock throttle to 1. }
else if ship:periapsis > 60000 { lock throttle to 0.1. }
else { lock throttle to 0.01. }
Wait 0.1.
}
lock throttle to 0.
// Check in case we need to raise PE
if ship:periapsis < 43000 {
wait_turn(prograde).
lock throttle to 0.01.
wait until ship:periapsis > 43000.
lock throttle to 0.
}
}
unlock throttle.
}
print "capture orbit. PE :"+round(ship:periapsis,0).
// We are captured, slowly lower the AP+PE
unlock steering.
sas on.
wait 1.
//set sasmode to "retrograde".
set warp to 0.
wait 1.
set warpmode to "rails".
set warp to 5.
wait until eta:periapsis < 60 or ship:altitude < 45000.
lock throttle to 1.0.
wait until maxthrust = 0.
lock throttle to 0.
wait 1.
stage.
print "waiting for 10,000 MSL".
wait until ship:altitude < 10000.
print "waiting for parachutes to be safe.".
wait until chutessafe = True.
print "chutes safe at alt "+alt:radar.
wait 1.
stage.
chute on.
print "parachutes deployed.".
print "done.".