View difference between Paste ID: WKLAvLk7 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.
8+
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:").
38+
39
for i in range(terminal:height-3) Print "":padright(terminal:width).
40
41
set steeringmanager:rollcontrolanglerange to 180.
42
toggle ag9.
43-
set takeoffspeed to 100.
43+
rcs on.
44-
set targetOrbitAltitude to 101e3.
44+
set targetOrbitAltitude to 20e3.
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 0.
50
brakes off.
51-
wait 0.5.
51+
52
53-
lock throttle to targetOrbitAltitude-apoapsis.
53+
54-
lock angletarget to 0.
54+
SetEngines("Activate Engine", nukes).
55-
when altitude > 72 and abs(steeringmanager:angleerror) < 5 then {
55+
lock throttle to choose apoapsis-periapsis > 500 if eta:apoapsis < 30 or apoapsis < targetOrbitAltitude else choose 30-eta:apoapsis if periapsis < 19e3 else 0.
56
when nukedv < 1 then setEngines("Shutdown Engine", nukes).
57
lock angletarget to 90-vang(up:vector, ship:facing:vector).
58-
    lock angletarget to max(0, min(90,100 - ((-verticalspeed + (80-altitude)/1.5)*100))).
58+
when alt:radar > 26 then {
59-
    //set p to 10.
59+
60
    info("engage dynamic servo").
61
    lock angletarget to max(0, min(90,(apoapsis/targetOrbitAltitude)*90 + 90-vang(up:vector, ship:facing:vector))).
62-
info("initialize vtols").
62+
	rcs off.
63-
lock vlimit to (-verticalspeed + (80-altitude))*100.
63+
64-
set vlimitcopy to vlimit.
64+
65
66
67-
when abs(vang(ship:facing:vector, heading(90,0):vector)) < 5 then {
67+
68-
     SetEngines("Activate Engine", ship:partsdubbedpattern("turbofan")).
68+
69
70
when true then{
71-
until vlimit < 0 {
71+
72-
    set vlimitcopy to vlimit.
72+
73
    print "servo angle: " + anglecopy at (0,1).
74-
    ThrustLimit(vectors, vlimitcopy).
74+
75
	print "   apoapsis: " + apoapsis at (0,3).
76-
    print "   v thrust: " + vlimitcopy at (0,0).
76+
	print "  periapsis: " + periapsis at (0,4).
77
	return apoapsis-periapsis > 500 .
78
}