sumguytwitches

hathi suderra props testing

Sep 7th, 2023 (edited)
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. set groundlevel to altitude.
  2. ship:partsdubbedpattern("cockpit")[0]:controlfrom().
  3.  
  4. set vectors to ship:partsdubbedpattern("vector").
  5. set nukes to ship:partsdubbedpattern("nuc").
  6. set turbos to ship:partsdubbedpattern("turbofan").
  7. set servos to ship:modulesnamed("ModuleRoboticRotationServo").
  8. set proprad to 5.8.
  9. set autoblades to true.
  10. set x to 90.
  11. lock p to 1.
  12. //set targetapoapsis to 100e3.
  13. set autoVectoring to true.
  14. set mountainclearcutoff to 1000.
  15. set turboSpeed to 350.
  16. lock srfp to 90-vang(srfprograde:vector,up:vector).
  17.  
  18. for rap in ship:partsdubbedpattern("rapier") turbos:add(rap).
  19.  
  20. set rotormods to ship:modulesnamed("ModuleRoboticServoRotor").
  21. set rotors to list().
  22. for rm in rotormods {
  23. local rotor to lexicon().
  24. if(rm:getfield("motor") <> "Unpowered")
  25. {
  26. set rotor["part"] to rm:part.
  27. set rotor["mod"] to rm.
  28.  
  29. set rotor["blades"] to list().
  30. for bm in rm:part:ModulesNamed("ModuleControlSurface") {
  31. local b to bm:part.
  32.  
  33. local blade to lexicon().
  34. set blade["mod"] to bm.
  35. set blade["offset"] to vdot(-b:Facing:starvector, b:position - b:parent:position).
  36. set blade["proprad"] to proprad.
  37.  
  38. bm:setfield("deploy", true).
  39. bm:setfield("pitch", true).
  40. bm:setfield("roll", true).
  41. bm:setfield("yaw", true).
  42.  
  43. rotor["blades"]:add(blade).
  44. }
  45.  
  46. rotors:add(rotor).
  47. if rm:hasfield("torque limit(%)") rm:setfield("torque limit(%)", 0).
  48. }
  49. }
  50. function ImaRocket {
  51. props off.
  52. setangle(0).
  53. ship:dockingports[0]:controlfrom().
  54. startup(vectors).
  55. shutoff(nukes).
  56. shutoff(turbos).
  57. }
  58.  
  59.  
  60. function ImaRocketPlane {
  61. props off.
  62. ship:rootpart:controlfrom().
  63. startup(vectors).
  64. shutoff(turbos).
  65. shutoff(nukes).
  66. }
  67.  
  68. function ImtheRedBaron {
  69. parameter resetengines is true.
  70. if resetengines shutoff(ship:engines).
  71. ship:partsdubbedpattern("cockpit")[0]:controlfrom().
  72. for rotor in rotors {
  73. if rotor:mod:hasfield("torque limit(%)") rotor:mod:setfield("torque limit(%)", 100).
  74. if rotor:part:parent:name:contains("bay") {
  75. set baymod to rotor:part:parent:getmodule("ModuleAnimateGeneric").
  76. if baymod:hasevent("open") baymod:doevent("open").
  77. }
  78. }
  79. set props to true.
  80.  
  81. lock rpmtarget to min(459,max(0, throttle * 460)).
  82.  
  83. set props to true.
  84. lock deploy to max(3, taraoa + arctan2(airspeed, calcAirspeed)).
  85. set taraoa to 4.5.
  86. for m in ship:modulesnamed("WBIModuleGeneratorFX") if m:hasevent("activate fusion power") m:doevent("activate fusion power").
  87.  
  88. on round(time:seconds * 20) {
  89. if props {
  90. set rpmcopy to rpmtarget.
  91. for rotor in rotors {
  92.  
  93. rotor:mod:setfield("rpm limit", rpmcopy ).
  94. set calcAirspeed to (2 * constant:pi * (rotor:blades[0]:proprad + rotor:blades[0]:offset) * rpmcopy/60).
  95. if autoblades {
  96. set deploycopy to max(3, taraoa + arctan2(airspeed, calcAirspeed)).
  97. } else {
  98. set deploycopy to deploy.
  99. }
  100. for blade in rotor:blades {
  101. blade:mod:setfield("deploy angle", deploycopy).
  102. }
  103. }
  104.  
  105. } else {
  106. for rotor in rotors {
  107. if rotor:mod:hasfield("torque limit(%)") rotor:mod:setfield("torque limit(%)", 0).
  108.  
  109. if rotor:part:parent:name:contains("bay") {
  110. set baymod to rotor:part:parent:getmodule("ModuleAnimateGeneric").
  111. if baymod:hasevent("close") baymod:doevent("close").
  112. }
  113. }
  114. for m in ship:modulesnamed("WBIModuleGeneratorFX") if m:hasevent("deactivate fusion power") m:doevent("deactivate fusion power").
  115. }
  116. return props.
  117. }
  118.  
  119.  
  120. }
  121.  
  122. function SetEngines {
  123. parameter targetMode to "Activate Engine".
  124. parameter engines to ship:partsdubbedpattern("vector").
  125. for engine in engines {
  126. if engine:hasmodule("ModuleEnginesFx") set m to engine:getmodule("ModuleEnginesFx").
  127. if engine:hasmodule("ModuleEngines") set m to engine:getmodule("ModuleEngines").
  128. if m:hasaction(targetMode) m:doaction(targetMode, true).
  129. }
  130. }
  131.  
  132. function shutoff {
  133. parameter engines to ship:partsdubbedpattern("vector").
  134. SetEngines("Shutdown Engine", engines).
  135. }
  136.  
  137. function startup {
  138. parameter engines to ship:partsdubbedpattern("vector").
  139. SetEngines("Activate Engine", engines).
  140. }
  141.  
  142. function ThrustLimit {
  143. parameter targetEngines.
  144. parameter targetThrust.
  145. for eng in targetEngines set eng:thrustlimit to targetThrust.
  146. }
  147.  
  148. function SetAngle {
  149. parameter targetangle.
  150. for s in servos if s:hasfield("target angle") s:setfield("target angle", targetangle).
  151. }
  152.  
  153. function info {
  154. parameter message.
  155.  
  156. set logmessage to round(missionTime,1) + ": " + message.
  157. print logmessage.
  158. }
  159. lock currpitch to 90-vang(up:vector,ship:facing:vector).
  160. lock p to 15.
  161. set x to 90.
  162. lock st to heading(x,p).
  163. lock slide to -vdot(st:starvector, srfprograde:vector).
  164. lock b to max(-15, min(15, choose 0 if abs(slide) < 5 else slide )).
  165.  
  166. gear off.
  167. brakes off.
  168.  
  169. setangle(0).
  170. startup(vectors).
  171. set steeringmanager:Rollcontrolanglerange to 180.
  172.  
  173. set autovectoring to true.
  174. gear on.
  175. rcs on.
  176. wait 5.
  177.  
  178. startup(vectors).
  179. lock steering to st.
  180. lock throttle to periapsis < body:atm:height.
  181. thrustlimit(ship:engines, 100).
  182.  
  183. info(status).
  184. on status {
  185. info(status).
  186. //gear off.
  187. return altitude < 1000.
  188. }
  189.  
  190. when altitude > groundlevel + 10 then {
  191. info("Retracting Gear").
  192.  
  193. gear off.
  194. steeringmanager:resetpids().
  195. }
  196. when altitude > 1000 then {
  197. lock p to 10.
  198. imtheredbaron(false).
  199. }
  200.  
  201. when verticalSpeed > 3 then {
  202. steeringManager:resetpids().
  203. }
  204.  
  205. when autoVectoring then {
  206. setangle(currpitch).
  207. thrustlimit(vectors,(1200-altitude)*50).
  208. return autoVectoring.
  209. }
  210.  
  211.  
Add Comment
Please, Sign In to add comment