Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name RDC's Torpedo E2 V1.5
- @inputs Fire Launchers:array Gun1:entity Gun2:entity Gun3:entity RefillCrate:entity AmmoRackProp:entity Aimpos:vector SinkDepth
- @outputs Torpedoes:array F1 F2 F3 AmmoActive TorpedoesLeft TEnt:entity
- @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
- @trigger
- interval(500)
- if(duped()|dupefinished())
- {
- reset()
- }
- elseif(first())
- {
- #There is no reason to use more than 3 launchers
- TorpedoProp="models/sprops/cylinders/size_2/cylinder_3x36.mdl" #Larger props are faster and have more fuse time
- #You have 10 points to distribute, use them wisely
- DepthOveride = 10 #Set to nonzero to force the torpedo to sink to a fixed depth, else use SinkDepth value on launch
- Speed = 2.5 #about 10 u/s per unit, faster/slower based on prop size
- Fuse = 5 #More fuse, more torpedo time
- Agility = 2.5 #For homing torpedoes only, if you use this on a torpedo which didnt have homing I will telebomb you
- #A homing e2 will go towards an aimposition specified at launch until its seeker head aquires the target
- SalvoFire=0 #Fire all torpedo tubes at once or recieve a faster reload
- ReloadTime=50 #Torpedo Reload Time given by chart
- TubeCount=4 #Torpedo Launchers in a single launcher set (IE: 4 to a quad mount, 2 to a double)
- PropKill=0 #Teleport ACF guns or use exploding props to do damage
- TorpModel=1 #What model do you want for your fired torpedoes?
- #Spawn a prop for derriving scaling
- TestProp = propSpawn(TorpedoProp,vec(0,0,0),ang(0,0,0),0)
- Dimensions=TestProp:boxSize()/6.5
- Length=(TestProp:boxSize()):z()/6.5
- Width=(TestProp:boxSize()):x()/6.5
- TVol=TestProp:volume()
- TestProp:propDelete()
- SpeedVal=Speed*10
- RLength=Length*6.5+0.1
- TMass=TVol/39.38
- AmmoActive=1
- CGun=1
- TorpedoesLeft=floor(AmmoRackProp:volume()/TVol/16)
- AmmoRackProp:setMass(TMass*TorpedoesLeft)
- LengthOffset=60+Length
- CurrentTube=1
- if(TorpModel==1)
- {
- HoloModel="models/props_phx/torpedo.mdl"
- HoloScaleVar=vec(Length/26,Width/3.4,Width/3.4)
- HoloVOffset=vec(0,3*Width,0)
- }
- else
- {
- HoloModel="models/props_phx/ww2bomb.mdl"
- HoloScaleVar=vec(Length*0.11,Width*0.423,Width*0.423)
- HoloVOffset=vec(0,2.5*Width,0)
- }
- function spawnTorpedo(Launcher:entity)
- {
- TProp=propSpawn("models/sprops/rectangles/size_1/rect_3x3x3.mdl",(Launcher:toWorld(vec(LengthOffset,0,0))),(Launcher:toWorld(ang(0,0,0))),0)
- TProp:applyForce(TProp:forward()*TMass*50)
- TProp:setAlpha(0)
- #TProp:propDrag(0)
- TProp:propFreeze(0)
- TProp:setMass(TMass)
- TProp:propSetBuoyancy(0)
- TProp:setTrails(Width*10,2*Width,3, "trails/smoke", vec(255,255,255),100)
- holoCreate(Holos)
- holoPos(Holos,TProp:toWorld(HoloVOffset))
- holoAng(Holos,TProp:toWorld(ang(0,0,0)))
- holoModel(Holos,HoloModel)
- holoScale(Holos,HoloScaleVar)
- holoParent(Holos,TProp)
- Holos++
- TProp:propGravity(0)
- Torpedoes:pushEntity(TProp)
- Fuse*=2
- FuseTimes:pushNumber(Fuse*TMass)
- if(!DepthOveride)
- {
- TDepth:pushNumber(SinkDepth)
- }
- else
- {
- TDepth:pushNumber(DepthOveride)
- }
- if(Aimpos!=vec(0)){AimPositions:pushVector(Aimpos)}else{AimPositions:pushVector(Launcher:toWorld(vec(5000,0,0)))}
- TProp:soundPlay(SIndex1,0,"acf_extra/cannons/scifi/vacuumgun.wav")
- soundPitch(SIndex1,95)
- soundVolume(SIndex1,52.8)
- SIndex1++
- }
- function fireGun(Aimpos:vector,AimAng:angle)
- {
- if(CGun==1)
- {
- Gun1:setPos(Aimpos)
- Gun1:setAng(AimAng)
- CGun=2
- }
- elseif(CGun==2)
- {
- Gun2:setPos(Aimpos)
- Gun2:setAng(AimAng)
- CGun=3
- }
- elseif(CGun==3)
- {
- Gun3:setPos(Aimpos)
- Gun3:setAng(AimAng)
- CGun=1
- }
- #Gun3:soundPlay(SIndex3,0,"acf_new/weapons/tow/near/mid (1).wav")
- #soundPitch(SIndex3,45)
- #SIndex3++
- timer("Fire",10)
- timer("returnGuns",100)
- }
- F1=1
- F2=2
- F3=3
- timer("returnGuns",200)
- if(!SalvoFire)
- {
- ReloadTime=ReloadTime/((TubeCount*Launchers:count()+1)/2)*1000
- }
- else
- {
- ReloadTime=ReloadTime/((TubeCount+1)/2)*1000
- }
- Canfire=1
- function torpedoBoom(TP:entity,Boompos:vector)
- {
- TP:propDelete()
- if(PropKill)
- {
- Boom = propSpawn("models/props_junk/propane_tank001a.mdl",Boompos,ang(0,0,0),0)
- Boom:propBreak()
- }
- else
- {
- fireGun(Boompos,TP:toWorld(ang(0,0,0)))
- }
- }
- #Another nifty function someone gave me
- function entity:turnTo(Tarang:angle,Mult){
- V = This:toLocal(rotationVector(quat(Tarang)/quat(This))+This:pos())
- This:applyTorque((Mult*100*V - 30*This:angVelVector())*This:inertia()/3)
- }
- function torpedo(TorpedoN) # I'M A TORPEDO! YAY!!!
- {
- Torpedo=Torpedoes[TorpedoN,entity]
- rangerHitWater(1)
- rangerHitEntities(0)
- WaterRanger=rangerOffset(8000,Torpedo:pos()+vec(0,0,4000),vec(0,0,-1))
- WaterHeight=WaterRanger:position():z()
- #(AvgHeight/LegCount)+vec(0,0,HoverHeight)-entity():pos()
- 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)
- #Torpedo:applyForce(vec(0,0,Difpos)*TMass)
- FTime=FuseTimes[TorpedoN,number]
- if(Torpedo:isUnderWater())
- {
- FuseTimes[TorpedoN,number]=FTime-0.5
- if(Agility!=0)
- {
- #Aimpos
- #TEnt=noentity()
- rangerHitWater(0)
- rangerHitEntities(1)
- rangerFilter(Torpedo)
- rangerFilter(Launchers)
- rangerFilter(Torpedoes)
- SearchRanger=rangerOffsetHull(4000,Torpedo:pos(),Torpedo:forward(),vec(1,600,400))
- if(SearchRanger:entity():isValid()&FTime<Fuse*TMass-12)
- {
- Torpedo:soundPlay("BEEP",0.17,"acf_extra/vehiclefx/horn/horn2.wav")
- soundPitch("BEEP",150)
- Pos=SearchRanger:entity():pos()
- AimPositions[TorpedoN,vector] = Pos
- TDepth[TorpedoN,number] = max(WaterHeight-Pos:z(),5)
- TEnt=SearchRanger:entity()
- GunAng =(Pos - Torpedo:pos()):toAngle()
- }
- else
- {
- GunAng =(AimPositions[TorpedoN,vector] - Torpedo:pos()):toAngle()*ang(0,1,0)
- }
- Torpedo:turnTo(GunAng,0.15*Agility)
- Torpedo:applyForce(Torpedo:forward()*TMass*2*SpeedVal-Torpedo:vel()*vec(1,1,0))
- }
- else
- {
- Torpedo:applyForce(Torpedo:forward()*(TMass*0.8)*SpeedVal)
- }
- }
- rangerHitWater(0)
- rangerHitEntities(1)
- Ranger=rangerOffset(20+abs(Torpedo:velL():length())*1,Torpedo:toWorld(vec(RLength,0,0)),Torpedo:forward())
- #Ranger=rangerOffset(Torpedo:toWorld(vec(0,0,RLength)),Torpedo:toWorld(vec(0,0,RLength+5*Length)))
- if(Ranger:hit()&FTime<Fuse*TMass-12)
- {
- torpedoBoom(Torpedo,Torpedo:toWorld(vec(-10,0,0)))
- }
- elseif(FuseTimes[TorpedoN,number]<0)
- {
- Torpedo:propDelete()
- }
- }
- if(Fuse+Speed+Agility>10)
- {
- hint("More than 10 points allocated",5)
- }
- else
- {
- Alright = 1
- }
- }
- if(Alright)
- {
- if(~Fire&Fire&Canfire&AmmoRackProp:isValid())
- {
- if(TorpedoesLeft>0)
- {
- AmmoRackProp:setMass(TMass*TorpedoesLeft/(AmmoRackProp:volume()/26))
- entity():soundPlay(SIndex2,500,"acf_extra/airfx/javelin_fire.wav")
- soundPitch(SIndex2,80)
- SIndex2++
- if(SalvoFire)
- {
- for(I=1,Launchers:count())
- {
- if(TorpedoesLeft>0)
- {
- TorpedoesLeft--
- spawnTorpedo(Launchers[I,entity])
- Canfire=0
- timer("Reload",ReloadTime)
- }
- }
- }
- else
- {
- TorpedoesLeft--
- spawnTorpedo(Launchers[CurrentTube,entity])
- CurrentTube++
- if(CurrentTube>Launchers:count())
- {CurrentTube=1}
- Canfire=0
- timer("Reload",ReloadTime)
- }
- }
- }
- for(I=1,Torpedoes:count())
- {
- if(Torpedoes[I,entity]:isValid())
- {torpedo(I)}else{Torpedoes:removeEntity(I),FuseTimes:removeNumber(I),AimPositions:removeVector(I),TDepth:removeNumber(I)}
- }
- }
- if(clk("Fire"))
- {
- if(CGun==1)
- {
- F3=1
- }
- if(CGun==2)
- {
- F1=1
- }
- if(CGun==3)
- {
- F2=1
- }
- }
- if(clk("returnGuns"))
- {
- F1=0
- F2=0
- F3=0
- Gun1:setPos(RefillCrate:pos()+vec(10,0,20))
- Gun2:setPos(RefillCrate:pos()+vec(0,0,20))
- Gun3:setPos(RefillCrate:pos()+vec(-10,0,20))
- }
- if(clk("Reload"))
- {
- Canfire=1
- entity():soundPlay("Ready",0.2,"acf_extra/airfx/weapon_select.wav")
- stoptimer("Reload")
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement