Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name RDC Simple Ship Movement V1.2
- @inputs Seat:entity Entity:entity Engine:entity Active W A S D CriticalEntites:array
- @outputs RudderTurn Accel Throttle Heat OverHeat MassiveOverheat TerminatePod
- @persist ReverseThrust NuclearPowered ForceMult Accel Val SpeedVal EVolume UVal Unit Sign EPow RudderTurn RudderMult PC PropMax
- @trigger W S Active
- interval(100)
- if(first()|dupefinished())
- {
- SpeedVal = 0 #Value goes from -3 to 8
- NuclearPowered=1 #If nuclear powered , engine cannot overheat but engine is less efficient.
- BiasRatio=8 # 10 = high speed, low accel, 1 = low speed, high accel
- RudderMult=0.07
- ReverseThrust = 1 #If you fucked up use this, dont forget to reverse A and D
- Seat:soundPlay("Engine", 0, "acf_extra/tankfx/tankinside2.wav")
- soundVolume("Engine",1)
- soundPitch("Engine",0)
- EVolume=Engine:volume()
- BiasRatio=clamp(BiasRatio,1,10)
- Val=BiasRatio/5
- EPow=EVolume/150
- Unit=(Val*250)/(1+NuclearPowered*0.4)
- PropMax=CriticalEntites:count()
- if(ReverseThrust)
- {
- ReverseThrust=-1
- }
- else
- {
- ReverseThrust=1
- }
- }
- #if(Engine:isValid()&Active&Entity:isUnderWater())
- if(Engine:isValid()&Active)
- {
- if(~W&W|~S&S)
- {
- if(MassiveOverheat)
- {
- SpeedVal=clamp(SpeedVal+(W-S),-1,1)
- }
- elseif(OverHeat)
- {
- SpeedVal=clamp(SpeedVal+(W-S),-3,6)
- }
- else
- {
- SpeedVal=clamp(SpeedVal+(W-S),-3,8)
- }
- Sign=sign(SpeedVal)
- UVal=abs(SpeedVal/8)*Unit
- if(SpeedVal>0)
- {
- if(SpeedVal==8)
- {
- Seat:printDriver("Ship Full Speed Ahead")
- }
- elseif(SpeedVal==4)
- {
- Seat:printDriver("Ship Half Speed Ahead")
- }
- elseif(SpeedVal<8)
- {
- Seat:printDriver("Ship "+SpeedVal+"/8s Speed Ahead")
- }
- }
- else
- {
- if(SpeedVal==0)
- {
- Seat:printDriver("Ship Stop")
- }
- elseif(SpeedVal==-3)
- {
- Seat:printDriver("Ship Full Speed Astern")
- }
- else
- {
- Seat:printDriver("Ship "+abs(SpeedVal)+"/3s Speed Astern")
- }
- }
- if(changed(SpeedVal))
- {
- Entity:soundPlay("AdjustSpeed", 0, "acf_extra/vehiclefx/trans/default_shift.wav")
- soundVolume("AdjustSpeed",1)
- soundPitch("AdjustSpeed",150)
- }
- }
- if(A|D)
- {
- RudderTurn=clamp(RudderTurn+((D-A)/4),-10,10)
- }
- else
- {
- RudderTurn*=0.9
- }
- if(round(RudderTurn)!=0)
- {
- Entity:applyAngForce(ang(0,Entity:mass()*30*RudderMult*Entity:velL():x()*RudderTurn,0))
- }
- Throttle=abs(Accel)/Unit
- if(UVal>0)
- {
- Accel=clamp(Accel+(Sign/Val*3),-UVal,UVal)#ambient/gas/steam2.wav
- Entity:applyForce(Accel*EPow*-Entity:forward()*ReverseThrust) #ambient/tones/industrial2_loop.wav
- if(!NuclearPowered)
- {
- Heat=max(Heat+(SpeedVal-3.5)*0.15,0)
- if(Heat>100)
- {
- if(!MassiveOverheat)
- {
- soundStop("Heat")
- entity():soundPlay("SuperHeat", 0, "ambient/gas/steam2.wav")
- soundPitch("SuperHeat",100)
- entity():soundPlay("Alarm", 5.5, "acf_extra/airfx/fire_alarm.wav")
- soundPitch("Alarm",100)
- Seat:printDriver("Critical Engine Temperature")
- SpeedVal=clamp(SpeedVal,-1,1)
- Sign=sign(SpeedVal)
- UVal=abs(SpeedVal/8)*Unit
- }
- MassiveOverheat=1
- Heat=100
- }
- elseif(Heat>70)
- {
- if(!OverHeat)
- {soundStop("Heat")
- entity():soundPlay("Heat", 0, "ambient/gas/steam2.wav")
- soundPitch("Heat",100)
- Seat:printDriver("Engine Overheating")
- SpeedVal=clamp(SpeedVal,-3,6)
- Sign=sign(SpeedVal)
- UVal=abs(SpeedVal/8)*Unit
- }
- OverHeat=1
- }
- if(MassiveOverheat){SpeedVal=clamp(SpeedVal,-1,1),if(Heat<=0){Heat=0,MassiveOverheat=0,OverHeat=0,soundStop("SuperHeat") }}
- elseif(OverHeat){SpeedVal=clamp(SpeedVal,-3,6),if(Heat<=70){OverHeat=0,soundStop("Heat")}}
- } #ambient/gas/steam2.wav
- }
- else
- {
- Accel*=0.9
- Heat=max(Heat-0.6,0)
- }
- soundPitch("Engine",abs(Accel)/2+20)
- }
- else
- {
- soundPitch("Engine",0)
- }
- if(Active)
- {
- PC=0
- for(I=1,PropMax){if(CriticalEntites[I,entity]:isValid()){PC+=1}}
- if(PC==0){TerminatePod=1}else{TerminatePod=0}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement