Advertisement
RedDeadlyCreeper

RDC Community Phalanx E2

Nov 23rd, 2018
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.65 KB | None | 0 0
  1. @name RDC's Phalanx Block 0 - Community Version
  2. @inputs Gun:entity ElevPos:array Entities:array Velocity:array Position:array ManualAimpos:vector ManualFire ManualAimInactive TTime:array
  3. @persist Missile:entity BaseAimHolo:entity TickInterval VulcanMain IMaxDist MaxDist TargPos:vector FOV Debug ElevationA Bearing ActAng:angle GunAng:angle Aimpos:vector CalPos Gunattachment Turntable Speed PSpeed Accel LLPos:vector LPos:vector Pos:vector Timescale PreLoaded Distance RTIncrements TravelTime OPos:vector NT H Inertia:angle Elevation Depression RotateSpeed Angle:angle Ranger:ranger AimHolo:entity Aimer:entity
  4. @outputs I H Active Fire Vel:vector
  5. @trigger none
  6.  
  7. if (first()|dupefinished()) {
  8. entity():setAlpha(255)
  9. Debug = 0 #Disable Parenting
  10. RTIncrements=20*39.37 #Dont touch unless you know what your doing
  11.  
  12. Elevation = 80 #Gun Elevation
  13. Depression = 10 #Gun Depression
  14.  
  15. MaxDist = 100 #Minimum Distance in meters until the CRAM can fire, useful for lower penetration MGs
  16.  
  17. MainColor=vec(230,230,230)
  18. TowerColor=vec(250,250,250)
  19. DarkerColor=vec(70,70,70)
  20. MainMat="models/props_pipes/pipemetal001a"
  21. SecMat="models/props_wasteland/concretewall064b"
  22. TowerMat="models/props_debris/building_template010a"
  23. Active = 1
  24. Scale=1.1/7
  25. #Unless you know what your doing dont edit below here
  26.  
  27. H = 1
  28.  
  29. I=1
  30.  
  31.  
  32. timer("scan",1500)
  33. timer("PreLoad",1000)
  34. Fire=1
  35.  
  36. holoCreate(I) #Reciever Main
  37. holoPos(I, entity():toWorld(vec(0,0,0)))
  38. holoAng(I, entity():toWorld(ang(0,0,0)))
  39. holoScale(I, vec(6,6,0.1)*Scale)
  40. holoColor(I,MainColor)
  41. holoModel(I, "hq_cylinder")
  42. holoMaterial(I,SecMat)
  43. holoParent(I,entity())
  44. I++
  45.  
  46. Turntable = I
  47. holoCreate(I) #Base
  48. holoPos(I, entity():toWorld(vec(0,0,3)*Scale))
  49. holoAng(I, entity():toWorld(ang(0,0,0)))
  50. holoScale(I, vec(5.46,5.46,0.3)*Scale)
  51. holoColor(I,MainColor)
  52. holoModel(I, "hq_cylinder")
  53. holoMaterial(I,MainMat)
  54. holoParent(I,entity())
  55. I++
  56.  
  57. holoCreate(I) #CIWS stand left
  58. holoPos(I, entity():toWorld(vec(0,22.55,8)*Scale))
  59. holoAng(I, entity():toWorld(ang(0,0,0)))
  60. holoScale(I, vec(2.54,0.8,1)*Scale)
  61. holoColor(I,MainColor)
  62. holoModel(I, "")
  63. holoMaterial(I,MainMat)
  64. holoParent(I,holoEntity(Turntable))
  65. I++
  66.  
  67. holoCreate(I)
  68. holoPos(I, entity():toWorld(vec(0,-22.55,8)*Scale))
  69. holoAng(I, entity():toWorld(ang(0,0,0)))
  70. holoScale(I, vec(2.54,0.8,1)*Scale)
  71. holoColor(I,MainColor)
  72. holoModel(I, "")
  73. holoMaterial(I,MainMat)
  74. holoParent(I,holoEntity(Turntable))
  75. I++
  76.  
  77. holoCreate(I) #CIWS stand left
  78. holoPos(I, entity():toWorld(vec(-4.3,-22.55,29)*Scale))
  79. holoAng(I, entity():toWorld(ang(-12,180,0)))
  80. holoScale(I, vec(0.55,0.41,0.51)*Scale)
  81. # holoColor(I,MainColor)
  82. holoModel(I, "models/props_wasteland/controlroom_filecabinet002a.mdl")
  83. holoMaterial(I,MainMat)
  84. holoParent(I,holoEntity(Turntable))
  85. I++
  86.  
  87. print("Phalanx E2 made by RDC")
  88. holoCreate(I) #CIWS stand left
  89. holoPos(I, entity():toWorld(vec(4.3,-22.55,29)*Scale))
  90. holoAng(I, entity():toWorld(ang(-12,0,0)))
  91. holoScale(I, vec(0.55,0.41,0.51)*Scale)
  92. # holoColor(I,MainColor)
  93. holoModel(I, "models/props_wasteland/controlroom_filecabinet002a.mdl")
  94. holoMaterial(I,MainMat)
  95. holoParent(I,holoEntity(Turntable))
  96. I++
  97.  
  98. holoCreate(I) #CIWS stand left
  99. holoPos(I, entity():toWorld(vec(-4.3,22.55,29)*Scale))
  100. holoAng(I, entity():toWorld(ang(-12,180,0)))
  101. holoScale(I, vec(0.55,0.41,0.51)*Scale)
  102. # holoColor(I,MainColor)
  103. holoModel(I, "models/props_wasteland/controlroom_filecabinet002a.mdl")
  104. holoMaterial(I,MainMat)
  105. holoParent(I,holoEntity(Turntable))
  106. I++
  107. holoCreate(I) #CIWS stand left
  108. holoPos(I, entity():toWorld(vec(4.3,22.55,29)*Scale))
  109. holoAng(I, entity():toWorld(ang(-12,0,0)))
  110. holoScale(I, vec(0.55,0.41,0.51)*Scale)
  111. # holoColor(I,MainColor)
  112. holoModel(I, "models/props_wasteland/controlroom_filecabinet002a.mdl")
  113. holoMaterial(I,MainMat)
  114. holoParent(I,holoEntity(Turntable))
  115. I++
  116.  
  117.  
  118. holoCreate(I) #CIWS stand left
  119. holoPos(I, entity():toWorld(vec(0,22.51,40.93)*Scale))
  120. holoAng(I, entity():toWorld(ang(0,0,0)))
  121. holoScale(I, vec(1.27,0.785,1.183)*Scale)
  122. holoColor(I,MainColor)
  123. holoModel(I, "")
  124. holoMaterial(I,MainMat)
  125. holoParent(I,holoEntity(Turntable))
  126. I++
  127.  
  128. holoCreate(I) #CIWS stand left
  129. holoPos(I, entity():toWorld(vec(0,-22.51,40.93)*Scale))
  130. holoAng(I, entity():toWorld(ang(0,0,0)))
  131. holoScale(I, vec(1.27,0.785,1.183)*Scale)
  132. holoColor(I,MainColor)
  133. holoModel(I, "")
  134. holoMaterial(I,MainMat)
  135. holoParent(I,holoEntity(Turntable))
  136. I++
  137. Gunattachment=I
  138. Gattachpos=vec(0,0,38.7)*Scale
  139. AimHolo= holoCreate(I) #CIWS GunAttachment
  140. holoPos(I, entity():toWorld(Gattachpos))
  141. holoAng(I, entity():toWorld(ang(0,0,0)))
  142. holoAlpha(I,0)
  143. holoParent(I,holoEntity(Turntable))
  144. I++
  145. BaseAimHolo=holoCreate(I) #CIWS GunAttachment
  146. holoPos(I, entity():toWorld(Gattachpos))
  147. holoAng(I, entity():toWorld(ang(0,0,0)))
  148. holoAlpha(I,0)
  149. holoParent(I,holoEntity(Turntable))
  150. I++
  151.  
  152. Aimer = holoCreate(I) #CIWS GunAttachment
  153. holoPos(I, entity():toWorld(Gattachpos))
  154. holoAng(I, entity():toWorld(ang(0,0,0)))
  155. holoScale(I, vec(0.1,0.1,0.1)*Scale)
  156. holoColor(I,MainColor)
  157. holoModel(I, "")
  158. holoMaterial(I,MainMat)
  159. holoParent(I,holoEntity(Gunattachment))
  160. I++
  161.  
  162. holoCreate(I) #CIWS stand left
  163. holoPos(I, entity():toWorld(Gattachpos))
  164. holoAng(I, entity():toWorld(ang(90,0,0)))
  165. holoScale(I, vec(1.7,3,2.6)*Scale)
  166. holoColor(I,MainColor)
  167. holoModel(I, "hq_stube")
  168. holoMaterial(I,MainMat)
  169. holoParent(I,holoEntity(Gunattachment))
  170. I++
  171.  
  172.  
  173.  
  174. #AmmoDrum
  175. holoCreate(I) #CIWS stand left
  176. holoPos(I, AimHolo:toWorld(vec(1.5,0,-18)*Scale))
  177. holoAng(I, AimHolo:toWorld(ang(-90,0,0)))
  178. holoScale(I, vec(1.3,1.3,3.4)*Scale)
  179. holoColor(I,MainColor)
  180. holoModel(I, "hq_rcylinder_thin")
  181. # holoModel(I, "hq_cylinder")
  182. holoMaterial(I,SecMat)
  183. holoParent(I,holoEntity(Gunattachment))
  184. I++
  185.  
  186. #AmmoBelt
  187. holoCreate(I) #CIWS stand left
  188. holoPos(I, AimHolo:toWorld(vec(-2,5,-14)*Scale))
  189. holoAng(I, AimHolo:toWorld(ang(10,2,110)))
  190. holoScale(I, vec(0.5,0.35,0.035)*Scale)
  191. holoColor(I,DarkerColor)
  192. holoModel(I, "models/hunter/tubes/tube2x2x2b.mdl")
  193. holoMaterial(I,MainMat)
  194. holoParent(I,holoEntity(Gunattachment))
  195. I++
  196.  
  197. holoCreate(I) #CIWS stand left
  198. holoPos(I, entity():toWorld(vec(0,0,91 )*Scale))
  199. holoAng(I, entity():toWorld(ang(0,0,0)))
  200. holoScale(I, vec(2.52,2.52,2)*Scale)
  201. holoColor(I,TowerColor)
  202. holoModel(I, "hq_dome")
  203. holoMaterial(I,TowerMat)
  204. holoParent(I,holoEntity(Gunattachment))
  205. I++
  206.  
  207. #Radar Dome
  208. holoCreate(I) #CIWS stand left
  209. holoPos(I, entity():toWorld(vec(0,0,47)*Scale))
  210. holoAng(I, entity():toWorld(ang(0,0,0)))
  211. holoScale(I, vec(1.1,1.1,1)*Scale)
  212. holoColor(I,TowerColor)
  213. holoModel(I, "models/props_c17/oildrum001.mdl")
  214. holoMaterial(I,TowerMat)
  215. holoParent(I,holoEntity(Gunattachment))
  216. I++
  217.  
  218. holoCreate(I) #Minigun Holder
  219. holoPos(I, entity():toWorld(vec(-3,0,33.5)*Scale))
  220. holoAng(I, entity():toWorld(ang(90,0,0)))
  221. holoScale(I, vec(0.5,0.5,1.5)*Scale)
  222. holoColor(I,MainColor)
  223. holoModel(I, "")
  224. holoMaterial(I,MainMat)
  225. holoParent(I,holoEntity(Gunattachment))
  226. I++
  227. VulcanMain=I
  228. holoCreate(I) #BarrelRotorbit
  229. holoPos(I, entity():toWorld(Gattachpos-vec(6.5,0,0)*Scale))
  230. holoAng(I, entity():toWorld(ang(0,0,0)))
  231. holoScale(I, vec(1.1,1.3,1.3)*Scale)
  232. holoColor(I,DarkerColor)
  233. holoModel(I, "models/rotarycannon/kw/14_5mmrac.mdl")
  234. holoBodygroup(I,1,0)
  235. # holoMaterial(I,MainMat)
  236. holoParent(I,holoEntity(Gunattachment))
  237. I++
  238.  
  239. holoCreate(I) #Orange band indicating scrub status
  240. holoPos(I, entity():toWorld(vec(0,0,76.8)*Scale))
  241. holoAng(I, entity():toWorld(ang(0,0,0)))
  242. holoScale(I, vec(2.6,2.6,0.6)*Scale)
  243. holoColor(I,vec(255,150,0))
  244. holoModel(I, "hq_cylinder")
  245. holoMaterial(I,TowerMat)
  246. holoParent(I,holoEntity(Gunattachment))
  247. I++
  248.  
  249.  
  250. function number interpolatearray(Array:array, Dist) {
  251. TableSlot=Dist/RTIncrements
  252. TableNum=floor(TableSlot)
  253. Rat=(Dist-floor(TableSlot))/RTIncrements
  254. Smaller=Array[TableNum,number]
  255. Larger=Array[TableNum+1,number]
  256.  
  257. return Smaller+(Larger-Smaller)/Rat
  258. }
  259.  
  260. MaxDist*=39.37
  261. TickInterval=tickInterval()*1.2
  262.  
  263. Gun:setAlpha(0)
  264. holoPos(Gunattachment,Gun:toWorld(vec(Gun:boxSize():x()/2+2,0,0)))
  265. holoAng(Gunattachment,Gun:toWorld(ang(0,0,0)))
  266. Gun:parentTo(holoEntity(Gunattachment))
  267.  
  268. holoPos(Gunattachment,entity():toWorld(Gattachpos))
  269. holoAng(Gunattachment,entity():toWorld(ang()))
  270. if(Debug)
  271. {
  272. Gun:parentTo()#L
  273. Gun:setAlpha(255)
  274. }
  275.  
  276.  
  277.  
  278. entity():soundPlay("GunDrive", 0, "acf_extra/tankfx/turret3.wav")
  279. soundVolume("GunDrive",1)
  280. soundPitch("GunDrive",0)
  281.  
  282. entity():soundPlay("TurretHydro", 0, "acf_extra/vehiclefx/trans/gearwhine2.wav")
  283. soundVolume("TurretHydro",1)
  284. soundPitch("TurretHydro",0)
  285.  
  286. entity():soundPlay("Incoming", 0, "ambient/alarms/city_firebell_loop1.wav")
  287. soundVolume("Incoming",1)
  288. soundPitch("Incoming",0)
  289.  
  290. }
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298. interval(100)
  299.  
  300. if(clk("PreLoad"))
  301. {
  302.  
  303. PreLoaded = 1
  304. Fire = 0
  305. if(Debug)
  306. {
  307. stoptimer("interval")
  308. }
  309. }
  310.  
  311. if(changed(Entities:count()))
  312. {
  313. H=1
  314. IMaxDist=entity():pos():distance(Position[H,vector])
  315. Missile = Entities[H,entity]
  316.  
  317. if(Entities:count()>0)
  318. {
  319. soundPitch("Incoming",75)
  320. }
  321. else
  322. {
  323. soundPitch("Incoming",0)
  324. }
  325. }
  326.  
  327. if(Entities:count()>0)
  328. {
  329.  
  330. if(Entities:count()>1)
  331. {
  332.  
  333. for(N=1,Entities:count())
  334. {
  335. Distance=entity():pos():distance(Position[N,vector])
  336. if(Distance<IMaxDist)
  337. {
  338. IMaxDist = Distance
  339. H=N
  340. # PVel=Vel=Velocity[H,vector]/TickInterval
  341. Missile=Entities[H,entity]
  342. Distance=AimHolo:pos():distance(Position[H,vector])
  343. }
  344. }
  345.  
  346.  
  347. }
  348.  
  349. #Lead Calculation
  350.  
  351. Vel=(Velocity[H,vector]/TickInterval)
  352.  
  353. Pos=Position[H,vector]+Vel*0.214
  354. Distance=AimHolo:pos():distance(Pos)
  355.  
  356. TravelTime=TTime[floor(Distance/RTIncrements),number]
  357. OPos = Pos+(Vel*TravelTime*0.9)
  358.  
  359. Distance=AimHolo:pos():distance(OPos)
  360.  
  361. CalPos=interpolatearray(ElevPos,Distance)
  362.  
  363. rangerFilter(Gun)
  364. Ranger = rangerOffset(500,AimHolo:pos(),AimHolo:forward())
  365. #!Player:inVehicle()
  366. #Light = vec(255,0,0)
  367.  
  368.  
  369. if(PreLoaded&!(Ranger:entity():owner() == owner())&Distance<MaxDist)
  370. {
  371. Fire = 1
  372. soundPitch("GunDrive",120)
  373. holoAnim(VulcanMain, "shoot", 0, 12)
  374. }
  375. else
  376. {
  377. soundPitch("GunDrive",0)
  378. }
  379.  
  380.  
  381.  
  382. if(PreLoaded)
  383. {
  384.  
  385.  
  386.  
  387. TargPos=(OPos+vec(0,0,CalPos))
  388.  
  389. Bearing=clamp(entity():bearing(TargPos),-150,150)
  390. ElevationA=clamp(BaseAimHolo:elevation(TargPos), -Depression, Elevation)
  391. AdjustYaw=clamp(holoEntity(Turntable):toLocal(entity():toWorld(ang(0,-Bearing,0)) ),-ang(360,90,360),ang(360,90,360))
  392. AdjustElev=clamp(holoEntity(Gunattachment):toLocal(BaseAimHolo:toWorld(ang(-ElevationA,0,0)) ),-ang(77,360,360),ang(77,360,360))
  393. AdjustYawYaw=abs(AdjustYaw:yaw())
  394. AdjustElevElev=abs(AdjustElev:pitch())
  395. if(AdjustYawYaw>3)
  396. {
  397. soundPitch("TurretHydro",100)
  398. }
  399. else
  400. {
  401. soundPitch("TurretHydro",0)
  402. }
  403. if(changed(AdjustYawYaw<=3)&AdjustYawYaw<=3)
  404. {
  405. entity():soundPlay("YawLock", 0.06, "acf_extra/vehiclefx/trans/default_shift.wav")
  406. soundVolume("YawLock",1)
  407. soundPitch("YawLock",90)
  408. }
  409. if(changed(AdjustElevElev<=3)&AdjustElevElev<=3)
  410. {
  411. entity():soundPlay("ElevLock", 0.06, "acf_extra/vehiclefx/trans/default_shift.wav")
  412. soundVolume("ElevLock",1)
  413. soundPitch("ElevLock",90)
  414. }
  415.  
  416.  
  417. # Bearing=clamp(entity():bearing(GPS),-180,180)
  418. # ElevationA=clamp(AimHolo:elevation(GPS),-13,90)
  419.  
  420. #CANG=clamp(Gun:toLocal(GunAng),ang(-15,-12,-1),ang(15,12,1))
  421. #Gun:setAng(Gun:toLocal(entity():toWorld(clamp(entity():toLocal(Gun:toWorld(GunAng)),ang(Elevation,-Yaw,-1),ang(Depression,Yaw,1)))))
  422. #ActAng=Gun:toWorld(CANG):setRoll(0)
  423. holoAng(Turntable, holoEntity(Turntable):toWorld( clamp(holoEntity(Turntable):toLocal(entity():toWorld(ang(0,-Bearing,0)) ),-ang(360,90,360),ang(360,90,360)) ) )
  424. holoAng(Gunattachment, holoEntity(Gunattachment):toWorld( clamp(holoEntity(Gunattachment):toLocal(BaseAimHolo:toWorld(ang(-ElevationA,0,0)) ),-ang(77,360,360),ang(77,360,360)) ) )
  425. }
  426. }
  427. elseif(ManualAimpos&!ManualAimInactive)
  428. {
  429. TargPos=(ManualAimpos+vec(0,0,interpolatearray(ElevPos,AimHolo:pos():distance(ManualAimpos))))
  430.  
  431. Bearing=clamp(entity():bearing(TargPos),-150,150)
  432. ElevationA=clamp(BaseAimHolo:elevation(TargPos), -Depression, Elevation)
  433. AdjustYaw=clamp(holoEntity(Turntable):toLocal(entity():toWorld(ang(0,-Bearing,0)) ),-ang(360,90,360),ang(360,90,360))
  434. AdjustElev=clamp(holoEntity(Gunattachment):toLocal(BaseAimHolo:toWorld(ang(-ElevationA,0,0)) ),-ang(77,360,360),ang(77,360,360))
  435. AdjustYawYaw=abs(AdjustYaw:yaw())
  436. AdjustElevElev=abs(AdjustElev:pitch())
  437. if(AdjustYawYaw>0.3)
  438. {
  439. soundPitch("TurretHydro",100)
  440. }
  441. else
  442. {
  443. soundPitch("TurretHydro",0)
  444. }
  445. if(changed(AdjustYawYaw<=1)&AdjustYawYaw<=1)
  446. {
  447. entity():soundPlay("YawLock", 0.06, "acf_extra/vehiclefx/trans/default_shift.wav")
  448. soundVolume("YawLock",1)
  449. soundPitch("YawLock",90)
  450. }
  451. if(changed(AdjustElevElev<=1)&AdjustElevElev<=1)
  452. {
  453. entity():soundPlay("ElevLock", 0.06, "acf_extra/vehiclefx/trans/default_shift.wav")
  454. soundVolume("ElevLock",1)
  455. soundPitch("ElevLock",90)
  456. }
  457.  
  458. holoAng(Turntable, holoEntity(Turntable):toWorld(AdjustYaw))
  459. holoAng(Gunattachment, holoEntity(Gunattachment):toWorld(AdjustElev))
  460.  
  461.  
  462. #holoAng(Gunattachment, holoEntity(Gunattachment):toWorld( clamp(holoEntity(Gunattachment):toLocal(Aimer:toWorld(ang(ElevationA,0,0)) ),-ang(ElevRate,360,360),ang(ElevRate,360,360)) ) )
  463. if(ManualFire)
  464. {
  465. rangerFilter(Gun)
  466. Ranger = rangerOffset(500,AimHolo:pos(),AimHolo:forward())
  467. if(!(Ranger:entity():owner() == owner()))
  468. {
  469. Fire = 1
  470. }
  471. soundPitch("GunDrive",130)
  472. holoAnim(VulcanMain, "shoot", 0, 12)
  473. }
  474. else
  475. {
  476. Fire=0
  477. soundPitch("GunDrive",0)
  478. }
  479.  
  480. }
  481. else
  482. {
  483. if(PreLoaded)
  484. {
  485. Fire=0
  486. soundPitch("GunDrive",0)
  487. }
  488. AdjustYaw=clamp(holoEntity(Turntable):toLocal(entity():toWorld(ang(0,0,0)) ),-ang(360,90,360),ang(360,90,360))
  489. AdjustElev=clamp(holoEntity(Gunattachment):toLocal(BaseAimHolo:toWorld(ang(0,0,0)) ),-ang(77,360,360),ang(77,360,360))
  490. AdjustYawYaw=abs(AdjustYaw:yaw())
  491. AdjustElevElev=abs(AdjustElev:pitch())
  492. if(AdjustYawYaw>0.3)
  493. {
  494. soundPitch("TurretHydro",100)
  495. }
  496. else
  497. {
  498. soundPitch("TurretHydro",0)
  499. }
  500. if(changed(AdjustYawYaw<=1)&AdjustYawYaw<=1)
  501. {
  502. entity():soundPlay("YawLock", 0.06, "acf_extra/vehiclefx/trans/default_shift.wav")
  503. soundVolume("YawLock",1)
  504. soundPitch("YawLock",90)
  505. }
  506. if(changed(AdjustElevElev<=1)&AdjustElevElev<=1)
  507. {
  508. entity():soundPlay("ElevLock", 0.06, "acf_extra/vehiclefx/trans/default_shift.wav")
  509. soundVolume("ElevLock",1)
  510. soundPitch("ElevLock",90)
  511. }
  512.  
  513. holoAng(Turntable, holoEntity(Turntable):toWorld(AdjustYaw))
  514. holoAng(Gunattachment, holoEntity(Gunattachment):toWorld(AdjustElev))
  515.  
  516. }
  517.  
  518. #[
  519. MissileHealth=Missile:acfPropHealth() #Add to persist if debugging
  520. if(changed(MissileHealth) & MissileHealth != Missile:acfPropHealthMax()){
  521. print("Hit")
  522. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement