Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name Tank Chip ACF V3 - Automatic RPM Shifting
- @inputs [Pod Gun TurretBase]:entity Active GunLock Zoom Ready
- @outputs XHVec:vector Debug GunLatch PrimaryAmmo Speed SecondaryAmmo TurretRPM
- @inputs W S A D R EngineRPM
- @outputs Throttle ClutchL ClutchR BrakeL BrakeR Gear EngineRPM LL LR
- @persist Clutch TClutch Brake R Speed EngineRPM LSpeed LatchEngageSpeed BrakePower BrakeLeft BrakeRight
- @persist Dran:ranger XH:ranger User:entity A HoloOpacity
- @persist Exclude
- @persist [Trig Sam Sac Fac Trig3 ET ET2]:vector
- @persist TrigTX TrigTY TrigTZ TrigY TrigX TrigZ TrigT XHVec:vector Vel:vector [ETG ETG2]:vector TurretPitchAch TurretPitch RPMPitch TurretRPM
- @persist TurningRate ElevationRate ShootPos:vector Change TreadPitch
- @outputs Reverse
- @persist Pactive LoadPitch
- @persist [Pos Turningf Turningb Force]:vector
- @inputs AmmoSwitch
- @outputs AmmoType CanShift X GearWait
- @persist Aon Aimpower TraverseRate ElevateRate TrackPitch
- @persist SpeedOut
- @persist T1 ETG2X ETG2Y ETG2Z
- @trigger all
- ## Tank Chip ACF V1 by Kickasskyle & Karbine
- ### READ ALL THE FUCKING COMMENTS
- #Changelog:
- #-Added hints for changing ammo
- ## Use the Manual gearbox chip to find shifting speeds for the automatic
- ## IMPORTANT: If you have more than one engine, use the example line below, and add an RPM variable for each engine
- # and divide rpm by the amount of engines. Don't forget to put an input for each rpm (RPM1 RPM2 RPM3 etc)
- #Example:
- #EngineRPM = RPM1+RPM2 / 2
- ## LL and LR are Left Latch Right Latch for low speed weld latching
- ## ALSO IMPORTANT: If your gearbox is not tuned for the automatic yet (shift speeds, use the Debugger to get the Speed output DO NOT RELY ON THE MPH OUTPUT)
- #then wire GearUp and GearDown to your mousewheel and use that for manual shifting. Make sure AutoGearboxEnabled is set to 0 for manual, 1 for automatic.
- #If your turret isn't making sound, make sure you've entity linked it and set the direction correctly
- #Go to line 178 and change the :pitch to :roll or :yaw until it works
- interval(20)
- #Turret Control
- Aimpower = 200
- TraverseRate = 0.03
- ElevateRate = 0.1
- HoloOpacity = 50 #(0-255) #VERY IMPORTANT: When you get in the tank, unlock the gun, and relock it. don't wait to do it after you've taken off.
- #Tread sound
- TreadPitch = 4
- Volume = 30 #Ignore
- #Engine and Gearbox control
- #leave this alone except for high rpm engines; set it to like 1400-1500 for the big-ass diesel engines
- ClutchSmoother = 0.8 #increase this by a tenth (0.1 > 0.5 etc) if you need a smoother clutch
- LatchEngageSpeed = 10 #Max speed for weld latch steering control (shuts off after this speed)
- BrakePower = 40 #Stopping power. Braking is a variable of 0-100, however usually over 40 brakes get spazzy
- BrakeLeft = 80 #Left track stopping power
- BrakeRight = 80 #Right track stopping power
- Speed = entity():vel():length() / 17.6
- TotalGears = 7 # NOT INCLUDING REVERSE
- ReverseGear = 8 # reverse gear (make it after the total gear amount)
- GearChangeWait = 130 # the delay on how fast it can shift up
- MinRPM = 800 # min rpm for clutch engaging
- LowBand = 1400 # rpm min for downshifting
- HighBand = 3300 # max rpm for upshifting
- if(changed(R)&R){
- Reverse=!Reverse
- }
- if(Reverse){Gear=ReverseGear,CanShift=0}else{CanShift=1}
- if(CanShift){
- if(GearWait){X++}
- if(GearWait & X > GearChangeWait){
- GearWait=0
- X=0
- }
- if(changed(Gear) & Gear){GearWait=1}
- if(changed(EngineRPM)&Gear==0|Gear==ReverseGear){Gear=1}
- if(!GearWait & EngineRPM > HighBand){
- if(TotalGears > 2 & Gear==1)
- {Gear=2}
- elseif(TotalGears > 3 & Gear==2)
- {Gear=3}
- elseif(TotalGears > 4 & Gear==3)
- {Gear=4}
- elseif(TotalGears > 5 & Gear==4)
- {Gear=5}
- elseif(TotalGears > 6 & Gear==5)
- {Gear=6}
- elseif(TotalGears > 7 & Gear==6)
- {Gear=7}
- }
- if(EngineRPM < LowBand){
- if(Gear==7){Gear=6}
- elseif(Gear==6){Gear=5}
- elseif(Gear==5){Gear=4}
- elseif(Gear==4){Gear=3}
- elseif(Gear==3){Gear=2}
- elseif(Gear==2){Gear=1}
- }
- }
- #Change the name of the ammo types in the hints if you're using diff. ammo
- if(changed(PrimaryAmmo)&PrimaryAmmo)
- {Pod:hintDriver("AP next load", 5)}
- if(changed(SecondaryAmmo)&SecondaryAmmo)
- {Pod:hintDriver("HE next load", 5)}
- ####### You shouldn't have to edit anything below this
- if(clk()){
- if(W|A|D) {Throttle=100}
- else{Throttle=0}
- #RPM & ClutchControl
- #RPM Monitor
- if(EngineRPM>MinRPM){
- TClutch = clamp(!(W|A|D),0,0.9)
- }else{
- TClutch = 1
- }
- #ClutchSmoother
- Clutch = clamp(TClutch,Clutch-ClutchSmoother,Clutch+ClutchSmoother)
- ClutchR = Clutch
- ClutchL = Clutch
- if(D) {ClutchL=1}
- if(A) {ClutchR=1}
- #lower Brake if shit spacks out
- Brake = BrakeL + BrakeR
- if(S|!Active) {Brake = BrakePower}
- else{Brake = 0}
- if(D) {BrakeL = BrakeLeft} else{BrakeL = Brake}
- if(A) {BrakeR = BrakeRight} else{BrakeR = Brake}
- }
- if(Speed < LatchEngageSpeed){
- Gear=1
- if(D|!Active) {LL = 1} else{LL = 0}
- if(A|!Active) {LR = 1} else{LR = 0}
- }
- else{
- LL = 0
- LR = 0
- }
- if(first()|dupefinished()){
- TurretBase:soundPlay(2,0,"tank/tracks/shilka_tracks.wav")
- TurretBase:soundPlay(3,0,"vehicles/tank_turret_loop1.wav")
- }
- soundPitch(2,TrackPitch)
- soundPitch(3,TurretPitch)
- soundPitch(4,LoadPitch)
- if(changed(Ready)&Ready){
- #ambient/levels/citadel/advisor_lift.wav futury reload sound
- Gun:soundPlay(4,1,"ambient/levels/outland/ol11_blastdoorlatch.wav")
- }
- LoadPitch = 90
- #Constants
- TurretPitchMax = 0.7 *100
- TurretSmoother = 0.03 *100 #Turret Sound Smoother
- RPMPitch = 1 #Amount of RPM before turret sounds activate
- TurretRPM = abs(TurretBase:angVel():yaw()/6)
- if(TurretRPM > RPMPitch) {
- TurretPitchAch = TurretPitchMax
- }
- else {
- TurretPitchAch = 0
- }
- #Smoother
- TurretPitch = clamp(TurretPitch+(TurretPitchAch-TurretPitch),TurretPitch-TurretSmoother,TurretPitch+TurretSmoother)
- if(!Pactive) {GunLatch = 1}
- else {GunLatch = 0}
- if(GunLock & ~GunLock) {Pactive = !Pactive}
- if(!Active) {
- Pactive = 0
- GunLatch = 1
- }
- if(first()|dupefinished())
- {
- Exclude = 1000 #Ignore
- XHExclude = 300 #Ignore
- TurningRate = TraverseRate
- ElevationRate = ElevateRate
- rangerPersist(1)
- rangerFilter(entity():getConstraints())
- ######HOLO CREATION
- holoCreate(1,entity():pos(),vec(0.5,0.5,0.5))
- holoModel(1,"cone")
- holoColor(1,vec(255,0,0),HoloOpacity)
- holoParent(1,Pod)
- #Tank Angles
- holoCreate(2,entity():pos(),vec(0.035,0.2,0.4))
- holoModel(2,"pyramid")
- holoColor(2,vec(125,25,25),175)
- holoMaterial(1,"models/wireframe")
- holoParent(2,Pod)
- }
- #Gun Vectors unlocked
- ET = entity():forward()
- ET2 = $ET
- ET2X = ET2:x()
- ET2Y = ET2:y()
- ET2Z = ET2:z()
- #Gun locking vectors (Put under the originals, they'll look the same should be under if(Pod driver)
- ETG = Gun:forward()
- ETG2 = $ETG
- ETG2X = ETG2:x()
- ETG2Y = ETG2:y()
- ETG2Z = ETG2:z()
- if(Zoom){
- HoloDist = 100
- HoloDist2 = 12
- }else{
- HoloDist = 20 #default was 40
- HoloDist2 = 12
- }
- if(Pactive){
- if(Pod:driver())
- {
- Change = 1
- User= Pod:driver()
- Dran = rangerOffset(30000, User:shootPos() + User:eye() * Exclude, User:eye())
- if($Change){
- ShootPos = Pod:toLocal(User:shootPos())
- }
- if(Gun)
- {
- #Xhair
- XH = rangerOffset(30000, Gun:pos() + Gun:forward() *XHExclude, Gun:forward())
- XHVec = XH:position()+vec(0,0,Zoom)
- XHVec2 = XH:position() - Pod:toWorld(ShootPos)
- #Hologram stuff
- HoloPos = Pod:toWorld(ShootPos) + XHVec2:normalized() * HoloDist
- HoloPos2 = Pod:toWorld(ShootPos) + XHVec2:normalized() * HoloDist2
- holoPos(1,HoloPos)
- holoAng(1,Gun:angles() + ang(90,0,0))
- holoPos(2,(HoloPos2-vec(0,0,1.5) ))
- #switcheroo the angles
- holoAng(2,( ang(entity():angles():pitch()+90 ,entity():angles():yaw() ,0 ) ))
- Trig2 = (Dran:position() - Gun:pos())
- Trig3 = Trig2:normalized()
- #Clamp the speed at which the Normalized vector changes, making a delayed turning
- #Split into 3 Numbers
- TrigX = Trig3:x()
- TrigY = Trig3:y()
- TrigZ = Trig3:z()
- #Add where it wants to aim, to a "delayed" value, that it will slowly obtain.
- TrigTX = clamp(TrigX, TrigTX-TurningRate, TrigTX+TurningRate)+ET2X
- TrigTY = clamp(TrigY, TrigTY-TurningRate, TrigTY+TurningRate)+ET2Y
- TrigTZ = clamp(TrigZ, TrigTZ-ElevationRate, TrigTZ+ElevationRate)+ET2Z
- TrigT = TrigTX+TrigTY+TrigTZ
- Trig = vec(TrigTX,TrigTY,TrigTZ)
- Sam = (Trig) - Gun:forward()
- Sac = (Gun:forward():cross(Sam)):cross(Gun:forward())
- Fac = (Sac + $Sac * 5)*Gun:mass()
- Gun:applyOffsetForce(Fac*50,Gun:pos()+Gun:forward()*Aimpower) #Edit the last number here to change force
- }
- }else{
- holoPos(1,entity():pos())
- holoPos(2,entity():pos())
- Change = 0
- }
- }else{
- TrigTX = TrigTX + ETG2X
- TrigTY = TrigTY + ETG2Y
- TrigTZ = TrigTZ + ETG2Z
- TrigX = TrigTX
- TrigY = TrigTY
- TrigZ = TrigTZ
- TurretPitch = 0
- DDDD = 1
- }
- #Sounds for Tracks (Inbuilt speedo and Smoother)
- if(clk()){
- MPH=toUnit("mph", entity():vel():length())
- TPitch = MPH*TreadPitch
- #Smoother
- TrackPitch = clamp(TPitch,TrackPitch-20,TrackPitch+20)
- }
- if(AmmoSwitch & ~AmmoSwitch) {Aon = !Aon}
- if(Aon) {SecondaryAmmo = 1} else{SecondaryAmmo = 0}
- if(!Aon) {PrimaryAmmo = 1} else{PrimaryAmmo = 0}
- #niggers nigger niggerpenispenispenis
Add Comment
Please, Sign In to add comment