Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name RDC's Phalanx Block 0 - Community Version
- @inputs Gun:entity ElevPos:array Entities:array Velocity:array Position:array ManualAimpos:vector ManualFire ManualAimInactive TTime:array
- @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
- @outputs I H Active Fire Vel:vector
- @trigger none
- if (first()|dupefinished()) {
- entity():setAlpha(255)
- Debug = 0 #Disable Parenting
- RTIncrements=20*39.37 #Dont touch unless you know what your doing
- Elevation = 80 #Gun Elevation
- Depression = 10 #Gun Depression
- MaxDist = 100 #Minimum Distance in meters until the CRAM can fire, useful for lower penetration MGs
- MainColor=vec(230,230,230)
- TowerColor=vec(250,250,250)
- DarkerColor=vec(70,70,70)
- MainMat="models/props_pipes/pipemetal001a"
- SecMat="models/props_wasteland/concretewall064b"
- TowerMat="models/props_debris/building_template010a"
- Active = 1
- Scale=1.1/7
- #Unless you know what your doing dont edit below here
- H = 1
- I=1
- timer("scan",1500)
- timer("PreLoad",1000)
- Fire=1
- holoCreate(I) #Reciever Main
- holoPos(I, entity():toWorld(vec(0,0,0)))
- holoAng(I, entity():toWorld(ang(0,0,0)))
- holoScale(I, vec(6,6,0.1)*Scale)
- holoColor(I,MainColor)
- holoModel(I, "hq_cylinder")
- holoMaterial(I,SecMat)
- holoParent(I,entity())
- I++
- Turntable = I
- holoCreate(I) #Base
- holoPos(I, entity():toWorld(vec(0,0,3)*Scale))
- holoAng(I, entity():toWorld(ang(0,0,0)))
- holoScale(I, vec(5.46,5.46,0.3)*Scale)
- holoColor(I,MainColor)
- holoModel(I, "hq_cylinder")
- holoMaterial(I,MainMat)
- holoParent(I,entity())
- I++
- holoCreate(I) #CIWS stand left
- holoPos(I, entity():toWorld(vec(0,22.55,8)*Scale))
- holoAng(I, entity():toWorld(ang(0,0,0)))
- holoScale(I, vec(2.54,0.8,1)*Scale)
- holoColor(I,MainColor)
- holoModel(I, "")
- holoMaterial(I,MainMat)
- holoParent(I,holoEntity(Turntable))
- I++
- holoCreate(I)
- holoPos(I, entity():toWorld(vec(0,-22.55,8)*Scale))
- holoAng(I, entity():toWorld(ang(0,0,0)))
- holoScale(I, vec(2.54,0.8,1)*Scale)
- holoColor(I,MainColor)
- holoModel(I, "")
- holoMaterial(I,MainMat)
- holoParent(I,holoEntity(Turntable))
- I++
- holoCreate(I) #CIWS stand left
- holoPos(I, entity():toWorld(vec(-4.3,-22.55,29)*Scale))
- holoAng(I, entity():toWorld(ang(-12,180,0)))
- holoScale(I, vec(0.55,0.41,0.51)*Scale)
- # holoColor(I,MainColor)
- holoModel(I, "models/props_wasteland/controlroom_filecabinet002a.mdl")
- holoMaterial(I,MainMat)
- holoParent(I,holoEntity(Turntable))
- I++
- print("Phalanx E2 made by RDC")
- holoCreate(I) #CIWS stand left
- holoPos(I, entity():toWorld(vec(4.3,-22.55,29)*Scale))
- holoAng(I, entity():toWorld(ang(-12,0,0)))
- holoScale(I, vec(0.55,0.41,0.51)*Scale)
- # holoColor(I,MainColor)
- holoModel(I, "models/props_wasteland/controlroom_filecabinet002a.mdl")
- holoMaterial(I,MainMat)
- holoParent(I,holoEntity(Turntable))
- I++
- holoCreate(I) #CIWS stand left
- holoPos(I, entity():toWorld(vec(-4.3,22.55,29)*Scale))
- holoAng(I, entity():toWorld(ang(-12,180,0)))
- holoScale(I, vec(0.55,0.41,0.51)*Scale)
- # holoColor(I,MainColor)
- holoModel(I, "models/props_wasteland/controlroom_filecabinet002a.mdl")
- holoMaterial(I,MainMat)
- holoParent(I,holoEntity(Turntable))
- I++
- holoCreate(I) #CIWS stand left
- holoPos(I, entity():toWorld(vec(4.3,22.55,29)*Scale))
- holoAng(I, entity():toWorld(ang(-12,0,0)))
- holoScale(I, vec(0.55,0.41,0.51)*Scale)
- # holoColor(I,MainColor)
- holoModel(I, "models/props_wasteland/controlroom_filecabinet002a.mdl")
- holoMaterial(I,MainMat)
- holoParent(I,holoEntity(Turntable))
- I++
- holoCreate(I) #CIWS stand left
- holoPos(I, entity():toWorld(vec(0,22.51,40.93)*Scale))
- holoAng(I, entity():toWorld(ang(0,0,0)))
- holoScale(I, vec(1.27,0.785,1.183)*Scale)
- holoColor(I,MainColor)
- holoModel(I, "")
- holoMaterial(I,MainMat)
- holoParent(I,holoEntity(Turntable))
- I++
- holoCreate(I) #CIWS stand left
- holoPos(I, entity():toWorld(vec(0,-22.51,40.93)*Scale))
- holoAng(I, entity():toWorld(ang(0,0,0)))
- holoScale(I, vec(1.27,0.785,1.183)*Scale)
- holoColor(I,MainColor)
- holoModel(I, "")
- holoMaterial(I,MainMat)
- holoParent(I,holoEntity(Turntable))
- I++
- Gunattachment=I
- Gattachpos=vec(0,0,38.7)*Scale
- AimHolo= holoCreate(I) #CIWS GunAttachment
- holoPos(I, entity():toWorld(Gattachpos))
- holoAng(I, entity():toWorld(ang(0,0,0)))
- holoAlpha(I,0)
- holoParent(I,holoEntity(Turntable))
- I++
- BaseAimHolo=holoCreate(I) #CIWS GunAttachment
- holoPos(I, entity():toWorld(Gattachpos))
- holoAng(I, entity():toWorld(ang(0,0,0)))
- holoAlpha(I,0)
- holoParent(I,holoEntity(Turntable))
- I++
- Aimer = holoCreate(I) #CIWS GunAttachment
- holoPos(I, entity():toWorld(Gattachpos))
- holoAng(I, entity():toWorld(ang(0,0,0)))
- holoScale(I, vec(0.1,0.1,0.1)*Scale)
- holoColor(I,MainColor)
- holoModel(I, "")
- holoMaterial(I,MainMat)
- holoParent(I,holoEntity(Gunattachment))
- I++
- holoCreate(I) #CIWS stand left
- holoPos(I, entity():toWorld(Gattachpos))
- holoAng(I, entity():toWorld(ang(90,0,0)))
- holoScale(I, vec(1.7,3,2.6)*Scale)
- holoColor(I,MainColor)
- holoModel(I, "hq_stube")
- holoMaterial(I,MainMat)
- holoParent(I,holoEntity(Gunattachment))
- I++
- #AmmoDrum
- holoCreate(I) #CIWS stand left
- holoPos(I, AimHolo:toWorld(vec(1.5,0,-18)*Scale))
- holoAng(I, AimHolo:toWorld(ang(-90,0,0)))
- holoScale(I, vec(1.3,1.3,3.4)*Scale)
- holoColor(I,MainColor)
- holoModel(I, "hq_rcylinder_thin")
- # holoModel(I, "hq_cylinder")
- holoMaterial(I,SecMat)
- holoParent(I,holoEntity(Gunattachment))
- I++
- #AmmoBelt
- holoCreate(I) #CIWS stand left
- holoPos(I, AimHolo:toWorld(vec(-2,5,-14)*Scale))
- holoAng(I, AimHolo:toWorld(ang(10,2,110)))
- holoScale(I, vec(0.5,0.35,0.035)*Scale)
- holoColor(I,DarkerColor)
- holoModel(I, "models/hunter/tubes/tube2x2x2b.mdl")
- holoMaterial(I,MainMat)
- holoParent(I,holoEntity(Gunattachment))
- I++
- holoCreate(I) #CIWS stand left
- holoPos(I, entity():toWorld(vec(0,0,91 )*Scale))
- holoAng(I, entity():toWorld(ang(0,0,0)))
- holoScale(I, vec(2.52,2.52,2)*Scale)
- holoColor(I,TowerColor)
- holoModel(I, "hq_dome")
- holoMaterial(I,TowerMat)
- holoParent(I,holoEntity(Gunattachment))
- I++
- #Radar Dome
- holoCreate(I) #CIWS stand left
- holoPos(I, entity():toWorld(vec(0,0,47)*Scale))
- holoAng(I, entity():toWorld(ang(0,0,0)))
- holoScale(I, vec(1.1,1.1,1)*Scale)
- holoColor(I,TowerColor)
- holoModel(I, "models/props_c17/oildrum001.mdl")
- holoMaterial(I,TowerMat)
- holoParent(I,holoEntity(Gunattachment))
- I++
- holoCreate(I) #Minigun Holder
- holoPos(I, entity():toWorld(vec(-3,0,33.5)*Scale))
- holoAng(I, entity():toWorld(ang(90,0,0)))
- holoScale(I, vec(0.5,0.5,1.5)*Scale)
- holoColor(I,MainColor)
- holoModel(I, "")
- holoMaterial(I,MainMat)
- holoParent(I,holoEntity(Gunattachment))
- I++
- VulcanMain=I
- holoCreate(I) #BarrelRotorbit
- holoPos(I, entity():toWorld(Gattachpos-vec(6.5,0,0)*Scale))
- holoAng(I, entity():toWorld(ang(0,0,0)))
- holoScale(I, vec(1.1,1.3,1.3)*Scale)
- holoColor(I,DarkerColor)
- holoModel(I, "models/rotarycannon/kw/14_5mmrac.mdl")
- holoBodygroup(I,1,0)
- # holoMaterial(I,MainMat)
- holoParent(I,holoEntity(Gunattachment))
- I++
- holoCreate(I) #Orange band indicating scrub status
- holoPos(I, entity():toWorld(vec(0,0,76.8)*Scale))
- holoAng(I, entity():toWorld(ang(0,0,0)))
- holoScale(I, vec(2.6,2.6,0.6)*Scale)
- holoColor(I,vec(255,150,0))
- holoModel(I, "hq_cylinder")
- holoMaterial(I,TowerMat)
- holoParent(I,holoEntity(Gunattachment))
- I++
- function number interpolatearray(Array:array, Dist) {
- TableSlot=Dist/RTIncrements
- TableNum=floor(TableSlot)
- Rat=(Dist-floor(TableSlot))/RTIncrements
- Smaller=Array[TableNum,number]
- Larger=Array[TableNum+1,number]
- return Smaller+(Larger-Smaller)/Rat
- }
- MaxDist*=39.37
- TickInterval=tickInterval()*1.2
- Gun:setAlpha(0)
- holoPos(Gunattachment,Gun:toWorld(vec(Gun:boxSize():x()/2+2,0,0)))
- holoAng(Gunattachment,Gun:toWorld(ang(0,0,0)))
- Gun:parentTo(holoEntity(Gunattachment))
- holoPos(Gunattachment,entity():toWorld(Gattachpos))
- holoAng(Gunattachment,entity():toWorld(ang()))
- if(Debug)
- {
- Gun:parentTo()#L
- Gun:setAlpha(255)
- }
- entity():soundPlay("GunDrive", 0, "acf_extra/tankfx/turret3.wav")
- soundVolume("GunDrive",1)
- soundPitch("GunDrive",0)
- entity():soundPlay("TurretHydro", 0, "acf_extra/vehiclefx/trans/gearwhine2.wav")
- soundVolume("TurretHydro",1)
- soundPitch("TurretHydro",0)
- entity():soundPlay("Incoming", 0, "ambient/alarms/city_firebell_loop1.wav")
- soundVolume("Incoming",1)
- soundPitch("Incoming",0)
- }
- interval(100)
- if(clk("PreLoad"))
- {
- PreLoaded = 1
- Fire = 0
- if(Debug)
- {
- stoptimer("interval")
- }
- }
- if(changed(Entities:count()))
- {
- H=1
- IMaxDist=entity():pos():distance(Position[H,vector])
- Missile = Entities[H,entity]
- if(Entities:count()>0)
- {
- soundPitch("Incoming",75)
- }
- else
- {
- soundPitch("Incoming",0)
- }
- }
- if(Entities:count()>0)
- {
- if(Entities:count()>1)
- {
- for(N=1,Entities:count())
- {
- Distance=entity():pos():distance(Position[N,vector])
- if(Distance<IMaxDist)
- {
- IMaxDist = Distance
- H=N
- # PVel=Vel=Velocity[H,vector]/TickInterval
- Missile=Entities[H,entity]
- Distance=AimHolo:pos():distance(Position[H,vector])
- }
- }
- }
- #Lead Calculation
- Vel=(Velocity[H,vector]/TickInterval)
- Pos=Position[H,vector]+Vel*0.214
- Distance=AimHolo:pos():distance(Pos)
- TravelTime=TTime[floor(Distance/RTIncrements),number]
- OPos = Pos+(Vel*TravelTime*0.9)
- Distance=AimHolo:pos():distance(OPos)
- CalPos=interpolatearray(ElevPos,Distance)
- rangerFilter(Gun)
- Ranger = rangerOffset(500,AimHolo:pos(),AimHolo:forward())
- #!Player:inVehicle()
- #Light = vec(255,0,0)
- if(PreLoaded&!(Ranger:entity():owner() == owner())&Distance<MaxDist)
- {
- Fire = 1
- soundPitch("GunDrive",120)
- holoAnim(VulcanMain, "shoot", 0, 12)
- }
- else
- {
- soundPitch("GunDrive",0)
- }
- if(PreLoaded)
- {
- TargPos=(OPos+vec(0,0,CalPos))
- Bearing=clamp(entity():bearing(TargPos),-150,150)
- ElevationA=clamp(BaseAimHolo:elevation(TargPos), -Depression, Elevation)
- AdjustYaw=clamp(holoEntity(Turntable):toLocal(entity():toWorld(ang(0,-Bearing,0)) ),-ang(360,90,360),ang(360,90,360))
- AdjustElev=clamp(holoEntity(Gunattachment):toLocal(BaseAimHolo:toWorld(ang(-ElevationA,0,0)) ),-ang(77,360,360),ang(77,360,360))
- AdjustYawYaw=abs(AdjustYaw:yaw())
- AdjustElevElev=abs(AdjustElev:pitch())
- if(AdjustYawYaw>3)
- {
- soundPitch("TurretHydro",100)
- }
- else
- {
- soundPitch("TurretHydro",0)
- }
- if(changed(AdjustYawYaw<=3)&AdjustYawYaw<=3)
- {
- entity():soundPlay("YawLock", 0.06, "acf_extra/vehiclefx/trans/default_shift.wav")
- soundVolume("YawLock",1)
- soundPitch("YawLock",90)
- }
- if(changed(AdjustElevElev<=3)&AdjustElevElev<=3)
- {
- entity():soundPlay("ElevLock", 0.06, "acf_extra/vehiclefx/trans/default_shift.wav")
- soundVolume("ElevLock",1)
- soundPitch("ElevLock",90)
- }
- # Bearing=clamp(entity():bearing(GPS),-180,180)
- # ElevationA=clamp(AimHolo:elevation(GPS),-13,90)
- #CANG=clamp(Gun:toLocal(GunAng),ang(-15,-12,-1),ang(15,12,1))
- #Gun:setAng(Gun:toLocal(entity():toWorld(clamp(entity():toLocal(Gun:toWorld(GunAng)),ang(Elevation,-Yaw,-1),ang(Depression,Yaw,1)))))
- #ActAng=Gun:toWorld(CANG):setRoll(0)
- holoAng(Turntable, holoEntity(Turntable):toWorld( clamp(holoEntity(Turntable):toLocal(entity():toWorld(ang(0,-Bearing,0)) ),-ang(360,90,360),ang(360,90,360)) ) )
- holoAng(Gunattachment, holoEntity(Gunattachment):toWorld( clamp(holoEntity(Gunattachment):toLocal(BaseAimHolo:toWorld(ang(-ElevationA,0,0)) ),-ang(77,360,360),ang(77,360,360)) ) )
- }
- }
- elseif(ManualAimpos&!ManualAimInactive)
- {
- TargPos=(ManualAimpos+vec(0,0,interpolatearray(ElevPos,AimHolo:pos():distance(ManualAimpos))))
- Bearing=clamp(entity():bearing(TargPos),-150,150)
- ElevationA=clamp(BaseAimHolo:elevation(TargPos), -Depression, Elevation)
- AdjustYaw=clamp(holoEntity(Turntable):toLocal(entity():toWorld(ang(0,-Bearing,0)) ),-ang(360,90,360),ang(360,90,360))
- AdjustElev=clamp(holoEntity(Gunattachment):toLocal(BaseAimHolo:toWorld(ang(-ElevationA,0,0)) ),-ang(77,360,360),ang(77,360,360))
- AdjustYawYaw=abs(AdjustYaw:yaw())
- AdjustElevElev=abs(AdjustElev:pitch())
- if(AdjustYawYaw>0.3)
- {
- soundPitch("TurretHydro",100)
- }
- else
- {
- soundPitch("TurretHydro",0)
- }
- if(changed(AdjustYawYaw<=1)&AdjustYawYaw<=1)
- {
- entity():soundPlay("YawLock", 0.06, "acf_extra/vehiclefx/trans/default_shift.wav")
- soundVolume("YawLock",1)
- soundPitch("YawLock",90)
- }
- if(changed(AdjustElevElev<=1)&AdjustElevElev<=1)
- {
- entity():soundPlay("ElevLock", 0.06, "acf_extra/vehiclefx/trans/default_shift.wav")
- soundVolume("ElevLock",1)
- soundPitch("ElevLock",90)
- }
- holoAng(Turntable, holoEntity(Turntable):toWorld(AdjustYaw))
- holoAng(Gunattachment, holoEntity(Gunattachment):toWorld(AdjustElev))
- #holoAng(Gunattachment, holoEntity(Gunattachment):toWorld( clamp(holoEntity(Gunattachment):toLocal(Aimer:toWorld(ang(ElevationA,0,0)) ),-ang(ElevRate,360,360),ang(ElevRate,360,360)) ) )
- if(ManualFire)
- {
- rangerFilter(Gun)
- Ranger = rangerOffset(500,AimHolo:pos(),AimHolo:forward())
- if(!(Ranger:entity():owner() == owner()))
- {
- Fire = 1
- }
- soundPitch("GunDrive",130)
- holoAnim(VulcanMain, "shoot", 0, 12)
- }
- else
- {
- Fire=0
- soundPitch("GunDrive",0)
- }
- }
- else
- {
- if(PreLoaded)
- {
- Fire=0
- soundPitch("GunDrive",0)
- }
- AdjustYaw=clamp(holoEntity(Turntable):toLocal(entity():toWorld(ang(0,0,0)) ),-ang(360,90,360),ang(360,90,360))
- AdjustElev=clamp(holoEntity(Gunattachment):toLocal(BaseAimHolo:toWorld(ang(0,0,0)) ),-ang(77,360,360),ang(77,360,360))
- AdjustYawYaw=abs(AdjustYaw:yaw())
- AdjustElevElev=abs(AdjustElev:pitch())
- if(AdjustYawYaw>0.3)
- {
- soundPitch("TurretHydro",100)
- }
- else
- {
- soundPitch("TurretHydro",0)
- }
- if(changed(AdjustYawYaw<=1)&AdjustYawYaw<=1)
- {
- entity():soundPlay("YawLock", 0.06, "acf_extra/vehiclefx/trans/default_shift.wav")
- soundVolume("YawLock",1)
- soundPitch("YawLock",90)
- }
- if(changed(AdjustElevElev<=1)&AdjustElevElev<=1)
- {
- entity():soundPlay("ElevLock", 0.06, "acf_extra/vehiclefx/trans/default_shift.wav")
- soundVolume("ElevLock",1)
- soundPitch("ElevLock",90)
- }
- holoAng(Turntable, holoEntity(Turntable):toWorld(AdjustYaw))
- holoAng(Gunattachment, holoEntity(Gunattachment):toWorld(AdjustElev))
- }
- #[
- MissileHealth=Missile:acfPropHealth() #Add to persist if debugging
- if(changed(MissileHealth) & MissileHealth != Missile:acfPropHealthMax()){
- print("Hit")
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement