Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- lock liquidmatched to min(ship:oxidizer * 9 / 11, ship:liquidfuel).
- lock NukeLiquid to max(0, ship:liquidfuel-liquidmatched).
- lock nukedv to Round(800 * 9.81 * ln(ship:mass / (ship:mass - (NukeLiquid * 0.005))), 5).
- lock oxidizermatched to min(ship:oxidizer, ship:liquidfuel * 11 / 9).
- 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).
- function SetEngines {
- parameter targetMode to "Activate Engine".
- parameter engines to ship:partsdubbedpattern("vector").
- for engine in engines {
- if engine:hasmodule("ModuleEnginesFx") set m to engine:getmodule("ModuleEnginesFx").
- if engine:hasmodule("ModuleEngines") set m to engine:getmodule("ModuleEngines").
- if m:hasaction(targetMode) m:doaction(targetMode, true).
- }
- }
- function ThrustLimit {
- parameter targetEngines.
- parameter targetThrust.
- for eng in targetEngines set eng:thrustlimit to targetThrust.
- }
- function SetAngle {
- parameter targetangle.
- for s in servos if s:hasfield("target angle") s:setfield("target angle", targetangle).
- }
- function info {
- parameter message.
- set logmessage to round(missionTime,1) + ": " + message.
- print logmessage.
- }
- for i in range(terminal:height-3) Print "":padright(terminal:width).
- set steeringmanager:rollcontrolanglerange to 180.
- toggle ag9.
- rcs on.
- set targetOrbitAltitude to 20e3.
- set vectors to ship:partsdubbedpattern("vector").
- set nukes to ship:partsdubbedpattern("nuc").
- set servos to ship:modulesnamed("ModuleRoboticRotationServo").
- lock p to 0.
- brakes off.
- lock steering to heading(90,p).
- SetEngines("Activate Engine", vectors).
- SetEngines("Activate Engine", nukes).
- lock throttle to choose apoapsis-periapsis > 500 if eta:apoapsis < 30 or apoapsis < targetOrbitAltitude else choose 30-eta:apoapsis if periapsis < 19e3 else 0.
- when nukedv < 1 then setEngines("Shutdown Engine", nukes).
- lock angletarget to 90-vang(up:vector, ship:facing:vector).
- when alt:radar > 26 then {
- gear off.
- info("engage dynamic servo").
- lock angletarget to max(0, min(90,(apoapsis/targetOrbitAltitude)*90 + 90-vang(up:vector, ship:facing:vector))).
- rcs off.
- }
- set anglecopy to angletarget.
- when true then{
- set anglecopy to angletarget.
- SetAngle(anglecopy).
- print "servo angle: " + anglecopy at (0,1).
- print " p: " + p at (0,2).
- print " apoapsis: " + apoapsis at (0,3).
- print " periapsis: " + periapsis at (0,4).
- return apoapsis-periapsis > 500 .
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement