Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set groundlevel to altitude.
- ship:partsdubbedpattern("cockpit")[0]:controlfrom().
- set vectors to ship:partsdubbedpattern("vector").
- set nukes to ship:partsdubbedpattern("nuc").
- set turbos to ship:partsdubbedpattern("turbofan").
- set servos to ship:modulesnamed("ModuleRoboticRotationServo").
- set proprad to 5.8.
- set autoblades to true.
- set x to 90.
- lock p to 1.
- //set targetapoapsis to 100e3.
- set autoVectoring to true.
- set mountainclearcutoff to 1000.
- set turboSpeed to 350.
- lock srfp to 90-vang(srfprograde:vector,up:vector).
- for rap in ship:partsdubbedpattern("rapier") turbos:add(rap).
- set rotormods to ship:modulesnamed("ModuleRoboticServoRotor").
- set rotors to list().
- for rm in rotormods {
- local rotor to lexicon().
- if(rm:getfield("motor") <> "Unpowered")
- {
- set rotor["part"] to rm:part.
- set rotor["mod"] to rm.
- set rotor["blades"] to list().
- for bm in rm:part:ModulesNamed("ModuleControlSurface") {
- local b to bm:part.
- local blade to lexicon().
- set blade["mod"] to bm.
- set blade["offset"] to vdot(-b:Facing:starvector, b:position - b:parent:position).
- set blade["proprad"] to proprad.
- bm:setfield("deploy", true).
- bm:setfield("pitch", true).
- bm:setfield("roll", true).
- bm:setfield("yaw", true).
- rotor["blades"]:add(blade).
- }
- rotors:add(rotor).
- if rm:hasfield("torque limit(%)") rm:setfield("torque limit(%)", 0).
- }
- }
- function ImaRocket {
- props off.
- setangle(0).
- ship:dockingports[0]:controlfrom().
- startup(vectors).
- shutoff(nukes).
- shutoff(turbos).
- }
- function ImaRocketPlane {
- props off.
- ship:rootpart:controlfrom().
- startup(vectors).
- shutoff(turbos).
- shutoff(nukes).
- }
- function ImtheRedBaron {
- parameter resetengines is true.
- if resetengines shutoff(ship:engines).
- ship:partsdubbedpattern("cockpit")[0]:controlfrom().
- for rotor in rotors {
- if rotor:mod:hasfield("torque limit(%)") rotor:mod:setfield("torque limit(%)", 100).
- if rotor:part:parent:name:contains("bay") {
- set baymod to rotor:part:parent:getmodule("ModuleAnimateGeneric").
- if baymod:hasevent("open") baymod:doevent("open").
- }
- }
- set props to true.
- lock rpmtarget to min(459,max(0, throttle * 460)).
- set props to true.
- lock deploy to max(3, taraoa + arctan2(airspeed, calcAirspeed)).
- set taraoa to 4.5.
- for m in ship:modulesnamed("WBIModuleGeneratorFX") if m:hasevent("activate fusion power") m:doevent("activate fusion power").
- on round(time:seconds * 20) {
- if props {
- set rpmcopy to rpmtarget.
- for rotor in rotors {
- rotor:mod:setfield("rpm limit", rpmcopy ).
- set calcAirspeed to (2 * constant:pi * (rotor:blades[0]:proprad + rotor:blades[0]:offset) * rpmcopy/60).
- if autoblades {
- set deploycopy to max(3, taraoa + arctan2(airspeed, calcAirspeed)).
- } else {
- set deploycopy to deploy.
- }
- for blade in rotor:blades {
- blade:mod:setfield("deploy angle", deploycopy).
- }
- }
- } else {
- for rotor in rotors {
- if rotor:mod:hasfield("torque limit(%)") rotor:mod:setfield("torque limit(%)", 0).
- if rotor:part:parent:name:contains("bay") {
- set baymod to rotor:part:parent:getmodule("ModuleAnimateGeneric").
- if baymod:hasevent("close") baymod:doevent("close").
- }
- }
- for m in ship:modulesnamed("WBIModuleGeneratorFX") if m:hasevent("deactivate fusion power") m:doevent("deactivate fusion power").
- }
- return props.
- }
- }
- 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 shutoff {
- parameter engines to ship:partsdubbedpattern("vector").
- SetEngines("Shutdown Engine", engines).
- }
- function startup {
- parameter engines to ship:partsdubbedpattern("vector").
- SetEngines("Activate Engine", engines).
- }
- 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.
- }
- lock currpitch to 90-vang(up:vector,ship:facing:vector).
- lock p to 15.
- set x to 90.
- lock st to heading(x,p).
- lock slide to -vdot(st:starvector, srfprograde:vector).
- lock b to max(-15, min(15, choose 0 if abs(slide) < 5 else slide )).
- gear off.
- brakes off.
- setangle(0).
- startup(vectors).
- set steeringmanager:Rollcontrolanglerange to 180.
- set autovectoring to true.
- gear on.
- rcs on.
- wait 5.
- startup(vectors).
- lock steering to st.
- lock throttle to periapsis < body:atm:height.
- thrustlimit(ship:engines, 100).
- info(status).
- on status {
- info(status).
- //gear off.
- return altitude < 1000.
- }
- when altitude > groundlevel + 10 then {
- info("Retracting Gear").
- gear off.
- steeringmanager:resetpids().
- }
- when altitude > 1000 then {
- lock p to 10.
- imtheredbaron(false).
- }
- when verticalSpeed > 3 then {
- steeringManager:resetpids().
- }
- when autoVectoring then {
- setangle(currpitch).
- thrustlimit(vectors,(1200-altitude)*50).
- return autoVectoring.
- }
Add Comment
Please, Sign In to add comment