Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. @name Tiresmoke+Skid V2
  2. @inputs [Baseplate WheelBL WheelBR]:entity
  3. @outputs ThrustL ThrustR
  4. @persist WheelDiameter WheelSpinL WheelSpinR
  5. @persist SkidVolCoef SkidPitchCoef SkidPitchOffset ThrusterThreshold
  6. @trigger none
  7.  
  8. #Funcitions
  9. #Funcitions
  10.  
  11. function number angVel2LinVel(Prop:entity, Diameter){ #Converts the angular velocity to linear velocity
  12. return abs((toRad(Prop:angVel():pitch())*Diameter)/2)
  13. }
  14.  
  15. #End of functions
  16. #End of functions
  17.  
  18. if(dupefinished()){reset()}
  19.  
  20. interval(50)
  21.  
  22. if(first()|dupefinished()) {
  23. #Tire skid sound setup
  24. soundPlay("skid",0,"acf_nwhis/misc/tires/skid07.wav")
  25. soundVolume("skid",0)
  26. holoCreate(1)
  27. holoAlpha(1,0)
  28.  
  29. #Constants
  30. WheelDiameter = 30 # Measure with source units
  31. RideHeight = 19 #Vehicle Distance off ground
  32. SkidVolCoef = 0.001 # Increase this value to increase loudness
  33. SkidPitchCoef = 0.035 # Increase this value to make the pitc more sensitive
  34. SkidPitchOffset = 80 # Increase this value to have a higher initial pitch
  35.  
  36. ThrusterThreshold = 400 # Wheelspin value at which the thrusters engage
  37. }
  38.  
  39. Distance = 30
  40.  
  41. rangerFilter(Baseplate)
  42. Ranger = rangerOffset(Distance, Baseplate:toWorld(vec(0,0,-8)), -Baseplate:up())
  43. holoPos(1,Ranger:position())
  44. Height = (Ranger:pos()-Baseplate:pos()):length()
  45. if(Height<RideHeight){On = 1}else{On = 0}
  46.  
  47.  
  48. #Wheel spin calculations
  49. WheelSpinL = abs(Baseplate:vel():length() - angVel2LinVel(WheelBL,WheelDiameter))
  50. WheelSpinR = abs(Baseplate:vel():length() - angVel2LinVel(WheelBR,WheelDiameter))
  51.  
  52. #Thruster smoke control
  53. if(WheelSpinL > ThrusterThreshold){ThrustL = 1}
  54. else{ThrustL = 0}
  55.  
  56. if(WheelSpinR > ThrusterThreshold){ThrustR = 1}
  57. else{ThrustR = 0}
  58.  
  59.  
  60.  
  61. if(Height<Distance){soundVolume("skid",((WheelSpinL+WheelSpinR)/2)*SkidVolCoef)}else{
  62. #Sound stuff
  63. soundVolume("skid",0)
  64.  
  65. }
  66.  
  67. soundPitch("skid",SkidPitchOffset+((WheelSpinL+WheelSpinR)/2)*SkidPitchCoef)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement