Advertisement
RedDeadlyCreeper

CTEC Naval E2

Nov 25th, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.44 KB | None | 0 0
  1. @name RDC Simple Ship Movement V1.2
  2. @inputs Seat:entity Entity:entity Engine:entity Active W A S D CriticalEntites:array
  3. @outputs RudderTurn Accel Throttle Heat OverHeat MassiveOverheat TerminatePod
  4. @persist ReverseThrust NuclearPowered ForceMult Accel Val SpeedVal EVolume UVal Unit Sign EPow RudderTurn RudderMult PC PropMax
  5. @trigger W S Active
  6. interval(100)
  7. if(first()|dupefinished())
  8. {
  9. SpeedVal = 0 #Value goes from -3 to 8
  10. NuclearPowered=1 #If nuclear powered , engine cannot overheat but engine is less efficient.
  11. BiasRatio=8 # 10 = high speed, low accel, 1 = low speed, high accel
  12. RudderMult=0.07
  13. ReverseThrust = 1 #If you fucked up use this, dont forget to reverse A and D
  14.  
  15.  
  16.  
  17. Seat:soundPlay("Engine", 0, "acf_extra/tankfx/tankinside2.wav")
  18. soundVolume("Engine",1)
  19. soundPitch("Engine",0)
  20.  
  21. EVolume=Engine:volume()
  22.  
  23. BiasRatio=clamp(BiasRatio,1,10)
  24.  
  25. Val=BiasRatio/5
  26.  
  27. EPow=EVolume/150
  28.  
  29. Unit=(Val*250)/(1+NuclearPowered*0.4)
  30. PropMax=CriticalEntites:count()
  31. if(ReverseThrust)
  32. {
  33. ReverseThrust=-1
  34. }
  35. else
  36. {
  37. ReverseThrust=1
  38. }
  39. }
  40.  
  41. #if(Engine:isValid()&Active&Entity:isUnderWater())
  42. if(Engine:isValid()&Active)
  43. {
  44. if(~W&W|~S&S)
  45. {
  46. if(MassiveOverheat)
  47. {
  48. SpeedVal=clamp(SpeedVal+(W-S),-1,1)
  49. }
  50. elseif(OverHeat)
  51. {
  52. SpeedVal=clamp(SpeedVal+(W-S),-3,6)
  53. }
  54. else
  55. {
  56. SpeedVal=clamp(SpeedVal+(W-S),-3,8)
  57. }
  58. Sign=sign(SpeedVal)
  59. UVal=abs(SpeedVal/8)*Unit
  60. if(SpeedVal>0)
  61. {
  62. if(SpeedVal==8)
  63. {
  64. Seat:printDriver("Ship Full Speed Ahead")
  65. }
  66. elseif(SpeedVal==4)
  67. {
  68. Seat:printDriver("Ship Half Speed Ahead")
  69. }
  70. elseif(SpeedVal<8)
  71. {
  72. Seat:printDriver("Ship "+SpeedVal+"/8s Speed Ahead")
  73. }
  74. }
  75. else
  76. {
  77. if(SpeedVal==0)
  78. {
  79. Seat:printDriver("Ship Stop")
  80. }
  81. elseif(SpeedVal==-3)
  82. {
  83. Seat:printDriver("Ship Full Speed Astern")
  84. }
  85. else
  86. {
  87. Seat:printDriver("Ship "+abs(SpeedVal)+"/3s Speed Astern")
  88. }
  89. }
  90. if(changed(SpeedVal))
  91. {
  92. Entity:soundPlay("AdjustSpeed", 0, "acf_extra/vehiclefx/trans/default_shift.wav")
  93. soundVolume("AdjustSpeed",1)
  94. soundPitch("AdjustSpeed",150)
  95. }
  96. }
  97.  
  98. if(A|D)
  99. {
  100. RudderTurn=clamp(RudderTurn+((D-A)/4),-10,10)
  101. }
  102. else
  103. {
  104. RudderTurn*=0.9
  105. }
  106.  
  107. if(round(RudderTurn)!=0)
  108. {
  109. Entity:applyAngForce(ang(0,Entity:mass()*30*RudderMult*Entity:velL():x()*RudderTurn,0))
  110. }
  111.  
  112. Throttle=abs(Accel)/Unit
  113. if(UVal>0)
  114. {
  115. Accel=clamp(Accel+(Sign/Val*3),-UVal,UVal)#ambient/gas/steam2.wav
  116. Entity:applyForce(Accel*EPow*-Entity:forward()*ReverseThrust) #ambient/tones/industrial2_loop.wav
  117. if(!NuclearPowered)
  118. {
  119. Heat=max(Heat+(SpeedVal-3.5)*0.15,0)
  120. if(Heat>100)
  121. {
  122. if(!MassiveOverheat)
  123. {
  124. soundStop("Heat")
  125. entity():soundPlay("SuperHeat", 0, "ambient/gas/steam2.wav")
  126. soundPitch("SuperHeat",100)
  127. entity():soundPlay("Alarm", 5.5, "acf_extra/airfx/fire_alarm.wav")
  128. soundPitch("Alarm",100)
  129. Seat:printDriver("Critical Engine Temperature")
  130. SpeedVal=clamp(SpeedVal,-1,1)
  131. Sign=sign(SpeedVal)
  132. UVal=abs(SpeedVal/8)*Unit
  133. }
  134. MassiveOverheat=1
  135. Heat=100
  136. }
  137. elseif(Heat>70)
  138. {
  139. if(!OverHeat)
  140. {soundStop("Heat")
  141. entity():soundPlay("Heat", 0, "ambient/gas/steam2.wav")
  142. soundPitch("Heat",100)
  143. Seat:printDriver("Engine Overheating")
  144. SpeedVal=clamp(SpeedVal,-3,6)
  145. Sign=sign(SpeedVal)
  146. UVal=abs(SpeedVal/8)*Unit
  147. }
  148. OverHeat=1
  149. }
  150. if(MassiveOverheat){SpeedVal=clamp(SpeedVal,-1,1),if(Heat<=0){Heat=0,MassiveOverheat=0,OverHeat=0,soundStop("SuperHeat") }}
  151. elseif(OverHeat){SpeedVal=clamp(SpeedVal,-3,6),if(Heat<=70){OverHeat=0,soundStop("Heat")}}
  152. } #ambient/gas/steam2.wav
  153.  
  154. }
  155. else
  156. {
  157. Accel*=0.9
  158. Heat=max(Heat-0.6,0)
  159. }
  160. soundPitch("Engine",abs(Accel)/2+20)
  161.  
  162.  
  163.  
  164.  
  165. }
  166. else
  167. {
  168. soundPitch("Engine",0)
  169. }
  170.  
  171. if(Active)
  172. {
  173. PC=0
  174. for(I=1,PropMax){if(CriticalEntites[I,entity]:isValid()){PC+=1}}
  175.  
  176. if(PC==0){TerminatePod=1}else{TerminatePod=0}
  177. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement