RedDeadlyCreeper

RDC Turret Lite

Oct 11th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. @name RDC's Turret Lite V1.2
  2. @inputs Gun:entity Active Aimpos:vector ElevPos:array Gunlock LaseKey
  3. @persist Lase TableSlot Distance RTIncrements Rotation Inertia:angle Elevation Depression Yaw RotateSpeed GunAng:angle
  4. @outputs Latched Distance SElevation TableSlot
  5. @trigger
  6.  
  7. #E2 was made to aim secondary guns like MGs on a tank and thus has no hud or cam links
  8.  
  9.  
  10. #Setup:
  11. #Link up Gun to the turret's main gun, Active to the the Pod Active,
  12. #Aimpos to the Came Controller Hitpos, Elevpos to the ballistic table array
  13. #Gunlock to the key that you want to lock your gun with along with setting up a weldlatch
  14. #To your baseplate and wiring that to the latch output to lock your gun in place.
  15. #THE WELD LATCH IS MANDATORY bc it reduces usage a lot and is just good to have, dont complain
  16. #If the turret doesn't work because you didn't setup a latch. Its also default on.
  17. #Setup Lasekey if you have Lase set to 1, this will adjust your range whenever you hit a key.
  18.  
  19.  
  20. #Notes: This gun accepts input from a ballistic calculator that does full drag computation
  21.  
  22. #This e2 was released at irritation at certain tank e2s using 700 US, talking
  23. #to you EZ tank turret and Turret Hud Combo, use it over those due to optimization
  24.  
  25. interval(100)
  26.  
  27. if(duped())
  28. {
  29. reset()
  30. }
  31. elseif (first()) {
  32. Lase=0 #Set to 1 if you want to press a key to lase a range, else auto range aquisition
  33. Elevation = 10 #Gun Elevation
  34. Depression = 90 #Gun Depression
  35. Yaw = 180 #Turret ability to rotate around, 180 is a complete circle
  36. Rotation = 500 #Turret rotation speed, be reasonable please
  37.  
  38.  
  39. #Unless you know what your doing dont edit below here
  40. Elevation*=-1
  41. Inertia = shiftL(ang(Gun:inertia()))
  42. RTIncrements=20*39.37
  43.  
  44. function number interpolatearray(Array:array, Dist) {
  45. TableSlot=Dist/RTIncrements
  46. TableNum=floor(TableSlot)
  47. Rat=(Dist-floor(TableSlot))/RTIncrements
  48. Smaller=Array[TableNum,number]
  49. Larger=Array[TableNum+1,number]
  50.  
  51. return Smaller+(Larger-Smaller)/Rat
  52. }
  53.  
  54.  
  55.  
  56. RotateSpeed = Rotation/Gun:mass()*10
  57. }
  58.  
  59. if (~Active) {
  60. Latched=1
  61. }
  62.  
  63. if( Active ) {
  64. if(~Gunlock&Gunlock)
  65. {
  66. Latched=!Latched
  67. }
  68. if(!Latched)
  69. {
  70.  
  71. # Distance=Gun:attachmentPos("muzzle"):setZ(0):distance(Aimpos:setZ(0))+(Aimpos:z()-Gun:attachmentPos("muzzle"):z())
  72.  
  73. if(!Lase|~LaseKey&LaseKey)
  74. {
  75. Distance=Gun:attachmentPos("muzzle"):distance(Aimpos)
  76.  
  77. SElevation = -elevation(vec(0),ang(0),vec(Distance,0,interpolatearray(ElevPos,Distance)))
  78. }
  79.  
  80.  
  81.  
  82. GunAng =(Aimpos - Gun:pos()):toAngle()+ang(SElevation,0,0)
  83. Gun:applyAngForce((Gun:toLocal(entity():toWorld(clamp(entity():toLocal(Gun:toWorld(clamp(Gun:toLocal(GunAng),ang(-RotateSpeed),ang(RotateSpeed)))),ang(Elevation,-Yaw,-1),ang(Depression,Yaw,1)))) * 250 - Gun:angVel() * 30) * Inertia)
  84. }
  85.  
  86.  
  87. }
Add Comment
Please, Sign In to add comment