@name Verus's Tank Chip @inputs [Turret Barrel Engine Pod Cam]:wirelink @outputs AccelerationTank Throttle Acc GTThrottle @persist [Bar Tur E Holo1]:entity [ThirdCameraPosition ThirdCameraRotation FirstCameraPosition]:vector YawLeft YawRight @persist [Constrained EyeSensitivity Array1 Array2 Array3]:array Size2:vector2 EngineSound:string Eye:angle InTimer FLIRA FLIR AimingMethod @persist SX SY Yaw Zoom VMod Mass Timer1 Timer2 Height Speed Forwards Backwards TurningSpeed ImpactDeath WaterLevel AimingModes Torque Power Acc TWeight @persist EnginePitch TurretSpeed Acceleration BarrelDepression BarrelElevation Stabalization EyeX1 EyeY1 TrueSensitivity UnderWater ControlMovement @model models/hunter/plates/plate2x3.mdl interval(20) if(first()){ #Read this before using # This is Verus / Badger130's tank chip # This e2 controls the tank's movement, turret rotation, barrel elevation, and camera # This e2 has trouble carring heavy props, and as such the turret and barrel should not have gravity # This e2 acts as the base of the tank, change the @model to your desired prop # Do NOT block the corners of the base prop, that is where the rangers trace for the base prop's angles #Option variables #Movement Options Height = 26 # This is how high off the ground the tank will float EPower = 340 # This is the amount of power in Kilo/Watts ETorque = 400 # This is the amount of torque in Newtons/Meter TurningSpeed = 20 # This is how much A and D affect the tank ControlMovement = 1 # Does the e2 control movement for tank or not Diesel = 0 #if 1 it will make engine diesel, if 0 it will make petrol #Turret Options BarrelDepression = 7 # This is how much the barrel can look downwards BarrelElevation = 15 # This is how much the barrel can look upwards TurretSpeed = 8 # This is how fast the turret traverses Stabalization = 1 # This determines if the turret is stabalized or not Sensitivity = 65 # This is how much the camera moves from your mouse, 100 being default #Camera Options FirstCameraPosition = vec(20,50,40) # This 3rd person camera's base position realitive to the turret ThirdCameraPosition = vec(0,0,30) # This 3rd person camera's base position realitive to the tank ThirdCameraRotation = vec(-160,0,70) # This 3rd person camera's position rotated by your view angles FLIR = 1 #This determines weather the tank has infrared vision ReticuleColor = vec(255,25,25) #This is the color of the crosshair ReticuleMode = 4 # A number between 1 and 10 for diffrent reticules ReticuleSize = 1.5 #T his determines the size of the reticule #Sound Options Sound = "/acf_engines/l6_diesellarge2.wav" # This is the sound of the engine EnginePitch = 18 # This is the default pitch of the engine and when it moves # The code is below # Only mess with if you know what your doing ReticleModels = array("cylinder","octagon","hexagon","icosphere","icosphere2","icosphere3","sphere") Tur = Turret:entity() Bar = Barrel:entity() E = entity() Size = E:boxSize()/2 SX = Size:x() SY = Size:y() EyeSensitivity = array() Array2 = array() Array1 = array() Array3 = array() TrueSensitivity = Sensitivity / 400 ImpactDeath = 0 WaterLevel = -50000 holoCreate(1,vec(),vec(),ang()) holoAlpha(1,0) holoVisible(1,players(),0) holoParent(1,E) holoCreate(2,vec(),vec(),ang()) holoVisible(2,players(),0) holoParent(2,1) OO5 = clamp(vec(0.05,0.05,0.05)*ReticuleSize,vec(0.05,0.05,0.05),vec(0.5,0.5,0.5)) holoCreate(3,vec(9,0,0),OO5,ang(90,0,0),ReticuleColor,"hq_torus_thin") holoVisible(3,players(),0) holoParent(3,2) holoDisableShading(3,1) holoCreate(4,vec(9,0,0),OO5,ang(90,0,0),ReticuleColor,ReticleModels[clamp(ReticuleMode,1,7),string]) holoVisible(4,players(),0) holoParent(4,2) holoDisableShading(4,1) holoMaterial(4,"models/wireframe") EngineData = table( #Order - Name, Model, Sound, power in KiloWats, torque in Newtons/meter, Engine Weight, Diesel array("1300cc single","models/engines/1cylb.mdl","^/acf_engines/i1_large.wav",13,20,55,0), array("500cc single","models/engines/1cylm.mdl","^/acf_engines/i1_Medium.wav",29,40,30,0), array("250cc single","models/engines/1cyls.mdl","^/acf_engines/i1_Small.wav",56,90,15,0), array("2400cc V-Twin","models/engines/v-twinb.mdl","^/acf_engines/vtwin_large.wav",92,160,120,0), array("1200cc V-Twin","models/engines/v-twinm.mdl","^/acf_engines/vtwin_Medium.wav",48,85,60,0), array("600cc V-Twin","models/engines/v-twins.mdl","^/acf_engines/vtwin_Small.wav",34,50,40,0), array("Gas Turbine, Large","models/engines/gasturbine_l.mdl","GT.Large",712,1700,1000,0), array("Gas Turbine, Medium","models/engines/gasturbine_m.mdl","^/acf_engines/turbine.wav",251,600,400,0), array("Gas Turbine, Small","models/engines/gasturbine_s.mdl","^/acf_engines/turbine.wav",104,200,150,0), array("Turbine, Large","models/engines/turbine_l.mdl","GT.Large"), array("Turbine, Medium","models/engines/turbine_m.mdl","^/acf_engines/turbine.wav"), array("Turbine, Small","models/engines/turbine_s.mdl","^/acf_engines/turbine.wav"), array("15.0L I4 Diesel","models/engines/inline4l.mdl","I4D.Large",282,1800,1500,1), array("3.1L I4 Diesel","models/engines/inline4m.mdl","I4D.Medium",125,400,350,1), array("1.6L I4 Diesel","models/engines/inline4s.mdl","I4D.Small",47,150,150,1), array("16.0L I4 Petrol","models/engines/inline4l.mdl","I4P.Large",323,950,800,0), array("3.7L I4 Petrol","models/engines/inline4m.mdl","I4P.Medium",188,300,250,0), array("1.5L I4 Petrol","models/engines/inline4s.mdl","I4P.Small",61,90,125,0), array("20.0L I6 Diesel","models/engines/inline6l.mdl","^/acf_engines/l6_diesellarge2.wav",356,2000,1800,1), array("6.5L I6 Diesel","models/engines/inline6m.mdl","L6D.Medium",201,550,650,1), array("3.0L I6 Diesel","models/engines/inline6s.mdl","L6D.Small",75,240,300,1), array("17.2L I6 Petrol","models/engines/inline6l.mdl","^/acf_engines/l6_petrollarge2.wav",403,1100,1000,0), array("4.8L I6 Petrol","models/engines/inline6m.mdl","L6P.Medium",243,400,350,0), array("2.2L I6 Petrol","models/engines/inline6s.mdl","L6P.Small",115,170,250,0), array("24.0L R7 Petrol","models/engines/radial7l.mdl","R7.Large",502,1600,800,0), array("11.0L R7 Petrol","models/engines/radial7m.mdl","R7.Medium",213,550,350,0), array("3.8L R7 Petrol","models/engines/radial7s.mdl","R7.Small",75,160,150,0), array("19.0L V8 Diesel","models/engines/v8l.mdl","V8D.Large",414,2400,2200,1), array("7.8L V8 Diesel","models/engines/v8m.mdl","V8D.Medium",223,710,750,1), array("4.5L V8 Diesel","models/engines/v8s.mdl","V8D.Small",178,340,400,1), array("18.0L V8 Petrol","models/engines/v8l.mdl","V8.Large",446,1420,900,0), array("9.0L V8 Petrol","models/engines/v8m.mdl","V8.Medium",261,350,550,0), array("5.7L V8 Petrol","models/engines/v8s.mdl","V8.Small",178,340,350,0), array("21.0L V12 Diesel","models/engines/v12l.mdl","V12D.Large",439,2800,3000,1), array("9.2L V12 Diesel","models/engines/v12m.mdl","V12D.Medium",345,462,900,1), array("4.0L V12 Diesel","models/engines/v12s.mdl","V12D.Small",117,400,475,1), array("23.0L V12 Petrol","models/engines/v12l.mdl","V12P.Large",565,1800,1500,0), array("7.0L V12 Petrol","models/engines/v12m.mdl","V12P.Medium",326,520,450,0), array("4.6L V12 Petrol","models/engines/v12s.mdl","V12P.Small",196,250,300,0) ) if(->Engine) { for(A = 1,EngineData:count()) { Table = EngineData[A,array] if((Engine:entity():model() == Table[2,string]) & (Table[7,number] == Diesel)) { Name = Table[1,string] EngineSound = Table[3,string] Power = Table[4,number] Torque = Table[5,number] TWeight= Table[6,number] } } } else { Power = EPower Torque = ETorque EngineSound = Sound } Holo1 = holoEntity(1) Cam["Angle",angle] = ang() Cam["Parent",entity] = holoEntity(1) Cam["Position",vector] = vec() for(A = 1,6) { rangerPersist(1) rangerFilter(E:getConstraints()) rangerFilter(players()) } Constraints = E:getConstraints() Mass = E:mass() for(G = 1,Constraints:count()) { Mass += Constraints[G,entity]:mass() } } else { W = Pod["W",number] A = Pod["A",number] S = Pod["S",number] D = Pod["D",number] Alt = Pod["Alt",number] Light = Pod["Light",number] Active = Pod["Active",number] Seat = Pod["Entity",entity] Up = Pod["NextWeapon",number] Dn = Pod["PrevWeapon",number] Speed = E:vel():length() if(!ImpactDeath & ControlMovement) { rangerPersist(1) FrontRight = rangerOffset(Height*2,E:toWorld(vec(SX,-SY,0)),-E:up()) FR = FrontRight:distance() FRP = FrontRight:position() rangerPersist(1) FrontLeft = rangerOffset(Height*2,E:toWorld(vec(SX,SY,0)),-E:up()) FL = FrontLeft:distance() FLP = FrontLeft:position() rangerPersist(1) BackRight = rangerOffset(Height*2,E:toWorld(vec(-SX,-SY,0)),-E:up()) BR = BackRight:distance() BRP = BackRight:position() rangerPersist(1) BackLeft = rangerOffset(Height*2,E:toWorld(vec(-SX,SY,0)),-E:up()) BL = BackLeft:distance() BLP = BackLeft:position() Front = (FL + FR)/2 Rear = (BL + BR)/2 Left = (FL + BL)/2 Right = (FR + BR)/2 AverageH = (( FRP + FLP + BRP + BLP ) / 4):z() + Height AboveGround = ((FR+FL+BR+BL)/4 < (Height + 5)) | (E:angles() > ang(35,360,35)) | (E:angles() < -ang(35,360,35)) if(Speed < 300) {VAffection = Speed/100} else {VAffection = (1/Speed)*600} YawLeft = clamp(YawLeft + A/10 - !A/10,0,1) YawRight = clamp(YawRight + D/10 - !D/10,0,1) if(!Active) {Yaw = 0} else {Yaw = (YawLeft - YawRight) * TurningSpeed * AboveGround * !UnderWater} Pitch = Front - Rear Roll = Right - Left if(AboveGround) { V2 = rotationVector(quat(ang(Pitch,Yaw,Roll)-(E:angVel()/2))) E:applyTorque((90*V2) * E:inertia()) RelativeMass = Mass * ( E:angles():roll() / 30 + 1) ForwardMotion = clamp(Torque - RelativeMass / 50,0,100) * Power Acceleration = Torque / RelativeMass * 60 Throttle = ForwardMotion * (W - S/2) / 200 GTThrottle = Throttle - Acc Acc += clamp(Acceleration,-5,1.5) * clamp(GTThrottle,-1-S,1) Velocity = E:vel()* vec(0.2,0.2,0.5) Z = clamp(AverageH - E:pos():z(),-1,20) E:applyForce((vec(0,0,Z)*20 - Velocity) * E:mass()) E:applyForce(-E:right() * Acc * E:mass() * !UnderWater) Tur:applyForce(vec(0,0,7*Tur:mass())) Bar:applyForce(vec(0,0,7*Bar:mass())) } } EyeAngles = Seat:toLocal(Seat:driver():eyeAngles()) EyePod1 = EyeAngles - EyeSensitivity[2,angle] EyePodYaw = EyePod1:yaw() EyeSensitivity:insertAngle(1,EyeAngles) if(EyeSensitivity:count() > 2) { EyeSensitivity:pop() } if(EyePodYaw > 180) { YawPlus = -360 } elseif(EyePodYaw < -180) { YawPlus = 360 } else { YawPlus = 0 } EyePod = EyePod1 + ang(0,YawPlus,0) if(Alt) {InTimer = clamp(InTimer + 1,0,18)} elseif(!Alt) {InTimer = 0} if(changed(InTimer) & (InTimer == 18)) {AimingMethod = mod(AimingMethod + 1,2)} if(AimingMethod == 0) { EyeX1 = mod(EyeX1 + EyePod:pitch() * (TrueSensitivity + Zoom / 400),360) EyeY1 = mod(EyeY1 + EyePod:yaw() * (TrueSensitivity + Zoom / 400),360) Pos = E:toWorld(ThirdCameraPosition) rangerPersist(1) CamPosition = rangerOffset(Pos,Pos + ThirdCameraRotation:rotate(Eye)) CamWorldPosition = CamPosition:position() + vec(10,0,0):rotate(Eye) holoPos(1,CamWorldPosition) holoAng(1,Eye) holoParent(1,E) } elseif(AimingMethod == 1) { EyeX1 = clamp(mod(EyeX1 + clamp(EyePod:pitch(),-4,4) * (TrueSensitivity + Zoom / 400),360),-BarrelElevation,BarrelDepression) EyeY1 = mod(EyeY1 + clamp(EyePod:yaw(),-4,4) * (TrueSensitivity + Zoom / 400),360) holoPos(1,Tur:toWorld(FirstCameraPosition)) holoAng(1,Bar:angles()) holoParent(1,Tur) } if(Active & Stabalization) { Eye = ang(EyeX1,EyeY1,EyeAngles:roll()) } elseif(Active & !Stabalization) { Eye = E:toWorld(ang(EyeX1,EyeY1,EyeAngles:roll())) } if(!UnderWater) { TurretSet = Eye:setPitch(E:angles():pitch()) TarQ1 = quat(TurretSet) CurQ1 = quat(Tur:angles()) CannonSet = E:toWorld(clamp(E:toLocal(Eye),-ang(BarrelElevation,360,360),ang(BarrelDepression,360,360))) TarQ2 = quat(CannonSet) CurQ2 = quat(Bar:angles()) Q1 = TarQ1/CurQ1 Q2 = TarQ2/CurQ2 V4 = vec(TurretSpeed,TurretSpeed,TurretSpeed) V5 = E:angVelVector() * !Stabalization * TurretSpeed / 50 V2 = clamp(Bar:toLocal(rotationVector(Q2)+Bar:pos()),-V4 + V5,V4 + V5) Bar:applyTorque((300*V2 - 27*Bar:angVelVector())*Bar:inertia()) V1 = clamp(Tur:toLocal(rotationVector(Q1)+Tur:pos()),-V4 + V5,V4 + V5) Tur:applyTorque((300*V1 - 32*Tur:angVelVector())*Tur:inertia()) } Constraints = E:getConstraints() if(changed(Constraints:count())) { Mass = E:mass() for(G = 1,Constraints:count()) { Mass += Constraints[G,entity]:mass() } } if(changed(Light) & Light & FLIR) {FLIRA = !FLIRA Seat:soundPlay(5,1,"/buttons/button16.wav")} Zoom = clamp(Zoom+(Up-Dn)*30,10,100) Cam["Activated",number] = Active Cam["Zoom",number] = Zoom Cam["FLIR",number] = FLIRA rangerPersist(1) GunRanger = rangerOffset(9999999999,Bar:toWorld(vec(Bar:boxSize():x()*1.3,0,0)),Bar:forward()):position() GunPos = ( GunRanger - Holo1:pos() ):toAngle() if(changed(Active) & Active) { holoVisible(3,Seat:driver(),1) holoVisible(4,Seat:driver(),1) holoVisible(5,Seat:driver(),1) Zoom = 100 Engine:entity():setMass(TWeight) } elseif(changed(Active) & !Active) { holoVisible(3,players(),0) holoVisible(4,players(),0) holoVisible(5,players(),0) Eye = Tur:angles() } holoAng(2,GunPos) TurSpeed = E:toLocal(Bar:angles()):yaw() + E:toLocal(Bar:angles()):pitch() Array1:insertNumber(1,TurSpeed) if(Array1:count()>7) { Array1:pop() } Prev = abs( TurSpeed - Array1[7,number] ) Physgun = owner():weapon():type() == "weapon_physgun" & owner():keyAttack1() Array2:insertNumber(1,Speed) if(Array2:count()>7) { Array2:pop() } Crash = (( Speed - Array2[7,number] ) < -600 ) & !Physgun if(changed(E:isUnderWater()) & E:isUnderWater()) { WaterLevel = E:pos():z() } if((E:toWorld(vec(0,0,45)):z() < WaterLevel)) { UnderWater = 1 } else { UnderWater = 0 } if(changed(Crash) & Crash) { ImpactDeath = 1 E:soundPlay(5,1,"ATV_impact_heavy") } if(changed(Prev > 3) & (Prev > 3) & !UnderWater & Active) { Tur:soundPlay(3,1,"/vehicles/tank_turret_start1.wav") Tur:soundPlay(4,0,"/vehicles/tank_turret_loop1.wav") soundVolume(3,0.3) soundVolume(4,0.3) } elseif(changed(Prev < 3) & (Prev < 3) & !UnderWater & Active) { Tur:soundPlay(3,1,"/vehicles/tank_turret_stop1.wav") soundVolume(3,0.3) soundStop(4) } if(ControlMovement) { if(changed(Active) & Active) { E:soundPlay(1,0,"/vehicles/v8/v8_start_loop1.wav") soundPitch(1,EnginePitch*7) timer("start",70*EnginePitch) } elseif((changed(Active) & !Active) & !UnderWater) { E:soundPlay(1,1,"/vehicles/v8/v8_stop1.wav") soundStop(2) } elseif(changed(UnderWater) & UnderWater) { E:soundPlay(1,1,"/vehicles/jetski/jetski_no_gas_start.wav") soundStop(2) } if(clk("start")) { soundStop(1) E:soundPlay(2,0,EngineSound) } } if(changed(Active) & Active) { Seat:hintDriver("This is Verus's Tank Chip",1) Seat:hintDriver("Hold Alt to Change Aiming Modes",5) Seat:hintDriver("Press Light to enable FLIR",7) } AccelerationTank = Speed - Array2[7,number] SpeedPitch = Speed / 11 + clamp(AccelerationTank / Speed * 400,-10,120) + abs(YawRight - YawLeft) * 70 soundPitch(1,EnginePitch*4.5) SP2 = clamp(SpeedPitch*(EnginePitch/30),EnginePitch,150) * Active soundPitch(2,SP2) SV2 = clamp(SpeedPitch*(EnginePitch/1000),0.5,1) soundVolume(2,SV2) } if(dupefinished()) {reset()}