-
Notifications
You must be signed in to change notification settings - Fork 0
/
ret_dun.ks
115 lines (97 loc) · 3.06 KB
/
ret_dun.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
// Return from Minmus
run once libguido.
print "Duna Return v0.1".
if ship:apoapsis < 20000 and body = Duna {
sas off.
wait until KUniverse:CANQUICKSAVE.
KUniverse:QUICKSAVETO("x4-prereturn").
// Let's get into a 60k orbit.
print "taking off.".
lock steering to heading(90,90).
lock throttle to 1.0.
wait 3.
print "raise ap to 60,000.".
gear off.
lock steering to heading(90,45).
wait until ship:apoapsis > 60000.
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-20).
print "turning.".
wait_turn(heading(90,0)).
print "circualrizing.".
lock throttle to 1.0.
wait until ship:periapsis > 60000 OR ship:apoapsis > 80000.
lock throttle to 0.0.
}
if ship:apoapsis < 490000 AND ship:orbit:body = Duna {
sas off.
wait until KUniverse:CANQUICKSAVE.
KUniverse:QUICKSAVETO("x5-retloworbit").
print "adjusting inclination and raising orbit to 500,000 m".
run incl.
run reorb(500000).
}
if body = Duna {
wait until KUniverse:CANQUICKSAVE.
KUniverse:QUICKSAVETO("x6-pretransfer").
// Load transfer library
run tr_pl(Kerbin,True).
my_transfer(Kerbin).
}
if body = Kerbin {
wait until KUniverse:CANQUICKSAVE.
KUniverse:QUICKSAVETO("x7-kerbin-soi").
if ship:periapsis < 40000 {
print "already in capture orbit.".
} else {
wait_turn(retrograde).
print "PE: "+round(ship:periapsis,1).
until ship:periapsis < 40000 {
if ship:periapsis > 100000 { lock throttle to 1. }
else if ship:periapsis > 41000 { lock throttle to 0.1. }
else { lock throttle to 0.01. }
wait 0.1.
}
set throttle to 0.
unlock throttle.
}
wait until KUniverse:CANQUICKSAVE.
KUniverse:QUICKSAVETO("x8-captureorbit").
print "capture orbit. PE :"+round(ship:periapsis,0).
// We are captured, slowly lower the AP+PE
unlock steering.
sas on.
wait 1.
if sasmode <> "retrograde" {
// To avoid annoying bug
set sasmode to "retrograde".
}
set warp to 0.
wait 1.
set warpmode to "rails".
set warp to 7.
// Burn rest of fuel to brake once we are low.
wait until eta:periapsis < 60 or ship:altitude < 45000.
lock throttle to 1.0.
wait until maxthrust = 0 OR ship:altitude < 11000.
lock throttle to 0.
wait 1.
safe_stage().
print "waiting for 10,000 MSL".
wait until ship:altitude < 10000.
wait until KUniverse:CANQUICKSAVE.
KUniverse:QUICKSAVETO("x9-preland").
print "waiting for parachutes to be safe.".
wait until chutessafe = True OR ship:velocity:surface:mag < 250.
print "chutes safe at alt "+round(alt:radar)+" m".
wait 1.
safe_stage().
chute on.
print "parachutes deployed.".
print "done.".
wait until KUniverse:CANQUICKSAVE.
KUniverse:QUICKSAVETO("x10-landed").
}