Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name Torpedo Launcher Tuby Things V1.0
- @inputs Active Aimpos:vector TorpedoLaunchers:array
- @outputs InRangeLaunchEnts:array Bearing1 Elevation2
- @persist StowAngle Tolerance LaunchEnts:array TestIfCanFire Launchers:array I YawRate YawLimit
- if(dupefinished())
- {
- reset()
- }
- elseif (first()){
- #acf_extra/cannons/scifi/vacuumgun.wav
- YawRate=10 #180 = full circle
- YawLimit=90
- Tolerance=5 #Degree Cone the torpedo Launcher is allowed to fire in
- StowAngle= -90 #Azimith to align launcher to
- TestIfCanFire=1 #Whether or not to check if launchers are in range
- TorpedoTubeWidth=2.5
- TorpedoTubeLength=40
- TorpedoTubeCount=4 #3, 4, or 5 Torpedoes
- H=0
- TorpedoTubeCount=clamp(TorpedoTubeCount,3,5)
- for(I=1,TorpedoLaunchers:count())
- {
- TLauncher=TorpedoLaunchers[I,entity]
- TLauncher:setAlpha(0)
- holoCreate(H)
- holoModel(H,"hq_cylinder")
- holoScale(H,vec(0.35,0.35,0.2))
- holoPos(H,TLauncher:toWorld(vec(0,0,-0.35)))
- holoAng(H,TLauncher:toWorld(ang(0,0,0)))
- holoColor(H,vec(150))
- # holoMaterial(H,"phoenix_storms/middle")
- holoMaterial(H,"models/props_pipes/pipemetal001a")
- holoParent(H,TLauncher)
- H++
- holoCreate(H)
- holoPos(H,TLauncher:toWorld(vec(0,0,0)))
- holoAng(H,TLauncher:toWorld(ang(0,0,0)))
- holoAlpha(H,0)
- holoParent(H,TLauncher)
- LaunchEnts:pushEntity(holoEntity(H))
- Launchers:pushNumber(H)
- H++
- holoCreate(H)
- holoModel(H,"models/sprops/rectangles/size_2/rect_12x"+(TorpedoTubeCount-1)*6+"x3.mdl")
- holoScale(H,vec(TorpedoTubeWidth/3.25,TorpedoTubeLength/19.5,TorpedoTubeCount*TorpedoTubeWidth/13))
- holoPos(H,TLauncher:toWorld(vec(0,0,1.2)))
- holoAng(H,TLauncher:toWorld(ang(0,90,0)))
- holoColor(H,vec(150))
- holoMaterial(H,"phoenix_storms/middle")
- # holoMaterial(H,"models/props_pipes/pipemetal001a")
- holoParent(H,holoEntity(H-1))
- H++
- }
- InRangeLaunchEnts=LaunchEnts
- }
- if(Active)
- {
- interval(100)
- for(I=1,Launchers:count())
- {
- LEnt=LaunchEnts[I,entity]
- TLEnt=TorpedoLaunchers[I,entity]
- 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))))
- }
- if(TestIfCanFire)
- {
- InRangeLaunchEnts=array()
- for(I=1,LaunchEnts:count())
- {
- LEnt=LaunchEnts[I,entity]
- if(inrange(LEnt:heading(Aimpos),-ang(90,Tolerance,90),ang(90,Tolerance,90)))
- {
- InRangeLaunchEnts:pushEntity(LEnt)
- }
- }
- }
- }
- else
- {
- interval(200)
- for(I=1,LaunchEnts:count())
- {
- LEnt=LaunchEnts[I,entity]
- TLEnt=TorpedoLaunchers[I,entity]
- 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))))
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement