Gmodism

Garry's Mod ACF Turret HUD Combo V2

Sep 18th, 2016
1,289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.66 KB | None | 0 0
  1. @name Turret HUD Combo V2
  2. @inputs Active NextWeapon PrevWeapon [Pod Cam EGP ]:wirelink [Gun Base Chair]:entity
  3. @persist Elevation Depression Yaw RotateSpeed FOV
  4. @persist Rangefinder:ranger [ScreenRes Res]:vector2 CamOffset:vector
  5. @persist [Inertia Hold]:angle CamL:entity User:entity
  6.  
  7. # EGP, Cam, and Pod Controller required
  8.  
  9. #The way Zoom is setup you have a max FOV (zoomed out), a minimum FOV (zoomed in)
  10. #and a change amount per scroll. The default for these are Max - 90, Min - 20, Change - 35.
  11. #Minimum and maximum is recommended to be between 0 and 90, minimum being zoomed in and max being zoomed out.
  12.  
  13. #You want to all mesh together, in the default example the max is 90 and one scroll click will
  14. #subract 35 making the FOV 55, then another click will subract 35 again bringing us to the
  15. #minimum of 20. If it was 90 / 20 / 10 you would reach the minimum FOV in 9 clicks.
  16. #Whatever the case, your Max minus Change a certain number of times should land you on your Minimum.
  17.  
  18. #Do not forget to change the fov reset value on line 26 as well.
  19.  
  20. #FOV Control These values below are what you change
  21. if (~PrevWeapon|~NextWeapon) {
  22. FOV = clamp(FOV + (NextWeapon - PrevWeapon) * 35,20,90)
  23. } #Change,Min,Max
  24. #FOV reset when entering / exiting
  25. if (~Active&Active|~Active&!Active) {
  26. FOV=90
  27. } # ^^This should be same as Max
  28.  
  29. #############################################################################################################################
  30.  
  31. #Do not touch this
  32.  
  33. if(first()||dupefinished())
  34. {
  35. holoCreate(1)
  36. holoAlpha(1,0)
  37. }
  38.  
  39. elseif ( ~Active & Active ) {
  40.  
  41. #############################################################################################################################
  42.  
  43. #Stuff you can adjust
  44.  
  45. #Hud Stuff
  46.  
  47. #HUD Color (Red,Green,Blue)
  48. local Color = vec(25,100,225)
  49. #Aimer Color (Red,Green,Blue)
  50. local Color2 = vec(0,0,200)
  51.  
  52. #Gun Stuff
  53.  
  54. #Elevation (How high the gun aims in degrees)
  55. Elevation = 10
  56. #Depression (How low the gun aims in degrees)
  57. Depression = 7.5
  58. #How far around the gun can left and right in degrees (180 is all the way around, 90 is flush to each side)
  59. Yaw = 180
  60. #How fast the gun turns, this is an arbitrary number and must be adjusted to your liking, Higher is faster
  61. RotateSpeed = 15
  62.  
  63. #Camera Stuff
  64.  
  65. #How far out the camera is from the pivot point
  66. Cam["Distance",number] = 200 #Forwards/Backwards|Left/Right|Up/Down forwards may be a negative number, experiment and see
  67. #Offset of camera from base center |F/B|L/R|U/D|
  68. CamOffset = vec(19.5, 0 ,100)
  69.  
  70. #Turret Sound Just replace the sound path with whatever sound you like
  71. Gun:soundPlay(1,0,"vehicles/tank_turret_loop1.wav")
  72. soundPitch(1,0)
  73.  
  74. #############################################################################################################################
  75.  
  76. #Stuff you probably should not touch below
  77.  
  78. #Camera Activation
  79. Cam["Activated",number] = 1
  80. #Entity the camera originates from
  81. Cam["Position",vector] = Base:toWorld(CamOffset)
  82. #Entity the camera parents to
  83. Cam["Parent",entity] = Base
  84.  
  85. #EGP Stuff
  86. User = Chair:driver()
  87. ScreenRes=egpScrSize(Chair:driver())
  88. Res=ScreenRes/2
  89.  
  90. #Forward Gun Tracker
  91. EGP:egp3DTracker(2,vec(0,0,0))
  92. EGP:egpParent(2,holoEntity(1))
  93.  
  94. EGP:egpCircle(3,vec2(0,0),vec2(4,4))
  95. EGP:egpColor(3,Color2)
  96. EGP:egpParent(3,2)
  97.  
  98. #Chevron
  99. EGP:egpPoly(4, Res, Res + vec2(24,17), Res + vec2(20,17), Res + vec2(0,4), Res + vec2(-20, 17), Res + vec2(-24, 17))
  100. EGP:egpColor(4,Color)
  101.  
  102. #Marks below Chevron
  103. EGP:egpCircle(5,Res+vec2(0,30),vec2(5,1))
  104. EGP:egpColor(5,Color)
  105.  
  106. EGP:egpCircle(6,Res+vec2(0,50),vec2(5,1))
  107. EGP:egpColor(6,Color)
  108.  
  109. EGP:egpCircle(7,Res+vec2(0,70),vec2(5,1))
  110. EGP:egpColor(7,Color)
  111.  
  112. rangerFilter(Gun)
  113. rangerFilter(entity():getConstraints())
  114. rangerPersist(1)
  115.  
  116. #Gun Stuff
  117. Elevation*=-1
  118. Inertia = shiftL(ang(Gun:inertia()))
  119. Hold = entity():toLocal(Gun:angles())
  120.  
  121. interval( 35 )
  122. timer("tracker",100)
  123. stoptimer("stop-gun-spinning")
  124. } elseif ( ~Active & !Active ) {
  125. stoptimer("interval")
  126. stoptimer("tracker")
  127. soundPitch(1,0)
  128. timer("stop-gun-spinning",100)
  129. } elseif (clk("tracker")) {
  130.  
  131. #EGP Stuff
  132. holoPos(1,rangerOffset(9999999999,Gun:pos()+Gun:forward()*100,Gun:forward()):position())
  133.  
  134. timer("tracker",100)
  135. } elseif( clk() ) {
  136.  
  137. #Sound Stuff
  138. local Position = Base:toWorld(CamOffset)
  139. local Angle = Chair:toLocal(User:eyeAngles())
  140. local Ranger = rangerOffset(9999999999,Position,Angle:forward())
  141. soundPitch(1,clamp(Gun:angVelVector():length()*10*(Gun:angVelVector():length()>10),0,80))
  142.  
  143. #Ang Force Stuff
  144. local GunAng = (Ranger:pos() - Gun:pos()):toAngle()
  145. local Force = Gun:toWorld(clamp(Gun:toLocal(GunAng),ang(-RotateSpeed),ang(RotateSpeed)))
  146. local Clamped = clamp(entity():toLocal(Force),ang(Elevation,-Yaw,-1),ang(Depression,Yaw,1))
  147. local LocalToGun = Gun:toLocal(entity():toWorld(Clamped))
  148. Gun:applyAngForce((LocalToGun * 250 - Gun:angVel() * 47) * Inertia) #250, 47
  149.  
  150. interval( 35 )
  151. } elseif (clk("stop-gun-spinning")) {
  152. Gun:applyAngForce(-Gun:angVel() * 30 * Inertia)
  153.  
  154. if (Gun:angVelVector():length() > 0.1) {
  155. timer("stop-gun-spinning",100)
  156. }
  157. }
  158. #Camera field of view link
  159. Cam["FOV",number] = FOV
Add Comment
Please, Sign In to add comment