Advertisement
RedDeadlyCreeper

RDC Acf Naval Torpedo E2

Nov 29th, 2018
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.90 KB | None | 0 0
  1. @name RDC's Torpedo E2 V1.5
  2. @inputs Fire Launchers:array Gun1:entity Gun2:entity Gun3:entity RefillCrate:entity AmmoRackProp:entity Aimpos:vector SinkDepth
  3. @outputs Torpedoes:array F1 F2 F3 AmmoActive TorpedoesLeft TEnt:entity
  4. @persist Canfire SalvoFire ReloadTime CurrentTube SIndex1 SIndex2 WaterHeight SearchRanger:ranger FuseTimes:array DepthOveride AimPositions:array TDepth:array Agility HoloScaleVar:vector HoloVOffset:vector HoloModel:string LengthOffset Length Width SpeedVal TorpedoProp:string RLength TMass Holos SinkDepth Fuse Alright PropKill CGun FDelay
  5. @trigger
  6. interval(500)
  7. if(duped()|dupefinished())
  8. {
  9. reset()
  10. }
  11. elseif(first())
  12. {
  13. #There is no reason to use more than 3 launchers
  14.  
  15.  
  16. TorpedoProp="models/sprops/cylinders/size_2/cylinder_3x36.mdl" #Larger props are faster and have more fuse time
  17. #You have 10 points to distribute, use them wisely
  18.  
  19. DepthOveride = 10 #Set to nonzero to force the torpedo to sink to a fixed depth, else use SinkDepth value on launch
  20. Speed = 2.5 #about 10 u/s per unit, faster/slower based on prop size
  21. Fuse = 5 #More fuse, more torpedo time
  22. Agility = 2.5 #For homing torpedoes only, if you use this on a torpedo which didnt have homing I will telebomb you
  23.  
  24. #A homing e2 will go towards an aimposition specified at launch until its seeker head aquires the target
  25.  
  26. SalvoFire=0 #Fire all torpedo tubes at once or recieve a faster reload
  27. ReloadTime=50 #Torpedo Reload Time given by chart
  28. TubeCount=4 #Torpedo Launchers in a single launcher set (IE: 4 to a quad mount, 2 to a double)
  29.  
  30.  
  31. PropKill=0 #Teleport ACF guns or use exploding props to do damage
  32.  
  33. TorpModel=1 #What model do you want for your fired torpedoes?
  34.  
  35. #Spawn a prop for derriving scaling
  36. TestProp = propSpawn(TorpedoProp,vec(0,0,0),ang(0,0,0),0)
  37. Dimensions=TestProp:boxSize()/6.5
  38. Length=(TestProp:boxSize()):z()/6.5
  39. Width=(TestProp:boxSize()):x()/6.5
  40. TVol=TestProp:volume()
  41. TestProp:propDelete()
  42. SpeedVal=Speed*10
  43. RLength=Length*6.5+0.1
  44. TMass=TVol/39.38
  45. AmmoActive=1
  46. CGun=1
  47. TorpedoesLeft=floor(AmmoRackProp:volume()/TVol/16)
  48. AmmoRackProp:setMass(TMass*TorpedoesLeft)
  49. LengthOffset=60+Length
  50.  
  51. CurrentTube=1
  52. if(TorpModel==1)
  53. {
  54. HoloModel="models/props_phx/torpedo.mdl"
  55. HoloScaleVar=vec(Length/26,Width/3.4,Width/3.4)
  56. HoloVOffset=vec(0,3*Width,0)
  57. }
  58. else
  59. {
  60. HoloModel="models/props_phx/ww2bomb.mdl"
  61. HoloScaleVar=vec(Length*0.11,Width*0.423,Width*0.423)
  62. HoloVOffset=vec(0,2.5*Width,0)
  63. }
  64. function spawnTorpedo(Launcher:entity)
  65. {
  66.  
  67. TProp=propSpawn("models/sprops/rectangles/size_1/rect_3x3x3.mdl",(Launcher:toWorld(vec(LengthOffset,0,0))),(Launcher:toWorld(ang(0,0,0))),0)
  68. TProp:applyForce(TProp:forward()*TMass*50)
  69. TProp:setAlpha(0)
  70. #TProp:propDrag(0)
  71. TProp:propFreeze(0)
  72. TProp:setMass(TMass)
  73. TProp:propSetBuoyancy(0)
  74. TProp:setTrails(Width*10,2*Width,3, "trails/smoke", vec(255,255,255),100)
  75. holoCreate(Holos)
  76. holoPos(Holos,TProp:toWorld(HoloVOffset))
  77. holoAng(Holos,TProp:toWorld(ang(0,0,0)))
  78. holoModel(Holos,HoloModel)
  79. holoScale(Holos,HoloScaleVar)
  80. holoParent(Holos,TProp)
  81. Holos++
  82.  
  83.  
  84. TProp:propGravity(0)
  85.  
  86. Torpedoes:pushEntity(TProp)
  87. Fuse*=2
  88. FuseTimes:pushNumber(Fuse*TMass)
  89. if(!DepthOveride)
  90. {
  91. TDepth:pushNumber(SinkDepth)
  92. }
  93. else
  94. {
  95. TDepth:pushNumber(DepthOveride)
  96. }
  97. if(Aimpos!=vec(0)){AimPositions:pushVector(Aimpos)}else{AimPositions:pushVector(Launcher:toWorld(vec(5000,0,0)))}
  98. TProp:soundPlay(SIndex1,0,"acf_extra/cannons/scifi/vacuumgun.wav")
  99. soundPitch(SIndex1,95)
  100. soundVolume(SIndex1,52.8)
  101. SIndex1++
  102. }
  103.  
  104. function fireGun(Aimpos:vector,AimAng:angle)
  105. {
  106. if(CGun==1)
  107. {
  108. Gun1:setPos(Aimpos)
  109. Gun1:setAng(AimAng)
  110. CGun=2
  111. }
  112. elseif(CGun==2)
  113. {
  114. Gun2:setPos(Aimpos)
  115. Gun2:setAng(AimAng)
  116. CGun=3
  117. }
  118. elseif(CGun==3)
  119. {
  120. Gun3:setPos(Aimpos)
  121. Gun3:setAng(AimAng)
  122. CGun=1
  123. }
  124.  
  125. #Gun3:soundPlay(SIndex3,0,"acf_new/weapons/tow/near/mid (1).wav")
  126. #soundPitch(SIndex3,45)
  127. #SIndex3++
  128.  
  129. timer("Fire",10)
  130. timer("returnGuns",100)
  131. }
  132.  
  133. F1=1
  134. F2=2
  135. F3=3
  136. timer("returnGuns",200)
  137.  
  138. if(!SalvoFire)
  139. {
  140. ReloadTime=ReloadTime/((TubeCount*Launchers:count()+1)/2)*1000
  141. }
  142. else
  143. {
  144. ReloadTime=ReloadTime/((TubeCount+1)/2)*1000
  145. }
  146. Canfire=1
  147. function torpedoBoom(TP:entity,Boompos:vector)
  148. {
  149. TP:propDelete()
  150. if(PropKill)
  151. {
  152. Boom = propSpawn("models/props_junk/propane_tank001a.mdl",Boompos,ang(0,0,0),0)
  153. Boom:propBreak()
  154. }
  155. else
  156. {
  157. fireGun(Boompos,TP:toWorld(ang(0,0,0)))
  158. }
  159. }
  160.  
  161. #Another nifty function someone gave me
  162. function entity:turnTo(Tarang:angle,Mult){
  163. V = This:toLocal(rotationVector(quat(Tarang)/quat(This))+This:pos())
  164. This:applyTorque((Mult*100*V - 30*This:angVelVector())*This:inertia()/3)
  165. }
  166.  
  167. function torpedo(TorpedoN) # I'M A TORPEDO! YAY!!!
  168. {
  169. Torpedo=Torpedoes[TorpedoN,entity]
  170. rangerHitWater(1)
  171. rangerHitEntities(0)
  172.  
  173. WaterRanger=rangerOffset(8000,Torpedo:pos()+vec(0,0,4000),vec(0,0,-1))
  174. WaterHeight=WaterRanger:position():z()
  175. #(AvgHeight/LegCount)+vec(0,0,HoverHeight)-entity():pos()
  176. Torpedo:applyForce(((((WaterRanger:position()-vec(0,0,TDepth[TorpedoN,number])-Torpedo:pos()))-Torpedo:vel())*TMass)*vec(0,0,1)+Torpedo:vel()*vec(0,0,-0.6)*TMass)
  177.  
  178. #Torpedo:applyForce(vec(0,0,Difpos)*TMass)
  179. FTime=FuseTimes[TorpedoN,number]
  180. if(Torpedo:isUnderWater())
  181. {
  182. FuseTimes[TorpedoN,number]=FTime-0.5
  183. if(Agility!=0)
  184. {
  185. #Aimpos
  186. #TEnt=noentity()
  187.  
  188. rangerHitWater(0)
  189. rangerHitEntities(1)
  190. rangerFilter(Torpedo)
  191. rangerFilter(Launchers)
  192. rangerFilter(Torpedoes)
  193. SearchRanger=rangerOffsetHull(4000,Torpedo:pos(),Torpedo:forward(),vec(1,600,400))
  194.  
  195. if(SearchRanger:entity():isValid()&FTime<Fuse*TMass-12)
  196. {
  197. Torpedo:soundPlay("BEEP",0.17,"acf_extra/vehiclefx/horn/horn2.wav")
  198. soundPitch("BEEP",150)
  199. Pos=SearchRanger:entity():pos()
  200. AimPositions[TorpedoN,vector] = Pos
  201. TDepth[TorpedoN,number] = max(WaterHeight-Pos:z(),5)
  202. TEnt=SearchRanger:entity()
  203. GunAng =(Pos - Torpedo:pos()):toAngle()
  204. }
  205. else
  206. {
  207. GunAng =(AimPositions[TorpedoN,vector] - Torpedo:pos()):toAngle()*ang(0,1,0)
  208. }
  209. Torpedo:turnTo(GunAng,0.15*Agility)
  210.  
  211.  
  212. Torpedo:applyForce(Torpedo:forward()*TMass*2*SpeedVal-Torpedo:vel()*vec(1,1,0))
  213.  
  214. }
  215. else
  216. {
  217. Torpedo:applyForce(Torpedo:forward()*(TMass*0.8)*SpeedVal)
  218. }
  219. }
  220.  
  221. rangerHitWater(0)
  222. rangerHitEntities(1)
  223. Ranger=rangerOffset(20+abs(Torpedo:velL():length())*1,Torpedo:toWorld(vec(RLength,0,0)),Torpedo:forward())
  224.  
  225.  
  226. #Ranger=rangerOffset(Torpedo:toWorld(vec(0,0,RLength)),Torpedo:toWorld(vec(0,0,RLength+5*Length)))
  227. if(Ranger:hit()&FTime<Fuse*TMass-12)
  228. {
  229. torpedoBoom(Torpedo,Torpedo:toWorld(vec(-10,0,0)))
  230. }
  231. elseif(FuseTimes[TorpedoN,number]<0)
  232. {
  233. Torpedo:propDelete()
  234. }
  235.  
  236. }
  237.  
  238. if(Fuse+Speed+Agility>10)
  239. {
  240. hint("More than 10 points allocated",5)
  241.  
  242. }
  243. else
  244. {
  245. Alright = 1
  246. }
  247. }
  248. if(Alright)
  249. {
  250. if(~Fire&Fire&Canfire&AmmoRackProp:isValid())
  251. {
  252. if(TorpedoesLeft>0)
  253. {
  254. AmmoRackProp:setMass(TMass*TorpedoesLeft/(AmmoRackProp:volume()/26))
  255. entity():soundPlay(SIndex2,500,"acf_extra/airfx/javelin_fire.wav")
  256. soundPitch(SIndex2,80)
  257. SIndex2++
  258. if(SalvoFire)
  259. {
  260. for(I=1,Launchers:count())
  261. {
  262. if(TorpedoesLeft>0)
  263. {
  264. TorpedoesLeft--
  265. spawnTorpedo(Launchers[I,entity])
  266. Canfire=0
  267. timer("Reload",ReloadTime)
  268. }
  269. }
  270. }
  271. else
  272. {
  273. TorpedoesLeft--
  274. spawnTorpedo(Launchers[CurrentTube,entity])
  275. CurrentTube++
  276. if(CurrentTube>Launchers:count())
  277. {CurrentTube=1}
  278. Canfire=0
  279. timer("Reload",ReloadTime)
  280. }
  281. }
  282.  
  283. }
  284.  
  285. for(I=1,Torpedoes:count())
  286. {
  287. if(Torpedoes[I,entity]:isValid())
  288. {torpedo(I)}else{Torpedoes:removeEntity(I),FuseTimes:removeNumber(I),AimPositions:removeVector(I),TDepth:removeNumber(I)}
  289. }
  290. }
  291.  
  292.  
  293. if(clk("Fire"))
  294. {
  295. if(CGun==1)
  296. {
  297. F3=1
  298. }
  299. if(CGun==2)
  300. {
  301. F1=1
  302. }
  303. if(CGun==3)
  304. {
  305. F2=1
  306. }
  307. }
  308. if(clk("returnGuns"))
  309. {
  310. F1=0
  311. F2=0
  312. F3=0
  313. Gun1:setPos(RefillCrate:pos()+vec(10,0,20))
  314. Gun2:setPos(RefillCrate:pos()+vec(0,0,20))
  315. Gun3:setPos(RefillCrate:pos()+vec(-10,0,20))
  316. }
  317. if(clk("Reload"))
  318. {
  319. Canfire=1
  320. entity():soundPlay("Ready",0.2,"acf_extra/airfx/weapon_select.wav")
  321. stoptimer("Reload")
  322. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement