View difference between Paste ID: Ks6HvtaA and V3bpYEja
SHOW: | | - or go back to the newest paste.
1
lock liquidmatched to min(ship:oxidizer * 9 / 11, ship:liquidfuel).
2
lock NukeLiquid to max(0, ship:liquidfuel-liquidmatched).
3
lock nukedv to Round(800 * 9.81 * ln(ship:mass / (ship:mass - (NukeLiquid * 0.005))), 5).
4
5
lock oxidizermatched to min(ship:oxidizer, ship:liquidfuel * 11 / 9).
6
lock vectordv to Round(315 * 9.81 * ln((ship:mass - (NukeLiquid * 0.005)) / ((ship:mass - (NukeLiquid * 0.005)) - (liquidmatched * 0.005) - (oxidizermatched * 0.005))), 5).
7
8
bays off. brakes off. rcs on.
9
function SetEngines {
10
    parameter targetMode to "Activate Engine".
11
    parameter engines to ship:partsdubbedpattern("vector").
12
    for engine in engines {
13
        if engine:hasmodule("ModuleEnginesFx") set m to engine:getmodule("ModuleEnginesFx").
14
        if engine:hasmodule("ModuleEngines") set m to engine:getmodule("ModuleEngines").
15
        if m:hasaction(targetMode) m:doaction(targetMode, true).
16
    }
17
}
18
19
function ThrustLimit {
20
    parameter targetEngines.
21
    parameter targetThrust.
22
    for eng in targetEngines set eng:thrustlimit to targetThrust.
23
}
24
25
function SetAngle {
26
    parameter targetangle.
27
    for s in servos if s:hasfield("target angle") s:setfield("target angle", targetangle).
28
}
29
30
function info {
31
    parameter message.
32
 
33
    set logmessage to round(missionTime,1) + ": " + message.
34
    print logmessage.
35
}
36
37
38
copypath("0:","1:").
39
for i in range(terminal:height-3) Print "":padright(terminal:width).
40
41
set steeringmanager:rollcontrolanglerange to 180.
42
43-
set takeoffspeed to 100.
43+
set takeoffspeed to 200.
44-
set targetOrbitAltitude to 101e3.
44+
set targetOrbitAltitude to body:atm:height + 10e3.
45
46
set vectors to ship:partsdubbedpattern("vector").
47
set nukes to ship:partsdubbedpattern("nuc").
48
set servos to ship:modulesnamed("ModuleRoboticRotationServo"). 
49-
lock p to choose 0 if airspeed < takeoffspeed else min(25,max(0,groundspeed/7.5)).
49+
lock p to choose 5 if airspeed < takeoffspeed else min(25,max(0,groundspeed/7.5)).
50
lock steering to heading(90,p).
51-
wait 0.5.
51+
52
SetEngines("Activate Engine", vectors).
53
lock throttle to targetOrbitAltitude-apoapsis.
54-
lock angletarget to 0.
54+
lock angletarget to 5.
55-
when altitude > 72 and abs(steeringmanager:angleerror) < 5 then {
55+
56
set runwayheight to 20.
57
when alt:Radar > runwayheight-1 then {
58-
    lock angletarget to max(0, min(90,100 - ((-verticalspeed + (80-altitude)/1.5)*100))).
58+
59-
    //set p to 10.
59+
60
    lock angletarget to max(5, min(90,100 - ((-verticalspeed + (runwayheight-alt:radar)/1.5)*100))).
61
    
62
}
63-
lock vlimit to (-verticalspeed + (80-altitude))*100.
63+
64
info("initialize vtols").
65
lock vlimit to (-verticalspeed + (runwayheight-alt:radar))*100.
66
set vlimitcopy to vlimit.
67-
when abs(vang(ship:facing:vector, heading(90,0):vector)) < 5 then {
67+
68
69
when abs(vang(ship:facing:vector, heading(90,0):vector)) < 6 then {
70
     SetEngines("Activate Engine", ship:partsdubbedpattern("turbofan")).
71
}
72
73
until vlimit < 0 {
74
    set vlimitcopy to vlimit.
75
    set anglecopy to angletarget.
76
    ThrustLimit(vectors, vlimitcopy).
77
    SetAngle(anglecopy).
78
    print "   v thrust: " + vlimitcopy at (0,0).
79
    print "servo angle: " + anglecopy at (0,1).
80
    print "          p: " + p at (0,2).
81
    wait 0.
82
}
83
84
info("store vtols").
85
SetEngines("Shutdown Engine", vectors).
86
87
SetAngle(90).
88
print "   v thrust: " + vlimitcopy at (0,0).
89
print "servo angle: " + anglecopy at (0,1).
90
info("gain speed").
91
lock aoa to vang(srfprograde:vector, ship:facing:vector).
92
lock p to max(aoa+0.5,min(45, aoa+(airspeed-400)/5 )).
93
94
when altitude > 8000 then {
95
    info("go faster").
96
    lock p to vang(srfprograde:vector,heading(90,0):vector).
97
}
98
when altitude > 8000 and p < 10 then set p to 10.
99
100
when altitude > 14000 then {
101
    info("engage nukes").
102
    SetEngines("Activate Engine", nukes).
103
    set p to 15.
104
}
105
106
when altitude > 20000 then {
107
    info("push to orbit").
108
    lock p to airspeed/50.
109
    SetEngines("Activate Engine", vectors).
110
    ThrustLimit(vectors, 100).
111
}
112
when altitude > 20000 and p > 30 then lock p to 30.
113
114
115
when ship:oxidizer < 3750 then {
116
    info("preserve landing fuel").
117
    SetEngines("Shutdown Engine", vectors).
118
}
119
120
when apoapsis >= targetOrbitAltitude-5e3 then {
121
    info("lock surface prograde").
122
    lock p to vang(srfprograde:vector,heading(90,0):vector).
123
}
124
125
when altitude > 50e3 then {
126
    lock p to vang(prograde:vector,heading(90,0):vector).
127
}
128
129
when apoapsis >= targetOrbitAltitude then {
130
    info("warping to space").
131
132
    SetEngines("Shutdown Engine", ship:partsdubbedpattern("turbofan")).
133
134
    lock throttle to 0.
135
    set warpmode to "physics". 
136
    set warp to 3.
137
}
138
139
when (altitude >= body:atm:height and (periapsis > body:atm:height or ship:verticalspeed > 0)) then {
140
141
    steeringManager:resettodefault().
142
    set warp to 0. 
143
    wait until kuniverse:timewarp:issettled.
144
    set warpmode to "rails".
145
    info("adjusting apoapsis").
146
    lock throttle to choose (targetOrbitAltitude - apoapsis)/10 if apoapsis - periapsis > 10 else 0.
147-
when apoapsis >= targetOrbitAltitude and (altitude >= body:atm:height and (periapsis > body:atm:height or ship:verticalspeed > 0)) then {
147+
148-
        
148+