Advertisement
RedDeadlyCreeper

EZ Torpedo Launcher E2

Dec 29th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 KB | None | 0 0
  1. @name Torpedo Launcher Tuby Things V1.0
  2. @inputs Active Aimpos:vector TorpedoLaunchers:array
  3. @outputs InRangeLaunchEnts:array Bearing1 Elevation2
  4. @persist StowAngle Tolerance LaunchEnts:array TestIfCanFire Launchers:array I YawRate YawLimit
  5. if(dupefinished())
  6. {
  7. reset()
  8. }
  9. elseif (first()){
  10. #acf_extra/cannons/scifi/vacuumgun.wav
  11.  
  12.  
  13. YawRate=10 #180 = full circle
  14. YawLimit=90
  15. Tolerance=5 #Degree Cone the torpedo Launcher is allowed to fire in
  16. StowAngle= -90 #Azimith to align launcher to
  17. TestIfCanFire=1 #Whether or not to check if launchers are in range
  18. TorpedoTubeWidth=2.5
  19. TorpedoTubeLength=40
  20. TorpedoTubeCount=4 #3, 4, or 5 Torpedoes
  21.  
  22. H=0
  23.  
  24. TorpedoTubeCount=clamp(TorpedoTubeCount,3,5)
  25. for(I=1,TorpedoLaunchers:count())
  26. {
  27. TLauncher=TorpedoLaunchers[I,entity]
  28. TLauncher:setAlpha(0)
  29. holoCreate(H)
  30. holoModel(H,"hq_cylinder")
  31. holoScale(H,vec(0.35,0.35,0.2))
  32. holoPos(H,TLauncher:toWorld(vec(0,0,-0.35)))
  33. holoAng(H,TLauncher:toWorld(ang(0,0,0)))
  34. holoColor(H,vec(150))
  35. # holoMaterial(H,"phoenix_storms/middle")
  36. holoMaterial(H,"models/props_pipes/pipemetal001a")
  37. holoParent(H,TLauncher)
  38. H++
  39.  
  40. holoCreate(H)
  41. holoPos(H,TLauncher:toWorld(vec(0,0,0)))
  42. holoAng(H,TLauncher:toWorld(ang(0,0,0)))
  43. holoAlpha(H,0)
  44. holoParent(H,TLauncher)
  45. LaunchEnts:pushEntity(holoEntity(H))
  46. Launchers:pushNumber(H)
  47. H++
  48.  
  49. holoCreate(H)
  50. holoModel(H,"models/sprops/rectangles/size_2/rect_12x"+(TorpedoTubeCount-1)*6+"x3.mdl")
  51. holoScale(H,vec(TorpedoTubeWidth/3.25,TorpedoTubeLength/19.5,TorpedoTubeCount*TorpedoTubeWidth/13))
  52. holoPos(H,TLauncher:toWorld(vec(0,0,1.2)))
  53. holoAng(H,TLauncher:toWorld(ang(0,90,0)))
  54. holoColor(H,vec(150))
  55. holoMaterial(H,"phoenix_storms/middle")
  56. # holoMaterial(H,"models/props_pipes/pipemetal001a")
  57. holoParent(H,holoEntity(H-1))
  58. H++
  59. }
  60. InRangeLaunchEnts=LaunchEnts
  61.  
  62. }
  63.  
  64. if(Active)
  65. {
  66. interval(100)
  67. for(I=1,Launchers:count())
  68. {
  69. LEnt=LaunchEnts[I,entity]
  70. TLEnt=TorpedoLaunchers[I,entity]
  71. holoAng(Launchers[I,number], TLEnt:toWorld(clamp(TLEnt:toLocal(LEnt:toWorld(ang(0,clamp(-LEnt:bearing(Aimpos),-YawRate,YawRate),0))),ang(0,-YawLimit,0),ang(0,YawLimit,0))))
  72. }
  73.  
  74. if(TestIfCanFire)
  75. {
  76. InRangeLaunchEnts=array()
  77. for(I=1,LaunchEnts:count())
  78. {
  79. LEnt=LaunchEnts[I,entity]
  80. if(inrange(LEnt:heading(Aimpos),-ang(90,Tolerance,90),ang(90,Tolerance,90)))
  81. {
  82. InRangeLaunchEnts:pushEntity(LEnt)
  83. }
  84.  
  85. }
  86.  
  87. }
  88. }
  89. else
  90. {
  91. interval(200)
  92. for(I=1,LaunchEnts:count())
  93. {
  94. LEnt=LaunchEnts[I,entity]
  95. TLEnt=TorpedoLaunchers[I,entity]
  96.  
  97. holoAng(Launchers[I,number], TLEnt:toWorld(clamp(TLEnt:toLocal(LEnt:toWorld(ang(0,clamp(StowAngle-LEnt:angles():yaw(),-YawRate,YawRate),0))),ang(0,-YawLimit,0),ang(0,YawLimit,0))))
  98. }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement