Guest User

Untitled

a guest
Nov 18th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.94 KB | None | 0 0
  1. @name Tank Chip ACF V3 - Automatic RPM Shifting
  2. @inputs [Pod Gun TurretBase]:entity Active GunLock Zoom Ready
  3. @outputs XHVec:vector Debug GunLatch PrimaryAmmo Speed SecondaryAmmo TurretRPM
  4.  
  5. @inputs W S A D R EngineRPM
  6. @outputs Throttle ClutchL ClutchR BrakeL BrakeR Gear EngineRPM LL LR
  7. @persist Clutch TClutch Brake R Speed EngineRPM LSpeed LatchEngageSpeed BrakePower BrakeLeft BrakeRight
  8.  
  9. @persist Dran:ranger XH:ranger User:entity A HoloOpacity
  10. @persist Exclude
  11. @persist [Trig Sam Sac Fac Trig3 ET ET2]:vector
  12. @persist TrigTX TrigTY TrigTZ TrigY TrigX TrigZ TrigT XHVec:vector Vel:vector [ETG ETG2]:vector TurretPitchAch TurretPitch RPMPitch TurretRPM
  13. @persist TurningRate ElevationRate ShootPos:vector Change TreadPitch
  14. @outputs Reverse
  15. @persist Pactive LoadPitch
  16. @persist [Pos Turningf Turningb Force]:vector
  17. @inputs AmmoSwitch
  18. @outputs AmmoType CanShift X GearWait
  19. @persist Aon Aimpower TraverseRate ElevateRate TrackPitch
  20. @persist SpeedOut
  21. @persist T1 ETG2X ETG2Y ETG2Z
  22. @trigger all
  23.  
  24. ## Tank Chip ACF V1 by Kickasskyle & Karbine
  25.  
  26. ### READ ALL THE FUCKING COMMENTS
  27.  
  28. #Changelog:
  29. #-Added hints for changing ammo
  30.  
  31.  
  32.  
  33. ## Use the Manual gearbox chip to find shifting speeds for the automatic
  34.  
  35. ## IMPORTANT: If you have more than one engine, use the example line below, and add an RPM variable for each engine
  36. # and divide rpm by the amount of engines. Don't forget to put an input for each rpm (RPM1 RPM2 RPM3 etc)
  37. #Example:
  38. #EngineRPM = RPM1+RPM2 / 2
  39. ## LL and LR are Left Latch Right Latch for low speed weld latching
  40.  
  41. ## 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)
  42. #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.
  43.  
  44. #If your turret isn't making sound, make sure you've entity linked it and set the direction correctly
  45. #Go to line 178 and change the :pitch to :roll or :yaw until it works
  46.  
  47. interval(20)
  48.  
  49. #Turret Control
  50. Aimpower = 200
  51. TraverseRate = 0.03
  52. ElevateRate = 0.1
  53. 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.
  54.  
  55.  
  56.  
  57.  
  58. #Tread sound
  59. TreadPitch = 4
  60. Volume = 30 #Ignore
  61.  
  62. #Engine and Gearbox control
  63.  
  64. #leave this alone except for high rpm engines; set it to like 1400-1500 for the big-ass diesel engines
  65. ClutchSmoother = 0.8 #increase this by a tenth (0.1 > 0.5 etc) if you need a smoother clutch
  66. LatchEngageSpeed = 10 #Max speed for weld latch steering control (shuts off after this speed)
  67. BrakePower = 40 #Stopping power. Braking is a variable of 0-100, however usually over 40 brakes get spazzy
  68. BrakeLeft = 80 #Left track stopping power
  69. BrakeRight = 80 #Right track stopping power
  70.  
  71.  
  72.  
  73. Speed = entity():vel():length() / 17.6
  74.  
  75.  
  76.  
  77. TotalGears = 7 # NOT INCLUDING REVERSE
  78. ReverseGear = 8 # reverse gear (make it after the total gear amount)
  79. GearChangeWait = 130 # the delay on how fast it can shift up
  80. MinRPM = 800 # min rpm for clutch engaging
  81. LowBand = 1400 # rpm min for downshifting
  82. HighBand = 3300 # max rpm for upshifting
  83.  
  84.  
  85.  
  86.  
  87. if(changed(R)&R){
  88. Reverse=!Reverse
  89. }
  90.  
  91.  
  92. if(Reverse){Gear=ReverseGear,CanShift=0}else{CanShift=1}
  93.  
  94.  
  95.  
  96. if(CanShift){
  97.  
  98. if(GearWait){X++}
  99.  
  100. if(GearWait & X > GearChangeWait){
  101. GearWait=0
  102. X=0
  103. }
  104.  
  105. if(changed(Gear) & Gear){GearWait=1}
  106. if(changed(EngineRPM)&Gear==0|Gear==ReverseGear){Gear=1}
  107.  
  108. if(!GearWait & EngineRPM > HighBand){
  109.  
  110. if(TotalGears > 2 & Gear==1)
  111. {Gear=2}
  112. elseif(TotalGears > 3 & Gear==2)
  113. {Gear=3}
  114. elseif(TotalGears > 4 & Gear==3)
  115. {Gear=4}
  116. elseif(TotalGears > 5 & Gear==4)
  117. {Gear=5}
  118. elseif(TotalGears > 6 & Gear==5)
  119. {Gear=6}
  120. elseif(TotalGears > 7 & Gear==6)
  121. {Gear=7}
  122. }
  123. if(EngineRPM < LowBand){
  124.  
  125.  
  126. if(Gear==7){Gear=6}
  127. elseif(Gear==6){Gear=5}
  128. elseif(Gear==5){Gear=4}
  129. elseif(Gear==4){Gear=3}
  130. elseif(Gear==3){Gear=2}
  131. elseif(Gear==2){Gear=1}
  132.  
  133.  
  134. }
  135. }
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142. #Change the name of the ammo types in the hints if you're using diff. ammo
  143. if(changed(PrimaryAmmo)&PrimaryAmmo)
  144. {Pod:hintDriver("AP next load", 5)}
  145. if(changed(SecondaryAmmo)&SecondaryAmmo)
  146. {Pod:hintDriver("HE next load", 5)}
  147. ####### You shouldn't have to edit anything below this
  148.  
  149.  
  150.  
  151. if(clk()){
  152.  
  153.  
  154. if(W|A|D) {Throttle=100}
  155. else{Throttle=0}
  156.  
  157.  
  158.  
  159.  
  160. #RPM & ClutchControl
  161. #RPM Monitor
  162. if(EngineRPM>MinRPM){
  163. TClutch = clamp(!(W|A|D),0,0.9)
  164. }else{
  165. TClutch = 1
  166. }
  167.  
  168.  
  169. #ClutchSmoother
  170.  
  171. Clutch = clamp(TClutch,Clutch-ClutchSmoother,Clutch+ClutchSmoother)
  172. ClutchR = Clutch
  173. ClutchL = Clutch
  174.  
  175. if(D) {ClutchL=1}
  176. if(A) {ClutchR=1}
  177. #lower Brake if shit spacks out
  178. Brake = BrakeL + BrakeR
  179. if(S|!Active) {Brake = BrakePower}
  180. else{Brake = 0}
  181.  
  182. if(D) {BrakeL = BrakeLeft} else{BrakeL = Brake}
  183. if(A) {BrakeR = BrakeRight} else{BrakeR = Brake}
  184.  
  185. }
  186. if(Speed < LatchEngageSpeed){
  187. Gear=1
  188. if(D|!Active) {LL = 1} else{LL = 0}
  189. if(A|!Active) {LR = 1} else{LR = 0}
  190. }
  191. else{
  192. LL = 0
  193. LR = 0
  194. }
  195.  
  196.  
  197.  
  198. if(first()|dupefinished()){
  199.  
  200.  
  201. TurretBase:soundPlay(2,0,"tank/tracks/shilka_tracks.wav")
  202. TurretBase:soundPlay(3,0,"vehicles/tank_turret_loop1.wav")
  203. }
  204.  
  205. soundPitch(2,TrackPitch)
  206. soundPitch(3,TurretPitch)
  207. soundPitch(4,LoadPitch)
  208.  
  209.  
  210.  
  211. if(changed(Ready)&Ready){
  212. #ambient/levels/citadel/advisor_lift.wav futury reload sound
  213. Gun:soundPlay(4,1,"ambient/levels/outland/ol11_blastdoorlatch.wav")
  214. }
  215. LoadPitch = 90
  216.  
  217.  
  218. #Constants
  219. TurretPitchMax = 0.7 *100
  220. TurretSmoother = 0.03 *100 #Turret Sound Smoother
  221. RPMPitch = 1 #Amount of RPM before turret sounds activate
  222.  
  223. TurretRPM = abs(TurretBase:angVel():yaw()/6)
  224. if(TurretRPM > RPMPitch) {
  225. TurretPitchAch = TurretPitchMax
  226. }
  227.  
  228. else {
  229. TurretPitchAch = 0
  230. }
  231. #Smoother
  232. TurretPitch = clamp(TurretPitch+(TurretPitchAch-TurretPitch),TurretPitch-TurretSmoother,TurretPitch+TurretSmoother)
  233.  
  234.  
  235.  
  236.  
  237. if(!Pactive) {GunLatch = 1}
  238. else {GunLatch = 0}
  239.  
  240. if(GunLock & ~GunLock) {Pactive = !Pactive}
  241.  
  242. if(!Active) {
  243. Pactive = 0
  244. GunLatch = 1
  245. }
  246.  
  247. if(first()|dupefinished())
  248. {
  249. Exclude = 1000 #Ignore
  250. XHExclude = 300 #Ignore
  251. TurningRate = TraverseRate
  252. ElevationRate = ElevateRate
  253. rangerPersist(1)
  254. rangerFilter(entity():getConstraints())
  255.  
  256. ######HOLO CREATION
  257. holoCreate(1,entity():pos(),vec(0.5,0.5,0.5))
  258. holoModel(1,"cone")
  259. holoColor(1,vec(255,0,0),HoloOpacity)
  260. holoParent(1,Pod)
  261. #Tank Angles
  262. holoCreate(2,entity():pos(),vec(0.035,0.2,0.4))
  263. holoModel(2,"pyramid")
  264. holoColor(2,vec(125,25,25),175)
  265. holoMaterial(1,"models/wireframe")
  266. holoParent(2,Pod)
  267.  
  268. }
  269.  
  270. #Gun Vectors unlocked
  271. ET = entity():forward()
  272. ET2 = $ET
  273. ET2X = ET2:x()
  274. ET2Y = ET2:y()
  275. ET2Z = ET2:z()
  276.  
  277. #Gun locking vectors (Put under the originals, they'll look the same should be under if(Pod driver)
  278. ETG = Gun:forward()
  279. ETG2 = $ETG
  280. ETG2X = ETG2:x()
  281. ETG2Y = ETG2:y()
  282. ETG2Z = ETG2:z()
  283.  
  284. if(Zoom){
  285. HoloDist = 100
  286. HoloDist2 = 12
  287. }else{
  288. HoloDist = 20 #default was 40
  289. HoloDist2 = 12
  290. }
  291.  
  292.  
  293. if(Pactive){
  294. if(Pod:driver())
  295. {
  296. Change = 1
  297. User= Pod:driver()
  298. Dran = rangerOffset(30000, User:shootPos() + User:eye() * Exclude, User:eye())
  299.  
  300.  
  301.  
  302. if($Change){
  303. ShootPos = Pod:toLocal(User:shootPos())
  304. }
  305.  
  306. if(Gun)
  307. {
  308. #Xhair
  309. XH = rangerOffset(30000, Gun:pos() + Gun:forward() *XHExclude, Gun:forward())
  310. XHVec = XH:position()+vec(0,0,Zoom)
  311. XHVec2 = XH:position() - Pod:toWorld(ShootPos)
  312. #Hologram stuff
  313. HoloPos = Pod:toWorld(ShootPos) + XHVec2:normalized() * HoloDist
  314. HoloPos2 = Pod:toWorld(ShootPos) + XHVec2:normalized() * HoloDist2
  315. holoPos(1,HoloPos)
  316. holoAng(1,Gun:angles() + ang(90,0,0))
  317. holoPos(2,(HoloPos2-vec(0,0,1.5) ))
  318. #switcheroo the angles
  319. holoAng(2,( ang(entity():angles():pitch()+90 ,entity():angles():yaw() ,0 ) ))
  320.  
  321. Trig2 = (Dran:position() - Gun:pos())
  322. Trig3 = Trig2:normalized()
  323. #Clamp the speed at which the Normalized vector changes, making a delayed turning
  324. #Split into 3 Numbers
  325. TrigX = Trig3:x()
  326. TrigY = Trig3:y()
  327. TrigZ = Trig3:z()
  328. #Add where it wants to aim, to a "delayed" value, that it will slowly obtain.
  329. TrigTX = clamp(TrigX, TrigTX-TurningRate, TrigTX+TurningRate)+ET2X
  330. TrigTY = clamp(TrigY, TrigTY-TurningRate, TrigTY+TurningRate)+ET2Y
  331. TrigTZ = clamp(TrigZ, TrigTZ-ElevationRate, TrigTZ+ElevationRate)+ET2Z
  332.  
  333. TrigT = TrigTX+TrigTY+TrigTZ
  334.  
  335. Trig = vec(TrigTX,TrigTY,TrigTZ)
  336.  
  337. Sam = (Trig) - Gun:forward()
  338. Sac = (Gun:forward():cross(Sam)):cross(Gun:forward())
  339. Fac = (Sac + $Sac * 5)*Gun:mass()
  340.  
  341. Gun:applyOffsetForce(Fac*50,Gun:pos()+Gun:forward()*Aimpower) #Edit the last number here to change force
  342. }
  343.  
  344. }else{
  345. holoPos(1,entity():pos())
  346. holoPos(2,entity():pos())
  347. Change = 0
  348. }
  349. }else{
  350. TrigTX = TrigTX + ETG2X
  351. TrigTY = TrigTY + ETG2Y
  352. TrigTZ = TrigTZ + ETG2Z
  353. TrigX = TrigTX
  354. TrigY = TrigTY
  355. TrigZ = TrigTZ
  356. TurretPitch = 0
  357. DDDD = 1
  358. }
  359.  
  360.  
  361. #Sounds for Tracks (Inbuilt speedo and Smoother)
  362. if(clk()){
  363. MPH=toUnit("mph", entity():vel():length())
  364.  
  365.  
  366. TPitch = MPH*TreadPitch
  367.  
  368.  
  369.  
  370.  
  371.  
  372. #Smoother
  373. TrackPitch = clamp(TPitch,TrackPitch-20,TrackPitch+20)
  374.  
  375. }
  376.  
  377. if(AmmoSwitch & ~AmmoSwitch) {Aon = !Aon}
  378. if(Aon) {SecondaryAmmo = 1} else{SecondaryAmmo = 0}
  379. if(!Aon) {PrimaryAmmo = 1} else{PrimaryAmmo = 0}
  380.  
  381.  
  382.  
  383. #niggers nigger niggerpenispenispenis
Add Comment
Please, Sign In to add comment